From 0fbb5aae07bbaf316bf114d72d28ffc2a9a19d8e Mon Sep 17 00:00:00 2001 From: Tom-on64 Date: Thu, 2 May 2024 14:41:12 +0200 Subject: [PATCH] ADDED SCROLLING!!!!!\n(It's so fucking slow) --- Makefile | 6 +++--- include/screen.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7b29bdc..8ce2faf 100644 --- a/Makefile +++ b/Makefile @@ -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..." diff --git a/include/screen.h b/include/screen.h index 0bb4c90..4589c42 100644 --- a/include/screen.h +++ b/include/screen.h @@ -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) {