Warp Unit
Jump to navigation
Jump to search
# ROUTINE: WarpUnit Event Instruction # Parameters: # r4 = (params) Parameter array for this event instruction # Offsets: # 0x00: ENTD Unit ID (2 bytes) # 0x02: X Coordinate (1 byte) # 0x03: Y Coordinate (1 byte) # 0x04: Higher Elevation (1 byte) # 0x05: Facing Direction (1 byte) 80147e60: 27bdffd0 addiu r29,r29,-0x0030 80147e64: afb20028 sw r18,0x0028(r29) 80147e68: 00809021 addu r18,r4,r0 80147e6c: afbf002c sw r31,0x002c(r29) 80147e70: afb10024 sw r17,0x0024(r29) 80147e74: 0c05181e jal 0x80146078 # UnitID = Load Halfword (params.UnitID); 80147e78: afb00020 sw r16,0x0020(r29) 80147e7c: 26520002 addiu r18,r18,0x0002 # params + 2 80147e80: 00021400 sll r2,r2,0x10 80147e84: 00022403 sra r4,r2,0x10 80147e88: 0c060324 jal 0x80180c90 # unitData = Find Unit Data Pointer For ENTD Unit ID (UnitID, resultCodePtr); 80147e8c: 27a50018 addiu r5,r29,0x0018 80147e90: 00408821 addu r17,r2,r0 # unitData 80147e94: 8fa30018 lw r3,0x0018(r29) # resultCode = *resultCodePtr 80147e98: 2402fffe addiu r2,r0,-0x0002 # -2 80147e9c: 10620003 beq r3,r2,0x80147eac 80147ea0: 00008021 addu r16,r0,r0 # unitIndex = 0 80147ea4: 0460003a bltz r3,0x80147f90 # if ((resultCode != -2) and (resultCode < 0)) return; 80147ea8: 00000000 nop # do { 80147eac: 0c0602bf jal 0x80180afc # tempUnitData = Get Unit's Data Pointer (unitIndex) 80147eb0: 02002021 addu r4,r16,r0 80147eb4: 10510005 beq r2,r17,0x80147ecc # if (tempUnitData == unitData) break; 80147eb8: 00000000 nop 80147ebc: 26100001 addiu r16,r16,0x0001 # unitIndex = unitIndex + 1 80147ec0: 2a020015 slti r2,r16,0x0015 80147ec4: 1440fff9 bne r2,r0,0x80147eac # } while (unitIndex < 21) 80147ec8: 00000000 nop 80147ecc: 92420000 lbu r2,0x0000(r18) # params.X 80147ed0: 00000000 nop 80147ed4: a2220047 sb r2,0x0047(r17) # unitData.X = params.X 80147ed8: 92420001 lbu r2,0x0001(r18) # params.Y 80147edc: 02002021 addu r4,r16,r0 # unitIndex 80147ee0: a2220048 sb r2,0x0048(r17) # unitData.Y = params.Y 80147ee4: 92430002 lbu r3,0x0002(r18) # params.HigherElevation 80147ee8: 96220048 lhu r2,0x0048(r17) # unitData.CombinedValue0x48 // High byte: 0x49 flags; 0x80 bit is Higher Elevation; Low byte: Y coordinate 80147eec: 00031bc0 sll r3,r3,0x0f # params.HigherElevation << 15 80147ef0: 30427fff andi r2,r2,0x7fff # unitData.CombinedValue0x48 & 0x7fff 80147ef4: 00431025 or r2,r2,r3 # (unitData.CombinedValue0x48 & 0x7fff) | (params.HigherElevation << 15) 80147ef8: a6220048 sh r2,0x0048(r17) # unitData.CombinedValue0x48 = (unitData.CombinedValue0x48 & 0x7fff) | (params.HigherElevation << 15) # // (Essentially, unitData.HigherElevation = params.HigherElevation) 80147efc: 92430003 lbu r3,0x0003(r18) # params.FacingDirection 80147f00: 3042f0ff andi r2,r2,0xf0ff # unitData.CombinedValue0x48 & 0xf0ff // (Clear facing direction) 80147f04: 3063000f andi r3,r3,0x000f # params.FacingDirection & 0x0f 80147f08: 00031a00 sll r3,r3,0x08 # (params.FacingDirection & 0x0f) << 8 80147f0c: 00431025 or r2,r2,r3 # (unitData.CombinedValue0x48 & 0xf0ff) | (params.FacingDirection & 0x0f) << 8) 80147f10: 0c023388 jal 0x8008ce20 # MiscUnitID = Get Misc Unit ID By Unit Index (unitIndex); 80147f14: a6220048 sh r2,0x0048(r17) # unitData.CombinedValue0x48 = (unitData.CombinedValue0x48 & 0xf0ff) | (params.FacingDirection & 0x0f) << 8) # // (Essentially, unitData.FacingDirection = params.FacingDirection) 80147f18: 00408021 addu r16,r2,r0 # MiscUnitID 80147f1c: 2402ffff addiu r2,r0,-0x0001 # -1 80147f20: 1202001b beq r16,r2,0x80147f90 # if (MiscUnitID == -1) return; 80147f24: 02002021 addu r4,r16,r0 # MiscUnitID 80147f28: 92220047 lbu r2,0x0047(r17) # unitData.X 80147f2c: 00000000 nop 80147f30: a7a20010 sh r2,0x0010(r29) # structData.X = unitData.X 80147f34: 96220048 lhu r2,0x0048(r17) # unitData.CombinedValue0x48 80147f38: 00000000 nop 80147f3c: 000213c2 srl r2,r2,0x0f # unitData.HigherElevation 80147f40: a7a20012 sh r2,0x0012(r29) # structData.HigherElevation = unitData.HigherElevation 80147f44: 92220048 lbu r2,0x0048(r17) # unitData.Y 80147f48: 3c058017 lui r5,0x8017 80147f4c: 24a5d9d8 addiu r5,r5,-0x2628 # 0x8016d9d8 80147f50: a7a20014 sh r2,0x0014(r29) # structData.Y = unitData.Y 80147f54: 001010c0 sll r2,r16,0x03 # MiscUnitID * 8 80147f58: 00501023 subu r2,r2,r16 # MiscUnitID * 7 80147f5c: 92430003 lbu r3,0x0003(r18) # params.FacingDirection 80147f60: 00451021 addu r2,r2,r5 # ptr = 0x8016d9d8 + (MiscUnitID * 7) 80147f64: a0400006 sb r0,0x0006(r2) # *(ptr + 6) = 0 80147f68: a0400004 sb r0,0x0004(r2) # *(ptr + 4) = 0 80147f6c: 00031880 sll r3,r3,0x02 # params.FacingDirection << 2 80147f70: a0430000 sb r3,0x0000(r2) # *ptr = params.FacingDirection << 2 80147f74: 92460003 lbu r6,0x0003(r18) # params.FacingDirection 80147f78: 0c02329f jal 0x8008ca7c # ? 0x8ca7c (MiscUnitID, structData, params.FacingDirection); 80147f7c: 27a50010 addiu r5,r29,0x0010 # structData 80147f80: 92450003 lbu r5,0x0003(r18) # params.FacingDirection 80147f84: 02002021 addu r4,r16,r0 # MiscUnitID 80147f88: 0c04b6c0 jal 0x8012db00 # ? 0x12db00 (MiscUnitID, params.FacingDirection << 2); 80147f8c: 00052880 sll r5,r5,0x02 # params.FacingDirection << 2 80147f90: 8fbf002c lw r31,0x002c(r29) 80147f94: 8fb20028 lw r18,0x0028(r29) 80147f98: 8fb10024 lw r17,0x0024(r29) 80147f9c: 8fb00020 lw r16,0x0020(r29) 80147fa0: 27bd0030 addiu r29,r29,0x0030 80147fa4: 03e00008 jr r31 80147fa8: 00000000 nop