Weird runes?

This commit is contained in:
xamidev
2024-08-19 12:50:17 +02:00
parent a2a7ab52a1
commit 6ce5264b43
5 changed files with 601 additions and 1 deletions

31
src/drivers/framebuffer.c Normal file
View File

@@ -0,0 +1,31 @@
#include "../libc/stdint.h"
#include "framebuffer.h"
//extern uint32_t *g_framebuffer;
void putpixel(uint32_t* fb, int pitch, int bpp, int x, int y, uint32_t color) // framebuffer pointer, x, y, color
{
if (bpp == 32) {
uint32_t* pixel_addr = (uint32_t*)((uint8_t*)fb + y * pitch + x *(bpp / 8));
*pixel_addr = color;
}
}
void draw_char(uint32_t* fb, int pitch, int bpp, int x, int y, char c, uint32_t fg_color, uint32_t bg_color)
{
const unsigned char* glyph = font[(unsigned char)c];
int glyph_width = 8;
int glyph_height = 16;
for (int py=0; py < glyph_height; py++)
{
for (int px=0; px < glyph_width; px++)
{
if (glyph[py] & (0x80 >> px)) {
putpixel(fb, pitch, bpp, x+px, y+py, fg_color);
} else {
putpixel(fb, pitch, bpp, x+px, y+py, bg_color);
}
}
}
}