mirror of https://github.com/mgba-emu/mgba.git
GB Serialize: Fix timing bug loading channel 4 timing
This commit is contained in:
parent
034d4bd43a
commit
af59e28f90
1
CHANGES
1
CHANGES
|
@ -2,6 +2,7 @@
|
||||||
Emulation fixes:
|
Emulation fixes:
|
||||||
- ARM: Fix ALU reading PC after shifting
|
- ARM: Fix ALU reading PC after shifting
|
||||||
- ARM: Fix STR storing PC after address calculation
|
- ARM: Fix STR storing PC after address calculation
|
||||||
|
- GB Serialize: Fix timing bug loading channel 4 timing
|
||||||
- GBA DMA: Linger last DMA on bus (fixes mgba.io/i/301 and mgba.io/i/1320)
|
- GBA DMA: Linger last DMA on bus (fixes mgba.io/i/301 and mgba.io/i/1320)
|
||||||
- GBA Memory: Misaligned SRAM writes are ignored
|
- GBA Memory: Misaligned SRAM writes are ignored
|
||||||
- GBA Memory: Improve gamepak prefetch timing
|
- GBA Memory: Improve gamepak prefetch timing
|
||||||
|
|
|
@ -1078,9 +1078,13 @@ void GBAudioPSGDeserialize(struct GBAudio* audio, const struct GBSerializedPSGSt
|
||||||
LOAD_32LE(audio->ch4.lastEvent, 0, &state->ch4.lastEvent);
|
LOAD_32LE(audio->ch4.lastEvent, 0, &state->ch4.lastEvent);
|
||||||
LOAD_32LE(when, 0, &state->ch4.nextEvent);
|
LOAD_32LE(when, 0, &state->ch4.nextEvent);
|
||||||
if (audio->ch4.envelope.dead < 2 && audio->playingCh4) {
|
if (audio->ch4.envelope.dead < 2 && audio->playingCh4) {
|
||||||
if (when - audio->ch4.lastEvent > (uint32_t) audio->sampleInterval) {
|
if (!audio->ch4.lastEvent) {
|
||||||
// Back-compat: fake this value
|
// Back-compat: fake this value
|
||||||
audio->ch4.lastEvent = when - audio->sampleInterval;
|
uint32_t currentTime = mTimingCurrentTime(audio->timing);
|
||||||
|
int32_t cycles = audio->ch4.ratio ? 2 * audio->ch4.ratio : 1;
|
||||||
|
cycles <<= audio->ch4.frequency;
|
||||||
|
cycles *= 8 * audio->timingFactor;
|
||||||
|
audio->ch4.lastEvent = currentTime + (when & (cycles - 1)) - cycles;
|
||||||
}
|
}
|
||||||
mTimingSchedule(audio->timing, &audio->ch4Event, when);
|
mTimingSchedule(audio->timing, &audio->ch4Event, when);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue