static int curx, cury, scroll;
+#define CURSTACK_SIZE 16
+static unsigned int savecur[CURSTACK_SIZE];
+static int savecur_top;
+
static void newline(void);
curx = cury = scroll = 0;
tbuf_first = tbuf_last = 0;
memset(textbuf[0], 0, sizeof textbuf[0]);
+
+ savecur_top = 0;
+}
+
+void con_setcur(int x, int y)
+{
+ curx = x < 0 ? 0 : (x >= NCOLS ? NCOLS - 1 : x);
+ cury = y < 0 ? 0 : (y >= NROWS ? NROWS - 1 : y);
+}
+
+void con_getcur(int *x, int *y)
+{
+ *x = curx;
+ *y = cury;
+}
+
+void con_pushcur(void)
+{
+ if(savecur_top >= CURSTACK_SIZE) return;
+
+ savecur[savecur_top++] = curx | (cury << 16);
+}
+
+void con_popcur(void)
+{
+ if(savecur_top <= 0) return;
+
+ savecur_top--;
+ curx = savecur[savecur_top] & 0xffff;
+ cury = savecur[savecur_top] >> 16;
}
void con_putchar(int c)
void con_init(void);
void con_reset(void);
-#define con_color(fg, bg) vga_setcolor(fg, bg)
+#define con_setcolor(fg, bg) vga_setcolor(fg, bg)
+
+void con_setcur(int x, int y);
+void con_getcur(int *x, int *y);
+void con_pushcur(void);
+void con_popcur(void);
void con_putchar(int c);
for(;;) {
printf("line %d", line++);
- for(i=0; i<65536 * 128; i++) {
- if((i & 0x3ffff) == 0) {
- con_putchar('.');
+ con_pushcur();
+ con_setcur(30, 0);
+ for(i=0; i<65536 * 300; i++) {
+ if((i & 0xfffff) == 0) {
+ con_setcolor(VGA_BRIGHT | (line & 7), VGA_BLACK);
+ con_putchar('>');
}
}
+ con_setcolor(VGA_WHITE, VGA_BLACK);
+ con_popcur();
con_putchar('\n');
}
}