shithub: orca

Download patch

ref: 191cb6279378acfb0bcdf5a0d4ee1f76591c7a11
parent: 86d268b19fa55eec0482009eacdd4a2c60a2f04a
author: cancel <cancel@cancel.fm>
date: Tue Nov 27 12:20:20 EST 2018

Add 'G'

--- a/sim.c
+++ b/sim.c
@@ -135,6 +135,9 @@
   gbuffer_poke_relative(gbuffer, height, width, y, x, _delta_y, _delta_x,      \
                         _glyph)
 #define BECOME(_glyph) gbuffer_poke(gbuffer, height, width, y, x, _glyph)
+#define STUN(_delta_y, _delta_x)                                               \
+  mbuffer_poke_relative_flags_or(mbuffer, height, width, y, x, _delta_y,       \
+                                 _delta_x, Mark_flag_sleep)
 
 #define LOCKING Mark_flag_lock
 #define NONLOCKING Mark_flag_none
@@ -153,6 +156,10 @@
   if (!Dual_is_active)                                                         \
   return
 
+#define STOP_IF_NOT_BANGED                                                     \
+  if (!oper_has_neighboring_bang(gbuffer, height, width, y, x))                \
+  return
+
 #define I_PORT(_delta_y, _delta_x, _flags)                                     \
   mbuffer_poke_relative_flags_or(                                              \
       mbuffer, height, width, y, x, _delta_y, _delta_x,                        \
@@ -200,6 +207,7 @@
   _('W', 'w', west)                                                            \
   _('Z', 'z', southeast)                                                       \
   _('A', 'a', add)                                                             \
+  _('G', 'g', generator)                                                       \
   _('H', 'h', halt)                                                            \
   _('I', 'i', increment)                                                       \
   _('J', 'j', jump)                                                            \
@@ -233,6 +241,19 @@
   REALIZE_DUAL;
   STOP_IF_DUAL_INACTIVE;
   POKE(1, 0, glyphs_add(PEEK(0, 1), PEEK(0, 2)));
+END_PHASE
+
+BEGIN_DUAL_PHASE_0(generator)
+  REALIZE_DUAL;
+  BEGIN_DUAL_PORTS
+    I_PORT(0, 1, LOCKING);
+    O_PORT(1, 0, NONLOCKING);
+  END_PORTS
+END_PHASE
+BEGIN_DUAL_PHASE_1(generator)
+  STOP_IF_NOT_BANGED;
+  POKE(1, 0, PEEK(0, 1));
+  STUN(0, 1);
 END_PHASE
 
 BEGIN_DUAL_PHASE_0(halt)