GB Audio: Fix channel 1, 2 and 4 reset timing

This commit is contained in:
Vicki Pfau 2018-09-22 15:34:18 -07:00
parent 56107e616f
commit ca9448cd35
2 changed files with 7 additions and 12 deletions

View File

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

View File

@ -206,11 +206,6 @@ void GBAudioWriteNR14(struct GBAudio* audio, uint8_t value) {
} }
if (GBAudioRegisterControlIsRestart(value << 8)) { if (GBAudioRegisterControlIsRestart(value << 8)) {
audio->playingCh1 = _resetEnvelope(&audio->ch1.envelope); audio->playingCh1 = _resetEnvelope(&audio->ch1.envelope);
if (audio->playingCh1) {
_updateSquareSample(&audio->ch1);
}
audio->ch1.sweep.realFrequency = audio->ch1.control.frequency; audio->ch1.sweep.realFrequency = audio->ch1.control.frequency;
_resetSweep(&audio->ch1.sweep); _resetSweep(&audio->ch1.sweep);
if (audio->playingCh1 && audio->ch1.sweep.shift) { if (audio->playingCh1 && audio->ch1.sweep.shift) {
@ -222,7 +217,8 @@ void GBAudioWriteNR14(struct GBAudio* audio, uint8_t value) {
--audio->ch1.control.length; --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); mTimingSchedule(audio->timing, &audio->ch1Event, 0);
} }
} }
@ -263,17 +259,14 @@ void GBAudioWriteNR24(struct GBAudio* audio, uint8_t value) {
if (GBAudioRegisterControlIsRestart(value << 8)) { if (GBAudioRegisterControlIsRestart(value << 8)) {
audio->playingCh2 = _resetEnvelope(&audio->ch2.envelope); audio->playingCh2 = _resetEnvelope(&audio->ch2.envelope);
if (audio->playingCh2) {
_updateSquareSample(&audio->ch2);
}
if (!audio->ch2.control.length) { if (!audio->ch2.control.length) {
audio->ch2.control.length = 64; audio->ch2.control.length = 64;
if (audio->ch2.control.stop && !(audio->frame & 1)) { if (audio->ch2.control.stop && !(audio->frame & 1)) {
--audio->ch2.control.length; --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); mTimingSchedule(audio->timing, &audio->ch2Event, 0);
} }
} }
@ -390,7 +383,8 @@ void GBAudioWriteNR44(struct GBAudio* audio, uint8_t value) {
--audio->ch4.length; --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); mTimingSchedule(audio->timing, &audio->ch4Event, 0);
} }
} }