metroid-maniac / gba-auto-batteryless-patcher

MIT License
86 stars 6 forks source link

GB Sound Channels too quiet after a SRAM flush happens #9

Closed Dartz150 closed 1 year ago

Dartz150 commented 1 year ago

This happens in Super Mario Advance 2 - Super Mario World.

To reproduce:

1.-Enter Super Mario World, then save and exit; wait for it to do the non-battery save process. 2.-In the game selection menu, select Classic Mario Bros. game. 3.-The music should sound quieter in the GB sounds channel (8-bit instruments).

Dartz150 commented 1 year ago

I'll be testing more games to see if the same behavior happens and report back here.

EDIT: Tested in more games and the same issue occurs, specifically:

-Castlevania: Aria of Sorrow. -Castlevania: Harmony of Dissonance. -Megaman & Bass -Zelda: Minish Cap. -Mario Kart Super Circuit. -Golden Sun. -Golden Sun: The Lost Age. -Metroid Fusion. -Magical Vacation. -Metroid Zero Mission. -Kuru Kuru Kururin.

metroid-maniac commented 1 year ago

https://problemkaputt.de/gbatek.htm#gbasoundcontrolregisters

While Bit 7 is cleared, both PSG and FIFO sounds are disabled, and all PSG registers at 4000060h..4000081h are reset to zero (and must be re-initialized after re-enabling sound).

Most likely this can be fixed just by saving the other PSG registers and restoring them after flushing, just like already done with the master sound register and DMA registers.

metroid-maniac commented 1 year ago

@Dartz150 https://github.com/metroid-maniac/gba-auto-batteryless-patcher/releases/tag/0.0.6

Please retest

Dartz150 commented 1 year ago

@Dartz150 https://github.com/metroid-maniac/gba-auto-batteryless-patcher/releases/tag/0.0.6

Please retest

I can confirm that 0.0.6 patcher fixed the missing GB channels sound issue! Tested the same games with no missing audio so far.

metroid-maniac commented 1 year ago

Looks like the simple fix was enough to fix the identified problem games. There's a chance I'll have to reopen this later since not all of the sound registers are being saved, but for now I'll close this.