7693 - baremetal: pass background color everywhere
This commit is contained in:
parent
f626421bc4
commit
8f34dfd1e0
|
@ -39,7 +39,7 @@ $read-byte:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$read-byte:abort:
|
$read-byte:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "read-byte: empty stream" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "read-byte: empty stream" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ $append-byte:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$append-byte:abort:
|
$append-byte:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "append-byte: out of space\n" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "append-byte: out of space\n" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ $allocate-raw:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$allocate-raw:abort:
|
$allocate-raw:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "allocate: failed" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "allocate: failed" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ $lookup:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$lookup:abort:
|
$lookup:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "lookup: failed" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "lookup: failed" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ allocate-region: # ad: (addr allocation-descriptor), n: int, out: (addr handle
|
||||||
# we bloat a potentially cold segment in RAM so we can abort with a single
|
# we bloat a potentially cold segment in RAM so we can abort with a single
|
||||||
# instruction.
|
# instruction.
|
||||||
$allocate-region:abort:
|
$allocate-region:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "allocate-region: failed to allocate" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "allocate-region: failed to allocate" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
|
|
@ -848,7 +848,7 @@ $write-slice:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$write-slice:abort:
|
$write-slice:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "write-slice: out of space" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "write-slice: out of space" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
@ -970,7 +970,7 @@ $slice-to-string:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$slice-to-string:abort:
|
$slice-to-string:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "slice-to-string: out of space\n" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "slice-to-string: out of space\n" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ $write-int32-decimal:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$write-int32-decimal:abort:
|
$write-int32-decimal:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "write-int32-decimal: stream out of space" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "write-int32-decimal: stream out of space" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ $to-decimal-digit:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$to-decimal-digit:abort:
|
$to-decimal-digit:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "to-decimal-digit: not a digit character" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "to-decimal-digit: not a digit character" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ $write-to-stream:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$write-to-stream:abort:
|
$write-to-stream:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "write-to-stream: stream full" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "write-to-stream: stream full" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ $read-from-stream:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
$read-from-stream:abort:
|
$read-from-stream:abort:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "read-from-stream: stream empty" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "read-from-stream: stream empty" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,13 @@ __check-mu-array-bounds: # index: int, elem-size: int, arr-size: int, function-
|
||||||
39/compare %eax 1/r32/ecx
|
39/compare %eax 1/r32/ecx
|
||||||
0f 82/jump-if-unsigned< $__check-mu-array-bounds:end/disp32 # negative index should always abort
|
0f 82/jump-if-unsigned< $__check-mu-array-bounds:end/disp32 # negative index should always abort
|
||||||
# abort if necessary
|
# abort if necessary
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "fn " 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "fn " 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x14) 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x14) 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 ": offset " 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 ": offset " 3 0) # 3=cyan
|
||||||
(draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0 %eax 3) # 3=cyan
|
(draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0 %eax 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 " is too large for array '" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 " is too large for array '" 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x18) 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x18) 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "'" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "'" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ $__check-mu-array-bounds:end:
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
__check-mu-array-bounds:overflow:
|
__check-mu-array-bounds:overflow:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "fn " 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "fn " 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x14) 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x14) 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 ": offset to array '" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 ": offset to array '" 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "offset to array overflowed 32 bits" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "offset to array overflowed 32 bits" 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x18) 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x18) 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "' overflowed 32 bits" 3) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "' overflowed 32 bits" 3 0) # 3=cyan
|
||||||
{
|
{
|
||||||
eb/jump loop/disp8
|
eb/jump loop/disp8
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ type screen {
|
||||||
type screen-cell {
|
type screen-cell {
|
||||||
data: grapheme
|
data: grapheme
|
||||||
color: int
|
color: int
|
||||||
|
background-color: int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize-screen screen: (addr screen), width: int, height: int {
|
fn initialize-screen screen: (addr screen), width: int, height: int {
|
||||||
|
@ -65,11 +66,11 @@ fn screen-size screen: (addr screen) -> _/eax: int, _/ecx: int {
|
||||||
|
|
||||||
# testable screen primitive
|
# testable screen primitive
|
||||||
# background color isn't configurable yet
|
# background color isn't configurable yet
|
||||||
fn draw-grapheme screen: (addr screen), g: grapheme, x: int, y: int, color: int {
|
fn draw-grapheme screen: (addr screen), g: grapheme, x: int, y: int, color: int, background-color: int {
|
||||||
{
|
{
|
||||||
compare screen, 0
|
compare screen, 0
|
||||||
break-if-!=
|
break-if-!=
|
||||||
draw-grapheme-on-real-screen g, x, y, color, 0
|
draw-grapheme-on-real-screen g, x, y, color, background-color
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
# fake screen
|
# fake screen
|
||||||
|
@ -170,7 +171,7 @@ fn show-cursor screen: (addr screen), g: grapheme {
|
||||||
var cursor-x/eax: int <- copy 0
|
var cursor-x/eax: int <- copy 0
|
||||||
var cursor-y/ecx: int <- copy 0
|
var cursor-y/ecx: int <- copy 0
|
||||||
cursor-x, cursor-y <- cursor-position screen
|
cursor-x, cursor-y <- cursor-position screen
|
||||||
draw-grapheme screen, g, cursor-x, cursor-y, 0 # cursor color not tracked for fake screen
|
draw-grapheme screen, g, cursor-x, cursor-y, 0/fg, 7/bg
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear-screen screen: (addr screen) {
|
fn clear-screen screen: (addr screen) {
|
||||||
|
@ -194,7 +195,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
|
draw-grapheme screen, space, x, y, 0/fg=black, 0/bg=black
|
||||||
x <- increment
|
x <- increment
|
||||||
loop
|
loop
|
||||||
}
|
}
|
||||||
|
@ -260,3 +261,22 @@ fn screen-color-at-idx screen-on-stack: (addr screen), idx-on-stack: int -> _/ea
|
||||||
var result/eax: int <- copy *src
|
var result/eax: int <- copy *src
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn screen-background-color-at screen-on-stack: (addr screen), x: int, y: int -> _/eax: int {
|
||||||
|
var screen-addr/esi: (addr screen) <- copy screen-on-stack
|
||||||
|
var idx/ecx: int <- screen-cell-index screen-addr, x, y
|
||||||
|
var result/eax: int <- screen-background-color-at-idx screen-addr, idx
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
fn screen-background-color-at-idx screen-on-stack: (addr screen), idx-on-stack: int -> _/eax: int {
|
||||||
|
var screen-addr/esi: (addr screen) <- copy screen-on-stack
|
||||||
|
var data-ah/eax: (addr handle array screen-cell) <- get screen-addr, data
|
||||||
|
var data/eax: (addr array screen-cell) <- lookup *data-ah
|
||||||
|
var idx/ecx: int <- copy idx-on-stack
|
||||||
|
var offset/ecx: (offset screen-cell) <- compute-offset data, idx
|
||||||
|
var cell/eax: (addr screen-cell) <- index data, offset
|
||||||
|
var src/eax: (addr int) <- get cell, background-color
|
||||||
|
var result/eax: int <- copy *src
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
|
@ -60,17 +60,17 @@ fn cursor-down screen: (addr screen) {
|
||||||
set-cursor-position screen, cursor-x, cursor-y
|
set-cursor-position screen, cursor-x, cursor-y
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-grapheme-at-cursor screen: (addr screen), g: grapheme, color: int {
|
fn draw-grapheme-at-cursor screen: (addr screen), g: grapheme, color: int, background-color: int {
|
||||||
var cursor-x/eax: int <- copy 0
|
var cursor-x/eax: int <- copy 0
|
||||||
var cursor-y/ecx: int <- copy 0
|
var cursor-y/ecx: int <- copy 0
|
||||||
cursor-x, cursor-y <- cursor-position screen
|
cursor-x, cursor-y <- cursor-position screen
|
||||||
draw-grapheme screen, g, cursor-x, cursor-y, color
|
draw-grapheme screen, g, cursor-x, cursor-y, 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
|
||||||
fn draw-text-rightward screen: (addr screen), text: (addr array byte), x: int, xmax: int, y: int, color: int -> _/eax: int {
|
fn draw-text-rightward screen: (addr screen), text: (addr array byte), x: int, xmax: int, y: int, color: int, background-color: int -> _/eax: int {
|
||||||
var stream-storage: (stream byte 0x100)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/esi: (addr stream byte) <- address stream-storage
|
var stream/esi: (addr stream byte) <- address stream-storage
|
||||||
write stream, text
|
write stream, text
|
||||||
|
@ -97,7 +97,7 @@ fn draw-text-rightward screen: (addr screen), text: (addr array byte), x: int, x
|
||||||
var g/eax: grapheme <- read-grapheme stream
|
var g/eax: grapheme <- read-grapheme stream
|
||||||
compare g, 0xffffffff/end-of-file
|
compare g, 0xffffffff/end-of-file
|
||||||
break-if-=
|
break-if-=
|
||||||
draw-grapheme screen, g, xcurr, y, color
|
draw-grapheme screen, g, xcurr, y, color, background-color
|
||||||
xcurr <- increment
|
xcurr <- increment
|
||||||
loop
|
loop
|
||||||
}
|
}
|
||||||
|
@ -105,11 +105,11 @@ fn draw-text-rightward screen: (addr screen), text: (addr array byte), x: int, x
|
||||||
return xcurr
|
return xcurr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-text-rightward-from-cursor screen: (addr screen), text: (addr array byte), xmax: int, color: int -> _/eax: int {
|
fn draw-text-rightward-from-cursor screen: (addr screen), text: (addr array byte), xmax: int, color: int, background-color: int -> _/eax: int {
|
||||||
var cursor-x/eax: int <- copy 0
|
var cursor-x/eax: int <- copy 0
|
||||||
var cursor-y/ecx: int <- copy 0
|
var cursor-y/ecx: int <- copy 0
|
||||||
cursor-x, cursor-y <- cursor-position screen
|
cursor-x, cursor-y <- cursor-position screen
|
||||||
var result/eax: int <- draw-text-rightward screen, text, cursor-x, xmax, cursor-y, color
|
var result/eax: int <- draw-text-rightward screen, text, cursor-x, xmax, cursor-y, color, background-color
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ fn draw-text-rightward-from-cursor screen: (addr screen), text: (addr array byte
|
||||||
# return the next (x, y) coordinate in raster order where drawing stopped
|
# return the next (x, y) coordinate in raster order where drawing stopped
|
||||||
# that way the caller can draw more if given the same min and max bounding-box.
|
# that way the caller can draw more if given the same min and max bounding-box.
|
||||||
# if there isn't enough space, return 0 without modifying the screen
|
# if there isn't enough space, return 0 without modifying the screen
|
||||||
fn draw-text-wrapping-right-then-down screen: (addr screen), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int -> _/eax: int, _/ecx: int {
|
fn draw-text-wrapping-right-then-down screen: (addr screen), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
|
||||||
var stream-storage: (stream byte 0x100)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/esi: (addr stream byte) <- address stream-storage
|
var stream/esi: (addr stream byte) <- address stream-storage
|
||||||
write stream, text
|
write stream, text
|
||||||
|
@ -152,7 +152,7 @@ fn draw-text-wrapping-right-then-down screen: (addr screen), text: (addr array b
|
||||||
var g/eax: grapheme <- read-grapheme stream
|
var g/eax: grapheme <- read-grapheme stream
|
||||||
compare g, 0xffffffff/end-of-file
|
compare g, 0xffffffff/end-of-file
|
||||||
break-if-=
|
break-if-=
|
||||||
draw-grapheme screen, g, xcurr, ycurr, color
|
draw-grapheme screen, g, xcurr, ycurr, color, background-color
|
||||||
xcurr <- increment
|
xcurr <- increment
|
||||||
compare xcurr, xmax
|
compare xcurr, xmax
|
||||||
{
|
{
|
||||||
|
@ -180,15 +180,15 @@ fn move-cursor-rightward-and-downward screen: (addr screen), xmin: int, xmax: in
|
||||||
set-cursor-position screen, cursor-x, cursor-y
|
set-cursor-position screen, cursor-x, cursor-y
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-text-wrapping-right-then-down-over-full-screen screen: (addr screen), text: (addr array byte), x: int, y: int, color: int -> _/eax: int, _/ecx: int {
|
fn draw-text-wrapping-right-then-down-over-full-screen screen: (addr screen), text: (addr array byte), x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
|
||||||
var x2/eax: int <- copy 0
|
var x2/eax: int <- copy 0
|
||||||
var y2/ecx: int <- copy 0
|
var y2/ecx: int <- copy 0
|
||||||
x2, y2 <- screen-size screen # width, height
|
x2, y2 <- screen-size screen # width, height
|
||||||
x2, y2 <- draw-text-wrapping-right-then-down screen, text, 0/xmin, 0/ymin, x2, y2, x, y, color
|
x2, y2 <- draw-text-wrapping-right-then-down screen, text, 0/xmin, 0/ymin, x2, y2, x, y, color, background-color
|
||||||
return x2, y2 # cursor-x, cursor-y
|
return x2, y2 # cursor-x, cursor-y
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-text-wrapping-right-then-down-from-cursor screen: (addr screen), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, color: int {
|
fn draw-text-wrapping-right-then-down-from-cursor screen: (addr screen), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, color: int, background-color: int {
|
||||||
var cursor-x/eax: int <- copy 0
|
var cursor-x/eax: int <- copy 0
|
||||||
var cursor-y/ecx: int <- copy 0
|
var cursor-y/ecx: int <- copy 0
|
||||||
cursor-x, cursor-y <- cursor-position screen
|
cursor-x, cursor-y <- cursor-position screen
|
||||||
|
@ -200,17 +200,17 @@ fn draw-text-wrapping-right-then-down-from-cursor screen: (addr screen), text: (
|
||||||
cursor-x <- copy xmin
|
cursor-x <- copy xmin
|
||||||
cursor-y <- increment
|
cursor-y <- increment
|
||||||
}
|
}
|
||||||
cursor-x, cursor-y <- draw-text-wrapping-right-then-down screen, text, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color
|
cursor-x, cursor-y <- draw-text-wrapping-right-then-down screen, text, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color, background-color
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen: (addr screen), text: (addr array byte), color: int {
|
fn draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen: (addr screen), text: (addr array byte), color: int, background-color: int {
|
||||||
var width/eax: int <- copy 0
|
var width/eax: int <- copy 0
|
||||||
var height/ecx: int <- copy 0
|
var height/ecx: int <- copy 0
|
||||||
width, height <- screen-size screen
|
width, height <- screen-size screen
|
||||||
draw-text-wrapping-right-then-down-from-cursor screen, text, 0/xmin, 0/ymin, width, height, color
|
draw-text-wrapping-right-then-down-from-cursor screen, text, 0/xmin, 0/ymin, width, height, color, background-color
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-int32-hex-wrapping-right-then-down screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int -> _/eax: int, _/ecx: int {
|
fn draw-int32-hex-wrapping-right-then-down screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
|
||||||
var stream-storage: (stream byte 0x100)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/esi: (addr stream byte) <- address stream-storage
|
var stream/esi: (addr stream byte) <- address stream-storage
|
||||||
write-int32-hex stream, n
|
write-int32-hex stream, n
|
||||||
|
@ -245,7 +245,7 @@ fn draw-int32-hex-wrapping-right-then-down screen: (addr screen), n: int, xmin:
|
||||||
var g/eax: grapheme <- read-grapheme stream
|
var g/eax: grapheme <- read-grapheme stream
|
||||||
compare g, 0xffffffff/end-of-file
|
compare g, 0xffffffff/end-of-file
|
||||||
break-if-=
|
break-if-=
|
||||||
draw-grapheme screen, g, xcurr, ycurr, color
|
draw-grapheme screen, g, xcurr, ycurr, color, background-color
|
||||||
xcurr <- increment
|
xcurr <- increment
|
||||||
compare xcurr, xmax
|
compare xcurr, xmax
|
||||||
{
|
{
|
||||||
|
@ -259,15 +259,15 @@ fn draw-int32-hex-wrapping-right-then-down screen: (addr screen), n: int, xmin:
|
||||||
return xcurr, ycurr
|
return xcurr, ycurr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-int32-hex-wrapping-right-then-down-over-full-screen screen: (addr screen), n: int, x: int, y: int, color: int -> _/eax: int, _/ecx: int {
|
fn draw-int32-hex-wrapping-right-then-down-over-full-screen screen: (addr screen), n: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
|
||||||
var x2/eax: int <- copy 0
|
var x2/eax: int <- copy 0
|
||||||
var y2/ecx: int <- copy 0
|
var y2/ecx: int <- copy 0
|
||||||
x2, y2 <- screen-size screen # width, height
|
x2, y2 <- screen-size screen # width, height
|
||||||
x2, y2 <- draw-int32-hex-wrapping-right-then-down screen, n, 0/xmin, 0/ymin, x2, y2, x, y, color
|
x2, y2 <- draw-int32-hex-wrapping-right-then-down screen, n, 0/xmin, 0/ymin, x2, y2, x, y, color, background-color
|
||||||
return x2, y2 # cursor-x, cursor-y
|
return x2, y2 # cursor-x, cursor-y
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-int32-hex-wrapping-right-then-down-from-cursor screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, color: int {
|
fn draw-int32-hex-wrapping-right-then-down-from-cursor screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, color: int, background-color: int {
|
||||||
var cursor-x/eax: int <- copy 0
|
var cursor-x/eax: int <- copy 0
|
||||||
var cursor-y/ecx: int <- copy 0
|
var cursor-y/ecx: int <- copy 0
|
||||||
cursor-x, cursor-y <- cursor-position screen
|
cursor-x, cursor-y <- cursor-position screen
|
||||||
|
@ -279,17 +279,17 @@ fn draw-int32-hex-wrapping-right-then-down-from-cursor screen: (addr screen), n:
|
||||||
cursor-x <- copy xmin
|
cursor-x <- copy xmin
|
||||||
cursor-y <- increment
|
cursor-y <- increment
|
||||||
}
|
}
|
||||||
cursor-x, cursor-y <- draw-int32-hex-wrapping-right-then-down screen, n, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color
|
cursor-x, cursor-y <- draw-int32-hex-wrapping-right-then-down screen, n, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color, background-color
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen: (addr screen), n: int, color: int {
|
fn draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen: (addr screen), n: int, color: int, background-color: int {
|
||||||
var width/eax: int <- copy 0
|
var width/eax: int <- copy 0
|
||||||
var height/ecx: int <- copy 0
|
var height/ecx: int <- copy 0
|
||||||
width, height <- screen-size screen
|
width, height <- screen-size screen
|
||||||
draw-int32-hex-wrapping-right-then-down-from-cursor screen, n, 0/xmin, 0/ymin, width, height, color
|
draw-int32-hex-wrapping-right-then-down-from-cursor screen, n, 0/xmin, 0/ymin, width, height, color, background-color
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-int32-decimal-wrapping-right-then-down screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int -> _/eax: int, _/ecx: int {
|
fn draw-int32-decimal-wrapping-right-then-down screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
|
||||||
var stream-storage: (stream byte 0x100)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/esi: (addr stream byte) <- address stream-storage
|
var stream/esi: (addr stream byte) <- address stream-storage
|
||||||
write-int32-decimal stream, n
|
write-int32-decimal stream, n
|
||||||
|
@ -324,7 +324,7 @@ fn draw-int32-decimal-wrapping-right-then-down screen: (addr screen), n: int, xm
|
||||||
var g/eax: grapheme <- read-grapheme stream
|
var g/eax: grapheme <- read-grapheme stream
|
||||||
compare g, 0xffffffff/end-of-file
|
compare g, 0xffffffff/end-of-file
|
||||||
break-if-=
|
break-if-=
|
||||||
draw-grapheme screen, g, xcurr, ycurr, color
|
draw-grapheme screen, g, xcurr, ycurr, color, background-color
|
||||||
xcurr <- increment
|
xcurr <- increment
|
||||||
compare xcurr, xmax
|
compare xcurr, xmax
|
||||||
{
|
{
|
||||||
|
@ -338,15 +338,15 @@ fn draw-int32-decimal-wrapping-right-then-down screen: (addr screen), n: int, xm
|
||||||
return xcurr, ycurr
|
return xcurr, ycurr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-int32-decimal-wrapping-right-then-down-over-full-screen screen: (addr screen), n: int, x: int, y: int, color: int -> _/eax: int, _/ecx: int {
|
fn draw-int32-decimal-wrapping-right-then-down-over-full-screen screen: (addr screen), n: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
|
||||||
var x2/eax: int <- copy 0
|
var x2/eax: int <- copy 0
|
||||||
var y2/ecx: int <- copy 0
|
var y2/ecx: int <- copy 0
|
||||||
x2, y2 <- screen-size screen # width, height
|
x2, y2 <- screen-size screen # width, height
|
||||||
x2, y2 <- draw-int32-decimal-wrapping-right-then-down screen, n, 0/xmin, 0/ymin, x2, y2, x, y, color
|
x2, y2 <- draw-int32-decimal-wrapping-right-then-down screen, n, 0/xmin, 0/ymin, x2, y2, x, y, color, background-color
|
||||||
return x2, y2 # cursor-x, cursor-y
|
return x2, y2 # cursor-x, cursor-y
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-int32-decimal-wrapping-right-then-down-from-cursor screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, color: int {
|
fn draw-int32-decimal-wrapping-right-then-down-from-cursor screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, color: int, background-color: int {
|
||||||
var cursor-x/eax: int <- copy 0
|
var cursor-x/eax: int <- copy 0
|
||||||
var cursor-y/ecx: int <- copy 0
|
var cursor-y/ecx: int <- copy 0
|
||||||
cursor-x, cursor-y <- cursor-position screen
|
cursor-x, cursor-y <- cursor-position screen
|
||||||
|
@ -358,14 +358,14 @@ fn draw-int32-decimal-wrapping-right-then-down-from-cursor screen: (addr screen)
|
||||||
cursor-x <- copy xmin
|
cursor-x <- copy xmin
|
||||||
cursor-y <- increment
|
cursor-y <- increment
|
||||||
}
|
}
|
||||||
cursor-x, cursor-y <- draw-int32-decimal-wrapping-right-then-down screen, n, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color
|
cursor-x, cursor-y <- draw-int32-decimal-wrapping-right-then-down screen, n, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color, background-color
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen: (addr screen), n: int, color: int {
|
fn draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen: (addr screen), n: int, color: int, background-color: int {
|
||||||
var width/eax: int <- copy 0
|
var width/eax: int <- copy 0
|
||||||
var height/ecx: int <- copy 0
|
var height/ecx: int <- copy 0
|
||||||
width, height <- screen-size screen
|
width, height <- screen-size screen
|
||||||
draw-int32-decimal-wrapping-right-then-down-from-cursor screen, n, 0/xmin, 0/ymin, width, height, color
|
draw-int32-decimal-wrapping-right-then-down-from-cursor screen, n, 0/xmin, 0/ymin, width, height, color, background-color
|
||||||
}
|
}
|
||||||
|
|
||||||
## Text direction: down then right
|
## Text direction: down then right
|
||||||
|
@ -373,7 +373,7 @@ fn draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen scre
|
||||||
# draw a single line of text vertically from x, y to ymax
|
# draw a single line of text vertically from x, y to ymax
|
||||||
# return the next 'y' coordinate
|
# return the next 'y' 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
|
||||||
fn draw-text-downward screen: (addr screen), text: (addr array byte), x: int, y: int, ymax: int, color: int -> _/eax: int {
|
fn draw-text-downward screen: (addr screen), text: (addr array byte), x: int, y: int, ymax: int, color: int, background-color: int -> _/eax: int {
|
||||||
var stream-storage: (stream byte 0x100)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/esi: (addr stream byte) <- address stream-storage
|
var stream/esi: (addr stream byte) <- address stream-storage
|
||||||
write stream, text
|
write stream, text
|
||||||
|
@ -400,7 +400,7 @@ fn draw-text-downward screen: (addr screen), text: (addr array byte), x: int, y:
|
||||||
var g/eax: grapheme <- read-grapheme stream
|
var g/eax: grapheme <- read-grapheme stream
|
||||||
compare g, 0xffffffff/end-of-file
|
compare g, 0xffffffff/end-of-file
|
||||||
break-if-=
|
break-if-=
|
||||||
draw-grapheme screen, g, x, ycurr, color
|
draw-grapheme screen, g, x, ycurr, color, background-color
|
||||||
ycurr <- increment
|
ycurr <- increment
|
||||||
loop
|
loop
|
||||||
}
|
}
|
||||||
|
@ -408,18 +408,18 @@ fn draw-text-downward screen: (addr screen), text: (addr array byte), x: int, y:
|
||||||
return ycurr
|
return ycurr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-text-downward-from-cursor screen: (addr screen), text: (addr array byte), ymax: int, color: int {
|
fn draw-text-downward-from-cursor screen: (addr screen), text: (addr array byte), ymax: int, color: int, background-color: int {
|
||||||
var cursor-x/eax: int <- copy 0
|
var cursor-x/eax: int <- copy 0
|
||||||
var cursor-y/ecx: int <- copy 0
|
var cursor-y/ecx: int <- copy 0
|
||||||
cursor-x, cursor-y <- cursor-position screen
|
cursor-x, cursor-y <- cursor-position screen
|
||||||
var result/eax: int <- draw-text-downward screen, text, cursor-x, cursor-y, ymax, color
|
var result/eax: int <- draw-text-downward screen, text, cursor-x, cursor-y, ymax, color, background-color
|
||||||
}
|
}
|
||||||
|
|
||||||
# draw text down and right in the rectangle from (xmin, ymin) to (xmax, ymax), starting from (x, y), wrapping as necessary
|
# draw text down and right in the rectangle from (xmin, ymin) to (xmax, ymax), starting from (x, y), wrapping as necessary
|
||||||
# return the next (x, y) coordinate in raster order where drawing stopped
|
# return the next (x, y) coordinate in raster order where drawing stopped
|
||||||
# that way the caller can draw more if given the same min and max bounding-box.
|
# that way the caller can draw more if given the same min and max bounding-box.
|
||||||
# if there isn't enough space, return 0 without modifying the screen
|
# if there isn't enough space, return 0 without modifying the screen
|
||||||
fn draw-text-wrapping-down-then-right screen: (addr screen), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int -> _/eax: int, _/ecx: int {
|
fn draw-text-wrapping-down-then-right screen: (addr screen), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
|
||||||
var stream-storage: (stream byte 0x100)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/esi: (addr stream byte) <- address stream-storage
|
var stream/esi: (addr stream byte) <- address stream-storage
|
||||||
write stream, text
|
write stream, text
|
||||||
|
@ -454,7 +454,7 @@ fn draw-text-wrapping-down-then-right screen: (addr screen), text: (addr array b
|
||||||
var g/eax: grapheme <- read-grapheme stream
|
var g/eax: grapheme <- read-grapheme stream
|
||||||
compare g, 0xffffffff/end-of-file
|
compare g, 0xffffffff/end-of-file
|
||||||
break-if-=
|
break-if-=
|
||||||
draw-grapheme screen, g, xcurr, ycurr, color
|
draw-grapheme screen, g, xcurr, ycurr, color, background-color
|
||||||
ycurr <- increment
|
ycurr <- increment
|
||||||
compare ycurr, ymax
|
compare ycurr, ymax
|
||||||
{
|
{
|
||||||
|
@ -468,15 +468,15 @@ fn draw-text-wrapping-down-then-right screen: (addr screen), text: (addr array b
|
||||||
return xcurr, ycurr
|
return xcurr, ycurr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-text-wrapping-down-then-right-over-full-screen screen: (addr screen), text: (addr array byte), x: int, y: int, color: int -> _/eax: int, _/ecx: int {
|
fn draw-text-wrapping-down-then-right-over-full-screen screen: (addr screen), text: (addr array byte), x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
|
||||||
var x2/eax: int <- copy 0
|
var x2/eax: int <- copy 0
|
||||||
var y2/ecx: int <- copy 0
|
var y2/ecx: int <- copy 0
|
||||||
x2, y2 <- screen-size screen # width, height
|
x2, y2 <- screen-size screen # width, height
|
||||||
x2, y2 <- draw-text-wrapping-down-then-right screen, text, 0/xmin, 0/ymin, x2, y2, x, y, color
|
x2, y2 <- draw-text-wrapping-down-then-right screen, text, 0/xmin, 0/ymin, x2, y2, x, y, color, background-color
|
||||||
return x2, y2 # cursor-x, cursor-y
|
return x2, y2 # cursor-x, cursor-y
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-text-wrapping-down-then-right-from-cursor screen: (addr screen), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, color: int {
|
fn draw-text-wrapping-down-then-right-from-cursor screen: (addr screen), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, color: int, background-color: int {
|
||||||
var cursor-x/eax: int <- copy 0
|
var cursor-x/eax: int <- copy 0
|
||||||
var cursor-y/ecx: int <- copy 0
|
var cursor-y/ecx: int <- copy 0
|
||||||
cursor-x, cursor-y <- cursor-position screen
|
cursor-x, cursor-y <- cursor-position screen
|
||||||
|
@ -488,12 +488,12 @@ fn draw-text-wrapping-down-then-right-from-cursor screen: (addr screen), text: (
|
||||||
cursor-x <- increment
|
cursor-x <- increment
|
||||||
cursor-y <- copy ymin
|
cursor-y <- copy ymin
|
||||||
}
|
}
|
||||||
cursor-x, cursor-y <- draw-text-wrapping-down-then-right screen, text, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color
|
cursor-x, cursor-y <- draw-text-wrapping-down-then-right screen, text, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color, background-color
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw-text-wrapping-down-then-right-from-cursor-over-full-screen screen: (addr screen), text: (addr array byte), color: int {
|
fn draw-text-wrapping-down-then-right-from-cursor-over-full-screen screen: (addr screen), text: (addr array byte), color: int, background-color: int {
|
||||||
var width/eax: int <- copy 0
|
var width/eax: int <- copy 0
|
||||||
var height/ecx: int <- copy 0
|
var height/ecx: int <- copy 0
|
||||||
width, height <- screen-size screen
|
width, height <- screen-size screen
|
||||||
draw-text-wrapping-down-then-right-from-cursor screen, text, 0/xmin, 0/ymin, width, height, color
|
draw-text-wrapping-down-then-right-from-cursor screen, text, 0/xmin, 0/ymin, width, height, color, background-color
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@ fn check-ints-equal _a: int, b: int, msg: (addr array byte) {
|
||||||
compare a, b
|
compare a, b
|
||||||
{
|
{
|
||||||
break-if-=
|
break-if-=
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/cyan
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/fg/cyan, 0/bg
|
||||||
count-test-failure
|
count-test-failure
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
break-if-!=
|
break-if-!=
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/cyan
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/fg/cyan, 0/bg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,23 +35,23 @@ fn check-screen-row-from screen-on-stack: (addr screen), x: int, y: int, expecte
|
||||||
compare g, expected-grapheme
|
compare g, expected-grapheme
|
||||||
{
|
{
|
||||||
break-if-!=
|
break-if-!=
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/cyan
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/fg/cyan, 0/bg
|
||||||
break $check-screen-row-from:compare-graphemes
|
break $check-screen-row-from:compare-graphemes
|
||||||
}
|
}
|
||||||
# otherwise print an error
|
# otherwise print an error
|
||||||
count-test-failure
|
count-test-failure
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/cyan
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ": expected '", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ": expected '", 3/fg/cyan, 0/bg
|
||||||
draw-grapheme-at-cursor 0/screen, expected-grapheme, 3/cyan
|
draw-grapheme-at-cursor 0/screen, expected-grapheme, 3/cyan, 0/bg
|
||||||
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3/fg/cyan, 0/bg
|
||||||
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3
|
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3/fg/cyan, 0/bg
|
||||||
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3
|
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") but observed '", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") but observed '", 3/fg/cyan, 0/bg
|
||||||
draw-grapheme-at-cursor 0/screen, g, 3/cyan
|
draw-grapheme-at-cursor 0/screen, g, 3/cyan, 0/bg
|
||||||
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3/fg/cyan, 0/bg
|
||||||
}
|
}
|
||||||
idx <- increment
|
idx <- increment
|
||||||
increment x
|
increment x
|
||||||
|
@ -102,46 +102,46 @@ fn check-screen-row-in-color-from screen-on-stack: (addr screen), fg: int, y: in
|
||||||
compare g, expected-grapheme
|
compare g, expected-grapheme
|
||||||
{
|
{
|
||||||
break-if-!=
|
break-if-!=
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/cyan
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/fg/cyan, 0/bg
|
||||||
break $check-screen-row-in-color-from:compare-graphemes
|
break $check-screen-row-in-color-from:compare-graphemes
|
||||||
}
|
}
|
||||||
# otherwise print an error
|
# otherwise print an error
|
||||||
count-test-failure
|
count-test-failure
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/cyan
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ": expected '", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ": expected '", 3/fg/cyan, 0/bg
|
||||||
draw-grapheme-at-cursor 0/screen, expected-grapheme, 3/cyan
|
draw-grapheme-at-cursor 0/screen, expected-grapheme, 3/cyan, 0/bg
|
||||||
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3/fg/cyan, 0/bg
|
||||||
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3
|
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3/fg/cyan, 0/bg
|
||||||
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3
|
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") but observed '", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") but observed '", 3/fg/cyan, 0/bg
|
||||||
draw-grapheme-at-cursor 0/screen, g, 3/cyan
|
draw-grapheme-at-cursor 0/screen, g, 3/cyan, 0/bg
|
||||||
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3/fg/cyan, 0/bg
|
||||||
}
|
}
|
||||||
$check-screen-row-in-color-from:compare-colors: {
|
$check-screen-row-in-color-from:compare-colors: {
|
||||||
var color/eax: int <- screen-color-at-idx screen, idx
|
var color/eax: int <- screen-color-at-idx screen, idx
|
||||||
compare fg, color
|
compare fg, color
|
||||||
{
|
{
|
||||||
break-if-!=
|
break-if-!=
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/cyan
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/fg/cyan, 0/bg
|
||||||
break $check-screen-row-in-color-from:compare-colors
|
break $check-screen-row-in-color-from:compare-colors
|
||||||
}
|
}
|
||||||
# otherwise print an error
|
# otherwise print an error
|
||||||
count-test-failure
|
count-test-failure
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/cyan
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ": expected '", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ": expected '", 3/fg/cyan, 0/bg
|
||||||
draw-grapheme-at-cursor 0/screen, expected-grapheme, 3/cyan
|
draw-grapheme-at-cursor 0/screen, expected-grapheme, 3/cyan, 0/bg
|
||||||
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3/fg/cyan, 0/bg
|
||||||
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3
|
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3/fg/cyan, 0/bg
|
||||||
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3
|
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") in color ", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") in color ", 3/fg/cyan, 0/bg
|
||||||
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, fg, 3
|
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, fg, 3/fg/cyan, 0/bg
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " but observed color ", 3
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " but observed color ", 3/fg/cyan, 0/bg
|
||||||
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, color, 3
|
draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, color, 3/fg/cyan, 0/bg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
idx <- increment
|
idx <- increment
|
||||||
|
@ -155,7 +155,7 @@ fn test-draw-single-grapheme {
|
||||||
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
|
var c/eax: grapheme <- copy 0x61/a
|
||||||
draw-grapheme screen, c, 0/x, 0/y, 1/color
|
draw-grapheme screen, c, 0/x, 0/y, 1/color, 0/bg
|
||||||
check-screen-row screen, 0/row, "a", "F - test-draw-single-grapheme" # top-left corner of the screen
|
check-screen-row screen, 0/row, "a", "F - test-draw-single-grapheme" # top-left corner of the screen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +163,6 @@ fn test-draw-multiple-graphemes {
|
||||||
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, 0x10/rows, 4/cols
|
initialize-screen screen, 0x10/rows, 4/cols
|
||||||
draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "Hello, 世界", 1/color
|
draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "Hello, 世界", 1/fg, 0/bg
|
||||||
check-screen-row screen, 0/screen, "Hello, 世界", "F - test-draw-multiple-graphemes"
|
check-screen-row screen, 0/screen, "Hello, 世界", "F - test-draw-multiple-graphemes"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,5 +11,5 @@
|
||||||
|
|
||||||
fn main {
|
fn main {
|
||||||
var g/eax: grapheme <- copy 0x41/A
|
var g/eax: grapheme <- copy 0x41/A
|
||||||
draw-grapheme 0/screen, g, 2/row, 1/col, 0xa/fg
|
draw-grapheme 0/screen, g, 2/row, 1/col, 0xa/fg, 0/bg
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,28 +20,28 @@ fn main {
|
||||||
compare key, 0x68/h
|
compare key, 0x68/h
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var g/eax: grapheme <- copy 0x2d/dash
|
var g/eax: grapheme <- copy 0x2d/dash
|
||||||
draw-grapheme-at-cursor 0/screen, g, 0x31
|
draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg
|
||||||
cursor-left 0
|
cursor-left 0
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
compare key, 0x6a/j
|
compare key, 0x6a/j
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var g/eax: grapheme <- copy 0x7c/vertical-bar
|
var g/eax: grapheme <- copy 0x7c/vertical-bar
|
||||||
draw-grapheme-at-cursor 0/screen, g, 0x31
|
draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg
|
||||||
cursor-down 0
|
cursor-down 0
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
compare key, 0x6b/k
|
compare key, 0x6b/k
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var g/eax: grapheme <- copy 0x7c/vertical-bar
|
var g/eax: grapheme <- copy 0x7c/vertical-bar
|
||||||
draw-grapheme-at-cursor 0/screen, g, 0x31
|
draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg
|
||||||
cursor-up 0
|
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: grapheme <- copy 0x2d/dash
|
||||||
draw-grapheme-at-cursor 0/screen, g, 0x31
|
draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg
|
||||||
cursor-right 0
|
cursor-right 0
|
||||||
}
|
}
|
||||||
loop
|
loop
|
||||||
|
|
|
@ -23,7 +23,7 @@ fn main -> _/ebx: int {
|
||||||
# read-eval-print loop
|
# read-eval-print loop
|
||||||
{
|
{
|
||||||
# print prompt
|
# print prompt
|
||||||
var x/eax: int <- draw-text-rightward 0/screen, "> ", 0/x, 0x80/xmax, y, 3/cyan
|
var x/eax: int <- draw-text-rightward 0/screen, "> ", 0/x, 0x80/xmax, y, 3/fg/cyan, 0/bg
|
||||||
set-cursor-position 0/screen, x, y
|
set-cursor-position 0/screen, x, y
|
||||||
# read line from keyboard
|
# read line from keyboard
|
||||||
clear-stream in
|
clear-stream in
|
||||||
|
@ -37,17 +37,17 @@ fn main -> _/ebx: int {
|
||||||
var key2/eax: int <- copy key
|
var key2/eax: int <- copy key
|
||||||
append-byte in, key2
|
append-byte in, key2
|
||||||
var g/eax: grapheme <- copy key2
|
var g/eax: grapheme <- copy key2
|
||||||
draw-grapheme-at-cursor 0/screen, g, 0xf
|
draw-grapheme-at-cursor 0/screen, g, 0xf/fg, 0/bg
|
||||||
cursor-right 0
|
cursor-right 0
|
||||||
loop
|
loop
|
||||||
}
|
}
|
||||||
# clear cursor
|
# clear cursor
|
||||||
draw-grapheme-at-cursor 0/screen, space, 3/fg/never-used
|
draw-grapheme-at-cursor 0/screen, space, 3/fg/never-used, 0/bg
|
||||||
# parse and eval
|
# parse and eval
|
||||||
var out/eax: int <- simplify in
|
var out/eax: int <- simplify in
|
||||||
# print
|
# print
|
||||||
y <- increment
|
y <- increment
|
||||||
out, y <- draw-int32-decimal-wrapping-right-then-down 0/screen, out, 0/xmin, y, 0x80/xmax, 0x30/ymax, 0/x, y, 7/fg
|
out, y <- draw-int32-decimal-wrapping-right-then-down 0/screen, out, 0/xmin, y, 0x80/xmax, 0x30/ymax, 0/x, y, 7/fg, 0/bg
|
||||||
# newline
|
# newline
|
||||||
y <- increment
|
y <- increment
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue