From a7ce765b1b57ec8a528263420852ed36da6d9d84 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Tue, 23 Jan 2024 10:30:54 +0100 Subject: Update profiling macros --- src/main.c | 94 +++++++++++++++++++++++++++----------------------------------- 1 file changed, 41 insertions(+), 53 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index a4d3421..6f1d0e6 100644 --- a/src/main.c +++ b/src/main.c @@ -11,7 +11,8 @@ WITH REGARD TO THIS SOFTWARE. // TODO: A list of features I would like to get to implement in the near future. // -// High priority: +// Remaining issues: +// // + Higher resolution clock to allow for microtiming and more accurate tempo. // + Look back again at the emulator issues... (I give up) // + Sync via MIDI with the Analogue cables. @@ -32,30 +33,18 @@ WITH REGARD TO THIS SOFTWARE. // + Fix A+B on ch3 // + Make sure Attack/Decay are grey for A+B // + Add help for attack/decay on ch3 +// + Bad performance when selecting patterns? // - Fix any bugs we currently have // - Add clipboard sharing between banks. // - Make sure transposing a sequence past the keyboard limit doesn't affect // the sequence and can be reversed. // - Study saving overhauls for bootleg cartridges. // - When putting a new trigger, make sure it uses the global parameters -// - Bad performance when selecting patterns? -// -// Low priority: -// -// Quality of life improvements. -// - When not on play mode, adjusting a note or a parameter triggers the sound. -// This could get annoying, so maybe it should be a configuration option to -// enable it? -// - Undo/Redo. -// -// Advanced +// - Improve memcpy32 performance (ASM?). We use it a lot in expensive places. // - Add tap tempo for BPM. -// - Allow "marking" several trigs to be able to copy/paste them and/or adjust -// their parameters. -// - Per trig LFO? How would we go about this? There is at least one empty slot -// in all channels. LFO amount? LFO speed? Would need a dedicated page for -// configuring LFOs - +// - Improve drawing routines even more (ASM?). +// - Improve interrupt handler to allow nesting/prioritization. +// #include "gba/gba.h" @@ -76,37 +65,37 @@ static int frames = 0; void render_sequencer(void) { if (redraw_trigs) { - PROF(draw_triggers(), draw_trigs_cycles); + draw_triggers(); redraw_trigs = false; } if (redraw_channels) { - PROF(draw_channels(), draw_btn_cycles); + draw_channels(); redraw_channels = false; } if (redraw_pattern_buttons) { - PROF(draw_pattern_buttons(), draw_btn_cycles); + draw_pattern_buttons(); redraw_pattern_buttons = false; } if (redraw_bank_buttons) { - PROF(draw_bank_buttons(), draw_btn_cycles); + draw_bank_buttons(); redraw_bank_buttons = false; } if (redraw_bpm) { - PROF(draw_bpm(), draw_btn_cycles); + draw_bpm(); redraw_bpm = false; } if (redraw_play_pause) { - PROF(draw_play(), draw_btn_cycles); - PROF(draw_stop(), draw_btn_cycles); - PROF(draw_settings(), draw_btn_cycles); + draw_play(); + draw_stop(); + draw_settings(); redraw_play_pause = false; } if (redraw_scale) { - PROF(draw_scale(), draw_btn_cycles); + draw_scale(); redraw_scale = false; } if (redraw_params) { - PROF(draw_parameters(), draw_param_cycles); + draw_parameters(); redraw_params = false; } @@ -117,11 +106,13 @@ render_sequencer(void) { } } - if (frames++ & 0x1) { + if (frames & 0x1) { draw_notif_bar(); - PROF(draw_piano_notes(), draw_piano_cycles); } - PROF(draw_cursors(), draw_cursor_cycles); + if (frames++ % 0x4 == 0) { + draw_piano_notes(); + } + draw_cursors(); } void @@ -169,28 +160,22 @@ render_settings(void) { txt_drawf("HELP", x0 + 2, y0 + 1, COL_FG); txt_drawf("%s", x1 + 8, y0 + 1, COL_FG, toggle_settings_str[settings.help]); - PROF(draw_settings_cursor(), draw_cursor_cycles); + draw_settings_cursor(); } void render(void) { - // NOTE: Debug key input - // PROF(screen_fill(COL_BG), clear_cycles); - // txt_printf("UP: %d\n", ctrl.key_up); - // txt_printf("DOWN: %d\n", ctrl.key_down); - // txt_printf("LEFT: %d\n", ctrl.key_left); - // txt_printf("RIGHT: %d\n", ctrl.key_right); - // txt_printf("A: %d\n", ctrl.key_a); - // txt_printf("B: %d\n", ctrl.key_b); - // txt_printf("L: %d\n", ctrl.key_l); - // txt_printf("R: %d\n", ctrl.key_r); - // txt_printf("SEL: %d\n", ctrl.key_select); - // txt_printf("START: %d\n", ctrl.key_start); - // txt_render(); - // txt_clear(); if (clear_screen) { - PROF(screen_fill(COL_BG), clear_cycles); + PROF(screen_fill(COL_BG), PROF_FILL); clear_screen = false; + redraw_trigs = true; + redraw_channels = true; + redraw_pattern_buttons = true; + redraw_bank_buttons = true; + redraw_bpm = true; + redraw_play_pause = true; + redraw_params = true; + redraw_scale = true; } switch (scene) { case SCENE_SETTINGS: { @@ -206,6 +191,10 @@ render(void) { void handle_input(void) { + if (key_tap(KEY_SELECT) && key_hold(KEY_START)) { + PROF_SHOW(); + clear_screen = true; + } switch (scene) { case SCENE_SETTINGS: { handle_settings_input(); @@ -218,7 +207,6 @@ handle_input(void) { void update(void) { - update_controller(); if (next_scene != scene) { scene = next_scene; clear_screen = true; @@ -269,15 +257,15 @@ main(void) { txt_spacing(6); // Main loop. + PROF_INIT(); while (true) { poll_keys(); bios_vblank_wait(); - PROF_SHOW(); FRAME_START(); - PROF(flip_buffer(), flip_cycles); - PROF(update(), update_cycles); - PROF(handle_input(), input_cycles); - PROF(render(), render_cycles); + PROF(flip_buffer(), PROF_FLIP); + PROF(update(), PROF_UPDATE); + PROF(handle_input(), PROF_INPUT); + PROF(render(), PROF_RENDER); FRAME_END(); } -- cgit v1.2.1