don't click here

Sonic R Hacking

Discussion in 'Engineering & Reverse Engineering' started by MainMemory, Dec 1, 2009.

  1. InvisibleUp

    InvisibleUp

    friendly internet ghost Member
    139
    13
    18
    It's fine. I just read your comment as a little harsh and got overly defensive because of it. (Actually, rereading that, ...yeah that was a little too much.) I'm nowhere near as miffed as you think I am. I guess if one thing is clear, it's that it's hard to express emotions in words.

    Glad we're all on good terms. Let's move on.
     
  2. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,742
    338
    63
    SonLVL
    I wonder if it would be possible to integrate DLL injection into your mod loader, or if it would be simpler to just port the SADX Mod Loader as a separate project.
     
  3. InvisibleUp

    InvisibleUp

    friendly internet ghost Member
    139
    13
    18
    So. Cool new thing to show off.



    What you're seeing off to the side is some debug text the devs left in. Normally all of these strings are assembled like a standard printf() input, then thrown out via a stub function. What I did is replace that stub function with a function that calls vprintf(). I also needed an init function that made sure it all got redirected to stdout. (It's supposed to also create a console, but I guess that's behind the game or something...) I did this with my mod loader, for the record.

    This debug text mostly seems to be graphics related. What textures are loaded, what display mode is used, etc. There's also some random information like window events and how many rings are on the track. Some important functions also announce when they're being called. Not quite as useful as I thought it would be, but still pretty neat.
     
  4. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,233
    969
    93
    Long-term happiness
    That's pretty cool. Find anything interesting in the text that you weren't expecting?
     
  5. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,742
    338
    63
    SonLVL
    So... it's been a while. I was asked on IRC if I could make a mod loader for Sonic R to make music load from the main game folder. I asked InvisibleUp if he had plans to release his loader, and he said he didn't, so yesterday I started working on porting my standard mod loader.

    Here is my version of a mod loader for the 2004 version of Sonic R. It has all the standard features: file replacement, DLL injection (untested), and cheat codes (untested). It also patches the game to load music from the main game folder, in order to support custom music in mods. As a side effect of this, the game cannot load music from the CD, and the game no longer requires the CD to function.

    I will add custom resolution support in the next version.

    As always, the source code is available on GitHub.
     
  6. InvisibleUp

    InvisibleUp

    friendly internet ghost Member
    139
    13
    18
    Coming to a hacking contest near you!
    [​IMG]
     
  7. Shaddy the guy

    Shaddy the guy

    Professional Internet asshole Member
    2,114
    1,142
    93
    OR
    Spoiler tags are broken for me, what is it?
     
  8. InvisibleUp

    InvisibleUp

    friendly internet ghost Member
    139
    13
    18
  9. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,742
    338
    63
    SonLVL
    Usually when spoiler tags don't work, it's because you need to wait until every image and YouTube embed has finished loading before you can click on the button.

    Well, this is certainly more impressive than anything I could've come up with.
     
  10. Shaddy the guy

    Shaddy the guy

    Professional Internet asshole Member
    2,114
    1,142
    93
    OR
    That's an annoying way for it to work. Why can't it just load after I open it so I at least know it's doing something? Disregarding the fact that half the time it's just text anyway.

    Anyway, that's a real cool lookin' mod you got there. I like low-poly stuff and it's not often done for post-genesis era characters, so I hope they look good.
     
  11. CheatFreak

    CheatFreak

    Catgirl expert. Member
    I'm actually having a bit of a weird problem with Sonic R 2004 now that I hadn't really noticed before, but it's definitely got nothing to do with the new mod manager.

    Basically, I'm having a problem where, when I have the game in focus, it runs worse, fullscreen or windowed.
    I have fraps open for monitoring FPS in the game, and when I click out of the window, it shoots up to smooth as butter 30, but when I jump back into the window, it goes down to like, 25-26.

    Someone on PC Gaming Wiki posted a "fix" for this by telling you to download dgvoodoo2 and use that but that seems to simply not work, afaik the 2004 port uses d3d9. :V

    Rather bizarrely after running the game in the background for about 5 to 10 or so minutes, occasionally, I'm able to sort of "break out" of this issue, with the game starting to run perfectly fine even in focus, but it seems entirely random, as sometimes when I then leave focus again, it goes back to dipping constantly.

    It's really quite annoying.

    If this could be figured out, a patch for it in the new mod manager would be cool. :V

    EDIT:
    Ask and ye shall recieve. Thanks to MainMemory for fixing it (and morph too for the code the fix was borrowed from.)
     
  12. Aquaslash

    Aquaslash

    <The Has-been Legend> Moderator
    I am now monitoring your posts :)
     
  13. CheatFreak

    CheatFreak

    Catgirl expert. Member
    I took it upon myself to make a simple mod with MainMemory's new Sonic R Mod Loader.
    Simple one this time- it fixes stray pixels in the UI for the game by replacing graphics with ones I've edited to look a bit more clean in game.

    There's obviously a much better way to fix this, but this is a quick and lazy way because I don't know how to code. :V

    Example:
    [​IMG]

    Download

    Also avaliable in the mods section on my website.
     
  14. Mr. Fox

    Mr. Fox

    Member
    559
    9
    18
    Me too. They sometimes do work, but most of the time time do not. Running latest Chrome on Win 10. Have to quote the posts just too see the content.
     
  15. Chris Highwind

    Chris Highwind

    Member
    2,100
    16
    18
    Statesville, NC
    Slacking
    If this becomes a thing, I might actually hunt down a 2004 version of Sonic R for it.
     
  16. InvisibleUp

    InvisibleUp

    friendly internet ghost Member
    139
    13
    18
    Actually, that's running on the 1998 version. I've just zipped the whole game directory up and dumped it on a file host, so you don't need to use MM's mod loader. However, I'm probably going to try and port it to the 2004 version in the future. I only went with the 1998 version because that's what I had on hand when I started.

    Also, more menus!

    [​IMG]

    + - STRANGE, ISN'T IT?  
     
  17. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    So, one thing I've always been curious about is the models. Why is it that some models (notably Sonic) have lopsided faces? Sonic's eye is bigger on one side than the other, and that causes some strange stretching to occur. Is there a fix for this? I want to update some of the textures but if they look screwed up still there isn't much of a point.
     
  18. InvisibleUp

    InvisibleUp

    friendly internet ghost Member
    139
    13
    18
    That's because the game is using rectangular textures on non-rectangular quads. On the DirectDraw renderer it works fine, but it's lopsided on Direct3D. (See https://imgur.com/a/IJssO for an example.) I assume this is because DirectDraw renders the quads as quads while Direct3D splits them into triangles before drawing.

    To fix this, the easiest way would be to alter the character models themselves to make the textures match the polygons. To do so, try this:

    1. Download the OBJ Importer and Exporter, along with Python 3 if you don't already have it.
    2. Run your model through srm2obj to convert it to an obj
    3. Load your obj in Blender or whatever (if you're using Blender, replace your OBJ exporter with this version following these instructions to make sure everything stays in the same order)
    4. If needed, use ImageMagick (convert -size 256x256 -depth 8 rgb:player00.raw player00.png), Photoshop, or some other program (I think there was one earlier in this thread) to convert the textures to something usable.
    5. Edit the textures so that the shape on the texture matches that of the polygon
    6. Run it back through obj2srm and put it in the game's files.

    Assuming nothing breaks, that should be everything you need to edit models. (Don't get carried away, though. Normally the game will crash if your models are too big because not enough RAM is reserved.)
     
  19. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    Wow I didn't realize the 2004 version isn't nearly as fucked up AI wise as the Gems version. Not only is that version a cake walk, a lot of characters have broken AI, particularly Metal Knuckles in Reactive Factory.

    Glad I finally get to play the definitive version of this silly game :v: Hopefully one day people figure out how to add new courses into the game.

    EDIT: Actually, some questions. Is it possible to hack the character replacement order? What I mean is that when you unlock characters, they overlap the original characters and replace them. The replacement order is different on the PC version than the Saturn. On both versions, the first 2 unlockable characters replace Amy than Eggman. Afterwards though they split. On the Saturn, Knuckles is replaced next, than Tails, than Sonic, but Super Sonic properly overwrites Sonic's slot when unlocked regardless of who has been unlocked. On the PC, Tails is replaced first, than Knuckles, than Sonic, but Super Sonic does not overwrite Sonic once unlocked, so you can end up with say, Metal Knuckles, Metal Sonic, Sonic, Knuckles, and Super Sonic in a race. Is there a way to change that? Or might it be possible to randomize the extra racers similar to how it's done in Mario Kart? Might be kinda fun to see some different rosters.
     
  20. InvisibleUp

    InvisibleUp

    friendly internet ghost Member
    139
    13
    18
    Quickly looking through, the logic for that seems to be this (this isn't even remotely close to how it's actually implemented, btw.):

    Code (Text):
    1.  
    2. if Players[0].ID < 5 // Sonic through Robotnik:
    3.     newID = 0;
    4.     for i in range(1, 4):
    5.             if Players[0].ID == newID: // Clash?
    6.                     newID++; // Go to next character
    7.             Players[i] = newID;
    8.             newID++;
    9. else:
    10.     /// S.Sonic, M.Knux, M.Sonic, D.Tails, EggRobo, Sonic, Knux, Tails, Robotnik, Amy
    11.     charList = [9, 7, 5, 6, 8, 0, 2, 1, 4, 3]
    12.     newIdx = 0;
    13.     for i in range(1, 4):
    14.             while Unlocked[charList[newIdx]] == false || Players[0].ID == charList[newIdx]:
    15.                     newIdx++;
    16.             Players[i] = charList[newIdx];
    17.             newIdx++;
    18.  
    Essentially, if you're playing a metal character the game goes down the list to determine who should go in each slot. If the character is locked or you're playing as them, it skips to the next in the list. This explains the replacement that goes on and why it's in the order it is. I'd imagine if you wanted to change the order you'd just change the array or tell it to point somewhere else. (I'm half tempted to do that now...)

    EDIT: That pseudocode was slightly off

    EDIT 2: To fix the Super Sonic issue, we'd have to insert a line along the lines of
    Code (Text):
    1.  
    2. if Unlocked[9] && charList[newIdx] == 0:
    3.         newIdx++
    4.  
    after the while loop.

    As to why metal and non-metal characters are split like they are, I believe it's because they were never meant to be raced against each other. They're on two different "tiers" of sorts. If you watch the AI in a course like Regal Ruin, the low-tier characters take the long route up the ramp and down the staircase, while the metal characters like to just take the shortcut. Additionally, the metal characters are just a lot faster and more capable than the other ones. This is why they have you race against them to unlock them; it's supposed to be lopsided against you. (But this is just me taking a guess, I may be wrong.)

    While I'm stuck musing about character balance, it seems that the devs seriously overvalued the ability to drive across water and shoot missiles. Amy and Robotnik are some of the worst characters in the game, but the intention was that they could "cheat" by driving straight across water, giving them unique shortcuts. However, every character can trudge through the water fast enough that this is really a moot point. And if the weather is set to Snow, anybody can take those shortcuts. And then you have the Metal Sonic and Metal Knuckles, where you can just spam jump and hop across rivers at full speed. And as far as shooting, it'd be much more devastating if it actually did anything besides knock you in the direction you're already going in.