shithub: orca

Download patch

ref: 44f547d355521ab4921c12b89e9e1061b6a4c8d9
parent: ea71fc06eb53136d6b9bdbd13e09bbcc135430c6
author: cancel <cancel@cancel.fm>
date: Tue Jan 22 03:14:46 EST 2019

Remove use of 'Gbuffer' and 'Mbuffer' typedef wrappers

Became unnecessary.

--- a/base.h
+++ b/base.h
@@ -82,7 +82,6 @@
 typedef char Glyph;
 typedef U8 Mark;
 
-typedef Glyph* Gbuffer;
 typedef struct Field Field;
 
 ORCA_FORCE_STATIC_INLINE Usz orca_round_up_power2(Usz x) {
--- a/field.h
+++ b/field.h
@@ -2,7 +2,7 @@
 #include "base.h"
 
 struct Field {
-  Gbuffer buffer;
+  Glyph* buffer;
   U16 height;
   U16 width;
 };
--- a/gbuffer.h
+++ b/gbuffer.h
@@ -1,7 +1,7 @@
 #pragma once
 #include "base.h"
 
-ORCA_PURE static inline Glyph gbuffer_peek(Gbuffer gbuf, Usz height, Usz width,
+ORCA_PURE static inline Glyph gbuffer_peek(Glyph* gbuf, Usz height, Usz width,
                                            Usz y, Usz x) {
   assert(y < height && x < width);
   (void)height;
@@ -8,7 +8,7 @@
   return gbuf[y + width + x];
 }
 
-ORCA_PURE static inline Glyph gbuffer_peek_relative(Gbuffer gbuf, Usz height,
+ORCA_PURE static inline Glyph gbuffer_peek_relative(Glyph* gbuf, Usz height,
                                                     Usz width, Usz y, Usz x,
                                                     Isz delta_y, Isz delta_x) {
   Isz y0 = (Isz)y + delta_y;
@@ -18,7 +18,7 @@
   return gbuf[(Usz)y0 * width + (Usz)x0];
 }
 
-static inline void gbuffer_poke(Gbuffer gbuf, Usz height, Usz width, Usz y,
+static inline void gbuffer_poke(Glyph* gbuf, Usz height, Usz width, Usz y,
                                 Usz x, Glyph g) {
   assert(y < height && x < width);
   (void)height;
@@ -25,7 +25,7 @@
   gbuf[y * width + x] = g;
 }
 
-static inline void gbuffer_poke_relative(Gbuffer gbuf, Usz height, Usz width,
+static inline void gbuffer_poke_relative(Glyph* gbuf, Usz height, Usz width,
                                          Usz y, Usz x, Isz delta_y, Isz delta_x,
                                          Glyph g) {
   Isz y0 = (Isz)y + delta_y;
@@ -42,5 +42,5 @@
                           Usz height, Usz width);
 
 ORCA_FORCE_NO_INLINE
-void gbuffer_fill_subrect(Glyph* gbuffer, Usz grid_h, Usz grid_w, Usz y, Usz x,
+void gbuffer_fill_subrect(Glyph* gbuf, Usz grid_h, Usz grid_w, Usz y, Usz x,
                           Usz height, Usz width, Glyph fill_char);
--- a/mark.c
+++ b/mark.c
@@ -16,7 +16,7 @@
 
 void markmap_reusable_deinit(Markmap_reusable* map) { free(map->buffer); }
 
-void mbuffer_clear(Mbuffer map, Usz height, Usz width) {
+void mbuffer_clear(Mark* mbuf, Usz height, Usz width) {
   Usz cleared_size = height * width;
-  memset(map, 0, cleared_size);
+  memset(mbuf, 0, cleared_size);
 }
--- a/mark.h
+++ b/mark.h
@@ -10,10 +10,8 @@
   Mark_flag_sleep = 1 << 4,
 } Mark_flags;
 
-typedef Mark* Mbuffer;
-
 typedef struct Markmap_reusable {
-  Mbuffer buffer;
+  Mark* buffer;
   Usz capacity;
 } Markmap_reusable;
 
@@ -21,20 +19,20 @@
 void markmap_reusable_ensure_size(Markmap_reusable* map, Usz height, Usz width);
 void markmap_reusable_deinit(Markmap_reusable* map);
 
-void mbuffer_clear(Mbuffer map, Usz height, Usz width);
+void mbuffer_clear(Mark* mbuf, Usz height, Usz width);
 
 ORCA_OK_IF_UNUSED
-static Mark_flags mbuffer_peek(Mbuffer map, Usz map_height, Usz map_width,
-                               Usz y, Usz x);
+static Mark_flags mbuffer_peek(Mark* mbuf, Usz map_height, Usz map_width, Usz y,
+                               Usz x);
 ORCA_OK_IF_UNUSED
-static Mark_flags mbuffer_peek_relative(Mbuffer map, Usz map_height,
+static Mark_flags mbuffer_peek_relative(Mark* mbuf, Usz map_height,
                                         Usz map_width, Usz y, Usz x, Isz offs_y,
                                         Isz offs_x);
 ORCA_OK_IF_UNUSED
-static void mbuffer_poke_flags_or(Mbuffer map, Usz map_height, Usz map_width,
+static void mbuffer_poke_flags_or(Mark* mbuf, Usz map_height, Usz map_width,
                                   Usz y, Usz x, Mark_flags flags);
 ORCA_OK_IF_UNUSED
-static void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height,
+static void mbuffer_poke_relative_flags_or(Mark* mbuf, Usz map_height,
                                            Usz map_width, Usz y, Usz x,
                                            Isz offs_y, Isz offs_x,
                                            Mark_flags flags);
@@ -42,14 +40,14 @@
 // Inline implementation
 
 ORCA_OK_IF_UNUSED
-static Mark_flags mbuffer_peek(Mbuffer map, Usz map_height, Usz map_width,
-                               Usz y, Usz x) {
+static Mark_flags mbuffer_peek(Mark* mbuf, Usz map_height, Usz map_width, Usz y,
+                               Usz x) {
   (void)map_height;
-  return map[y * map_width + x];
+  return mbuf[y * map_width + x];
 }
 
 ORCA_OK_IF_UNUSED
-static Mark_flags mbuffer_peek_relative(Mbuffer map, Usz map_height,
+static Mark_flags mbuffer_peek_relative(Mark* mbuf, Usz map_height,
                                         Usz map_width, Usz y, Usz x, Isz offs_y,
                                         Isz offs_x) {
   Isz y0 = (Isz)y + offs_y;
@@ -56,18 +54,18 @@
   Isz x0 = (Isz)x + offs_x;
   if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0)
     return Mark_flag_none;
-  return map[(Usz)y0 * map_width + (Usz)x0];
+  return mbuf[(Usz)y0 * map_width + (Usz)x0];
 }
 
 ORCA_OK_IF_UNUSED
-static void mbuffer_poke_flags_or(Mbuffer map, Usz map_height, Usz map_width,
+static void mbuffer_poke_flags_or(Mark* mbuf, Usz map_height, Usz map_width,
                                   Usz y, Usz x, Mark_flags flags) {
   (void)map_height;
-  map[y * map_width + x] |= (Mark)flags;
+  mbuf[y * map_width + x] |= (Mark)flags;
 }
 
 ORCA_OK_IF_UNUSED
-static void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height,
+static void mbuffer_poke_relative_flags_or(Mark* mbuf, Usz map_height,
                                            Usz map_width, Usz y, Usz x,
                                            Isz offs_y, Isz offs_x,
                                            Mark_flags flags) {
@@ -75,5 +73,5 @@
   Isz x0 = (Isz)x + offs_x;
   if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0)
     return;
-  map[(Usz)y0 * map_width + (Usz)x0] |= (Mark)flags;
+  mbuf[(Usz)y0 * map_width + (Usz)x0] |= (Mark)flags;
 }
--- a/sim.c
+++ b/sim.c
@@ -774,7 +774,7 @@
 
 //////// Run simulation
 
-void orca_run(Gbuffer gbuf, Mbuffer mbuf, Usz height, Usz width,
+void orca_run(Glyph* restrict gbuf, Mark* restrict mbuf, Usz height, Usz width,
               Usz tick_number, Oevent_list* oevent_list,
               Piano_bits piano_bits) {
   Glyph vars_slots[Glyphs_index_count];
--- a/sim.h
+++ b/sim.h
@@ -15,5 +15,6 @@
   return UINT64_C(0);
 }
 
-void orca_run(Gbuffer gbuf, Mbuffer markmap, Usz height, Usz width,
-              Usz tick_number, Oevent_list* oevent_list, Piano_bits piano_bits);
+void orca_run(Glyph* restrict gbuffer, Mark* restrict mbuffer, Usz height,
+              Usz width, Usz tick_number, Oevent_list* oevent_list,
+              Piano_bits piano_bits);