Find Direction of Target

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
001978e4: 80830002 lb r3,0x0002(r4)		Load Target's Y
001978e8: 80860000 lb r6,0x0000(r4)		Load Target's X
001978ec: 80a40000 lb r4,0x0000(r5)		Load Attacker's X
001978f0: 80a50002 lb r5,0x0002(r5)		Load Attacker's Y
001978f4: 00661023 subu r2,r3,r6		TY - TX
001978f8: 00441021 addu r2,r2,r4		TY - TX + AX
001978fc: 00453823 subu r7,r2,r5		TY - TX + AX - AY
00197900: 00661821 addu r3,r3,r6		TY + TX
00197904: 00641823 subu r3,r3,r4		TY + TX - AX
00197908: 1ce00005 bgtz r7,0x00197920		Branch if T is N/W of A
0019790c: 00651823 subu r3,r3,r5		TY + TX - AX - AY
00197910: 04610005 bgez r3,0x00197928		Branch if T is N/E of or same as A
00197914: 00001021 addu r2,r0,r0		r2 = 0 (South)
00197918: 08065e55 j 0x00197954
0019791c: 00000000 nop
00197920: 1860000c blez r3,0x00197954		Branch if T is S/W of or same as A
00197924: 34020001 ori r2,r0,0x0001		r2 = 1 (West)
00197928: 04e00005 bltz r7,0x00197940		Branch if T is S/E of A
0019792c: 00000000 nop
00197930: 18600003 blez r3,0x00197940		Branch if T is S/W of or same as A
00197934: 00000000 nop
00197938: 08065e55 j 0x00197954
0019793c: 34020002 ori r2,r0,0x0002		r2 = 2 (North)
00197940: 04e10004 bgez r7,0x00197954		Branch if T is N/W of or same as A
00197944: 34020004 ori r2,r0,0x0004		r2 = 4 (Same Coord, different level)
00197948: 04600002 bltz r3,0x00197954		Branch if T is S/W of A
0019794c: 00000000 nop
00197950: 34020003 ori r2,r0,0x0003		r2 = 3 (East)
00197954: 03e00008 jr r31
00197958: 00000000 nop