From 70cf18e60a945927d1ca24e480b62a675b822f89 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sun, 2 May 2021 12:47:07 +0200 Subject: Update note names depending on the sequence --- src/main.c | 2 + src/sequencer.c | 171 ++++++++++++++++++++++++++++++-------------------------- 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) { TIMER_CTRL_0 ^= TIMER_CTRL_ENABLE; } + update_sequencer_sprites(); + // txt_position(1,6); // txt_clear_line(); // 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 @@ #define SPRITE_NOTE_NAMES_H 8 u32 sprite_note_names[] = { - 0x77417111, 0x77000000, 0x00000000, 0x00000000, - 0x13157555, 0x33000000, 0x07040701, 0x07000000, - 0x73457515, 0x73000000, 0x00000000, 0x00000000, - 0x17117351, 0x37000000, 0x07040701, 0x07000000, - 0x77417311, 0x77000000, 0x00000000, 0x00000000, - 0x77417311, 0x71000000, 0x00000000, 0x00000000, - 0x17117155, 0x37000000, 0x07040701, 0x07000000, - 0x77417115, 0x77000000, 0x00000000, 0x00000000, - 0x17157557, 0x35000000, 0x07040701, 0x07000000, - 0x77457517, 0x75000000, 0x00000000, 0x00000000, - 0x17157355, 0x37000000, 0x07040701, 0x07000000, - 0x77457315, 0x77000000, 0x00000000, 0x00000000, - 0x77416141, 0x77000000, 0x00000000, 0x00000000, - 0x13157555, 0x33000000, 0x07040604, 0x07000000, - 0x73456545, 0x73000000, 0x00000000, 0x00000000, - 0x17117351, 0x37000000, 0x07040604, 0x07000000, - 0x77416341, 0x77000000, 0x00000000, 0x00000000, - 0x77416341, 0x71000000, 0x00000000, 0x00000000, - 0x17117155, 0x37000000, 0x07040604, 0x07000000, - 0x77416145, 0x77000000, 0x00000000, 0x00000000, - 0x17157557, 0x35000000, 0x07040604, 0x07000000, - 0x77456547, 0x75000000, 0x00000000, 0x00000000, - 0x17157355, 0x37000000, 0x07040604, 0x07000000, - 0x77456345, 0x77000000, 0x00000000, 0x00000000, - 0x47615171, 0x47000000, 0x00000000, 0x00000000, - 0x13157555, 0x33000000, 0x04060507, 0x04000000, - 0x43655575, 0x43000000, 0x00000000, 0x00000000, - 0x17117351, 0x37000000, 0x04060507, 0x04000000, - 0x47615371, 0x47000000, 0x00000000, 0x00000000, - 0x47615371, 0x41000000, 0x00000000, 0x00000000, - 0x17117155, 0x37000000, 0x04060507, 0x04000000, - 0x47615175, 0x47000000, 0x00000000, 0x00000000, - 0x17157557, 0x35000000, 0x04060507, 0x04000000, - 0x47655577, 0x45000000, 0x00000000, 0x00000000, - 0x17157355, 0x37000000, 0x04060507, 0x04000000, - 0x47655375, 0x47000000, 0x00000000, 0x00000000, - 0x77117141, 0x77000000, 0x00000000, 0x00000000, - 0x13157555, 0x33000000, 0x07010704, 0x07000000, - 0x73157545, 0x73000000, 0x00000000, 0x00000000, - 0x17117351, 0x37000000, 0x07010704, 0x07000000, - 0x77117341, 0x77000000, 0x00000000, 0x00000000, - 0x77117341, 0x71000000, 0x00000000, 0x00000000, - 0x17117155, 0x37000000, 0x07010704, 0x07000000, - 0x77117145, 0x77000000, 0x00000000, 0x00000000, - 0x17157557, 0x35000000, 0x07010704, 0x07000000, - 0x77157547, 0x75000000, 0x00000000, 0x00000000, - 0x17157355, 0x37000000, 0x07010704, 0x07000000, - 0x77157345, 0x77000000, 0x00000000, 0x00000000, - 0x77117151, 0x77000000, 0x00000000, 0x00000000, - 0x13157555, 0x33000000, 0x07010705, 0x07000000, - 0x73157555, 0x73000000, 0x00000000, 0x00000000, - 0x17117351, 0x37000000, 0x07010705, 0x07000000, - 0x77117351, 0x77000000, 0x00000000, 0x00000000, - 0x77117351, 0x71000000, 0x00000000, 0x00000000, - 0x17117155, 0x37000000, 0x07010705, 0x07000000, - 0x77117155, 0x77000000, 0x00000000, 0x00000000, - 0x17157557, 0x35000000, 0x07010705, 0x07000000, - 0x77157557, 0x75000000, 0x00000000, 0x00000000, - 0x17157355, 0x37000000, 0x07010705, 0x07000000, - 0x77157355, 0x77000000, 0x00000000, 0x00000000, - 0x77412111, 0x17000000, 0x00000000, 0x00000000, - 0x13157555, 0x33000000, 0x07040201, 0x01000000, - 0x73452515, 0x13000000, 0x00000000, 0x00000000, - 0x17117351, 0x37000000, 0x07040201, 0x01000000, - 0x77412311, 0x17000000, 0x00000000, 0x00000000, - 0x77412311, 0x11000000, 0x00000000, 0x00000000, - 0x17117155, 0x37000000, 0x07040201, 0x01000000, - 0x77412115, 0x17000000, 0x00000000, 0x00000000, - 0x17157557, 0x35000000, 0x07040201, 0x01000000, - 0x77452517, 0x15000000, 0x00000000, 0x00000000, - 0x17157355, 0x37000000, 0x07040201, 0x01000000, - 0x77452315, 0x17000000, 0x00000000, 0x00000000, - 0x77517151, 0x77000000, 0x00000000, 0x00000000, + 0x000000e0, 0x202020e0, 0x0000000e, 0x080e020e, + 0x00000098, 0xa8a8a898, 0x00000038, 0x203b0a39, + 0x00000060, 0xa0a0a060, 0x0000000e, 0x080e020e, + 0x000000b8, 0x889888b8, 0x00000038, 0x203b0a39, + 0x000000e0, 0x206020e0, 0x0000000e, 0x080e020e, + 0x000000e0, 0x20602020, 0x0000000e, 0x080e020e, + 0x000000b8, 0x8888a8b8, 0x00000038, 0x203b0a39, + 0x000000e0, 0x2020a0e0, 0x0000000e, 0x080e020e, + 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x203b0a39, + 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x080e020e, + 0x000000b8, 0xa898a8b8, 0x00000038, 0x203b0a39, + 0x000000e0, 0xa060a0e0, 0x0000000e, 0x080e020e, + 0x000000e0, 0x202020e0, 0x0000000e, 0x080c080e, + 0x00000098, 0xa8a8a898, 0x00000038, 0x20332239, + 0x00000060, 0xa0a0a060, 0x0000000e, 0x080c080e, + 0x000000b8, 0x889888b8, 0x00000038, 0x20332239, + 0x000000e0, 0x206020e0, 0x0000000e, 0x080c080e, + 0x000000e0, 0x20602020, 0x0000000e, 0x080c080e, + 0x000000b8, 0x8888a8b8, 0x00000038, 0x20332239, + 0x000000e0, 0x2020a0e0, 0x0000000e, 0x080c080e, + 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x20332239, + 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x080c080e, + 0x000000b8, 0xa898a8b8, 0x00000038, 0x20332239, + 0x000000e0, 0xa060a0e0, 0x0000000e, 0x080c080e, + 0x000000e0, 0x202020e0, 0x00000008, 0x0c0a0e08, + 0x00000098, 0xa8a8a898, 0x00000020, 0x302b3a21, + 0x00000060, 0xa0a0a060, 0x00000008, 0x0c0a0e08, + 0x000000b8, 0x889888b8, 0x00000020, 0x302b3a21, + 0x000000e0, 0x206020e0, 0x00000008, 0x0c0a0e08, + 0x000000e0, 0x20602020, 0x00000008, 0x0c0a0e08, + 0x000000b8, 0x8888a8b8, 0x00000020, 0x302b3a21, + 0x000000e0, 0x2020a0e0, 0x00000008, 0x0c0a0e08, + 0x000000b8, 0xa8a8b8a8, 0x00000020, 0x302b3a21, + 0x000000e0, 0xa0a0e0a0, 0x00000008, 0x0c0a0e08, + 0x000000b8, 0xa898a8b8, 0x00000020, 0x302b3a21, + 0x000000e0, 0xa060a0e0, 0x00000008, 0x0c0a0e08, + 0x000000e0, 0x202020e0, 0x0000000e, 0x020e080e, + 0x00000098, 0xa8a8a898, 0x00000038, 0x083b2239, + 0x00000060, 0xa0a0a060, 0x0000000e, 0x020e080e, + 0x000000b8, 0x889888b8, 0x00000038, 0x083b2239, + 0x000000e0, 0x206020e0, 0x0000000e, 0x020e080e, + 0x000000e0, 0x20602020, 0x0000000e, 0x020e080e, + 0x000000b8, 0x8888a8b8, 0x00000038, 0x083b2239, + 0x000000e0, 0x2020a0e0, 0x0000000e, 0x020e080e, + 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x083b2239, + 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x020e080e, + 0x000000b8, 0xa898a8b8, 0x00000038, 0x083b2239, + 0x000000e0, 0xa060a0e0, 0x0000000e, 0x020e080e, + 0x000000e0, 0x202020e0, 0x0000000e, 0x020e0a0e, + 0x00000098, 0xa8a8a898, 0x00000038, 0x083b2a39, + 0x00000060, 0xa0a0a060, 0x0000000e, 0x020e0a0e, + 0x000000b8, 0x889888b8, 0x00000038, 0x083b2a39, + 0x000000e0, 0x206020e0, 0x0000000e, 0x020e0a0e, + 0x000000e0, 0x20602020, 0x0000000e, 0x020e0a0e, + 0x000000b8, 0x8888a8b8, 0x00000038, 0x083b2a39, + 0x000000e0, 0x2020a0e0, 0x0000000e, 0x020e0a0e, + 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x083b2a39, + 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x020e0a0e, + 0x000000b8, 0xa898a8b8, 0x00000038, 0x083b2a39, + 0x000000e0, 0xa060a0e0, 0x0000000e, 0x020e0a0e, + 0x000000e0, 0x202020e0, 0x0000000e, 0x08040202, + 0x00000098, 0xa8a8a898, 0x00000038, 0x20130a09, + 0x00000060, 0xa0a0a060, 0x0000000e, 0x08040202, + 0x000000b8, 0x889888b8, 0x00000038, 0x20130a09, + 0x000000e0, 0x206020e0, 0x0000000e, 0x08040202, + 0x000000e0, 0x20602020, 0x0000000e, 0x08040202, + 0x000000b8, 0x8888a8b8, 0x00000038, 0x20130a09, + 0x000000e0, 0x2020a0e0, 0x0000000e, 0x08040202, + 0x000000b8, 0xa8a8b8a8, 0x00000038, 0x20130a09, + 0x000000e0, 0xa0a0e0a0, 0x0000000e, 0x08040202, + 0x000000b8, 0xa898a8b8, 0x00000038, 0x20130a09, + 0x000000e0, 0xa060a0e0, 0x0000000e, 0x08040202, + 0x000000e0, 0x202020e0, 0x0000000e, 0x0a0e0a0e, }; typedef struct SeqTrigger { @@ -90,7 +90,7 @@ static SeqTrigger sequence_synth[] = { {true, NOTE_C_5}, {true, NOTE_D_4}, - {false, NOTE_D_4}, + {false, NOTE_C_SHARP_4}, {false, NOTE_D_4}, {false, NOTE_D_4}, @@ -202,15 +202,30 @@ init_sequencer_sprites() { } } +void +update_sequencer_sprites() { + // 000-015: Step note names. + for (size_t i = 0; i < 16; ++i) { + // Each note name is made of 2 8x8 tiles (16x8). + size_t base_tile = sequence_synth[i].note * 2; + + // TODO: Show the note name if is within the duration, hide when trigger + // is off or duration of previous note was cut short. + if (!sequence_synth[i].trigger) { + seq_sprites[i].obj_attr_0 |= OBJ_HIDDEN; + } else { + seq_sprites[i].obj_attr_0 &= ~OBJ_HIDDEN; + } + + seq_sprites[i].obj_attr_2 = base_tile; + } +} + void render_sequencer_sprites() { size_t len = sizeof(seq_sprites) / sizeof(SeqSprite); for (size_t i = 0; i < len; ++i) { size_t id = seq_sprites[i].id; - // TODO: This needs to be done in an update function, not here. - size_t base_tile = sequence_synth[i].note; - seq_sprites[i].obj_attr_2 = base_tile; - OBJ_ATTR_0(id) = seq_sprites[i].obj_attr_0; OBJ_ATTR_1(id) = seq_sprites[i].obj_attr_1; OBJ_ATTR_2(id) = seq_sprites[i].obj_attr_2; -- cgit v1.2.1