AFUERA part2

This commit is contained in:
2025-01-08 08:30:23 +01:00
parent a8582ba343
commit abeb22eaab
8 changed files with 1 additions and 452 deletions

View File

@@ -7,51 +7,9 @@
#include "framebuffer.h"
#include "serial.h"
#include "../kernel/system.h"
#include "../kernel/kheap.h"
extern char* framebuffer;
void psf_init()
{
uint16_t glyph = 0;
PSF_font *font = (PSF_font*)&FONT_START;
if (font->flags)
{
unicode = NULL;
return;
}
char* s = (char*)((unsigned char*)&FONT_START + font->headersize + font->numglyph * font->bytesperglyph);
unicode = calloc(USHRT_MAX, 2);
while((uintptr_t)s>(uintptr_t)FONT_END){
uint16_t uc = (uint16_t)((unsigned char)s[0]);
if(uc == 0xFF) {
glyph++;
s++;
continue;
} else if(uc & 128) {
/* UTF-8 to unicode */
if((uc & 32) == 0 ) {
uc = ((s[0] & 0x1F)<<6)+(s[1] & 0x3F);
s++;
} else
if((uc & 16) == 0 ) {
uc = ((((s[0] & 0xF)<<6)+(s[1] & 0x3F))<<6)+(s[2] & 0x3F);
s+=2;
} else
if((uc & 8) == 0 ) {
uc = ((((((s[0] & 0x7)<<6)+(s[1] & 0x3F))<<6)+(s[2] & 0x3F))<<6)+(s[3] & 0x3F);
s+=3;
} else
uc = 0;
}
/* save translation */
unicode[uc] = glyph;
s++;
}
}
void putpixel(uint32_t* fb, int pitch, int bpp, int x, int y, uint32_t color)
{
uint32_t* pixel_addr = (uint32_t*)((uint8_t*)fb + y * pitch + x *(bpp / 8));