diff --git a/boot.s b/kernel/arch/i386/boot.s similarity index 100% rename from boot.s rename to kernel/arch/i386/boot.s diff --git a/linker.ld b/kernel/arch/i386/linker.ld similarity index 100% rename from linker.ld rename to kernel/arch/i386/linker.ld diff --git a/kernel.nim b/kernel/arch/i386/tty.nim similarity index 57% rename from kernel.nim rename to kernel/arch/i386/tty.nim index 83684c3..c70dc8c 100644 --- a/kernel.nim +++ b/kernel/arch/i386/tty.nim @@ -1,27 +1,4 @@ -type - VGA_Colour {.pure.} = enum - black = 0, - blue = 1, - green = 2, - cyan = 3, - red = 4, - magenta = 5, - brown = 6, - lightGrey = 7, - darkGrey = 8, - lightBlue = 9, - lightGreen = 10, - lightCyan = 11, - lightRed = 12, - lightMagenta = 13, - lightBrown = 14, - white = 15 - -proc vgaEntryColour(fg: VGA_Colour, bg: VGA_Colour): int = - result = ord(fg) or (ord(bg) shl 4) - -proc vgaEntry(c: char, colour: int): int16 = - result = int16(int(c) or (colour shl 8)) +import vga const vgaWidth = 80 @@ -35,9 +12,9 @@ var proc terminalWriteAtPoint(writeChar: char, colour: int, xPos: int, yPos: int) = let index = terminalBufferBaseAddress + (yPos * bufferWidthSkip + (xPos * 2)) - cast[ptr int16](index)[] = vgaEntry(writeChar, terminalColour) # Write directly to display memory + cast[ptr int16](index)[] = vga.vgaEntry(writeChar, terminalColour) # Write directly to display memory -proc terminalInitialize() = +proc terminalInitialize*() = terminalColour = vgaEntryColour(VGA_Colour.lightGreen, VGA_Colour.red) for x in 0..