Browse Source

Add typedef alias for U8 -> Mark

master
cancel 6 years ago
parent
commit
1bc8d428df
  1. 1
      base.h
  2. 6
      mark.h
  3. 14
      sim.c

1
base.h

@ -78,6 +78,7 @@ typedef size_t Usz;
typedef ssize_t Isz;
typedef char Glyph;
typedef U8 Mark;
typedef Glyph* Gbuffer;

6
mark.h

@ -10,7 +10,7 @@ typedef enum {
Mark_flag_sleep = 1 << 4,
} Mark_flags;
typedef U8* Mbuffer;
typedef Mark* Mbuffer;
typedef struct Markmap_reusable {
Mbuffer buffer;
@ -63,7 +63,7 @@ ORCA_OK_IF_UNUSED
static 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;
map[y * map_width + x] |= (Mark)flags;
}
ORCA_OK_IF_UNUSED
@ -75,5 +75,5 @@ static void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height,
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] |= (U8)flags;
map[(Usz)y0 * map_width + (Usz)x0] |= (Mark)flags;
}

14
sim.c

@ -162,7 +162,7 @@ Usz usz_clamp(Usz val, Usz min, Usz max) {
Usz const width, Usz const y, Usz const x, Usz Tick_number
#define OPER_PHASE_0_COMMON_ARGS \
OPER_PHASE_COMMON_ARGS, Oper_bank_write_params *const bank_params, \
U8 const cell_flags
Mark const cell_flags
#define OPER_PHASE_1_COMMON_ARGS \
OPER_PHASE_COMMON_ARGS, Oper_bank_read_params* const bank_params
@ -622,10 +622,10 @@ BEGIN_DUAL_PHASE_0(count)
Usz max_x = x + len;
if (max_x > width)
max_x = width;
U8* i = mbuffer + y * width + x + 1;
U8* e = mbuffer + y * width + max_x;
Mark* i = mbuffer + y * width + x + 1;
Mark* e = mbuffer + y * width + max_x;
while (i != e) {
*i = (U8)(*i | Mark_flag_lock);
*i = (Mark)(*i | Mark_flag_lock);
++i;
}
}
@ -830,12 +830,12 @@ static void sim_phase_0(Gbuffer gbuf, Mbuffer mbuf, Usz height, Usz width,
Usz tick_number, Oper_bank_write_params* bank_params) {
for (Usz iy = 0; iy < height; ++iy) {
Glyph const* glyph_row = gbuf + iy * width;
U8 const* mark_row = mbuf + iy * width;
Mark const* mark_row = mbuf + iy * width;
for (Usz ix = 0; ix < width; ++ix) {
Glyph glyph_char = glyph_row[ix];
if (ORCA_LIKELY(glyph_char == '.'))
continue;
U8 cell_flags = mark_row[ix] & (Mark_flag_lock | Mark_flag_sleep);
Mark cell_flags = mark_row[ix] & (Mark_flag_lock | Mark_flag_sleep);
switch (glyph_char) {
ORCA_SOLO_OPERATORS(SIM_EXPAND_SOLO_PHASE_0)
ORCA_DUAL_OPERATORS(SIM_EXPAND_DUAL_PHASE_0)
@ -848,7 +848,7 @@ static void sim_phase_1(Gbuffer gbuf, Mbuffer mbuf, Usz height, Usz width,
Usz tick_number, Oper_bank_read_params* bank_params) {
for (Usz iy = 0; iy < height; ++iy) {
Glyph const* glyph_row = gbuf + iy * width;
U8 const* mark_row = mbuf + iy * width;
Mark const* mark_row = mbuf + iy * width;
for (Usz ix = 0; ix < width; ++ix) {
Glyph glyph_char = glyph_row[ix];
if (ORCA_LIKELY(glyph_char == '.'))

Loading…
Cancel
Save