Skip to content

Commit

Permalink
GBA: Disable zombie mode for GB audio channels
Browse files Browse the repository at this point in the history
Caused sound issues in some games (i.e M&L Superstar saga)
  • Loading branch information
SourMesen committed Jul 13, 2024
1 parent 2280d3a commit 3f1ba1e
Showing 1 changed file with 3 additions and 35 deletions.
38 changes: 3 additions & 35 deletions Core/GBA/APU/GbaEnvelope.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,41 +41,9 @@ class GbaEnvelope
if((value & 0xF8) == 0) {
state.Enabled = false;
} else {
//This implementation of the Zombie mode behavior differs from the description
//found here: https://gbdev.gg8.se/wiki/articles/Gameboy_sound_hardware
//Instead, it's based on the behavior of the channel_1_nrx2_glitch test and
//and SameBoy's implementation of the glitch
bool preventIncrement = false;
if(raiseVolume != state.EnvRaiseVolume) {
if(raiseVolume) {
if(!state.EnvStopped && state.EnvPeriod == 0) {
state.Volume ^= 0x0F;
} else {
state.Volume = 14 - state.Volume;
}
preventIncrement = true;
} else {
//"If the mode was changed (add to subtract or subtract to add), volume is set to 16 - volume."
state.Volume = 16 - state.Volume;
}

//"Only the low 4 bits of volume are kept"
state.Volume &= 0xF;
}

if(!state.EnvStopped && !preventIncrement) {
if(state.EnvPeriod == 0 && (period || raiseVolume)) {
if(raiseVolume) {
//"If the old envelope period was zero and the envelope is still doing automatic updates, volume is incremented by 1"
state.Volume++;
} else {
state.Volume--;
}

//"Only the low 4 bits of volume are kept"
state.Volume &= 0xF;
}
}
//No zombie mode for GBA? (or maybe it behaves differently.)
//Using the GB implementation of zombie mode causes sound issues in some games
//e.g popping can be heard in M&L Superstar Saga's menu at the start of the game
}

state.EnvPeriod = period;
Expand Down

0 comments on commit 3f1ba1e

Please sign in to comment.