gba-sprite-engine/engine/src/sound_control.cpp

43 lines
1.4 KiB
C++
Raw Normal View History

2018-08-07 14:32:20 +02:00
//
// Created by Wouter Groeneveld on 07/08/18.
//
#include <engine/gba/tonc_memmap.h>
#include <engine/sound_control.h>
2018-08-07 14:32:20 +02:00
void SoundControl::accept(const void *data, int totalSamples, int ticksPerSample) {
2018-08-07 17:27:43 +02:00
this->data = data;
2018-08-07 14:32:20 +02:00
*DMASourceAddress = (u32) data;
*DMADestinationAddress = (u32) FiFoBuffer;
vblanksTotal = vblanksRemaning = totalSamples * ticksPerSample * (1.0 / CYCLES_PER_BLANK);
};
2018-08-07 17:27:43 +02:00
void SoundControl::reset() {
vblanksRemaning = vblanksTotal;
*(DMAControl) = 0;
*DMASourceAddress = (u32) data;
enable();
}
std::unique_ptr<SoundControl> SoundControl::channelAControl() {
return std::unique_ptr<SoundControl>(new SoundControl{
2018-08-07 14:32:20 +02:00
&REG_DMA1CNT,
&REG_DMA1SAD,
&REG_DMA1DAD,
&REG_FIFOA,
2018-08-07 17:27:43 +02:00
// Left/Right, timed, tone 100% vol, channel A 50%, channel B 100% (only one directsound reg)
SDS_AR | SDS_AL | SDS_ARESET | SDS_DMG100 | SDS_A50 | SDS_B100
});
2018-08-07 14:32:20 +02:00
}
std::unique_ptr<SoundControl> SoundControl::channelBControl() {
return std::unique_ptr<SoundControl>(new SoundControl{
2018-08-07 14:32:20 +02:00
&REG_DMA2CNT,
&REG_DMA2SAD,
&REG_DMA2DAD,
&REG_FIFOB,
2018-08-07 17:27:43 +02:00
// Left/Right, timed, tone 100% vol, channel A 50%, channel B 100% (only one directsound reg)
SDS_BR | SDS_BL | SDS_BRESET | SDS_DMG100 | SDS_A50 | SDS_B100
});
2018-08-07 14:32:20 +02:00
}