shithub: orca

Download patch

ref: df0e1276ec2ef795f8a072a6f6768cc7ef73647c
parent: fd0c4b9b42bfd84b791b1b61d87d1382e5e1cc40
parent: a53ce88328b24b591b51d8db3f74f7b562b30c03
author: Лu Лinveгa <aliceffekt@gmail.com>
date: Mon May 20 11:28:19 EDT 2019

Merge pull request #22 from npisanti/master

changes A C D F I to match orcaJS

--- a/sim.c
+++ b/sim.c
@@ -50,7 +50,7 @@
 #else
 // Reference implementation
 static Usz index_of(Glyph c) {
-  if (c == '.')
+  if (c == '.' || c == '*')
     return 0;
   if (c >= '0' && c <= '9')
     return (Usz)(c - '0');
@@ -417,11 +417,11 @@
 
 BEGIN_OPERATOR(add)
   LOWERCASE_REQUIRES_BANG;
+  PORT(0, -1, IN);
   PORT(0, 1, IN);
-  PORT(0, 2, IN);
   PORT(1, 0, OUT);
-  Usz a = index_of(PEEK(0, 1));
-  Usz b = index_of(PEEK(0, 2));
+  Usz a = index_of(PEEK(0, -1));
+  Usz b = index_of(PEEK(0, 1));
   POKE(1, 0, indexed_glyphs[(a + b) % Glyphs_index_count]);
 END_OPERATOR
 
@@ -453,7 +453,7 @@
   if (rate == 0)
     rate = 1;
   if (mod_num == 0)
-    mod_num = 10;
+    mod_num = 8;
   Glyph g = glyph_of(Tick_number / rate % mod_num);
   POKE(1, 0, g);
 END_OPERATOR
@@ -468,7 +468,7 @@
   if (rate == 0)
     rate = 1;
   if (mod_num == 0)
-    mod_num = 10;
+    mod_num = 8;
   Glyph g = Tick_number % (rate * mod_num) == 0 ? '*' : '.';
   POKE(1, 0, g);
 END_OPERATOR
@@ -475,12 +475,12 @@
 
 BEGIN_OPERATOR(if)
   LOWERCASE_REQUIRES_BANG;
+  PORT(0, -1, IN);
   PORT(0, 1, IN);
-  PORT(0, 2, IN);
   PORT(1, 0, OUT);
-  Glyph g0 = PEEK(0, 1);
-  Glyph g1 = PEEK(0, 2);
-  POKE(1, 0, g0 == g1 ? '*' : '.');
+  Glyph g0 = PEEK(0, -1);
+  Glyph g1 = PEEK(0, 1);
+  POKE(1, 0, (g0 == g1 && g0 != '.' && g1 != '.') ? '*' : '.');
 END_OPERATOR
 
 BEGIN_OPERATOR(generator)
@@ -506,25 +506,19 @@
 
 BEGIN_OPERATOR(increment)
   LOWERCASE_REQUIRES_BANG;
+  PORT(0, -1, IN);
   PORT(0, 1, IN);
-  PORT(0, 2, IN);
   PORT(1, 0, IN | OUT);
-  Usz a = index_of(PEEK(0, 1));
-  Usz b = index_of(PEEK(0, 2));
+  Glyph g = PEEK(0, -1);
+  Usz rate = 1;
+  if (g != '.' && g != '*')
+    rate = index_of(g);
+  Usz max = index_of(PEEK(0, 1));
   Usz val = index_of(PEEK(1, 0));
-  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;
-  }
+  if (max == 0)
+    max = 36;
+  val = val + rate;
+  val = val % max;
   POKE(1, 0, glyph_of(val));
 END_OPERATOR