shithub: orca

Download patch

ref: 1642d837654833d244b4faf4e8444ff12b214f48
parent: 0ee76d0d00c2701f3ca11ef47501f0eee60f089e
author: cancel <cancel@cancel.fm>
date: Sun Jan 26 21:59:39 EST 2020

Rename bank.h/.c to vmio.h/.c

--- a/bank.c
+++ /dev/null
@@ -1,33 +1,0 @@
-#include "bank.h"
-
-void oevent_list_init(Oevent_list *olist) {
-  olist->buffer = NULL;
-  olist->count = 0;
-  olist->capacity = 0;
-}
-void oevent_list_deinit(Oevent_list *olist) { free(olist->buffer); }
-void oevent_list_clear(Oevent_list *olist) { olist->count = 0; }
-void oevent_list_copy(Oevent_list const *src, Oevent_list *dest) {
-  Usz src_count = src->count;
-  if (dest->capacity < src_count) {
-    Usz new_cap = orca_round_up_power2(src_count);
-    dest->buffer = realloc(dest->buffer, new_cap * sizeof(Oevent));
-    dest->capacity = new_cap;
-  }
-  memcpy(dest->buffer, src->buffer, src_count * sizeof(Oevent));
-  dest->count = src_count;
-}
-Oevent *oevent_list_alloc_item(Oevent_list *olist) {
-  Usz count = olist->count;
-  if (olist->capacity == count) {
-    // Note: no overflow check, but you're probably out of memory if this
-    // happens anyway. Like other uses of realloc in orca, we also don't check
-    // for a failed allocation.
-    Usz capacity = count < 16 ? 16 : orca_round_up_power2(count + 1);
-    olist->buffer = realloc(olist->buffer, capacity * sizeof(Oevent));
-    olist->capacity = capacity;
-  }
-  Oevent *result = olist->buffer + count;
-  olist->count = count + 1;
-  return result;
-}
--- a/bank.h
+++ /dev/null
@@ -1,68 +1,0 @@
-#pragma once
-#include "base.h"
-
-typedef enum {
-  Oevent_type_midi_note,
-  Oevent_type_midi_cc,
-  Oevent_type_midi_pb,
-  Oevent_type_osc_ints,
-  Oevent_type_udp_string,
-} Oevent_types;
-
-typedef struct {
-  U8 oevent_type;
-} Oevent_any;
-
-typedef struct {
-  U8 oevent_type;
-  U8 channel, octave, note, velocity, duration : 7, mono : 1;
-} Oevent_midi_note;
-
-typedef struct {
-  U8 oevent_type;
-  U8 channel, control, value;
-} Oevent_midi_cc;
-
-typedef struct {
-  U8 oevent_type;
-  U8 channel, lsb, msb;
-} Oevent_midi_pb;
-
-enum { Oevent_osc_int_count = 16 };
-
-typedef struct {
-  U8 oevent_type;
-  Glyph glyph;
-  U8 count;
-  U8 numbers[Oevent_osc_int_count];
-} Oevent_osc_ints;
-
-enum { Oevent_udp_string_count = 16 };
-
-typedef struct {
-  U8 oevent_type;
-  U8 count;
-  char chars[Oevent_udp_string_count];
-} Oevent_udp_string;
-
-typedef union {
-  Oevent_any any;
-  Oevent_midi_note midi_note;
-  Oevent_midi_cc midi_cc;
-  Oevent_midi_pb midi_pb;
-  Oevent_osc_ints osc_ints;
-  Oevent_udp_string udp_string;
-} Oevent;
-
-typedef struct {
-  Oevent *buffer;
-  Usz count, capacity;
-} Oevent_list;
-
-void oevent_list_init(Oevent_list *olist);
-void oevent_list_deinit(Oevent_list *olist);
-void oevent_list_clear(Oevent_list *olist);
-ORCA_NOINLINE
-void oevent_list_copy(Oevent_list const *src, Oevent_list *dest);
-ORCA_NOINLINE
-Oevent *oevent_list_alloc_item(Oevent_list *olist);
--- a/cli_main.c
+++ b/cli_main.c
@@ -1,8 +1,8 @@
-#include "bank.h"
 #include "base.h"
 #include "field.h"
 #include "gbuffer.h"
 #include "sim.h"
+#include "vmio.h"
 #include <getopt.h>
 
 static void usage(void) {
--- a/sim.h
+++ b/sim.h
@@ -1,6 +1,6 @@
 #pragma once
-#include "bank.h"
 #include "base.h"
+#include "vmio.h"
 
 void orca_run(Glyph *restrict gbuffer, Mark *restrict mbuffer, Usz height,
               Usz width, Usz tick_number, Oevent_list *oevent_list,
--- a/tool
+++ b/tool
@@ -329,7 +329,7 @@
       ;;
   esac
 
-  add source_files gbuffer.c field.c bank.c sim.c
+  add source_files gbuffer.c field.c vmio.c sim.c
   case $1 in
     cli)
       add source_files cli_main.c
--- a/tui_main.c
+++ b/tui_main.c
@@ -1,4 +1,3 @@
-#include "bank.h"
 #include "base.h"
 #include "field.h"
 #include "gbuffer.h"
@@ -7,6 +6,7 @@
 #include "sim.h"
 #include "sysmisc.h"
 #include "term_util.h"
+#include "vmio.h"
 #include <getopt.h>
 #include <locale.h>
 
--- /dev/null
+++ b/vmio.c
@@ -1,0 +1,33 @@
+#include "vmio.h"
+
+void oevent_list_init(Oevent_list *olist) {
+  olist->buffer = NULL;
+  olist->count = 0;
+  olist->capacity = 0;
+}
+void oevent_list_deinit(Oevent_list *olist) { free(olist->buffer); }
+void oevent_list_clear(Oevent_list *olist) { olist->count = 0; }
+void oevent_list_copy(Oevent_list const *src, Oevent_list *dest) {
+  Usz src_count = src->count;
+  if (dest->capacity < src_count) {
+    Usz new_cap = orca_round_up_power2(src_count);
+    dest->buffer = realloc(dest->buffer, new_cap * sizeof(Oevent));
+    dest->capacity = new_cap;
+  }
+  memcpy(dest->buffer, src->buffer, src_count * sizeof(Oevent));
+  dest->count = src_count;
+}
+Oevent *oevent_list_alloc_item(Oevent_list *olist) {
+  Usz count = olist->count;
+  if (olist->capacity == count) {
+    // Note: no overflow check, but you're probably out of memory if this
+    // happens anyway. Like other uses of realloc in orca, we also don't check
+    // for a failed allocation.
+    Usz capacity = count < 16 ? 16 : orca_round_up_power2(count + 1);
+    olist->buffer = realloc(olist->buffer, capacity * sizeof(Oevent));
+    olist->capacity = capacity;
+  }
+  Oevent *result = olist->buffer + count;
+  olist->count = count + 1;
+  return result;
+}
--- /dev/null
+++ b/vmio.h
@@ -1,0 +1,68 @@
+#pragma once
+#include "base.h"
+
+typedef enum {
+  Oevent_type_midi_note,
+  Oevent_type_midi_cc,
+  Oevent_type_midi_pb,
+  Oevent_type_osc_ints,
+  Oevent_type_udp_string,
+} Oevent_types;
+
+typedef struct {
+  U8 oevent_type;
+} Oevent_any;
+
+typedef struct {
+  U8 oevent_type;
+  U8 channel, octave, note, velocity, duration : 7, mono : 1;
+} Oevent_midi_note;
+
+typedef struct {
+  U8 oevent_type;
+  U8 channel, control, value;
+} Oevent_midi_cc;
+
+typedef struct {
+  U8 oevent_type;
+  U8 channel, lsb, msb;
+} Oevent_midi_pb;
+
+enum { Oevent_osc_int_count = 16 };
+
+typedef struct {
+  U8 oevent_type;
+  Glyph glyph;
+  U8 count;
+  U8 numbers[Oevent_osc_int_count];
+} Oevent_osc_ints;
+
+enum { Oevent_udp_string_count = 16 };
+
+typedef struct {
+  U8 oevent_type;
+  U8 count;
+  char chars[Oevent_udp_string_count];
+} Oevent_udp_string;
+
+typedef union {
+  Oevent_any any;
+  Oevent_midi_note midi_note;
+  Oevent_midi_cc midi_cc;
+  Oevent_midi_pb midi_pb;
+  Oevent_osc_ints osc_ints;
+  Oevent_udp_string udp_string;
+} Oevent;
+
+typedef struct {
+  Oevent *buffer;
+  Usz count, capacity;
+} Oevent_list;
+
+void oevent_list_init(Oevent_list *olist);
+void oevent_list_deinit(Oevent_list *olist);
+void oevent_list_clear(Oevent_list *olist);
+ORCA_NOINLINE
+void oevent_list_copy(Oevent_list const *src, Oevent_list *dest);
+ORCA_NOINLINE
+Oevent *oevent_list_alloc_item(Oevent_list *olist);