ADDED SCROLLING!!!!!\n(It's so fucking slow)

This commit is contained in:
2024-05-02 14:41:12 +02:00
parent 07ac2caeb7
commit 0fbb5aae07
2 changed files with 33 additions and 3 deletions
+3 -3
View File
@@ -17,7 +17,7 @@ os: $(BUILD) filesystem
@echo "\nDone!\n"
# Filesystem
filesystem: $(BUILD)/boot.bin $(BUILD)/kernel.bin $(C_FILES) $(FONTS)
filesystem: bootloader kernel $(C_FILES) $(FONTS)
@echo "Building filesystem..."
@$(AS) -fbin -o $(BUILD)/filetable.bin $(SRC)/filetable.asm
@dd if=/dev/zero of=kern.iso bs=512 count=2880 status=none
@@ -35,7 +35,7 @@ $(BUILD):
@rm -rf $(BUILD)/*
# Bootloader: This target is responsible for creating boot.bin
$(BUILD)/boot.bin: $(SRC)/stage1.asm $(SRC)/stage2.asm
bootloader: $(SRC)/stage1.asm $(SRC)/stage2.asm
@echo "Assembling $(SRC)/stage1.asm..."
@$(AS) -fbin -o $(BUILD)/stage1.bin $(SRC)/stage1.asm
@echo "Assembling $(SRC)/stage2.asm..."
@@ -43,7 +43,7 @@ $(BUILD)/boot.bin: $(SRC)/stage1.asm $(SRC)/stage2.asm
@cat $(BUILD)/stage1.bin $(BUILD)/stage2.bin > $(BUILD)/boot.bin
# Kernel: This target is responsible for creating kernel.bin
$(BUILD)/kernel.bin: $(SRC)/kernel.c $(SRC)/entry.asm
kernel: $(SRC)/kernel.c $(SRC)/entry.asm
@echo "Assembling $(SRC)/entry.asm..."
@$(AS) -felf32 -o $(BUILD)/entry.o $(SRC)/entry.asm
@echo "Compiling $(SRC)/kernel.c..."
+30
View File
@@ -2,6 +2,7 @@
#define SCREEN_H
#include "stdint.h"
#include "string.h"
#define MODE_INFO_BLOCK 0x9000
#define BG_COLOR 0x00010b17
@@ -123,6 +124,33 @@ 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)
uint8_t charHeight = *(font + 1);
if ((cursor.y+1) * charHeight < gfxMode->yRes) { return; } // Check if we should scroll
uint32_t bytesPerLine = charHeight * gfxMode->bytesPerScanline;
uint32_t lines = gfxMode->yRes / charHeight;
uint32_t vidmem = gfxMode->physicalBasePtr;
for (uint32_t i = 1; i < lines; i++) {
uint32_t address = vidmem + i * bytesPerLine;
memcopy((char*)address, (char*)(address - bytesPerLine), bytesPerLine);
}
uint32_t color = convertColor(bgColor);
uint8_t* lastLine = (uint8_t*)(vidmem + (lines-1) * bytesPerLine);
uint8_t bytesPerPx = (gfxMode->bpp+1) / 8;
for (uint32_t i = 0; i < bytesPerLine; i++) {
for (uint8_t j = 0; j < bytesPerPx; j++) {
lastLine[j] = (uint8_t)(color >> (j * 8));
}
lastLine += bytesPerPx;
}
cursor.y--;
}
void putc(char c) {
uint8_t charWidth = *(font);
@@ -150,6 +178,8 @@ void putc(char c) {
cursor.x = 0;
}
}
scroll();
}
void print(const char* str) {