Browse Source

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

Became unnecessary.
master
cancel 6 years ago
parent
commit
44f547d355
  1. 1
      base.h
  2. 2
      field.h
  3. 10
      gbuffer.h
  4. 4
      mark.c
  5. 34
      mark.h
  6. 2
      sim.c
  7. 5
      sim.h

1
base.h

@ -82,7 +82,6 @@ typedef ssize_t Isz;
typedef char Glyph; typedef char Glyph;
typedef U8 Mark; typedef U8 Mark;
typedef Glyph* Gbuffer;
typedef struct Field Field; typedef struct Field Field;
ORCA_FORCE_STATIC_INLINE Usz orca_round_up_power2(Usz x) { ORCA_FORCE_STATIC_INLINE Usz orca_round_up_power2(Usz x) {

2
field.h

@ -2,7 +2,7 @@
#include "base.h" #include "base.h"
struct Field { struct Field {
Gbuffer buffer; Glyph* buffer;
U16 height; U16 height;
U16 width; U16 width;
}; };

10
gbuffer.h

@ -1,14 +1,14 @@
#pragma once #pragma once
#include "base.h" #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) { Usz y, Usz x) {
assert(y < height && x < width); assert(y < height && x < width);
(void)height; (void)height;
return gbuf[y + width + x]; 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, Usz width, Usz y, Usz x,
Isz delta_y, Isz delta_x) { Isz delta_y, Isz delta_x) {
Isz y0 = (Isz)y + delta_y; 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]; 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) { Usz x, Glyph g) {
assert(y < height && x < width); assert(y < height && x < width);
(void)height; (void)height;
gbuf[y * width + x] = g; 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, Usz y, Usz x, Isz delta_y, Isz delta_x,
Glyph g) { Glyph g) {
Isz y0 = (Isz)y + delta_y; 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); Usz height, Usz width);
ORCA_FORCE_NO_INLINE 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); Usz height, Usz width, Glyph fill_char);

4
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 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; Usz cleared_size = height * width;
memset(map, 0, cleared_size); memset(mbuf, 0, cleared_size);
} }

34
mark.h

@ -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;
} }

2
sim.c

@ -774,7 +774,7 @@ END_OPERATOR
//////// Run simulation //////// 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, Usz tick_number, Oevent_list* oevent_list,
Piano_bits piano_bits) { Piano_bits piano_bits) {
Glyph vars_slots[Glyphs_index_count]; Glyph vars_slots[Glyphs_index_count];

5
sim.h

@ -15,5 +15,6 @@ static inline Piano_bits piano_bits_of(Glyph g) {
return UINT64_C(0); return UINT64_C(0);
} }
void orca_run(Gbuffer gbuf, Mbuffer markmap, Usz height, Usz width, void orca_run(Glyph* restrict gbuffer, Mark* restrict mbuffer, Usz height,
Usz tick_number, Oevent_list* oevent_list, Piano_bits piano_bits); Usz width, Usz tick_number, Oevent_list* oevent_list,
Piano_bits piano_bits);

Loading…
Cancel
Save