GB Audio: Fix write behavior on channel 3
Jeffrey Pfau jeffrey@endrift.com
Sun, 14 Feb 2016 01:22:03 -0800
2 files changed,
5 insertions(+),
2 deletions(-)
M
src/gb/audio.c
→
src/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.c
→
src/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: