61 lines
1.1 KiB
C
61 lines
1.1 KiB
C
#include "stlio.h"
|
|
|
|
static u8 COLOR_FG = Green;
|
|
static u8 COLOR_BG = White;
|
|
|
|
// We are assuming null-terminated strings here
|
|
u64 strlen(char* buffer) {
|
|
char* c;
|
|
for(c = buffer; *c != '\0'; c++); // LULW
|
|
return (u64)(c - buffer);
|
|
}
|
|
void putch(const char c) {
|
|
write_cell_fb(c, COLOR_FG, COLOR_BG);
|
|
}
|
|
|
|
u64 write(const char* buffer, const u64 size) {
|
|
u64 i;
|
|
for(i = 0; i < size; i++) {
|
|
// cheesy but whatever
|
|
if(buffer[i] == '\n') {
|
|
frame_buffer_newline();
|
|
//write(_line, sizeof(_line));
|
|
}
|
|
else {
|
|
write_cell_fb(buffer[i], COLOR_FG, COLOR_BG);
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
u64 read(const u64 n) {
|
|
// read n bytes from keyboard
|
|
return n;
|
|
}
|
|
|
|
void printf(char* fmt) {
|
|
u64 i;
|
|
u64 size = strlen(fmt);
|
|
for(i = 0; i < size;i++) {
|
|
char c = fmt[i];
|
|
switch(c) {
|
|
case '\n': {
|
|
frame_buffer_newline();
|
|
break;
|
|
}
|
|
case '%': {
|
|
/* only do something if the situation calls for it
|
|
* NOTE: this call might not do anything interesting
|
|
*/
|
|
if((i+1) < size) {
|
|
write_cell_fb(fmt[c], COLOR_FG, COLOR_BG);
|
|
i += 2;
|
|
}
|
|
}
|
|
default: {
|
|
putch(c);
|
|
}
|
|
}
|
|
}
|
|
}
|