From 65a4b94be100d795528202464b7d6f4b72e53734 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Sun, 22 Oct 2017 01:54:51 +0100 Subject: [PATCH] Scrolling now works. Simplified access to VGA memory. --- kernel/arch/i386/tty.nim | 36 ++++++++++++++++++++---------------- kernel/arch/i386/vga.nim | 6 ++++-- kernel/kernel.nim | 3 +++ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/kernel/arch/i386/tty.nim b/kernel/arch/i386/tty.nim index 90aee3f..baf7c3f 100644 --- a/kernel/arch/i386/tty.nim +++ b/kernel/arch/i386/tty.nim @@ -1,18 +1,21 @@ import vga +type + VGAMemory = ptr array[0..2000, VGADoubleByte] + const vgaWidth = 80 vgaHeight = 25 terminalBufferBaseAddress = 0xB8000 - bufferWidthSkip = vgaWidth * 2 + vgaMem = cast[VGAMemory](terminalBufferBaseAddress) var terminalRow, terminalColumn = 0 terminalColour: int proc terminalWriteAtPoint(writeChar: char, colour: int, xPos: int, yPos: int) = - let index = terminalBufferBaseAddress + (yPos * bufferWidthSkip + (xPos * 2)) - cast[ptr int16](index)[] = vga.vgaEntry(writeChar, terminalColour) + let index = yPos * vgaWidth + xPos + vgaMem[index] = vga.vgaEntry(writeChar, terminalColour) proc terminalClear*() = for x in 0..