|
@ -10,10 +10,8 @@ typedef enum { |
|
|
Mark_flag_sleep = 1 << 4, |
|
|
Mark_flag_sleep = 1 << 4, |
|
|
} Mark_flags; |
|
|
} Mark_flags; |
|
|
|
|
|
|
|
|
typedef Mark* Mbuffer; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct Markmap_reusable { |
|
|
typedef struct Markmap_reusable { |
|
|
Mbuffer buffer; |
|
|
Mark* buffer; |
|
|
Usz capacity; |
|
|
Usz capacity; |
|
|
} Markmap_reusable; |
|
|
} Markmap_reusable; |
|
|
|
|
|
|
|
@ -21,20 +19,20 @@ void markmap_reusable_init(Markmap_reusable* map); |
|
|
void markmap_reusable_ensure_size(Markmap_reusable* map, Usz height, Usz width); |
|
|
void markmap_reusable_ensure_size(Markmap_reusable* map, Usz height, Usz width); |
|
|
void markmap_reusable_deinit(Markmap_reusable* map); |
|
|
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 |
|
|
ORCA_OK_IF_UNUSED |
|
|
static Mark_flags mbuffer_peek(Mbuffer map, Usz map_height, Usz map_width, |
|
|
static Mark_flags mbuffer_peek(Mark* mbuf, Usz map_height, Usz map_width, Usz y, |
|
|
Usz y, Usz x); |
|
|
Usz x); |
|
|
ORCA_OK_IF_UNUSED |
|
|
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, |
|
|
Usz map_width, Usz y, Usz x, Isz offs_y, |
|
|
Isz offs_x); |
|
|
Isz offs_x); |
|
|
ORCA_OK_IF_UNUSED |
|
|
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); |
|
|
Usz y, Usz x, Mark_flags flags); |
|
|
ORCA_OK_IF_UNUSED |
|
|
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, |
|
|
Usz map_width, Usz y, Usz x, |
|
|
Isz offs_y, Isz offs_x, |
|
|
Isz offs_y, Isz offs_x, |
|
|
Mark_flags flags); |
|
|
Mark_flags flags); |
|
@ -42,32 +40,32 @@ static void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height, |
|
|
// Inline implementation
|
|
|
// Inline implementation
|
|
|
|
|
|
|
|
|
ORCA_OK_IF_UNUSED |
|
|
ORCA_OK_IF_UNUSED |
|
|
static Mark_flags mbuffer_peek(Mbuffer map, Usz map_height, Usz map_width, |
|
|
static Mark_flags mbuffer_peek(Mark* mbuf, Usz map_height, Usz map_width, Usz y, |
|
|
Usz y, Usz x) { |
|
|
Usz x) { |
|
|
(void)map_height; |
|
|
(void)map_height; |
|
|
return map[y * map_width + x]; |
|
|
return mbuf[y * map_width + x]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ORCA_OK_IF_UNUSED |
|
|
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, |
|
|
Usz map_width, Usz y, Usz x, Isz offs_y, |
|
|
Isz offs_x) { |
|
|
Isz offs_x) { |
|
|
Isz y0 = (Isz)y + offs_y; |
|
|
Isz y0 = (Isz)y + offs_y; |
|
|
Isz x0 = (Isz)x + offs_x; |
|
|
Isz x0 = (Isz)x + offs_x; |
|
|
if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0) |
|
|
if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0) |
|
|
return Mark_flag_none; |
|
|
return Mark_flag_none; |
|
|
return map[(Usz)y0 * map_width + (Usz)x0]; |
|
|
return mbuf[(Usz)y0 * map_width + (Usz)x0]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ORCA_OK_IF_UNUSED |
|
|
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) { |
|
|
Usz y, Usz x, Mark_flags flags) { |
|
|
(void)map_height; |
|
|
(void)map_height; |
|
|
map[y * map_width + x] |= (Mark)flags; |
|
|
mbuf[y * map_width + x] |= (Mark)flags; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ORCA_OK_IF_UNUSED |
|
|
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, |
|
|
Usz map_width, Usz y, Usz x, |
|
|
Isz offs_y, Isz offs_x, |
|
|
Isz offs_y, Isz offs_x, |
|
|
Mark_flags flags) { |
|
|
Mark_flags flags) { |
|
@ -75,5 +73,5 @@ static void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height, |
|
|
Isz x0 = (Isz)x + offs_x; |
|
|
Isz x0 = (Isz)x + offs_x; |
|
|
if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0) |
|
|
if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0) |
|
|
return; |
|
|
return; |
|
|
map[(Usz)y0 * map_width + (Usz)x0] |= (Mark)flags; |
|
|
mbuf[(Usz)y0 * map_width + (Usz)x0] |= (Mark)flags; |
|
|
} |
|
|
} |
|
|