don't click here

S&KC Mod Loader

Discussion in 'Engineering & Reverse Engineering' started by MainMemory, Apr 28, 2015.

  1. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    Someone on SSRG posted a request for help with getting a level they had converted into Sonic & Knuckles Collection, but there was no easy way to do it, so I sought to rectify that.

    The S&KC Mod Loader has all the same basic features as the SADX/SA2 Mod Loaders, it can load DLL files containing custom code, it can load data from an INI file, and it has cheat code support. The one thing it doesn't have is file replacement, due to all the game's data other than music and sfx being in the EXE.

    Download

    To create a mod, create a folder within the "mods" folder of your S&KC install, and add a file named "mod.ini" within that folder containing the following lines:
    Code (Text):
    1. Name=Mod Name
    2. Description=Mod Description
    3. Author=Your Name
    Additionally you can add a DLLFile line pointing to a DLL file to load, and an EXEData line pointing to an INI file listing data to be replaced in the EXE.

    The S&KC disassembly has been updated to include more split data files, all the levels in SonLVL's INI, and an example INI file for the mod loader's EXEData setting.

    Note that I have only done minimal testing with unedited AIZ1 files.
     
  2. PsychoSk8r

    PsychoSk8r

    PsychedelAnt | Tone Turner Oldbie
    2,640
    56
    28
    Birmingham, UK
    30 Day Project: Revisited.A New Release!
    Could this potentially make possible in future a mod to display from high colour graphics rather than limited pallete (if developed)? perhaps even higher resolution tilesets?
     
  3. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    Anything's possible.

    But it would require a lot more research than has been done so far, and a lot of recoding things.
     
  4. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    I've finally made an update for this thing. Now it has self-update support, mod update support, save file redirection, and a custom music playback engine with support for MIDI, SMPS (Megadrive), VGMStream (ADX, BRSTM, etc), and other music file formats. There is a configuration tool for the music player included in the "Music" folder. Mods can also include their own Music folder to override the base settings, allowing for easier switching of music.

    The music player will default to using the SMPS music from the original Megadrive version of the games. There is a mod included that switches to the MIDI music from the PC release. Unfortunately (or fortunately, depending on how you feel about it), the MIDI playback method used by the mod loader requires the use of a soundfont file, so the MIDI music will not sound exactly the same as it normally would. The selected soundfont can be changed in the music configuration tool.

    If you had the old SMPS Player or HQ Music mods, you should remove them, as this has the functionality of both, and is incompatible with those mods. Additionally, if you've injected custom MIDI data into the game's MIDIOUT.DLL, you will have to export them to MIDI files and use the mod loader's music configuration to play them, as it ignores the original MIDIOUT.DLL entirely.

    I've also made a Mania Music mod as an example of the new system.
     
  5. Blue Spikeball

    Blue Spikeball

    Member
    2,346
    956
    93
    I decided to give the new feature a shot, but I can't seem to get the game to use custom tracks :v:
    I open the music config tool, assign an mp3 on my hard drive to AIZ on both All and S3&K by clicking the "File..." button, and it still plays the SMPS AIZ1 theme. Checking the Music.ini file confirms that the track was properly added to the ini file. I even tried using one of the music tracks from your Mania music mod and nothing.

    If I click "List..." and, say, assign the HCZ1 theme to AIZ1, it gets properly replaced with SMPS HCZ1.

    What am I doing wrong?
     
  6. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    Sounds like it's failing to read the sound file. I should probably have it display that in the log. Either you're using an unsupported format, or I screwed something up.
     
  7. Blue Spikeball

    Blue Spikeball

    Member
    2,346
    956
    93
    It couldn't be an unsupported format, I tried the music files from your Mania Music mod.
     
  8. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    Oh, wait. You used files from outside the Music folder, didn't you. The mod loader just dumbly adds the relative path to the folder in question to each file, so if you have a full path, it ends up becoming invalid.
     
  9. Blue Spikeball

    Blue Spikeball

    Member
    2,346
    956
    93
    Oh, that was it! Now it works as a charm, thank you :)

    Nice to see that your mod manager is compatible with Korama's patches, the S&KC HD Audio patch conflicted with them. Any plans for adding FLAC support and/or MD sound effects?

    Edit: Bug report - I've noticed that the speed shoes slow down the music if you're using the SMPS audio, but work properly with custom tracks.
     
  10. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    FLAC, sure I guess. MD sound effects would require ValleyBell to add support for them to SMPSPlay, and would require me to figure out how I can replace the game's sound effect playback.
     
  11. Blue Spikeball

    Blue Spikeball

    Member
    2,346
    956
    93
    Thanks for adding FLAC support.

    As for the SFX. Well, I suppose SMPS isn't a requirement; I would be happy with just being able to replace the sound effects with custom audio files, that way it would be possible to replicate the MD SFX by using rips. But I'll understand if you're not planning to look into the matter any time soon, since this mod loader is probably not a priority for you compared with the ones for the other games. I'll just say that I appreciate the community fixing Sega's shoddy ports one step at a time.

    Edit: The newest version of the mod loader is missing the music config tool. Also, FLAC playback isn't working for me for some reason, even though I put the track in the Music folder and properly edited the .ini file.
     
  12. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    This is why it's important to at least test that your code builds before you ship it. Not only was it missing the music config tool, it was missing the mod loader and mod manager too. Now that the mod loader is actually in the update, if FLAC support doesn't work, I have no explanation, I'm pretty sure I'm loading the plugin properly.

    As for sound effects, I would be totally up for implementing SMPS if the opportunity became available. As for using better recordings, that's entirely possible now. SKCsnd can be used to import sound effects at any chosen quality level, and if you want to make the game play them, a small C++ or cheat code mod could easily do it. It's just a matter of someone taking the time to organize and rip all the sound effects.
     
  13. Blue Spikeball

    Blue Spikeball

    Member
    2,346
    956
    93
    Oh, it's working now. A minor thing, though: You forgot to add the .flac extension to the open dialog in the music config tool.

    A glitch I found: If I have a custom track set to Invincibility or Super Sonic, place 4 or more Super monitors with debug mode, break them to go Hyper and get 200+ rings, then grab a ring (thus gaining a life), the 1up jingle starts playing endlessly. It doesn't occur with 100 rings, or if I had previously gained a life, or if I'm using the SMPS invincibility tune.
    If I attempt to replicate the glitch with the Mania Music mod, the 1up jingle plays only once as expected, but then the bgm stops playing.

    Another minor one is that the mod loader breaks the menu sound test: it cannot play SMPS music, and custom tracks play but the Stop button doesn't work. Not a huge deal though, and the level select sound test still works.

    Oh, I thought using the SKCsnd method restricted you to a lower sound quality than the original MD version?
     
  14. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    By default, it does. But there are options to change the quality.

    I've attempted to fix the 1up issue. As for the sound test, I can't imagine why it doesn't work properly, but perhaps I can replace it with my own eventually.

    Also, I've released a mod that makes the game's palette more accurate to the MD version: https://gamebanana.com/gamefiles/6489

    Edit: oops I made the 1up handling worse on accident.
     
  15. Blue Spikeball

    Blue Spikeball

    Member
    2,346
    956
    93
    Are you talking about the hex edit hack to the executable to tweak the bgm sample rate?

    The 1up jingle and sound test issues seem to be fixed now, good job :thumbsup:

    Nice, I didn't realize S&KC had slightly darker colors. It's subtle, but it looks better with the mod.
    While we're on the subject of possible fixes to the port, there are the tiles of the Rolling Jump background, which seem to be incorrectly flipped or something, as they give it a saw-like look:
    [​IMG]
    Perhaps you would like to look into that?
     
  16. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
  17. Redhornett

    Redhornett

    Member
    13
    0
    0
    Neofeud - a point-and-click adventure made with Adventure Game Studio
    Probably a silly question, but how do we get the mod loader to detect the original game file?
     
  18. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    You just extract the archive to the folder that sonic3k.exe is in.
     
  19. Redhornett

    Redhornett

    Member
    13
    0
    0
    Neofeud - a point-and-click adventure made with Adventure Game Studio
    Cheers. How do we get it to run with the SEGA PC Reloaded program please?
     
  20. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,733
    330
    63
    SonLVL
    As long as you've installed the game in Sega PC Reloaded and ddraw.dll is in the game's folder, it will automatically load the Sega PC Reloaded stuff.