Author Topic: EDGBA X5 Battery/RTC Questions  (Read 715 times)

0 Members and 1 Guest are viewing this topic.

Offline dav3yb

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
EDGBA X5 Battery/RTC Questions
« on: October 17, 2020, 09:07 PM »
So I just recently picked up an Everdrive X5 off ebay, and I've been learning a lot about some of the nuances of the RTC.  It's an older model (Rev. B), as I wanted to avoid any of the current manufacturing issues that are being ironed out.

I started a game of Pokémon Emerald, and I used Boktai to set the date of the RTC.  From the reading I've been doing, it's probably a good idea to use Boktai any time I start a new game on anything that uses the RTC, since Boktai allows you to set the date along w/ the time. Would this be accurate to say?

Also, how does swapping the ED's battery or it dying effect the RTC for games like Pokémon Emerald.  I have a cartridge for emerald, and I recently replaced it's battery (as it's been dead for a while), but I'm guessing due to some discrepancies with the save file and RTC, Berries no longer grow for me on the official cart.  I'd like to avoid this on the ED if possible, so should I just use Boktai to set the date/time any time the battery is swapped?

Also, the easiest question, what type of battery does the EDGBA use?

Thanks for any info anyone can provide. 

Offline Richardragon87

  • SNESAdvance Revival Coder
  • Sr. Member
  • ****
  • Posts: 450
  • Karma: +9/-0
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #1 on: October 17, 2020, 10:11 PM »
The RTC in my opinion seems to be the reason why the batteries always run out as it happened in the physical games too, games that don't use RTC never drain the battery so it lasts for years... it seems like something no one has figured out how to make a RTC function that wont drain the battery in the device that runs it. I avoid my GB X7 for that exact reason.
[quote Random dating spambotJ

Quote
Post changed:

Great, the photo didn't load! Does anyone know how to fix this?
In any case, my other photos can be viewed here, I will be glad to meet you, I love flirt))

P.S Richardragon87! Don't write me again, dude! You're in ignore list!

Offline taiyotenko

  • Newbie
  • *
  • Posts: 11
  • Karma: +1/-0
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #2 on: October 17, 2020, 10:12 PM »
The issue with Pokémon R/S/E games is that they do a clock reset when you start a new save file. Setting the clock with Boktai 1 is the best way to change the clock on the EDGBA.
The battery is a CR1220 and since EDGBA has a support it's pretty easy to swap.

Offline nuu

  • Hero Member
  • *****
  • Posts: 1586
  • Karma: +74/-2
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #3 on: October 17, 2020, 10:57 PM »
Specifically, Pokemon resets the date and time to 2001-01-01, 00:00 at the start of a new game, then it never touches the RTC again. Other than resetting it, the RTC can never be changed in Pokemon, and the game just saves an offset used to calculate game time from the RTC's time. This means that it will mess up the RTC for any other game when you do this. And it also means that Pokemon's time will always be off if the RTC is then changed by another game.
The solution is to set the wall clock in Pokemon at the start of the game to a few minutes after midnight (depending on how long the intro takes for you) to make the time offset as close to 0 as possible. Then the RTC can be set in Boktai to real time, without the time being too much off in Pokemon. You need to do this every time you start a new game in any of the Pokemon games.

You don't have to set the date to present day real time in Boktai, but you should at least set it to a date after 2002-01-02. Doing this stops the berry glitch from happening.


Boktai is only used because it's a game that allows you to set the RTC time manually. There may be other games that can do it too, but just remember that Pokemon can't.


If you have already started a game in Pokemon and don't want to start over again, I suppose the only solution is to figure out where the time offset is stored in the save file and changing it to 0 manually, and recalculate the checksum.

it seems like something no one has figured out how to make a RTC function that wont drain the battery in the device that runs it. I avoid my GB X7 for that exact reason.
Fully mechanical geared clocks have been around a 1000 years. But I it might be hard to fit one in an Everdrive. And you would need to fit a slot for a key to wind up the spring.
« Last Edit: October 17, 2020, 11:03 PM by nuu »

Offline dav3yb

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #4 on: October 17, 2020, 11:07 PM »
Specifically, Pokemon resets the date and time to 2001-01-01, 00:00 at the start of a new game, then it never touches the RTC again. Other than resetting it, the RTC can never be changed in Pokemon, and the game just saves an offset used to calculate game time from the RTC's time. This means that it will mess up the RTC for any other game when you do this. And it also means that Pokemon's time will always be off if the RTC is then changed by another game.
The solution is to set the wall clock in Pokemon at the start of the game to a few minutes after midnight (depending on how long the intro takes for you) to make the time offset as close to 0 as possible. Then the RTC can be set in Bokutai to real time, without the time being too much off in Pokemon. You need to do this every time you start a new game in any of the Pokemon games.

You don't have to set the date to present day real time in Bokutai, but you should at least set it to a date after 2002-01-02. Doing this stops the berry glitch from happening.


Bokutai is only used because it's a game that allows you to set the RTC time manually. There may be other games that can do it too, but just remember that Pokemon can't.


If you have already started a game in Pokemon and don't want to start over again, I suppose the only solution is to figure out where the time offset is stored in the save file and changing it to 0 manually, and recalculate the checksum.

What i did so far (on the everdrive) was start a new pokemon emerald game, then go into boktai and set the date to current, but i didn't touch the time at all, since I wanted the time in emerald to at least stay accurate.  From all the other reading I did I kind of gathered that setting the time in a new game would then update the time in other games, but mainly by offsetting it?  So by not actually adjusting the time in boktai, it kept my accurate time in Emerald.  Seems like the best way to sync up the times all around would be to just wait for the default time in Boktai on any given day that you set it? 

It just feels a bit convoluted to me at the moment. 

Offline nuu

  • Hero Member
  • *****
  • Posts: 1586
  • Karma: +74/-2
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #5 on: October 17, 2020, 11:26 PM »
It is convoluted, I had trouble understanding it the first time I heard it.
Anyway, no you don't have to wait for real time to be anything in particular. If I understand it correctly you should just set the time to 00:05 or something in Emerald, regardless what the real time is. 00:05 is in case the intro up to the point that you set the wall clock in emerald took you about 5 minutes for you to go through. If you think it took 10 minutes, set it to 00:10 and so on (if you mess up, just reset and start a new game again). Then continue the game until you can save. After saving you can start Boktai and set the RTC to real time or whatever you want and it should be correct in Emerald as well.

The point is that if Emerald's time offset is 0, time in Emerald will be whatever the RTC is set to. Making it exactly 0 is probably hard to do, unless you hack the save file, but a few minutes off might not be a big deal.

Offline dav3yb

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #6 on: October 17, 2020, 11:51 PM »
It is convoluted, I had trouble understanding it the first time I heard it.
Anyway, no you don't have to wait for real time to be anything in particular. If I understand it correctly you should just set the time to 00:05 or something in Emerald, regardless what the real time is. 00:05 is in case the intro up to the point that you set the wall clock in emerald took you about 5 minutes for you to go through. If you think it took 10 minutes, set it to 00:10 and so on (if you mess up, just reset and start a new game again). Then continue the game until you can save. After saving you can start Boktai and set the RTC to real time or whatever you want and it should be correct in Emerald as well.

The point is that if Emerald's time offset is 0, time in Emerald will be whatever the RTC is set to. Making it exactly 0 is probably hard to do, unless you hack the save file, but a few minutes off might not be a big deal.

Ok, after playing around a bit, i think i made myself even more confused.  I deleted the save file for Boktai, and when I went back in and adjusted it to the correct date/time, the time jumped in emerald, that makes sense to me.

I started a new game in emerald, set the clock to a couple minutes past midnight, but then going back into boktai, the date and time are current.  So that would lead me to think I could just set the date/time in boktai, then start a new game in Pokemon and it'll be normal? 

Offline nuu

  • Hero Member
  • *****
  • Posts: 1586
  • Karma: +74/-2
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #7 on: October 18, 2020, 02:24 AM »
Date and time is still current? I thought starting a new game in Emerald would reset it to 2001-01-01, 00:00.

Anyway if what I've been saying is correct you should already be fine now when you have started a game in Emerald and set time a little past midnight in it. The time offset in Emerald's save file should be close to zero now. You can change the RTC to anything you want, using Boktai, and the time in Emerald should still match the new time.

Offline dav3yb

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #8 on: October 18, 2020, 02:33 AM »
Date and time is still current? I thought starting a new game in Emerald would reset it to 2001-01-01, 00:00.

Anyway if what I've been saying is correct you should already be fine now when you have started a game in Emerald and set time a little past midnight in it. The time offset in Emerald's save file should be close to zero now. You can change the RTC to anything you want, using Boktai, and the time in Emerald should still match the new time.

Hmm... yeah, just went back to check Boktai, and in the options, it's set to nearly the exact time as current.  Thinking that it might be best for a fresh Everdrive, going into boktai to set date and time first, then starting any pokemon game will work just fine.  Maybe starting a game in Ruby or Sapphire would alter the time in Boktai, but since they're all using the same shared clock, and since it's powered, I would assume it wouldn't really change anything.  Could be wrong, but I think i'll give it a shot. 

Offline dav3yb

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #9 on: October 18, 2020, 02:44 AM »
Update!

Yeah, Ruby and Sapphire seem to create a new RTC file (so to speak), but I guess Emerald doesn't.  After stating a new game on Sapphire, Boktai read 1/1/2000, time 00:02 AM. 

I set the time correctly in Boktai, and that did alter the time to be incorrect on Sapphire, but I guess since I originally set it first in Boktai, THEN made the Emerald save, it just used the time it was reading, instead of resetting the RTC.  I'm guessing this might partially be how the Berry glitch was fixed?  Idk, but it's certainly interesting. 

So when starting new games on Ruby or Sapphire, it's good to set the clock to 2 or 3 minutes past midnight, then correcting the clock in Boktai.  Good to know. 

Offline nuu

  • Hero Member
  • *****
  • Posts: 1586
  • Karma: +74/-2
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #10 on: October 18, 2020, 02:52 PM »
So Emerald is special while Ruby and Sapphire works as described above. Thanks for confirming this.

I have no idea how Emerald works, but I guess it's possible it just uses the actual time value recorded in the RTC, just like Boktai. But if that was the case, it shouldn't mess up Boktai. If you change the RTC in Boktai, Emerald should change accordingly as well.
Is it possible to change the time again in Emerald after the first time in the intro, like you can in Boktai?

The berry glitch happens because of a bug that prevents the game from counting days correctly the second year (when the RTC says year 2001). When the date is 2002-01-02, the game should count days correctly again and berries and other time events should work like normal again.
Emerald was made after this bug was discovered and naturally doesn't have it. The Ruby and Sapphire are "patched" when linking to Emerald, FireRed, LeafGreen, the Gamecube Pokemon games or when using certain e-cards. The patch simply forwards the RTC date by 366 days if the glitch hasn't happened or sets it to 2002-01-02 if it has. If you start a new game the patch will of course be needed to be applied again since the RTC is reset to 2000-01-01. Setting the RTC date to 2002-01-02 or later in Boktai should be an easy way to fix it in an Everdrive.

Offline dav3yb

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #11 on: October 18, 2020, 03:59 PM »
So Emerald is special while Ruby and Sapphire works as described above. Thanks for confirming this.

I have no idea how Emerald works, but I guess it's possible it just uses the actual time value recorded in the RTC, just like Boktai. But if that was the case, it shouldn't mess up Boktai. If you change the RTC in Boktai, Emerald should change accordingly as well.
Is it possible to change the time again in Emerald after the first time in the intro, like you can in Boktai?

The berry glitch happens because of a bug that prevents the game from counting days correctly the second year (when the RTC says year 2001). When the date is 2002-01-02, the game should count days correctly again and berries and other time events should work like normal again.
Emerald was made after this bug was discovered and naturally doesn't have it. The Ruby and Sapphire are "patched" when linking to Emerald, FireRed, LeafGreen, the Gamecube Pokemon games or when using certain e-cards. The patch simply forwards the RTC date by 366 days if the glitch hasn't happened or sets it to 2002-01-02 if it has. If you start a new game the patch will of course be needed to be applied again since the RTC is reset to 2000-01-01. Setting the RTC date to 2002-01-02 or later in Boktai should be an easy way to fix it in an Everdrive.

Yeah, from my messings around with it, changing time in Boktai will change the time in emerald as well.  As far as I know, outside of maybe a patched ROM that allows you to change the clock again, it's set the first time and you can't change it again.  I know for my older Gameboy ED I had to patch Crystal to allow the clock to be set each time it was loaded or most things wouldn't work at all.

I'm also not completely sure exactly how they changed Berries in emerald, if at all.  I know yesterday while messing with it, I planed some, and waited a few hours for them to sprout.  Then going back into boktai and correcting the time (it was set forward a few hours) made the berries no longer be sprouted.  There's certainly still some kind of counting going on for it, and I think that's why my physical copy of emerald won't grow any berries, it probably has a day count somewhere in the save file as well, and since all that was reset when the battery dried out, even replacing it won't help since some value doesn't match. 

So knowing all this now, probably whenever the battery needs replacing on the everdrive, just going to set the correct time in boktai should set everything back to normal, assuming you took the steps to set everything correctly as needed (R/S starting w/ the offset and correcting the time later). 

Doesn't the Gameboy ED X7 have a menu option for changing the RTC btw?  Any idea if doing that would be possible for the EDGBA?
« Last Edit: October 18, 2020, 04:09 PM by dav3yb »

Offline nuu

  • Hero Member
  • *****
  • Posts: 1586
  • Karma: +74/-2
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #12 on: October 18, 2020, 05:17 PM »
Yeah, from my messings around with it, changing time in Boktai will change the time in emerald as well.
This is given. Any game that uses the RTC would be affected by RTC changes, or there would be no point of it having an RTC.


I'm also not completely sure exactly how they changed Berries in emerald, if at all.  I know yesterday while messing with it, I planed some, and waited a few hours for them to sprout.  Then going back into boktai and correcting the time (it was set forward a few hours) made the berries no longer be sprouted.  There's certainly still some kind of counting going on for it, and I think that's why my physical copy of emerald won't grow any berries, it probably has a day count somewhere in the save file as well, and since all that was reset when the battery dried out, even replacing it won't help since some value doesn't match.

So knowing all this now, probably whenever the battery needs replacing on the everdrive, just going to set the correct time in boktai should set everything back to normal, assuming you took the steps to set everything correctly as needed (R/S starting w/ the offset and correcting the time later).
Yes maybe your Emerald cart has problems because the RTC reset to its default value when you changed the battery, and the game went "back in time". It's not a problem on the Everdrive where you can easily change the RTC setting using Boktai.

It seems to be the same problem described here:
https://github.com/megaboyexe/GBA_RTCRead
Quote
Basically, the game stores a timestamp from when you last saved the game, and only performs its clock-based tasks if the current time is higher. Whether this is intentional is anyone's guess.

Because the RTC's value is reset to 2000-01-01 00:00:00 when the battery dies, it will always be lower than the save file timestamp when you replace the battery.
In other words, your berries won't grow and the day counter is frozen until the RTC catches up to the timestamp in the save file. It's a separate glitch from the "berry glitch", and unlike that one, it seems to affect Emerald as well as confirmed by you.
It's also described on the berry glitch page on Bulbapedia.
https://bulbapedia.bulbagarden.net/wiki/Berry_glitch#Replaced_battery


You can change the RTC on your Emerald cart starting the above tool on your Everdrive, and hotswap it with the Emerald cart, then set it to a date that is later than the timestamp in the save file.

Offline dav3yb

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #13 on: October 21, 2020, 05:21 AM »
Yeah, from my messings around with it, changing time in Boktai will change the time in emerald as well.
This is given. Any game that uses the RTC would be affected by RTC changes, or there would be no point of it having an RTC.


I'm also not completely sure exactly how they changed Berries in emerald, if at all.  I know yesterday while messing with it, I planed some, and waited a few hours for them to sprout.  Then going back into boktai and correcting the time (it was set forward a few hours) made the berries no longer be sprouted.  There's certainly still some kind of counting going on for it, and I think that's why my physical copy of emerald won't grow any berries, it probably has a day count somewhere in the save file as well, and since all that was reset when the battery dried out, even replacing it won't help since some value doesn't match.

So knowing all this now, probably whenever the battery needs replacing on the everdrive, just going to set the correct time in boktai should set everything back to normal, assuming you took the steps to set everything correctly as needed (R/S starting w/ the offset and correcting the time later).
Yes maybe your Emerald cart has problems because the RTC reset to its default value when you changed the battery, and the game went "back in time". It's not a problem on the Everdrive where you can easily change the RTC setting using Boktai.

It seems to be the same problem described here:
https://github.com/megaboyexe/GBA_RTCRead
Quote
Basically, the game stores a timestamp from when you last saved the game, and only performs its clock-based tasks if the current time is higher. Whether this is intentional is anyone's guess.

Because the RTC's value is reset to 2000-01-01 00:00:00 when the battery dies, it will always be lower than the save file timestamp when you replace the battery.
In other words, your berries won't grow and the day counter is frozen until the RTC catches up to the timestamp in the save file. It's a separate glitch from the "berry glitch", and unlike that one, it seems to affect Emerald as well as confirmed by you.
It's also described on the berry glitch page on Bulbapedia.
https://bulbapedia.bulbagarden.net/wiki/Berry_glitch#Replaced_battery


You can change the RTC on your Emerald cart starting the above tool on your Everdrive, and hotswap it with the Emerald cart, then set it to a date that is later than the timestamp in the save file.

Awesome.  I got my DS flashcart in today, and loaded up the homebrew app.  Got my emerald updated to the correct date/time, so we'll see if I can grow some berries.  The only thing in the app I was slightly confused by was a "wkd:" field, which numbered... 0 to 6.  I'm guessing this is which weekday you're on, but not really knowing where the count is intended to start, I treated Sunday as 0, and set it to day 2.  Just have to wait now to see if things will grow. 

Quite a journey this whole thing was, that's for sure.  Thanks for all the help.  Glad I could also contribute some information to all of this. 

Offline nuu

  • Hero Member
  • *****
  • Posts: 1586
  • Karma: +74/-2
    • View Profile
Re: EDGBA X5 Battery/RTC Questions
« Reply #14 on: October 21, 2020, 05:32 PM »
This thread will be of great assistance to anyone looking for this information, I'm sure. It should almost be stickied.
Thanks for confirming what has been said. I haven't tried any of this myself yet. Everything I said is from what other people told me, and some guesswork.

Wkd 0-6 must be weekday, but there is no way to know if it starts with monday or sunday. I found the datasheet for the S-3511 RTC chip that Pokemon seems to be using:
https://pdf1.alldatasheet.com/datasheet-pdf/view/80559/SII/S-3511.html
It just says the day of the week is stored as a number 0-6. I searched the internet a bit for various RTC chips, and they always seems to use 0 as sunday, so I think it's somewhat safe to assume this one does as well.
It's also quite possible that Pokemon never reads this value, since it just counts days. Years, months and day of the month should be enough to do that.


Some more good information here (from those RTC app links above):
Quote
Technical Info
The game saves a 5-byte timestamp at 0x00A0 (DDHMS - 16-bit/2 byte for days, 1 byte each for the others). It seems that if the RTC (+/- the offset however that is stored at 0x0098) is lower than this timestamp then the in-game timer based events (berries, item-dispenser NPCs, lottery, etc) will not be updated.
So if anyone wants to manually adjust the offset (don't touch the timestamp) in the save file it should be at 0x0098. Setting it to zero should be enough to make Pokemon follow the Everdrive's RTC time exactly, if my theory is right. There might be a CRC that must be recalculated and updated too if any changes to the save file are made though, or the game might detect that the save file has been tampered with and erase it. But I can't find any information about it.
« Last Edit: October 21, 2020, 05:39 PM by nuu »