Sonic and Sega Retro Message Board: CPKREDIR - loading and combining mods for Sonic Generations - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 6 Pages +
  • 1
  • 2
  • 3
  • 4
  • Last ►
    Locked
    Locked Forum

CPKREDIR - loading and combining mods for Sonic Generations New version 0.41, now with save file redirection

#16 User is offline Chimera 

Posted 11 May 2012 - 01:36 PM

  • I'm not a furry.
  • Posts: 877
  • Joined: 04-October 10
  • Gender:Male
  • Project:TOO MANY. BUT ONE LESS.
  • Wiki edits:5

View PostKorama, on 11 May 2012 - 08:54 AM, said:

As far as I know, Sonic Generations doesn't do the save file access itself, but uses the Steam API for that. I'm not sure if I should mess around with that. It should be possible, though.


Considering the Steam API also controls the DRM (Generations and Sonic 4 Episode 2 use it to check if Steam's running and etc, lol), I really don't think you should on account of possible legal trouble. However, if you manage to get a working Steam API clone that protects DRM (to the dismay of many I'm sure), you can probably get away with that.

Great work everybody, your work is helping me mess around with objects and see how they work :P Documentation on many objects (such as cameras) soon to come.

#17 User is offline SoullessSentinel 

Posted 11 May 2012 - 01:54 PM

  • Posts: 240
  • Joined: 01-October 05
  • Gender:Male
  • Location:Grimsby, England
  • Project:Sonic 1 32X Remix

View PostChimera, on 11 May 2012 - 01:36 PM, said:

View PostKorama, on 11 May 2012 - 08:54 AM, said:

As far as I know, Sonic Generations doesn't do the save file access itself, but uses the Steam API for that. I'm not sure if I should mess around with that. It should be possible, though.


Considering the Steam API also controls the DRM (Generations and Sonic 4 Episode 2 use it to check if Steam's running and etc, lol), I really don't think you should on account of possible legal trouble. However, if you manage to get a working Steam API clone that protects DRM (to the dismay of many I'm sure), you can probably get away with that.

Great work everybody, your work is helping me mess around with objects and see how they work :P Documentation on many objects (such as cameras) soon to come.


Wouldn't it be possible to write a partial Steam emulator, kind of like the cracked Steam releases, but instead of overriding the DRM, Only intercept the saving and loading functionality, passing all DRM checking to an unedited copy of the DLL? That way, communication with Steam should remain intact?

#18 User is offline Yarharhar 

Posted 11 May 2012 - 03:53 PM

  • Posts: 54
  • Joined: 20-November 06
The steam save file is in a predictable location. Just keeping backups/moving/copying different save files would be the easiest path for this.

#19 User is offline Korama 

Posted 11 May 2012 - 03:56 PM

  • Posts: 232
  • Joined: 18-May 04

View PostChimera, on 11 May 2012 - 01:36 PM, said:

Great work everybody, your work is helping me mess around with objects and see how they work :P Documentation on many objects (such as cameras) soon to come.

Great, looking forward to it!


View PostSoullessSentinel, on 11 May 2012 - 01:54 PM, said:

Wouldn't it be possible to write a partial Steam emulator, kind of like the cracked Steam releases, but instead of overriding the DRM, Only intercept the saving and loading functionality, passing all DRM checking to an unedited copy of the DLL? That way, communication with Steam should remain intact?

Yes, as I said, it's doable.
However, nothing as fancy as a Steam emulator is required. I easily found the class methods in Sonic Generations that deal with reading and writing the savegame file (sonic.sav). They call some Steam API function named "SteamRemoteStorage" and even have a fallback implemented. If the SteamRemoteStorage interface couldn't be initialized for some reason, the game would use a local sonic.sav right in its working directory.
Anyway, I think hijacking those savegame methods and redirecting them to a user-defined local file shouldn't be difficult. And doesn't involve Steam at all.

#20 User is offline DinnerSonic 

Posted 11 May 2012 - 04:35 PM

  • Never Posting Since 2004!
  • Posts: 161
  • Joined: 11-April 04
  • Gender:Male
  • Location:West Virginia, United States of America
I figured the save file thing was reasonable because Steam didn't seem to care about all the other stuff everyone did to Generations, the only thing I can see them fretting about would relate to leader boards. Wouldn't they be disabled if you had the program force it into offline mode for accessing the save file offline instead of the Steam Cloud one, anyway? Might be another incidental advantage.

#21 User is offline Dario FF 

Posted 12 May 2012 - 02:46 PM

  • Tech Support Hotline
  • Posts: 934
  • Joined: 03-April 10
  • Gender:Male
  • Location:Mar Del Plata
  • Project:SonicGLvl
I haven't been able to get Sound redirection to work. I tried placing the following folder in the "Sound" folder(using CPKREDIR simple mode), and when I play the stage I just hear nothing at all. If I remove the folder, stock green hill zone plays out.
http://fbe.am/6pt, I know that these files work since I can just use the regular repacked CPK with these and it works ingame.

#22 User is offline iGamr 

Posted 12 May 2012 - 04:04 PM

  • Posts: 260
  • Joined: 16-April 12
  • Gender:Male

View PostDario FF, on 12 May 2012 - 02:46 PM, said:

I haven't been able to get Sound redirection to work. I tried placing the following folder in the "Sound" folder(using CPKREDIR simple mode), and when I play the stage I just hear nothing at all. If I remove the folder, stock green hill zone plays out.
http://fbe.am/6pt, I know that these files work since I can just use the regular repacked CPK with these and it works ingame.


What mod are you trying to use, exactly? I know you posted a link but it's not very clear to me how you'd use those files or what they'd do... Is it just a music swap?

#23 User is offline Dario FF 

Posted 12 May 2012 - 04:12 PM

  • Tech Support Hotline
  • Posts: 934
  • Joined: 03-April 10
  • Gender:Male
  • Location:Mar Del Plata
  • Project:SonicGLvl
It's just the AAX sound files that are usually inside the green hill zone music CPK, but using Windmill Isle's instead. It was done by JoeTE back in January. The fact that the game plays no music whatsoever on the stage when placing the files there kind of indicates the redirection is doing something, but it's not working correctly for streaming it yet.
This post has been edited by Dario FF: 12 May 2012 - 04:12 PM

#24 User is offline Korama 

Posted 12 May 2012 - 04:26 PM

  • Posts: 232
  • Joined: 18-May 04
Thanks. Without you, I'd barely have any test cases. ;)
I've never tested redirecting those sound CPKs, I just assumed (hoped) it would work the same. But apparently it doesn't. Here's the relevant part of the log:

Posted Image

After reading the TOC of SNG_01GHZ.cpk, the game tries to use the regular OPEN function to open those AAX files instead of just reading from the CPK. Very weird...
I'll look into it.

#25 User is offline Dario FF 

Posted 12 May 2012 - 04:31 PM

  • Tech Support Hotline
  • Posts: 934
  • Joined: 03-April 10
  • Gender:Male
  • Location:Mar Del Plata
  • Project:SonicGLvl
Does the TOC store the absolute address of the file in the CPK? I'd assume they stream the file instead of opening it via the regular CPK functions and store it in memory. Given the game crashes when the AAX files are on a different sampling sometimes, perhaps they use some math with that to find the exact position at which they should be reading. I would've given you a log but it doesn't seem to get created when I try to use it. I'm stupid, I didn't know there was a mode 2 for logging, although I doubt it's necessary now.
This post has been edited by Dario FF: 12 May 2012 - 04:32 PM

#26 User is offline Korama 

Posted 12 May 2012 - 05:06 PM

  • Posts: 232
  • Joined: 18-May 04
Yes, LogType=2 is for logging to a file.
The TOC of a CPK stores file offsets in a quasi-absolute way. You have to add 2048 (=size of a CPK header block) to the offset given by the TOC to get the absolute address. Unless the CPK version is 8 or higher, then you have to add the "ContentOffset" value given by the CPK header. ;)

I just found a bug in my TOC routine, the directory name got corrupted somehow, that's why the game can't find the AAX files in the CPK. It's interesting that it actually tries to fall back to external files then! Don't tell me I could have spared myself all the work on CPKREDIR and just pass the game an empty TOC to make it look for external files...
Oh well, even if that were true, you wouldn't have the arbitrary file location and cascading features. It was a good programming exercise anyway. :specialed:

Quote

Given the game crashes when the AAX files are on a different sampling sometimes, perhaps they use some math with that to find the exact position at which they should be reading.

I was thinking the same at first, but now I don't think that's the case.
Anyway, I suspect the CSB files might be responsible for those crashes and other issues. They obviously contain control information for the respective sound CPKs.
I think CSB stands for "cue sheet binary". It's just another use of CRI's UTF (universal table format?).
Here's a screenshot of SNG01_GHZ.csb in an experimental UTF reader that I made, a byproduct of CPKREDIR:
Posted Image
If I find the time, I might release a full-blown UTF/CSB editor one day.
This post has been edited by Korama: 12 May 2012 - 05:07 PM

#27 User is offline Korama 

Posted 12 May 2012 - 06:05 PM

  • Posts: 232
  • Joined: 18-May 04
Okay, I fixed the bug.

Here is a little hotfix release.

Sound CPK redirection should work with that.

#28 User is offline Dario FF 

Posted 12 May 2012 - 06:34 PM

  • Tech Support Hotline
  • Posts: 934
  • Joined: 03-April 10
  • Gender:Male
  • Location:Mar Del Plata
  • Project:SonicGLvl
Thanks for the quick support! It works perfectly now music-wise, no crashes, could quit the level fine. Will report if I run into any more stability issues later on.
This post has been edited by Dario FF: 12 May 2012 - 06:35 PM

#29 User is offline iGamr 

Posted 12 May 2012 - 06:59 PM

  • Posts: 260
  • Joined: 16-April 12
  • Gender:Male

View PostKorama, on 12 May 2012 - 06:05 PM, said:

Okay, I fixed the bug.

Here is a little hotfix release.

Sound CPK redirection should work with that.


If we already have CPKREDIR installed, which files need to be replaced?

#30 User is offline Korama 

Posted 12 May 2012 - 07:06 PM

  • Posts: 232
  • Joined: 18-May 04
The DLL, of course. And the txt file, maybe.
But replacing the other files shouldn't do any harm either. Just be aware that overwriting any ini file will naturally reset any settings you might have customized.

  • 6 Pages +
  • 1
  • 2
  • 3
  • 4
  • Last ►
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users