How to Make Custom Items & Staves
Hey everyone! So after a TON of research I finally, FINALLY figured out how to make custom items in FE7--and not just editing existing items, but making new items with new effects. And no, I don't mean weapons, either. I mean actual items you can "use" with the use menu.
To my knowledge, no one has ever done this for FE7 before, or if they have, they haven't shared it before, or it's in some obscure location I don't know about (I looked through Cam's and Hextator's doc a LOT and not even THOSE huge docs seemed to detail how to actually add new items).
NOTE: I'M GOING TO START "RANTING" HERE, BUT MOST OF WHAT I SAY IS PRETTY IMPORTANT AS MAKING THESE HACKS ISN'T GOING TO BE SUPER EASY, SO I'LL TRY TO BE CONCISE BUT PLEASE GATHER UP SOME PATIENC AND READ IT. =)
First, I know there are a lot of people instantly thinking stuff like: "we need multiple healing items that heal different amounts of HP!" and "I want a Rewarp staff!". Well, that's all great and all, but you have to take into account that items use ASM for all their effects, so if you're going to create custom items, that means you're going to need ASM.
Thus what I'd like to propose is that those people who can ASM hack should share their hacks with others so that they can be inserted into the game. Due to the fact that everyone has different amounts of free space etc., I don't want to set the new table at a specific offset, so that means IF YOU'RE GOING TO MAKE CUSTOM ITEMS, YOU'RE GOING TO HAVE TO KNOW HOW TO HEX EDIT. Assuming no one else comes up with a better method that's also flexible.
It won't be anything complicated; you're going to have to repoint a couple of tables, edit a couple of bytes of ASM, edit the tables, and last but not least, insert new ASM for the tables to point to. One of the common issues with ASM, however, is that they use these things I call "relative pointers", which reference an offset based on the distance between the current address and the address to go to, instead of using the specific address itself. These things have limited space ranges, but there's a nice chunk of space near the beginning of the ROM that I'd like to use for ASM hacks, and that's the space that the Weapon Icons use, between 0xC5EA4 and 0xCBEA4 (which is where the palette offset is). ASM hacks are usually small in size so this is a GREAT space range to use; the only issue is that the weapon icons need to be repointed and a patch called the Item Icon Bug Fix patch, located in FEditor Adv in both IPS and JFP format, needs to be applied for the repointed table to work.
However, with this repointed, there should be plenty of space for ASM hackers to make new hacks. We'll be able to standardize them making it easier for people to use them as they won't have to know how to assemble assembly hacks and patch them (not that it's very hard, but it can be intimidating and confusing, and it'd likely be easier for people to just use a hex editor... even though using the patcher is probably much quicker once you know how to use it).
With all that covered, it's time to go on to how to actually hack the item table. For ASM-savvy people, I'd like to post some notes, but I honestly didn't take very many - I kind of just freaked out once I figured it out and stopped taking notes so I could enjoy the moment I know, I should be ashamed
How to Expand Item Effects
- Basic hex editor knowledge required. HxD is suggested hex editor.
- FE7. Sorry, FE8 is an awesome game but I don't hack it because as it is it took years to figure out how to hack FE7 so much, and I don't want to have to do the same things for FE8. >_>'
- Repointed Weapon Icon table with Item Icon Bug Fix patch applied.
- An ASM hack for the new item.
- Item Editor and Nightmare Modules.
- A situation in which you can test/use your item.
Notes: "Item" can actually refer to practically anything--though I haven't tested it, you should be able to make things like swords that double as vulneraries. For sake of ease, I'm just going to use the generic term "item".
This is the simplified version that just gives instructions and doesn't explain anything unnecessary.
Step 1: Repointing the Tables
There are two arrays/tables to repoint. One controls the condition for making an item usable--if the condition is not met, the item will be greyed out and deemed unusable. If the condition is met, it will be usable. The second one controls the actual effect of the item.
Find two areas of free space of 0x400 bytes each. Write the offsets for each and label them; one is for item usability, and one is for item effect.
Go to 0x26D0C in a hex editor and repoint it to the offset of the new Item Usability Array. Then copy the data from 0x26D10 to 0x26E54 (the length is 0x144 bytes) and paste it to the new offset.
Do the same thing for the Item Effect Array. The pointer to repoint is at 0x2D048 and the table is at 0x2D04C and goes to 0x2D190 (also 0x144 bytes). Repoint it and paste the data at the new table offset.
Note on Repointing: Be sure to add 0x08000000 to the offset and use little endian. I consider this a basic of hex editing, but if you haven't learned it yet or need a quick refresher, 12345678 -> 12 34 56 78 -> 78 56 34 12 is how little endian works (you reverse the order of the bytes, not the digits of the bytes); e.g. for offset 0xD45A40 you would write 08 D4 5A 40 in reverse, being 40 5A D4 08.
Change the values at 0x26CFC and 0x2D030 to 0xB5.
Go to the end of the first repointed table--i.e. where there are 00's for the pointers. Copy these bytes: 44 6F 02 08 and paste them over and over until you fill up 0x400 bytes worth, e.g. if your base offset is 0xD40000, and the data ends at 0xD40144, at 0xD40144, paste those bytes over and over until you get to 0xD40400.
Do the same thing for the second table, but with these bytes: 34 D2 02 08.
Save your game and test a normal item. If it doesn't work, something went wrong, as we haven't made any real changes to the items, we just repointed and expanded them. Check your steps and try again.
Step 2: Adding New Items
If you find an ASM hack you want to add, first, you have to apply the ASM hack, either by copying the data to the given offset or applying a patch. Make sure it's meant for this and isn't something else. Also, note the offset of the start of the ASM hack, which is where you copy it to/should be documented in the hack itself. For example, if you put the part of the hack that is the condition checker at 0xC5F00 and the effect part of the hack at 0xC5F20, you'll need to know both of those offsets.
We need to find the offset of the item usability pointer and item effect pointer for the item. To do this, take them ID and subtract 0x4A from it, then multiply it by 4, and add that to the base offset of each array. For example, for item 0xC2 and array at 0xD40400, use a hex calculator to do ((0xC2 - 0x4A) * 0x04) + 0xD40400 = 0x1E0 + 0xD40400 = 0xD405E0.
Go to this offset and repoint the current pointer to the pointer for the first part of the ASM hack (the part that determines whether the item is usable or not). See the notes above regarding little endian and repointing in hex.
Do the same thing for the second table and second part of the ASM hack. Continuing from my last example, I'd type "00 5F 0C 08" and "20 5F 0C 08" (respectively) at the two offsets.
Now you just have to configure the item using a Nightmare Module. You may want to expand your item table to give you more space (IIRC it starts at 0xBE222C). Then try and use the item. If the ASM hack is done right and everything is repointed/setup right, it should work! Enjoy!
Important Note: If the item you're trying to hack is under 0x4A, there's a bit of an issue with this, as you may have very well noticed. This makes the hack a bit more complicated, but if you really need to, edit the values at 0x26CFA and 0x2D02E to be 00 instead of 0x4A and 0x26CFC and 0x2D030 to 0xFF instead of 0xB5. Then, when you insert the data, you have to add it to 0xD40128 and fill in both the pointers before AND after the data with that blank pointer I mentioned above. It's a bit more complex then the simple way which is why I didn't want to include it since the harder I make things for you the more I have to explain. Hopefully someone can create a program or picture tutorial or something to make this process easier at some point.
More Complex Versions/Details
I'm only going to try to go over what's relevant/useful, not my other random crap that ended up not being productive. These aren't really notes, it's something I'm typing after I've figured it out, so yeah.
- At the offset 0x26CFA the game does this (and I'm not going to properly comment it):
08026CFA 384A sub r0,#0x4A - subtracts 0x4A from r0. r0 holds the value of the item. I think it actually checks every item in the inventory. XP
08026CFC 2850 cmp r0,#0x50 - compares it to 0x50. 0x50 is the original max entry value.
08026CFE D900 bls #0x8026D02 - if its less than 0x50, go to this offset (located below)
08026D00 E120 b #0x8026F44 - if its not, go to this one (makes unusable; same offset used for entries in table which aren't usable items)
08026D02 0080 lsl r0,r0,#0x2 - multiply r0 by 4
08026D04 4901 ldr r1,=#0x8026D10 - load offset of table
08026D06 1840 add r0,r0,r1 - add r0 to r1, i.e. find offset of pointer for that item
08026D08 6800 ldr r0,[r0] - load that pointer
08026D0A 4687 mov r15,r0 - go run the ASM at that pointer (same as mov pc, r0)
As you can see, probably to save space, it just ignores items under 0x4A, because all items before the heal staff (item ID 0x4A) can't be used. Practically the same thing is done with the other table with the ASM routine located at like 0x02D026 and it DOES do some other stuff but I don't care for it.
Thus to maximize this we have to make it subtract 00 and compare it to 0xFF so that it always uses the entries, or else just get rid of the subtraction and just always make it go straight to that offset (which would probably free up some space XP). We also need to repoint the table (it's right after the routine) and whatnot.
Regarding the ASM's, the first routine should output 0x01 into r0 if it's true, and 0x00 if it's false. Obviously you'll want to code some actual checks before doing this, but that's the basic idea. For the second part, you can do pretty much whatever you want with your ASM. You'll likely want to reference some codes though in order to a) save how much coding you do, b) mimic existing effects, and c) make the items do stuff like show the healing animation (which is appointed to the item through the Spell Association Data, might I add [see the "Spell Association Editor" Nightmare Module for that]) and d) some other stuff (whatever that is).
By the way, here's the basic routine for item checks:
mov r0, #0x00 @ Marks as failure; set to 0x01 for true
be sure to push your registers at the beginning and pop at the end and just append that code at the end of a check; you'll want to set it to "0x01" if the check has been passed and the item can be used, or 0x00 if the check hasn't been passed and as a result the item can't be used.
The good thing is, if the ASM hack doesn't need to branch to any instructions in the early part of the game, you won't need to make use of the space I kindly requested people clear up near the beginning; however, TO MY KNOWLEDGE, when using stuff like bl $0800E30 the routine which uses the RNG to output "random" numbers, I believe, though it's one of those things I haven't actually checked so I can't say with confidence you need to have the data within a certain range or the relative pointer will be, well, out of range, and it won't work. Granted I feel like there might be some ways to bypass this but I haven't had very much luck so far and I haven't cared enough to try to find an alternative, but maybe one day somebody will tell me of one (if it exists) or I'll just stop being lazy and figure it out myself.
And that's most of the explanation regarding the items... I can't really help much with the actual ASM hacking--that's up to you guys, but I think you can do it! So best of luck!
~ Burning Gravity