don't click here

SA2/SADX Mod Loader

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

  1. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    I have added a new parameter to the Init function in mods, which is a const reference to a structure containing pointers to helper functions. So far, all these functions enable multiple mods to add ("register") data to SADX's various global lists, such as the start position list, the common object texture list, etc. Currently the structure looks like this:
    Code (Text):
    1. struct HelperFunctions_v3
    2. {
    3.     // The version of the structure.
    4.     int Version;
    5.     // Registers a start position for a character.
    6.     void (__cdecl *RegisterStartPosition)(unsigned char character, const StartPosition &position);
    7.     // Clears the list of registered start positions for a character.
    8.     void (__cdecl *ClearStartPositionList)(unsigned char character);
    9.     // Registers a field start position for a character.
    10.     void (__cdecl *RegisterFieldStartPosition)(unsigned char character, const FieldStartPosition &position);
    11.     // Clears the list of registered field start positions for a character.
    12.     void (__cdecl *ClearFieldStartPositionList)(unsigned char character);
    13.     // Registers a path list.
    14.     void (__cdecl *RegisterPathList)(const PathDataPtr &paths);
    15.     // Clears the list of registered path lists.
    16.     void (__cdecl *ClearPathListList)();
    17.     // Registers a PVM file for a character.
    18.     void (__cdecl *RegisterCharacterPVM)(unsigned char character, const PVMEntry &pvm);
    19.     // Clears the list of registered PVM files for a character.
    20.     void (__cdecl *ClearCharacterPVMList)(unsigned char character);
    21.     // Registers a PVM file for a common object.
    22.     void (__cdecl *RegisterCommonObjectPVM)(const PVMEntry &pvm);
    23.     // Clears the list of registered PVM files for common objects.
    24.     void (__cdecl *ClearCommonObjectPVMList)();
    25.     // Registers a trial level entry for a character.
    26.     void (__cdecl *RegisterTrialLevel)(unsigned char character, const TrialLevelListEntry &level);
    27.     // Clears the list of registered trial level entries for a character.
    28.     void (__cdecl *ClearTrialLevelList)(unsigned char character);
    29.     // Registers a trial subgame entry for a character.
    30.     void (__cdecl *RegisterTrialSubgame)(unsigned char character, const TrialLevelListEntry &level);
    31.     // Clears the list of registered trial subgame entries for a character.
    32.     void (__cdecl *ClearTrialSubgameList)(unsigned char character);
    33. };
    If I add more functions to future versions of the structure, it may be necessary for mods to check the Version number and ensure that they only use functions present in that particular version of the structure, in case a newer mod is loaded with an old loader. Presently, there is no way to check for previous mod loaders, since the value of the structure reference is undefined in previous versions.

    I have updated the Goal Ring Mod so that it adds its PVM to the common object texture list instead of overriding the entire list, and it works perfectly.

    The SA2 Mod Loader will get this functionality soon.
     
  2. SpaceyBat

    SpaceyBat

    Member
    2,037
    309
    63
    United States
    Freedom Planet 2
    I've been having a weird problem with the SADX mod loader for a while. When the loader is in use, the character models have no gloss and some upgrades like Amy's warrior feather have no textures. The problem is fixed if I restore CHRMODELS.DLL to its original state - however, when I do this, the mod loader will no longer function unless I allow it to replace the .dll with its own, and when I do, there is once again no gloss. Any ideas?
     
  3. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    By itself the mod loader shouldn't have any effect on the character models, unless your copy of chrmodels.dll is hacked.
     
  4. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    The SADX Mod Manager now has a "Force 4:3 Aspect Ratio" checkbox which is checked by default, and a "Native Resolution" button which fills in the resolution boxes with your primary screen's current resolution.
     
  5. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,972
    85
    28
    USA
    rom-properties
    In case anyone's tried to run SADX Mod Loader on Wine: The current version of Wine is missing some MSVCP100 functions that were used by the mod loader due to a certain usage of ifstream. I fixed this in git, so SADX Mod Loader now runs properly on Wine. (This also affects SA2 Mod Loader, but I haven't tested it. MainMemory committed a similar fix for that.)

    The fix is not currently available in a precompiled build.

    As a workaround, you can install the original MSVC 2010 runtime and configure Wine to use the native DLLs instead of built-in. http://www.microsoft.com/en-us/download/details.aspx?id=8328
     
  6. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    [​IMG]

    Edit: Okay, for those of you wondering, no, I didn't port Windy Valley beta to the Steam version. I made the SADX Mod Loader's "windowed fullscreen" mode display the border image from the Steam version in the areas of the screen not covered by the game. You can customize it by changing mods\Border.png, although you'll have to do it every time you update the mod loader.
     
  7. Sappharad

    Sappharad

    Oldbie
    1,420
    72
    28
    It was pretty obvious when it instantly crashed and the error had MSVC in it that I needed to install the MSVC runtimes. It was the first thing I tried at least, when I set mine up.
    Nice to know it was something you could work around though, so thanks for fixing it.

    Edit: On a related note, the "Mod manager makes characters not shiny" bug actually happens for me too, but ONLY when running the game in WINE. If I run it in Windows natively, everything looks normal.
     
  8. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,972
    85
    28
    USA
    rom-properties
    I noticed the "not shiny" issue on Wine too, and it's more of a feature. :) I'll check later to see what causes it.

    Latest binary version of SADX Mod Loader now has the Wine fix plus SADX Steam border emulation. (Don't enable logging the debug console to file; that apparently uses an ofstream assignment, which I didn't notice at the time.)

    My branch will be merged sometime this week, and has major code refactoring plus improved versioning. (The DLL itself now has a version resource with the version number and git tag.)

    Randomness: I tried to build SADX Mod Loader with MinGW gcc to see how much work would be needed to get it working. Turns out gcc's libstdc++ marks basic_ofstream::operator=() [and ifstream] as *deleted*. I'm not sure if that's just a gcc implementation quirk, or if MSVC is incorrectly implementing this operator.
     
  9. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,972
    85
    28
    USA
    rom-properties
    Coming later this week hopefully: SADX Mod Loader v3.1

    No major user-visible changes, but the code has been refactored to make it easier to work with, and it now uses cmake instead of Visual Studio projects.

    For modders:
    • SADXModLoader.h has been split into multiple files. You'll just need to #include "SADXModLoader.h" though.
    • Some of the auxiliary files have been consolidated into libmodutils. This isn't going to be distributed as a standalone library, but you can build it by compiling SADX Mod Loader from source. (Or just take the files from src/libmodutils/.)
    And coming sometime in the next month or so: SADX Mod Manager Qt rewrite. Currently using Qt 4.8 (though I may switch to 5.3 later), this will be a full rewrite of the SADX Mod Manager using Qt and C++. As such, it will no longer depend on the .NET Framework, though it will require the Qt DLLs (which will be included). Among other things, the SADX Mod Manager Qt rewrite will have a native Linux port, which will be identical to the Windows version except it will invoke SADX through Wine.
     
  10. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    I have updated SADX Mod Loader to v3.2.

    • SADXModLoader.h now has multiple files, so you'll need to copy all of them into your code instead of just the two.
    • You can now specify parts of data in a mod separately instead of in the ModInfo structure.
      • PointerList Pointers[] -- lists pointers to be written.
      • PointerList Jumps[] -- lists jumps to be written.
      • PointerList Calls[] -- lists calls to be written.
      • PatchList Patches[] -- lists patches to be applied.
      • void __cdecl Init(const char *path, const HelperFunctions &helperFunctions) -- called when the mod is loaded.
      • void __cdecl OnFrame() -- new function, allows code to be run every frame like the cheat code system.
      Remember to put 'extern "C"' and '__declspec(dllexport)' before all of them so the mod loader can find them.
      If you use these APIs in your mod, old versions of the mod loader will fail to run them properly.
    • You can now specify data in INI files, in the same format that split/splitDLL produce, by adding entries to mod.ini:
      • EXEData - sonic.exe
      • CHRMODELSData - CHRMODELS.DLL
      • ADV00MODELSData - ADV00MODELS.DLL
      • ADV01MODELSData - ADV01MODELS.DLL
      • ADV01CMODELSData - ADV01CMODELS.DLL
      • ADV02MODELSData - ADV02MODELS.DLL
      • ADV03MODELSData - ADV03MODELS.DLL
      • BOSSCHAOS0MODELSData - BOSSCHAOS0MODELS.DLL
      • CHAOSTGGARDEN02MR_DAYTIMEData - CHAOSTGGARDEN02MR_DAYTIME.DLL
      • CHAOSTGGARDEN02MR_EVENINGData - CHAOSTGGARDEN02MR_EVENING.DLL
      • CHAOSTGGARDEN02MR_NIGHTData - CHAOSTGGARDEN02MR_NIGHT.DLL
      Note that using this method does not allow as much freedom as building a DLL mod, and makes it easier for people to steal your content.
    StructConverter and DLLModGenerator in SA Tools have been updated to have three Export buttons: one for the old C++ API, one for the new C++ API, and one for INI.

    SA2 version coming... eventually.
     
  11. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    I've added a feature to the SADX Mod Loader that I've been wanting for a long time: if you have Windowed Fullscreen enabled and press Alt+Enter, you can switch between fullscreen and windowed mode. Unfortunately there is a bug with it, the music stops playing when you switch modes, until another song plays (affects both vgmstream and wmp music).
     
  12. Turbohog

    Turbohog

    Member
    966
    125
    43
    That's beautiful. Too bad about the bug though. Hopefully there will be a way to fix that eventually.
     
  13. SpaceyBat

    SpaceyBat

    Member
    2,037
    309
    63
    United States
    Freedom Planet 2
    I usually do my screen adjustments when the game's still in the menu, so it's not too impeding at least.

    Any idea if there will be a feature to leave the game running when it's not in focus for us chao breeders?
     
  14. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    I fixed the music problem, added an option to not pause when inactive, and made an option to not stretch the game to fill the screen in windowed fullscreen mode.
     
  15. Turbohog

    Turbohog

    Member
    966
    125
    43
    That's awesome. This is somewhat unrelated, but have you looked into how SA2 handles screen size and fullscreen mode? My laptop switches between an integrate gpu and a real gpu for games and things. When I run SA2 using the real gpu, fullscreen won't even work. It would be great to be able to fix that in some way. I imagine the way SA2 handles screen size is quite different, since it came out on pc much later.
     
  16. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    I haven't looked into it, and I don't know how much I can do, because by the time SA2 loads Data_DLL.dll, it's already created the window.

    Edit: minor update, switching modes no longer causes the window to disappear and reappear.
     
  17. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    SADX Mod Loader now has multi-monitor support in "Windowed Fullscreen" mode. You can choose to have the game display on any monitor, or span all the monitors. Note however, that widescreen resolutions are still inadvisable (and also impossible for me for some reason, it closes immediately with anything higher than my primary monitor's native resolution).
     
  18. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    You know how SADX was extremely picky about the resolutions it would run with? I've fixed it so that it will run at any resolution in windowed and windowed fullscreen modes. Real fullscreen can only work with a resolution your primary monitor supports, though.
     
  19. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,789
    370
    63
    SonLVL
    Both mod managers have been updated to fix mods in subfolders (ie mods\MyMod\Part1\mod.ini), add a Version property to mod.ini (can be any string), and save the enabled cheat codes to the mod loader's INI instead of in Codes.xml.
     
  20. ELS

    ELS

    Member
    233
    64
    28
    I saw there were some updates to the SADX launcher so I went back to the first post, downloaded the mod manager zip and pasted it into my installation folder.

    But now I can't launch the loader without getting this: [​IMG] If I hit continue I can get to the application but no mods will be on the list refreshing the mod list and attempting to install loader also brings up this message.