Implemented a proper libk

This commit is contained in:
2024-10-09 16:45:37 +02:00
parent 9ff817b935
commit 95d32f025a
45 changed files with 1713 additions and 1524 deletions
+2 -14
View File
@@ -65,20 +65,8 @@ typedef struct modeInfoBlock_s {
uint8_t reserved4[190];
} __attribute__ ((packed)) modeInfoBlock_t;
static modeInfoBlock_t* gfxMode = (modeInfoBlock_t*)MODE_INFO_BLOCK_LOC;
extern modeInfoBlock_t* gfxMode;
uint32_t convertColor(uint32_t color) {
if (gfxMode->bpp == 8) { // Uses VGA Color pallete, idk how to support that
return color & 0xff;
}
// TODO: !! Important !! - Is should be divided by 255.0 (for floats), but using '-mgeneral-regs-only' removes fp-registers and
// wants to use some dumb functions for converting fp numbers in the stdlib (that we don't have)
uint8_t red = ((color >> 16) & 0xff) * (((1 << gfxMode->linearRedMaskSize) - 1) / 255);
uint8_t green = ((color >> 8 ) & 0xff) * (((1 << gfxMode->linearGreenMaskSize) - 1) / 255);
uint8_t blue = ((color ) & 0xff) * (((1 << gfxMode->linearBlueMaskSize) - 1) / 255);
return (red << gfxMode->redFieldPos) | (green << gfxMode->greenFieldPos) | (blue << gfxMode->blueFieldPos);
}
uint32_t convertColor(uint32_t color);
#endif