That's a lot more RAM than you think!
But I didn't really say the
system'sconsole's RAM. The expansion carts have RAM and not all of it would have to be used for the game. But yes, it makes sense to use a few bytes of the system memory to store the counter and then patch the ROM to use it (
If you can find the space). In practice, I bet quite a few have gaps of unused memory. Also, does the system erase the memory before letting the GBA game run? The other problem I see is that each game would use RAM differently so it would be a royal pain to find a good location for all the GBA RTC games. A work around is to patch the game using a detour to code that reads it from a standard location and then copies it to that game's (previously) unused 4 bytes. Then the detour goes on to the normal game. The patch would use very little RAM. The 3 parts (init detour+interrupt detour+replaced time-reading code) would all be ROM code. Having the counter incremented and then going on to the regular interrupt will change the timing, sadly. No one ever said assembly language had to be easy.
This is an ugly kludge but it's probably feasible if at least a few of those pitfalls are passable. Has anyone tried this?
::EDIT::
Der, GBATA does something like this. And yes, the author has to make a patch for each game.
"The border is nothing more than a tiny segment of RAM that isn't cleared when booting into GBA mode, while pretty much everything else gets cleared out by the GBA BIOS. It has to be set before booting into GBA mode, as the GBA cannot access that memory by itself. The point is that you can only access the DS's RTC from within DS mode itself, so there's no way to patch the Pokemon rom to do what you want." -
DanTheManMS
OK, that's in another thread and I only found it with a lucky unrelated search. The BIOS erases the RAM
except at those locations. But yes, I need to just break down and read the datasheets again. The last system in this line that I've played with is the GBA. The NDS looks like it has some neat wrinkles added.
I didn't intend to do this, but is it possible to move our RTC emulation discussion to another topic like "RTC emulation?" or something like that? Sorry about how this seems to have moved too far from mostly a RAM/Flash feature focus instead of just the RTC.