about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-02-07 15:50:16 -0800
committerKartik Agaram <vc@akkartik.com>2021-02-07 15:50:16 -0800
commit8f34dfd1e09e9e33176bba8f05a2ec229cf3b56f (patch)
tree2a627da04cef70f856a712e9bd56d186c30aa8bc
parentf626421bc4f526c48b789914a3a1e088a9250278 (diff)
downloadmu-8f34dfd1e09e9e33176bba8f05a2ec229cf3b56f.tar.gz
7693 - baremetal: pass background color everywhere
-rw-r--r--baremetal/112read-byte.subx2
-rw-r--r--baremetal/115write-byte.subx2
-rw-r--r--baremetal/120allocate.subx6
-rw-r--r--baremetal/123slice.subx4
-rw-r--r--baremetal/126write-int-decimal.subx4
-rw-r--r--baremetal/309stream.subx4
-rw-r--r--baremetal/313index-bounds-check.subx26
-rw-r--r--baremetal/500text-screen.mu28
-rw-r--r--baremetal/501draw-text.mu84
-rw-r--r--baremetal/502test.mu4
-rw-r--r--baremetal/504test-screen.mu72
-rw-r--r--baremetal/ex4.mu2
-rw-r--r--baremetal/ex7.mu8
-rw-r--r--baremetal/rpn.mu8
14 files changed, 137 insertions, 117 deletions
diff --git a/baremetal/112read-byte.subx b/baremetal/112read-byte.subx
index 4c8fcc5a..64666e9b 100644
--- a/baremetal/112read-byte.subx
+++ b/baremetal/112read-byte.subx
@@ -39,7 +39,7 @@ $read-byte:end:
     c3/return
 
 $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
     }
diff --git a/baremetal/115write-byte.subx b/baremetal/115write-byte.subx
index 0d1e52f0..0eeef216 100644
--- a/baremetal/115write-byte.subx
+++ b/baremetal/115write-byte.subx
@@ -41,7 +41,7 @@ $append-byte:end:
     c3/return
 
 $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
     }
diff --git a/baremetal/120allocate.subx b/baremetal/120allocate.subx
index d5fa0a39..4fa42743 100644
--- a/baremetal/120allocate.subx
+++ b/baremetal/120allocate.subx
@@ -130,7 +130,7 @@ $allocate-raw:end:
     c3/return
 
 $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
     }
@@ -252,7 +252,7 @@ $lookup:end:
     c3/return
 
 $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
     }
@@ -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
 # instruction.
 $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
     }
diff --git a/baremetal/123slice.subx b/baremetal/123slice.subx
index d3f4c70f..01c29290 100644
--- a/baremetal/123slice.subx
+++ b/baremetal/123slice.subx
@@ -848,7 +848,7 @@ $write-slice:end:
     c3/return
 
 $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
     }
@@ -970,7 +970,7 @@ $slice-to-string:end:
     c3/return
 
 $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
     }
diff --git a/baremetal/126write-int-decimal.subx b/baremetal/126write-int-decimal.subx
index eae331a1..9f148248 100644
--- a/baremetal/126write-int-decimal.subx
+++ b/baremetal/126write-int-decimal.subx
@@ -114,7 +114,7 @@ $write-int32-decimal:end:
     c3/return
 
 $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
     }
@@ -419,7 +419,7 @@ $to-decimal-digit:end:
     c3/return
 
 $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
     }
diff --git a/baremetal/309stream.subx b/baremetal/309stream.subx
index fc727329..56b19272 100644
--- a/baremetal/309stream.subx
+++ b/baremetal/309stream.subx
@@ -98,7 +98,7 @@ $write-to-stream:end:
     c3/return
 
 $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
     }
@@ -151,7 +151,7 @@ $read-from-stream:end:
     c3/return
 
 $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
     }
diff --git a/baremetal/313index-bounds-check.subx b/baremetal/313index-bounds-check.subx
index 6970e23a..c9d01ee2 100644
--- a/baremetal/313index-bounds-check.subx
+++ b/baremetal/313index-bounds-check.subx
@@ -26,13 +26,13 @@ __check-mu-array-bounds:  # index: int, elem-size: int, arr-size: int, function-
     39/compare %eax 1/r32/ecx
     0f 82/jump-if-unsigned< $__check-mu-array-bounds:end/disp32  # negative index should always abort
     # 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 *(ebp+0x14) 3)  # 3=cyan
-    (draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 ": offset " 3)  # 3=cyan
-    (draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0 %eax 3)  # 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 *(ebp+0x18) 3)  # 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 "fn " 3 0)  # 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 0)  # 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 0)  # 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 0)  # 3=cyan
     {
       eb/jump loop/disp8
     }
@@ -48,12 +48,12 @@ $__check-mu-array-bounds:end:
     c3/return
 
 __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 *(ebp+0x14) 3)  # 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 overflowed 32 bits" 3)  # 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 "' overflowed 32 bits" 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 0)  # 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 0)  # 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 0)  # 3=cyan
     {
       eb/jump loop/disp8
     }
diff --git a/baremetal/500text-screen.mu b/baremetal/500text-screen.mu
index cd72209b..3cdc8d51 100644
--- a/baremetal/500text-screen.mu
+++ b/baremetal/500text-screen.mu
@@ -17,6 +17,7 @@ type screen {
 type screen-cell {
   data: grapheme
   color: int
+  background-color: 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
 # 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
     break-if-!=
-    draw-grapheme-on-real-screen g, x, y, color, 0
+    draw-grapheme-on-real-screen g, x, y, color, background-color
     return
   }
   # fake screen
@@ -170,7 +171,7 @@ fn show-cursor screen: (addr screen), g: grapheme {
   var cursor-x/eax: int <- copy 0
   var cursor-y/ecx: int <- copy 0
   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) {
@@ -194,7 +195,7 @@ fn clear-screen screen: (addr screen) {
     {
       compare x, *width
       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
       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
   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
+}
diff --git a/baremetal/501draw-text.mu b/baremetal/501draw-text.mu
index fc69c604..0d0d1ce8 100644
--- a/baremetal/501draw-text.mu
+++ b/baremetal/501draw-text.mu
@@ -60,17 +60,17 @@ fn cursor-down screen: (addr screen) {
   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-y/ecx: int <- copy 0
   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
 # return the next 'x' coordinate
 # 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/esi: (addr stream byte) <- address stream-storage
   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
     compare g, 0xffffffff/end-of-file
     break-if-=
-    draw-grapheme screen, g, xcurr, y, color
+    draw-grapheme screen, g, xcurr, y, color, background-color
     xcurr <- increment
     loop
   }
@@ -105,11 +105,11 @@ fn draw-text-rightward screen: (addr screen), text: (addr array byte), x: int, x
   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-y/ecx: int <- copy 0
   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
 }
 
@@ -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
 # 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
-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/esi: (addr stream byte) <- address stream-storage
   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
     compare g, 0xffffffff/end-of-file
     break-if-=
-    draw-grapheme screen, g, xcurr, ycurr, color
+    draw-grapheme screen, g, xcurr, ycurr, color, background-color
     xcurr <- increment
     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
 }
 
-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 y2/ecx: int <- copy 0
   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
 }
 
-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-y/ecx: int <- copy 0
   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-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 height/ecx: int <- copy 0
   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/esi: (addr stream byte) <- address stream-storage
   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
     compare g, 0xffffffff/end-of-file
     break-if-=
-    draw-grapheme screen, g, xcurr, ycurr, color
+    draw-grapheme screen, g, xcurr, ycurr, color, background-color
     xcurr <- increment
     compare xcurr, xmax
     {
@@ -259,15 +259,15 @@ fn draw-int32-hex-wrapping-right-then-down screen: (addr screen), n: int, xmin:
   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 y2/ecx: int <- copy 0
   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
 }
 
-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-y/ecx: int <- copy 0
   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-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 height/ecx: int <- copy 0
   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/esi: (addr stream byte) <- address stream-storage
   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
     compare g, 0xffffffff/end-of-file
     break-if-=
-    draw-grapheme screen, g, xcurr, ycurr, color
+    draw-grapheme screen, g, xcurr, ycurr, color, background-color
     xcurr <- increment
     compare xcurr, xmax
     {
@@ -338,15 +338,15 @@ fn draw-int32-decimal-wrapping-right-then-down screen: (addr screen), n: int, xm
   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 y2/ecx: int <- copy 0
   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
 }
 
-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-y/ecx: int <- copy 0
   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-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 height/ecx: int <- copy 0
   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
@@ -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
 # return the next 'y' coordinate
 # 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/esi: (addr stream byte) <- address stream-storage
   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
     compare g, 0xffffffff/end-of-file
     break-if-=
-    draw-grapheme screen, g, x, ycurr, color
+    draw-grapheme screen, g, x, ycurr, color, background-color
     ycurr <- increment
     loop
   }
@@ -408,18 +408,18 @@ fn draw-text-downward screen: (addr screen), text: (addr array byte), x: int, y:
   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-y/ecx: int <- copy 0
   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
 # 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.
 # 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/esi: (addr stream byte) <- address stream-storage
   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
     compare g, 0xffffffff/end-of-file
     break-if-=
-    draw-grapheme screen, g, xcurr, ycurr, color
+    draw-grapheme screen, g, xcurr, ycurr, color, background-color
     ycurr <- increment
     compare ycurr, ymax
     {
@@ -468,15 +468,15 @@ fn draw-text-wrapping-down-then-right screen: (addr screen), text: (addr array b
   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 y2/ecx: int <- copy 0
   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
 }
 
-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-y/ecx: int <- copy 0
   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-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 height/ecx: int <- copy 0
   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
 }
diff --git a/baremetal/502test.mu b/baremetal/502test.mu
index 2683d206..d26eaeb1 100644
--- a/baremetal/502test.mu
+++ b/baremetal/502test.mu
@@ -4,13 +4,13 @@ fn check-ints-equal _a: int, b: int, msg: (addr array byte) {
   compare a, b
   {
     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
     return
   }
   {
     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
   }
 }
 
diff --git a/baremetal/504test-screen.mu b/baremetal/504test-screen.mu
index 07efcc7f..a3d12957 100644
--- a/baremetal/504test-screen.mu
+++ b/baremetal/504test-screen.mu
@@ -35,23 +35,23 @@ fn check-screen-row-from screen-on-stack: (addr screen), x: int, y: int, expecte
       compare g, expected-grapheme
       {
         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
       }
       # otherwise print an error
       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, ": expected '", 3
-      draw-grapheme-at-cursor 0/screen, expected-grapheme, 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/fg/cyan, 0/bg
+      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
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3
-      draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3
-      draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") but observed '", 3
-      draw-grapheme-at-cursor 0/screen, g, 3/cyan
+      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/fg/cyan, 0/bg
+      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/fg/cyan, 0/bg
+      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, 0/bg
       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
     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
         {
           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
         }
         # otherwise print an error
         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, ": expected '", 3
-        draw-grapheme-at-cursor 0/screen, expected-grapheme, 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/fg/cyan, 0/bg
+        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
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") but observed '", 3
-        draw-grapheme-at-cursor 0/screen, g, 3/cyan
+        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/fg/cyan, 0/bg
+        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/fg/cyan, 0/bg
+        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, 0/bg
         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: {
         var color/eax: int <- screen-color-at-idx screen, idx
         compare fg, color
         {
           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
         }
         # otherwise print an error
         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, ": expected '", 3
-        draw-grapheme-at-cursor 0/screen, expected-grapheme, 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/fg/cyan, 0/bg
+        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
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") in color ", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, fg, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " but observed color ", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, color, 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/fg/cyan, 0/bg
+        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/fg/cyan, 0/bg
+        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/fg/cyan, 0/bg
+        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/fg/cyan, 0/bg
       }
     }
     idx <- increment
@@ -155,7 +155,7 @@ fn test-draw-single-grapheme {
   var screen/esi: (addr screen) <- address screen-on-stack
   initialize-screen screen, 5, 4
   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
 }
 
@@ -163,6 +163,6 @@ fn test-draw-multiple-graphemes {
   var screen-on-stack: screen
   var screen/esi: (addr screen) <- address screen-on-stack
   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"
 }
diff --git a/baremetal/ex4.mu b/baremetal/ex4.mu
index 2c09d15a..ede48e09 100644
--- a/baremetal/ex4.mu
+++ b/baremetal/ex4.mu
@@ -11,5 +11,5 @@
 
 fn main {
   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
 }
diff --git a/baremetal/ex7.mu b/baremetal/ex7.mu
index 82529644..d6bca444 100644
--- a/baremetal/ex7.mu
+++ b/baremetal/ex7.mu
@@ -20,28 +20,28 @@ fn main {
       compare key, 0x68/h
       break-if-!=
       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
     }
     {
       compare key, 0x6a/j
       break-if-!=
       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
     }
     {
       compare key, 0x6b/k
       break-if-!=
       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
     }
     {
       compare key, 0x6c/l
       break-if-!=
       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
     }
     loop
diff --git a/baremetal/rpn.mu b/baremetal/rpn.mu
index b309409f..65959957 100644
--- a/baremetal/rpn.mu
+++ b/baremetal/rpn.mu
@@ -23,7 +23,7 @@ fn main -> _/ebx: int {
   # read-eval-print loop
   {
     # 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
     # read line from keyboard
     clear-stream in
@@ -37,17 +37,17 @@ fn main -> _/ebx: int {
       var key2/eax: int <- copy key
       append-byte in, 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
       loop
     }
     # 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
     var out/eax: int <- simplify in
     # print
     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
     y <- increment
     #