Height/coordinate validation

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
Parameters : r4 = Attacker ID
             Load target ID exceeding stack offset (reaching previous routine r29 0x10)	  

Returns : r2 = Target ID (-0x01 if not in melee range)
-------------------------------------------------------------------
0017b3f4: 27bdffd8 addiu r29,r29,-0x0028    
0017b3f8: afb00018 sw r16,0x0018(r29)       
0017b3fc: 00808021 addu r16,r4,r0           |r16 = Attacker ID
0017b400: afb20020 sw r18,0x0020(r29)       |
0017b404: 8fb20038 lw r18,0x0038(r29)       |r18 = Target ID Strange way to get previous routine stack 0x10
0017b408: 27a40010 addiu r4,r29,0x0010      |r4 = Stack 0x10
0017b40c: afbf0024 sw r31,0x0024(r29)       |
0017b410: afb1001c sw r17,0x001c(r29)       |
0017b414: 0c05f056 jal 0x0017c158           |-->Calculate_Height_Data Return some Target map/height data on r4 pointer
0017b418: 02402821 addu r5,r18,r0           |r5 = Target ID
0017b41c: 93a20013 lbu r2,0x0013(r29)       |r2 = Target ID (with crystal/treasure/chocobo data)
0017b420: 00000000 nop                      |
0017b424: 30420080 andi r2,r2,0x0080        |r2 = 0x80 if Target unit is a crystal
0017b428: 14400016 bne r2,r0,0x0017b484     #If Target is not a crystal /If Crystalized branch to end (return target ID = -0x01)
0017b42c: 2402ffff addiu r2,r0,-0x0001      |r2 = -0x01
0017b430: 02002821 addu r5,r16,r0                |r5 = Attacker ID
0017b434: 93b00015 lbu r16,0x0015(r29)           |r16 = Target walking Height (depht/float check)
0017b438: 93b10016 lbu r17,0x0016(r29)           |r17 = Target total height (map + unit)
0017b43c: 0c05f056 jal 0x0017c158                |-->Calculate_Height_Data Return some Target map/height data on r4 pointer
0017b440: 27a40010 addiu r4,r29,0x0010           |r4 = Stack 0x10
0017b444: 93a20013 lbu r2,0x0013(r29)            |r2 = Attacker ID (with crystal/treasure/chocobo data)
0017b448: 00000000 nop                           |
0017b44c: 30420080 andi r2,r2,0x0080             |r2 = 0x80
0017b450: 10400003 beq r2,r0,0x0017b460          #If Attacker is a crystal (…)
0017b454: 00000000 nop                               |
0017b458: 0805ed21 j 0x0017b484                      >>jump to end with ID = -0x01
0017b45c: 2402ffff addiu r2,r0,-0x0001               |r2 = -0x0001
0017b460: 93a30016 lbu r3,0x0016(r29)            #Else (Attacker is not a crystal) r3= Attacker total height (map + unit)
0017b464: 93a40015 lbu r4,0x0015(r29)                |r4 = Attacker walking height
0017b468: 0203182b sltu r3,r16,r3                    |r3 = 0x01 if Target is too low
0017b46c: 10600005 beq r3,r0,0x0017b484              #if Target walking Height < Attacker total height /Else Target walks far above attacker - exit with Target = -0x01
0017b470: 2402ffff addiu r2,r0,0xffff                |r2 = -0x0001
0017b474: 0224182b sltu r3,r17,r4                        |r3 = 0x00 if Target is too high
0017b478: 14600002 bne r3,r0,0x0017b484                  #If Attacker walking height < Attacker total height /Else Attacker walk above target (not reachable)
0017b47c: 00000000 nop                                       |
0017b480: 02401021 addu r2,r18,r0                            |r2 = Target ID
0017b484: 8fbf0024 lw r31,0x0024(r29)        END
0017b488: 8fb20020 lw r18,0x0020(r29)            
0017b48c: 8fb1001c lw r17,0x001c(r29)            
0017b490: 8fb00018 lw r16,0x0018(r29)            
0017b494: 27bd0028 addiu r29,r29,0x0028          
0017b498: 03e00008 jr r31                        
0017b49c: 00000000 nop

Return locations

Battle.bin
 0017af3c: Targeting_validation_(weapon_flags)