Targeting routine

From Final Fantasy Hacktics Wiki
Revision as of 14:28, 18 April 2013 by Choto (talk | contribs)
Jump to navigation Jump to search
Targeting routine:
0017b874: 27bdffb8 addiu r29,r29,0xffb8
0017b878: 27a50010 addiu r5,r29,0x0010
0017b87c: afbf0040 sw r31,0x0040(r29)
0017b880: afb5003c sw r21,0x003c(r29)
0017b884: afb40038 sw r20,0x0038(r29)
0017b888: afb30034 sw r19,0x0034(r29)
0017b88c: afb20030 sw r18,0x0030(r29)
0017b890: afb1002c sw r17,0x002c(r29)
0017b894: 0c01788b jal 0x0005e22c
0017b898: afb00028 sw r16,0x0028(r29)
0017b89c: 3c058019 lui r5,0x8019
0017b8a0: 24a508cc addiu r5,r5,0x08cc
0017b8a4: 87a20012 lh r2,0x0012(r29)           load used ability ID
0017b8a8: 93b40010 lbu r20,0x0010(r29)         load unit ID
0017b8ac: 000218c0 sll r3,r2,0x03
0017b8b0: 00621823 subu r3,r3,r2
0017b8b4: 00031840 sll r3,r3,0x01
0017b8b8: 3c028006 lui r2,0x8006
0017b8bc: 2442fbf0 addiu r2,r2,0xfbf0          ability data
0017b8c0: 00621821 addu r3,r3,r2
0017b8c4: 001410c0 sll r2,r20,0x03
0017b8c8: 00541023 subu r2,r2,r20
0017b8cc: 00021180 sll r2,r2,0x06
0017b8d0: 90690003 lbu r9,0x0003(r3)		ability flags 1
0017b8d4: 90710004 lbu r17,0x0004(r3)		ability flags 2
0017b8d8: 90640006 lbu r4,0x0006(r3)		ability flags 4
0017b8dc: 90730001 lbu r19,0x0001(r3)		load aoe
0017b8e0: 90750002 lbu r21,0x0002(r3)		load verticle
0017b8e4: 30840020 andi r4,r4,0x0020		
0017b8e8: 10800003 beq r4,r0,0x0017b8f8		branch  if not direct attack
0017b8ec: 00458021 addu r16,r2,r5		r16 =  unit data pointer
0017b8f0: 35290020 ori r9,r9,0x0020		r9 = 20
0017b8f4: 32310039 andi r17,r17,0x0039		Check all flags under hit allies
If not direct attack
0017b8f8: 32220006 andi r2,r17,0x0006		Check linear flag
0017b8fc: 10400006 beq r2,r0,0x0017b918	Branch if not linear
0017b900: 34020006 ori r2,r0,0x0006		r2= 06
If linear
0017b904: 92050047 lbu r5,0x0047(r16)		load x coordinate
0017b908: 96020048 lhu r2,0x0048(r16)		load y coordinate
0017b90c: 92040048 lbu r4,0x0048(r16)		load y coordinate
0017b910: 0805ee59 j 0x0017b964		skip following routine
0017b914: 00021bc2 srl r3,r2,0x0f		r3= Map Level?
If not linear
0017b918: 93a3001a lbu r3,0x001a(r29)		load target Y coordinate?
0017b91c: 00000000 nop
0017b920: 10620006 beq r3,r2,0x0017b93c	branch if target y = caster y
0017b924: 00000000 nop
0017b928: 93a5001c lbu r5,0x001c(r29)		load target x
0017b92c: 93a40020 lbu r4,0x0020(r29)		load target y
0017b930: 93a3001e lbu r3,0x001e(r29)		load ?
0017b934: 0805ee59 j 0x0017b964			
0017b938: 00000000 nop
0017b93c: 93a2001b lbu r2,0x001b(r29)		load ?
0017b940: 00000000 nop
0017b944: 000218c0 sll r3,r2,0x03
0017b948: 00621823 subu r3,r3,r2
0017b94c: 00031980 sll r3,r3,0x06
0017b950: 00651821 addu r3,r3,r5
0017b954: 90650047 lbu r5,0x0047(r3)		load caster x
0017b958: 94620048 lhu r2,0x0048(r3)		load caster y
0017b95c: 90640048 lbu r4,0x0048(r3)		load caster y
0017b960: 00021bc2 srl r3,r2,0x0f		caster y/2^0f?
0017b964: 3c06800e lui r6,0x800e
0017b968: 90c64e9c lbu r6,0x4e9c(r6)		map max x
0017b96c: 00000000 nop	
0017b970: 00a6102a slt r2,r5,r6			set if caster x < max x??
0017b974: 104000b6 beq r2,r0,0x0017bc50		skip to end if not
0017b978: 2402ffff addiu r2,r0,0xffff		
0017b97c: 3c02800e lui r2,0x800e
0017b980: 90424ea0 lbu r2,0x4ea0(r2)		load max y?
0017b984: 00000000 nop
0017b988: 0082102a slt r2,r4,r2			set if caster y < max y??
0017b98c: 10400010 beq r2,r0,0x0017b9d0		skip to end if not	
0017b990: 28620002 slti r2,r3,0x0002		set if caster y/2^0f < 02
0017b994: 1040000e beq r2,r0,0x0017b9d0		skip to end if not?
0017b998: 00860018 mult r4,r6
0017b99c: 00031200 sll r2,r3,0x08
0017b9a0: 00001812 mflo r3
0017b9a4: 00431021 addu r2,r2,r3
0017b9a8: 00453021 addu r6,r2,r5
0017b9ac: 000618c0 sll r3,r6,0x03		
0017b9b0: 3c028019 lui r2,0x8019
0017b9b4: 2442f8cc addiu r2,r2,0xf8cc		load tile data start
0017b9b8: 00622821 addu r5,r3,r2
0017b9bc: 90a20006 lbu r2,0x0006(r5)		load byte at 8018f8cc + 2B8 (20)
0017b9c0: 00000000 nop
0017b9c4: 30420001 andi r2,r2,0x0001		
0017b9c8: 10400003 beq r2,r0,0x0017b9d8		jump if tile isn't unselectable via  cursor
0017b9cc: 00000000 nop
0017b9d0: 0805ef14 j 0x0017bc50			else skip to end
0017b9d4: 2402ffff addiu r2,r0,0xffff
0017b9d8: 90a40002 lbu r4,0x0002(r5)		load tile height
0017b9dc: 90a30003 lbu r3,0x0003(r5)		load depth
0017b9e0: 90a20003 lbu r2,0x0003(r5)		load depth
0017b9e4: 00042040 sll r4,r4,0x01		height*2
0017b9e8: 3063001f andi r3,r3,0x001f		set if depth flag = 1f? (never)
0017b9ec: 00832021 addu r4,r4,r3		r4 = (height*2) + 0?
0017b9f0: 00021142 srl r2,r2,0x05		depth/2^5
0017b9f4: 00021040 sll r2,r2,0x01		depth*2
0017b9f8: 00829021 addu r18,r4,r2		
0017b9fc: 326300ff andi r3,r19,0x00ff		?dunno what r19 is, 01 in this case
0017ba00: 340200ff ori r2,r0,0x00ff		
0017ba04: 1462000c bne r3,r2,0x0017ba38		?
0017ba08: 00002021 addu r4,r0,r0		
0017ba0c: 34050001 ori r5,r0,0x0001		
0017ba10: 3c038019 lui r3,0x8019		
0017ba14: 24632dd8 addiu r3,r3,0x2dd8		
0017ba18: a0650000 sb r5,0x0000(r3)
0017ba1c: a0600001 sb r0,0x0001(r3)
0017ba20: 24840001 addiu r4,r4,0x0001
0017ba24: 28820200 slti r2,r4,0x0200		loop runs 200 times?
0017ba28: 1440fffb bne r2,r0,0x0017ba18
0017ba2c: 24630005 addiu r3,r3,0x0005
0017ba30: 0805eebf j 0x0017bafc			skip big following routine
0017ba34: 00000000 nop
0017ba38: 3c038019 lui r3,0x8019
0017ba3c: 24632dd8 addiu r3,r3,0x2dd8		
0017ba40: a0600000 sb r0,0x0000(r3)
0017ba44: a0600001 sb r0,0x0001(r3)
0017ba48: 24840001 addiu r4,r4,0x0001
0017ba4c: 28820200 slti r2,r4,0x0200
0017ba50: 1440fffb bne r2,r0,0x0017ba40		loop runs 200 times, clearing every 5th byte starting at 80192dd8
0017ba54: 24630005 addiu r3,r3,0x0005
0017ba58: 00061080 sll r2,r6,0x02
0017ba5c: 00461821 addu r3,r2,r6
0017ba60: 3c048019 lui r4,0x8019
0017ba64: 24842dd8 addiu r4,r4,0x2dd8
0017ba68: 00644021 addu r8,r3,r4
0017ba6c: 26620001 addiu r2,r19,0x0001
0017ba70: a1020000 sb r2,0x0000(r8)
0017ba74: 28c20100 slti r2,r6,0x0100
0017ba78: 10400005 beq r2,r0,0x0017ba90
0017ba7c: 24820500 addiu r2,r4,0x0500
0017ba80: 00623821 addu r7,r3,r2
0017ba84: 34020001 ori r2,r0,0x0001
0017ba88: 0805eea8 j 0x0017baa0
0017ba8c: a1020001 sb r2,0x0001(r8)
0017ba90: 2482fb00 addiu r2,r4,0xfb00
0017ba94: 00623821 addu r7,r3,r2
0017ba98: 34020001 ori r2,r0,0x0001
0017ba9c: a0e20001 sb r2,0x0001(r7)
0017baa0: 30c300ff andi r3,r6,0x00ff
0017baa4: 00031080 sll r2,r3,0x02
0017baa8: 00431021 addu r2,r2,r3
0017baac: 34030001 ori r3,r0,0x0001
0017bab0: 3c018019 lui r1,0x8019
0017bab4: 00220821 addu r1,r1,r2
0017bab8: a0232dd9 sb r3,0x2dd9(r1)
0017babc: 31220020 andi r2,r9,0x0020
0017bac0: 1440000e bne r2,r0,0x0017bafc
0017bac4: 02602021 addu r4,r19,r0
0017bac8: 00002821 addu r5,r0,r0
0017bacc: 26620001 addiu r2,r19,0x0001
0017bad0: a1020000 sb r2,0x0000(r8)
0017bad4: 0c05e546 jal 0x00179518
0017bad8: a0e20000 sb r2,0x0000(r7)
0017badc: 324400ff andi r4,r18,0x00ff
0017bae0: 02a02821 addu r5,r21,r0
0017bae4: 00113142 srl r6,r17,0x05
0017bae8: 0c05e4a9 jal 0x001792a4
0017baec: 30c60001 andi r6,r6,0x0001
0017baf0: 87a40012 lh r4,0x0012(r29)
0017baf4: 0c05e481 jal 0x00179204
0017baf8: 00000000 nop
0017bafc: 0c060428 jal 0x001810a0
0017bb00: 02002021 addu r4,r16,r0
0017bb04: 00021880 sll r3,r2,0x02
0017bb08: 00621821 addu r3,r3,r2
0017bb0c: 3c128019 lui r18,0x8019
0017bb10: 26522dd8 addiu r18,r18,0x2dd8
0017bb14: 32220001 andi r2,r17,0x0001
0017bb18: 10400002 beq r2,r0,0x0017bb24
0017bb1c: 00721821 addu r3,r3,r18
0017bb20: a0600000 sb r0,0x0000(r3)
0017bb24: 32220004 andi r2,r17,0x0004
0017bb28: 10400003 beq r2,r0,0x0017bb38
0017bb2c: 27a40010 addiu r4,r29,0x0010
0017bb30: 0c05ef9a jal 0x0017be68
0017bb34: 34050001 ori r5,r0,0x0001
0017bb38: 32220002 andi r2,r17,0x0002
0017bb3c: 10400004 beq r2,r0,0x0017bb50
0017bb40: 323000c0 andi r16,r17,0x00c0
0017bb44: 27a40010 addiu r4,r29,0x0010
0017bb48: 0c05ef9a jal 0x0017be68
0017bb4c: 34050003 ori r5,r0,0x0003
0017bb50: 12000006 beq r16,r0,0x0017bb6c
0017bb54: 02802021 addu r4,r20,r0
0017bb58: 32250080 andi r5,r17,0x0080
0017bb5c: 32260040 andi r6,r17,0x0040
0017bb60: 3a6700ff xori r7,r19,0x00ff
0017bb64: 0c05ef1e jal 0x0017bc78
0017bb68: 2ce70001 sltiu r7,r7,0x0001
0017bb6c: 1600001d bne r16,r0,0x0017bbe4
0017bb70: 00003021 addu r6,r0,r0
0017bb74: 00002021 addu r4,r0,r0
0017bb78: 02402821 addu r5,r18,r0
0017bb7c: 3c038019 lui r3,0x8019
0017bb80: 2463f8cc addiu r3,r3,0xf8cc
0017bb84: 90a20000 lbu r2,0x0000(r5)
0017bb88: 00000000 nop
0017bb8c: 1040000a beq r2,r0,0x0017bbb8
0017bb90: 00000000 nop
0017bb94: 90620006 lbu r2,0x0006(r3)
0017bb98: 00000000 nop
0017bb9c: 30420003 andi r2,r2,0x0003
0017bba0: 14400005 bne r2,r0,0x0017bbb8
0017bba4: 00000000 nop
0017bba8: 90620005 lbu r2,0x0005(r3)
0017bbac: 24c60001 addiu r6,r6,0x0001
0017bbb0: 0805eef1 j 0x0017bbc4
0017bbb4: 34420080 ori r2,r2,0x0080
0017bbb8: 90620005 lbu r2,0x0005(r3)
0017bbbc: 00000000 nop
0017bbc0: 3042007f andi r2,r2,0x007f
0017bbc4: a0620005 sb r2,0x0005(r3)
0017bbc8: 24a50005 addiu r5,r5,0x0005
0017bbcc: 24840001 addiu r4,r4,0x0001
0017bbd0: 28820200 slti r2,r4,0x0200
0017bbd4: 1440ffeb bne r2,r0,0x0017bb84
0017bbd8: 24630008 addiu r3,r3,0x0008
0017bbdc: 0805ef14 j 0x0017bc50
0017bbe0: 00c01021 addu r2,r6,r0
0017bbe4: 00002021 addu r4,r0,r0
0017bbe8: 02402821 addu r5,r18,r0
0017bbec: 3c038019 lui r3,0x8019
0017bbf0: 2463f8cc addiu r3,r3,0xf8cc
0017bbf4: 90a20001 lbu r2,0x0001(r5)
0017bbf8: 00000000 nop
0017bbfc: 1040000a beq r2,r0,0x0017bc28
0017bc00: 00000000 nop
0017bc04: 90620006 lbu r2,0x0006(r3)
0017bc08: 00000000 nop
0017bc0c: 30420003 andi r2,r2,0x0003
0017bc10: 14400005 bne r2,r0,0x0017bc28
0017bc14: 00000000 nop
0017bc18: 90620005 lbu r2,0x0005(r3)
0017bc1c: 24c60001 addiu r6,r6,0x0001
0017bc20: 0805ef0d j 0x0017bc34
0017bc24: 34420080 ori r2,r2,0x0080
0017bc28: 90620005 lbu r2,0x0005(r3)
0017bc2c: 00000000 nop
0017bc30: 3042007f andi r2,r2,0x007f
0017bc34: a0620005 sb r2,0x0005(r3)
0017bc38: 24a50005 addiu r5,r5,0x0005
0017bc3c: 24840001 addiu r4,r4,0x0001
0017bc40: 28820200 slti r2,r4,0x0200
0017bc44: 1440ffeb bne r2,r0,0x0017bbf4
0017bc48: 24630008 addiu r3,r3,0x0008
0017bc4c: 00c01021 addu r2,r6,r0
0017bc50: 8fbf0040 lw r31,0x0040(r29)
0017bc54: 8fb5003c lw r21,0x003c(r29)
0017bc58: 8fb40038 lw r20,0x0038(r29)
0017bc5c: 8fb30034 lw r19,0x0034(r29)
0017bc60: 8fb20030 lw r18,0x0030(r29)
0017bc64: 8fb1002c lw r17,0x002c(r29)
0017bc68: 8fb00028 lw r16,0x0028(r29)
0017bc6c: 27bd0048 addiu r29,r29,0x0048
0017bc70: 03e00008 jr r31
0017bc74: 00000000 nop


Return Locations

0017ac38: - Routine at 17aaf8