Fixing putc and puts to use pointers correctly

This commit is contained in:
Jarkko Toivanen 2023-09-24 20:46:39 +03:00
parent f0243cb45e
commit 2c6826e293
Signed by: jt
GPG key ID: 9151B109B73ECAD5
2 changed files with 17 additions and 11 deletions

View file

@ -1,6 +1,7 @@
#include "framebuffer.h"
#include "font8x8_basic.h"
#include "serial.h"
#include "xtoa.h"
static unsigned long fb_address;
static unsigned long fb_pitch;
@ -48,8 +49,8 @@ void putpixel(
}
}
static void putc(
const unsigned char character,
void putc(
const unsigned char *character,
unsigned short x,
unsigned short y,
unsigned char r,
@ -57,16 +58,13 @@ static void putc(
unsigned char b
){
// Limit to ASCII printable
if (character < 0x20) {
serial_write_string("\nASCII too low");
return;
}
if (character > 0x7e) {
serial_write_string("\nASCII too hihg");
if (*character < 0x20 || *character > 0x7e) {
serial_write_string("\nputc ASCII out of range: ");
serial_write_string(uitoa(*character, 16));
return;
}
unsigned char *rowdata = font8x8_basic[character];
unsigned char *rowdata = font8x8_basic[*character];
unsigned char charx, chary, iy, ix;
unsigned char sizex=1;
unsigned char sizey=1;
@ -94,7 +92,7 @@ void puts(
){
unsigned char i = 0;
while (text[i]) {
putc(text[i], x+i*8, y, r, g, b);
putc(text+i, x+i*8, y, r, g, b);
i++;
}
}

View file

@ -17,7 +17,15 @@ void putpixel(
unsigned char r,
unsigned char g,
unsigned char b
);
);
void putc(
const unsigned char *character,
unsigned short x,
unsigned short y,
unsigned char r,
unsigned char g,
unsigned char b
);
void puts(
const unsigned char *text,
unsigned short x,