summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-05-07 10:18:29 +0200
committerBad Diode <bd@badd10de.dev>2021-05-07 10:18:29 +0200
commitce5976eed899a7214629302b7994acc48415ef81 (patch)
tree63b037f974ef823b9a7e11968c9dbfbcb616491a
parentdb0c517337ffc147eb460dee2e079a9a356e7225 (diff)
downloadgba-experiments-ce5976eed899a7214629302b7994acc48415ef81.tar.gz
gba-experiments-ce5976eed899a7214629302b7994acc48415ef81.zip
Hack for improving the flickering
-rw-r--r--src/common.h1
-rw-r--r--src/sequencer.c83
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];
156// affine parameters. 156// affine parameters.
157// TODO: Benchmark if this would be slower or the same that TONC's 157// TODO: Benchmark if this would be slower or the same that TONC's
158// implementation. 158// implementation.
159// TODO: Cleanup OBJ/OAM memory copying and access.
159#define OBJ_ATTR_0(N) *((vu16*)(MEM_OAM + 0 + 8 * (N))) 160#define OBJ_ATTR_0(N) *((vu16*)(MEM_OAM + 0 + 8 * (N)))
160#define OBJ_ATTR_1(N) *((vu16*)(MEM_OAM + 2 + 8 * (N))) 161#define OBJ_ATTR_1(N) *((vu16*)(MEM_OAM + 2 + 8 * (N)))
161#define OBJ_ATTR_2(N) *((vu16*)(MEM_OAM + 4 + 8 * (N))) 162#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) {
900 } 900 }
901} 901}
902 902
903bool update_params_screen = true;
904
903void 905void
904update_sequencer_sprites(void) { 906update_sequencer_sprites(void) {
905 // 000-015: Step note names. 907 // 000-015: Step note names.
@@ -1049,39 +1051,45 @@ update_sequencer_sprites(void) {
1049 seq_sprites[i].obj_attr_0 |= OBJ_HIDDEN; 1051 seq_sprites[i].obj_attr_0 |= OBJ_HIDDEN;
1050 } 1052 }
1051 1053
1052 if (current_selection == SEQ_SELECT_TRIGGER && channel_selection_loc == 2) { 1054 if (update_params_screen) {
1053 u8 *wave_a = sequences[channel_selection_loc][trig_selection_loc].wave_a; 1055 // Clear screen.
1054 u8 *wave_b = sequences[channel_selection_loc][trig_selection_loc].wave_b; 1056 // draw_fill_rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 2, COLOR_BLACK);
1055 1057 int zero = 0;
1056 // Draw wave patterns for this trig. 1058 dma_fill(FRAMEBUFFER, zero, SCREEN_WIDTH * SCREEN_HEIGHT * 2, 3);
1057 int x = SEQ_ENV_POS_X + 8;
1058 int y = SEQ_ENV_POS_Y;
1059 1059
1060 draw_fill_rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, COLOR_BLACK); 1060 }
1061 1061 if (channel_selection_loc == 2) {
1062 // Clear wave A and draw. 1062 if (update_params_screen) {
1063 // draw_fill_rect(x, y, x + 64, y + 16, COLOR_BLACK); 1063 u8 *wave_a = sequences[channel_selection_loc][trig_selection_loc].wave_a;
1064 draw_wave_pattern(wave_a, x, y, COLOR_RED); 1064 u8 *wave_b = sequences[channel_selection_loc][trig_selection_loc].wave_b;
1065 1065
1066 // Write wave text. 1066 // Draw wave patterns for this trig.
1067 txt_position(x, y + 20); 1067 int x = SEQ_ENV_POS_X;
1068 txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x", 1068 int y = SEQ_ENV_POS_Y;
1069 wave_a[0], wave_a[1], wave_a[2], wave_a[3], 1069
1070 wave_a[4], wave_a[5], wave_a[6], wave_a[7]); 1070 // Wave A.
1071 txt_position(x, y + 20 + 8); 1071 draw_wave_pattern(wave_a, x, y, COLOR_RED);
1072 txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x", 1072 txt_position(x - 1, y + 20);
1073 wave_a[8], wave_a[9], wave_a[10], wave_a[11], 1073 txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x",
1074 wave_a[12], wave_a[13], wave_a[14], wave_a[15]); 1074 wave_a[0], wave_a[1], wave_a[2], wave_a[3],
1075 // txt_position(0,y + 20 + 8); 1075 wave_a[4], wave_a[5], wave_a[6], wave_a[7]);
1076 // txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n", 1076 txt_position(x - 1, y + 20 + 8);
1077 // wave_b[0], wave_b[1], wave_b[2], wave_b[3], 1077 txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x",
1078 // wave_b[4], wave_b[5], wave_b[6], wave_b[7], 1078 wave_a[8], wave_a[9], wave_a[10], wave_a[11],
1079 // wave_b[8], wave_b[9], wave_b[10], wave_b[11], 1079 wave_a[12], wave_a[13], wave_a[14], wave_a[15]);
1080 // wave_b[12], wave_b[13], wave_b[14], wave_b[15]); 1080
1081 1081 // Wave B.
1082 // Clear wave B and draw. 1082 x += 64 + 32 + 12;
1083 // draw_fill_rect(x + 64 + 16, y, x + 64 * 2 + 16, y + 16, COLOR_BLACK); 1083 draw_wave_pattern(wave_b, x, y, COLOR_CYAN);
1084 draw_wave_pattern(wave_b, x + 64 + 16, y, COLOR_CYAN); 1084 txt_position(x - 1, y + 20);
1085 txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x",
1086 wave_b[0], wave_b[1], wave_b[2], wave_b[3],
1087 wave_b[4], wave_b[5], wave_b[6], wave_b[7]);
1088 txt_position(x - 1, y + 20 + 8);
1089 txt_printf("%02x%02x%02x%02x %02x%02x%02x%02x",
1090 wave_b[8], wave_b[9], wave_b[10], wave_b[11],
1091 wave_b[12], wave_b[13], wave_b[14], wave_b[15]);
1092 }
1085 } else if ((current_selection == SEQ_SELECT_TRIGGER 1093 } else if ((current_selection == SEQ_SELECT_TRIGGER
1086 || current_selection == SEQ_SELECT_PARAMETER) 1094 || current_selection == SEQ_SELECT_PARAMETER)
1087 && channel_selection_loc == 0) { 1095 && channel_selection_loc == 0) {
@@ -1103,6 +1111,7 @@ update_sequencer_sprites(void) {
1103 draw_fill_rect(x, y, x + 64, y + 16, COLOR_BLACK); 1111 draw_fill_rect(x, y, x + 64, y + 16, COLOR_BLACK);
1104 draw_fill_rect(x + 64 + 16, y, x + 64 * 2 + 16, y + 16, COLOR_BLACK); 1112 draw_fill_rect(x + 64 + 16, y, x + 64 * 2 + 16, y + 16, COLOR_BLACK);
1105 } 1113 }
1114 update_params_screen = false;
1106} 1115}
1107 1116
1108void 1117void
@@ -1259,6 +1268,16 @@ handle_sequencer_input(void) {
1259 SOUND_SQUARE2_CTRL = 0; 1268 SOUND_SQUARE2_CTRL = 0;
1260 SOUND_WAVE_CTRL = 0; 1269 SOUND_WAVE_CTRL = 0;
1261 } 1270 }
1271
1272 if (key_pressed(KEY_LEFT)
1273 || key_pressed(KEY_RIGHT)
1274 || key_pressed(KEY_UP)
1275 || key_pressed(KEY_DOWN)
1276 || key_pressed(KEY_L)
1277 || key_pressed(KEY_R)
1278 ) {
1279 update_params_screen = true;
1280 }
1262} 1281}
1263 1282
1264void 1283void