From ce5976eed899a7214629302b7994acc48415ef81 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Fri, 7 May 2021 10:18:29 +0200 Subject: Hack for improving the flickering --- src/common.h | 1 + src/sequencer.c | 83 +++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 32 deletions(-) diff --git a/src/common.h b/src/common.h index f0c0886..aa7261e 100644 --- a/src/common.h +++ b/src/common.h @@ -156,6 +156,7 @@ typedef Color Scanline[SCREEN_WIDTH]; // affine parameters. // TODO: Benchmark if this would be slower or the same that TONC's // implementation. +// TODO: Cleanup OBJ/OAM memory copying and access. #define OBJ_ATTR_0(N) *((vu16*)(MEM_OAM + 0 + 8 * (N))) #define OBJ_ATTR_1(N) *((vu16*)(MEM_OAM + 2 + 8 * (N))) #define OBJ_ATTR_2(N) *((vu16*)(MEM_OAM + 4 + 8 * (N))) diff --git a/src/sequencer.c b/src/sequencer.c index 6f7dd21..a19cef7 100644 --- a/src/sequencer.c +++ b/src/sequencer.c @@ -900,6 +900,8 @@ init_sequencer_sprites(void) { } } +bool update_params_screen = true; + void update_sequencer_sprites(void) { // 000-015: Step note names. @@ -1049,39 +1051,45 @@ update_sequencer_sprites(void) { seq_sprites[i].obj_attr_0 |= OBJ_HIDDEN; } - if (current_selection == SEQ_SELECT_TRIGGER && channel_selection_loc == 2) { - u8 *wave_a = sequences[channel_selection_loc][trig_selection_loc].wave_a; - u8 *wave_b = sequences[channel_selection_loc][trig_selection_loc].wave_b; - - // Draw wave patterns for this trig. - int x = SEQ_ENV_POS_X + 8; - int y = SEQ_ENV_POS_Y; + if (update_params_screen) { + // Clear screen. + // draw_fill_rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 2, COLOR_BLACK); + int zero = 0; + dma_fill(FRAMEBUFFER, zero, SCREEN_WIDTH * SCREEN_HEIGHT * 2, 3); - draw_fill_rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, COLOR_BLACK); - - // Clear wave A and draw. - // draw_fill_rect(x, y, x + 64, y + 16, COLOR_BLACK); - draw_wave_pattern(wave_a, x, y, COLOR_RED); - - // Write wave text. - txt_position(x, y + 20); - txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x", - wave_a[0], wave_a[1], wave_a[2], wave_a[3], - wave_a[4], wave_a[5], wave_a[6], wave_a[7]); - txt_position(x, y + 20 + 8); - txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x", - wave_a[8], wave_a[9], wave_a[10], wave_a[11], - wave_a[12], wave_a[13], wave_a[14], wave_a[15]); - // txt_position(0,y + 20 + 8); - // txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n", - // wave_b[0], wave_b[1], wave_b[2], wave_b[3], - // wave_b[4], wave_b[5], wave_b[6], wave_b[7], - // wave_b[8], wave_b[9], wave_b[10], wave_b[11], - // wave_b[12], wave_b[13], wave_b[14], wave_b[15]); - - // Clear wave B and draw. - // draw_fill_rect(x + 64 + 16, y, x + 64 * 2 + 16, y + 16, COLOR_BLACK); - draw_wave_pattern(wave_b, x + 64 + 16, y, COLOR_CYAN); + } + if (channel_selection_loc == 2) { + if (update_params_screen) { + u8 *wave_a = sequences[channel_selection_loc][trig_selection_loc].wave_a; + u8 *wave_b = sequences[channel_selection_loc][trig_selection_loc].wave_b; + + // Draw wave patterns for this trig. + int x = SEQ_ENV_POS_X; + int y = SEQ_ENV_POS_Y; + + // Wave A. + draw_wave_pattern(wave_a, x, y, COLOR_RED); + txt_position(x - 1, y + 20); + txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x", + wave_a[0], wave_a[1], wave_a[2], wave_a[3], + wave_a[4], wave_a[5], wave_a[6], wave_a[7]); + txt_position(x - 1, y + 20 + 8); + txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x", + wave_a[8], wave_a[9], wave_a[10], wave_a[11], + wave_a[12], wave_a[13], wave_a[14], wave_a[15]); + + // Wave B. + x += 64 + 32 + 12; + draw_wave_pattern(wave_b, x, y, COLOR_CYAN); + txt_position(x - 1, y + 20); + txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x", + wave_b[0], wave_b[1], wave_b[2], wave_b[3], + wave_b[4], wave_b[5], wave_b[6], wave_b[7]); + txt_position(x - 1, y + 20 + 8); + txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x", + wave_b[8], wave_b[9], wave_b[10], wave_b[11], + wave_b[12], wave_b[13], wave_b[14], wave_b[15]); + } } else if ((current_selection == SEQ_SELECT_TRIGGER || current_selection == SEQ_SELECT_PARAMETER) && channel_selection_loc == 0) { @@ -1103,6 +1111,7 @@ update_sequencer_sprites(void) { draw_fill_rect(x, y, x + 64, y + 16, COLOR_BLACK); draw_fill_rect(x + 64 + 16, y, x + 64 * 2 + 16, y + 16, COLOR_BLACK); } + update_params_screen = false; } void @@ -1259,6 +1268,16 @@ handle_sequencer_input(void) { SOUND_SQUARE2_CTRL = 0; SOUND_WAVE_CTRL = 0; } + + if (key_pressed(KEY_LEFT) + || key_pressed(KEY_RIGHT) + || key_pressed(KEY_UP) + || key_pressed(KEY_DOWN) + || key_pressed(KEY_L) + || key_pressed(KEY_R) + ) { + update_params_screen = true; + } } void -- cgit v1.2.1