summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-06-08 10:15:44 +0200
committerBad Diode <bd@badd10de.dev>2021-06-08 10:15:44 +0200
commit32cd65387f8ba2ea6a92c1c44da7a31b8ceef4b0 (patch)
treede08e1354e6116e58d439419d4b6d204c26be0f2
parent17de3925aa6cbe3f37f5f19ebf1a3a98c5047020 (diff)
downloadgba-sequencer-32cd65387f8ba2ea6a92c1c44da7a31b8ceef4b0.tar.gz
gba-sequencer-32cd65387f8ba2ea6a92c1c44da7a31b8ceef4b0.zip
Add drawing of triggers and channel buttons
-rw-r--r--assets/channel_buttons.bmpbin0 -> 2934 bytes
-rw-r--r--src/main.c71
-rw-r--r--src/text/font.h7
3 files changed, 59 insertions, 19 deletions
diff --git a/assets/channel_buttons.bmp b/assets/channel_buttons.bmp
new file mode 100644
index 0000000..34a6ded
--- /dev/null
+++ b/assets/channel_buttons.bmp
Binary files differ
diff --git a/src/main.c b/src/main.c
index 3a15655..b14fbed 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,21 +50,66 @@ WITH REGARD TO THIS SOFTWARE.
50#define PROF_INIT() 50#define PROF_INIT()
51#endif 51#endif
52 52
53#define TRIG_W 15
54#define TRIG_H 24
55#define TRIG_START_X 66
56#define TRIG_START_Y 90
57#define TRIG_OFFSET_X (TRIG_W + 4)
58#define TRIG_OFFSET_Y (TRIG_H + 7)
59
53void 60void
54test_rects() { 61draw_triggers(void) {
55 for (size_t i = 0; i < 100; i++) { 62 for (size_t i = 0; i < 8; i++) {
56 // draw_line(0, 10, 10, 10, 1); 63 size_t x0 = TRIG_START_X + TRIG_OFFSET_X * i;
57 // draw_line(10, 10, 10, 20, 1); 64 size_t x1 = TRIG_START_X + TRIG_W + TRIG_OFFSET_X * i;
58 // draw_line(0, 0, 10, 10, 2); 65 size_t y0 = TRIG_START_Y;
59 // draw_line(0, 20, 20, 14, 1); 66 size_t y1 = TRIG_START_Y + TRIG_H;
60 // draw_line(0, 0, 239, 159, 2); 67 draw_rect(x0, y0, x1, y1, 1);
61 // draw_line(0, 159, 239, 0, 3); 68 }
62 // draw_filled_rect(10, 10, SCREEN_WIDTH - 11, SCREEN_HEIGHT - 11, 3); 69 for (size_t i = 0; i < 8; i++) {
63 // draw_filled_rect(10, 10, 13, 21, 3); 70 size_t x0 = TRIG_START_X + TRIG_OFFSET_X * i;
64 draw_filled_rect(10, 10, 20, 20, 3); 71 size_t x1 = TRIG_START_X + TRIG_W + TRIG_OFFSET_X * i;
72 size_t y0 = TRIG_START_Y + TRIG_OFFSET_Y;
73 size_t y1 = TRIG_START_Y + TRIG_H + TRIG_OFFSET_Y;
74 draw_rect(x0, y0, x1, y1, 1);
65 } 75 }
66} 76}
67 77
78#define CHAN_START_X 35
79#define CHAN_START_Y 90
80#define CHAN_OFFSET_Y 12
81
82void
83draw_channels(void) {
84 // Contains 5 channel buttons: Ch. 1-4 + FM. We are only drawing the DMG
85 // channels for now, since FM may take some time to develop.
86 u32 channel_buttons[] = {
87 0xff017111, 0x117101ff, 0xff008585, 0x879500ff,
88 0x0f080808, 0x0808080f, 0xff01b989, 0x89b901ff,
89 0xff004242, 0x434a00ff, 0x0f080909, 0x0909080f,
90 0xff015d45, 0xc55d01ff, 0xff00a1a1, 0xa1a500ff,
91 0x0f080a0a, 0x0a0a080f, 0xff015d45, 0xc55d01ff,
92 0xff00a1a1, 0xa12500ff, 0x0f080a0a, 0x0a0b080f,
93 0xff01c141, 0xc14101ff, 0xff00151c, 0x141400ff,
94 0x0f080808, 0x0808080f,
95 };
96 Tile channel_tiles[3 * 4] = {0};
97 unpack_tiles(channel_buttons, channel_tiles, 3 * 4);
98 size_t k = 0;
99 for (size_t i = 0; i < 4; i++) {
100 size_t y = CHAN_START_Y + i * CHAN_OFFSET_Y;
101 draw_tile(CHAN_START_X, y, channel_tiles + k++, false);
102 draw_tile(CHAN_START_X + 8, y, channel_tiles + k++, false);
103 draw_tile(CHAN_START_X + 16, y, channel_tiles + k++, false);
104 }
105}
106
107void
108sequencer_init(void) {
109 draw_triggers();
110 draw_channels();
111}
112
68int main(void) { 113int main(void) {
69 // Adjust system wait times. 114 // Adjust system wait times.
70 SYSTEM_WAIT = SYSTEM_WAIT_CARTRIDGE; 115 SYSTEM_WAIT = SYSTEM_WAIT_CARTRIDGE;
@@ -79,12 +124,14 @@ int main(void) {
79 irq_init(); 124 irq_init();
80 irs_set(IRQ_VBLANK, irs_stub); 125 irs_set(IRQ_VBLANK, irs_stub);
81 126
127 // Initialize sequencer.
128 sequencer_init();
129
82 // Main loop. 130 // Main loop.
83 PROF_INIT(); 131 PROF_INIT();
84 while (true) { 132 while (true) {
85 bios_vblank_wait(); 133 bios_vblank_wait();
86 PROF(flip_buffer(), flip_cycles); 134 PROF(flip_buffer(), flip_cycles);
87 PROF(test_rects(), eval_cycles);
88 PROF_SHOW(); 135 PROF_SHOW();
89 } 136 }
90 137
diff --git a/src/text/font.h b/src/text/font.h
index 65579b8..4f3c319 100644
--- a/src/text/font.h
+++ b/src/text/font.h
@@ -128,10 +128,3 @@ static const u32 font[] = {
128 0x00000000, 0x00000000, 0x00000000, 0x00000000, 128 0x00000000, 0x00000000, 0x00000000, 0x00000000,
129 0x00000000, 0x00000000, 0x00000000, 0x00000000, 129 0x00000000, 0x00000000, 0x00000000, 0x00000000,
130}; 130};
131
132u16 palette[16] = {
133 0x7fff, 0x0000, 0x7fff, 0x7fff,
134 0x7fff, 0x7fff, 0x7fff, 0x7fff,
135 0x7fff, 0x7fff, 0x7fff, 0x7fff,
136 0x7fff, 0x7fff, 0x7fff, 0x7fff,
137};