-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo.c
41 lines (35 loc) · 957 Bytes
/
video.c
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
#include "video.h"
void clear_screen(void)
{
unsigned int i = 0;
// this loop clears the screen
while(i < 80 * 25 * 2)
{
VIDEO_TEXT_MODE_PTR[i] = ' ';
VIDEO_TEXT_MODE_PTR[i + 1] = 0x07; // light grey
i = i + 2;
}
}
void print_char(char c, unsigned int x, unsigned int y, unsigned char color)
{
unsigned int index = (80 * y + x) * 2;
VIDEO_TEXT_MODE_PTR[index] = c;
VIDEO_TEXT_MODE_PTR[index + 1] = color;
}
void print_string(char * str, unsigned int x, unsigned int y, unsigned char color)
{
unsigned int i = 0;
unsigned int index = (80 * y + x) * 2;
if (str == 0 || x > 80 || y > 25)
{
return;
}
// this loop writes the string to video mem at the specified position
while(str[i] != '\0' && index < 80 * 25 * 2)
{
VIDEO_TEXT_MODE_PTR[index] = str[i];
VIDEO_TEXT_MODE_PTR[index + 1] = color;
++i;
index = index + 2;
}
}