Made scrolling substantually faster

This commit is contained in:
2024-05-02 17:37:58 +02:00
parent 5d67e12fe2
commit 906ce6d160
4 changed files with 21 additions and 10 deletions
+8 -4
View File
@@ -93,10 +93,14 @@ uint32_t convertColor(uint32_t color) {
// TODO: Reimplement larger text
// TODO: Support different bpps (and still keep the colors the same)
void putcAt(unsigned char c, uint32_t x, uint32_t y) {
uint8_t* vidmem = (uint8_t*)gfxMode->physicalBasePtr;
uint8_t bytesPerPx = (gfxMode->bpp+1) / 8;
// Font info
uint8_t charWidth = *(font);
uint8_t charHeight = *(font + 1);
// uint8_t bitmapRowLen = (charWidth - 1) / 8 + 1; // TODO: Larger font support
// Video stuff
uint8_t bytesPerPx = (gfxMode->bpp+1) / 8;
uint8_t* vidmem = (uint8_t*)gfxMode->physicalBasePtr;
uint32_t offset = (gfxMode->xRes * y * charHeight + x * charWidth) * bytesPerPx;
char* bitmap = &font[((c % 128) - 1) * charHeight];
@@ -124,7 +128,7 @@ void printAt(const char* str, uint32_t x, uint32_t y) {
}
}
void scroll() { // TODO: Make this fast (same as everything else, it's extremely slow)
void scroll() { // TODO: Make this faster (still kinda slow)
uint8_t charHeight = *(font + 1);
if ((cursor.y+1) * charHeight < gfxMode->yRes) { return; } // Check if we should scroll
@@ -134,7 +138,7 @@ void scroll() { // TODO: Make this fast (same as everything else, it's extremely
for (uint32_t i = 1; i < lines; i++) {
uint32_t address = vidmem + i * bytesPerLine;
memcopy((char*)address, (char*)(address - bytesPerLine), bytesPerLine);
memcpy32((char*)address, (char*)(address - bytesPerLine), bytesPerLine);
}
uint32_t color = convertColor(bgColor);
+11 -4
View File
@@ -82,16 +82,23 @@ uint32_t strlen(const char* str) {
}
// Memory functions
char* memcopy(char* src, char* dst, uint32_t length) {
void* memcpy(void* src, void* dst, uint32_t length) {
for (uint32_t i = 0; i < length; i++) {
*(dst + i) = *(src + i);
*((uint8_t*)dst + i) = *((uint8_t*)src + i);
}
return dst;
}
char* memset(char* dst, char value, uint32_t length) {
void* memcpy32(void* src, void* dst, uint32_t length) {
for (uint32_t i = 0; i * 4 < length; i++) {
*((uint32_t*)dst + i) = *((uint32_t*)src + i);
}
return dst;
}
void* memset(void* dst, uint8_t value, uint32_t length) {
for (uint32_t i = 0; i < length; i++) {
*(dst + i) = value;
*(uint8_t*)(dst + i) = value;
}
return dst;
}