From f0243cb45e10e7e9c3c10956c4d51c478ff293fd Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Sun, 24 Sep 2023 01:39:22 +0300 Subject: [PATCH] Printing whole strings to screen --- src/framebuffer.c | 29 ++++++++++++++++++++++------- src/framebuffer.h | 4 ++-- src/kernel.c | 6 +----- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/framebuffer.c b/src/framebuffer.c index 35b73b5..1e19efa 100644 --- a/src/framebuffer.c +++ b/src/framebuffer.c @@ -48,8 +48,8 @@ void putpixel( } } -void putc( - unsigned char *character, +static void putc( + const unsigned char character, unsigned short x, unsigned short y, unsigned char r, @@ -57,19 +57,19 @@ void putc( unsigned char b ){ // Limit to ASCII printable - if (*character < 0x20) { + if (character < 0x20) { serial_write_string("\nASCII too low"); return; } - if (*character > 0x7e) { + if (character > 0x7e) { serial_write_string("\nASCII too hihg"); return; } - unsigned char *rowdata = font8x8_basic[*character]; + unsigned char *rowdata = font8x8_basic[character]; unsigned char charx, chary, iy, ix; - unsigned char sizex=5; - unsigned char sizey=5; + unsigned char sizex=1; + unsigned char sizey=1; for (chary=0;chary<8;chary++) { for (charx=0;charx<8;charx++) { unsigned char pix = rowdata[chary] & 1 << charx; @@ -83,3 +83,18 @@ void putc( } } } + +void puts( + const unsigned char *text, + unsigned short x, + unsigned short y, + unsigned char r, + unsigned char g, + unsigned char b +){ + unsigned char i = 0; + while (text[i]) { + putc(text[i], x+i*8, y, r, g, b); + i++; + } +} diff --git a/src/framebuffer.h b/src/framebuffer.h index 96ed6d7..8066375 100644 --- a/src/framebuffer.h +++ b/src/framebuffer.h @@ -18,8 +18,8 @@ void putpixel( unsigned char g, unsigned char b ); -void putc( - unsigned char *character, +void puts( + const unsigned char *text, unsigned short x, unsigned short y, unsigned char r, diff --git a/src/kernel.c b/src/kernel.c index 1fab654..1f5766d 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -87,11 +87,7 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) } } - putc("r", 412, 5, 0xff, 0xff, 0xff); - putc("O", 452, 5, 0xff, 0xff, 0xff); - putc("S", 492, 5, 0xff, 0xff, 0xff); - putc("k", 532, 5, 0xff, 0xff, 0xff); - putc("a", 572, 5, 0xff, 0xff, 0xff); + puts("rOSka", 0, 0, 0xff, 0x00, 0x00); //while(1){} serial_write_string("\nExecution finished, halting...\n");