Hacking Sonic Mega Collection audio patch for Nintendont

SuperrSonic

Well-Known Member
OP
Member
Joined
Dec 9, 2011
Messages
807
Trophies
1
XP
2,323
Country
Puerto Rico


Issue starts at 6:15

As you can see in the video SMC has audio latency and distortion when played in nintendont or devolution.
Despite being reported for both projects nothing ever came to be. Can't imagine why.

Patches:

NTSC-U

Audio Patch (SS)
202AA2F9 000005BE
042AA2F9 00000B7B
E0000000 00000000

PAL (60Hz mode only)

Audio Patch (SS)
202C8619 000005BE
042C8619 00000B7B
E0000000 00000000

NTSC-J

Audio Patch (SS)
202ABD11 000005BE
042ABD11 00000B7B
E0000000 00000000

About the issue:
Starting any of the games will slowly, gradually cause the audio to lag behind the game, when it gets to around 6 minutes distortion starts to kick in for about 20 seconds, after that it resyncs, but the next time it will distort sooner indefinitely. The workaround until now was to bring up the pause menu and resume before the lag is noticeable, this forces the a/v to sync until you exit and start another game.

About the patch:
I always thought it was because of the hw speed difference, but apparently this isn't the case. If you start MIOS without BC, the game plays normally albeit with broken audio and no memory card reading but the audio never lags behind the video.

Anyway, because of that I started to experiment and since I don't have a usb gecko for doing so, I used Dolphin to dump memory and started the hunt.
Finding the relevant stuff was surprisingly easy, finding the actual value to fix the issue was a bit long and tedious.
Kp6Hl5w.png

At address 0x2AA2FA is the value that the code changes and acts like a timer, it's volatile, it starts as 0x5BE the moment you start a game, then it changes to 10 different values per frame and loops. What I found is that patching the first value to something else automatically changes the rest, so that's what I did. I increased it and doing that reduced the distortion so I kept at it and now 0xB7B is the farthest I could go before the distortion happens 2 minutes in instead of 6.

The next value you see in the image is 0x44E8, this is the first value that shows up when you load a game, it's always 0x44E8. It seems to affect audio speed, the fact that it's 0x52B0 in 50Hz mode in the PAL version seems to back this. The next value you see in the image 0x5BE, also volatile, might be related to video, constantly patching it to 0x5BE slows down the video when you call the pause menu and resume, otherwise it just makes the audio lag happen sooner.
The 0xAC44 value might be the emulated sample rate, changing it doesn't do anything that I could tell.

Issues worth mentioning:
While this works well to avoid the latency and distorted audio the patch doesn't actually fix it 100%, the game still performs differently from GC mode in that there's a very faint jump in the audio at 6 minutes. In any case I tested the entirety of Sonic 2 without actually noticing this small "audio skip", so it's not so bad. I tested the NTSC-U version, and only changed the addresses for the other versions but it should still work the same.

I recommend using my mod of nintendont, because it removes the memory card delay the official version enforces.
 

cvskid

Well-Known Member
Member
Joined
Apr 13, 2014
Messages
2,810
Trophies
2
XP
3,412
Country
United States


Issue starts at 6:15

As you can see in the video SMC has audio latency and distortion when played in nintendont or devolution.
Despite being reported for both projects nothing ever came to be. Can't imagine why.

Patches:

NTSC-U

Audio Patch (SS)
202AA2F9 000005BE
042AA2F9 00000B7B
E0000000 00000000

PAL (60Hz mode only)

Audio Patch (SS)
202C8619 000005BE
042C8619 00000B7B
E0000000 00000000

NTSC-J

Audio Patch (SS)
202ABD11 000005BE
042ABD11 00000B7B
E0000000 00000000

About the issue:
Starting any of the games will slowly, gradually cause the audio to lag behind the game, when it gets to around 6 minutes distortion starts to kick in for about 20 seconds, after that it resyncs, but the next time it will distort sooner indefinitely. The workaround until now was to bring up the pause menu and resume before the lag is noticeable, this forces the a/v to sync until you exit and start another game.

About the patch:
I always thought it was because of the hw speed difference, but apparently this isn't the case. If you start MIOS without BC, the game plays normally albeit with broken audio and no memory card reading but the audio never lags behind the video.

Anyway, because of that I started to experiment and since I don't have a usb gecko for doing so, I used Dolphin to dump memory and started the hunt.
Finding the relevant stuff was surprisingly easy, finding the actual value to fix the issue was a bit long and tedious.
Kp6Hl5w.png

At address 0x2AA2FA is the value that the code changes and acts like a timer, it's volatile, it starts as 0x5BE the moment you start a game, then it changes to 10 different values per frame and loops. What I found is that patching the first value to something else automatically changes the rest, so that's what I did. I increased it and doing that reduced the distortion so I kept at it and now 0xB7B is the farthest I could go before the distortion happens 2 minutes in instead of 6.

The next value you see in the image is 0x44E8, this is the first value that shows up when you load a game, it's always 0x44E8. It seems to affect audio speed, the fact that it's 0x52B0 in 50Hz mode in the PAL version seems to back this. The next value you see in the image 0x5BE, also volatile, might be related to video, constantly patching it to 0x5BE slows down the video when you call the pause menu and resume, otherwise it just makes the audio lag happen sooner.
The 0xAC44 value might be the emulated sample rate, changing it doesn't do anything that I could tell.

Issues worth mentioning:
While this works well to avoid the latency and distorted audio the patch doesn't actually fix it 100%, the game still performs differently from GC mode in that there's a very faint jump in the audio at 6 minutes. In any case I tested the entirety of Sonic 2 without actually noticing this small "audio skip", so it's not so bad. I tested the NTSC-U version, and only changed the addresses for the other versions but it should still work the same.

I recommend using my mod of nintendont, because it removes the memory card delay the official version enforces.

Does using the actual gc disc of sonic mega collection give the same audio issues?
 

SuperrSonic

Well-Known Member
OP
Member
Joined
Dec 9, 2011
Messages
807
Trophies
1
XP
2,323
Country
Puerto Rico
New code.

NTSC-U

Video Patch (SS)
242AA305 00000000
042AA305 000005BE
E0000000 00000000

Audio Patch (SS)
242AA2F9 00003F2A
042AA2F9 000005BE
E0000000 00000000

Finally got a decent computer to run the game in Dolphin, and since it has the same issue, I watched memory frame by frame, and learned that the a/v desync happens around 2 minutes into the game. Random values start being used instead of the constant values that should be used and are used when the Z menu is brought up.

Unfortunately it's still not perfect, the audio "jump" will still happen and earlier at five minutes, the advantage of this new code is that there is less audio latency.
 
  • Like
Reactions: cvskid

SuperrSonic

Well-Known Member
OP
Member
Joined
Dec 9, 2011
Messages
807
Trophies
1
XP
2,323
Country
Puerto Rico
According to Dolphin devs it's because of slightly wrong sample rate. Somehow though, I can't imagine tueidj getting that wrong with devolution, so who knows.
 

Sonic Angel Knight

Well-Known Member
Member
Joined
May 27, 2016
Messages
14,408
Trophies
1
Location
New York
XP
12,978
Country
United States
Game using a emulator to emulate a console on another console emulator. :blink:

Why not just play the virtual console game or use genesis plus gx emulator, or fusion if you using pc. The only real reason to play this would be if you owned a gamecube with no access to homebrew emulators. Even then the ps2 and xbox version is better. :unsure:
 

Viri

Well-Known Member
Member
Joined
Sep 13, 2009
Messages
4,236
Trophies
2
XP
6,849
Country
United States
Game using a emulator to emulate a console on another console emulator. :blink:

Why not just play the virtual console game or use genesis plus gx emulator, or fusion if you using pc. The only real reason to play this would be if you owned a gamecube with no access to homebrew emulators. Even then the ps2 and xbox version is better. :unsure:
What? You don't use Cemu to emulate Wii u to emulate Wii to play a Pokemon Stadium n64 inject to play Pokemon red? What kind of casual are you?
 

Sonic Angel Knight

Well-Known Member
Member
Joined
May 27, 2016
Messages
14,408
Trophies
1
Location
New York
XP
12,978
Country
United States
What? You don't use Cemu to emulate Wii u to emulate Wii to play a Pokemon Stadium n64 inject to play Pokemon red? What kind of casual are you?
You are right i don't, and would never. I would just use a genesis emulator to play sonic 2 and I would never be playing pokemon stadium anyway. (not sure why you talking about pokemon stadium.)
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Veho @ Veho: I have a number of geriatric relatives.