trigger_segfault Posted May 28, 2016 Share Posted May 28, 2016 (edited) I have managed to successfully read and save Pokemon Box saves and have them load without issues on the actual game. An editor actually does exist for Pokemon Box with source code Here which is what I based some of my findings on however this program doesn't have saving. Thank you Kaphotics for finding it. Save File Structure: Size: 0x76000 (+64 if it contains GCI data) 0x0 - GameCube Memory Card Data 0x02000 - Save Slot 1 0x30000 - Save Slot 2 Save Slot Structure: Size: 0x2E000 0x0 - Array of 23 blocks of data. There is no data after that. Each save file contains 23 blocks from start to finish. There is no leftover data. Save data is stored in an almost identical fashion to the GBA games. Block Structure: Size: 0x2000 Variables: 0x0 - ushort ChecksumA in big endian 0x2 - ushort ChecksumB in big endian 0x4 - u32 BlockID in big endian (from 0-22 inclusive) 0x8 - u32 SaveCount in big endian 0xC-0x1FFB - Actual Data 0x1FFC - u32 Footer (unsure what this is used for) Calculating the Checksum (In C#): uint checksum = (ushort)((ushort)BlockID + (ushort)(BlockID >> 16) + (ushort)SaveCount + (ushort)(SaveCount >> 16)); for (int i = 0xC; i < 0x1FFC; i += 2) { // Read the next ushort in big endian then add it to the checksum. uint word = (uint)(((uint)RawData[i] << 8) + RawData[i + 1]); checksum += word; } ChecksumA = (ushort)checksum; ChecksumB = (ushort)(0xF004 - (ushort)checksum); Actual Data Structure: Size: 0x2BEA0 0x04 - u32 CurrentBox in little endian. (The last box the player was viewing before saving) 0x08 - Start of Pokemon Boxes, Each Pokemon is listed every 84 bytes until the last Pokemon in box 25 0x1EC38 - Start of box names, each is spaced 9 bytes appart and uses Gen 3 GBA Character Encoding and is 9 bytes in length. A name starting in 0 or 255 is empty and the default name for that box should be used. 0x1ED19 - Start of box wallpapers. Each wallpaper is 1 byte in length. Each wallpaper's id corresponds to its order in the menu. GBA Pokemon Character Encoding First load each block then order them from lowest to highest block id. Then dump each block's actual data into a single array and use that as the save file containing your data. Pokemon Data Structure: Size: 0x54 (84 bytes) 0x00-0x4F - Gen 3 GBA PKM Data 0x50 - u16 Trainer ID of sender in little endian 0x52 - u16 Secret ID of sender in little endian GBA PKM Data Structure Saving Pokemon Box: Saving is pretty straight forwards assuming you're reading the file correctly. You don't need to increment the save count or anything and you only need to update the most recent save slot. Keeping the order the blocks were in works when saving the game and loading it on Pokemon Box. I haven't had anyone test it with sorting the blocks. Edited June 1, 2016 by trigger_death Link to comment Share on other sites More sharing options...
BlackShark Posted May 28, 2016 Share Posted May 28, 2016 Since Dolphin-GBA connectivity is shot there's no way to even peak into the contents of what a save contains. Pokemon Box was fixed with revision 4.0-9242 a few weeks ago. Just use the latest development version of Dolphin (https://en.dolphin-emu.org/download/) and the latest version of VBA-M (https://sourceforge.net/projects/vbam/files/) and follow these instructions http://web.archive.org/web/20151006182128/http://vba-m.com/forum/Thread-multiple-instances-of-vba-m?pid=7684 (from their official site before the server crashed a while ago). It works fine for me. Link to comment Share on other sites More sharing options...
trigger_segfault Posted May 28, 2016 Author Share Posted May 28, 2016 Pokemon Box was fixed with revision 4.0-9242 a few weeks ago.Just use the latest development version of Dolphin (https://en.dolphin-emu.org/download/) and the latest version of VBA-M (https://sourceforge.net/projects/vbam/files/) and follow these instructions http://web.archive.org/web/20151006182128/http://vba-m.com/forum/Thread-multiple-instances-of-vba-m?pid=7684 (from their official site before the server crashed a while ago). It works fine for me. Thanks. I'll test it out. Edit: Hmm. It says I need to save at a Pokemon Center, yet I have. I've tried different Pokemon centers and making sure the save is Flash 128k, Both Ruby, Sapphire and Emerald and still nothing. Link to comment Share on other sites More sharing options...
codemonkey85 Posted May 29, 2016 Share Posted May 29, 2016 Stupid question, but are you saving twice in the GBA game before trying to load the save in Pokémon Box? That should guarantee that the 'current' and 'backup' save blocks are identical in case Box is reading the wrong one somehow. Link to comment Share on other sites More sharing options...
trigger_segfault Posted May 29, 2016 Author Share Posted May 29, 2016 Stupid question, but are you saving twice in the GBA game before trying to load the save in Pokémon Box? That should guarantee that the 'current' and 'backup' save blocks are identical in case Box is reading the wrong one somehow. Yes I have been sadly. If anyone else can actually get it to work on their end that would at least mean it's possible. Link to comment Share on other sites More sharing options...
Kaphotics Posted May 29, 2016 Share Posted May 29, 2016 https://github.com/VitHuang/PokemonBoxSaveEditor c++/ruby Save editor for Pokémon Box: Ruby & Sapphire see: https://github.com/VitHuang/PokemonBoxSaveEditor/blob/master/checksum.rb https://github.com/VitHuang/PokemonBoxSaveEditor/blob/054e9878a89fb385e9b8aaf72256107a4f758981/PokemonBoxRSSaveEditor/saveblock.cpp#L47-L57 Link to comment Share on other sites More sharing options...
trigger_segfault Posted May 29, 2016 Author Share Posted May 29, 2016 https://github.com/VitHuang/PokemonBoxSaveEditorc++/ruby Save editor for Pokémon Box: Ruby & Sapphire see: https://github.com/VitHuang/PokemonBoxSaveEditor/blob/master/checksum.rb https://github.com/VitHuang/PokemonBoxSaveEditor/blob/054e9878a89fb385e9b8aaf72256107a4f758981/PokemonBoxRSSaveEditor/saveblock.cpp#L47-L57 Wow well that throws all my research out the window. Thank you though. Now my program can have complete Pokemon Box support! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now