[FE8] Set weapon to consume durability even upon a miss

Sure.

Here’s the original code, starting at 2B804

ldr r0,[r5,#0x4C] @ r5 = battle struct, +0x4C is the item's "ability word"
mov r1,#0x82 @ 0x80 (uncounterable flag) + 0x2 (magic)
and r0,r1 @ remove all other bits
cmp r0,#0 @ are either of those bits set?
beq #0x802B828 @ if they're not, go to 2B828 (which skips the item decrementing bit)

We want to change the mov r1,#0x82 to mov r1,#0x400000 (at least, I think this is the right one?). However, we can’t do that directly, because mov only takes arguments up to 1 byte, and 0x400000 is bigger than a byte. So we’re going to do use mov r1,#0x40 and left shift by 0x10 to get 0x400000. Unfortunately, that takes up an extra opcode, which there isn’t room for. But wait, we can substitute tst r0,r1 for and r0,r1; cmp r0,#0!

ldr r0,[r5,#0x4C] @ r5 = battle struct, +0x4C is the item's "ability word"
mov r1,#0x40
lsl r1,r1,#0x10 @ now we have 0x400000 in r1
tst r0,r1
beq #0x802B828

Now we turn this into byte code using the debugger. The first and last lines are identical, so all you have to do is write 40 21 09 04 08 42 to 2B806, and update tomes and ballistae to use that flag (because now we’re not checking for magic/uncounterable flags anymore).

If you want to understand more about what I did here, check out Assembly for Dummies.

2 Likes