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
    @Strife
    I can't seem to find where that is in the 2004 version, but in the 1998 version there's a table at 0x4828AC that controls which character (excluding Sonic) gets which "engine" sound effect. (It can be one of "Null", "Tails", "Amy" or "Robot".) I modified that part of the code in Redux to make Silver make noises when he hovers and to make Tails not be so obnoxious by changing the pitch of his tails and not making them make noise when he ran.
     
  2. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    Sonic R Mod Loader is now at v3. Added icon to manager program, fixed sound effect replacement, added widescreen support, fixed "practice mode" code, added initial PNG/GIF/BMP texture support.
     
  3. Conzuh

    Conzuh

    yeah yeah big nice Member
    84
    11
    8
    Millennium Dreams
    Just wanted to say that the work you guys have put into this is absolutely amazing. For years I've been coming back to Sonic R and been frustrated with how difficult it was to get working on modern machines. To be able to play it now with ease in widescreen HD plus mods is more than I could have hoped for. Excited to see where the community takes it next!

    Just wondering if there's a way to have the title screen and menus render 4:3 and the courses 16:9?
     
  4. BlazeHedgehog

    BlazeHedgehog

    A "Community Enigma"? Oldbie
    1,467
    11
    18
    If you're like me, the ring sound in Sonic R for PC drives you crazy. It clips like hell, which makes this game a nightmare to listen to using headphones. When I had Sonic R installed back on Windows XP it was just a simple matter of replacing the ring1.wav, but since we have a mod loader now, I'll just make that a mod formally

    So here's that!

    https://gamebanana.com/sounds/39571

    I just took the ring chime from Sonic 2 and ran it through a couple of FL Studio plugins to make sure it doesn't clip or sound too annoying.
     
  5. ICEknight

    ICEknight

    Researcher Researcher
  6. BlazeHedgehog

    BlazeHedgehog

    A "Community Enigma"? Oldbie
    1,467
    11
    18
    I used the Sonic 2 ring sound from Lange's pack, actually. It's probably just an artifact of the filter/compressors I used, or the process of downsampling from 44100 to 22050

    Your ears are too good, ICEKnight :colbert:
     
  7. CheatFreak

    CheatFreak

    Catgirl expert. Member
    Trying it myself, it seems like maybe you overcompensated for the possibility of clipping a bit, I'm actually working on a mod called "Classic SFX Pack" which aims to replace the majority of the games sounds with ones from the classics now, and as is mine sounds just as loud as the original sound effect but without horrible clipping going on and that alone was enough.
     
  8. Covarr

    Covarr

    Sentient Cash Register Member
    4,233
    3
    18
    Trapped in my own thoughts.
    Two stageplays, a screenplay, and an album
    The noise at the end is because of this sudden stop:

    [​IMG]

    It's easy enough to fix by chopping the file there and adding a fade out. Here's what a quick and dirty fade looks like in Adobe Audition, but any audio software should be able to do this:

    [​IMG]

    Here's the file it produces.

    As a general rule, a jump like that from sound to no sound should be avoided. It's all but guaranteed to sound wrong in virtually any scenario.
     
  9. InvisibleUp

    InvisibleUp

    friendly internet ghost Member
    139
    13
    18
    I was messing around with the vertex shading and I think I got a little bit of a lead.

    So, normally the game looks like this:

    [​IMG]

    However, there's this variable at 0075349C that I'm calling RenderMode. In the 1998 version, this signaled whether the game was running in DirectDraw or Direct3D mode, and let the graphics routines do different things accordingly. Even though there is no DirectDraw mode in the 2004 version, changing it (where 1 = Direct3D, 0 = DirectDraw) still does things.

    [​IMG]

    First off, the background scrolling is completely broken, going way too fast and wrapping improperly. The camera angle is different too, for some reason. (Switching back and forth has the camera move back and forth between the two spots.) But, more importantly, the vertex colors are darker.

    As it turns out, when loading the level, if the RenderMode is set to Direct3D, 96 is added to the vertex colors, bringing them to a range from 96 to 255.

    I wanted to see if I could recreate the DirectDraw rendering in Blender. So I imported the track into Blender (using a slightly modified version of my Blender importer) and set the blend mode to Multiply. Sure enough, the output looked just like the game with RenderMode = DirectDraw.

    [​IMG]

    However, none of the other blend modes were even remotely close. So I then turned the textures off, took a screenshot, and did the same with the vertex colors. I then imported the textures-only and colors-only images into Krita. Layering the colors over the textures and playing with the blend modes got me results pretty consistent with what Blender was giving me. I think I found the right blend mode: "Grain Merge".

    [​IMG]

    And for comparison's sake, DirectDraw from the 1998 version

    [​IMG]

    According to the Krita docs, Grain Merge is where "Similar to addition, the colors of the upper layer [colors] are added to the colors [textures], and then 50% grey is subtracted." That seems really doable. I just need to figure out how to implement it now.
     
  10. CheatFreak

    CheatFreak

    Catgirl expert. Member
    Used the cheat engine debugger to tinker around with that address you posted.

    Looks like there's some code at 00405345 onward is responsible for changing the camera angle if the value at that Render Mode address you posted is set to 1, which always run in the 2004 port because there's no setting for render mode, obviously.

    If you change the condition so that it's looking for 0 instead, it'll always be using the saturn/directdraw sort of camera angle, which is pretty cool, I prefer the more "behind the back" sort of camera to be honest. Only annoying part is that the floor map seems to just disappear while you're walking on it... kind of annoying, but still, super cool that this is something that you can change now.

    The "easy" addresses you can use to change this is 00405359 and 004053B7, by setting it to 0 instead of 1.

    Edit: Off topic, I also posted a sound effects mod of my own that fixes the ring sound clipping problem and improves quality of several other sound effects, but without making the sounds any quieter. More work needs done on this for sure, but until then, this will do.

    https://gamebanana.com/sounds/39581
     
  11. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    Actually, it seems that the true software rendering mode from the 1998 version is with 0075349C = 2, but in order for it to not simply show an error dialog with a message "unsupported", you also have to set 007C2470 (bits per pixel) = 15 or 16. In the true "software rendering" mode, the game displays the logo screens as pure white, the "R" on the title screen is completely black, the models on the menus use the different lighting, and when you go to race, you're presented with a black screen, there's no voice for the countdown, and I'm not sure but I think the track is loaded incorrectly, because there are times when I think I should be hitting water but I don't.
     
  12. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    One thing I've always wondered, is it possible to assign the stipulations for Time Attack's Reverse Mode onto VS or Grand Prix mode?

    It seemed odd the developers didn't add that option since they already had half the programming through Time Attack and it would have at least semi-compensated for the game's lack of tracks.

    Grand Prix would likely involve programming new AI but VS could possibly just work on Time Attack's coordinating.
     
  13. I'd imagine it would need new AI. Sounds like a pretty cool idea. Definitely something I'd like to see.
     
  14. qwertysonic

    qwertysonic

    Member
    917
    312
    63
    creating the biggest sonic collection
    Thanks for the Sonic R Updater. This definitely beats using dxwnd or some other work-around to play Sonic R on modern PCs. It's nice to see Sonic R get some hacking love after all these years.
     
  15. InvisibleUp

    InvisibleUp

    friendly internet ghost Member
    139
    13
    18
    Actually, in the Tag 4 mode the AI is perfectly capable of running the course backwards. It might not be THAT horrible difficult to implement.

    Of course, the AI is hideously dumb and barely competitive, but that's another matter entirely.
     
  16. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    So what you're saying is, you're going to make a harder AI mod in the future?

    I'm not sure when I'll get to making another proper release, but there have been some changes in the code list, including one to disable the menu timeouts. You can grab the latest code list here.
     
  17. McAleeCh

    McAleeCh

    Oldbie
    1,470
    531
    93
    Just chiming in to say it's great to see research being done into restoring the DirectDraw lighting effects - I still have my '98 disc of Sonic R, and the DirectDraw mode screenshot is exactly how I remember Radical City looking. Hope you're successful in figuring out a way to implement these effects in the mod loader compatible version of the game, so they can be enjoyed in conjunction with proper widescreen etc.! = )

    Out of interest - how comparable is the DirectDraw mode lighting to the overall look of the original Saturn version of the game? Just curious - I'm mostly familiar with the PC version of the game, which I know has a lot of added things like the weather effects, but I'm curious if there's anything which was lost in the transition between Saturn and PC. If there is anything unique to the Saturn version, it'd be interesting to see if modders could restore it, similar to what's been going on recently with SA:DX on PC.
     
  18. Chibisteven

    Chibisteven

    Member
    1,364
    39
    28
    US
    https://info.sonicretro.org/Sonic_R#Versions
     
  19. BlazeHedgehog

    BlazeHedgehog

    A "Community Enigma"? Oldbie
    1,467
    11
    18
    The sample rate for sound effects is locked at mono 22050hz, huh? Or am I missing something?

    I'd like to do a mod that implements sounds from the Saturn version of Sonic 3D Blast, but a lot of those require stereo panning and ideally 44100hz, but upping the sample rate just makes them play at half speed in-game.
     
  20. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    Yeah, it creates all the DirectSound buffers with the same settings, disregarding the WAV files' headers. It should be possible to fix it, but unfortunately IDA lacks a DirectSound8 type library, so I can't get a good idea of what it's actually doing.