SA2/SADX Mod Loader

Discussion in 'Engineering & Reverse Engineering' started by MainMemory, Aug 4, 2013.

  1. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    SA2 Mod Loader
    SADX Mod Loader
    [hr]
    After seven days of work (mostly on the mods) the first version of SA2 Mod Loader is done. It's rather similar to SonicGMI/CPKREDIR, except while those are designed to replace data files, the SA2 Mod Loader is designed to inject custom C++ code into the game. It does this by replacing Data_DLL.dll with a custom DLL, requiring no modification to the sonic2app.exe file. In fact, it should work even with the original encrypted exe from Steam.

    Download SA2 Mod Loader. The archive should be extracted to your SA2 install folder.

    In the root folder you'll find SA2ModManager.exe (and some additional files for debugging and stuff). When you run it, it looks something like this:
    [​IMG]
    This allows you to enable and disable mods, change the order they're loaded in, install or uninstall the loader dll, and play the game. You can also enable a console window, which will print the build version and date, the list of mods loaded, any mods that failed to load, and anything a mod writes to stdout, for example with printf or cout.
    You may replace SA2's Launcher.exe with this if you have no need to configure SA2 (you should probably back it up though).

    The archive also contains a folder named "mods", which is where mods will go, each in their own folder with a "mod.ini" file and at least one DLL. It also contains SA2ModLoader.dll which is copied to SA2's Data_DLL.dll when you install. If I update the loader you can replace this copy of the dll and the manager will detect the change and ask if you want to copy it over the currently installed version.

    Finally there's a "programming" folder, which contains the header files that define the mod API, several important variables, functions, structures and enums in SA2, and a couple convenience functions and macros. You will also find a copy of the Character Randomizer mod's source code as an example.

    There are currently three mods, all made by me:
     
  2. Josh

    Josh

    Oldbie
    2,077
    1,021
    93
    USA
    Woah, awesome work dude! I'll give it a try the next time I play SA2. We really need a dedicated database for SA2 and SG mods...
     
  3. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    Update:
    • Mods can now specify overrides for data exported from Data_DLL.dll in the ModInfo structure via a list of structures containing the string name of the export to override, and the data to replace it with.
    • File redirection is now possible. Any time SA2 reads from the resource\gd_PC folder, all mod folders will be searched for a matching file in a gd_PC subfolder. For example, if SA2 loads resource\gd_PC\PRS\missiontex_am.pak, and your mod contains a file mods\modfolder\gd_PC\PRS\missiontex_am.pak, it will load the file from your mod's folder instead of SA2's folder.
    • There is now an option to reactivate SA2's removed debug printing function, allowing you to see its messages in the console.
     
  4. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    I noticed a little bit of what might be an issue.

    I tried using it, and it seems to work perfectly, and then I went to the Chao Garden using the chao key after playing as Tails instead of Eggman.

    [​IMG]

    Weeeelp.
     
  5. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    So I've converted the main functions of the SA2 mod loader for SADX, and I'm releasing it now, without any mods and hardly anything in the .h file because it has some unique features:
    • Fixes the window size to match the selected resolution.
    • Disables the CD check.
    • Allows you to enter a custom resolution (be warned, many nonstandard resolutions cause SADX to abruptly exit).

    Download SADX Mod Loader.

    You should note that, like everything else I do for SADXPC, this only works with the 2004 US version.

    Edit: And I should inform you, that the SADX mod loader's file redirection function does not work for music or videos, as those are handled by Windows Media Player, which I have tried and failed to override. This has been fixed.

    Edit 2: I forgot to mention, it also makes SADX check the depth buffer settings in order from highest to lowest, rather than lowest to highest like it normally does.
     
  6. Strife

    Strife

    Member
    2,013
    216
    43
    United States
    Freedom Planet 2
    So, the mod loader should fix the quirk with SADX where the window stretches beyond the specified resolution? If so, then it's not working for me. I've tried different versions of the .exe as well.
    I'd definitely like to try and get it working, since on my widescreen monitor the game is horizontally stretched to a rather ugly degree unless I switch to fullscreen.
     
  7. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    You're sure you clicked the "Install loader" button?
     
  8. Strife

    Strife

    Member
    2,013
    216
    43
    United States
    Freedom Planet 2
    Nope. To be specific, I set the resolution to be 640x480. While it matches the width, the height of the window ends up being just a few measley pixels, so I can't see anything. I can tell the game is running fine though since I can make out the fading transitions.
     
  9. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    It definitely shouldn't be doing that. Are you using a US EXE, such as the one on my website?
     
  10. Strife

    Strife

    Member
    2,013
    216
    43
    United States
    Freedom Planet 2
    Yeah, that's the one I'm trying to use. My OS is Windows XP with Service Pack 3, and everything I can conceivably update has been updated for a while.
     
  11. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    I made a minor update, try downloading it again.
     
  12. Strife

    Strife

    Member
    2,013
    216
    43
    United States
    Freedom Planet 2
    Works perfectly now. Thanks!
     
  13. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
  14. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    Update for the SADX mod loader which allows mods to overwrite read-only data, and a new mod which required such functionality:
    A Metal Sonic mod. It replaces Sonic with Metal Sonic everywhere but in cutscenes and the Perfect Chaos fight (that'll come later). It also includes his missing voice clips from the GC version in case you don't have them, and it imports his physics data from Sonic Adventure 2 Battle.
    http://youtu.be/JFwH-7m1Jec
     
  15. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    Apparently SADX isn't the only one with music issues, for some reason SA2 uses the full path for music, video and voice files. The loader has been updated to accommodate this, and also makes the read-only data writable.
     
  16. Would it be possible to get his animations in from Sa2? :V That's one thing that always bothered me, he pretty much copies Sonic's for everything. It just felt like a cheap reskin instead of an actual extra character in DX.
     
  17. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    I... guess? I have no idea how SA2 Metal Sonic's "skeleton" maps to SA1 Sonic though.
     
  18. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    Not possible, the two games use totally different animation systems.
     
  19. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    ...what? The animation format is identical, it's the standard NINJA animation format.
     
  20. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    Clarification: It's technically the same 'system', but sa2 is a superset of sa1.

    Then again it's like that for nearly the entire game, not just the animation system.