GB Audio: Fix write behavior on channel 3

This commit is contained in:
Jeffrey Pfau 2016-02-14 01:22:03 -08:00
parent 94ff4f7c4e
commit ed94288902
2 changed files with 5 additions and 2 deletions

View File

@ -281,7 +281,8 @@ void GBAudioWriteNR34(struct GBAudio* audio, uint8_t value) {
if (audio->nextEvent == INT_MAX) {
audio->eventDiff = 0;
}
audio->nextCh3 = audio->eventDiff + audio->p->cpu->cycles + 2 + 2 * (2048 - audio->ch3.rate);
// TODO: Where does this cycle delay come from?
audio->nextCh3 = audio->eventDiff + audio->p->cpu->cycles + 4 + 2 * (2048 - audio->ch3.rate);
audio->ch3.readable = false;
audio->nextEvent = audio->p->cpu->cycles;
if (audio->p) {

View File

@ -243,8 +243,10 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) {
case REG_WAVE_D:
case REG_WAVE_E:
case REG_WAVE_F:
if (!gb->audio.playingCh3 || gb->audio.ch3.readable) {
if (!gb->audio.playingCh3) {
gb->audio.ch3.wavedata8[address - REG_WAVE_0] = value;
} else if(gb->audio.ch3.readable) {
gb->audio.ch3.wavedata8[gb->audio.ch3.window >> 1] = value;
}
break;
case REG_JOYP: