shithub: orca

Download patch

ref: dfcae4a51589a86187a548069241a09615bdb2f6
parent: 47fcbfe1b4af559ecae488d8b284ae86f04cfaec
author: cancel <cancel@cancel.fm>
date: Mon Nov 26 06:40:10 EST 2018

Add more directional operators

--- a/sim.c
+++ b/sim.c
@@ -98,17 +98,29 @@
   field_poke_relative(field, y, x, _delta_x, _delta_y, _glyph)
 #define OPER_POKE_SELF(_glyph) OPER_POKE_ABSOLUTE(y, x, _glyph)
 
-#define OPER_MOVE_OR_EXPLODE(_delta_y, _delta_x, _glyph)                       \
+#define OPER_MOVE_OR_EXPLODE(_delta_y, _delta_x)                               \
   oper_move_relative_or_explode(field->buffer, markmap, field->height,         \
-                                field->width, _glyph, y, x, _delta_y,          \
+                                field->width, This_oper_char, y, x, _delta_y,  \
                                 _delta_x);
 
+#define OPER_DEFINE_UPPERCASE_DIRECTIONAL(_oper_name, _delta_y, _delta_x)      \
+  OPER_PHASE_0(_oper_name)                                                     \
+  OPER_END                                                                     \
+  OPER_PHASE_1(_oper_name)                                                     \
+    OPER_MOVE_OR_EXPLODE(_delta_y, _delta_x)                                   \
+  OPER_END                                                                     \
+  OPER_PHASE_2(_oper_name)                                                     \
+  OPER_END
+
 //////// Operators
 
 #define ORCA_OPERATORS(_)                                                      \
   _(bang, '*')                                                                 \
   _(add, 'a')                                                                  \
+  _(North, 'N')                                                                \
   _(East, 'E')                                                                 \
+  _(South, 'S')                                                                \
+  _(West, 'W')                                                                 \
   _(modulo, 'm')
 
 ORCA_DECLARE_OPERATORS(ORCA_OPERATORS)
@@ -128,13 +140,10 @@
   }
 OPER_END
 
-OPER_PHASE_0(East)
-OPER_END
-OPER_PHASE_1(East)
-  OPER_MOVE_OR_EXPLODE(0, 1, 'E')
-OPER_END
-OPER_PHASE_2(East)
-OPER_END
+OPER_DEFINE_UPPERCASE_DIRECTIONAL(North, -1, 0)
+OPER_DEFINE_UPPERCASE_DIRECTIONAL(East, 0, 1)
+OPER_DEFINE_UPPERCASE_DIRECTIONAL(South, 1, 0)
+OPER_DEFINE_UPPERCASE_DIRECTIONAL(West, 0, -1)
 
 OPER_PHASE_0(modulo)
 OPER_END