Check if Unit can be Targeted
Jump to navigation
Jump to search
Parameters : r5 = previous routine stack pointer r4 = Unit ID Returns : r2 = 0x01 if unit cannot be targeted r2 = 0x00 if unit can be target (Exist, not crystal, not jumping, not treasure, not ridden) Store unit tile ID in previous routine stack pointer ------------------------------------------------------------------------------------------------------ 0017bdd0: 27bdffe0 addiu r29,r29,0xffe0 | 0017bdd4: afb00010 sw r16,0x0010(r29) | 0017bdd8: 00a08021 addu r16,r5,r0 |r16 = Stack Pointer (previous routine) 0017bddc: 000410c0 sll r2,r4,0x03 |r2 =Unit ID * 8 0017bde0: 00441023 subu r2,r2,r4 |r2 =Unit ID * 7 0017bde4: 00021180 sll r2,r2,0x06 |r2 =Unit ID * 448 (0x1c0) 0017bde8: 3c038019 lui r3,0x8019 | 0017bdec: 246308cc addiu r3,r3,0x08cc |r3 = 0x801908cc (start of unit 0x00 data) 0017bdf0: afb10014 sw r17,0x0014(r29) | 0017bdf4: 00438821 addu r17,r2,r3 |r17 = Unit's Data Pointer 0017bdf8: afbf0018 sw r31,0x0018(r29) | 0017bdfc: 0c060428 jal 0x001810a0 |-->Map Location Calculation return r2 = Unit Tile Info ( X coord. +( Y coord. * Map Max X) + elevation * 256 (= 0x00 or 0x100) 0017be00: 02202021 addu r4,r17,r0 |r4 = Unit's Data Pointer 0017be04: ae020000 sw r2,0x0000(r16) |Store Tile ID in stack pointer (previous routine) 0017be08: 92230001 lbu r3,0x0001(r17) |r3 = Unit ID 0017be0c: 340200ff ori r2,r0,0x00ff |r2 = 0xff 0017be10: 1062000f beq r3,r2,0x0017be50 #If unit exists / Else branch to End With r2 = 0x01 0017be14: 34020001 ori r2,r0,0x0001 |r2 = 0x01 0017be18: 92220058 lbu r2,0x0058(r17) |r2 = Unit's Current Statuses 1 0017be1c: 00000000 nop | 0017be20: 30420044 andi r2,r2,0x0044 |r2 <> 0x00 if unit has crystal or jump 0017be24: 1440000a bne r2,r0,0x0017be50 #If unit doesn't have crystal or jump / Else branch to End With r2 = 0x01 0017be28: 34020001 ori r2,r0,0x0001 |r2 = 0x01 0017be2c: 92220059 lbu r2,0x0059(r17) |r2 = Unit's Current Statuses 2 0017be30: 00000000 nop | 0017be34: 30420001 andi r2,r2,0x0001 |r2 = 0x01 if unit has treasure 0017be38: 14400005 bne r2,r0,0x0017be50 #If unit doesn't has treasure / Else branch to End With r2 = 0x01 0017be3c: 34020001 ori r2,r0,0x0001 |r2 = 0x01 0017be40: 92220182 lbu r2,0x0182(r17) |r2 = Unit's Mount Info 0017be44: 00000000 nop | 0017be48: 30420040 andi r2,r2,0x0040 |r2 = 0x40 if unit is being ridden / Else 0x00 0017be4c: 0002102b sltu r2,r0,r2 |r2 = 0x01 if Unit is being Ridden / Else 0x00 0017be50: 8fbf0018 lw r31,0x0018(r29) END 0017be54: 8fb10014 lw r17,0x0014(r29) 0017be58: 8fb00010 lw r16,0x0010(r29) 0017be5c: 27bd0020 addiu r29,r29,0x0020 0017be60: 03e00008 jr r31 0017be64: 00000000 nop
Return locations
0017bce4: Check_Allies/Enemies_that_can_be_Targeted 0017cba8: Reaction_Target/Hit_Calculation Store tile ID at r29 + 0x10