8426a661dd1ad2d5ccefe357a714d41fcd154a6b
[3sys] / sys1 / kern / src / main.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdint.h>
4 #include "vga.h"
5 #include "mem.h"
6
7 void drawtext(int x, int y, const char *s)
8 {
9         while(*s) {
10                 vga_drawchar(x++, y, *s++);
11         }
12 }
13
14 void kmain(void)
15 {
16         int i, row;
17         int line, scroll;
18         char buf[64];
19         char twirl[] = "-\\|/";
20
21         vga_reset();
22
23         mem_init();
24         intr_init();
25
26         line = 0;
27         for(;;) {
28                 scroll = line <= 24 ? 0 : line - 24;
29                 row = line <= 24 ? line : 24;
30                 sprintf(buf, "line %d  (scroll %d [%d])", line, scroll, scroll % 25);
31                 vga_scroll(scroll);
32                 if(scroll) {
33                         vga_clearline(24);
34                 }
35                 vga_setcolor(VGA_YELLOW | VGA_BRIGHT, VGA_BLACK);
36                 drawtext(line & 7, row, buf);
37
38                 for(i=0; i<65536 * 16; i++) {
39                         buf[0] = twirl[(i >> 15) & 3];
40                         buf[1] = 0;
41                         vga_setcolor(VGA_WHITE, VGA_BLACK);
42                         drawtext(50, row, buf);
43                 }
44                 line++;
45         }
46 }