Sample FIFOs with sound DMA timer

This commit is contained in:
Jeffrey Pfau 2013-10-02 00:46:51 -07:00
parent 71ec6162f1
commit a834f8b1f6
3 changed files with 31 additions and 13 deletions

View File

@ -138,17 +138,17 @@ struct GBAAudio {
union { union {
struct { struct {
unsigned volume : 2; unsigned volume : 2;
unsigned volumeDmaA : 1; unsigned volumeChA : 1;
unsigned volumeDmaB : 1; unsigned volumeChB : 1;
unsigned : 4; unsigned : 4;
unsigned dmaARight : 1; unsigned chARight : 1;
unsigned dmaALeft : 1; unsigned chALeft : 1;
unsigned dmaATimer : 1; unsigned chATimer : 1;
unsigned dmaAReset : 1; unsigned chAReset : 1;
unsigned dmaBRight : 1; unsigned chBRight : 1;
unsigned dmaBLeft : 1; unsigned chBLeft : 1;
unsigned dmaBTimer : 1; unsigned chBTimer : 1;
unsigned dmaBReset : 1; unsigned chBReset : 1;
}; };
uint16_t soundcntHi; uint16_t soundcntHi;
}; };

View File

@ -209,10 +209,8 @@ void GBAIOWrite32(struct GBA* gba, uint32_t address, uint32_t value) {
GBAAudioWriteWaveRAM(&gba->audio, 3, value); GBAAudioWriteWaveRAM(&gba->audio, 3, value);
break; break;
case REG_FIFO_A_LO: case REG_FIFO_A_LO:
GBAAudioWriteFIFO(&gba->audio, 0, value);
break;
case REG_FIFO_B_LO: case REG_FIFO_B_LO:
GBAAudioWriteFIFO(&gba->audio, 1, value); GBAAudioWriteFIFO(&gba->audio, address, value);
break; break;
case REG_DMA0SAD_LO: case REG_DMA0SAD_LO:
GBAMemoryWriteDMASAD(&gba->memory, 0, value); GBAMemoryWriteDMASAD(&gba->memory, 0, value);

View File

@ -136,6 +136,16 @@ static int32_t GBATimersProcessEvents(struct GBA* gba, int32_t cycles) {
GBARaiseIRQ(gba, IRQ_TIMER0); GBARaiseIRQ(gba, IRQ_TIMER0);
} }
if (gba->audio.enable) {
if ((gba->audio.chALeft || gba->audio.chARight) && gba->audio.chATimer == 0) {
GBAAudioSampleFIFO(&gba->audio, 0);
}
if ((gba->audio.chBLeft || gba->audio.chBRight) && gba->audio.chBTimer == 0) {
GBAAudioSampleFIFO(&gba->audio, 1);
}
}
nextTimer = &gba->timers[1]; nextTimer = &gba->timers[1];
if (nextTimer->countUp) { if (nextTimer->countUp) {
++gba->memory.io[REG_TM1CNT_LO >> 1]; ++gba->memory.io[REG_TM1CNT_LO >> 1];
@ -161,6 +171,16 @@ static int32_t GBATimersProcessEvents(struct GBA* gba, int32_t cycles) {
GBARaiseIRQ(gba, IRQ_TIMER1); GBARaiseIRQ(gba, IRQ_TIMER1);
} }
if (gba->audio.enable) {
if ((gba->audio.chALeft || gba->audio.chARight) && gba->audio.chATimer == 1) {
GBAAudioSampleFIFO(&gba->audio, 0);
}
if ((gba->audio.chBLeft || gba->audio.chBRight) && gba->audio.chBTimer == 1) {
GBAAudioSampleFIFO(&gba->audio, 1);
}
}
if (timer->countUp) { if (timer->countUp) {
timer->nextEvent = INT_MAX; timer->nextEvent = INT_MAX;
} }