shithub: orca

Download patch

ref: f8d8e7d5898f9d459483de98c19879333f88129a
parent: 1ee8a46b8e91fab2d9cfe8945c64c0cca41bf64b
author: cancel <cancel@cancel.fm>
date: Wed Jan 1 20:36:26 EST 2020

Remove trigger/'piano' mode.

Old orca-c feature that is not present in orca JS. This was using up the
'!' glyph, which we'll need back for MIDI CC. It was also using up the
'/' input key in the TUI, and added a bunch of stuff to the code that
probably nobody was using.

--- a/cli_main.c
+++ b/cli_main.c
@@ -103,7 +103,7 @@
   Usz max_ticks = (Usz)ticks;
   for (Usz i = 0; i < max_ticks; ++i) {
     orca_run(field.buffer, mbuf_r.buffer, field.height, field.width, i,
-             &oevent_list, ORCA_PIANO_BITS_NONE, 0);
+             &oevent_list, 0);
   }
   mbuf_reusable_deinit(&mbuf_r);
   oevent_list_deinit(&oevent_list);
--- a/sim.c
+++ b/sim.c
@@ -147,7 +147,6 @@
 
 typedef struct {
   Glyph* vars_slots;
-  Piano_bits piano_bits;
   Oevent_list* oevent_list;
   Usz random_seed;
 } Oper_extra_params;
@@ -220,7 +219,7 @@
 //////// Operators
 
 #define UNIQUE_OPERATORS(_)                                                    \
-  _('!', keys)                                                                 \
+  _('!', midicc)                                                               \
   _('#', comment)                                                              \
   _('*', bang)                                                                 \
   _(':', midi)                                                                 \
@@ -303,21 +302,8 @@
   }
 END_OPERATOR
 
-BEGIN_OPERATOR(keys)
-  PORT(0, 1, IN);
-  PORT(1, 0, OUT);
-  Glyph g = PEEK(0, 1);
-  Piano_bits pb = piano_bits_of(g);
-  // instead of this extra branch, could maybe just leave output port unlocked
-  // so the '*' goes away on its own?
-  if (pb == ORCA_PIANO_BITS_NONE)
-    return;
-  Glyph o;
-  if (ORCA_LIKELY((pb & extra_params->piano_bits) == ORCA_PIANO_BITS_NONE))
-    o = '.';
-  else
-    o = '*';
-  POKE(1, 0, o);
+BEGIN_OPERATOR(midicc)
+  // TODO unimplemented
 END_OPERATOR
 
 BEGIN_OPERATOR(comment)
@@ -758,8 +744,7 @@
 //////// Run simulation
 
 void orca_run(Glyph* restrict gbuf, Mark* restrict mbuf, Usz height, Usz width,
-              Usz tick_number, Oevent_list* oevent_list, Piano_bits piano_bits,
-              Usz random_seed) {
+              Usz tick_number, Oevent_list* oevent_list, Usz random_seed) {
   Glyph vars_slots[Glyphs_index_count];
   memset(vars_slots, '.', sizeof(vars_slots));
   mbuffer_clear(mbuf, height, width);
@@ -766,7 +751,6 @@
   oevent_list_clear(oevent_list);
   Oper_extra_params extras;
   extras.vars_slots = &vars_slots[0];
-  extras.piano_bits = piano_bits;
   extras.oevent_list = oevent_list;
   extras.random_seed = random_seed;
 
--- a/sim.h
+++ b/sim.h
@@ -2,18 +2,6 @@
 #include "bank.h"
 #include "base.h"
 
-#define ORCA_PIANO_KEYS_COUNT ((size_t)(('9' - '0') + 1 + ('z' - 'a') + 1))
-#define ORCA_PIANO_BITS_NONE UINT64_C(0)
-typedef U64 Piano_bits;
-
-static inline Piano_bits piano_bits_of(Glyph g) {
-  if (g >= '0' && g <= '9')
-    return UINT64_C(1) << (U64)((Usz)('9' - g));
-  if (g >= 'a' && g <= 'z')
-    return UINT64_C(1) << (U64)(((Usz)('z' - g)) + ((Usz)('9' - '0')) + 1);
-  return UINT64_C(0);
-}
-
 void orca_run(Glyph* restrict gbuffer, Mark* restrict mbuffer, Usz height,
               Usz width, Usz tick_number, Oevent_list* oevent_list,
-              Piano_bits piano_bits, Usz random_seed);
+              Usz random_seed);
--- a/tui_main.c
+++ b/tui_main.c
@@ -189,9 +189,8 @@
 
 typedef enum {
   Ged_input_mode_normal = 0,
-  Ged_input_mode_append = 1,
-  Ged_input_mode_piano = 2,
-  Ged_input_mode_selresize = 3,
+  Ged_input_mode_append,
+  Ged_input_mode_selresize,
 } Ged_input_mode;
 
 typedef struct {
@@ -452,7 +451,7 @@
   lamps[1] = ACS_HLINE | A_normal;
   lamps[2] = ACS_HLINE | A_bold;
   lamps[3] = lamps[1];
-#else // Appearance where segments can turn off completely
+#else   // Appearance where segments can turn off completely
   lamps[0] = ' ';
   lamps[1] = ACS_HLINE | fg_bg(C_black, C_natural) | A_bold;
   lamps[2] = ACS_HLINE | A_normal;
@@ -505,10 +504,6 @@
     wattrset(win, A_bold);
     waddstr(win, "append");
     break;
-  case Ged_input_mode_piano:
-    wattrset(win, A_reverse);
-    waddstr(win, "trigger");
-    break;
   case Ged_input_mode_selresize:
     wattrset(win, A_bold);
     waddstr(win, "select");
@@ -799,7 +794,6 @@
   Oevent_list scratch_oevent_list;
   Susnote_list susnote_list;
   Ged_cursor ged_cursor;
-  Piano_bits piano_bits;
   Usz tick_num;
   Usz ruler_spacing_y, ruler_spacing_x;
   Ged_input_mode input_mode;
@@ -838,7 +832,6 @@
   oevent_list_init(&a->scratch_oevent_list);
   susnote_list_init(&a->susnote_list);
   ged_cursor_init(&a->ged_cursor);
-  a->piano_bits = ORCA_PIANO_BITS_NONE;
   a->tick_num = 0;
   a->ruler_spacing_y = 8;
   a->ruler_spacing_x = 8;
@@ -1154,9 +1147,8 @@
     apply_time_to_sustained_notes(oosc_dev, midi_mode, secs_span,
                                   &a->susnote_list, &a->time_to_next_note_off);
     orca_run(a->field.buffer, a->mbuf_r.buffer, a->field.height, a->field.width,
-             a->tick_num, &a->oevent_list, a->piano_bits, a->random_seed);
+             a->tick_num, &a->oevent_list, a->random_seed);
     ++a->tick_num;
-    a->piano_bits = ORCA_PIANO_BITS_NONE;
     a->needs_remarking = true;
     a->is_draw_dirty = true;
 
@@ -1247,7 +1239,7 @@
     mbuf_reusable_ensure_size(&a->mbuf_r, a->field.height, a->field.width);
     orca_run(a->scratch_field.buffer, a->mbuf_r.buffer, a->field.height,
              a->field.width, a->tick_num, &a->scratch_oevent_list,
-             a->piano_bits, a->random_seed);
+             a->random_seed);
     a->needs_remarking = false;
   }
   int win_h = a->win_h;
@@ -1330,7 +1322,6 @@
   switch (a->input_mode) {
   case Ged_input_mode_normal:
   case Ged_input_mode_append:
-  case Ged_input_mode_piano:
     switch (dir) {
     case Ged_dir_up:
       ged_move_cursor_relative(a, -step_length, 0);
@@ -1494,11 +1485,6 @@
   a->is_draw_dirty = true;
 }
 
-void ged_add_piano_bits_for_character(Ged* a, char c) {
-  Piano_bits added_bits = piano_bits_of((Glyph)c);
-  a->piano_bits |= added_bits;
-}
-
 bool ged_try_selection_clipped_to_field(Ged const* a, Usz* out_y, Usz* out_x,
                                         Usz* out_h, Usz* out_w) {
   Usz curs_y = a->ged_cursor.y;
@@ -1609,9 +1595,6 @@
       a->is_draw_dirty = true;
     }
     break;
-  case Ged_input_mode_piano:
-    ged_add_piano_bits_for_character(a, c);
-    break;
   }
 }
 
@@ -1618,7 +1601,6 @@
 typedef enum {
   Ged_input_cmd_undo,
   Ged_input_cmd_toggle_append_mode,
-  Ged_input_cmd_toggle_piano_mode,
   Ged_input_cmd_toggle_selresize_mode,
   Ged_input_cmd_step_forward,
   Ged_input_cmd_toggle_show_event_list,
@@ -1652,14 +1634,6 @@
     }
     a->is_draw_dirty = true;
     break;
-  case Ged_input_cmd_toggle_piano_mode:
-    if (a->input_mode == Ged_input_mode_piano) {
-      a->input_mode = Ged_input_mode_normal;
-    } else {
-      a->input_mode = Ged_input_mode_piano;
-    }
-    a->is_draw_dirty = true;
-    break;
   case Ged_input_cmd_toggle_selresize_mode:
     if (a->input_mode == Ged_input_mode_selresize) {
       a->input_mode = Ged_input_mode_normal;
@@ -1671,10 +1645,9 @@
   case Ged_input_cmd_step_forward:
     undo_history_push(&a->undo_hist, &a->field, a->tick_num);
     orca_run(a->field.buffer, a->mbuf_r.buffer, a->field.height, a->field.width,
-             a->tick_num, &a->oevent_list, a->piano_bits, a->random_seed);
+             a->tick_num, &a->oevent_list, a->random_seed);
     ++a->tick_num;
     a->activity_counter += a->oevent_list.count;
-    a->piano_bits = ORCA_PIANO_BITS_NONE;
     a->needs_remarking = true;
     a->is_draw_dirty = true;
     break;
@@ -2582,7 +2555,7 @@
       ged_input_cmd(&ged_state, Ged_input_cmd_toggle_append_mode);
       break;
     case '/':
-      ged_input_cmd(&ged_state, Ged_input_cmd_toggle_piano_mode);
+      // Currently unused. Formerly 'piano'/trigger mode toggle.
       break;
     case '<':
       ged_adjust_bpm(&ged_state, -1);