mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-04 02:23:10 +00:00
Imporved text.h
This commit is contained in:
@@ -10,8 +10,8 @@
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t width;
|
||||
uint8_t height
|
||||
} __attribute__ ((packed)) info;
|
||||
uint8_t height;
|
||||
};
|
||||
uint8_t data[4096];
|
||||
} __attribute__ ((packed)) font_t;
|
||||
|
||||
@@ -19,8 +19,8 @@ typedef union {
|
||||
void drawChar(char c, uint32_t x, uint32_t y, uint32_t fgColor, uint32_t bgColor) {
|
||||
// Font info
|
||||
font_t* font = (font_t*)FONT_LOC;
|
||||
uint8_t charWidth = font->info.width;
|
||||
uint8_t charHeight = font->info.height;
|
||||
uint8_t charWidth = font->width;
|
||||
uint8_t charHeight = font->height;
|
||||
// uint8_t bitmapRowLen = (charWidth - 1) / 8 + 1; // TODO: Larger font support
|
||||
|
||||
// Video stuff
|
||||
@@ -28,7 +28,7 @@ void drawChar(char c, uint32_t x, uint32_t y, uint32_t fgColor, uint32_t bgColor
|
||||
uint8_t* vidmem = (uint8_t*)gfxMode->physicalBasePtr;
|
||||
uint32_t offset = (gfxMode->xRes * y * charHeight + x * charWidth) * bytesPerPx;
|
||||
|
||||
char* bitmap = &font.data[(c - 1) * charHeight];
|
||||
uint8_t* bitmap = &font->data[(c - 1) * charHeight];
|
||||
for (uint8_t i = 0; i < charHeight; i++) { // Rows
|
||||
char bitmapRow = bitmap[i];
|
||||
uint32_t color = convertColor((bitmapRow & 0x80) ? fgColor : bgColor);
|
||||
@@ -48,7 +48,7 @@ void drawChar(char c, uint32_t x, uint32_t y, uint32_t fgColor, uint32_t bgColor
|
||||
}
|
||||
|
||||
void scroll() { // TODO: Make this faster (still kinda slow, but memcpy32() helped alot)
|
||||
uint8_t charHeight = *(uint8_t*)FONT_HEIGHT;
|
||||
uint8_t charHeight = ((font_t*)FONT_LOC)->height;
|
||||
if (terminal->y+1 < terminal->height) { return; } // Check if we should scroll
|
||||
|
||||
uint32_t bytesPerLine = charHeight * gfxMode->bytesPerScanline;
|
||||
|
||||
Reference in New Issue
Block a user