summaryrefslogtreecommitdiff
path: root/kernel/kernel.c
blob: 665455db981cfe8c6dfae391b8562b308d51aaf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#define SCR_WIDTH 80
#define SCR_HEIGHT 23

#define SCR_CTRL 0x3D4
#define SCR_DATA 0x3D5

#define SCR_BLACK 0x0
#define SCR_BLUE 0x1
#define SCR_GREEN 0x2
#define SCR_CYAN 0x3
#define SCR_RED 0x4
// todo...
# define SCR_WHITE 0xf



void print_char(int x, int y, char c, char col)
{
    char* video_mem=(char *)0xb8000+(x+y*SCR_WIDTH)*2;
    video_mem[0]=c;
    video_mem[1]=col;
}

float func(float x,float y)
{
    return x*x*y;
}

void clear_screen()
{
    int x=0;
    int y=0;

    for(x=0;x<SCR_WIDTH;x++)
	for(y=2;y<SCR_HEIGHT;y++)
	    print_char(x,y,'R',SCR_BLACK);
}

void sleep(int i)
{
    int x;

    for(x=0;x<i;x++)
    {
	__asm__("nop");

    }
}

void kernel_main()
{

    int col=0;
    
    while(1)
    {

	print_char(0,0,'*',col++%0xf);
	int0();
	
    }
    
}

void kernel_main_joke()
{ 
    
    float time=0;
    int col=0; 
    int x;

    while(1)
    {
	time++;
	print_char(0,0,'R',col++%0xf);
	for(x=0;x<SCR_WIDTH;x++)
	{
	    print_char(x,(2+(int)func((float)x,0.002*(time/100)))%(SCR_HEIGHT-2),'R',SCR_BLUE);
	}
	if(time>300)time=0;
	
    }

}

int cursor=0;
void int0()
{
    int i=0;
    char codes[]={ 0x1e,0x30,0x2e,0x23,0x24,0x2b,0x34,0x33,0x43,0x3b,0x42,0x4b,0x3a,0x31,0x44,0x43,0x15,0x2d,0x1b,0x2c,0x3c,0x2a,0x1d,0x22,0x35,0x1a};

    char* int_count=(char *)0x7c00+3;

    for(i=0;i<24;i++){
  	if(codes[i]==*int_count)
	print_char(10,10,'A'+i,0xf);
    }
    
}