forked from PoliEcho-holding-org/kern
Imporved text.h
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# Config
|
||||||
|
make.config
|
||||||
|
|
||||||
# Binaries
|
# Binaries
|
||||||
bin/
|
bin/
|
||||||
*.bin
|
*.bin
|
||||||
@@ -7,9 +10,14 @@ makedisk
|
|||||||
|
|
||||||
# Object files
|
# Object files
|
||||||
*.o
|
*.o
|
||||||
|
*.out
|
||||||
*.obj
|
*.obj
|
||||||
*.elf
|
*.elf
|
||||||
|
|
||||||
|
# Font source files
|
||||||
|
src/fonts/**.asm
|
||||||
|
|
||||||
# Vim swap files
|
# Vim swap files
|
||||||
*.swp
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
uint8_t width;
|
uint8_t width;
|
||||||
uint8_t height
|
uint8_t height;
|
||||||
} __attribute__ ((packed)) info;
|
};
|
||||||
uint8_t data[4096];
|
uint8_t data[4096];
|
||||||
} __attribute__ ((packed)) font_t;
|
} __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) {
|
void drawChar(char c, uint32_t x, uint32_t y, uint32_t fgColor, uint32_t bgColor) {
|
||||||
// Font info
|
// Font info
|
||||||
font_t* font = (font_t*)FONT_LOC;
|
font_t* font = (font_t*)FONT_LOC;
|
||||||
uint8_t charWidth = font->info.width;
|
uint8_t charWidth = font->width;
|
||||||
uint8_t charHeight = font->info.height;
|
uint8_t charHeight = font->height;
|
||||||
// uint8_t bitmapRowLen = (charWidth - 1) / 8 + 1; // TODO: Larger font support
|
// uint8_t bitmapRowLen = (charWidth - 1) / 8 + 1; // TODO: Larger font support
|
||||||
|
|
||||||
// Video stuff
|
// 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;
|
uint8_t* vidmem = (uint8_t*)gfxMode->physicalBasePtr;
|
||||||
uint32_t offset = (gfxMode->xRes * y * charHeight + x * charWidth) * bytesPerPx;
|
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
|
for (uint8_t i = 0; i < charHeight; i++) { // Rows
|
||||||
char bitmapRow = bitmap[i];
|
char bitmapRow = bitmap[i];
|
||||||
uint32_t color = convertColor((bitmapRow & 0x80) ? fgColor : bgColor);
|
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)
|
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
|
if (terminal->y+1 < terminal->height) { return; } // Check if we should scroll
|
||||||
|
|
||||||
uint32_t bytesPerLine = charHeight * gfxMode->bytesPerScanline;
|
uint32_t bytesPerLine = charHeight * gfxMode->bytesPerScanline;
|
||||||
|
|||||||
@@ -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
|
#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) {
|
int32_t terminalWrite(const void* buf, uint32_t len) {
|
||||||
terminal->width = gfxMode->xRes / *(uint8_t*)FONT_WIDTH;
|
terminal->width = gfxMode->xRes / *(uint8_t*)(FONT_LOC);
|
||||||
terminal->height = gfxMode->yRes / *(uint8_t*)FONT_HEIGHT;
|
terminal->height = gfxMode->yRes / *(uint8_t*)(FONT_LOC+1);
|
||||||
|
|
||||||
char* str = (char*)buf;
|
char* str = (char*)buf;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|||||||
@@ -93,8 +93,6 @@ void main() {
|
|||||||
// Run Interactive Shell Program
|
// Run Interactive Shell Program
|
||||||
// TODO: Make it in another file
|
// TODO: Make it in another file
|
||||||
while (1) {
|
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);
|
printf("\e[6M\e[8N%s \e[2M%s \e[8M", cwd, PROMPT);
|
||||||
char input[256];
|
char input[256];
|
||||||
char* inputPtr = input;
|
char* inputPtr = input;
|
||||||
|
|||||||
Reference in New Issue
Block a user