Difference between revisions of "Check if Linear Ability hits anything (0019c8ec)"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
m
Line 4: Line 4:
 
Note: The main routine (19b30c) that uses this routine sets r4 as 3 and r5 as 0.
 
Note: The main routine (19b30c) that uses this routine sets r4 as 3 and r5 as 0.
  
r4 = 0 = Load Range, 1 = Load AoE, 2 = Load both Range and AoE
+
r4 = Mode
 +
0 = Load Range, 1 = Load AoE, 2 = Load both Range and AoE,  X<0 or X>2 = Use Preset Range
  
 
r5 = Range/AoE/RangeAoE
 
r5 = Range/AoE/RangeAoE
Line 25: Line 26:
 
  0019c910: 00000000 nop
 
  0019c910: 00000000 nop
 
   
 
   
 +
<r4 = 0>
 
  0019c914: 10800008 beq r4,r0,0x0019c938 <Check Range> if PV = 0
 
  0019c914: 10800008 beq r4,r0,0x0019c938 <Check Range> if PV = 0
 
  0019c918: 29020010 slti r2,r8,0x0010 Set if Range/AoE < 0x0010
 
  0019c918: 29020010 slti r2,r8,0x0010 Set if Range/AoE < 0x0010
  0019c91c: 0806725d j 0x0019c974 Skip to Branch
+
  0019c91c: 0806725d j 0x0019c974 Skip to Branch and use r5
 
  0019c920: 00000000 nop
 
  0019c920: 00000000 nop
 
   
 
   
 +
<r4 = 2>
 
  0019c924: 34020002 ori r2,r0,0x0002
 
  0019c924: 34020002 ori r2,r0,0x0002
 
  0019c928: 1082000b beq r4,r2,0x0019c958 Skip to Range + AoE Check if 2
 
  0019c928: 1082000b beq r4,r2,0x0019c958 Skip to Range + AoE Check if 2
 
  0019c92c: 29020010 slti r2,r8,0x0010 Set false if Preset was less than 0x000f
 
  0019c92c: 29020010 slti r2,r8,0x0010 Set false if Preset was less than 0x000f
  0019c930: 0806725d j 0x0019c974                    Skip to Branch
+
  0019c930: 0806725d j 0x0019c974                    Skip to Branch and use r5
 
  0019c934: 00000000 nop
 
  0019c934: 00000000 nop
  

Revision as of 11:00, 27 November 2022

Check if Linear Abiilty hits anything (AI)

Note: The main routine (19b30c) that uses this routine sets r4 as 3 and r5 as 0.

r4 = Mode 0 = Load Range, 1 = Load AoE, 2 = Load both Range and AoE, X<0 or X>2 = Use Preset Range

r5 = Range/AoE/RangeAoE

Assumptions: X+ = East X- = West Y+ = North Y- = South

0019c8ec: 27bdffd8 addiu r29,r29,0xffd8
0019c8f0: 00a04021 addu r8,r5,r0					r8 = Preset
0019c8f4: 3c05801a lui r5,0x801a
0019c8f8: 24a5f3c4 addiu r5,r5,0xf3c4				r5 = Unit AI Data Pointer
0019c8fc: 34020001 ori r2,r0,0x0001
0019c900: 10820011 beq r4,r2,0x0019c948				Branch to AoE if 1
0019c904: afbf0020 sw r31,0x0020(r29)
0019c908: 28820002 slti r2,r4,0x0002
0019c90c: 10400005 beq r2,r0,0x0019c924				Branch to Next PV Check if PV > 1
0019c910: 00000000 nop

<r4 = 0>
0019c914: 10800008 beq r4,r0,0x0019c938				<Check Range> if PV = 0
0019c918: 29020010 slti r2,r8,0x0010				Set if Range/AoE < 0x0010
0019c91c: 0806725d j 0x0019c974					Skip to Branch and use r5
0019c920: 00000000 nop

<r4 = 2>
0019c924: 34020002 ori r2,r0,0x0002
0019c928: 1082000b beq r4,r2,0x0019c958				Skip to Range + AoE Check if 2
0019c92c: 29020010 slti r2,r8,0x0010				Set false if Preset was less than 0x000f
0019c930: 0806725d j 0x0019c974                     Skip to Branch and use r5
0019c934: 00000000 nop
<Range>
0019c938: 3c08801a lui r8,0x801a
0019c93c: 9108f3c8 lbu r8,-0x0c38(r8)				Load Range
0019c940: 0806725d j 0x0019c974
0019c944: 29020010 slti r2,r8,0x0010				Set if Range is less than 16
<AoE>
0019c948: 3c08801a lui r8,0x801a
0019c94c: 9108f3c9 lbu r8,-0x0c37(r8)				Load AoE
0019c950: 0806725d j 0x0019c974
0019c954: 29020010 slti r2,r8,0x0010				Set if AoE is less than 16
<AoE + Range>
0019c958: 3c03801a lui r3,0x801a
0019c95c: 9063f3c8 lbu r3,-0x0c38(r3)				Load Range
0019c960: 3c02801a lui r2,0x801a
0019c964: 9042f3c9 lbu r2,-0x0c37(r2)				Load AoE
0019c968: 00000000 nop
0019c96c: 00624021 addu r8,r3,r2					Range + AoE
0019c970: 29020010 slti r2,r8,0x0010
0019c974: 1440000c bne r2,r0,0x0019c9a8				Branch if Range + AoE combined is less than 16 (0x0010)
0019c978: 34060011 ori r6,r0,0x0011
<Set all linear panels as negative>
0019c97c: 00003021 addu r6,r0,r0					reset r6
0019c980: 3403ffff ori r3,r0,0xffff					r3 = -1
0019c984: 00a02021 addu r4,r5,r0					r4 = Unit AI Data Pointer

0019c988: a4830b4c sh r3,0x0b4c(r4)					Set (Working) Linear Panel as -1 (fail)
0019c98c: a4830b70 sh r3,0x0b70(r4)					Set (Resulting) Linear Panel as -1 (fail)
0019c990: 24c60001 addiu r6,r6,0x0001
0019c994: 28c20012 slti r2,r6,0x0012
0019c998: 1440fffb bne r2,r0,0x0019c988				Loop for all panels
0019c99c: 24840002 addiu r4,r4,0x0002				Linear Panels Flags++
0019c9a0: 080672e1 j 0x0019cb84						Exit Routine (Set Linear Flags as failed)
0019c9a4: 00000000 nop

0019c9a8: 24a20022 addiu r2,r5,0x0022
0019c9ac: a4400b4c sh r0,0x0b4c(r2)
0019c9b0: 24c6ffff addiu r6,r6,0xffff
0019c9b4: 04c1fffd bgez r6,0x0019c9ac				Reset all Panels
0019c9b8: 2442fffe addiu r2,r2,0xfffe

0019c9bc: 90a90c76 lbu r9,0x0c76(r5)				r9 = Load Caster? Y
0019c9c0: 90a40c74 lbu r4,0x0c74(r5)				r4 = Load Caster? X
0019c9c4: 0500001d bltz r8,0x0019ca3c				Branch if Range+AoE is negative
0019c9c8: 00003021 addu r6,r0,r0
<Western and Eastern Linear (X+-)>
0019c9cc: 288d0008 slti r13,r4,0x0008				Set r13 if X is less than 8
0019c9d0: 3c0a801a lui r10,0x801a
0019c9d4: 254af2f8 addiu r10,r10,0xf2f8				r10 = 0x8019f2f8
0019c9d8: 34020007 ori r2,r0,0x0007
0019c9dc: 00446023 subu r12,r2,r4					r12 = 7 - X (West)
0019c9e0: 248bfff9 addiu r11,r4,0xfff9				r11 = X - 7 (East)
0019c9e4: 01003821 addu r7,r8,r0					r7 = Range + AoE

0019c9e8: 01261023 subu r2,r9,r6					Y - Counter
0019c9ec: 04400013 bltz r2,0x0019ca3c				Y Cap, branch to RangeAoE check
0019c9f0: 00000000 nop
0019c9f4: 11a00007 beq r13,r0,0x0019ca14			X Cap, branch to Eastern check
0019c9f8: 00071840 sll r3,r7,0x01					r3 = Range+AoE * 2
<Western Linear Target Offset>
0019c9fc: 00021040 sll r2,r2,0x01					Y * 2
0019ca00: 006a1821 addu r3,r3,r10					X Offset
0019ca04: 94630000 lhu r3,0x0000(r3)				Load X Panel 
0019ca08: 00451021 addu r2,r2,r5					Current Panel address
0019ca0c: 0806728a j 0x0019ca28						
0019ca10: 01831804 sllv r3,r3,r12					Get Panel offset of Western Target
<Eastern Linear Target Offset>
0019ca14: 00021040 sll r2,r2,0x01					Y * 2
0019ca18: 006a1821 addu r3,r3,r10					X Offset
0019ca1c: 94630000 lhu r3,0x0000(r3)				Load X Panel
0019ca20: 00451021 addu r2,r2,r5					Current Panel Address
0019ca24: 01631807 srav r3,r3,r11					Get Panel offset of Eastern Target
<W/E Loop End>
0019ca28: a4430b4c sh r3,0x0b4c(r2)					Save to Linear Panel Flags
0019ca2c: 24c60001 addiu r6,r6,0x0001				Linear Counter++
0019ca30: 0106102a slt r2,r8,r6						
0019ca34: 1040ffec beq r2,r0,0x0019c9e8				Loop for all targets in Linear
0019ca38: 24e7ffff addiu r7,r7,0xffff				RangeAoE--

0019ca3c: 1900001f blez r8,0x0019cabc				<Linear Check> if Range+AoE is zero or negative
0019ca40: 34060001 ori r6,r0,0x0001					r6 = 1
<North and South Linear (Y+-)>
0019ca44: 288c0008 slti r12,r4,0x0008 				Set r12 if Y is less than 8
0019ca48: 3c07801a lui r7,0x801a
0019ca4c: 24e7f2f8 addiu r7,r7,0xf2f8				r7 = 0x8019f2f8
0019ca50: 34020007 ori r2,r0,0x0007
0019ca54: 00445823 subu r11,r2,r4					r11 = 7 - Y (North)
0019ca58: 248afff9 addiu r10,r4,0xfff9				r10 = Y - 7 (South)
0019ca5c: 2504ffff addiu r4,r8,0xffff				r4 = RangeAoe - 1 (?)

0019ca60: 90a20e3b lbu r2,0x0e3b(r5)				Load Max Y
0019ca64: 01261821 addu r3,r9,r6					r3 = Caster Y + 1
0019ca68: 0062102a slt r2,r3,r2
0019ca6c: 10400013 beq r2,r0,0x0019cabc				<Linear Check> if Caster Y > Max Y
0019ca70: 00000000 nop
0019ca74: 11800007 beq r12,r0,0x0019ca94			<Southern Linear Target Offset> if Y < 8
0019ca78: 00031040 sll r2,r3,0x01					Caster Y * 2
<Northern Linear Target Offset>
0019ca7c: 00041840 sll r3,r4,0x01
0019ca80: 00671821 addu r3,r3,r7
0019ca84: 94630000 lhu r3,0x0000(r3)				Load Y
0019ca88: 00451021 addu r2,r2,r5
0019ca8c: 080672aa j 0x0019caa8						Jump to N/S Loop End
0019ca90: 01631804 sllv r3,r3,r11					r3 = Y >> 7-Y (North)
<Southern Linear Target Offset>
0019ca94: 00041840 sll r3,r4,0x01					RangeAoE * 2
0019ca98: 00671821 addu r3,r3,r7
0019ca9c: 94630000 lhu r3,0x0000(r3)				Load Y
0019caa0: 00451021 addu r2,r2,r5
0019caa4: 01431807 srav r3,r3,r10					r3 = Y >> Y-7 (South)
<N/S Loop End>
0019caa8: a4430b4c sh r3,0x0b4c(r2)					Save Y Offset
0019caac: 24c60001 addiu r6,r6,0x0001
0019cab0: 0106102a slt r2,r8,r6
0019cab4: 1040ffea beq r2,r0,0x0019ca60				Loop for all cells in Linear Range
0019cab8: 2484ffff addiu r4,r4,0xffff				X Counter--
<Linear Check>
0019cabc: 8ca2000c lw r2,0x000c(r5)					Load AI Flags
0019cac0: 3c030020 lui r3,0x0020
0019cac4: 00431024 and r2,r2,r3
0019cac8: 1040002a beq r2,r0,0x0019cb74				<Exit> if not Linear
0019cacc: 00000000 nop

0019cad0: 90a20e3b lbu r2,0x0e3b(r5)				Load Max Y
0019cad4: 00000000 nop
0019cad8: 18400026 blez r2,0x0019cb74				<Exit> if Max Y is negative
0019cadc: 00004821 addu r9,r0,r0
0019cae0: 340a8000 ori r10,r0,0x8000				r10 = 0x8000
0019cae4: 00a04021 addu r8,r5,r0					r8 = Offset
<Y Loop>
0019cae8: 95060b4c lhu r6,0x0b4c(r8)				Load Panel Offset?
0019caec: 00000000 nop
0019caf0: 10c0001b beq r6,r0,0x0019cb60				Next if no panel
0019caf4: 00000000 nop
0019caf8: 90a20e3a lbu r2,0x0e3a(r5)				Load Max X
0019cafc: 00000000 nop
0019cb00: 18400017 blez r2,0x0019cb60				Y++ if Max X is negative
0019cb04: 00002021 addu r4,r0,r0
0019cb08: 01003821 addu r7,r8,r0
0019cb0c: 00861004 sllv r2,r6,r4
<X Loop>
0019cb10: 30428000 andi r2,r2,0x8000
0019cb14: 1040000d beq r2,r0,0x0019cb4c				<X++> if cell doesn't have a targetable unit
0019cb18: 00000000 nop
0019cb1c: 90a20c74 lbu r2,0x0c74(r5)				Load Caster? X
0019cb20: 00000000 nop
0019cb24: 10820009 beq r4,r2,0x0019cb4c				<X++> if current X
0019cb28: 00000000 nop
0019cb2c: 90a20c76 lbu r2,0x0c76(r5)				Load Caster? Y
0019cb30: 00000000 nop
0019cb34: 11220005 beq r9,r2,0x0019cb4c				<X++> if current Y

0019cb38: 008a1807 srav r3,r10,r4					0x8000 >> X
0019cb3c: 94e20b4c lhu r2,0x0b4c(r7)				Load Linear Panel Flag
0019cb40: 00000000 nop
0019cb44: 00431026 xor r2,r2,r3						Unflag all panels that are not in the Linear path
0019cb48: a4e20b4c sh r2,0x0b4c(r7)					Save to Linear Panel Flag
<X++>
0019cb4c: 90a20e3a lbu r2,0x0e3a(r5)				Load Max X
0019cb50: 24840001 addiu r4,r4,0x0001				X++
0019cb54: 0082102a slt r2,r4,r2
0019cb58: 1440ffed bne r2,r0,0x0019cb10				Loop until Max X
0019cb5c: 00861004 sllv r2,r6,r4
<Y++>
0019cb60: 90a20e3b lbu r2,0x0e3b(r5)				Load Max Y
0019cb64: 25290001 addiu r9,r9,0x0001				Y++
0019cb68: 0122102a slt r2,r9,r2
0019cb6c: 1440ffde bne r2,r0,0x0019cae8				Loop until Max Y
0019cb70: 25080002 addiu r8,r8,0x0002
<Exit>
0019cb74: 24a40b70 addiu r4,r5,0x0b70
0019cb78: 24a50b4c addiu r5,r5,0x0b4c
0019cb7c: 0c066ac2 jal 0x0019ab08					Transfer Halfword Values
0019cb80: 34060024 ori r6,r0,0x0024
0019cb84: 8fbf0020 lw r31,0x0020(r29)
0019cb88: 27bd0028 addiu r29,r29,0x0028
0019cb8c: 03e00008 jr r31
0019cb90: 00000000 nop