3d89aa957ef11bd3760f3e486d0f485ff5a27e37
[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
25         line = 0;
26         for(;;) {
27                 scroll = line <= 24 ? 0 : line - 24;
28                 row = line <= 24 ? line : 24;
29                 sprintf(buf, "line %d  (scroll %d [%d])", line, scroll, scroll % 25);
30                 vga_scroll(scroll);
31                 if(scroll) {
32                         vga_clearline(24);
33                 }
34                 vga_setcolor(VGA_YELLOW | VGA_BRIGHT, VGA_BLACK);
35                 drawtext(line & 7, row, buf);
36
37                 for(i=0; i<65536 * 16; i++) {
38                         buf[0] = twirl[(i >> 15) & 3];
39                         buf[1] = 0;
40                         vga_setcolor(VGA_WHITE, VGA_BLACK);
41                         drawtext(50, row, buf);
42                 }
43                 line++;
44         }
45 }