channel A repeats

This commit is contained in:
wgroeneveld 2018-08-07 17:27:43 +02:00
parent 43950fc09f
commit 4dcc28f4be
5 changed files with 18707 additions and 6 deletions

View File

@ -23,8 +23,12 @@ void GBAEngine::onVBlank() {
unsigned short tempInterruptState = REG_IF;
if((REG_IF & INTERRUPT_VBLANK) == INTERRUPT_VBLANK) {
if(GBAEngine::activeChannelA && GBAEngine::activeChannelA->done()) {
if(GBAEngine::activeChannelA) {
if(GBAEngine::activeChannelA->done()) {
GBAEngine::activeChannelA->reset();
} else {
GBAEngine::activeChannelA->step();
}
}
if(GBAEngine::activeChannelB) {
if(GBAEngine::activeChannelB->done()) {

View File

@ -6,18 +6,27 @@
#include "sound.h"
void SoundControl::accept(const void *data, int totalSamples, int ticksPerSample) {
this->data = data;
*DMASourceAddress = (u32) data;
*DMADestinationAddress = (u32) FiFoBuffer;
vblanksTotal = vblanksRemaning = totalSamples * ticksPerSample * (1.0 / CYCLES_PER_BLANK);
};
void SoundControl::reset() {
vblanksRemaning = vblanksTotal;
*(DMAControl) = 0;
*DMASourceAddress = (u32) data;
enable();
}
std::unique_ptr<SoundControl> SoundControl::channelAControl() {
return std::unique_ptr<SoundControl>(new SoundControl{
&REG_DMA1CNT,
&REG_DMA1SAD,
&REG_DMA1DAD,
&REG_FIFOA,
SDS_AR | SDS_AL | SDS_ARESET
// 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
});
}
@ -27,6 +36,7 @@ std::unique_ptr<SoundControl> SoundControl::channelBControl() {
&REG_DMA2SAD,
&REG_DMA2DAD,
&REG_FIFOB,
SDS_BR | SDS_BL | SDS_BRESET
// 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
});
}

View File

@ -33,12 +33,15 @@ private:
u32 vblanksRemaning; // updated each vblank, counts down to 0
u32 vblanksTotal; // calculated once when enqueueing
const void* data;
public:
SoundControl(vu32* dma, vu32* src, vu32* dest, vu32* fifo, u16 flags)
: DMAControl(dma), DMASourceAddress(src), DMADestinationAddress(dest), FiFoBuffer(fifo), controlFlags(flags), vblanksRemaning(0), vblanksTotal(0) {}
u16 getControlFlags() { return controlFlags; }
u32 getVBlanksRemaning() { return vblanksRemaning; }
void reset();
void step() { vblanksRemaning--; }
bool done() { return vblanksRemaning <= 0; }
u32 getVBlanksTotal() { return vblanksTotal; }

File diff suppressed because it is too large Load Diff

View File

@ -35,15 +35,17 @@ void SampleStartScene::load() {
.buildPtr();
TextStream::instance().setText("PRESS START", 3, 8);
engine->enqueueSound(zelda_secret_16K_mono, zelda_secret_16K_mono_bytes);
engine->enqueueMusic(zelda_music_16K_mono, zelda_music_16K_mono_bytes);
}
void SampleStartScene::tick(u16 keys) {
if(keys & KEY_START) {
if(!engine->isTransitioning()) {
engine->enqueueSound(zelda_secret_16K_mono, zelda_secret_16K_mono_bytes);
TextStream::instance() << "entered: starting next scene";
engine->transitionIntoScene(new FlyingStuffScene(engine), new FadeOutScene(4));
engine->transitionIntoScene(new FlyingStuffScene(engine), new FadeOutScene(2));
}
} else if(keys & KEY_LEFT) {
animation->flipHorizontally(true);