-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.c
62 lines (55 loc) · 966 Bytes
/
print.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "print.h"
static unsigned char *videoram = (unsigned char *) 0xb8000;
static int xpos = 0, ypos = 0;
inline void
add_newline()
{
xpos = 0;
ypos++;
}
inline void
put_char(char c)
{
videoram[ypos*80+xpos] = c;
videoram[ypos*80+xpos+1] = 0x07;
xpos += 2;
if(xpos > 80) {
add_newline();
}
}
void
print(char* string)//, int len)
{
int cur_char = 0;
while(string[cur_char] != 0) {
//put_char(string[cur_char], videoram);
//videoram += 2;
if(string[cur_char] == '\n') {
add_newline();
cur_char++;
continue;
}
put_char(string[cur_char]);
cur_char++;
}
}
void
print_hex(int input)
{
short shift = 28;
while(shift >= 0) {
put_char(((input & (0xF << shift)) >> shift) + 48);
shift -= 4;
}
add_newline();
}
void clear_screen()
{
xpos = 0;
ypos = 0;
while(ypos < 25) {
put_char(' ');
}
xpos = 0;
ypos = 0;
}