mirror of https://github.com/mgba-emu/mgba.git
Sample FIFOs with sound DMA timer
This commit is contained in:
parent
71ec6162f1
commit
a834f8b1f6
|
@ -138,17 +138,17 @@ struct GBAAudio {
|
|||
union {
|
||||
struct {
|
||||
unsigned volume : 2;
|
||||
unsigned volumeDmaA : 1;
|
||||
unsigned volumeDmaB : 1;
|
||||
unsigned volumeChA : 1;
|
||||
unsigned volumeChB : 1;
|
||||
unsigned : 4;
|
||||
unsigned dmaARight : 1;
|
||||
unsigned dmaALeft : 1;
|
||||
unsigned dmaATimer : 1;
|
||||
unsigned dmaAReset : 1;
|
||||
unsigned dmaBRight : 1;
|
||||
unsigned dmaBLeft : 1;
|
||||
unsigned dmaBTimer : 1;
|
||||
unsigned dmaBReset : 1;
|
||||
unsigned chARight : 1;
|
||||
unsigned chALeft : 1;
|
||||
unsigned chATimer : 1;
|
||||
unsigned chAReset : 1;
|
||||
unsigned chBRight : 1;
|
||||
unsigned chBLeft : 1;
|
||||
unsigned chBTimer : 1;
|
||||
unsigned chBReset : 1;
|
||||
};
|
||||
uint16_t soundcntHi;
|
||||
};
|
||||
|
|
|
@ -209,10 +209,8 @@ void GBAIOWrite32(struct GBA* gba, uint32_t address, uint32_t value) {
|
|||
GBAAudioWriteWaveRAM(&gba->audio, 3, value);
|
||||
break;
|
||||
case REG_FIFO_A_LO:
|
||||
GBAAudioWriteFIFO(&gba->audio, 0, value);
|
||||
break;
|
||||
case REG_FIFO_B_LO:
|
||||
GBAAudioWriteFIFO(&gba->audio, 1, value);
|
||||
GBAAudioWriteFIFO(&gba->audio, address, value);
|
||||
break;
|
||||
case REG_DMA0SAD_LO:
|
||||
GBAMemoryWriteDMASAD(&gba->memory, 0, value);
|
||||
|
|
|
@ -136,6 +136,16 @@ static int32_t GBATimersProcessEvents(struct GBA* gba, int32_t cycles) {
|
|||
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];
|
||||
if (nextTimer->countUp) {
|
||||
++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);
|
||||
}
|
||||
|
||||
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) {
|
||||
timer->nextEvent = INT_MAX;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue