MiSTer-devel / GBA_MiSTer

GBA for MiSTer
GNU General Public License v2.0
147 stars 44 forks source link

RTC not working with another Pokémon rom back, Unbound #147

Closed hotcereal closed 5 months ago

hotcereal commented 5 months ago

Unbound is one of the most popular ronhacks for the GBA, but it seems to have never had this problem reported and solved.

In the game, whenever you start the game is in-game listed as Jan 1, 2000 at 12:00 AM.

RTC module has a fresh battery, resetting the time via hwckock -wu or running the rtc.sh script shows that the module is working fine otherwise.

The GPIO setting for RTC + Rumble is turned on. Ironically, the feature seems to have been reported for another Pokémon romhack and someone does mention Unbound in that thread, but never posts again. https://github.com/MiSTer-devel/GBA_MiSTer/issues/105

Turning the GPIO setting off results in the RTC being reported as not working in-game. Turning it on results in the game warning each time about “RTC tampering” and therefore loses some of the game’s features. The above details what the game sees time-wise. Jan 1, 2000 and 12:00AM starting at whatever point you loaded the game in the core.

hotcereal commented 5 months ago

There is a fix for this. As reported in #105, the problem is the unique ID that Unbound uses as reported below:

The reason is most likely that the game is not in the RTC list. As it is written in the readme, only some games are supported for RTC. "If there is a game you want to play that also uses one of these features, but is not listed, please open a bug request."

The reason is simple: i cannot activate RTC for all games, because it overwrites some part of the ROM, which would break normal games. So we either must have a RTC recognition(which we don't have as this is very difficult in FPGA) or a whitelist.

You can find the whitelist in code here(gpio_quirk): https://github.com/MiSTer-devel/GBA_MiSTer/blob/master/GBA.sv#L686-L700

As I don't have this romhack, you must help at this point. Please open the ROM with a hexeditor and look at address A0 for the name, so it can be added to the list.

It looks like this for Pokemon Emerald: poke_eme

Best would be if you can also make a screenshot and show here.

Warning: if they use the same code as normal Pokemon Red, this method cannot work, as it would break normal Pokemon Red. In this case we have to think what else can be done. But please look first.

Thanks!

This is also a problem on the DS/DSi and is fixed with this tool here: https://wiki.ds-homebrew.com/gbarunner2/faq?faq=why-isnt-rtc-real-time-clock-supported-in-a-rom-hack

Expand the "Why isn’t RTC (Real Time Clock) supported in a ROM hack?" section to see an area to drag and drop/find your .gba file. Do that and it should autogenerate "BPRE" (the game ID for Fire Red). Hit Save, replace this new one with the one you had before, boot up the GBA core on your MiSTer and make sure the GPIO setting is on. The game should load normally now with a functional RTC.

This goes for any games not on the list. Load up the .gba on that same site, and patch it with the generated game ID (so long as it's one of the ones that supports RTC in the MiSTer core.)

As a final parting, Robert, I do wish you the best on your future developments. The legacy you've created within the MiSTer community is not one that will be forgotten. We all benefit from your contributions and passion. Hopefully whoever decides to carry on this core from here can mimic a single iota of what you've given us.

RobertPeip commented 5 months ago

thank you for reporting back. Do you think we can close this issue with that or is there anything to do?

hotcereal commented 5 months ago

It can be closed! Issue has an easy enough fix that answers my needs.

hotcereal commented 5 months ago

I hate to be this person, but the above fix I posted actually does not work. I'm unsure of what the problem could be or is, but mu multiple attempts result in different issues that prevent it from working.

Homebrew BIOS [On], Game patched through above site (GPTAS) with TitleID BPRE = RTC Tampering found in save file, time in-game is Sat 12:00AM Homebrew BIOS [Off], GPTAS with TitleID BPRE = RTC Tampering found in save file, time in-game is Sat 12:00AM Homebrew BIOS [On], GPTAS with TitleID APXJ = RTC Tampering found in save file, time in-game is Sat 12:00AM Homebrew BIOS [Off], GPTAS with TitleID APXJ = Game freezes at the end of the GBA logo/BIOS intro

Disabling the GPIO Hack setting produces a different in-game error warning that RTC time cannot be read.

I'm unsure what I was doing to think it had worked before or what setting I had altered, but every which way I try now, an error or problem is produced.

OngoGablogian commented 4 months ago

I've also been having some issues with the "GPIO HACK(RTC+Rumble)" toggle. Previously it was working fine with Pokemon FireRed based ROM hacks (Unbound, Radical Red, etc.), but now I can't seem to get the RTC working with this setting enabled.

The in-game time seems to be defaulting to 1/1/2010 at 12:00AM every time the core boots. I've tried editing the header to use the Pokemon Emerald Title ID, but the time is unaffected by this change. I haven't noticed any issues with the RTC in Pokemon Emerald or any Emerald based ROM hacks.

I've also tried reverting back to older versions of the GBA core and the MiSTer firmware without success.

EDIT: I just figured out a way around this issue. If you use the GBA homebrew RTCRead, you can set the time in the core and it seems to persist after rebooting the MiSTer and loading different games.

Dobcool commented 2 months ago

I've also been having some issues with the "GPIO HACK(RTC+Rumble)" toggle. Previously it was working fine with Pokemon FireRed based ROM hacks (Unbound, Radical Red, etc.), but now I can't seem to get the RTC working with this setting enabled.

The in-game time seems to be defaulting to 1/1/2010 at 12:00AM every time the core boots. I've tried editing the header to use the Pokemon Emerald Title ID, but the time is unaffected by this change. I haven't noticed any issues with the RTC in Pokemon Emerald or any Emerald based ROM hacks.

I've also tried reverting back to older versions of the GBA core and the MiSTer firmware without success.

EDIT: I just figured out a way around this issue. If you use the GBA homebrew RTCRead, you can set the time in the core and it seems to persist after rebooting the MiSTer and loading different games.

I've found that no matter what I press in RTCRead when editing the date and time, the selected field changes, but the date and time incriments never increase or decrease no matter what I press. This was the case when running the program in VBA-M and on my Analogue Pocket (which is what I'm trying to get the RTC working for Unbound so I can run the ROM on there properly in the first place). It won't even let me get to that screen when using m-GBA as there is an apparent battery issue! My question to you is how did you manage to edit the date and time using this RTCRead program? (it's not a button mapping issue)

OngoGablogian commented 2 months ago

Make sure the "GPIO HACK(RTC+Rumble)" option is enabled when setting the time with RTCRead.

Colton-Tux commented 2 months ago

RTCRead worked for me. For anyone who might be confused I downloaded the RTCRead from here https://web.archive.org/web/20180811045454/http://furlocks-forest.net/wiki/uploadedfiles/rtcread.zip and unzipped for the .gba file. Loaded that gba file in the MiSTer gba core, set the date/time (Ignore the whole load the game part) and then I just loaded the unbound game and it showed the correct rtc time. Seems like setting it saved the time to the core itself.

hotcereal commented 2 months ago

For me, this only seems to work the one time. If I load up RTCRead, set the time, then go to a game, change the game etc, it will hgave the correct time.

But restarting the MiSTer and choosing the same game resets the clock back to 01/01/2000 at 12:00.

On Sep 23, 2024, at 6:19 PM, Colton-Tux @.***> wrote:

RTCRead worked for me. For anyone who might be confused I downloaded the RTCRead from here https://web.archive.org/web/20180811045454/http://furlocks-forest.net/wiki/uploadedfiles/rtcread.zip and unzipped for the .gba file. Loaded that gba file in the MiSTer gba core, set the date/time (Ignore the whole load the game part) and then I just loaded the unbound game and it showed the correct rtc time. Seems like setting it saved the time to the core itself.

— Reply to this email directly, view it on GitHub https://github.com/MiSTer-devel/GBA_MiSTer/issues/147#issuecomment-2369625376, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2ZD4ROBJPUA4NTD5E4LI3ZYCHV3AVCNFSM6AAAAABI7TSW5CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRZGYZDKMZXGY. You are receiving this because you authored the thread.

BuckTennington commented 2 months ago

@hotcereal Same issue for me after a Mister reboot. RTCreader has to be set after each Mister reboot.

Dobcool commented 2 months ago

RTCRead worked for me. For anyone who might be confused I downloaded the RTCRead from here https://web.archive.org/web/20180811045454/http://furlocks-forest.net/wiki/uploadedfiles/rtcread.zip and unzipped for the .gba file. Loaded that gba file in the MiSTer gba core, set the date/time (Ignore the whole load the game part) and then I just loaded the unbound game and it showed the correct rtc time. Seems like setting it saved the time to the core itself.

For this did you have "GPIO HACK(RTC+Rumble)" enabled because I still can only select the fields and cannot change the increments no matter what buttons I press. It just stays at 00/00/2000 wkday:0 00:00:00. If you managed to change this without the "GPIO HACK(RTC+Rumble)" thing enabled then let me know how you did it. Also, I'll kinda be exposing my own ignorance and stupidity here, but I'm not exactly sure what "GPIO HACK(RTC+Rumble)" even is, let alone how to enable/disable it. I think I'm probably coming at this the wrong way in the first place as I'm using the Spiritualized GBA core (as I'm trying to get this to work on my Analogue pocket) and I'm testing it on the VBA-M emulator so perhaps I'm just completely barking up the wrong tree here. I'm wondering if I can somehow get the MiSTer gba core running on my Analogue pocket because that core appears to be a prelude to all these fixes. Unfortunately that seems impossible and I don't know how the settings would be properly adjusted in that case anyway, even if it were possible. You'll have to be lenient with me, sorry.

BuckTennington commented 2 months ago

@Dobcool The Spirtualized open FPGA core does not support RTC. However, there is someone in the Pocket community developing a GBA core that might support RTC.

Also, you can't port the Spirtualized core to Mister, the source code is not available.

Dobcool commented 2 months ago

@Dobcool The Spirtualized open FPGA core does not support RTC. However, there is someone in the Pocket community developing a GBA core that might support RTC.

Also, you can't port the Spirtualized core to Mister, the source code is not available.

Yeah, sorry. I misunderstood the aim of this thread. I thought that aim of this thread was to find methods to get RTC support working manually on cores that would otherwise not support RTC. I now see that it's a thread detailing methods on how to resolve specific RTC issues with cores that already support RTC. I suppose I'll have to wait for budude2's GBA core to release and then find a way for the RTC support to extend to Pokemon Unbound. Hopefully it will do that automatically when the time comes...

BuckTennington commented 2 months ago

@Dobcool No worries! I'm happy there's a dialogue, I want to see this issue resolved.

I'm glad that you mentioned Budude2 because I'd like him to know about this issue. It will surely come up when he releases his core. Unfortunately I don't know the best method to bring this to his attention.

Dobcool commented 2 months ago

@Dobcool No worries! I'm happy there's a dialogue, I want to see this issue resolved.

I'm glad that you mentioned Budude2 because I'd like him to know about this issue. It will surely come up when he releases his core. Unfortunately I don't know the best method to bring this to his attention.

Oh, I'm sure he already knows about it. That's why I brought him up because he did make the GBC core that does have RTC support for the Analogue pocket.

BuckTennington commented 2 months ago

I've also been having some issues with the "GPIO HACK(RTC+Rumble)" toggle. Previously it was working fine with Pokemon FireRed based ROM hacks (Unbound, Radical Red, etc.), but now I can't seem to get the RTC working with this setting enabled.

The in-game time seems to be defaulting to 1/1/2010 at 12:00AM every time the core boots. I've tried editing the header to use the Pokemon Emerald Title ID, but the time is unaffected by this change. I haven't noticed any issues with the RTC in Pokemon Emerald or any Emerald based ROM hacks.

I've also tried reverting back to older versions of the GBA core and the MiSTer firmware without success.

EDIT: I just figured out a way around this issue. If you use the GBA homebrew RTCRead, you can set the time in the core and it seems to persist after rebooting the MiSTer and loading different games.

RTC in the rom hack is fine after the inital RTCRead setup. The problem occurs after rebooting the MiSTer. RTC is not persistent and accelerates very rapidly (i.e., like 10 times faster than a real clock). It's interesting that you and @Colton-Tux are not experiencing this.

Colton-Tux commented 2 months ago

I've also been having some issues with the "GPIO HACK(RTC+Rumble)" toggle. Previously it was working fine with Pokemon FireRed based ROM hacks (Unbound, Radical Red, etc.), but now I can't seem to get the RTC working with this setting enabled. The in-game time seems to be defaulting to 1/1/2010 at 12:00AM every time the core boots. I've tried editing the header to use the Pokemon Emerald Title ID, but the time is unaffected by this change. I haven't noticed any issues with the RTC in Pokemon Emerald or any Emerald based ROM hacks. I've also tried reverting back to older versions of the GBA core and the MiSTer firmware without success. EDIT: I just figured out a way around this issue. If you use the GBA homebrew RTCRead, you can set the time in the core and it seems to persist after rebooting the MiSTer and loading different games.

RTC in the rom hack is fine after the inital RTCRead setup. The problem occurs after rebooting the MiSTer. RTC is not persistent and accelerates very rapidly (i.e., like 10 times faster than a real clock). It's interesting that you and @Colton-Tux are not experiencing this.

I have not checked if the clock runs fast, I simply tested if it worked as an inconvenient fix. I can confirm that process does need to be repeated on each reboot. Also, yes I did have the GPIO HACK(RTC+Rumble) enabled in the cores miscellaneous settings.

Colton-Tux commented 2 months ago

Ideally, I think that there should be an option to "Force RTC" in the core that would perform the same process that opening and running RTCRead is doing automatically using the current system clock

Dobcool commented 2 months ago

Ideally, I think that there should be an option to "Force RTC" in the core that would perform the same process that opening and running RTCRead is doing automatically using the current system clock

Yes, this is initially what I thought the program RTCRead would do thus allowing RTC to function on cores that don't currently have RTC support. This turned out to not be the case.

Colton-Tux commented 2 months ago

Can confirm after letting the game run for several hours that there is no noticeable drift in the in game clock relative to actual time.

Colton-Tux commented 2 months ago

Ideally, I think that there should be an option to "Force RTC" in the core that would perform the same process that opening and running RTCRead is doing automatically using the current system clock

Yes, this is initially what I thought the program RTCRead would do thus allowing RTC to function on cores that don't currently have RTC support. This turned out to not be the case.

I mean, I can't see why this couldn't be automated into the boot process of the GBA core. I doubt it works for other systems but as long as the core is for GBA then it should be implementable.