39 lines
636 B
C
39 lines
636 B
C
#include "include/screen.h"
|
|
#include "../os3_common/datatypes.h"
|
|
#include "../os3_common/packing.h"
|
|
|
|
int x = 0;
|
|
int y = 0;
|
|
|
|
void write_character(char c) {
|
|
os_u16 color_byte = 0x0A;
|
|
os_u16* vram = (os_u16*) 0xB8000;
|
|
os_u16* cursor_pos = vram + ((y * 80) + x);
|
|
*cursor_pos = c | (color_byte << 8);
|
|
}
|
|
|
|
void write_string(const char* str, int max_len) {
|
|
int i = 0;
|
|
do {
|
|
char c = *str;
|
|
if (c == 0) {
|
|
return;
|
|
}
|
|
|
|
if (c == '\n') {
|
|
y = (y + 1) % 25;
|
|
x = 0;
|
|
str++;
|
|
continue;
|
|
}
|
|
|
|
write_character(c);
|
|
x++;
|
|
if (x >= 80) {
|
|
y = (y + 1) % 25;
|
|
x = 0;
|
|
}
|
|
str++;
|
|
i++;
|
|
} while(i < max_len || max_len == 0);
|
|
}
|