Store counter ability

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
Store Counter Ability?
r4 = unit data
r5 = skillset of last attack
r6 = ability ID of used attack (to be used as counter)
r7 = 0x01 appears to be used for Hamedo, Counter, MBS, Counter Tackle; 0x00 for Counter Magic, Counter Flood
0017e650: 3c028019 lui r2,0x8019
0017e654: 8c42f8c8 lw r2,-0x0738(r2)		load Target ID for reaction?
0017e658: 27bdffe0 addiu r29,r29,0xffe0
0017e65c: afb20018 sw r18,0x0018(r29)
0017e660: 00809021 addu r18,r4,r0
0017e664: afb00010 sw r16,0x0010(r29)
0017e668: 2650016e addiu r16,r18,0x016e		r16 = targetting data
0017e66c: afbf001c sw r31,0x001c(r29)
0017e670: afb10014 sw r17,0x0014(r29)
0017e674: a245016f sb r5,0x016f(r18)		store skillset of used attack
0017e678: a6460170 sh r6,0x0170(r18)		store ability ID of used attack
0017e67c: 000218c0 sll r3,r2,0x03
0017e680: 00621823 subu r3,r3,r2
0017e684: 00031980 sll r3,r3,0x06
0017e688: 3c028019 lui r2,0x8019
0017e68c: 244208cc addiu r2,r2,0x08cc		Target unit data
0017e690: 10e00018 beq r7,r0,0x 0017e6f4
0017e694: 00628821 addu r17,r3,r2		r17 = target unit data?
0017e698: 0c05ea30 jal 0x 0017a8c0		Calculate ability range based on action menu byte
0017e69c: 02002021 addu r4,r16,r0		r16 = targetting data
0017e6a0: 00401821 addu r3,r2,r0
0017e6a4: 2402ffff addiu r2,r0,0xffff
0017e6a8: 10620004 beq r3,r2,0x 0017e6bc		branch if result was 0xffff
0017e6ac: 2462fffe addiu r2,r3,0xfffe
0017e6b0: 2c420002 sltiu r2,r2,0x0002
0017e6b4: 10400003 beq r2,r0,0x 0017e6c4		branch if not 2 or 3
0017e6b8: 00000000 nop
0017e6bc: 0805f9d9 j 0x 0017e764			jump to end, return 0xffff
0017e6c0: 2402ffff addiu r2,r0,0xffff
0017e6c4: 0c060428 jal 0x001810a0		map location calculation
0017e6c8: 02202021 addu r4,r17,r0
0017e6cc: 000210c0 sll r2,r2,0x03
0017e6d0: 3c018019 lui r1,0x8019
0017e6d4: 00220821 addu r1,r1,r2
0017e6d8: 9022f8d1 lbu r2,-0x072f(r1)		load enemy in range?
0017e6dc: 00000000 nop
0017e6e0: 30420040 andi r2,r2,0x0040
0017e6e4: 14400004 bne r2,r0,0x 0017e6f8		branch if enemy in range? targetable?
0017e6e8: 34020005 ori r2,r0,0x0005		
0017e6ec: 0805f9d9 j 0x 0017e764				jump to end
0017e6f0: 2402fffe addiu r2,r0,0xfffe		return r2 = 0xfffe
R7 input was 00
0017e6f4: 34020005 ori r2,r0,0x0005
0017e6f8: a202000a sb r2,0x000a(r16)		store 0x05 - tile specific targeting
0017e6fc: 3c028019 lui r2,0x8019
0017e700: 9042f8c8 lbu r2,-0x0738(r2)		load target ID
0017e704: 00000000 nop
0017e708: a202000b sb r2,0x000b(r16)		store Target ID into reacting unit data as target
0017e70c: 92220047 lbu r2,0x0047(r17)		load X coordinate
0017e710: 00000000 nop
0017e714: a602000c sh r2,0x000c(r16)		store X coordinate of target
0017e718: 92220048 lbu r2,0x0048(r17)
0017e71c: 00000000 nop
0017e720: a6020010 sh r2,0x0010(r16)		store Y coordinate of target
0017e724: 96220048 lhu r2,0x0048(r17)
0017e728: 02002021 addu r4,r16,r0
0017e72c: 000213c2 srl r2,r2,0x0f
0017e730: a482000e sh r2,0x000e(r4)			store elevation of target
0017e734: 9250015d lbu r16,0x015d(r18)		load current ability CT
0017e738: 0c05f0f7 jal 0x 0017c3dc			jump to set status flags based on ability
0017e73c: 00000000 nop						returns r2 = ability CT?
0017e740: 00401821 addu r3,r2,r0
0017e744: 2402ffff addiu r2,r0,0xffff
0017e748: 10620005 beq r3,r2,0x 0017e760		branch if 0xff ability CT is returned?
0017e74c: a250015d sb r16,0x015d(r18)		store current ability CT
0017e750: 2462fffe addiu r2,r3,0xfffe		CT - 2
0017e754: 2c420002 sltiu r2,r2,0x0002		set if CT = 2,3
0017e758: 10400002 beq r2,r0,0x 0017e764		branch if not
0017e75c: 00000000 nop
0017e760: 2402fffd addiu r2,r0,0xfffd		return r2 = -3
0017e764: 8fbf001c lw r31,0x001c(r29)
0017e768: 8fb20018 lw r18,0x0018(r29)
0017e76c: 8fb10014 lw r17,0x0014(r29)
0017e770: 8fb00010 lw r16,0x0010(r29)
0017e774: 27bd0020 addiu r29,r29,0x0020
0017e778: 03e00008 jr r31
0017e77c: 00000000 nop