Jump to content

Editing a black and white save, please give advice.


Recommended Posts

Hello.

I'm attempting to edit an aspect of a black and white save which neither PokeGen nor PokeSav doesn't edit.

Since I'm far more familiar with programming than I am with hex editing I designed a small tool to take care of my data analysis for me.

After saving a "before" save, performing actions in game which would cause this particular data to change and then saving an "after" save, I tried comparing them only to find that over 1500 bytes had changed.

Then I tried opening the before save, walking around and acting in ways which would not change this information, then saving as an after save. Still just as many results. So, I put all results on a "do not show" list, a feature which I had to add to my custome application. Since PokeGen developer Codr informed me that mistery gift data is re-encrypted each time you save, I figured that loading and saving enough times would let me get all mistery gift related bytes blacklisted so my program would no longer display them as mismatched bytes.

I kept doing this until virtually nothing came up, and then I completed the event and saved before and after. Result was 86 changed bytes. Not so bad, so I tried resetting all mismatched bytes which weren't on my ignore list to their values as seen in the before file. Loading the after save back into the game, the Nimbasa city Bianca and father scene (Dad tells bianca she needs to come home, Leader Elesa chimes in, Dad finally changes his mind as beautifully sad music plays) should have played upon entering and leaving the musical hall, but it didn't. In fact, none of the related scenes came back on, which were all in uncompleted states on the before save.

Once that method didn't work, I scrapped the ignore list entirely and started searching for obvious looking event / state values which had changed (a byte in the before that was 0 which changed to 1 in after, 1 to 0, etc). I also have possible proof that the byte responsible for whether these cutscenes should play might also be responsible for whether or not you'll fight a Team Plasma grunt to save the daycare owner and receive the bike. This comes from the fact that using PokeSav to set your x/y/z position to be past the south entrance of town, then leaving via route 5 doesn't result in you being stopped by Bianca to visit the musical hall (since a legit player couldn't possibly get into town without fighting this guy). Once this fight is won, only then does bianca stop you and you go through all those scenes if you try to leave Nimbasa through it's west gatehouse.

With this said, I think this byte has one state for none of it completed, one for battle but not musical event, one for battle, musical event but not father scene (which you have to manually exit the musical hall to trigger), and one for all four events. So I searched for 0 which became 1, 2 or 3, 3 that became 2, 1 or 0, 2 which became 1 or 0 and 1 which became 2 or 3. Several bytes were found but none gave the desired results when reset. Some even corrupted the main part of the save and caused a revert to backup.

There must be a simple explanation for why I can't pull this off and why so very many bytes change.

Can anyone provide a little insite?

Thanks in advance,

Jordan.

Edit: I guess some cutscenes could be stored in a bitfield, which could make them harder to find. Some general info regarding how cutscene flags are stored in this game would be a big help, if anyone can provide such information.

Thanks.

Edited by GenuineCorruption
Link to comment
Share on other sites

I hate to say it, but I don't think anyone really knows anything about the story event completion data (which are likely bitfields as you suggest). Honestly, it would be insanely difficult to use this information effectively, as there are so many story events (that's without even considering flags for whether or not you've battled X trainer), so I'm not sure anyone would be bold enough to try documenting it. You're probably the furthest pioneer for this specific chain of events.

That being said, if you can get your hands on the right software tools, you could maybe just watch the game's RAM while you do your thing. I think that would be easier than viewing save file after save file.

Link to comment
Share on other sites

Hello.

I definitely agree that to develop a system to reset an entire storyline would be close to impossible with all of the random trainers and collectable item balls. However I think it'd be pretty cool to be able to reset key plot events (important event battles, the event which gives you your starter, even gym leaders would be a start which PokeSav for D/P/PT could edit). I'm pretty determined to reset this bianca/dad/elesa scene for my own reasons (love the music, I want to reset it so I can hear it while on the go as my DS travels wherever I do).

I've definitely used tools such as game cheater before, which have you look up a value in a game and type it into the program to seek out a variable through a process of elimination. Such a tool would make it easy to find data such as money, number of X item in bag etc, but their downfall comes when trying to seek out boolean (switch) values. One time a few years back I built a custome script which just had one command to set a switch value to on and then back to off, and Game Cheater could never find it.

I'm actually puzzled as to why my method didn't work. Even more puzzling is the fact that the game changes over an entire KB of data within your save file if you simply load it and then save your game, however blacklisting bytes which changed regardless of actions got me down to 86 bytes but none of them reset it.

I did figure out a few things about the saves last night which should help, but lead me to a question.

The distance between any given byte within the save and it's counterpart in the backup section is 147456 bytes, 147456 divided by 1024 = a perfectly even 144 KB. So finding a value in a hex editor and then navigating to offset 0x24000 (relative to current offset, not from start of file) leads to an identical byte in the other half of the save. So if the main save data is 144 KB long, and the backup is the same, that only accounts for 288 KB out of 512. To me, this suggests 112 KB of extra data at one end of the save and the same at the other. During my tests of before/after saves, results were never found before the 112 KB mark. Likewise, results never populated beyond the 400 KB mark.

This makes me wonder what all this data is (unless the save isn't really 512 KB worth of data and so it contains 112 KB of filler at either end?

I plan on testing this further with one save at start of game and one with the game completed to see if I'm correct in that the leading and trailing 112 KB don't change.

Link to comment
Share on other sites

Another thing you might want to not is that sometimes values aren't on the byte division as seen in hex editors, or even your program).

For instance, when I figured out how to view held money on Mystery Dungeon Explorers of Sky (here), I found that it was stored something like this: yyXXXXXX XXXXXXXX XXyyyyyy, where X (a bit) is part of held money and y is irrelevant and probably means something else.

When you were looking for 0, 1, 2, or 3 in the bytes, you are almost doomed to failure. You must convert the hex to binary and look for what you want in the string of binary. If you look here, you'll find my very old and buggy program which should do a similar thing to yours, but if you look around, you'll find a tool that will convert hex to binary (and then add an extra byte of 0 at the end, watch out for that; also it doesn't pad the left with 0's so you'll have to manually do that). Hopefully that will help you once you've found out the general area of what you're looking for.

Also, I recommend you use HxD in addition to your tool and mine. It can determine the difference between any two files. (Also, the hex editor in mine is fail, so you'll have to use HxD to get the hex to convert to binary).

Since it seems that my tool is still useful, I might reprogram it in the future, removing the annoying bugs.

Link to comment
Share on other sites

I'm pretty determined to reset this bianca/dad/elesa scene for my own reasons (love the music, I want to reset it so I can hear it while on the go as my DS travels wherever I do).

Don't take this as me belittling your R&D, but wouldn't it be far easier to just find the music track and play it on a phone / MP3 player? There are rips of the OST, and I'm sure the ROM hackers on this forum would help you if you wanted to just rip it yourself.

Link to comment
Share on other sites

No interest in buying that type of equipment. The only music player I own is a turntable (vinyl record player), because vinyl which is kept in good condition sounds far better than anything else unless you store your music as uncompressed PCM wave which eats up way too much disk space.

I wouldn't use such a device for anything else so I can't justify the cost. Furthermore, the phones that are accessible (they read what's on the screen aloud) are the more expensive ones.

Besides, my ultimate goal in all of this is to reset all of the key storyline events.

Anyway, anyone care to take a look at this?

0x20212 is an important byte with regards to that scene, but I can't reset it. As I suspected it goes from 0 to 3, 0 being you haven't done any of it's events, one means you fought the grunt and got the bike, 2 means you've done the event inside the contest building and 3 means you've also seen the scene with bianca and her father.

From there, there is a backup of that same byte at 24000 (relative to the first one). Changing one results in the game reverting to the other. Changing both results in the game deleting the entire save.

I managed to hack it in ram, but it didn't entirely work (I got an abrieviated version of some of the scenes) and other portions of the event didn't reset.

Anyone have any ideas as to why it won't allow that to be reverted to it's default value?

Thanks.

Link to comment
Share on other sites

If listening to the music is what you want, then use a flashcart* to run the NDS Music Player:

(*I didn't see anywhere regarding how you obtained the save file so I don't know if you have one. If you don't have a flashcart, you may want to buy one. They can be as cheap as $10, though good ones are $35. Look here for more info.)

As for editing that byte you mentioned, you didn't manually fix the checksum. Since you didn't, the game thinks that part of the save file is corrupt, so it loads the non-corrupt section. When you change both, the game thinks the entire save is corrupt, so it deletes the entire thing. So, you will want to open your save file in Pokegen then save it, fixing the checksum.

Link to comment
Share on other sites

Hello.

The PokeGen strategy did work, sort of. After editing the byte I can open the save in PokeGen, and tell it to consider it to be from Black and White as it won't inicially recognize it with the byte changed. I'm pretty sure you actually have to edit something before saving it will do anything as it didn't work for me until I did that.

Is there any information available on how the checksums work? If possible I'd like to be able to code something to calculate it myself rather than having to rely on an external program.

Thanks.

Link to comment
Share on other sites

Sorry for the late reply.

I'm pretty sure I have the checksum algorithm somewhere... I will take a look in my notes and report my findings.

EDIT: This is all I can find. Just so we're clear, that seed calculation and checksum calculation are universal for DPPt, HGSS, and BW / B2W2. The usage will be slightly different for the Gen V games, because the blocks are structured differently.

I'm sure Codr gave me more specific instructions on how to fix Pokémon Black & White save files, as the structures are (obviously) different from previous games, but I guess I didn't keep that conversation logged. >_> You can contact him with more specific questions.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...