X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=sys1%2Fkern%2Fsrc%2Fmain.c;h=00d3882b0cb59db2d39f3dae61272cdeb185f913;hb=a9ac2db02f009e086df85d25dc9b32452f259538;hp=b89a98bedd89733077833cbd7a81943987448711;hpb=570cc7602962c08b173754d25af50c43b75c2f2f;p=3sys diff --git a/sys1/kern/src/main.c b/sys1/kern/src/main.c index b89a98b..00d3882 100644 --- a/sys1/kern/src/main.c +++ b/sys1/kern/src/main.c @@ -1,22 +1,42 @@ +#include #include #include - -void clearscr(void) -{ - memset((void*)0xb8000, 0, 80 * 25 * 2); -} +#include "vga.h" void drawtext(int x, int y, const char *s) { - uint16_t *vptr = (uint16_t*)0xb8000 + y * 80 + x; - while(*s) { - *vptr++ = 0x0c00 | *s++; + vga_drawchar(x++, y, *s++); } } void kmain(void) { - clearscr(); - drawtext(10, 5, "3sys kernel 1"); + int i, row; + int line, scroll; + char buf[64]; + char twirl[] = "-\\|/"; + + vga_reset(); + + line = 0; + for(;;) { + scroll = line <= 24 ? 0 : line - 24; + row = line <= 24 ? line : 24; + sprintf(buf, "line %d (scroll %d [%d])", line, scroll, scroll % 25); + vga_scroll(scroll); + if(scroll) { + vga_clearline(24); + } + vga_setcolor(VGA_YELLOW | VGA_BRIGHT, VGA_BLACK); + drawtext(line & 7, row, buf); + + for(i=0; i<65536 * 4; i++) { + buf[0] = twirl[(i >> 18) & 3]; + buf[1] = 0; + vga_setcolor(VGA_WHITE, VGA_BLACK); + drawtext(50, row, buf); + } + line++; + } }