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;
|
static u8* Frame_Buffer = (u8*)FRAME_BUFFER_ADDR;
|
||||||
s32 Frame_Buffer_Cursor = 0x0000;
|
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
|
// Writes character to a given cell in the framebuffer
|
||||||
// @cell parameter is the logical (linear)index into the buffer
|
// @cell parameter is the logical (linear)index into the buffer
|
||||||
void write_cell_fb(u8 c, u8 fg, u8 bg) {
|
void write_cell_fb(u8 c, u8 fg, u8 bg) {
|
||||||
|
@ -39,7 +39,8 @@
|
|||||||
|
|
||||||
extern s32 Frame_Buffer_Cursor;
|
extern s32 Frame_Buffer_Cursor;
|
||||||
|
|
||||||
// Serial wrapper for
|
void frame_buffer_newline();
|
||||||
|
|
||||||
void write_cell_fb(u8, u8, u8);
|
void write_cell_fb(u8, u8, u8);
|
||||||
|
|
||||||
void clear_fb(void);
|
void clear_fb(void);
|
||||||
|
25
stlio.c
25
stlio.c
@ -1,6 +1,5 @@
|
|||||||
#include "stlio.h"
|
#include "stlio.h"
|
||||||
|
|
||||||
static const char _line[52] = {" "};
|
|
||||||
// We are assuming null-terminated strings here
|
// We are assuming null-terminated strings here
|
||||||
u64 strlen(char* buffer) {
|
u64 strlen(char* buffer) {
|
||||||
char* c;
|
char* c;
|
||||||
@ -14,8 +13,10 @@ void putch(const char c) {
|
|||||||
u64 write(const char* buffer, const u64 size) {
|
u64 write(const char* buffer, const u64 size) {
|
||||||
u64 i;
|
u64 i;
|
||||||
for(i = 0; i < size; i++) {
|
for(i = 0; i < size; i++) {
|
||||||
|
// cheesy but whatever
|
||||||
if(buffer[i] == '\n') {
|
if(buffer[i] == '\n') {
|
||||||
write(_line, sizeof(_line));
|
frame_buffer_newline();
|
||||||
|
//write(_line, sizeof(_line));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
write_cell_fb(buffer[i], Green, White);
|
write_cell_fb(buffer[i], Green, White);
|
||||||
@ -29,23 +30,17 @@ u64 read(const u64 n) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printf(const s8* fmt, ...) {
|
void printf(char* fmt) {
|
||||||
u64 i = 0;
|
u64 i;
|
||||||
char c = *fmt;
|
for(i = 0; i < strlen(fmt);i++) {
|
||||||
while(c != '\0') {
|
char c = fmt[i];
|
||||||
/* Check for some kind of contol character
|
|
||||||
* for now we just have \n and \t
|
|
||||||
*/
|
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case '\n': {
|
case '\n': {
|
||||||
write(_line, sizeof(_line));
|
frame_buffer_newline();
|
||||||
}
|
break;
|
||||||
case '%': {
|
|
||||||
continue; // eventually there will be more support but for now lmao nah
|
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
putch(fmt[i]);
|
putch(c);
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
stlio.h
2
stlio.h
@ -5,4 +5,4 @@
|
|||||||
u64 strlen(char*);
|
u64 strlen(char*);
|
||||||
u64 write(const char*, const u64);
|
u64 write(const char*, const u64);
|
||||||
u64 read(const u64);
|
u64 read(const u64);
|
||||||
void printf(const s8*, ...);
|
void printf(char*);
|
||||||
|
3
tests.c
3
tests.c
@ -7,6 +7,7 @@ void test_write() {
|
|||||||
clear_fb();
|
clear_fb();
|
||||||
char* msg1 = "Imagine literally not \nwriting your own os";
|
char* msg1 = "Imagine literally not \nwriting your own os";
|
||||||
serial_write((signed char*)msg1, strlen(msg1));
|
serial_write((signed char*)msg1, strlen(msg1));
|
||||||
|
serial_write((signed char*)msg1, strlen(msg1));
|
||||||
//write(msg1, strlen(msg1));
|
//write(msg1, strlen(msg1));
|
||||||
printf((signed char*)msg1);
|
printf(msg1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user