Imporved text.h

This commit is contained in:
2024-10-05 15:13:36 +02:00
parent 1b1276f89f
commit 9ff817b935
5 changed files with 16 additions and 10 deletions
+8
View File
@@ -1,5 +1,8 @@
.DS_Store
# Config
make.config
# Binaries
bin/
*.bin
@@ -7,9 +10,14 @@ makedisk
# Object files
*.o
*.out
*.obj
*.elf
# Font source files
src/fonts/**.asm
# Vim swap files
*.swp
*.swo
+6 -6
View File
@@ -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;
+2 -2
View File
@@ -24,8 +24,8 @@ terminal_t* terminal = (terminal_t*)TERMINAL_INFO_LOC;
#include <screen/text.h> // This needs to be here because it uses 'terminal' and otherwise it would be undeclared
int32_t terminalWrite(const void* buf, uint32_t len) {
terminal->width = gfxMode->xRes / *(uint8_t*)FONT_WIDTH;
terminal->height = gfxMode->yRes / *(uint8_t*)FONT_HEIGHT;
terminal->width = gfxMode->xRes / *(uint8_t*)(FONT_LOC);
terminal->height = gfxMode->yRes / *(uint8_t*)(FONT_LOC+1);
char* str = (char*)buf;
uint32_t i;
BIN
View File
Binary file not shown.
-2
View File
@@ -93,8 +93,6 @@ void main() {
// Run Interactive Shell Program
// TODO: Make it in another file
while (1) {
for (size_t i = 0; i < 0x20; i++) drawChar(0x70+i, i, 0, FG_COLOR, BG_COLOR);
printf("\e[6M\x80");
printf("\e[6M\e[8N%s \e[2M%s \e[8M", cwd, PROMPT);
char input[256];
char* inputPtr = input;