Added x2 multiplication for row placement. Means newlines actually work properly.
This commit is contained in:
parent
4d19433c17
commit
c3ca04dd5a
10
kernel.nim
10
kernel.nim
@ -27,19 +27,20 @@ const
|
||||
vgaWidth = 80
|
||||
vgaHeight = 25
|
||||
terminalBufferBaseAddress = 0xB8000
|
||||
bufferWidthSkip = vgaWidth * 2
|
||||
|
||||
var
|
||||
terminalRow, terminalColumn = 0
|
||||
terminalColour: int
|
||||
|
||||
proc terminalWriteAtPoint(writeChar: char, colour: int, xPos: int, yPos: int) =
|
||||
let index = terminalBufferBaseAddress + (yPos * vgaWidth + (xPos * 2))
|
||||
let index = terminalBufferBaseAddress + (yPos * bufferWidthSkip + (xPos * 2))
|
||||
cast[ptr int16](index)[] = vgaEntry(writeChar, terminalColour) # Write directly to display memory
|
||||
|
||||
proc terminalInitialize() =
|
||||
terminalColour = vgaEntryColour(VGA_Colour.lightGreen, VGA_Colour.red)
|
||||
for y in 0..<vgaWidth:
|
||||
for x in 0..<vgaHeight:
|
||||
for x in 0..<vgaWidth:
|
||||
for y in 0..<vgaHeight:
|
||||
terminalWriteAtPoint(' ', terminalColour, x, y)
|
||||
|
||||
proc setTerminalColour(newColour: int) =
|
||||
@ -48,6 +49,7 @@ proc setTerminalColour(newColour: int) =
|
||||
proc terminalWriteChar(writeChar: char) =
|
||||
if(writeChar == '\L'):
|
||||
inc(terminalRow)
|
||||
terminalColumn = 0
|
||||
if(terminalRow == vgaHeight): terminalRow = 0
|
||||
return
|
||||
terminalWriteAtPoint(writeChar, terminalColour, terminalColumn, terminalRow)
|
||||
@ -63,5 +65,5 @@ proc terminalWrite(data: string) =
|
||||
|
||||
proc kernelMain() {.exportc: "kernel_main"}=
|
||||
terminalInitialize()
|
||||
terminalWrite("Hello World\LThis is Nim!")
|
||||
terminalWrite("Hello World!\LNim here!")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user