7713
This commit is contained in:
parent
2be221bce8
commit
08c55cb2b7
|
@ -90,6 +90,12 @@ fn draw-grapheme screen: (addr screen), g: grapheme, x: int, y: int, color: int,
|
||||||
copy-to *dest-color, src-color
|
copy-to *dest-color, src-color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# we can't really render non-ASCII yet, but when we do we'll be ready
|
||||||
|
fn draw-code-point screen: (addr screen), c: code-point, x: int, y: int, color: int, background-color: int {
|
||||||
|
var g/eax: grapheme <- copy c
|
||||||
|
draw-grapheme screen, g, x, y, color, background-color
|
||||||
|
}
|
||||||
|
|
||||||
# not really needed for a real screen, though it shouldn't do any harm
|
# not really needed for a real screen, though it shouldn't do any harm
|
||||||
fn screen-cell-index screen-on-stack: (addr screen), x: int, y: int -> _/ecx: int {
|
fn screen-cell-index screen-on-stack: (addr screen), x: int, y: int -> _/ecx: int {
|
||||||
var screen/esi: (addr screen) <- copy screen-on-stack
|
var screen/esi: (addr screen) <- copy screen-on-stack
|
||||||
|
@ -193,7 +199,6 @@ fn clear-screen screen: (addr screen) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
# fake screen
|
# fake screen
|
||||||
var space/edi: grapheme <- copy 0x20
|
|
||||||
set-cursor-position screen, 0, 0
|
set-cursor-position screen, 0, 0
|
||||||
var screen-addr/esi: (addr screen) <- copy screen
|
var screen-addr/esi: (addr screen) <- copy screen
|
||||||
var y/eax: int <- copy 1
|
var y/eax: int <- copy 1
|
||||||
|
@ -206,7 +211,7 @@ fn clear-screen screen: (addr screen) {
|
||||||
{
|
{
|
||||||
compare x, *width
|
compare x, *width
|
||||||
break-if->
|
break-if->
|
||||||
draw-grapheme screen, space, x, y, 0/fg=black, 0/bg=black
|
draw-code-point screen, 0x20/space, x, y, 0/fg=black, 0/bg=black
|
||||||
x <- increment
|
x <- increment
|
||||||
loop
|
loop
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,12 @@ fn draw-grapheme-at-cursor screen: (addr screen), g: grapheme, color: int, backg
|
||||||
draw-grapheme screen, g, cursor-x, cursor-y, color, background-color
|
draw-grapheme screen, g, cursor-x, cursor-y, color, background-color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# we can't really render non-ASCII yet, but when we do we'll be ready
|
||||||
|
fn draw-code-point-at-cursor screen: (addr screen), c: code-point, color: int, background-color: int {
|
||||||
|
var g/eax: grapheme <- copy c
|
||||||
|
draw-grapheme-at-cursor screen, g, color, background-color
|
||||||
|
}
|
||||||
|
|
||||||
# draw a single line of text from x, y to xmax
|
# draw a single line of text from x, y to xmax
|
||||||
# return the next 'x' coordinate
|
# return the next 'x' coordinate
|
||||||
# if there isn't enough space, return 0 without modifying the screen
|
# if there isn't enough space, return 0 without modifying the screen
|
||||||
|
|
|
@ -301,8 +301,7 @@ fn test-draw-single-grapheme {
|
||||||
var screen-on-stack: screen
|
var screen-on-stack: screen
|
||||||
var screen/esi: (addr screen) <- address screen-on-stack
|
var screen/esi: (addr screen) <- address screen-on-stack
|
||||||
initialize-screen screen, 5, 4
|
initialize-screen screen, 5, 4
|
||||||
var c/eax: grapheme <- copy 0x61/a
|
draw-code-point screen, 0x61/a, 0/x, 0/y, 1/fg, 2/bg
|
||||||
draw-grapheme screen, c, 0/x, 0/y, 1/fg, 2/bg
|
|
||||||
check-screen-row screen, 0/y, "a", "F - test-draw-single-grapheme" # top-left corner of the screen
|
check-screen-row screen, 0/y, "a", "F - test-draw-single-grapheme" # top-left corner of the screen
|
||||||
check-screen-row-in-color screen, 1/fg, 0/y, "a", "F - test-draw-single-grapheme-fg"
|
check-screen-row-in-color screen, 1/fg, 0/y, "a", "F - test-draw-single-grapheme-fg"
|
||||||
check-screen-row-in-background-color screen, 2/bg, 0/y, "a", "F - test-draw-single-grapheme-bg"
|
check-screen-row-in-background-color screen, 2/bg, 0/y, "a", "F - test-draw-single-grapheme-bg"
|
||||||
|
|
|
@ -10,6 +10,5 @@
|
||||||
# Expected output: letter 'A' in green near the top-left corner of screen
|
# Expected output: letter 'A' in green near the top-left corner of screen
|
||||||
|
|
||||||
fn main {
|
fn main {
|
||||||
var g/eax: grapheme <- copy 0x41/A
|
draw-codepoint 0/screen, 0x41/A, 2/row, 1/col, 0xa/fg, 0/bg
|
||||||
draw-grapheme 0/screen, g, 2/row, 1/col, 0xa/fg, 0/bg
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,29 +19,26 @@ fn main {
|
||||||
{
|
{
|
||||||
compare key, 0x68/h
|
compare key, 0x68/h
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var g/eax: grapheme <- copy 0x2d/dash
|
draw-code-point-at-cursor 0/screen, 0x2d/dash, 0x31/fg, 0/bg
|
||||||
draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg
|
|
||||||
move-cursor-left 0
|
move-cursor-left 0
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
compare key, 0x6a/j
|
compare key, 0x6a/j
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var g/eax: grapheme <- copy 0x7c/vertical-bar
|
draw-code-point-at-cursor 0/screen, 0x7c/vertical-bar, 0x31/fg, 0/bg
|
||||||
draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg
|
|
||||||
move-cursor-down 0
|
move-cursor-down 0
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
compare key, 0x6b/k
|
compare key, 0x6b/k
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var g/eax: grapheme <- copy 0x7c/vertical-bar
|
draw-code-point-at-cursor 0/screen, 0x7c/vertical-bar, 0x31/fg, 0/bg
|
||||||
draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg
|
|
||||||
move-cursor-up 0
|
move-cursor-up 0
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
compare key, 0x6c/l
|
compare key, 0x6c/l
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var g/eax: grapheme <- copy 0x2d/dash
|
var g/eax: code-point <- copy 0x2d/dash
|
||||||
draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg
|
draw-code-point-at-cursor 0/screen, 0x2d/dash, 0x31/fg, 0/bg
|
||||||
move-cursor-right 0
|
move-cursor-right 0
|
||||||
}
|
}
|
||||||
loop
|
loop
|
||||||
|
|
Loading…
Reference in New Issue