Check Unit for Crystal or Treasure Status
Jump to navigation
Jump to search
# ROUTINE: CHECK UNIT FOR CRYSTAL OR TREASURE STATUS ALTERNATIVE VERSION AI_Check_if_Unit_is_a_Crystal/Treasure_(0019bb20) # Parameters: (none) # Returns: RAM_BYTE[0x801a0083]: # 0, if unit is not Crystal or Treasure # 1, if unit is Crystal # 2, if unit is Treasure 0019bb20: 27bdffe8 addiu r29,r29,0xffe8 0019bb24: 3c04801a lui r4,0x801a 0019bb28: 2484f3dc addiu r4,r4,0xf3dc # 0x801af3dc: Parameter for [Find unit at coordinates] routine - points to array with format [X Coordinate, Higher Elevation bit, Y Coordinate] 0019bb2c: afbf0010 sw r31,0x0010(r29) 0019bb30: 3c01801a lui r1,0x801a 0019bb34: a0200083 sb r0,0x0083(r1) # RAM_BYTE[0x801a0083] = 0 0019bb38: 0c0674a5 jal 0x0019d294 # ROUTINE: Find unit at coordinates 0019bb3c: 00000000 nop 0019bb40: 00401821 addu r3,r2,r0 # [Unit index] = (Unit found by routine) 0019bb44: 34020015 ori r2,r0,0x0015 0019bb48: 10620018 beq r3,r2,0x0019bbac # If (no unit found), return (exit the routine) 0019bb4c: 000310c0 sll r2,r3,0x03 # [Unit index] * 8 0019bb50: 00431023 subu r2,r2,r3 # [Unit index] * 7 0019bb54: 00021180 sll r2,r2,0x06 # [Unit index] * 448 (448 == sizeof(Unit)) 0019bb58: 3c038019 lui r3,0x8019 0019bb5c: 246308cc addiu r3,r3,0x08cc # [Base pointer for unit data] 0019bb60: 00432021 addu r4,r2,r3 # [Found unit data pointer] 0019bb64: 90830001 lbu r3,0x0001(r4) # [Unit ID] 0019bb68: 340200ff ori r2,r0,0x00ff 0019bb6c: 1062000f beq r3,r2,0x0019bbac # if ([Unit ID] == 0xFF (Unit doesn't exist)), return (exit the routine) 0019bb70: 00000000 nop 0019bb74: 90820058 lbu r2,0x0058(r4) # [Current Statuses 1 byte] 0019bb78: 00000000 nop 0019bb7c: 30420040 andi r2,r2,0x0040 # Check for Crystal status 0019bb80: 10400003 beq r2,r0,0x0019bb90 # If (Unit is Crystal) { 0019bb84: 34020001 ori r2,r0,0x0001 0019bb88: 3c01801a lui r1,0x801a # RAM_BYTE[0x801a0083] = 1 0019bb8c: a0220083 sb r2,0x0083(r1) # } 0019bb90: 90820059 lbu r2,0x0059(r4) # [Current Statuses 2 byte] 0019bb94: 00000000 nop 0019bb98: 30420001 andi r2,r2,0x0001 # Check for Treasure status 0019bb9c: 10400003 beq r2,r0,0x0019bbac # If (Unit is Treasure) { 0019bba0: 34020002 ori r2,r0,0x0002 0019bba4: 3c01801a lui r1,0x801a # RAM_BYTE[0x801a0083] = 2 0019bba8: a0220083 sb r2,0x0083(r1) # } 0019bbac: 8fbf0010 lw r31,0x0010(r29) 0019bbb0: 27bd0018 addiu r29,r29,0x0018 0019bbb4: 03e00008 jr r31 0019bbb8: 00000000 nop