Mercurial > lcfOS
comparison cos/kernel/video.c @ 23:5dd47d6eebac
Added ubersimple malloc algorithm
author | windel |
---|---|
date | Thu, 01 Dec 2011 21:42:59 +0100 |
parents | 6129643f5c34 |
children | d8627924d40d |
comparison
equal
deleted
inserted
replaced
22:69bc6d477b38 | 23:5dd47d6eebac |
---|---|
4 | 4 |
5 #define NUM_COLS 80 | 5 #define NUM_COLS 80 |
6 #define NUM_ROWS 25 | 6 #define NUM_ROWS 25 |
7 #define SCREEN_SIZE (NUM_COLS * NUM_ROWS) | 7 #define SCREEN_SIZE (NUM_COLS * NUM_ROWS) |
8 | 8 |
9 #define SCREEN_ATTR 0x0F | |
10 | |
11 static int row, col; | 9 static int row, col; |
10 uint8_t video_color = 0x1F; | |
12 | 11 |
13 void move_cursor() | 12 void move_cursor() |
14 { | 13 { |
15 uint16_t cursorLocation = row * 80 + col; | 14 uint16_t cursorLocation = row * 80 + col; |
16 outb(0x3D4, 14); | 15 outb(0x3D4, 14); |
25 unsigned char *vidmem = (unsigned char *) VIDMEM; | 24 unsigned char *vidmem = (unsigned char *) VIDMEM; |
26 int loop; | 25 int loop; |
27 | 26 |
28 for (loop = 0; loop < SCREEN_SIZE; loop++) { | 27 for (loop = 0; loop < SCREEN_SIZE; loop++) { |
29 *vidmem++ = 0x20; | 28 *vidmem++ = 0x20; |
30 *vidmem++ = SCREEN_ATTR; | 29 *vidmem++ = video_color; |
31 } | 30 } |
32 } | 31 } |
33 | 32 |
34 void | 33 void |
35 init_screen() | 34 init_screen() |
51 *v = *(v + NUM_COLS); | 50 *v = *(v + NUM_COLS); |
52 ++v; | 51 ++v; |
53 } | 52 } |
54 | 53 |
55 for (v = (unsigned short*) VIDMEM + n, i = 0; i < NUM_COLS; i++) { | 54 for (v = (unsigned short*) VIDMEM + n, i = 0; i < NUM_COLS; i++) { |
56 *v++ = SCREEN_ATTR & (0x20 << 8); | 55 *v++ = (video_color << 8) & 0x20; |
57 } | 56 } |
58 } | 57 } |
59 | 58 |
60 static void | 59 static void |
61 new_line() | 60 new_line() |
74 int loop; | 73 int loop; |
75 unsigned char *v = (unsigned char *) ((uint64_t)(VIDMEM + row * NUM_COLS * 2 + col * 2)); | 74 unsigned char *v = (unsigned char *) ((uint64_t)(VIDMEM + row * NUM_COLS * 2 + col * 2)); |
76 | 75 |
77 for (loop = col; loop < NUM_COLS; loop++) { | 76 for (loop = col; loop < NUM_COLS; loop++) { |
78 *v++ = ' '; | 77 *v++ = ' '; |
79 *v++ = SCREEN_ATTR; | 78 *v++ = video_color; |
80 } | 79 } |
81 } | 80 } |
82 | 81 |
83 static void | 82 static void |
84 print_char(int c) | 83 print_char(int c) |
90 clear_to_EOL(); | 89 clear_to_EOL(); |
91 new_line(); | 90 new_line(); |
92 break; | 91 break; |
93 default: | 92 default: |
94 *v++ = (unsigned char) c; | 93 *v++ = (unsigned char) c; |
95 *v = SCREEN_ATTR; | 94 *v = video_color; |
96 | 95 |
97 if (col < NUM_COLS - 1) | 96 if (col < NUM_COLS - 1) |
98 ++col; | 97 ++col; |
99 else | 98 else |
100 new_line(); | 99 new_line(); |