Get Final Height data from unit misc data

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
Parameters : r4 = Unit misc. data pointer
Returns : r2 = Unit height data

0007d51c: 27bdffd8 addiu r29,r29,-0x0028    |
0007d520: afb00018 sw r16,0x0018(r29)       |
0007d524: 00808021 addu r16,r4,r0           |r16 = Unit's Misc Data Pointer
0007d528: afbf0020 sw r31,0x0020(r29)       |
0007d52c: 0c01f428 jal 0x0007d0a0           |-->Get_Unit_misc_data_pointer_of_ridden_unit_by_r4 r2 = Ridden unit data pointer if any, unit data pointer if not, 0x00 if fail.
0007d530: afb1001c sw r17,0x001c(r29)       |
0007d534: 00408821 addu r17,r2,r0           |r17 = r16 Unit's Misc Data Pointer or Ridden unit if r16 is riding
0007d538: 8e220134 lw r2,0x0134(r17)        |r2 = Unit on the ground data pointer
0007d53c: 00000000 nop                      |
0007d540: 90430047 lbu r3,0x0047(r2)        |r3 = Unit on the ground X coord.
0007d544: 00000000 nop                      |
0007d548: 000310c0 sll r2,r3,0x03           |X * 8
0007d54c: 00431023 subu r2,r2,r3            |X * 7
0007d550: 00021080 sll r2,r2,0x02           |X * 28
0007d554: 2442000e addiu r2,r2,0x000e       |X * 28 + 14 (14 is a value that will be used in further routines)
0007d558: a7a20010 sh r2,0x0010(r29)        |Store Unit's X Mod on stack 0x10
0007d55c: 8e220134 lw r2,0x0134(r17)        |r2 = Unit on the ground data pointer
0007d560: 00000000 nop                      |
0007d564: 90430048 lbu r3,0x0048(r2)        |r3 = Unit on the ground Y coord.
0007d568: 02202021 addu r4,r17,r0           |r4 = Unit's on the ground Misc Data Pointer
0007d56c: 000310c0 sll r2,r3,0x03           |Y * 8
0007d570: 00431023 subu r2,r2,r3            |Y * 7
0007d574: 00021080 sll r2,r2,0x02           |Y * 28
0007d578: 2442000e addiu r2,r2,0x000e       |Y * 28 + 14 (14 is a value that will be used in further routines)
0007d57c: a7a20014 sh r2,0x0014(r29)        |Store Unit's Y Mod on stack 0x14
0007d580: 9222007e lbu r2,0x007e(r17)       |Load Unit's on the ground elevation
0007d584: 27a50010 addiu r5,r29,0x0010      |r5 = Stack Pointer + 0x10
0007d588: 0c01f435 jal 0x0007d0d4           |-->Complex_Height_Data_from_unit_misc_data_and_coordinates returns r2 = Height data
0007d58c: a7a20012 sh r2,0x0012(r29)        |Store Unit's Elevation on stack 0x012
0007d590: 00402021 addu r4,r2,r0            |r4 = Unit height data
0007d594: 92030130 lbu r3,0x0130(r16)       |r3 = Unit misc. Mount/rider flag
0007d598: 34020001 ori r2,r0,0x0001         |r2 = 0x01 (riding flag)
0007d59c: 14620005 bne r3,r2,0x0007d5b4     #If unit is riding
0007d5a0: 00041400 sll r2,r4,0x10           |r2 = Unit height data * 1024
0007d5a4: 96230076 lhu r3,0x0076(r17)            |Unit misc ??
0007d5a8: 2482fff6 addiu r2,r4,0xfff6            |r2 = -(Height data) - 0x0a 
0007d5ac: 00622021 addu r4,r3,r2                 |r4 = -(Height data + 0x0a) + Unit misc ??
0007d5b0: 00041400 sll r2,r4,0x10                |r2 = r4*1024
0007d5b4: 00021403 sra r2,r2,0x10           |r2 = Unit height data (register cleanup)
0007d5b8: 8fbf0020 lw r31,0x0020(r29)       |
0007d5bc: 8fb1001c lw r17,0x001c(r29)       |
0007d5c0: 8fb00018 lw r16,0x0018(r29)       |
0007d5c4: 27bd0028 addiu r29,r29,0x0028     |
0007d5c8: 03e00008 jr r31                   END
0007d5cc: 00000000 nop

Return location

Battle.bin
0008c4f8: Set_Unit_Xmod,_Y_Mod_and_Height_data_from_unit_ID