Remove C usage

This commit is contained in:
neviyn 2017-11-07 01:39:24 +00:00
parent edbc39cc3b
commit a03745805b
3 changed files with 11 additions and 17 deletions

View File

@ -20,8 +20,8 @@ proc terminalWriteAtPoint(writeChar: char, colour: int, xPos: int, yPos: int) =
vgaMem[index] = vga.vgaEntry(writeChar, terminalColour) vgaMem[index] = vga.vgaEntry(writeChar, terminalColour)
proc terminalClear*() = proc terminalClear*() =
for x in 0..<vgaWidth: for x in 0 .. vgaWidth - 1:
for y in 0..<vgaHeight: for y in 0 .. vgaHeight - 1:
terminalWriteAtPoint(' ', terminalColour, x, y) terminalWriteAtPoint(' ', terminalColour, x, y)
terminalRow = 0 terminalRow = 0
terminalColumn = 0 terminalColumn = 0
@ -31,12 +31,12 @@ proc terminalInitialize*() =
terminalClear() terminalClear()
proc terminalScroll() = proc terminalScroll() =
for y in 0..< (vgaHeight - 1): for y in 0 .. (vgaHeight - 2):
let base1 = y * vgaWidth let base1 = y * vgaWidth
let base2 = (y + 1) * vgaWidth let base2 = (y + 1) * vgaWidth
for x in 0..<vgaWidth: for x in 0 .. vgaWidth - 1:
vgaMem[base1 + x] = vgaMem[base2 + x] vgaMem[base1 + x] = vgaMem[base2 + x]
for x in 0..<vgaWidth: # Blank the "new" bottom line for x in 0 .. vgaWidth - 1: # Blank the "new" bottom line
terminalWriteAtPoint(' ', terminalColour, x, vgaHeight - 1) terminalWriteAtPoint(' ', terminalColour, x, vgaHeight - 1)
proc setTerminalColour(newColour: int) = proc setTerminalColour(newColour: int) =
@ -59,8 +59,8 @@ proc terminalWriteChar(writeChar: char) =
scrollCheckAndSet() scrollCheckAndSet()
proc terminalWrite*(data: string) = proc terminalWrite*(data: string) =
for character in data: for i in 0 .. data.len - 1:
terminalWriteChar(character) terminalWriteChar(data[i])
proc terminalWrite*(data: char) = proc terminalWrite*(data: char) =
terminalWriteChar(data) terminalWriteChar(data)

View File

@ -1,17 +1,12 @@
import tty
{.push debugger:off, hints:off.}
proc printf(frmt: cstring) {.varargs, importc, header: "<stdio.h>", cdecl.}
proc exit(code: int) {.importc, header: "<stdlib.h>", cdecl.}
{.push stack_trace: off, profiler:off.} {.push stack_trace: off, profiler:off.}
proc rawoutput(s: string) = proc rawoutput(s: string) =
printf("%s\n", s) tty.terminalWrite(s)
proc panic(s: string) = proc panic(s: string) =
rawoutput(s) rawoutput(s)
exit(1)
# Alternatively we also could implement these 2 here: # Alternatively we also could implement these 2 here:
# #
@ -19,4 +14,3 @@ proc panic(s: string) =
# template sysFatal(exceptn: typeDesc, message, arg: string) # template sysFatal(exceptn: typeDesc, message, arg: string)
{.pop.} {.pop.}
{.pop.}

View File

@ -5,6 +5,6 @@
--path:"kernel/arch/i386" --path:"kernel/arch/i386"
--cpu:i386 --cpu:i386
--os:standalone --os:standalone
--passC:"-ffreestanding -nostdlib --target=i386-pc-none-elf -march=i386 -lc" --passC:"-ffreestanding -nostdlib --target=i386-pc-none-elf -march=i386"
--passL:"-ffreestanding -target i386 -nostdlib -T ./kernel/arch/i386/linker.ld boot.o -lc" --passL:"-ffreestanding -target i386 -nostdlib -T ./kernel/arch/i386/linker.ld boot.o"
--out:"myos.bin" --out:"myos.bin"