+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  GameBoy - Editing Saved Files Without Game Not Loading Them?
Pages: [1]
Author Topic: GameBoy - Editing Saved Files Without Game Not Loading Them?  (Read 2 times)
Lin
Guest
« on: April 04, 2008, 10:59:28 pm »

Hey all. I've been ROM Hacking for a little more than a year now, and made a few tools here and there, and hacked a bunch of ROMs through a hex editor. My question is: Well, my title... I'm trying to hack Dragon Warrior Monsters' saved file, and then edit my monster 1's stats. The address for them starts at 0x253. There is shows 08 00 05 00 05 00 00 00 03 00 Or something like that, and when I go to change 1 byte, whether it's by a great value or like 08 to 09, the saved file acts like it doesn't work and the game sees it as nothing. Then when I fix it, it loads fine again. So basically, is there anyway to prevent this? When/If I figure it out, I'd like to make a tool for it.

Cheers!

~Lin
BRPXQZME
Guest
« Reply #1 on: April 04, 2008, 11:17:01 pm »

I’m loathe to just put advice out there without knowing what you’re talking about, but are you sure there isn’t a checksum or something?
Tauwasser
Guest
« Reply #2 on: April 05, 2008, 06:52:42 am »

Most gameboy games incorporate a kind of checksum function in their save files to make sure they're not corrupted or cheated. Look at the first two bytes and see if that'd be a checksum for either the whole file or a particular part of the file (like 0x100~0x400 bytes maybe or so). I know of games that use it like [Checksum][100 Bytes][Checksum][100 Bytes] etc...

cYa,

Tauwasser
Karatorian
Guest
« Reply #3 on: April 05, 2008, 12:09:19 pm »

One thing you can try can try that which may work if the checksum is a very simple one is to reduce another value by the same ammount that you increase the value you wish to edit. If the checksum is actually a simple checksum and not some sort of more advanced error detection algorithm, it should work.

Of course, this isn't a solution for being able to edit things at will, but it can be used. For instance, in some games, you can edit your current HP down and put the increase into permanant stats. Another thing you may be able to do is to move values from the low byte to the high byte of multibyte values. For example, before I learned how to fix the checksum of Final Fantasy saves, I was able to hack in a lot of gold by reducing the low byte and incresing the high byte by the same ammount.

Of course, what you really want to do is locate the checksum and figure out it's algorithm. There are two ways to go about doing this. The first is by using code tracing or debugging or disassebly (whichever you prefer) to locate the save game and/or load game routines. This is proabably the easiest way if you have the skills and are already familiar with the game's codebase.

The other method is basically brute force. You can attempt to find the location of the checksum by making a series of saves and comparing them. First make one save and move it so it doesn't get overwritten. Then load that save into the game, change some value, and save the game again. Try to change as little as possible. How one does this depends on the exact details of the game you're hacking. But try to keep as much the same as you can. For example, save in the same location. In fact, don't even move if you can alter the game state without doing so. (Like drop an item from your inventory or something).

Once you've got two or more similar, but slightly different saves, start comparing them. Hopefully you'll already know where the value you changed is stored, so you can ignore that. Look for other values that changed. This will give you a list of places to investigate. If the addition and subtraction method I mentioned above works, it will help a lot. Going through the changed values, you would be able to edit them and reload the ROM and see what changed, so you can tell what is stored there. As you eliminate addresses, one of them should be the checksum.

If the addition and subtraction method doesn't work, it'll be more complicated, but it's still workable.

As mentioned above, some games only checksum a portion of the save state. You can test for this by seeing if there are any parts of the save you can edit without corrupting it. If you find any such areas, you can narrow in on the exact checksummed region by progressively moving the edited area until you get corruption. Then you move back until it works again. The fastest way to do this is to move in large steps one direction until you've had a state change (uncorrupted to corrupted or vice-versa) and then start moveing the other way in smaller steps. Keep doing this until you narrow down exactly the byte range covered by the checksum.

If only a portion of the save is checksummed, this will help out in your search for the checksum as you can ignore any changes outside the checksummed areas.

Once you've located the checksum, you'll have to puzzle out the algorithm. There are a variety of error correction algorithms, but the basic ones consist of adding together all the checksummed values with some sort of truncation or modulo arithmetic. More complex versions will require some research. Once you've done that, it'll be a simple matter of programming a small utility to fixup the save.

Best of luck.

Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC