blob: 9b51a751b78dc2ce474c7c422bea39da9d8474d2 (
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
|
#ifndef CONSOLE_C
#define CONSOLE_C
#include <toast.h>
/*********************************************************
* Set up the console buffer and pointer
********************************************************/
void console_init()
{
console_buffer = (char*)0xB8000;
console_pointer = 0;
}
/*********************************************************
* Update flashing cursor to match console_position
* Note: Does _NOT_ dictate the pos for next printed byte
********************************************************/
void console_update_cursor()
{
outb(0x3D4, 0x0F);
outb(0x3D5, ((console_pointer/2) & 0xFF));
outb(0x3D4, 0x0E);
outb(0x3D5, (((console_pointer/2)>>8)&0xFF));
}
/*********************************************************
* Clear the console with the current colour scheme
********************************************************/
void console_clear()
{
int console_pointer;
for (console_pointer = 0; console_pointer < 4000; console_pointer++)
{
console_buffer[console_pointer] = console_color;
console_buffer[console_pointer++] = 0;
}
//console_update_cursor();
}
/*********************************************************
* Set the console foreground and background colours
********************************************************/
void console_set_colors(uint8_t fg, uint8_t bg)
{
console_color = (bg << 4) | fg;
}
/*********************************************************
* Set the console foreground colour
********************************************************/
void console_set_color(uint8_t fg)
{
console_color &= 0xF0; // Zero-out foreground color
console_color |= fg; // Apply foreground color
}
/*********************************************************
* Print a null-terminated string to the text screen
********************************************************/
void console_print(char *string)
{
uint16_t i;
for (i = 0; i < strlen(string); i++)
{
// If special char, handle appropriately
if (string[i] < 32)
{
switch (string[i])
case 10:
console_pointer = 160 + (console_pointer / 160) * 160;
} else {
console_buffer[console_pointer++] = string[i];
console_buffer[console_pointer++] = console_color;
}
}
console_update_cursor();
}
#endif
|