diff --git a/base.h b/base.h index 5630550..f2d5921 100644 --- a/base.h +++ b/base.h @@ -82,7 +82,6 @@ typedef ssize_t Isz; typedef char Glyph; typedef U8 Mark; -typedef Glyph* Gbuffer; typedef struct Field Field; ORCA_FORCE_STATIC_INLINE Usz orca_round_up_power2(Usz x) { diff --git a/field.h b/field.h index c4a1852..74cdd9c 100644 --- a/field.h +++ b/field.h @@ -2,7 +2,7 @@ #include "base.h" struct Field { - Gbuffer buffer; + Glyph* buffer; U16 height; U16 width; }; diff --git a/gbuffer.h b/gbuffer.h index 09ceaec..1b6b89c 100644 --- a/gbuffer.h +++ b/gbuffer.h @@ -1,14 +1,14 @@ #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; 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,14 +18,14 @@ ORCA_PURE static inline Glyph gbuffer_peek_relative(Gbuffer gbuf, Usz height, 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; 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 @@ void gbuffer_copy_subrect(Glyph* src, Glyph* dest, Usz src_grid_h, 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); diff --git a/mark.c b/mark.c index f3004fc..f71a395 100644 --- a/mark.c +++ b/mark.c @@ -16,7 +16,7 @@ void markmap_reusable_ensure_size(Markmap_reusable* map, Usz height, 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); } diff --git a/mark.h b/mark.h index a2b6342..6dd8523 100644 --- a/mark.h +++ b/mark.h @@ -10,10 +10,8 @@ typedef enum { 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_init(Markmap_reusable* map); 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,32 +40,32 @@ static void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height, // 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; 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 @@ 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] |= (Mark)flags; + mbuf[(Usz)y0 * map_width + (Usz)x0] |= (Mark)flags; } diff --git a/sim.c b/sim.c index 371ff5f..3926841 100644 --- a/sim.c +++ b/sim.c @@ -774,7 +774,7 @@ END_OPERATOR //////// 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]; diff --git a/sim.h b/sim.h index 1076622..e2d215e 100644 --- a/sim.h +++ b/sim.h @@ -15,5 +15,6 @@ static inline Piano_bits piano_bits_of(Glyph g) { 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);