shithub: orca

Download patch

ref: f5dd21b4bb360cc8dbbd89aee624ed4916ccfc06
parent: 51c13b34d138923b45cc5f9d0658534f1c26f009
author: cancel <cancel@cancel.fm>
date: Mon Nov 26 08:27:15 EST 2018

Rename Markmap_buffer to Mbuffer

--- a/mark.c
+++ b/mark.c
@@ -16,7 +16,7 @@
 
 void markmap_reusable_deinit(Markmap_reusable* map) { free(map->buffer); }
 
-void markmap_clear(Markmap_buffer map, Usz height, Usz width) {
+void mbuffer_clear(Mbuffer map, Usz height, Usz width) {
   Usz cleared_size = height * width;
   memset(map, 0, cleared_size);
 }
--- a/mark.h
+++ b/mark.h
@@ -10,10 +10,10 @@
   Mark_flag_sleep = 1 << 4,
 } Mark_flags;
 
-typedef U8* Markmap_buffer;
+typedef U8* Mbuffer;
 
 typedef struct Markmap_reusable {
-  Markmap_buffer buffer;
+  Mbuffer buffer;
   Usz capacity;
 } Markmap_reusable;
 
@@ -21,14 +21,14 @@
 void markmap_reusable_ensure_size(Markmap_reusable* map, Usz height, Usz width);
 void markmap_reusable_deinit(Markmap_reusable* map);
 
-void markmap_clear(Markmap_buffer map, Usz height, Usz width);
+void mbuffer_clear(Mbuffer map, Usz height, Usz width);
 
 ORCA_FORCE_INLINE
-Mark_flags markmap_peek_relative(Markmap_buffer map, Usz map_height,
+Mark_flags mbuffer_peek_relative(Mbuffer map, Usz map_height,
                                  Usz map_width, Usz y, Usz x, Isz offs_y,
                                  Isz offs_x);
 ORCA_FORCE_INLINE
-void markmap_poke_relative(Markmap_buffer map, Usz map_height, Usz map_width,
+void mbuffer_poke_relative(Mbuffer map, Usz map_height, Usz map_width,
                            Usz y, Usz x, Isz offs_y, Isz offs_x,
                            Mark_flags flags);
 
@@ -35,7 +35,7 @@
 // Inline implementation
 
 ORCA_FORCE_INLINE
-Mark_flags markmap_peek_relative(Markmap_buffer map, Usz map_height,
+Mark_flags mbuffer_peek_relative(Mbuffer map, Usz map_height,
                                  Usz map_width, Usz y, Usz x, Isz offs_y,
                                  Isz offs_x) {
   Isz y0 = (Isz)y + offs_y;
@@ -46,7 +46,7 @@
 }
 
 ORCA_FORCE_INLINE
-void markmap_poke_relative(Markmap_buffer map, Usz map_height, Usz map_width,
+void mbuffer_poke_relative(Mbuffer map, Usz map_height, Usz map_width,
                            Usz y, Usz x, Isz offs_y, Isz offs_x,
                            Mark_flags flags) {
   Isz y0 = (Isz)y + offs_y;
@@ -57,7 +57,7 @@
 }
 
 ORCA_FORCE_INLINE
-void markmap_poke_relative_flags_or(Markmap_buffer map, Usz map_height,
+void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height,
                                     Usz map_width, Usz y, Usz x, Isz offs_y,
                                     Isz offs_x, Mark_flags flags) {
   Isz y0 = (Isz)y + offs_y;
@@ -68,7 +68,7 @@
 }
 
 ORCA_FORCE_INLINE
-void markmap_poke_flags_or(Markmap_buffer map, Usz map_height, Usz map_width,
+void mbuffer_poke_flags_or(Mbuffer map, Usz map_height, Usz map_width,
                            Usz y, Usz x, Mark_flags flags) {
   (void)map_height;
   map[y * map_width + x] |= (U8)flags;
@@ -75,7 +75,7 @@
 }
 
 ORCA_FORCE_INLINE
-Mark_flags markmap_peek(Markmap_buffer map, Usz map_height, Usz map_width,
+Mark_flags mbuffer_peek(Mbuffer map, Usz map_height, Usz map_width,
                         Usz y, Usz x) {
   (void)map_height;
   return map[y * map_width + x];
--- a/sim.c
+++ b/sim.c
@@ -48,8 +48,7 @@
          gbuffer_peek_relative(gbuf, h, w, y, x, -1, 0) == '*';
 }
 
-static inline void oper_move_relative_or_explode(Gbuffer gbuf,
-                                                 Markmap_buffer markmap,
+static inline void oper_move_relative_or_explode(Gbuffer gbuf, Mbuffer mbuf,
                                                  Usz height, Usz width,
                                                  Glyph moved, Usz y, Usz x,
                                                  Isz delta_y, Isz delta_x) {
@@ -62,19 +61,17 @@
   Glyph* at_dest = gbuf + (Usz)y0 * width + (Usz)x0;
   if (*at_dest != '.') {
     gbuf[y * width + x] = '*';
-    markmap_poke_flags_or(markmap, height, width, y, x, Mark_flag_sleep);
+    mbuffer_poke_flags_or(mbuf, height, width, y, x, Mark_flag_sleep);
     return;
   }
   *at_dest = moved;
-  markmap_poke_flags_or(markmap, height, width, (Usz)y0, (Usz)x0,
-                        Mark_flag_sleep);
+  mbuffer_poke_flags_or(mbuf, height, width, (Usz)y0, (Usz)x0, Mark_flag_sleep);
   gbuf[y * width + x] = '.';
 }
 
-static inline void oper_lock_relative(Markmap_buffer markmap, Usz height,
-                                      Usz width, Usz y, Usz x, Isz delta_y,
-                                      Isz delta_x) {
-  markmap_poke_relative_flags_or(markmap, height, width, y, x, delta_y, delta_x,
+static inline void oper_lock_relative(Mbuffer mbuf, Usz height, Usz width,
+                                      Usz y, Usz x, Isz delta_y, Isz delta_x) {
+  mbuffer_poke_relative_flags_or(mbuf, height, width, y, x, delta_y, delta_x,
                                  Mark_flag_lock);
 }
 
@@ -86,10 +83,9 @@
 
 #define OPER_PHASE_N(_phase_number, _oper_name)                                \
   static inline void oper_phase##_phase_number##_##_oper_name(                 \
-      Gbuffer gbuffer, Markmap_buffer markmap, Usz height, Usz width, Usz y,   \
-      Usz x) {                                                                 \
+      Gbuffer gbuffer, Mbuffer mbuffer, Usz height, Usz width, Usz y, Usz x) { \
     (void)gbuffer;                                                             \
-    (void)markmap;                                                             \
+    (void)mbuffer;                                                             \
     (void)height;                                                              \
     (void)width;                                                               \
     (void)y;                                                                   \
@@ -115,10 +111,10 @@
   return
 
 #define OPER_LOCK_RELATIVE(_delta_y, _delta_x)                                 \
-  oper_lock_relative(markmap, height, width, y, x, _delta_y, _delta_x)
+  oper_lock_relative(mbuffer, height, width, y, x, _delta_y, _delta_x)
 
 #define OPER_MOVE_OR_EXPLODE(_delta_y, _delta_x)                               \
-  oper_move_relative_or_explode(gbuffer, markmap, height, width,               \
+  oper_move_relative_or_explode(gbuffer, mbuffer, height, width,               \
                                 This_oper_char, y, x, _delta_y, _delta_x)
 
 #define OPER_DEFINE_UPPERCASE_DIRECTIONAL(_oper_name, _delta_y, _delta_x)      \
@@ -210,19 +206,19 @@
 OPER_PHASE_2(bang)
 OPER_END
 
-void orca_run(Gbuffer gbuf, Markmap_buffer markmap, Usz height, Usz width) {
-  markmap_clear(markmap, height, width);
+void orca_run(Gbuffer gbuf, Mbuffer mbuf, Usz height, Usz width) {
+  mbuffer_clear(mbuf, height, width);
   // Phase 0
   for (Usz iy = 0; iy < height; ++iy) {
     Glyph* glyph_row = gbuf + iy * width;
     for (Usz ix = 0; ix < width; ++ix) {
       Glyph c = glyph_row[ix];
-      if (markmap_peek(markmap, height, width, iy, ix) & Mark_flag_sleep)
+      if (mbuffer_peek(mbuf, height, width, iy, ix) & Mark_flag_sleep)
         continue;
       switch (c) {
 #define X(_oper_name, _oper_char)                                              \
   case _oper_char:                                                             \
-    oper_phase0_##_oper_name(gbuf, markmap, height, width, iy, ix);            \
+    oper_phase0_##_oper_name(gbuf, mbuf, height, width, iy, ix);               \
     break;
         ORCA_OPERATORS(X)
 #undef X
@@ -233,13 +229,13 @@
   for (Usz iy = 0; iy < height; ++iy) {
     Glyph* glyph_row = gbuf + iy * width;
     for (Usz ix = 0; ix < width; ++ix) {
-      if (markmap_peek(markmap, height, width, iy, ix) & Mark_flag_sleep)
+      if (mbuffer_peek(mbuf, height, width, iy, ix) & Mark_flag_sleep)
         continue;
       Glyph c = glyph_row[ix];
       switch (c) {
 #define X(_oper_name, _oper_char)                                              \
   case _oper_char:                                                             \
-    oper_phase1_##_oper_name(gbuf, markmap, height, width, iy, ix);            \
+    oper_phase1_##_oper_name(gbuf, mbuf, height, width, iy, ix);               \
     break;
         ORCA_OPERATORS(X)
 #undef X
--- a/sim.h
+++ b/sim.h
@@ -2,4 +2,4 @@
 #include "base.h"
 #include "mark.h"
 
-void orca_run(Gbuffer gbuf, Markmap_buffer markmap, Usz height, Usz width);
+void orca_run(Gbuffer gbuf, Mbuffer markmap, Usz height, Usz width);