From 90eba82c396b8c545312d852bb9b77f6410663e8 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Sat, 21 Oct 2017 16:24:06 +0100 Subject: [PATCH] Hello world now operational. Separate insertion of colour codes was required. --- kernel.nim | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/kernel.nim b/kernel.nim index 117c07e..41aa066 100644 --- a/kernel.nim +++ b/kernel.nim @@ -17,8 +17,8 @@ type lightBrown = 14, white = 15 -proc vgaEntryColour(fg: VGA_Colour, bg: VGA_Colour): uint8 = - result = uint8(ord(fg)) or (uint8(ord(bg)) shl 4) +proc vgaEntryColour(fg: VGA_Colour, bg: VGA_Colour): int = + result = ord(fg) or (ord(bg) shl 4) proc vgaEntry(c: char, colour: uint8): uint16 = result = uint16(c) or (uint16(colour) shl 8) @@ -30,22 +30,24 @@ const var terminalRow, terminalColumn = 0 - terminalColour = vgaEntryColour(VGA_Colour.lightGrey, VGA_Colour.black) + terminalColour: int -proc terminalWriteAtPoint(writeChar: char, colour: uint8, xPos: int, yPos: int) = - let index = terminalBufferBaseAddress + (yPos * vgaWidth + xPos) - cast[ptr uint16](index)[] = vgaEntry(writeChar, colour) # Write directly to display memory +proc terminalWriteAtPoint(writeChar: char, colour: int, xPos: int, yPos: int) = + let index = terminalBufferBaseAddress + (yPos * vgaWidth + (xPos * 2)) + cast[ptr int](index)[] = int(writeChar) # Write directly to display memory + cast[ptr int](index+1)[] = terminalColour proc terminalInitialize() = + terminalColour = vgaEntryColour(VGA_Colour.white, VGA_Colour.black) for y in 0..