See if any units are on target panel

From Final Fantasy Hacktics Wiki
Revision as of 19:49, 19 May 2024 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
BATTLE.BIN :  - See_if_any_units_are_on_target_panel
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : r2 = Unit ID if on Considered Tile (AI 0x28)
         r2 = 0x15 if No units found (end of loop)
------------------------------------------------------------------------------------------
0019d218: 3c06801a lui r6,0x801a             |
0019d21c: 24c6f3c4 addiu r6,r6,-0x0c3c       |0x8019f3c4
0019d220: 00002821 addu r5,r0,r0             |
0019d224: 340700ff ori r7,r0,0x00ff          |
0019d228: 3c048019 lui r4,0x8019             |
0019d22c: 248408cc addiu r4,r4,0x08cc        |Prepare dynamic pointer to Battle data
                                            @LOOP - All Units
0019d230: 90820001 lbu r2,0x0001(r4)             |This Unit ID
0019d234: 00000000 nop                           |
0019d238: 10470010 beq r2,r7,0x0019d27c          #If This unit doesn't exist : branch to Next Unit
0019d23c: 00000000 nop                               |
0019d240: 90830047 lbu r3,0x0047(r4)             |This Unit X
0019d244: 94c20028 lhu r2,0x0028(r6)             |Considered Tile X
0019d248: 00000000 nop                           |
0019d24c: 1462000b bne r3,r2,0x0019d27c          #If Note same X : branch to  Next Unit
0019d250: 00000000 nop                           |
0019d254: 90830048 lbu r3,0x0048(r4)             |Unit Y
0019d258: 94c2002c lhu r2,0x002c(r6)             |Considered Tile Y
0019d25c: 00000000 nop                           |
0019d260: 14620006 bne r3,r2,0x0019d27c          #If Note same Y : branch to  Next Unit
0019d264: 00000000 nop                           |
0019d268: 94820048 lhu r2,0x0048(r4)             |Unit Elevation
0019d26c: 94c3002a lhu r3,0x002a(r6)             |Considred Tile elevation
0019d270: 000213c2 srl r2,r2,0x0f                |
0019d274: 10430005 beq r2,r3,0x0019d28c          #If Same Elevation :  Exit Routine Returns Unit ID
0019d278: 00000000 nop                           |
0019d27c: 24a50001 addiu r5,r5,0x0001            |Unit counter + 1
0019d280: 28a20015 slti r2,r5,0x0015             |
0019d284: 1440ffea bne r2,r0,0x0019d230      Λ Loop
0019d288: 248401c0 addiu r4,r4,0x01c0            |Battle data offset
0019d28c: 03e00008 jr r31
0019d290: 00a01021 addu r2,r5,r0

Return locations

BATTLE.BIN
 0019d06c: AI_Target_Unit_for_Direct_vs_Arc_Attack_(0019cd9c)