summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-05-02 12:47:07 +0200
committerBad Diode <bd@badd10de.dev>2021-05-02 12:47:07 +0200
commit70cf18e60a945927d1ca24e480b62a675b822f89 (patch)
tree2a6566787d3041810e89515e7fb51bbbf62ad9bd
parentc9fbc44912f54a0263b6c1514f086cc1b5ef3079 (diff)
downloadgba-experiments-70cf18e60a945927d1ca24e480b62a675b822f89.tar.gz
gba-experiments-70cf18e60a945927d1ca24e480b62a675b822f89.zip
Update note names depending on the sequence
-rw-r--r--src/main.c2
-rw-r--r--src/sequencer.c171
2 files changed, 95 insertions, 78 deletions
diff --git a/src/main.c b/src/main.c
index b3a4d5a..08816f3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -60,6 +60,8 @@ int main(void) {
60 TIMER_CTRL_0 ^= TIMER_CTRL_ENABLE; 60 TIMER_CTRL_0 ^= TIMER_CTRL_ENABLE;
61 } 61 }
62 62
63 update_sequencer_sprites();
64
63 // txt_position(1,6); 65 // txt_position(1,6);
64 // txt_clear_line(); 66 // txt_clear_line();
65 // txt_printf(" BPM: %d\n\n", bpm); 67 // txt_printf(" BPM: %d\n\n", bpm);
diff --git a/src/sequencer.c b/src/sequencer.c
index 4231def..8ebb9af 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -2,79 +2,79 @@
2#define SPRITE_NOTE_NAMES_H 8 2#define SPRITE_NOTE_NAMES_H 8
3 3
4u32 sprite_note_names[] = { 4u32 sprite_note_names[] = {
5 0x77417111, 0x77000000, 0x00000000, 0x00000000, 5 0x000000e0, 0x202020e0, 0x0000000e, 0x080e020e,
6 0x13157555, 0x33000000, 0x07040701, 0x07000000, 6 0x00000098, 0xa8a8a898, 0x00000038, 0x203b0a39,
7 0x73457515, 0x73000000, 0x00000000, 0x00000000, 7 0x00000060, 0xa0a0a060, 0x0000000e, 0x080e020e,
8 0x17117351, 0x37000000, 0x07040701, 0x07000000, 8 0x000000b8, 0x889888b8, 0x00000038, 0x203b0a39,
9 0x77417311, 0x77000000, 0x00000000, 0x00000000, 9 0x000000e0, 0x206020e0, 0x0000000e, 0x080e020e,
10 0x77417311, 0x71000000, 0x00000000, 0x00000000, 10 0x000000e0, 0x20602020, 0x0000000e, 0x080e020e,
11 0x17117155, 0x37000000, 0x07040701, 0x07000000, 11 0x000000b8, 0x8888a8b8, 0x00000038, 0x203b0a39,
12 0x77417115, 0x77000000, 0x00000000, 0x00000000, 12 0x000000e0, 0x2020a0e0, 0x0000000e, 0x080e020e,
13 0x17157557, 0x35000000, 0x07040701, 0x07000000, 13 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x203b0a39,
14 0x77457517, 0x75000000, 0x00000000, 0x00000000, 14 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x080e020e,
15 0x17157355, 0x37000000, 0x07040701, 0x07000000, 15 0x000000b8, 0xa898a8b8, 0x00000038, 0x203b0a39,
16 0x77457315, 0x77000000, 0x00000000, 0x00000000, 16 0x000000e0, 0xa060a0e0, 0x0000000e, 0x080e020e,
17 0x77416141, 0x77000000, 0x00000000, 0x00000000, 17 0x000000e0, 0x202020e0, 0x0000000e, 0x080c080e,
18 0x13157555, 0x33000000, 0x07040604, 0x07000000, 18 0x00000098, 0xa8a8a898, 0x00000038, 0x20332239,
19 0x73456545, 0x73000000, 0x00000000, 0x00000000, 19 0x00000060, 0xa0a0a060, 0x0000000e, 0x080c080e,
20 0x17117351, 0x37000000, 0x07040604, 0x07000000, 20 0x000000b8, 0x889888b8, 0x00000038, 0x20332239,
21 0x77416341, 0x77000000, 0x00000000, 0x00000000, 21 0x000000e0, 0x206020e0, 0x0000000e, 0x080c080e,
22 0x77416341, 0x71000000, 0x00000000, 0x00000000, 22 0x000000e0, 0x20602020, 0x0000000e, 0x080c080e,
23 0x17117155, 0x37000000, 0x07040604, 0x07000000, 23 0x000000b8, 0x8888a8b8, 0x00000038, 0x20332239,
24 0x77416145, 0x77000000, 0x00000000, 0x00000000, 24 0x000000e0, 0x2020a0e0, 0x0000000e, 0x080c080e,
25 0x17157557, 0x35000000, 0x07040604, 0x07000000, 25 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x20332239,
26 0x77456547, 0x75000000, 0x00000000, 0x00000000, 26 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x080c080e,
27 0x17157355, 0x37000000, 0x07040604, 0x07000000, 27 0x000000b8, 0xa898a8b8, 0x00000038, 0x20332239,
28 0x77456345, 0x77000000, 0x00000000, 0x00000000, 28 0x000000e0, 0xa060a0e0, 0x0000000e, 0x080c080e,
29 0x47615171, 0x47000000, 0x00000000, 0x00000000, 29 0x000000e0, 0x202020e0, 0x00000008, 0x0c0a0e08,
30 0x13157555, 0x33000000, 0x04060507, 0x04000000, 30 0x00000098, 0xa8a8a898, 0x00000020, 0x302b3a21,
31 0x43655575, 0x43000000, 0x00000000, 0x00000000, 31 0x00000060, 0xa0a0a060, 0x00000008, 0x0c0a0e08,
32 0x17117351, 0x37000000, 0x04060507, 0x04000000, 32 0x000000b8, 0x889888b8, 0x00000020, 0x302b3a21,
33 0x47615371, 0x47000000, 0x00000000, 0x00000000, 33 0x000000e0, 0x206020e0, 0x00000008, 0x0c0a0e08,
34 0x47615371, 0x41000000, 0x00000000, 0x00000000, 34 0x000000e0, 0x20602020, 0x00000008, 0x0c0a0e08,
35 0x17117155, 0x37000000, 0x04060507, 0x04000000, 35 0x000000b8, 0x8888a8b8, 0x00000020, 0x302b3a21,
36 0x47615175, 0x47000000, 0x00000000, 0x00000000, 36 0x000000e0, 0x2020a0e0, 0x00000008, 0x0c0a0e08,
37 0x17157557, 0x35000000, 0x04060507, 0x04000000, 37 0x000000b8, 0xa8a8b8a8, 0x00000020, 0x302b3a21,
38 0x47655577, 0x45000000, 0x00000000, 0x00000000, 38 0x000000e0, 0xa0a0e0a0, 0x00000008, 0x0c0a0e08,
39 0x17157355, 0x37000000, 0x04060507, 0x04000000, 39 0x000000b8, 0xa898a8b8, 0x00000020, 0x302b3a21,
40 0x47655375, 0x47000000, 0x00000000, 0x00000000, 40 0x000000e0, 0xa060a0e0, 0x00000008, 0x0c0a0e08,
41 0x77117141, 0x77000000, 0x00000000, 0x00000000, 41 0x000000e0, 0x202020e0, 0x0000000e, 0x020e080e,
42 0x13157555, 0x33000000, 0x07010704, 0x07000000, 42 0x00000098, 0xa8a8a898, 0x00000038, 0x083b2239,
43 0x73157545, 0x73000000, 0x00000000, 0x00000000, 43 0x00000060, 0xa0a0a060, 0x0000000e, 0x020e080e,
44 0x17117351, 0x37000000, 0x07010704, 0x07000000, 44 0x000000b8, 0x889888b8, 0x00000038, 0x083b2239,
45 0x77117341, 0x77000000, 0x00000000, 0x00000000, 45 0x000000e0, 0x206020e0, 0x0000000e, 0x020e080e,
46 0x77117341, 0x71000000, 0x00000000, 0x00000000, 46 0x000000e0, 0x20602020, 0x0000000e, 0x020e080e,
47 0x17117155, 0x37000000, 0x07010704, 0x07000000, 47 0x000000b8, 0x8888a8b8, 0x00000038, 0x083b2239,
48 0x77117145, 0x77000000, 0x00000000, 0x00000000, 48 0x000000e0, 0x2020a0e0, 0x0000000e, 0x020e080e,
49 0x17157557, 0x35000000, 0x07010704, 0x07000000, 49 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x083b2239,
50 0x77157547, 0x75000000, 0x00000000, 0x00000000, 50 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x020e080e,
51 0x17157355, 0x37000000, 0x07010704, 0x07000000, 51 0x000000b8, 0xa898a8b8, 0x00000038, 0x083b2239,
52 0x77157345, 0x77000000, 0x00000000, 0x00000000, 52 0x000000e0, 0xa060a0e0, 0x0000000e, 0x020e080e,
53 0x77117151, 0x77000000, 0x00000000, 0x00000000, 53 0x000000e0, 0x202020e0, 0x0000000e, 0x020e0a0e,
54 0x13157555, 0x33000000, 0x07010705, 0x07000000, 54 0x00000098, 0xa8a8a898, 0x00000038, 0x083b2a39,
55 0x73157555, 0x73000000, 0x00000000, 0x00000000, 55 0x00000060, 0xa0a0a060, 0x0000000e, 0x020e0a0e,
56 0x17117351, 0x37000000, 0x07010705, 0x07000000, 56 0x000000b8, 0x889888b8, 0x00000038, 0x083b2a39,
57 0x77117351, 0x77000000, 0x00000000, 0x00000000, 57 0x000000e0, 0x206020e0, 0x0000000e, 0x020e0a0e,
58 0x77117351, 0x71000000, 0x00000000, 0x00000000, 58 0x000000e0, 0x20602020, 0x0000000e, 0x020e0a0e,
59 0x17117155, 0x37000000, 0x07010705, 0x07000000, 59 0x000000b8, 0x8888a8b8, 0x00000038, 0x083b2a39,
60 0x77117155, 0x77000000, 0x00000000, 0x00000000, 60 0x000000e0, 0x2020a0e0, 0x0000000e, 0x020e0a0e,
61 0x17157557, 0x35000000, 0x07010705, 0x07000000, 61 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x083b2a39,
62 0x77157557, 0x75000000, 0x00000000, 0x00000000, 62 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x020e0a0e,
63 0x17157355, 0x37000000, 0x07010705, 0x07000000, 63 0x000000b8, 0xa898a8b8, 0x00000038, 0x083b2a39,
64 0x77157355, 0x77000000, 0x00000000, 0x00000000, 64 0x000000e0, 0xa060a0e0, 0x0000000e, 0x020e0a0e,
65 0x77412111, 0x17000000, 0x00000000, 0x00000000, 65 0x000000e0, 0x202020e0, 0x0000000e, 0x08040202,
66 0x13157555, 0x33000000, 0x07040201, 0x01000000, 66 0x00000098, 0xa8a8a898, 0x00000038, 0x20130a09,
67 0x73452515, 0x13000000, 0x00000000, 0x00000000, 67 0x00000060, 0xa0a0a060, 0x0000000e, 0x08040202,
68 0x17117351, 0x37000000, 0x07040201, 0x01000000, 68 0x000000b8, 0x889888b8, 0x00000038, 0x20130a09,
69 0x77412311, 0x17000000, 0x00000000, 0x00000000, 69 0x000000e0, 0x206020e0, 0x0000000e, 0x08040202,
70 0x77412311, 0x11000000, 0x00000000, 0x00000000, 70 0x000000e0, 0x20602020, 0x0000000e, 0x08040202,
71 0x17117155, 0x37000000, 0x07040201, 0x01000000, 71 0x000000b8, 0x8888a8b8, 0x00000038, 0x20130a09,
72 0x77412115, 0x17000000, 0x00000000, 0x00000000, 72 0x000000e0, 0x2020a0e0, 0x0000000e, 0x08040202,
73 0x17157557, 0x35000000, 0x07040201, 0x01000000, 73 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x20130a09,
74 0x77452517, 0x15000000, 0x00000000, 0x00000000, 74 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x08040202,
75 0x17157355, 0x37000000, 0x07040201, 0x01000000, 75 0x000000b8, 0xa898a8b8, 0x00000038, 0x20130a09,
76 0x77452315, 0x17000000, 0x00000000, 0x00000000, 76 0x000000e0, 0xa060a0e0, 0x0000000e, 0x08040202,
77 0x77517151, 0x77000000, 0x00000000, 0x00000000, 77 0x000000e0, 0x202020e0, 0x0000000e, 0x0a0e0a0e,
78}; 78};
79 79
80typedef struct SeqTrigger { 80typedef struct SeqTrigger {
@@ -90,7 +90,7 @@ static SeqTrigger sequence_synth[] = {
90 {true, NOTE_C_5}, 90 {true, NOTE_C_5},
91 91
92 {true, NOTE_D_4}, 92 {true, NOTE_D_4},
93 {false, NOTE_D_4}, 93 {false, NOTE_C_SHARP_4},
94 {false, NOTE_D_4}, 94 {false, NOTE_D_4},
95 {false, NOTE_D_4}, 95 {false, NOTE_D_4},
96 96
@@ -203,14 +203,29 @@ init_sequencer_sprites() {
203} 203}
204 204
205void 205void
206update_sequencer_sprites() {
207 // 000-015: Step note names.
208 for (size_t i = 0; i < 16; ++i) {
209 // Each note name is made of 2 8x8 tiles (16x8).
210 size_t base_tile = sequence_synth[i].note * 2;
211
212 // TODO: Show the note name if is within the duration, hide when trigger
213 // is off or duration of previous note was cut short.
214 if (!sequence_synth[i].trigger) {
215 seq_sprites[i].obj_attr_0 |= OBJ_HIDDEN;
216 } else {
217 seq_sprites[i].obj_attr_0 &= ~OBJ_HIDDEN;
218 }
219
220 seq_sprites[i].obj_attr_2 = base_tile;
221 }
222}
223
224void
206render_sequencer_sprites() { 225render_sequencer_sprites() {
207 size_t len = sizeof(seq_sprites) / sizeof(SeqSprite); 226 size_t len = sizeof(seq_sprites) / sizeof(SeqSprite);
208 for (size_t i = 0; i < len; ++i) { 227 for (size_t i = 0; i < len; ++i) {
209 size_t id = seq_sprites[i].id; 228 size_t id = seq_sprites[i].id;
210 // TODO: This needs to be done in an update function, not here.
211 size_t base_tile = sequence_synth[i].note;
212 seq_sprites[i].obj_attr_2 = base_tile;
213
214 OBJ_ATTR_0(id) = seq_sprites[i].obj_attr_0; 229 OBJ_ATTR_0(id) = seq_sprites[i].obj_attr_0;
215 OBJ_ATTR_1(id) = seq_sprites[i].obj_attr_1; 230 OBJ_ATTR_1(id) = seq_sprites[i].obj_attr_1;
216 OBJ_ATTR_2(id) = seq_sprites[i].obj_attr_2; 231 OBJ_ATTR_2(id) = seq_sprites[i].obj_attr_2;