ansicon: allow to pass page # to write functions
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Tue, 11 Aug 2009 15:58:19 +0000 (08:58 -0700)
committerPierre-Alexandre Meyer <pierre@mouraf.org>
Tue, 1 Sep 2009 18:43:37 +0000 (11:43 -0700)
Some video modes support up to 8 different pages, the current one being
stored at 0x462.

The display page value is passed in BH when invoking the INT 10h Video
Service routines. This patch changes the interface of ansicon_write_char
and ansicon_set_cursor to allow the caller to specify the page.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
com32/lib/sys/ansi.c
com32/lib/sys/ansi.h
com32/lib/sys/ansicon_write.c

index 7d58085..43b3b65 100644 (file)
@@ -123,7 +123,7 @@ void __ansi_putchar(const struct term_info *ti, uint8_t ch)
                if (st->vtgraphics && (ch & 0xe0) == 0x60)
                    ch = decvt_to_cp437[ch - 0x60];
 
-               op->write_char(xy.x, xy.y, ch, st);
+               op->write_char(xy.x, xy.y, BIOS_PAGE, ch, st);
                xy.x++;
            }
            break;
@@ -430,6 +430,6 @@ void __ansi_putchar(const struct term_info *ti, uint8_t ch)
     }
 
     /* Update cursor position */
-    op->set_cursor(xy.x, xy.y, st->cursor);
+    op->set_cursor(xy.x, xy.y, BIOS_PAGE, st->cursor);
     st->xy = xy;
 }
index 0d1f102..1e03424 100644 (file)
@@ -9,6 +9,11 @@
 
 #define ANSI_MAX_PARMS 16
 
+#define BIOS_CURXY ((struct curxy *)0x450)     /* Array for each page */
+#define BIOS_ROWS (*(uint8_t *)0x484)  /* Minus one; if zero use 24 (= 25 lines) */
+#define BIOS_COLS (*(uint16_t *)0x44A) /* Number of columns on screen */
+#define BIOS_PAGE (*(uint8_t *)0x462)  /* Current page number  */
+
 enum ansi_state {
     st_init,
     st_esc,
@@ -43,10 +48,10 @@ struct term_state {
 struct ansi_ops {
     void (*erase) (const struct term_state * st, int x0, int y0, int x1,
                   int y1);
-    void (*write_char) (int x, int y, uint8_t ch, const struct term_state * st);
+    void (*write_char) (int x, int y, int page, uint8_t ch, const struct term_state * st);
     void (*showcursor) (const struct term_state * st);
     void (*scroll_up) (const struct term_state * st);
-    void (*set_cursor) (int x, int y, int visible);
+    void (*set_cursor) (int x, int y, int page, int visible);
     void (*beep) (void);
 };
 
index 7c2754e..8ec16b0 100644 (file)
 #include "ansi.h"
 
 static void ansicon_erase(const struct term_state *, int, int, int, int);
-static void ansicon_write_char(int, int, uint8_t, const struct term_state *);
+static void ansicon_write_char(int, int, int, uint8_t, const struct term_state *);
 static void ansicon_showcursor(const struct term_state *);
 static void ansicon_scroll_up(const struct term_state *);
-static void ansicon_set_cursor(int, int, int);
+static void ansicon_set_cursor(int, int, int, int);
 
 static struct term_state ts;
 struct ansi_ops __ansicon_ops = {
@@ -65,11 +65,6 @@ static struct term_info ti = {
     .op = &__ansicon_ops
 };
 
-#define BIOS_CURXY ((struct curxy *)0x450)     /* Array for each page */
-#define BIOS_ROWS (*(uint8_t *)0x484)  /* Minus one; if zero use 24 (= 25 lines) */
-#define BIOS_COLS (*(uint16_t *)0x44A)
-#define BIOS_PAGE (*(uint8_t *)0x462)
-
 /* Reference counter to the screen, to keep track of if we need
    reinitialization. */
 static int ansicon_counter = 0;
@@ -176,9 +171,8 @@ static void ansicon_showcursor(const struct term_state *st)
     __intcall(0x10, &ireg, NULL);
 }
 
-static void ansicon_set_cursor(int x, int y, int visible)
+static void ansicon_set_cursor(int x, int y, int page, int visible)
 {
-    const int page = BIOS_PAGE;
     struct curxy xy = BIOS_CURXY[page];
     static com32sys_t ireg;
 
@@ -193,16 +187,16 @@ static void ansicon_set_cursor(int x, int y, int visible)
     }
 }
 
-static void ansicon_write_char(int x, int y, uint8_t ch,
+static void ansicon_write_char(int x, int y, int page, uint8_t ch,
                               const struct term_state *st)
 {
     static com32sys_t ireg;
 
-    ansicon_set_cursor(x, y, 0);
+    ansicon_set_cursor(x, y, 0, page);
 
     ireg.eax.b[1] = 0x09;
     ireg.eax.b[0] = ch;
-    ireg.ebx.b[1] = BIOS_PAGE;
+    ireg.ebx.b[1] = page;
     ireg.ebx.b[0] = ansicon_attribute(st);
     ireg.ecx.w[0] = 1;
     __intcall(0x10, &ireg, NULL);