+#include <stdio.h>
#include <string.h>
#include <stdint.h>
-
-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 * 16; i++) {
+ buf[0] = twirl[(i >> 15) & 3];
+ buf[1] = 0;
+ vga_setcolor(VGA_WHITE, VGA_BLACK);
+ drawtext(50, row, buf);
+ }
+ line++;
+ }
}