GB Audio: Improve "zombie mode" emulation in CGB mode (fixes #2029)

This commit is contained in:
Vicki Pfau 2023-12-20 02:52:45 -08:00
parent 36a9602e62
commit 6ee880c58b
8 changed files with 16 additions and 2 deletions

View File

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 762 B

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 756 B

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 569 B

After

Width:  |  Height:  |  Size: 569 B

View File

@ -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);