Printing whole strings to screen

This commit is contained in:
Jarkko Toivanen 2023-09-24 01:39:22 +03:00
parent b077a17fa4
commit f0243cb45e
Signed by: jt
GPG key ID: 9151B109B73ECAD5
3 changed files with 25 additions and 14 deletions

View file

@ -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++;
}
}

View file

@ -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,

View file

@ -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");