Searching for Boktai sunrise/sunset timing data

Started by Euclide, March 30, 2019, 09:05:15 PM

Previous topic - Next topic

Euclide

It's a long shot, but I'm hoping to get some advice on finding the data that defines sunrise/sunset timing in Boktai. For those unaware, the game includes a list of regions (which varies by version), and the selected one affects the in-game daily sunrise and sunset times (using a real-time clock) to match the real world. My goal is to edit the aforementioned list and sunrise/sunset curves/times to match.

I am a relative beginner, in that I know the basics of memory filtering to find interesting addresses, bases, assembly etc., but I may not be aware and taking advantage of all the tools available. I did read the documents I found on general romhacking and some GBA-specific tips.

My first instinct was to set a breakpoint (with No$GBA) at the point in the in-game menu that displays the sunset time. The player can toggle current/sunrise/sunset time and a memory value changes along with that, which allowed me to set a conditional breakpoint.

Next I tried to run single lines/operations looking for a predictable value in registers. Knowing the hour, minute, total time in number of minutes, and total time in number of seconds, I looked for these or similar values, but the menu draw loop (that takes care of displaying the correct time) went by and I was not able to find an appropriate value that would come out any differently when modified. I tried to follow the assembly line by line as well, but it is very long and tedious to figure out the purpose of each statement, and without knowing how the time is computed/retrieved/displayed it is difficult to narrow down the search space in the program.

That's about where I gave up at this point. I can't think of a way to get closer to the data I'm looking for without going back and analyzing the code line by line. There are probably a few hundred lines in the draw loop past the point that checks for which of the times (current, sunrise, sunset) to display until the image is refreshed with the right one, and that's quite intimidating. The main issue is that I don't know if the data is stored as a series of times, time offsets, or curve parameters for an approximation.

If anyone has an idea but wants more detail on my method, or wants to have a look, here is how I was looking at it. I was using the Japanese version, but work RAM is mostly the same in all versions, so the breakpoint should work regardless.
1. Start a new game, get past the initial cutscenes, enter the next area and save to avoid going through them again in case resetting is needed
2. Open the menu (Select)
3. Add breakpoint: [2001b74]=2 (triggers when switching from displaying sunrise time to displaying sunset time)
4. Press Start while in the menu to change the time display
5. Run single lines and stare at registers until all hope is lost

Soon after the breakpoint is hit, the code compares the memory value involved to determine whether current, sunrise, or sunset time should be displayed. But going into the branch and trying to figure out how the time is being retrieved and displayed is where I got lost.

Any advice would be appreciated.

FAST6191

Assuming day and night is some kind of flag in memory would that not be a better thing to play with? If it changes that then something in the immediate past should lead to what you want, or the routines for it at least.

I was wondering at first if it would be worth watching the clock hardware itself ( http://problemkaputt.de/gbatek.htm#gbacartrealtimeclockrtc ) but if there is that much stuff layered upon it I am not sure it would refresh from hardware as much as seed it at the start of the game and go from there.