newlines kinda working, multiple newlines are still annoying to do but oh well
This commit is contained in:
parent
c72ac8bf3b
commit
57bb696228
@ -12,6 +12,16 @@
|
||||
static u8* Frame_Buffer = (u8*)FRAME_BUFFER_ADDR;
|
||||
s32 Frame_Buffer_Cursor = 0x0000;
|
||||
|
||||
void frame_buffer_newline() {
|
||||
while(Frame_Buffer_Cursor != (AREA*2)) {
|
||||
if((Frame_Buffer_Cursor % 160) == 0) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
Frame_Buffer_Cursor++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Writes character to a given cell in the framebuffer
|
||||
// @cell parameter is the logical (linear)index into the buffer
|
||||
void write_cell_fb(u8 c, u8 fg, u8 bg) {
|
||||
|
@ -39,7 +39,8 @@
|
||||
|
||||
extern s32 Frame_Buffer_Cursor;
|
||||
|
||||
// Serial wrapper for
|
||||
void frame_buffer_newline();
|
||||
|
||||
void write_cell_fb(u8, u8, u8);
|
||||
|
||||
void clear_fb(void);
|
||||
|
25
stlio.c
25
stlio.c
@ -1,6 +1,5 @@
|
||||
#include "stlio.h"
|
||||
|
||||
static const char _line[52] = {" "};
|
||||
// We are assuming null-terminated strings here
|
||||
u64 strlen(char* buffer) {
|
||||
char* c;
|
||||
@ -14,8 +13,10 @@ void putch(const char c) {
|
||||
u64 write(const char* buffer, const u64 size) {
|
||||
u64 i;
|
||||
for(i = 0; i < size; i++) {
|
||||
// cheesy but whatever
|
||||
if(buffer[i] == '\n') {
|
||||
write(_line, sizeof(_line));
|
||||
frame_buffer_newline();
|
||||
//write(_line, sizeof(_line));
|
||||
}
|
||||
else {
|
||||
write_cell_fb(buffer[i], Green, White);
|
||||
@ -29,23 +30,17 @@ u64 read(const u64 n) {
|
||||
return n;
|
||||
}
|
||||
|
||||
void printf(const s8* fmt, ...) {
|
||||
u64 i = 0;
|
||||
char c = *fmt;
|
||||
while(c != '\0') {
|
||||
/* Check for some kind of contol character
|
||||
* for now we just have \n and \t
|
||||
*/
|
||||
void printf(char* fmt) {
|
||||
u64 i;
|
||||
for(i = 0; i < strlen(fmt);i++) {
|
||||
char c = fmt[i];
|
||||
switch(c) {
|
||||
case '\n': {
|
||||
write(_line, sizeof(_line));
|
||||
}
|
||||
case '%': {
|
||||
continue; // eventually there will be more support but for now lmao nah
|
||||
frame_buffer_newline();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
putch(fmt[i]);
|
||||
i++;
|
||||
putch(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
stlio.h
2
stlio.h
@ -5,4 +5,4 @@
|
||||
u64 strlen(char*);
|
||||
u64 write(const char*, const u64);
|
||||
u64 read(const u64);
|
||||
void printf(const s8*, ...);
|
||||
void printf(char*);
|
||||
|
Loading…
Reference in New Issue
Block a user