forked from PoliEcho-holding-org/kern
Fixed boundaryFill (sorta, circle is still broken, idk why)
This commit is contained in:
@@ -12,19 +12,23 @@ C_FILES = calc
|
||||
.PHONY: os clean run
|
||||
|
||||
# Main compilation target
|
||||
os: $(BUILD) bootloader kernel $(C_FILES)
|
||||
os: $(BUILD) bootloader kernel $(C_FILES) filesystem
|
||||
@echo "\nDone!\n"
|
||||
|
||||
# Filesystem
|
||||
filesystem:
|
||||
@echo "Assembling $(SRC)/testfont.asm..."
|
||||
@$(AS) -fbin -o $(BUILD)/testfont.bin $(SRC)/testfont.asm
|
||||
@echo "Building filesystem..."
|
||||
@$(AS) -fbin -o $(BUILD)/filetable.bin $(SRC)/filetable.asm
|
||||
@cat $(BUILD)/boot.bin $(BUILD)/filetable.bin $(BUILD)/kernel.bin > $(BUILD)/os.bin
|
||||
@echo "Building kern.iso..."
|
||||
@dd if=/dev/zero of=kern.iso bs=512 count=2880 status=none
|
||||
@dd if=$(BUILD)/os.bin of=kern.iso conv=notrunc status=none
|
||||
@dd if=$(BUILD)/testfont.bin of=kern.iso bs=512 seek=36 conv=notrunc status=none
|
||||
@dd if=$(SRC)/fs/test.txt of=kern.iso bs=512 seek=40 conv=notrunc status=none
|
||||
@dd if=$(BUILD)/calc.bin of=kern.iso bs=512 seek=41 conv=notrunc status=none
|
||||
@echo "\nDone!\n"
|
||||
# TODO: Make this not so manual
|
||||
@dd if=$(BUILD)/boot.bin of=kern.iso bs=512 seek=0 conv=notrunc status=none
|
||||
@dd if=$(BUILD)/filetable.bin of=kern.iso bs=512 seek=5 conv=notrunc status=none
|
||||
@dd if=$(BUILD)/kernel.bin of=kern.iso bs=512 seek=6 conv=notrunc status=none
|
||||
@dd if=$(BUILD)/testfont.bin of=kern.iso bs=512 seek=36 conv=notrunc status=none
|
||||
@dd if=$(SRC)/fs/test.txt of=kern.iso bs=512 seek=40 conv=notrunc status=none
|
||||
@dd if=$(BUILD)/calc.bin of=kern.iso bs=512 seek=41 conv=notrunc status=none
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $(BUILD) ] || mkdir $(BUILD)
|
||||
|
||||
@@ -54,6 +54,7 @@ _These images may be outdated, Idk_
|
||||
|
||||
## Known issues
|
||||
- If you run kernel.bin from shell, it will clear the memory map so when you load anything it will override the kernel code
|
||||
- fillCircle() in graphics.h is broken. No idea why, so no filled circles for you (i commented out the boundaryFill call in the function)
|
||||
|
||||
## [Old Version](https://github.com/Tom-on64/old-kern)
|
||||
|
||||
|
||||
+16
-7
@@ -105,18 +105,27 @@ void drawCircle(int32_t x, int32_t y, uint16_t radius, uint32_t color) {
|
||||
void boundaryFill(int32_t x, int32_t y, uint32_t fillColor, uint32_t boundaryColor) {
|
||||
uint8_t* vidmem = (uint8_t*)gfxMode->physicalBasePtr;
|
||||
uint8_t bytesPerPx = (gfxMode->bpp+1) / 8;
|
||||
uint32_t convColor = convertColor(fillColor);
|
||||
uint32_t convColorF = convertColor(fillColor);
|
||||
uint32_t convColorB = convertColor(boundaryColor);
|
||||
|
||||
uint32_t offset = (y * gfxMode->xRes + x) * bytesPerPx;
|
||||
|
||||
if (vidmem[offset] != fillColor && vidmem[offset] != boundaryColor) {
|
||||
uint8_t draw = 0;
|
||||
for (uint8_t i = 0; i < bytesPerPx; i++) {
|
||||
if (vidmem[offset + i] != (uint8_t)(convColorF >> (i*8)) && vidmem[offset + i] != (uint8_t)(convColorB >> (i*8))) {
|
||||
draw = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (draw) {
|
||||
for (uint8_t i = 0; i < bytesPerPx; i++) {
|
||||
vidmem[offset + i] = (uint8_t)(convColor >> (i*8));
|
||||
vidmem[offset + i] = (uint8_t)(convColorF >> (i*8));
|
||||
}
|
||||
|
||||
boundaryFill(x + 1, y, fillColor, boundaryColor);
|
||||
boundaryFill(x - 1, y, fillColor, boundaryColor);
|
||||
boundaryFill(x, y + 1, fillColor, boundaryColor);
|
||||
boundaryFill(x - 1, y, fillColor, boundaryColor);
|
||||
boundaryFill(x, y - 1, fillColor, boundaryColor);
|
||||
}
|
||||
}
|
||||
@@ -127,7 +136,7 @@ void fillRect(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color) {
|
||||
int32_t cy = (y1 + y2) / 2;
|
||||
|
||||
drawRect(x1, y1, x2, y2, color - 1);
|
||||
// boundaryFill(cx, cy, color, color - 1);
|
||||
boundaryFill(cx, cy, color, color - 1);
|
||||
drawRect(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
@@ -136,13 +145,13 @@ void fillTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, in
|
||||
int32_t cy = (y1 + y2 + y3) / 3;
|
||||
|
||||
drawTriangle(x1, y1, x2, y2, x3, y3, color - 1);
|
||||
// boundaryFill(cx, cy, color, color - 1);
|
||||
boundaryFill(cx, cy, color, color - 1);
|
||||
drawTriangle(x1, y1, x2, y2, x3, y3, color);
|
||||
}
|
||||
|
||||
void fillCircle(int32_t x, int32_t y, uint16_t radius, uint32_t color) {
|
||||
drawCircle(x, y, radius, color - 1);
|
||||
// boundaryFill(x, y, color, color - 1);
|
||||
// boundaryFill(x, y, color, color - 1); TODO: It just doesn't feel like working here and hangs
|
||||
drawCircle(x, y, radius, color);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#define MODE_INFO_BLOCK 0x5000
|
||||
#define MODE_INFO_BLOCK 0x9000
|
||||
#define BG_COLOR 0x00010b17
|
||||
#define FG_COLOR 0x00ebddf4
|
||||
#define CHAR_WIDTH 8
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- Memory Map ---
|
||||
0x1000 - Kernel
|
||||
0x5000 - VBE Mode Info Block
|
||||
0x6000 - Font
|
||||
0x7000 - Filetable (0x7c00 - Bootloader)
|
||||
0x8500 - ACPI Memory map
|
||||
0x9000 - VBE Mode Info Block
|
||||
0x30000 - Memory manager memmap
|
||||
|
||||
|
||||
@@ -259,6 +259,8 @@ void main() {
|
||||
clear();
|
||||
} else if (strcmp(fileType, "tab") == 0) {
|
||||
printFiletable(address);
|
||||
} else if (strcmp(fileType, "fnt") == 0) {
|
||||
print("Loading...\n");
|
||||
} else {
|
||||
for (size_t i = 0; i < size * 512; i++) {
|
||||
if (address[i] != '\0') {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
%define VIDMEM 0xb800
|
||||
%define KERNEL_LOC 0x1000
|
||||
%define FILETAB_LOC 0x7000 ; TODO: Read kernel size and location from ft
|
||||
%define KERNEL_SIZE 30 ; 15kB
|
||||
%define KERNEL_SIZE 30; 15kB
|
||||
|
||||
start:
|
||||
mov [driveNum], dl ; Store the drive number
|
||||
|
||||
+1
-1
@@ -250,7 +250,7 @@ protected_start:
|
||||
|
||||
; Store VBE Mode Info Block in memory
|
||||
mov esi, modeInfoBlock
|
||||
mov edi, 0x5000 ; Destination
|
||||
mov edi, 0x9000 ; Destination
|
||||
mov ecx, 64 ; 64 * 4 = 256B (size of modeInfoBlock)
|
||||
rep movsd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user