Sonic CD Disassembly

Discussion in 'Showroom' started by Devon, May 22, 2022.

  1. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    Update:
    • Every PCM driver is now disassembled with their data extracted. Music and SFX in ASM format.
    • Began some cleanup and further documentation that I left untouched forever.
     
    ProjectFM, JGamer2151 and Nik Pi like this.
  2. RobiWanKenobi

    RobiWanKenobi Python Developer and ASM enthusiast Member

    Joined:
    Sep 10, 2022
    Messages:
    88
    Location:
    United States
    Nice, I hope to see this go somewhere, maybe even where sonic isn't a different object per zone.
     
  3. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    Technically, most of the zones use the same core object code for Sonic. It's just Wacky Workbench that uses its own copy for handling its gimmicks.
     
  4. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    I am happy to say that disassembly work on the stage MMDs in particular will go by a **lot** quicker now, because I have written myself an auto-analysis script for IDA that can comb through an MMD file for functions, objects, Nemesis compressed data, etc. I made a tool that auto-generates a list of locations from some databases I have, and implements them into the script, as well.

     
    Last edited: Dec 31, 2022
    Pacca, Clownacy, JGamer2151 and 2 others like this.
  5. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    This project is now considered archived. I just simply do not have the time nor the motivation to work on this anymore. Personal matters and other (personal) projects of mine are taking priority. This isn't to say that this is the end for good. Perhaps one day I may return to this. But for now, I must step away. Anyone is free to do their own work if they want to, though. The repository isn't going anywhere and can be forked. I apologize for not getting around to getting it properly cleaned up and organized like I really wanted it to be.

    IDA Script (use with European version)
    Gens Overlay (use with USA version)
    Extracted Data (from European version)

    Notes:
    • The Gens overlay is for the USA version, because I wanted to record videos at the NTSC rate. The others use the European version, because the wiki detailed data locations for it, so I used it.
    • To use the IDA script, open a stage MMD file in IDA, make sure that it's rooted at address 0x200000, and then run "_DisassembleMMD.idc". It will set up known functions, data, structures, and analyze object code.
    • The IDA script and Gens overlay will only work for the FINAL VERSION, not with any prototypes.
    • There MIGHT probably issues that I haven't caught, but generally, these have worked okay for me.
    • They're very much hacked together. Sorry lol
     
    Last edited: Mar 11, 2023
    Pacca, JGamer2151, Nik Pi and 2 others like this.
  6. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    IDA Script update:
    • Fixed branch detection in object code analysis in later versions of IDA.
    • Accounted for different word addressing expansion between versions of IDA.
    • Properly parsed through Sonic's object code in Wacky Workbench.
    Link
     
  7. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    IDA Script update time.

    I have tracked down an issue with it after someone reported it to me. Turns out there's an animation used by the exit barrier in the CCZ boss in which it doesn't have a flag at the end of the data. As a result, it kept continuing to erroneously parse the animation past the end of it, which busted the area where the animal object was at, preventing it from being properly disassembled.
    Code:
    Ani_20EA86:dc.w @Ani_20EA86_0-*
    @Ani_20EA86_0:dc.b 0
            dc.b 0, 1, 2, 3, 4, 5, 6, 7, 7
    [​IMG]

    The reason this animation is like this is because the object itself manually checks which frame it's on before stopping it, meaning the flag isn't really needed.

    I have modified the script that takes this into account.
     
    ProjectFM and DeltaW like this.
  8. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    Pushed out another update to fix a few more issues with uncaught data and a function not being properly disassembled all the way.
     
  9. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    Minor update to the IDA script. Debug item index count reading was a little bugged.
     
  10. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    Surprise! I am continuing the disassembly. I will mention that I am currently refactoring it, so it won't be very usable for a while.
     
    Last edited: Sep 22, 2024
  11. Devon

    Devon DROWN, DROWN, DROWN MYSELF! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,401
    Location:
    your mom
    I will mention one thing, for the refactor, I am going to focus purely on documentation, and following a bit of how the original source code did things. Yes, even if it means that the layout ends up being a bit shitty... but hey, I guess it adds to the accuracy, exposing how cracked Sonic CD's code can get lol. Trying to cater to hackers is just going to make things an even bigger mess, and no amount of polish I could possibly give it will fix any of the fundamental flaws of how the game was structured.
     
    Last edited: Sep 25, 2024
    Crimson Neo, vladikcomper and DeltaW like this.