about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-28 22:01:26 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-28 22:01:26 -0700
commit3640f1dfe9686d84c67e22497c0b636e1f24eb0b (patch)
treecfe73423b76ab2f3cd568acf5a5c77e570095628
parent2c51a46455c9dde990cfda0ed345b6e976a8aba5 (diff)
downloadmu-3640f1dfe9686d84c67e22497c0b636e1f24eb0b.tar.gz
support unused screen-cells in fake screens
We'll need this when rendering 16-bit glyphs. They'll occupy two
8x16 display units on screen, but the grapheme is a single unit as far
as fake screens are concerned.
-rw-r--r--500fake-screen.mu19
-rw-r--r--504test-screen.mu12
2 files changed, 31 insertions, 0 deletions
diff --git a/500fake-screen.mu b/500fake-screen.mu
index a2e9ae40..1d13f2cf 100644
--- a/500fake-screen.mu
+++ b/500fake-screen.mu
@@ -28,6 +28,7 @@ type screen-cell {
   data: grapheme
   color: int
   background-color: int
+  unused?: boolean
 }
 
 fn initialize-screen _screen: (addr screen), width: int, height: int, pixel-graphics?: boolean {
@@ -424,6 +425,24 @@ fn clear-rect-on-real-screen xmin: int, ymin: int, xmax: int, ymax: int, backgro
   }
 }
 
+fn screen-cell-unused-at? _screen: (addr screen), x: int, y: int -> _/eax: boolean {
+  var screen/esi: (addr screen) <- copy _screen
+  var index/ecx: int <- screen-cell-index screen, x, y
+  var result/eax: boolean <- screen-cell-unused-at-index? screen, index
+  return result
+}
+
+fn screen-cell-unused-at-index? _screen: (addr screen), _index: int -> _/eax: boolean {
+  var screen/esi: (addr screen) <- copy _screen
+  var data-ah/eax: (addr handle array screen-cell) <- get screen, data
+  var data/eax: (addr array screen-cell) <- lookup *data-ah
+  var index/ecx: int <- copy _index
+  var offset/ecx: (offset screen-cell) <- compute-offset data, index
+  var cell/eax: (addr screen-cell) <- index data, offset
+  var src/eax: (addr boolean) <- get cell, unused?
+  return *src
+}
+
 fn screen-grapheme-at _screen: (addr screen), x: int, y: int -> _/eax: grapheme {
   var screen/esi: (addr screen) <- copy _screen
   var index/ecx: int <- screen-cell-index screen, x, y
diff --git a/504test-screen.mu b/504test-screen.mu
index 553c6112..da146fb6 100644
--- a/504test-screen.mu
+++ b/504test-screen.mu
@@ -21,6 +21,9 @@ fn check-screen-row-from _screen: (addr screen), x: int, y: int, expected: (addr
     compare done?, 0
     break-if-!=
     {
+      var unused?/eax: boolean <- screen-cell-unused-at-index? screen, index
+      compare unused?, 0/false
+      break-if-!=
       var _g/eax: grapheme <- screen-grapheme-at-index screen, index
       var g/ebx: grapheme <- copy _g
       var expected-grapheme/eax: grapheme <- read-grapheme e-addr
@@ -86,6 +89,9 @@ fn check-screen-row-in-color-from _screen: (addr screen), fg: int, y: int, x: in
     compare done?, 0
     break-if-!=
     {
+      var unused?/eax: boolean <- screen-cell-unused-at-index? screen, index
+      compare unused?, 0/false
+      break-if-!=
       var _g/eax: grapheme <- screen-grapheme-at-index screen, index
       var g/ebx: grapheme <- copy _g
       var _expected-grapheme/eax: grapheme <- read-grapheme e-addr
@@ -179,6 +185,9 @@ fn check-screen-row-in-background-color-from _screen: (addr screen), bg: int, y:
     compare done?, 0
     break-if-!=
     {
+      var unused?/eax: boolean <- screen-cell-unused-at-index? screen, index
+      compare unused?, 0/false
+      break-if-!=
       var _g/eax: grapheme <- screen-grapheme-at-index screen, index
       var g/ebx: grapheme <- copy _g
       var _expected-grapheme/eax: grapheme <- read-grapheme e-addr
@@ -277,6 +286,9 @@ fn check-background-color-in-screen-row-from _screen: (addr screen), bg: int, y:
     compare done?, 0
     break-if-!=
     {
+      var unused?/eax: boolean <- screen-cell-unused-at-index? screen, index
+      compare unused?, 0/false
+      break-if-!=
       var _expected-bit/eax: grapheme <- read-grapheme e-addr
       var expected-bit/edi: grapheme <- copy _expected-bit
       $check-background-color-in-screen-row-from:compare-cells: {