rileytestut / Delta

Delta is an all-in-one classic video game emulator for non-jailbroken iOS devices.
4.53k stars 334 forks source link

GBA Real time clock not functioning #5

Closed Ayukito closed 3 years ago

Ayukito commented 4 years ago

I play a lot of Pokemon rom hacks and those that use RTC for day/night and time-specific spawn tables are unplayable. It defaults to 12:00:00 and will stay there. Patching roms for using a RTC do not fix this issue. They worked fine in GBA4iOS 2.0

bc9 commented 3 years ago

still having this issue with the latest alpha (1.2a6)

ericlewis commented 3 years ago

@Ayukito @bc9 which specific game and how do you reproduce?

jschoeny commented 3 years ago

@ericlewis I can reproduce the bug by running the Pokémon RadicalRed gba hack. After going past the title screen with no save, it gives the following message:

“WARNING! The correct system time could not be read. Enable the Real Time Clock (RTC), and make sure the time is correct.”

Ayukito commented 3 years ago

@Ayukito @bc9 which specific game and how do you reproduce?

The game/rom hack you can easily test this in is Pokemon Red Chapter, if you play to the point where you have free control and can open the menu, you have a label in it telling you the current time. On Delta, this will always be 12:00:00. On GBA4iOS, this will function properly.

I assume this is simply the gba core only enabling rtc for certain games and not all games, as Pokemon Emerald's clock worked properly at the time of creating this issue.

J-Mazer commented 3 years ago

This same issue has happened to me on Pokemon Unbound, which limits certain features of the game. There are areas you can only access at certain times of day, and with the time being stuck at 12:00:00, those places are inaccessible.

Godis1coolguy commented 3 years ago

It’s weird, because the issue isn’t present in GBA4IOS. Is there a fix planned? How is Delta and GBA4IOS handling the real time clock differently?

Godis1coolguy commented 3 years ago

@Ayukito @bc9 which specific game and how do you reproduce?

From what I can gather, this will apply to any rom hack built on top of Fire Red, which didn’t natively have a real time clock. The real time clock functionality is working for these games in GBA4IOS and though.

jschoeny commented 3 years ago

I was able to get it working for Radical Red by changing line 804 in GBADeltaCore -> libVBA-M -> VBA-M -> Util.cpp:

I changed rtcEnable(rtcFound); to rtcEnable(true);

I haven’t done a full-fledged test to make sure everything is working, but Radical Red at least no longer gives the RTC warning.

J-Mazer commented 3 years ago

I was able to get it working for Radical Red by changing line 804 in GBADeltaCore -> libVBA-M -> VBA-M -> Util.cpp:

I changed rtcEnable(rtcFound); to rtcEnable(true);

I haven’t done a full-fledged test to make sure everything is working, but Radical Red at least no longer gives the RTC warning.

How would I go about doing that myself? Is editing the core a beta-only feature?

JamesPeters98 commented 3 years ago

Yep I just tried to play the Pokemon Unbound rom hack and it pops up with this error instantly asking about RTC.image

Ayukito commented 3 years ago

I was able to get it working for Radical Red by changing line 804 in GBADeltaCore -> libVBA-M -> VBA-M -> Util.cpp:

I changed rtcEnable(rtcFound); to rtcEnable(true);

I haven’t done a full-fledged test to make sure everything is working, but Radical Red at least no longer gives the RTC warning.

Could be on to something. I wonder if this line could be changed permanently without negatively effecting other games.

Reading through that code, it seems that whether a rom uses RTC is identified the same way the save type is, and something that rom hack makers should be changing -thing is, I could’ve sworn I manually patched roms using save patchers to enable Rtc in the past and it didn’t work. I’ll follow up and see if that actually does work tomorrow.

A simple alternative to all of this though, is to have a master switch on RTC by changing the mentioned line of code (if on, force on. If off, respect game’s choice). I wouldn’t expect the average user to patch their roms to turn on RTC.

jschoeny commented 3 years ago

Could be on to something. I wonder if this line could be changed permanently without negatively effecting other games.

Reading through that code, it seems that whether a rom uses RTC is identified the same way the save type is, and something that rom hack makers should be changing -thing is, I could’ve sworn I manually patched roms using save patchers to enable Rtc in the past and it didn’t work. I’ll follow up and see if that actually does work tomorrow.

A simple alternative to all of this though, is to have a master switch on RTC by changing the mentioned line of code (if on, force on. If off, respect game’s choice). I wouldn’t expect the average user to patch their roms to turn on RTC.

Yeah, I noticed GBA4iOS uses the same method with a comment stating:

Some hacked games use the RealTimeClock even when the game they're based off of doesn't (ex: Pokemon Liquid Crystal), so we always have it enabled.

There doesn't appear to be any effect on games that don't normally use the RTC. If there is, then I suppose there could be an option per game to force enable RTC.

Ayukito commented 3 years ago

I was able to get it working for Radical Red by changing line 804 in GBADeltaCore -> libVBA-M -> VBA-M -> Util.cpp: I changed rtcEnable(rtcFound); to rtcEnable(true); I haven’t done a full-fledged test to make sure everything is working, but Radical Red at least no longer gives the RTC warning.

Could be on to something. I wonder if this line could be changed permanently without negatively effecting other games.

Reading through that code, it seems that whether a rom uses RTC is identified the same way the save type is, and something that rom hack makers should be changing -thing is, I could’ve sworn I manually patched roms using save patchers to enable Rtc in the past and it didn’t work. I’ll follow up and see if that actually does work tomorrow.

A simple alternative to all of this though, is to have a master switch on RTC by changing the mentioned line of code (if on, force on. If off, respect game’s choice). I wouldn’t expect the average user to patch their roms to turn on RTC.

So after a bit of tinkering, it seems that there is no simple tool to use to patch a gba rom and enable RTC, most "rtc fixes" are game/hack specific therefore not really useful here.

To begin with it would be unreasonable to expect users to manually patch RTC anyways.

BuMmR88 commented 3 years ago

I was able to get it working for Radical Red by changing line 804 in GBADeltaCore -> libVBA-M -> VBA-M -> Util.cpp:

I changed rtcEnable(rtcFound); to rtcEnable(true);

I haven’t done a full-fledged test to make sure everything is working, but Radical Red at least no longer gives the RTC warning.

@jschoeny Could you elaborate on how you were able to do this? I searched for the file Util.cpp and was unable to find anything.

jschoeny commented 3 years ago

On Xcode, the path is as listed above, but on Github and in the file browser, the path is GBADeltaCore -> visualboyadvance-m -> src -> Util.cpp, so it's really located within the visualboyadvance-m repository.

I actually just tried running Radical Red in visualboyadvance-m on a Mac and had the exact same problem, so it appears to be an issue with the vba-m core, not necessarily Delta

BuMmR88 commented 3 years ago

On Xcode, the path is as listed above, but on Github and in the file browser, the path is GBADeltaCore -> visualboyadvance-m -> src -> Util.cpp, so it's really located within the visualboyadvance-m repository.

I actually just tried running Radical Red in visualboyadvance-m on a Mac and had the exact same problem, so it appears to be an issue with the vba-m core, not necessarily Delta

So you're playing on Mac? I am trying to play on iOS iPhone, and I don't think that file is there.

jschoeny commented 3 years ago

When I got the RTC working, I was doing that for iOS. I just did a quick test just now to check whether the underlying issue was Delta or the vba-m core. Making the change as I described above will fix the issue for iOS.

BuMmR88 commented 3 years ago

I don’t have that file to even modify it, can you do a video walkthrough or anything?

Ayukito commented 3 years ago

I don’t have that file to even modify it, can you do a video walkthrough or anything?

You’re not going to find this file in the app’s file system with Filza. You’ll need to build the app from Xcode after changing the line here. https://github.com/visualboyadvance-m/visualboyadvance-m/blob/1b6d9557a24703666eb8fa2253746ddda630bf26/src/Util.cpp#L869

hdwatts commented 3 years ago

@rileytestut seeing as how there is a new Delta build being released soon, curious if you have taken a peek at any of the comments above which resolve this issue. I'll note modified games have started to warn against using Delta (see below). It would be great to get this fixed officially!

image

Ayukito commented 3 years ago

@rileytestut seeing as how there is a new Delta build being released soon, curious if you have taken a peek at any of the comments above which resolve this issue. I'll note modified games have started to warn against using Delta (see below). It would be great to get this fixed officially!

image

I believe one of the betas fixes or at least addresses this issue, so when Delta 1.3 releases I will test it out again.

abdullahb9922 commented 3 years ago

On beta, RTC isn't fully working on Pokemon Unbound. It doesn't sync with my phone's time.

Ayukito commented 3 years ago

This seems to have been fixed as of the latest public release. Closing.