all repos — mgba @ ed94288902a67d9dd0fd86211e07cb27000ec826

mGBA Game Boy Advance Emulator

GB Audio: Fix write behavior on channel 3
Jeffrey Pfau jeffrey@endrift.com
Sun, 14 Feb 2016 01:22:03 -0800
commit

ed94288902a67d9dd0fd86211e07cb27000ec826

parent

94ff4f7c4e25c717f3dc0b049e0e54c1818688ce

2 files changed, 5 insertions(+), 2 deletions(-)

jump to
M src/gb/audio.csrc/gb/audio.c

@@ -281,7 +281,8 @@ if (audio->playingCh3) {

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) {
M src/gb/io.csrc/gb/io.c

@@ -243,8 +243,10 @@ case REG_WAVE_C:

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: