Set Unit Xmod, Y Mod and Height data from unit ID

From Final Fantasy Hacktics Wiki
(Redirected from 0008c468 - 0008c514)
Jump to navigation Jump to search
Parameters : r4 = Unit ID
             r5 = previous routine stack pointer

Returns : r2 = 0x00 if unit misc data pointer is invalid (no data stored)
          r2 = 0x01 if unit ID point to a valid Unit misc data pointer
               Store data on previous stack pointer :
                 - 0x00 Unit X mod ((X coord.)*28 + 14)
                 - 0x02 Unit Height data
                 - 0x04 Unit Y mod ((Y coord.)*28 + 14)
-------------------------------------------------------------------------------------
0008c468: 27bdffe0 addiu r29,r29,-0x0020    |
0008c46c: afb10014 sw r17,0x0014(r29)       |
0008c470: 00a08821 addu r17,r5,r0           |r17 = PR pointer
0008c474: 3084ffff andi r4,r4,0xffff        |r4 = Unit's ID
0008c478: afbf0018 sw r31,0x0018(r29)       |
0008c47c: 0c01e9c9 jal 0x0007a724           |-->Get_unit_misc_data_that_matches_r4_ID  return r2 =  Unit misc. Data pointer (0x00 if not found)
0008c480: afb00010 sw r16,0x0010(r29)       |
0008c484: 00408021 addu r16,r2,r0           |r16 = Unit's Misc Unit Data Pointer (or 0x00 if not found)
0008c488: 1200001d beq r16,r0,0x0008c500    #If Unit misc stack pointer is valid /Else Branch to End (r2 = 0x00)
0008c48c: 00001021 addu r2,r0,r0            |r2 = 0x00 (Fail)
0008c490: 8e020134 lw r2,0x0134(r16)             |r2 = Unit's Data Pointer
0008c494: 00000000 nop                               |(getting the tile pointer here is useless since it's overwritten)
0008c498: 90440047 lbu r4,0x0047(r2)             |r4 =  Unit's X coord.
0008c49c: 94460048 lhu r6,0x0048(r2)             |r6 =  Unit's Y coord. + Elevation/Facing byte
0008c4a0: 90450048 lbu r5,0x0048(r2)             |r5 = Unit's Y coord.
0008c4a4: 0c060fed jal 0x00183fb4                |-->Get_Tile_Data_Pointer returns r2 = Unit Tile data pointer (0x00 if not valid)
0008c4a8: 000633c2 srl r6,r6,0x0f                |r6 = Unit's Elevation bit
0008c4ac: 8e020134 lw r2,0x0134(r16)             |r2 = Unit's Data Pointer
0008c4b0: 00000000 nop                           |
0008c4b4: 90430047 lbu r3,0x0047(r2)             |r3 =  Unit's X coord.
0008c4b8: 00000000 nop                           |
0008c4bc: 000310c0 sll r2,r3,0x03                |X * 8
0008c4c0: 00431023 subu r2,r2,r3                 |X * 7
0008c4c4: 00021080 sll r2,r2,0x02                |X * 28
0008c4c8: 2442000e addiu r2,r2,0x000e            |X * 28 + 14
0008c4cc: a6220000 sh r2,0x0000(r17)             |Store X Mod to PR pointer
0008c4d0: 8e020134 lw r2,0x0134(r16)             |r2 = Unit's Data Pointer
0008c4d4: 00000000 nop                           |
0008c4d8: 90430048 lbu r3,0x0048(r2)             |r3 =  Unit's Y coord.
0008c4dc: 02002021 addu r4,r16,r0                |r4 = Unit's Misc Data Pointer
0008c4e0: 000310c0 sll r2,r3,0x03                |Y * 8
0008c4e4: 00431023 subu r2,r2,r3                 |Y * 7
0008c4e8: 00021080 sll r2,r2,0x02                |Y * 28
0008c4ec: 2442000e addiu r2,r2,0x000e            |Y * 28 + 14
0008c4f0: 0c01f547 jal 0x0007d51c                |-->Get_Final_Height_data_from_unit_misc_data - returns r2 = Unit height data
0008c4f4: a6220004 sh r2,0x0004(r17)             |Store Y Mod to PR pointer
0008c4f8: a6220002 sh r2,0x0002(r17)             |Store Unit Height data to PR pointer (unit and map height)
0008c4fc: 34020001 ori r2,r0,0x0001              |r2 = 0x01
0008c500: 8fbf0018 lw r31,0x0018(r29)        END
0008c504: 8fb10014 lw r17,0x0014(r29)            
0008c508: 8fb00010 lw r16,0x0010(r29)            
0008c50c: 27bd0020 addiu r29,r29,0x0020          
0008c510: 03e00008 jr r31                        
0008c514: 00000000 nop

Return locations

Battle.bin
001af838: List_targeting_data_of_all_valid_units
001afe08: 001afd90_-_001aff14
001afe24: 001afd90_-_001aff14
001affc0: Set_and_Validate_Arc_Trajectory
001b007c: Set_and_Validate_Arc_Trajectory
001b0758: 001b06d0_-_001b0814
001b0770: 001b06d0_-_001b0814
001b08bc: 001b0818_-_001b0a8c
001b0960: 001b0818_-_001b0a8c
001b0b14: 001b0a90_-_001b0c84
001b0bb8: 001b0a90_-_001b0c84