mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Made scrolling substantually faster
This commit is contained in:
@@ -8,7 +8,7 @@ CFLAGS = -ffreestanding -m32 -Iinclude -Wall -Wextra
|
||||
SRC = ./src
|
||||
BUILD = ./build
|
||||
C_FILES = calc
|
||||
FONTS = testfont term16n
|
||||
FONTS = testfont term16n term18n
|
||||
|
||||
.PHONY: os clean run
|
||||
|
||||
|
||||
+8
-4
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -263,7 +263,7 @@ void main() {
|
||||
print("Loading ");
|
||||
print(filename);
|
||||
print("...\n");
|
||||
memcopy(address, font, size * 512);
|
||||
memcpy(address, font, size * 512);
|
||||
print("Font loaded\n");
|
||||
} else {
|
||||
for (size_t i = 0; i < size * 512; i++) {
|
||||
|
||||
Reference in New Issue
Block a user