diff --git a/CHANGES b/CHANGES index b5a6b9136..e5f40a5ff 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,7 @@ Emulation fixes: - GB Audio: Fix channels 1/2 staying muted if restarted after long silence - GB Audio: Fix channel 1 restarting if sweep applies after stop (fixes mgba.io/i/2965) - GB Audio: Fix restarting envelope when writing to register (fixes mgba.io/i/3067) + - GB Audio: Improve "zombie mode" emulation in CGB mode (fixes mgba.io/i/2029) - GB I/O: Read back proper SVBK value after writing 0 (fixes mgba.io/i/2921) - GB I/O: Fix STAT writing IRQ trigger conditions (fixes mgba.io/i/2501) - GB Serialize: Add missing Pocket Cam state to savestates diff --git a/cinema/gb/samesuite/apu/channel_1/nrx2_glitch/xbaseline_0000.png b/cinema/gb/samesuite/apu/channel_1/nrx2_glitch/xbaseline_0000.png index 8ba9bc9df..24c22936b 100644 Binary files a/cinema/gb/samesuite/apu/channel_1/nrx2_glitch/xbaseline_0000.png and b/cinema/gb/samesuite/apu/channel_1/nrx2_glitch/xbaseline_0000.png differ diff --git a/cinema/gb/samesuite/apu/channel_1/nrx2_speed_change/xbaseline_0000.png b/cinema/gb/samesuite/apu/channel_1/nrx2_speed_change/xbaseline_0000.png index eae5b521f..0032b919f 100644 Binary files a/cinema/gb/samesuite/apu/channel_1/nrx2_speed_change/xbaseline_0000.png and b/cinema/gb/samesuite/apu/channel_1/nrx2_speed_change/xbaseline_0000.png differ diff --git a/cinema/gb/samesuite/apu/channel_1/volume/xbaseline_0000.png b/cinema/gb/samesuite/apu/channel_1/volume/xbaseline_0000.png index 54a535e66..e639befda 100644 Binary files a/cinema/gb/samesuite/apu/channel_1/volume/xbaseline_0000.png and b/cinema/gb/samesuite/apu/channel_1/volume/xbaseline_0000.png differ diff --git a/cinema/gb/samesuite/apu/channel_2/nrx2_glitch/xbaseline_0000.png b/cinema/gb/samesuite/apu/channel_2/nrx2_glitch/xbaseline_0000.png index 2cecec38f..eefe570bd 100644 Binary files a/cinema/gb/samesuite/apu/channel_2/nrx2_glitch/xbaseline_0000.png and b/cinema/gb/samesuite/apu/channel_2/nrx2_glitch/xbaseline_0000.png differ diff --git a/cinema/gb/samesuite/apu/channel_2/nrx2_speed_change/xbaseline_0000.png b/cinema/gb/samesuite/apu/channel_2/nrx2_speed_change/xbaseline_0000.png index 51bc87580..2804b6f3a 100644 Binary files a/cinema/gb/samesuite/apu/channel_2/nrx2_speed_change/xbaseline_0000.png and b/cinema/gb/samesuite/apu/channel_2/nrx2_speed_change/xbaseline_0000.png differ diff --git a/cinema/gb/samesuite/apu/channel_2/volume/xbaseline_0000.png b/cinema/gb/samesuite/apu/channel_2/volume/xbaseline_0000.png index c8e022e18..cb59bd6b2 100644 Binary files a/cinema/gb/samesuite/apu/channel_2/volume/xbaseline_0000.png and b/cinema/gb/samesuite/apu/channel_2/volume/xbaseline_0000.png differ diff --git a/src/gb/audio.c b/src/gb/audio.c index 8a778b2ed..996fce66d 100644 --- a/src/gb/audio.c +++ b/src/gb/audio.c @@ -911,12 +911,25 @@ void _writeDuty(struct GBAudioEnvelope* envelope, uint8_t value) { } bool _writeEnvelope(struct GBAudioEnvelope* envelope, uint8_t value, enum GBAudioStyle style) { + bool oldDirection = envelope->direction; envelope->stepTime = GBAudioRegisterSweepGetStepTime(value); envelope->direction = GBAudioRegisterSweepGetDirection(value); envelope->initialVolume = GBAudioRegisterSweepGetInitialVolume(value); - if (style == GB_AUDIO_DMG && !envelope->stepTime) { + if (!envelope->stepTime) { // TODO: Improve "zombie" mode - ++envelope->currentVolume; + if (style == GB_AUDIO_DMG) { + ++envelope->currentVolume; + } else if (style == GB_AUDIO_CGB) { + if (envelope->direction == oldDirection) { + if (envelope->direction) { + ++envelope->currentVolume; + } else { + envelope->currentVolume += 2; + } + } else { + envelope->currentVolume = 0; + } + } envelope->currentVolume &= 0xF; } _updateEnvelopeDead(envelope);