ROM Hack Leveraging help from GBATemp for romhack save/load functionality

sakadeo

New Member
OP
Newbie
Joined
Sep 7, 2017
Messages
2
Trophies
0
Age
36
XP
41
Country
United States
Hi- basically I want to create a 'practice' rom for some games, the most notable function being injecting a save-state/load-state function into the rom. The idea is that the game can be played on a real console via flash cart, and someone can save & load at will to practice certain parts over and over. Many others have done this for other consoles (NES/SNES games in particular), but GBA is uncharted territory. I am sure it's doable, I just don't think anyone has sifted through the requirements.

The concept, at least for all the other consoles' save & load hacks, is pretty basic - find an unused section of the ROM/RAM banks, and implement hooks on button presses to flush SRAM & VRAM values on demand. Does anyone have any thoughts, any insights or recommendations for plan of attack that I would benefit from?

As someone newer to the process of assembling code specific to GBA, I have sifted through a few resources (Tonc's page on GBA, and the GBATek resource have helped my understand tremendously.) I'm now familiar with the compilers (namely 'arm-none-eabi'), and am trying to figure out what setup is best, either compiling directly with arm-none-eabi, using DKP or to use something like xkas (which I've gathered has THUMB capability). The reason I'm here is to leverage any input from anyone here- What I'm trying to do really isn't super complicated right, I don't want to create custom GBA content, I just want to implement a functionality, for which I have a pretty decent idea (I have code designed for the SNES that replicates pretty much what I want to do). The hangup is the syntax specific to GBA & the compiling of a GBA rom effort.

The big question is, how far into the rabbit hole do I have to go? If I have to learn everything about GBA and assembly then I will, but I don't think that's the case. I just want to be able to import a pre-existing romfile, make some code changes and clever hooks/use of dead ROM/RAM space, implement save/load and be done with it. Thanks a lot, any help is much appreciated.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
There are flash carts with savestates, the EZ3 (sadly not the EZ4 or the 3 in 1) being among the more notable but you will have a hard time finding those today. I don't know what goes with the less common DS expansion packs, the 3 in 1 which is what most use will lack this. Reliability of it was... usable but hardly emulator grade. I guess if you are going on a game by game basis you can figure out what might be tripping you up (without checking I can't think of any read only or write only areas like some DS memory sections so it is probably timing).

"unused ROM space" is trivial for almost all games on the GBA (32 megabytes is directly addressable in all games with no penalties/lockouts beyond some BIOS calls and other routines wanting you to be 8 or 16 bit aligned, and other than mother 3 and the video ROMs they should all have some 300K of space* for you to stash and pull a RAM image from). What I use depends upon what I am doing -- if I am just doing an in place hack like breaking a health bar then I won't use anything, for something more than about 5 instructions long I will tend to have it compiled/assembled by armeabi/ARMIPS or something and then manually overwrite, for something more I would definitely use ARMIPS as it is built for this. You could probably get away with an early intro/trainer style hack as well -- early intros for the GBA would jump after the basic IO setup, run basically a self contained piece of code and then jump back to the game (which you would have all the memory, registers and states for already and presumably have saved/loaded as part of this).

*understatement there. If you have a 4 meg ROM then even without the space gained by trimming you have 28 megabytes or a comfortable space for 70 savestates if you leave them uncompressed and give them 400K each and still have the better part of a meg for your routine.

I guess you need a place to add your hook then. What cheats use would be a start for most games (and those which are not tend to be known about already http://doc.kodewerx.org/hacking_gba.html ) but if you are already hacking you could do what you like. Alternatively http://gbatemp.net/threads/gba-auto-trainer-maker-gbaatm.99334/ is pretty good for this, that said you could probably just crowbar a button check and jump to your custom code (see the intro thing above) into the vblank routine of most games easily enough.

Be aware that the GBA can and does inject routines to run from system memory rather than ROM at times, not like the DS where it is the default and thus troubles people using savestates with certain types of hack, and this very much includes tight loops a game might be running during action heavy segments -- the classic example might be if you have decided to halve mana consumption or something the game might have said routine already loaded in RAM and your changes to the ROM might not happen until the routine gets read back from the ROM at some point later, if it even does.

I don't know why you would want to do this on hardware for testing like this as emulators have been great from day 0, and you can even use your GBA as a controller if you fancy sorting a multiboot cable, but to each their own I guess.

You might be able to figure out the equivalent of http://adshomebrewersdiary.blogspot.co.uk/2012/02/unequivocal-answer.html for the GBA too but it is probably not too troubling for you here -- I doubt it is going to be orders of magnitude quicker or anything.

Anyway to actually answer some other of your questions you don't need to able to recount http://quirkygba.blogspot.com/2008/12/things-you-never-wanted-to-know-about.html from memory or anything. Indeed as loading a savestate destroys the existing state of the game you don't even have to be careful saving flags, states, CPU, making sure you are not in a branch and all the other things most hackers have to worry about when crowbarring in their own routines or expanding/subverting existing ones to new space.

There are a few programs which try to subvert any GBA ROM to do its own thing. The big two would likely be the cheat injection program GBAATM and the other would be the BOMA/bootomatic advance which attempted to add a button activated hard reset to any game it was fed, others would probably be sleep functions for games and you might even find some open source for that one (kuwanger did some fairly recently for the EZ4).

Option 2.
Boss rush hack style. The GBA has a few boss rush hacks and they usually try to evoke something like what I imagine you want your savestates to do. If you are fine tuning a mechanic and just want to see it in action without the downtime/slow periods good creative design says you need in a work it could be even better; rather than finding a good point in the game to test you straight up make one. You might find it easier to alter the levels of a game to put all the things to test right after the other and repeating endlessly.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Well start walking towards them +1