Sonic Mega Collection audio patch for Nintendont

Discussion in 'Wii - Hacking' started by SuperrSonic, Jul 15, 2017.

  1. SuperrSonic
    OP

    SuperrSonic GBAtemp Advanced Fan

    Member
    662
    220
    Dec 9, 2011


    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.
    [​IMG]
    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.
     
  2. cvskid

    cvskid GBAtemp Addict

    Member
    2,240
    824
    Apr 13, 2014
    United States
    Does using the actual gc disc of sonic mega collection give the same audio issues?
     
  3. SuperrSonic
    OP

    SuperrSonic GBAtemp Advanced Fan

    Member
    662
    220
    Dec 9, 2011
    Disc+nintendont gives the same exact issue.
     
    cvskid likes this.
  4. SuperrSonic
    OP

    SuperrSonic GBAtemp Advanced Fan

    Member
    662
    220
    Dec 9, 2011
    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.
     
    cvskid likes this.
  5. the_randomizer

    the_randomizer The Temp's official fox whisperer

    Member
    22,128
    10,451
    Apr 29, 2011
    United States
    Dr. Wahwee's castle
    So why does this happen and why is it so hard to track?
     
  6. SuperrSonic
    OP

    SuperrSonic GBAtemp Advanced Fan

    Member
    662
    220
    Dec 9, 2011
    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.
     
  7. the_randomizer

    the_randomizer The Temp's official fox whisperer

    Member
    22,128
    10,451
    Apr 29, 2011
    United States
    Dr. Wahwee's castle
    The game is running an emulator based off of Gens, so who knows for sure.
     
  8. Sonic Angel Knight

    Sonic Angel Knight GBAtemp Legend

    Member
    10,034
    5,080
    May 27, 2016
    United States
    New York
    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:
     
  9. Viri

    Viri GBAtemp Maniac

    Member
    1,224
    1,103
    Sep 13, 2009
    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?
     
  10. Sonic Angel Knight

    Sonic Angel Knight GBAtemp Legend

    Member
    10,034
    5,080
    May 27, 2016
    United States
    New York
    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.)
     
  11. Viri

    Viri GBAtemp Maniac

    Member
    1,224
    1,103
    Sep 13, 2009
    United States
    Because I was kidding around.
     
  12. Sonic Angel Knight

    Sonic Angel Knight GBAtemp Legend

    Member
    10,034
    5,080
    May 27, 2016
    United States
    New York
    Yes you was. What kind of causal are you? Can't even play pokemon stadium 2 :creep: