all repos — mgba @ ca9448cd353ca12264bfa1dcfddc6fe470f7d77a

mGBA Game Boy Advance Emulator

GB Audio: Fix channel 1, 2 and 4 reset timing
Vicki Pfau vi@endrift.com
Sat, 22 Sep 2018 15:34:18 -0700
commit

ca9448cd353ca12264bfa1dcfddc6fe470f7d77a

parent

56107e616ff54b5a83668ac268db6245b4620807

2 files changed, 7 insertions(+), 12 deletions(-)

jump to
M CHANGESCHANGES

@@ -61,6 +61,7 @@ - GB MBC: Improve multicart detection heuristic (fixes mgba.io/i/1177)

- GB Audio: Fix channel 3 reset value - GB Audio: Fix channel 4 initial LFSR - GB, GBA Video: Don't call finishFrame twice in thread proxy + - GB Audio: Fix channel 1, 2 and 4 reset timing Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
M src/gb/audio.csrc/gb/audio.c

@@ -206,11 +206,6 @@ }

} if (GBAudioRegisterControlIsRestart(value << 8)) { audio->playingCh1 = _resetEnvelope(&audio->ch1.envelope); - - if (audio->playingCh1) { - _updateSquareSample(&audio->ch1); - } - audio->ch1.sweep.realFrequency = audio->ch1.control.frequency; _resetSweep(&audio->ch1.sweep); if (audio->playingCh1 && audio->ch1.sweep.shift) {

@@ -222,7 +217,8 @@ if (audio->ch1.control.stop && !(audio->frame & 1)) {

--audio->ch1.control.length; } } - if (audio->playingCh1 && audio->ch1.envelope.dead != 2 && !mTimingIsScheduled(audio->timing, &audio->ch1Event)) { + if (audio->playingCh1 && audio->ch1.envelope.dead != 2) { + mTimingDeschedule(audio->timing, &audio->ch1Event); mTimingSchedule(audio->timing, &audio->ch1Event, 0); } }

@@ -263,17 +259,14 @@ }

if (GBAudioRegisterControlIsRestart(value << 8)) { audio->playingCh2 = _resetEnvelope(&audio->ch2.envelope); - if (audio->playingCh2) { - _updateSquareSample(&audio->ch2); - } - if (!audio->ch2.control.length) { audio->ch2.control.length = 64; if (audio->ch2.control.stop && !(audio->frame & 1)) { --audio->ch2.control.length; } } - if (audio->playingCh2 && audio->ch2.envelope.dead != 2 && !mTimingIsScheduled(audio->timing, &audio->ch2Event)) { + if (audio->playingCh2 && audio->ch2.envelope.dead != 2) { + mTimingDeschedule(audio->timing, &audio->ch2Event); mTimingSchedule(audio->timing, &audio->ch2Event, 0); } }

@@ -390,7 +383,8 @@ if (audio->ch4.stop && !(audio->frame & 1)) {

--audio->ch4.length; } } - if (audio->playingCh4 && audio->ch4.envelope.dead != 2 && !mTimingIsScheduled(audio->timing, &audio->ch4Event)) { + if (audio->playingCh4 && audio->ch4.envelope.dead != 2) { + mTimingDeschedule(audio->timing, &audio->ch4Event); mTimingSchedule(audio->timing, &audio->ch4Event, 0); } }