about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-22 10:13:35 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-22 10:13:35 -0700
commit670bf6ed01b539868e13c7c8f2b8a33755289e51 (patch)
tree25ab45349f0db078f26ad06bf3f930546dd52d96 /apps
parent8152b0d109a3ee01b7a357926aa01b1a8de3f366 (diff)
downloadmu-670bf6ed01b539868e13c7c8f2b8a33755289e51.tar.gz
6833 - tile: right-justify for negative numbers
Diffstat (limited to 'apps')
-rw-r--r--apps/tile/environment.mu10
-rw-r--r--apps/tile/int-stack.mu7
2 files changed, 9 insertions, 8 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index 8b7cfc1e..aeaa9167 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -211,8 +211,8 @@ fn render-column screen: (addr screen), first-word: (addr word), final-word: (ad
     evaluate first-word, final-word, stack-addr
     # render stack
     var curr-row/edx: int <- copy 6  # input-row 3 + stack-margin-top 3
-    var _max-val/eax: int <- max-stack-value stack-addr
-    var max-val/esi: int <- copy _max-val
+    var _justify-threshold/eax: int <- max-stack-justify-threshold stack-addr
+    var justify-threshold/esi: int <- copy _justify-threshold
     var i/eax: int <- int-stack-length stack-addr
     {
       compare i, 0
@@ -220,7 +220,7 @@ fn render-column screen: (addr screen), first-word: (addr word), final-word: (ad
       move-cursor screen, curr-row, indented-col
       {
         var val/eax: int <- pop-int-stack stack-addr
-        render-integer screen, val, max-val
+        render-integer screen, val, justify-threshold
         var size/eax: int <- decimal-size val
         compare size, max-width
         break-if-<=
@@ -261,7 +261,7 @@ fn render-column screen: (addr screen), first-word: (addr word), final-word: (ad
 }
 
 # synaesthesia
-fn render-integer screen: (addr screen), val: int, max-val: int {
+fn render-integer screen: (addr screen), val: int, justify-threshold: int {
   var bg/eax: int <- hash-color val
   var fg/ecx: int <- copy 7
   {
@@ -281,7 +281,7 @@ fn render-integer screen: (addr screen), val: int, max-val: int {
   }
   start-color screen, fg, bg
   print-grapheme screen, 0x20  # space
-  print-int32-decimal-right-justified screen, val, max-val
+  print-int32-decimal-right-justified screen, val, justify-threshold
   print-grapheme screen, 0x20  # space
 }
 
diff --git a/apps/tile/int-stack.mu b/apps/tile/int-stack.mu
index 74aa16fd..65b9107b 100644
--- a/apps/tile/int-stack.mu
+++ b/apps/tile/int-stack.mu
@@ -68,7 +68,7 @@ fn int-stack-length _self: (addr int-stack) -> result/eax: int {
   result <- copy *top-addr
 }
 
-fn max-stack-value _self: (addr int-stack) -> result/eax: int {
+fn max-stack-justify-threshold _self: (addr int-stack) -> result/eax: int {
   var self/esi: (addr int-stack) <- copy _self
   var data-ah/edi: (addr handle array int) <- get self, data
   var _data/eax: (addr array int) <- lookup *data-ah
@@ -80,10 +80,11 @@ fn max-stack-value _self: (addr int-stack) -> result/eax: int {
     compare i, *top-addr
     break-if->=
     var g/edx: (addr int) <- index data, i
-    compare *g, result
+    var threshold/ecx: int <- right-justify-threshold-decimal *g
+    compare threshold, result
     {
       break-if-<=
-      result <- copy *g
+      result <- copy threshold
     }
     i <- increment
     loop