Added proc to write characters to terminal.

This commit is contained in:
neviyn 2017-10-20 18:12:00 +01:00
parent 30c76c17c9
commit ba0e9982c9

View File

@ -32,8 +32,21 @@ var
terminalRow, terminalColumn = 0 terminalRow, terminalColumn = 0
terminalColour = vgaEntryColour(VGA_Colour.lightGrey, VGA_Colour.black) terminalColour = vgaEntryColour(VGA_Colour.lightGrey, VGA_Colour.black)
proc terminalWriteAtPoint(writeChar: char, colour: uint8, xPos: int, yPos: int) =
let index = terminalBufferBaseAddress + (yPos * vgaWidth + xPos)
cast[ptr uint16](index)[] = vgaEntry(' ', terminalColour) # Write directly to display memory
proc terminalInitialize() = proc terminalInitialize() =
for y in 0..<vgaWidth: for y in 0..<vgaWidth:
for x in 0..<vgaHeight: for x in 0..<vgaHeight:
let index = terminalBufferBaseAddress + (y * vgaWidth + x) terminalWriteAtPoint(' ', terminalColour, x, y)
cast[ptr uint16](index)[] = vgaEntry(' ', terminalColour) # Write directly to display memory
proc setTerminalColour(newColour: uint8) =
terminalColour = newColour
proc terminalWriteChar(writeChar: char) =
terminalWriteAtPoint(writeChar, terminalColour, terminalColumn, terminalRow)
inc(terminalColumn)
inc(terminalRow)
if(terminalColumn == vgaWidth): terminalColumn = 0
if(terminalRow == vgaHeight): terminalRow = 0