Weapon Range Routine

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
DUPLICATED Set_targeting_for_weapon_attack?
00179a20: 
00000000: 27bdffe0 addiu r29,r29,-0x0020
00000004: 00803821 addu r7,r4,r0				Caster ID = r7
00000008: afbf0018 sw r31,0x0018(r29)
0000000c: afb10014 sw r17,0x0014(r29)
00000010: afb00010 sw r16,0x0010(r29)
00000014: 90f10048 lbu r17,0x0048(r7)			Caster Y
00000018: 3c02800e lui r2,0x800e
0000001c: 90424e9c lbu r2,0x4e9c(r2)			Max Map X
00000020: 00000000 nop
00000024: 02220018 mult r17,r2					Caster Y * Max X
00000028: 90e4001d lbu r4,0x001d(r7)			Caster Right hand Weapon
0000002c: 90e2005a lbu r2,0x005a(r7)			Caster Cur. Status 3
00000030: 90f00047 lbu r16,0x0047(r7)			Caster X
00000034: 30420002 andi r2,r2,0x0002			Check for Frog
00000038: 00001812 mflo r3
0000003c: 10400002 beq r2,r0,0x00000048			If Caster is Frogged
00000040: 02032821 addu r5,r16,r3				Caster Y * Max X + Caster X
00000044: 00002021 addu r4,r0,r0				Right Hand is empty
00000048: 308300ff andi r3,r4,0x00ff			Rh weapon/frog = r3
0000004c: 340200ff ori r2,r0,0x00ff
00000050: 14620006 bne r3,r2,0x0000006c			If Caster has a Rh weapon
00000054: 00000000 nop
00000058: 90e4001f lbu r4,0x001f(r7)			Caster Left Hand Weapon
0000005c: 00000000 nop
00000060: 14830003 bne r4,r3,0x00000070			If Caster has a Lh weapon
00000064: 308200ff andi r2,r4,0x00ff
00000068: 00002021 addu r4,r0,r0				Left Hand is empty
0000006c: 308200ff andi r2,r4,0x00ff			r2 = weapon
00000070: 2c420080 sltiu r2,r2,0x0080			
00000074: 14400002 bne r2,r0,0x00000080			Is item in hand a weapon?
00000078: 00051880 sll r3,r5,0x02
0000007c: 00002021 addu r4,r0,r0
00000080: 000420c0 sll r4,r4,0x03
00000084: 3c028006 lui r2,0x8006
00000088: 24423ab8 addiu r2,r2,0x3ab8			Get Weapon data
0000008c: 00822021 addu r4,r4,r2				point to weapon in hand
00000090: 00651821 addu r3,r3,r5
00000094: 3c028019 lui r2,0x8019
00000098: 24422dd8 addiu r2,r2,0x2dd8
0000009c: 00622821 addu r5,r3,r2				Get Caster tile
000000a0: 24420500 addiu r2,r2,0x0500
000000a4: 00621821 addu r3,r3,r2				Get Caster tile + 500 (high tile?)
000000a8: 34020001 ori r2,r0,0x0001
000000ac: 90880000 lbu r8,0x0000(r4)			Get Weapon Range(r8)
000000b0: 90860001 lbu r6,0x0001(r4)			Get Weapon Attack Flags(r6)
000000b4: 25040001 addiu r4,r8,0x0001			r4 = Range + 1
000000b8: a0a40000 sb r4,0x0000(r5)				Save Weapon Range to Caster Panel
000000bc: a0640000 sb r4,0x0000(r3)				Save Weapon Range to Caster Panel+
000000c0: a0a20001 sb r2,0x0001(r5)				Caster panel is targeted
000000c4: 30c200c0 andi r2,r6,0x00c0			Is Weapon Striking/Lunging?			
000000c8: 10400005 beq r2,r0,0x000000e0			Branch if false
000000cc: 00e02021 addu r4,r7,r0				Save Caster data to r4
000000d0: 0c05e6d6 jal 0x00179b58				Strike/Lunge Routine
000000d4: 00c02821 addu r5,r6,r0				Save Weapon Attack Flags
000000d8: 0805e6ce j 0x00179b38					Jump to Select Target
000000dc: 00000000 nop
000000e0: 30c20020 andi r2,r6,0x0020			If Weapon is Direct
000000e4: 10400009 beq r2,r0,0x0000010c			branch to Arc Range Routine if false
000000e8: 01002021 addu r4,r8,r0				Store Weapon Range
000000ec: 0c05e546 jal 0x00179518				Limit Range to Map Function
000000f0: 00002821 addu r5,r0,r0
000000f4: 02002021 addu r4,r16,r0				Save Caster X
000000f8: 02202821 addu r5,r17,r0				Save Caster Y
000000fc: 0c05e509 jal 0x00179424				Remove Close Range Routine
00000100: 34060002 ori r6,r0,0x0002
00000104: 0805e6ce j 0x00179b38					jump to Select Target
00000108: 00000000 nop
0000010c: 00e02021 addu r4,r7,r0				Save Caster data
00000110: 0c05e62c jal 0x001798b0				Arc Range Calculation Routine
00000114: 01002821 addu r5,r8,r0				save Weapon Range
00000118: 0c05e761 jal 0x00179d84				Can Select Target Tile Routine
0000011c: 00000000 nop
00000120: 8fbf0018 lw r31,0x0018(r29)
00000124: 8fb10014 lw r17,0x0014(r29)
00000128: 8fb00010 lw r16,0x0010(r29)
0000012c: addiu r29,r29,0x0020
00000130: jr r31
00000134: nop