all repos — mgba @ 883bf556609b07b82fceb704aaf23cb1733dd9fe

mGBA Game Boy Advance Emulator

GB Audio: Fix timing when reseting audio channels
Jeffrey Pfau jeffrey@endrift.com
Mon, 22 Feb 2016 00:05:55 -0800
commit

883bf556609b07b82fceb704aaf23cb1733dd9fe

parent

e9e6eaa353b642342c4dc90564c6ea8eeda4f8e7

1 files changed, 7 insertions(+), 7 deletions(-)

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

@@ -142,9 +142,10 @@ if (GBAudioRegisterControlIsRestart(value << 8)) {

if (audio->nextEvent == INT_MAX) { audio->eventDiff = 0; } - if (!audio->playingCh1) { - audio->nextCh1 = audio->eventDiff; + if (audio->playingCh1) { + audio->ch1.control.hi = !audio->ch1.control.hi; } + audio->nextCh1 = audio->eventDiff; audio->playingCh1 = audio->ch1.envelope.initialVolume || audio->ch1.envelope.direction; audio->ch1.envelope.currentVolume = audio->ch1.envelope.initialVolume; if (audio->ch1.envelope.currentVolume > 0) {

@@ -210,9 +211,10 @@ }

if (audio->nextEvent == INT_MAX) { audio->eventDiff = 0; } - if (!audio->playingCh2) { - audio->nextCh2 = audio->eventDiff; + if (audio->playingCh2) { + audio->ch2.control.hi = !audio->ch2.control.hi; } + audio->nextCh2 = audio->eventDiff; if (!audio->ch2.control.length) { audio->ch2.control.length = 64; if (audio->ch2.control.stop && !(audio->frame & 1)) {

@@ -335,9 +337,7 @@ }

if (audio->nextEvent == INT_MAX) { audio->eventDiff = 0; } - if (!audio->playingCh4) { - audio->nextCh4 = audio->eventDiff; - } + audio->nextCh4 = audio->eventDiff; if (!audio->ch4.length) { audio->ch4.length = 64; if (audio->ch4.stop && !(audio->frame & 1)) {