shithub: orca

Download patch

ref: 03172f6c6066f7f9e788fae1692cbd9e656b1da1
parent: 33e6fc2364a5ea84d743529ecd9c753e35102646
author: cancel <cancel@cancel.fm>
date: Thu Jan 17 01:00:34 EST 2019

Update behavior of `I`

--- a/sim.c
+++ b/sim.c
@@ -489,14 +489,22 @@
   PORT(0, 1, IN);
   PORT(0, 2, IN);
   PORT(1, 0, IN | OUT);
-  Usz min = index_of(PEEK(0, 1));
-  Usz max = index_of(PEEK(0, 2));
+  Usz a = index_of(PEEK(0, 1));
+  Usz b = index_of(PEEK(0, 2));
   Usz val = index_of(PEEK(1, 0));
-  ++val;
-  if (max == 0)
-    max = 10;
-  if (val >= max)
-    val = min;
+  if (a < b) {
+    if (val < a || val >= b - 1)
+      val = a;
+    else
+      ++val;
+  } else if (a > b) {
+    if (val <= b || val > a)
+      val = a - 1;
+    else
+      --val;
+  } else {
+    return;
+  }
   POKE(1, 0, glyph_of(val));
 END_OPERATOR