Let’s take for instance activating dragon veins (using the FE8 skills hack). Obviously there’s nothing built into the AI, but suppose we have a “simple” check to see if there is a vein nearby, if so go and use it. How viable would it be to add that? I would love to also have the AI be able to do things like, dance and dismount, etc. I’m really new to rom hacking, but looking at the FE7/8 AI documentation I see that we know where the checks are being called. So i’m assuming that I would first have to write some routine in assembly, insert it somewhere and then somehow have the AI run my check where I want it. I’m experienced with C/C++ and x64 assembly but I"m not sure how much that carries over to romhacking. Any tips on how to do something like this would be greatly appreciated.
First of all welcome to FEU.
You might want to check this:
Dance AI has already been done, from what I remember it uses some leftover stuff the game had for the actual dance target selection but don’t quote me on that:
The person that has been doing the most AI stuff is @Teraspark I would say, so if Tera can share his stuff with you or give you pointers on what he’s doing maybe that would help.
You can check this, but I’m not sure how up to date it is:
I would assume that the action to perform uses the same stuff as what we call the action struct, if it’s not just the same to begin with.
This is found at 0x203A958, you can find more on it in Teq’s better notes:
Finally, we have a channel dedicated to helping people that are starting out with gba assembly over at the discord server, as well as a channel for more advanced code discussion and other technical stuff. You probably want to join if you want to share your process and ask for help and whatnot.
The ARM7TDMI is a fair bit simpler than x86/x64. Conventions are a bit different.
- You’ll be passing params to functions via r0-r3) rather than the stack (unless you pass more than 4 params to a function, then the rest go on the stack)
- Calling functions is a little less simple than CALL / RET
- There’s no hardware floating point support, division is a software interrupt (‘BIOS’ function call, basically)
- You can’t do some things you can in x86 like push/pop directly to a memory location
- The processor can switch modes between ARM (32bit opcodes) and THUMB (16bit opcodes). You won’t likely have to deal with ARM code though.
- Possibly more stuff I forget, I’m pretty new to x86/x64
If you already know a bit about reverse engineering / assembly, you won’t have a problem jumping into hacking GBA.
Furthermore, knowing C is a great asset here - given that we have C libraries developed for GBA fire emblem (and a super neat linker, even). I personally do all my engine hacks in C. Check out these and the guide Leonarth posted.
Thank you guys so much for the fast responses. If dancing has already been done, then I have some hope. When I manage to whip something up I’ll be sure to post my process.