Pokémon Emerald RTC problem

Discussion in 'GBA - Hardware, Devices and Utilities' started by pLaYeR^^, Jul 1, 2016.

  1. pLaYeR^^
    OP

    pLaYeR^^ GBAtemp Fan

    Member
    441
    44
    Sep 18, 2014
    Austria
    Hey guys,
    my battery of my pokemon emerald version ran dry and so i changed the battery and patched the RTC with my nds flashcard. Now all time events work again also berry growing. But there is an old berry which wont grow, also if i change time or date. All other berries which i plant new are growing well. Is there any possibillity to remove the not growing berry, which i messed up? I also can make a save backup and change the save on my computer.
    Thanks in advance! :)
     
  2. FAST6191

    FAST6191 Techromancer

    pip Reporter
    23,868
    9,780
    Nov 21, 2005
    United Kingdom
    I am guessing this berry got planted when the battery died or otherwise was influenced by the battery dying. To that end yeah you will want to be able to dump and restore the save.

    For any other game I would be one of the the ones to sit here and puzzle it out with you but I know there are people out there with far more in depth knowledge of pokemon save hacking so one of those would be the better bet. Still should it happen to me and I actually care then other people having tools does help. Equally I doubt there is a save editor that handles this specifically -- you might be able to put all the berries you want in your bag or get a pokemon to hold it, assuming that is a thing in these games, but probably not edit the plant locations.
    Anyway what I would do is go to the screen and see if there are any other plant zones, many have multiple if memory serves but if it is just the one there is still hope. Make sure there are nothing in those and dump the save. Do nothing else in the game, plant something in the others, save the game and dump the save. Compare the saves to get the changes and other than time in game the only other changes should be the berries and time they were planted. In most game saves I have ever looked at it will all be in a similar location so hopefully in the middle of the changes will be your not growing berry, if not it will be just before or just after. If it is just the one spot in that screen/section then it is still not so bad -- just find ones on sections either side, or in general.

    Anyway so now you know where in the save the berries data is located. Pokemon protects its save with a checksum, like most games do, but people having already come before is a bonus. I don't know what save editors are out there at this point but what you would want to do it is edit the broken berry to be blank (or clone another one) and then load the edited save in the save editor, make a small change (give a pokemon 1 less experience point if you want) and then save in the editor. The editor will then hopefully fix the checksum along the way and you are golden.

    There are some alternative methods. For instance the berry data will likely be loaded into memory at some point, run your game + save in an emulator and use a cheat to change it. The GBA does not have much memory and pokemon has a large save so this is tricky here, for other games with smaller saves it would be the method I use. In most cases the data would be dumped directly from the save into memory so you can find the broken berry info, go to that section in the game, dump the memory or search the memory for that data and then make a cheat to fix it. If by some miracle pokemon does put the entire save in memory (or at least all the things with berries in it) then it is easier to do this.
    If you can figure out what the time was when the broken berry was planted then change your computer to that and run the dumped save, hopefully grow or get rid of the berry and revert to normal save time. If you like you can try to figure it out using the save editing technique above -- plant a berry at a known time in the game, figure out where in the save it is, figure out how the game stores the time and then figure out what the broken berry time is so you can adjust your clock accordingly.
     
    pLaYeR^^ likes this.
  3. anthonyplep

    anthonyplep (´ε` )

    Member
    308
    96
    Apr 13, 2010
    United States
    Ohio
    Might be a dumb suggestion, but could it be possible to say, dump the save to your computer. Then after that get a Gen III map editor, and remove the berry soil/dirt from the map. Open the modified ROM with the hacked map in in an emulator to verify the berry 'area' is gone, rebuild the area in the editor back to normal, verify it works again, and inject the save back in the cartridge?
     
    pLaYeR^^ likes this.
  4. FAST6191

    FAST6191 Techromancer

    pip Reporter
    23,868
    9,780
    Nov 21, 2005
    United Kingdom
    Map editors usually work on the ROM level rather than the save level. That said depending upon how the game works you might get somewhere by loading the broken save into an edited ROM without the errors and hoping the game catches it and removes it from the save. There have been various fixes like this for all sorts of things - games, databases, office documents.... On the other hand it might do nothing and it might even corrupt everything or cause it to crash, however as you would be working with a copy of the save at this point that is not a problem, especially if it only takes 5 minutes on a map editor.
     
    pLaYeR^^ likes this.
  5. pLaYeR^^
    OP

    pLaYeR^^ GBAtemp Fan

    Member
    441
    44
    Sep 18, 2014
    Austria
    First thanks for the long and good answer! I gonna try to dump my save, plant a new one and dump again. Can i check the changes in an hexeditor like HxD?
     
  6. FAST6191

    FAST6191 Techromancer

    pip Reporter
    23,868
    9,780
    Nov 21, 2005
    United Kingdom
    pLaYeR^^ likes this.
  7. pLaYeR^^
    OP

    pLaYeR^^ GBAtemp Fan

    Member
    441
    44
    Sep 18, 2014
    Austria
    I compared with HxD, but there are so many changes.... I just saved in front of a empty place beside the glitched berry, made a backup, plant a berry and made a backup again... I upload the files now in a rar archive. Sav4 is the first backup and Sav5 the second.
     

    Attached Files:

  8. FAST6191

    FAST6191 Techromancer

    pip Reporter
    23,868
    9,780
    Nov 21, 2005
    United Kingdom
    I should have mentioned that pokemon will make a backup of the old save (you may have seen or seen people reference a message like "save is corrupt, loading old save"). I don't know how many save slots the gem named GBA games have but if you have multiple of those then it gets worse still. With that in mind it might be worth saving twice so as to overwrite both sections, or account for it when editing.
    I should also have done the search and seen what is out there
    http://bulbapedia.bulbagarden.net/wiki/Save_data_structure_in_Generation_III

    And a search for a save editor
    https://projectpokemon.org/forums/showthread.php?31254-A-Save-(3rd-Generation-Save-Editor)
     
    pLaYeR^^ likes this.
  9. pLaYeR^^
    OP

    pLaYeR^^ GBAtemp Fan

    Member
    441
    44
    Sep 18, 2014
    Austria
    I already have that save editor, but sadly it doesnt help. In the meantime i tried to edit the rom like anthony said, and yes i can remove the berry but only if i remove the event and so i couldnt plant new berries there. I saved two times now but there are still so many changes. I uploaded the saves.
     

    Attached Files:

  10. Monty Kensicle

    Monty Kensicle Yay!

    Member
    1,171
    280
    Aug 4, 2008
    United States
    Commonwealth of Virginia
    So you swapped out for a working battery yes? Have you tried going to your house in Littleroot and resetting the clock?
     
    pLaYeR^^ likes this.
  11. pLaYeR^^
    OP

    pLaYeR^^ GBAtemp Fan

    Member
    441
    44
    Sep 18, 2014
    Austria
    Yes i changed the battery and refreshed the RTC. The clock in Littleroot works, but the time is bs. However my problem is that i planted a berry a long time ago which still dont grow. New berries always grows and also all other time events work.
     
  12. Monty Kensicle

    Monty Kensicle Yay!

    Member
    1,171
    280
    Aug 4, 2008
    United States
    Commonwealth of Virginia
    Sorry about that, I don't know how I didn't read you mentioning that in the first post.
     
    pLaYeR^^ likes this.
  13. pLaYeR^^
    OP

    pLaYeR^^ GBAtemp Fan

    Member
    441
    44
    Sep 18, 2014
    Austria
    Well i just make a short update. I wasnt able yet to remove the berry from the field. If there is someone who know a bit about pokemon save editing, it would be nice if you could look in my save files.
     
  14. FAST6191

    FAST6191 Techromancer

    pip Reporter
    23,868
    9,780
    Nov 21, 2005
    United Kingdom
    OK I got bored again so I thought I would have a look. It seems stock linux VBA does not have a good cheat search back on the netbook again. After slapping VBA hard enough that it worked with the save and got RTC working I got into your save.

    Searching for this is not quite as nice an infinite items cheat (can't just use one item, search, use one item, search) but start search, plant, search for change, do nothing, search for equal, do nothing, search for equal... is not the worst thing out there.

    I got a few places to look at so I started planting things.

    I am not sure how much data it would need to hold berries but berry type (there appears to be at least 35 of them on your save, http://bulbapedia.bulbagarden.net/wiki/List_of_items_by_index_number_(Generation_III) lists 43 berry items and 346 items in general, so possibly not 8 bit), location (not sure what max planting sections per room/map section is but there are at least 12 here), plant time (maybe it is related to http://bulbapedia.bulbagarden.net/wiki/Save_data_structure_in_Generation_III#Time_played in which case it is going to be large indeed), is or is not watered (don't know what else you can do but it is something that will have to be saved)... anyway no more dead reckoning as I realised I could probably just look up a FAQ and learn more things.
    https://www.gamefaqs.com/gba/921905-pokemon-emerald-version/faqs/38369
    "You should water your trees at every stage to get the most possible berries." So that is possibly four counts of watering or not.

    Anyway 02021788 (skip the first 0 if you are putting it in VBA memory viewer or cheat maker) and the areas surrounding it show some promise. It vanishes if you go into your bag or pokedex or map or something which is not the best programming form if it is actual what is planted data but staying in there it changes when I plant new berries in the other slots and not much else. It also stays there if I sit around doing nothing (in this case you can probably ignore anything that constantly changes).

    Well I got bored and nobody has ever accused me of being gentle. Or in other words -- if in doubt give it a clout. In this case it takes the form of 00ing everything around there.
    Curiously it got the sprites to vanish but pressing a button still says I have one cheri berry here and going into the house and coming back out seems them all appear again. That is OK though as we now have something in memory that clearly deals with berries. That said I tried it in the house and got the sprites to vanish there so it might be some kind of map data (it is not directly sprites as that is handled by the OAM).

    Next step if you are doing this properly is tracing -- if you know it reacts to/writes to that area of memory you can set a breakpoint and find out where the berry data is really kept. If you are talking to others in pokemon forums at the same time then they quite often know tracing (more than I would expect going by the guides I see to it pop up in said forums).

    Personally though I reckon a bunch more savestates but this time change berry type (I was mainly using type 1, go for type 2....). I tried that but did not get too far. Annoyingly the game does seem to have some form of dynamic memory allocation as well, or at least the same structures can appear shifted by a few bytes at times.
    I narrowed it down a bit. In memory a later value in the line starting 020217E8 saw the sprite vanished when blanked. The value however changed quite a lot so it might be an animation/sprite loading pointer of sorts as it did not work all the time and sometimes also lost the girl also visible on the screen. The sprites also reappeared when I planted a new berry (no going in the house/out of the map or anything).

    To that end it is going to be a tracing session and I have things to do today.
     
    pLaYeR^^ likes this.
  15. pLaYeR^^
    OP

    pLaYeR^^ GBAtemp Fan

    Member
    441
    44
    Sep 18, 2014
    Austria
    Wow, thank you again that you made a look in my save files! Sadly im still a noob in pokemon save editing :/ But its nice that you spend your time so much with my problem :) thanks!
     
  16. pLaYeR^^
    OP

    pLaYeR^^ GBAtemp Fan

    Member
    441
    44
    Sep 18, 2014
    Austria
    Problem still exists :(
     
  17. Trinity92

    Trinity92 Newbie

    Newcomer
    1
    0
    Nov 13, 2016
    Luxembourg
    Could you please tell me what exactly you did in A-Save to get in-game time, berries and events working again?
    You see, my battery ran dry so I replaced it, then I extracted my save file from Emerald using the GBA_Backup_Tool on a NDS flashcart. I opened my save file with A-Save and hit "Reset RTC" but events are still not working.
     
  18. pLaYeR^^
    OP

    pLaYeR^^ GBAtemp Fan

    Member
    441
    44
    Sep 18, 2014
    Austria
    You need this : http://furlocks-forest.net/wiki/?page=Pokemon_Ruby/Sapphire_New_Battery_Glitch. In the comments someone posted a DS version of the tool.
     
    Last edited by pLaYeR^^, Nov 13, 2016