summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/sound.c b/sound.c
index 3a320e9..d743e12 100644
--- a/sound.c
+++ b/sound.c
@@ -33,33 +33,46 @@ static u32 sound_buffer_base;
static u32 sound_last_cpu_ticks;
static fixed16_16 gbc_sound_tick_step;
-// Queue 1, 2, or 4 samples to the top of the DS FIFO, wrap around circularly
-
-#define sound_timer_queue(size, value) \
- *((s##size *)(ds->fifo + ds->fifo_top)) = value; \
- ds->fifo_top = (ds->fifo_top + 1) % 32; \
+/* Queue 1 sample to the top of the DS FIFO, wrap around circularly */
void sound_timer_queue8(u32 channel, u8 value)
{
direct_sound_struct *ds = direct_sound_channel + channel;
- sound_timer_queue(8, value);
+
+ *((s8 *)(ds->fifo + ds->fifo_top)) = value;
+ ds->fifo_top = (ds->fifo_top + 1) % 32;
}
+/* Queue 2 samples to the top of the DS FIFO, wrap around circularly */
+
void sound_timer_queue16(u32 channel, u16 value)
{
direct_sound_struct *ds = direct_sound_channel + channel;
- sound_timer_queue(8, value & 0xFF);
- sound_timer_queue(8, value >> 8);
+
+ *((s8 *)(ds->fifo + ds->fifo_top)) = value & 0xFF;
+ ds->fifo_top = (ds->fifo_top + 1) % 32;
+
+ *((s8 *)(ds->fifo + ds->fifo_top)) = value >> 8;
+ ds->fifo_top = (ds->fifo_top + 1) % 32;
}
+/* Queue 4 samples to the top of the DS FIFO, wrap around circularly */
+
void sound_timer_queue32(u32 channel, u32 value)
{
direct_sound_struct *ds = direct_sound_channel + channel;
- sound_timer_queue(8, value & 0xFF);
- sound_timer_queue(8, (value >> 8) & 0xFF);
- sound_timer_queue(8, (value >> 16) & 0xFF);
- sound_timer_queue(8, value >> 24);
+ *((s8 *)(ds->fifo + ds->fifo_top)) = value & 0xFF;
+ ds->fifo_top = (ds->fifo_top + 1) % 32;
+
+ *((s8 *)(ds->fifo + ds->fifo_top)) = (value >> 8) & 0xFF;
+ ds->fifo_top = (ds->fifo_top + 1) % 32;
+
+ *((s8 *)(ds->fifo + ds->fifo_top)) = (value >> 16) & 0xFF;
+ ds->fifo_top = (ds->fifo_top + 1) % 32;
+
+ *((s8 *)(ds->fifo + ds->fifo_top)) = (value >> 24);
+ ds->fifo_top = (ds->fifo_top + 1) % 32;
}