diff --git a/cli_main.c b/cli_main.c index 68fdfe8..305237d 100644 --- a/cli_main.c +++ b/cli_main.c @@ -1,7 +1,6 @@ #include "bank.h" #include "base.h" #include "field.h" -#include "mark.h" #include "sim.h" #include diff --git a/field.c b/field.c index cfd3886..c5e27e2 100644 --- a/field.c +++ b/field.c @@ -115,3 +115,18 @@ Field_load_error field_load_file(char const* filepath, Field* field) { fclose(file); return Field_load_error_ok; } + +void mbuf_reusable_init(Mbuf_reusable* mbr) { + mbr->buffer = NULL; + mbr->capacity = 0; +} + +void mbuf_reusable_ensure_size(Mbuf_reusable* mbr, Usz height, Usz width) { + Usz capacity = height * width; + if (mbr->capacity < capacity) { + mbr->buffer = realloc(mbr->buffer, capacity); + mbr->capacity = capacity; + } +} + +void mbuf_reusable_deinit(Mbuf_reusable* mbr) { free(mbr->buffer); } diff --git a/field.h b/field.h index 8790ebb..cd66792 100644 --- a/field.h +++ b/field.h @@ -30,3 +30,20 @@ typedef enum { } Field_load_error; Field_load_error field_load_file(char const* filepath, Field* field); + +// A reusable buffer for the per-grid-cell flags. Similar to how Field is a +// reusable buffer for Glyph, Mbuf_reusable is for Mark. The naming isn't so +// great. Also like Field, the VM doesn't have to care about the buffer being +// reusable -- it only cares about a 'Mark*' type. (With the same dimensions of +// the 'Field*' buffer, since it uses them together.) There are no procedures +// for saving/loading Mark* buffers to/from disk, since we currently don't need +// that functionality. + +typedef struct Mbuf_reusable { + Mark* buffer; + Usz capacity; +} Mbuf_reusable; + +void mbuf_reusable_init(Mbuf_reusable* mbr); +void mbuf_reusable_ensure_size(Mbuf_reusable* mbr, Usz height, Usz width); +void mbuf_reusable_deinit(Mbuf_reusable* mbr); diff --git a/mark.c b/mark.c deleted file mode 100644 index d06e6fc..0000000 --- a/mark.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "mark.h" - -void mbuf_reusable_init(Mbuf_reusable* mbr) { - mbr->buffer = NULL; - mbr->capacity = 0; -} - -void mbuf_reusable_ensure_size(Mbuf_reusable* mbr, Usz height, Usz width) { - Usz capacity = height * width; - if (mbr->capacity < capacity) { - mbr->buffer = realloc(mbr->buffer, capacity); - mbr->capacity = capacity; - } -} - -void mbuf_reusable_deinit(Mbuf_reusable* mbr) { free(mbr->buffer); } diff --git a/mark.h b/mark.h deleted file mode 100644 index ba58724..0000000 --- a/mark.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "base.h" - -typedef struct Mbuf_reusable { - Mark* buffer; - Usz capacity; -} Mbuf_reusable; - -void mbuf_reusable_init(Mbuf_reusable* mbr); -void mbuf_reusable_ensure_size(Mbuf_reusable* mbr, Usz height, Usz width); -void mbuf_reusable_deinit(Mbuf_reusable* mbr); diff --git a/sim.h b/sim.h index f9f9b21..f65d61e 100644 --- a/sim.h +++ b/sim.h @@ -1,7 +1,6 @@ #pragma once #include "bank.h" #include "base.h" -#include "mark.h" #define ORCA_PIANO_KEYS_COUNT ((size_t)(('9' - '0') + 1 + ('z' - 'a') + 1)) #define ORCA_PIANO_BITS_NONE UINT64_C(0) diff --git a/tool b/tool index 6604b05..11ad50a 100755 --- a/tool +++ b/tool @@ -286,7 +286,7 @@ build_target() { ;; esac - add source_files gbuffer.c field.c mark.c bank.c sim.c + add source_files gbuffer.c field.c bank.c sim.c case "$2" in cli) add source_files cli_main.c diff --git a/tui_main.c b/tui_main.c index 051ca6e..bf8cc34 100644 --- a/tui_main.c +++ b/tui_main.c @@ -2,7 +2,6 @@ #include "base.h" #include "field.h" #include "gbuffer.h" -#include "mark.h" #include "osc_out.h" #include "sim.h" #include "term_util.h"