Modding => Help! => Topic started by: Emmy on March 26, 2016, 01:57:35 pm
Title: How to find/kill whatever is messing up this code? (Asm help)
Post by: Emmy on March 26, 2016, 01:57:35 pm
Something strange is going on with my reaction code. 4 slots (Gilgame heart, Blank, Arrow Guard, Blade Grasp) are working perfectly to cast an ability. 4 other slots (Abandon, Weapon guard, Catch, Finger Guard) are casting abilities from random other slots including what it's supposed to cast and the other slots. It prints the name of the other abilities when it casts them.
I don't think the issue is with the asm itself since it doesn't matter which order i place the abilities in the code, the same 4 slots don't work. Which leads me to believe there's extra hard coding somewhere messing up these slots, but I have no idea what it is or how to find it. :cry:
For reference the asm used for this is here: http://pastebin.com/GRM8uT4s
Title: Re: How to find/kill whatever is messing up this code? (Asm help)
Post by: Aqueous on March 28, 2016, 05:25:37 pm
Need 2 things to help really.
What spells are being cast and your actual MIPS code rather than the hex.
Title: Re: How to find/kill whatever is messing up this code? (Asm help)
Post by: Emmy on March 28, 2016, 06:13:17 pm
Mips code of Multi-reaction Deluxe
ori r4,r0,0x0000 lui r6,0x8015 sll r2,r4,0x01 addu r6,r6,r2 lhu r5,0x1ec0(r6) lui r2,0x8019 lhu r2,0x2d9c(r2) nop bne r2,r5,0x00000038 addiu r4,r4,0x0001 lhu r6,0x1ed0(r6) ori r5,r0,0x000b j 0x0017e3dc addu r4,r17,r0 sltiu r5,r4,0x0008 bne r5,r0,0x00000004 lui r2,0x8019 lh r2,0x2d9c(r2) j 0x0017e400 lui r1,0x8006
The first chart refers to the ability ID of the reaction, second chart to the ability ID of the cast ability with reversed bytes (bb01 = blank reaction, for example).
Using blank abilities requires this code though (Multi-reaction = damage trigger):
lui r4,0x8019 lw r4,0x2d98(r4) nop lbu r3,0x008e(r4) nop andi r2,r3,0x0040 beq r2,r0,0x00000028 nop jal 0x0018ce88 ori r4,r0,0x01bf andi r2,r3,0x0020 beq r2,r0,0x0000003c nop jal 0x0018ce88 ori r4,r0,0x01c0 andi r2,r3,0x0010 beq r2,r0,0x00000050 nop jal 0x0018ce88 ori r4,r0,0x01c1 andi r2,r3,0x0008 beq r2,r0,0x00000064 nop jal 0x0018ce88 ori r4,r0,0x01c2 andi r2,r3,0x0004 beq r2,r0,0x00000078 nop jal 0x0018ce88 ori r4,r0,0x01c3 andi r2,r3,0x0002 beq r2,r0,0x0000008c nop jal 0x0018ce88 ori r4,r0,0x01c4 lbu r3,0x008d(r4) nop andi r2,r3,0x0004 beq r2,r0,0x000000a8 nop jal 0x0018ce88 ori r4,r0,0x01bb j 0x0018cc70 nop
Now, the issue I'm running into makes me think there's other hard coding that is messing up the slots of Weapon Guard, Abandon, Finger Guard, Catch; even though their old slots have been disabled and moved to support abilities. It doesn't matter which order I place these abilities in the above codes, the same slots are messed up, while the Blank, Gilgame Heart, Arrow Guard, Blade Grasp slots work perfectly with these codes.
Is there a way to search for other hard coding that can affect a slot?
Title: Re: How to find/kill whatever is messing up this code? (Asm help)
Post by: Xifanie on March 28, 2016, 06:31:02 pm
The way FFT usually does it, is take the first ID, make it negative, and addiu that to the current ID. So in this case, if there is hardcoding for those (and in this format), I would guess it would be something like: [indent=2]addiu r2, r2, 0xFE41 (-0x01BF) sltiu r2, r2, 0x0004[/indent] ...but I couldn't find anything of the sort in any of the code. So, unfortunately, chances are that the Ability ID is checked for other ranges first by subtracting and using sltiu, then subtractrating again for every new check based on the previously calculated value. :/ No real way to search for that. I forgot if it's possible or not that it would do something like -0x1C3 then branch if the value is negative or not... but I would guess in this case it would be extremely unlikely anyway.
Are you sure it's an exception? From my point of view, there could be the possibility that these abilities are not included in the range that affects the other abilities you mentioned. I really don't know anything about that ability stuff, just throwing that out there.
Title: Re: How to find/kill whatever is messing up this code? (Asm help)
Post by: Aqueous on March 30, 2016, 11:19:41 am
Might be silly questions but:
How have the reaction skills in question been positioned in FFTPatcher ie. what ability IDs have they been given? Have you rejigged any of the existing IDs? The reactions not working properly: are they using all of these abilities in one reaction or is it just random which they use?
With those questions out of the way, I'd suggest looking at the first piece of code first. Without context it's difficult to see what the first piece of code is doing exactly, which is the problem with any hack affecting undocumented code. Eyeballing the code, two lines that stick out to me that you might want to check:
ori r4,r0,0x0000 lui r6,0x8015 sll r2,r4,0x01 addu r6,r6,r2 lhu r5,0x1ec0(r6) lui r2,0x8019 lhu r2,0x2d9c(r2) nop bne r2,r5,0x00000038 - Is there a pattern between the abilities that work properly and this branch triggering? addiu r4,r4,0x0001 lhu r6,0x1ed0(r6) - This appears to be loading the ability it will counter with. If all of the Reaction abilities are getting to this point in the code, what's happening here? ori r5,r0,0x000b j 0x0017e3dc addu r4,r17,r0 sltiu r5,r4,0x0008 bne r5,r0,0x00000004 lui r2,0x8019 lh r2,0x2d9c(r2) j 0x0017e400 lui r1,0x8006
That's probably the most help I can give at the moment, quite a bit of it will be checking what the code is doing in real-time with breakpoints.
Title: Re: How to find/kill whatever is messing up this code? (Asm help)
Post by: Emmy on March 30, 2016, 04:57:52 pm
The first table is the reaction abilities:
B701BB01 BF01C001 C101C201 C301C401
This part is the ability it casts:
6D016E01 4E011600 0F014300 4D014E01
The bytes are reversed here, but each piece corresponds to the same other piece. So for example the blank slot (01bb) casts ability 016e in Patcher. It doesn't matter which order I place them into the code, the same abilities work and the same abilities don't work.
The reactions that aren't working appear to be selecting an ability at random. It will cast with the reaction ability title of another ability.
Title: Re: How to find/kill whatever is messing up this code? (Asm help)
Post by: Aqueous on March 30, 2016, 05:05:30 pm
Will need to step through the code in PSX then I think. The two lines I highlighted should be bringing in the correct IDs, if it was working properly. I'm hoping that'll be your best place to start.
Title: Re: How to find/kill whatever is messing up this code? (Asm help)
Post by: Emmy on April 02, 2016, 03:08:06 pm
Finally got a lead as to something that could be affecting this. The "Thunder Cats" bug is still in the game. Finger Guard's vanilla slot has been rewritten to cast Bolt. Panthers have Finger Guard (which I had rewritten to a support ability), and no Priority 0-2 abilities. If it were working 100% properly, Panthers wouldn't react with anything, but I saw one react with Bolt.
Not sure yet what is causing this to happen but I figure I might as well let you guys know if someone is still trying to solve this problem.
For reference, these are the Finger Guard hacks (Moves it to support slot, changes the coding of it to block Br/pa/ma drain and dance):
<Patch name="Finger Guard blocks XX Formulas"> <Description> Can block up to 4 formulas. If using less, set unused slots as copies of one that it does block. So to block only formula 2a, set them to 2a, 2a, 2a, 2a. Nops at 0x121308 disable the check to see if unit can react. </Description> <Location file="BATTLE_BIN" offset="121308"> 00000000 00000000 00000000 </Location> <Location file="BATTLE_BIN" offset="121334"> 00000000 </Location> <Location file="BATTLE_BIN" offset="121344"> 25100000 </Location> <Location file="BATTLE_BIN" offset="124940"> C4470508 00000000 </Location> <Location file="BATTLE_BIN" offset="EAf10"> E8FFBD27 1400BFAF 1980013C E5382390 </Location> <Variable name="Formula 1" file="BATTLE_BIN" offset="EAF20" default = "55"/> <Variable name="Formula 2" file="BATTLE_BIN" offset="EAF21" default = "56"/> <Location file="BATTLE_BIN" offset="EAF22"> 013C </Location> <Variable name="Formula 3" file="BATTLE_BIN" offset="EAF24" default = "1D"/> <Variable name="Formula 4" file="BATTLE_BIN" offset="EAF25" default = "62"/> <Location file="BATTLE_BIN" offset="EAF26"> 2134 FF002230 08006210 020A0100 FCFF2014 00000000 2A000134 03006110 00000000 D6470508 00000000 BE20060C 00000000 1400BF8F 1800BD27 1980023C 522E0608 902D428C </Location> </Patch>
<Patch name="Moves Finger Guard to support abilities"> <Description>Finger Guard support in Equip Sword slot instead of reactions.</Description> <Location file="BATTLE_BIN" offset="121324"> 8F00A290 00000000 20004230 </Location> </Patch>