channel A repeats
This commit is contained in:
parent
43950fc09f
commit
4dcc28f4be
|
@ -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()) {
|
||||
|
|
|
@ -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{
|
||||
®_DMA1CNT,
|
||||
®_DMA1SAD,
|
||||
®_DMA1DAD,
|
||||
®_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() {
|
|||
®_DMA2SAD,
|
||||
®_DMA2DAD,
|
||||
®_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
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
18682
src/sample_sound.h
18682
src/sample_sound.h
File diff suppressed because it is too large
Load Diff
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue