diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 94 |
1 files changed, 41 insertions, 53 deletions
@@ -11,7 +11,8 @@ WITH REGARD TO THIS SOFTWARE. | |||
11 | 11 | ||
12 | // TODO: A list of features I would like to get to implement in the near future. | 12 | // TODO: A list of features I would like to get to implement in the near future. |
13 | // | 13 | // |
14 | // High priority: | 14 | // Remaining issues: |
15 | // | ||
15 | // + Higher resolution clock to allow for microtiming and more accurate tempo. | 16 | // + Higher resolution clock to allow for microtiming and more accurate tempo. |
16 | // + Look back again at the emulator issues... (I give up) | 17 | // + Look back again at the emulator issues... (I give up) |
17 | // + Sync via MIDI with the Analogue cables. | 18 | // + Sync via MIDI with the Analogue cables. |
@@ -32,30 +33,18 @@ WITH REGARD TO THIS SOFTWARE. | |||
32 | // + Fix A+B on ch3 | 33 | // + Fix A+B on ch3 |
33 | // + Make sure Attack/Decay are grey for A+B | 34 | // + Make sure Attack/Decay are grey for A+B |
34 | // + Add help for attack/decay on ch3 | 35 | // + Add help for attack/decay on ch3 |
36 | // + Bad performance when selecting patterns? | ||
35 | // - Fix any bugs we currently have | 37 | // - Fix any bugs we currently have |
36 | // - Add clipboard sharing between banks. | 38 | // - Add clipboard sharing between banks. |
37 | // - Make sure transposing a sequence past the keyboard limit doesn't affect | 39 | // - Make sure transposing a sequence past the keyboard limit doesn't affect |
38 | // the sequence and can be reversed. | 40 | // the sequence and can be reversed. |
39 | // - Study saving overhauls for bootleg cartridges. | 41 | // - Study saving overhauls for bootleg cartridges. |
40 | // - When putting a new trigger, make sure it uses the global parameters | 42 | // - When putting a new trigger, make sure it uses the global parameters |
41 | // - Bad performance when selecting patterns? | 43 | // - Improve memcpy32 performance (ASM?). We use it a lot in expensive places. |
42 | // | ||
43 | // Low priority: | ||
44 | // | ||
45 | // Quality of life improvements. | ||
46 | // - When not on play mode, adjusting a note or a parameter triggers the sound. | ||
47 | // This could get annoying, so maybe it should be a configuration option to | ||
48 | // enable it? | ||
49 | // - Undo/Redo. | ||
50 | // | ||
51 | // Advanced | ||
52 | // - Add tap tempo for BPM. | 44 | // - Add tap tempo for BPM. |
53 | // - Allow "marking" several trigs to be able to copy/paste them and/or adjust | 45 | // - Improve drawing routines even more (ASM?). |
54 | // their parameters. | 46 | // - Improve interrupt handler to allow nesting/prioritization. |
55 | // - Per trig LFO? How would we go about this? There is at least one empty slot | 47 | // |
56 | // in all channels. LFO amount? LFO speed? Would need a dedicated page for | ||
57 | // configuring LFOs | ||
58 | |||
59 | 48 | ||
60 | #include "gba/gba.h" | 49 | #include "gba/gba.h" |
61 | 50 | ||
@@ -76,37 +65,37 @@ static int frames = 0; | |||
76 | void | 65 | void |
77 | render_sequencer(void) { | 66 | render_sequencer(void) { |
78 | if (redraw_trigs) { | 67 | if (redraw_trigs) { |
79 | PROF(draw_triggers(), draw_trigs_cycles); | 68 | draw_triggers(); |
80 | redraw_trigs = false; | 69 | redraw_trigs = false; |
81 | } | 70 | } |
82 | if (redraw_channels) { | 71 | if (redraw_channels) { |
83 | PROF(draw_channels(), draw_btn_cycles); | 72 | draw_channels(); |
84 | redraw_channels = false; | 73 | redraw_channels = false; |
85 | } | 74 | } |
86 | if (redraw_pattern_buttons) { | 75 | if (redraw_pattern_buttons) { |
87 | PROF(draw_pattern_buttons(), draw_btn_cycles); | 76 | draw_pattern_buttons(); |
88 | redraw_pattern_buttons = false; | 77 | redraw_pattern_buttons = false; |
89 | } | 78 | } |
90 | if (redraw_bank_buttons) { | 79 | if (redraw_bank_buttons) { |
91 | PROF(draw_bank_buttons(), draw_btn_cycles); | 80 | draw_bank_buttons(); |
92 | redraw_bank_buttons = false; | 81 | redraw_bank_buttons = false; |
93 | } | 82 | } |
94 | if (redraw_bpm) { | 83 | if (redraw_bpm) { |
95 | PROF(draw_bpm(), draw_btn_cycles); | 84 | draw_bpm(); |
96 | redraw_bpm = false; | 85 | redraw_bpm = false; |
97 | } | 86 | } |
98 | if (redraw_play_pause) { | 87 | if (redraw_play_pause) { |
99 | PROF(draw_play(), draw_btn_cycles); | 88 | draw_play(); |
100 | PROF(draw_stop(), draw_btn_cycles); | 89 | draw_stop(); |
101 | PROF(draw_settings(), draw_btn_cycles); | 90 | draw_settings(); |
102 | redraw_play_pause = false; | 91 | redraw_play_pause = false; |
103 | } | 92 | } |
104 | if (redraw_scale) { | 93 | if (redraw_scale) { |
105 | PROF(draw_scale(), draw_btn_cycles); | 94 | draw_scale(); |
106 | redraw_scale = false; | 95 | redraw_scale = false; |
107 | } | 96 | } |
108 | if (redraw_params) { | 97 | if (redraw_params) { |
109 | PROF(draw_parameters(), draw_param_cycles); | 98 | draw_parameters(); |
110 | redraw_params = false; | 99 | redraw_params = false; |
111 | } | 100 | } |
112 | 101 | ||
@@ -117,11 +106,13 @@ render_sequencer(void) { | |||
117 | } | 106 | } |
118 | } | 107 | } |
119 | 108 | ||
120 | if (frames++ & 0x1) { | 109 | if (frames & 0x1) { |
121 | draw_notif_bar(); | 110 | draw_notif_bar(); |
122 | PROF(draw_piano_notes(), draw_piano_cycles); | ||
123 | } | 111 | } |
124 | PROF(draw_cursors(), draw_cursor_cycles); | 112 | if (frames++ % 0x4 == 0) { |
113 | draw_piano_notes(); | ||
114 | } | ||
115 | draw_cursors(); | ||
125 | } | 116 | } |
126 | 117 | ||
127 | void | 118 | void |
@@ -169,28 +160,22 @@ render_settings(void) { | |||
169 | txt_drawf("HELP", x0 + 2, y0 + 1, COL_FG); | 160 | txt_drawf("HELP", x0 + 2, y0 + 1, COL_FG); |
170 | txt_drawf("%s", x1 + 8, y0 + 1, COL_FG, toggle_settings_str[settings.help]); | 161 | txt_drawf("%s", x1 + 8, y0 + 1, COL_FG, toggle_settings_str[settings.help]); |
171 | 162 | ||
172 | PROF(draw_settings_cursor(), draw_cursor_cycles); | 163 | draw_settings_cursor(); |
173 | } | 164 | } |
174 | 165 | ||
175 | void | 166 | void |
176 | render(void) { | 167 | render(void) { |
177 | // NOTE: Debug key input | ||
178 | // PROF(screen_fill(COL_BG), clear_cycles); | ||
179 | // txt_printf("UP: %d\n", ctrl.key_up); | ||
180 | // txt_printf("DOWN: %d\n", ctrl.key_down); | ||
181 | // txt_printf("LEFT: %d\n", ctrl.key_left); | ||
182 | // txt_printf("RIGHT: %d\n", ctrl.key_right); | ||
183 | // txt_printf("A: %d\n", ctrl.key_a); | ||
184 | // txt_printf("B: %d\n", ctrl.key_b); | ||
185 | // txt_printf("L: %d\n", ctrl.key_l); | ||
186 | // txt_printf("R: %d\n", ctrl.key_r); | ||
187 | // txt_printf("SEL: %d\n", ctrl.key_select); | ||
188 | // txt_printf("START: %d\n", ctrl.key_start); | ||
189 | // txt_render(); | ||
190 | // txt_clear(); | ||
191 | if (clear_screen) { | 168 | if (clear_screen) { |
192 | PROF(screen_fill(COL_BG), clear_cycles); | 169 | PROF(screen_fill(COL_BG), PROF_FILL); |
193 | clear_screen = false; | 170 | clear_screen = false; |
171 | redraw_trigs = true; | ||
172 | redraw_channels = true; | ||
173 | redraw_pattern_buttons = true; | ||
174 | redraw_bank_buttons = true; | ||
175 | redraw_bpm = true; | ||
176 | redraw_play_pause = true; | ||
177 | redraw_params = true; | ||
178 | redraw_scale = true; | ||
194 | } | 179 | } |
195 | switch (scene) { | 180 | switch (scene) { |
196 | case SCENE_SETTINGS: { | 181 | case SCENE_SETTINGS: { |
@@ -206,6 +191,10 @@ render(void) { | |||
206 | 191 | ||
207 | void | 192 | void |
208 | handle_input(void) { | 193 | handle_input(void) { |
194 | if (key_tap(KEY_SELECT) && key_hold(KEY_START)) { | ||
195 | PROF_SHOW(); | ||
196 | clear_screen = true; | ||
197 | } | ||
209 | switch (scene) { | 198 | switch (scene) { |
210 | case SCENE_SETTINGS: { | 199 | case SCENE_SETTINGS: { |
211 | handle_settings_input(); | 200 | handle_settings_input(); |
@@ -218,7 +207,6 @@ handle_input(void) { | |||
218 | 207 | ||
219 | void | 208 | void |
220 | update(void) { | 209 | update(void) { |
221 | update_controller(); | ||
222 | if (next_scene != scene) { | 210 | if (next_scene != scene) { |
223 | scene = next_scene; | 211 | scene = next_scene; |
224 | clear_screen = true; | 212 | clear_screen = true; |
@@ -269,15 +257,15 @@ main(void) { | |||
269 | txt_spacing(6); | 257 | txt_spacing(6); |
270 | 258 | ||
271 | // Main loop. | 259 | // Main loop. |
260 | PROF_INIT(); | ||
272 | while (true) { | 261 | while (true) { |
273 | poll_keys(); | 262 | poll_keys(); |
274 | bios_vblank_wait(); | 263 | bios_vblank_wait(); |
275 | PROF_SHOW(); | ||
276 | FRAME_START(); | 264 | FRAME_START(); |
277 | PROF(flip_buffer(), flip_cycles); | 265 | PROF(flip_buffer(), PROF_FLIP); |
278 | PROF(update(), update_cycles); | 266 | PROF(update(), PROF_UPDATE); |
279 | PROF(handle_input(), input_cycles); | 267 | PROF(handle_input(), PROF_INPUT); |
280 | PROF(render(), render_cycles); | 268 | PROF(render(), PROF_RENDER); |
281 | FRAME_END(); | 269 | FRAME_END(); |
282 | } | 270 | } |
283 | 271 | ||