Check if another unit is on the same Tile

From Final Fantasy Hacktics Wiki
Revision as of 20:21, 2 December 2021 by Orkney (talk | contribs) (Add duplicated link)
Jump to navigation Jump to search
Duplicated here Find_Unit_at_Specified_Coordinates
----------------------------------------------------------------
0017dca8: 27bdffd0 addiu r29,r29,0xffd0
0017dcac: afb40020 sw r20,0x0020(r29)
0017dcb0: 0080a021 addu r20,r4,r0		r20 = Unit's X Coordinate
0017dcb4: afb50024 sw r21,0x0024(r29)
0017dcb8: 00a0a821 addu r21,r5,r0		r21 = Unit's Y Coordinate
0017dcbc: afb60028 sw r22,0x0028(r29)
0017dcc0: 00c0b021 addu r22,r6,r0		r22 = Unit's Map Level
0017dcc4: afb20018 sw r18,0x0018(r29)
0017dcc8: 00e09021 addu r18,r7,r0		r18 = Preset Value
0017dccc: afbf002c sw r31,0x002c(r29)
0017dcd0: afb3001c sw r19,0x001c(r29)
0017dcd4: afb10014 sw r17,0x0014(r29)
0017dcd8: 0680002c bltz r20,0x0017dd8c		Branch if Unit's X Coordinate < 0
0017dcdc: afb00010 sw r16,0x0010(r29)
0017dce0: 3c03800e lui r3,0x800e
0017dce4: 90634e9c lbu r3,0x4e9c(r3)		Load Map Max X Coordinate
0017dce8: 00000000 nop
0017dcec: 0283102a slt r2,r20,r3
0017dcf0: 10400026 beq r2,r0,0x0017dd8c		Branch if X Coordinate >= Max X
0017dcf4: 00000000 nop
0017dcf8: 06a0006a bltz r21,0x0017dea4		Branch if Y Coordinate < 0
0017dcfc: 2402fffe addiu r2,r0,0xfffe		r2 = -2
0017dd00: 3c02800e lui r2,0x800e
0017dd04: 90424ea0 lbu r2,0x4ea0(r2)		Load Map Max Y Coordinate
0017dd08: 00000000 nop
0017dd0c: 02a2102a slt r2,r21,r2
0017dd10: 1040001e beq r2,r0,0x0017dd8c		Branch if Y Coordinate >= Max Y
0017dd14: 2ec20002 sltiu r2,r22,0x0002
0017dd18: 1040001c beq r2,r0,0x0017dd8c		Branch if Unit's Map Level >= 2
0017dd1c: 02a30018 mult r21,r3			Max X * Y
0017dd20: 00161200 sll r2,r22,0x08		Map Level * 0x100
0017dd24: 00001812 mflo r3			r3 = Max X * Y
0017dd28: 00431021 addu r2,r2,r3		Y Mod = Max X * Y + Map Level * 0x100
0017dd2c: 00541021 addu r2,r2,r20		Tile ID = Y Mod + X
0017dd30: 000210c0 sll r2,r2,0x03		Tile ID * 8
0017dd34: 3c038019 lui r3,0x8019
0017dd38: 2463f8cc addiu r3,r3,0xf8cc
0017dd3c: 00431821 addu r3,r2,r3
0017dd40: 90620006 lbu r2,0x0006(r3)		Load misc. Tile Data
0017dd44: 00000000 nop
0017dd48: 30420003 andi r2,r2,0x0003
0017dd4c: 14400055 bne r2,r0,0x0017dea4		Branch if Tile is unable to be selected
0017dd50: 2402fffe addiu r2,r0,0xfffe		r2 = -2
0017dd54: 30e20002 andi r2,r7,0x0002
0017dd58: 10400010 beq r2,r0,0x0017dd9c		Branch if Check isn't Slope
0017dd5c: 00008821 addu r17,r0,r0		Counter = 0
0017dd60: 90620003 lbu r2,0x0003(r3)		Load Tile Height (slope + Depth)
0017dd64: 00000000 nop
0017dd68: 304200e0 andi r2,r2,0x00e0
0017dd6c: 1440004d bne r2,r0,0x0017dea4		Branch if Tile has water
0017dd70: 2402fffe addiu r2,r0,0xfffe		r2 = -2
0017dd74: 90620003 lbu r2,0x0003(r3)		Load Tile Height (slope + Depth)
0017dd78: 00000000 nop
0017dd7c: 3042001f andi r2,r2,0x001f		Leave only slope
0017dd80: 28420003 slti r2,r2,0x0003
0017dd84: 14400006 bne r2,r0,0x0017dda0		Branch if slope < 3
0017dd88: 00009821 addu r19,r0,r0		Unit Counter = 0
0017dd8c: 0805f7a9 j 0x0017dea4
0017dd90: 2402fffe addiu r2,r0,0xfffe		r2 = -2
0017dd94: 0805f7a9 j 0x0017dea4
0017dd98: 3082001f andi r2,r4,0x001f		r2 = Mount ID
0017dd9c: 00009821 addu r19,r0,r0		Unit Counter = 0
0017dda0: 3c028019 lui r2,0x8019
0017dda4: 244208cc addiu r2,r2,0x08cc
0017dda8: 02628021 addu r16,r19,r2
0017ddac: 92030001 lbu r3,0x0001(r16)		Load Unit's Unit ID
0017ddb0: 340200ff ori r2,r0,0x00ff		r2 = FF
0017ddb4: 10620036 beq r3,r2,0x0017de90		Branch if Unit doesn't exist
0017ddb8: 32420051 andi r2,r18,0x0051
0017ddbc: 10400018 beq r2,r0,0x0017de20		Branch if Check isn't Cryst/Trans/Treas
0017ddc0: 32420040 andi r2,r18,0x0040
0017ddc4: 10400007 beq r2,r0,0x0017dde4		Branch if Check isn't Crystal
0017ddc8: 32420001 andi r2,r18,0x0001
0017ddcc: 92020058 lbu r2,0x0058(r16)		Load Unit's Current Statuses 1
0017ddd0: 00000000 nop
0017ddd4: 30420040 andi r2,r2,0x0040
0017ddd8: 14400012 bne r2,r0,0x0017de24		Branch if Unit has Crystal
0017dddc: 32420080 andi r2,r18,0x0080
0017dde0: 32420001 andi r2,r18,0x0001
0017dde4: 10400007 beq r2,r0,0x0017de04		Branch if Check isn't Treasure
0017dde8: 32420010 andi r2,r18,0x0010
0017ddec: 92020059 lbu r2,0x0059(r16)		Load Unit's Current Statuses 2
0017ddf0: 00000000 nop
0017ddf4: 30420001 andi r2,r2,0x0001
0017ddf8: 1440000a bne r2,r0,0x0017de24		Branch if Unit has Treasure
0017ddfc: 32420080 andi r2,r18,0x0080
0017de00: 32420010 andi r2,r18,0x0010
0017de04: 10400022 beq r2,r0,0x0017de90		Branch if Check isn't Transparent
0017de08: 00000000 nop
0017de0c: 9202005a lbu r2,0x005a(r16)		Load Unit's Current Statuses 3
0017de10: 00000000 nop
0017de14: 30420010 andi r2,r2,0x0010
0017de18: 1040001d beq r2,r0,0x0017de90		Branch if Unit doesn't have Transparent
0017de1c: 00000000 nop
0017de20: 32420080 andi r2,r18,0x0080
0017de24: 10400005 beq r2,r0,0x0017de3c		Branch if Check isn't Chocobo
0017de28: 00000000 nop
0017de2c: 0c05d0f2 jal 0x001743c8		Check if Unit can be Mounted
0017de30: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0017de34: 10400016 beq r2,r0,0x0017de90		Branch if Unit isn't Mountable
0017de38: 00000000 nop
0017de3c: 92020047 lbu r2,0x0047(r16)		Load Unit's X Coordinate
0017de40: 00000000 nop
0017de44: 14540012 bne r2,r20,0x0017de90	Branch if X != Moving Unit's X
0017de48: 00000000 nop
0017de4c: 92020048 lbu r2,0x0048(r16)		Load Unit's Y Coordinate
0017de50: 00000000 nop
0017de54: 1455000e bne r2,r21,0x0017de90	Branch if Y != Moving Unit's Y
0017de58: 00000000 nop
0017de5c: 96020048 lhu r2,0x0048(r16)		Load Unit's Y + Map Level/Facing
0017de60: 00000000 nop
0017de64: 000213c2 srl r2,r2,0x0f		Y Data / 0x8000 (Map Level)
0017de68: 14560009 bne r2,r22,0x0017de90	Branch if Map Level != Map Level
0017de6c: 00000000 nop
0017de70: 92040182 lbu r4,0x0182(r16)		Load Unit's Mount Data
0017de74: 00000000 nop
0017de78: 308200ff andi r2,r4,0x00ff
0017de7c: 2c420080 sltiu r2,r2,0x0080
0017de80: 1040ffc4 beq r2,r0,0x0017dd94		Branch if Riding a Unit is present
0017de84: 02201021 addu r2,r17,r0		r2 = Counter
0017de88: 0805f7a9 j 0x0017dea4
0017de8c: 00000000 nop
0017de90: 26310001 addiu r17,r17,0x0001		Counter ++
0017de94: 2a220015 slti r2,r17,0x0015
0017de98: 1440ffc1 bne r2,r0,0x0017dda0		Branch if Counter < 21
0017de9c: 267301c0 addiu r19,r19,0x01c0		Unit Data Pointer += 0x1c0
0017dea0: 2402ffff addiu r2,r0,0xffff		r2 = -1 (unit doesn't exist)
0017dea4: 8fbf002c lw r31,0x002c(r29)
0017dea8: 8fb60028 lw r22,0x0028(r29)
0017deac: 8fb50024 lw r21,0x0024(r29)
0017deb0: 8fb40020 lw r20,0x0020(r29)
0017deb4: 8fb3001c lw r19,0x001c(r29)
0017deb8: 8fb20018 lw r18,0x0018(r29)
0017debc: 8fb10014 lw r17,0x0014(r29)
0017dec0: 8fb00010 lw r16,0x0010(r29)
0017dec4: 27bd0030 addiu r29,r29,0x0030
0017dec8: 03e00008 jr r31
0017decc: 00000000 nop