Walk To
Jump to navigation
Jump to search
# ROUTINE: WalkTo # Called from WalkTo event instruction routine, 0x8013e5c0. # Parameters: # r4 = (MiscID) Unit misc ID # r5 = (coords) Array of coordinates (halfwords) of destination tile [X, Higher Elevation, Y] # r6 = (ElevationAddend) 256 if event instruction parameter 7 was 0, 0 otherwise # r7 = (p4) 3 # *(sp + 0x10) = Speed # Returns: # r2 = IsSuccess (true (1) or false (0)) 8008c664: 27bdffc8 addiu r29,r29,-0x0038 8008c668: afb00020 sw r16,0x0020(r29) 8008c66c: 00a08021 addu r16,r5,r0 # coords 8008c670: afb20028 sw r18,0x0028(r29) 8008c674: 00c09021 addu r18,r6,r0 # ElevationAddend 8008c678: afb3002c sw r19,0x002c(r29) 8008c67c: 00e09821 addu r19,r7,r0 # p4 8008c680: afb40030 sw r20,0x0030(r29) 8008c684: 8fb40048 lw r20,0x0048(r29) # Speed 8008c688: 3084ffff andi r4,r4,0xffff # MiscID 8008c68c: afbf0034 sw r31,0x0034(r29) 8008c690: 0c01e9b9 jal 0x8007a6e4 # unitMiscData = Get Unit Misc Data Pointer (MiscID); 8008c694: afb10024 sw r17,0x0024(r29) 8008c698: 00408821 addu r17,r2,r0 # unitMiscData 8008c69c: 1220003f beq r17,r0,0x8008c79c 8008c6a0: 02402021 addu r4,r18,r0 # ElevationAddend # if (unitMiscData != null) { 8008c6a4: 9222007e lbu r2,0x007e(r17) # unitMiscData.HigherElevation 8008c6a8: 9226007c lbu r6,0x007c(r17) # unitMiscData.X 8008c6ac: 9227007d lbu r7,0x007d(r17) # unitMiscData.Y 8008c6b0: afa20010 sw r2,0x0010(r29) # unitMiscData.HigherElevation 8008c6b4: 86020000 lh r2,0x0000(r16) # coords.X 8008c6b8: 00000000 nop 8008c6bc: afa20014 sw r2,0x0014(r29) # coords.X 8008c6c0: 86020004 lh r2,0x0004(r16) # coords.Y 8008c6c4: 00000000 nop 8008c6c8: afa20018 sw r2,0x0018(r29) # coords.Y 8008c6cc: 86020002 lh r2,0x0002(r16) # coords.HigherElevation 8008c6d0: 02602821 addu r5,r19,r0 # p4 8008c6d4: 0c05e03b jal 0x801780ec # pathingArray = Calculate WalkTo Pathing (ElevationAddend, p4 (= 3), unitMiscData.X, unitMiscData.Y, unitMiscData.HigherElevation, # coords.X, coords.Y, coords.HigherElevation); 8008c6d8: afa2001c sw r2,0x001c(r29) # coords.HigherElevation 8008c6dc: 10400031 beq r2,r0,0x8008c7a4 # if (pathingArray == 0 (null)), return 0 8008c6e0: 2627009c addiu r7,r17,0x009c # unitMiscDataEntryPtr = unitMiscData + 0x9c 8008c6e4: 00403021 addu r6,r2,r0 # pathingEntryPtr = pathingArray 8008c6e8: 00c71025 or r2,r6,r7 # pathingEntryPtr | unitMiscDataEntryPtr 8008c6ec: 30420003 andi r2,r2,0x0003 # isWordUnaligned = (pathingEntryPtr | (unitMiscData + 0x9c)) mod 4 8008c6f0: 10400016 beq r2,r0,0x8008c74c 8008c6f4: 24c80080 addiu r8,r6,0x0080 # pathingArray + 0x80 // Sentinel address # if (isWordUnaligned) { 8008c6f8: 88c20003 lwl r2,0x0003(r6) 8008c6fc: 98c20000 lwr r2,0x0000(r6) # patchingEntryPtr->0x00 8008c700: 88c30007 lwl r3,0x0007(r6) 8008c704: 98c30004 lwr r3,0x0004(r6) # patchingEntryPtr->0x04 8008c708: 88c4000b lwl r4,0x000b(r6) 8008c70c: 98c40008 lwr r4,0x0008(r6) # patchingEntryPtr->0x08 8008c710: 88c5000f lwl r5,0x000f(r6) 8008c714: 98c5000c lwr r5,0x000c(r6) # patchingEntryPtr->0x0c 8008c718: a8e20003 swl r2,0x0003(r7) 8008c71c: b8e20000 swr r2,0x0000(r7) # unitMiscDataEntryPtr->0x00 = patchingEntryPtr->0x00 8008c720: a8e30007 swl r3,0x0007(r7) 8008c724: b8e30004 swr r3,0x0004(r7) # unitMiscDataEntryPtr->0x04 = patchingEntryPtr->0x04 8008c728: a8e4000b swl r4,0x000b(r7) 8008c72c: b8e40008 swr r4,0x0008(r7) # unitMiscDataEntryPtr->0x08 = patchingEntryPtr->0x08 8008c730: a8e5000f swl r5,0x000f(r7) 8008c734: b8e5000c swr r5,0x000c(r7) # unitMiscDataEntryPtr->0x0c = patchingEntryPtr->0x0c 8008c738: 24c60010 addiu r6,r6,0x0010 # pathingEntryPtr = pathingEntryPtr + 0x10 8008c73c: 14c8ffee bne r6,r8,0x8008c6f8 8008c740: 24e70010 addiu r7,r7,0x0010 # unitMiscDataEntryPtr = unitMiscDataEntryPtr + 0x10 # } while (pathingEntryPtr != (pathingArray + 0x80)) 8008c744: 080231df j 0x8008c77c 8008c748: 02202021 addu r4,r17,r0 # unitMiscData # } else { 8008c74c: 8cc20000 lw r2,0x0000(r6) # patchingEntryPtr->0x00 8008c750: 8cc30004 lw r3,0x0004(r6) # patchingEntryPtr->0x04 8008c754: 8cc40008 lw r4,0x0008(r6) # patchingEntryPtr->0x08 8008c758: 8cc5000c lw r5,0x000c(r6) # patchingEntryPtr->0x0c 8008c75c: ace20000 sw r2,0x0000(r7) # unitMiscDataEntryPtr->0x00 = patchingEntryPtr->0x00 8008c760: ace30004 sw r3,0x0004(r7) # unitMiscDataEntryPtr->0x04 = patchingEntryPtr->0x04 8008c764: ace40008 sw r4,0x0008(r7) # unitMiscDataEntryPtr->0x08 = patchingEntryPtr->0x08 8008c768: ace5000c sw r5,0x000c(r7) # unitMiscDataEntryPtr->0x0c = patchingEntryPtr->0x0c 8008c76c: 24c60010 addiu r6,r6,0x0010 # pathingEntryPtr = pathingEntryPtr + 0x10 8008c770: 14c8fff6 bne r6,r8,0x8008c74c 8008c774: 24e70010 addiu r7,r7,0x0010 # unitMiscDataEntryPtr = unitMiscDataEntryPtr + 0x10 # } while (pathingEntryPtr != (pathingArray + 0x80)) 8008c778: 02202021 addu r4,r17,r0 # unitMiscData # } 8008c77c: 00141040 sll r2,r20,0x01 # Speed * 2 8008c780: ac820038 sw r2,0x0038(r4) # unitMiscData.0x38 = Speed * 2 8008c784: 34022000 ori r2,r0,0x2000 # 0x2000 8008c788: ac82003c sw r2,0x003c(r4) # unitMiscData.0x3c = 0x2000 8008c78c: 0c01a4af jal 0x800692bc # ? 0x692bc (unitMiscData) // Mount logic? 8008c790: ac800098 sw r0,0x0098(r4) # unitMiscData.0x98 = 0 8008c794: 080231ea j 0x8008c7a8 # return 1; 8008c798: 34020001 ori r2,r0,0x0001 # } else { 8008c79c: 0c01128d jal 0x80044a34 # ? 0x44a34 (12); // *0x8004c6c4 = 0; (Routine does nothing else; parameter is irrelevant) 8008c7a0: 3404000c ori r4,r0,0x000c # 12 # } 8008c7a4: 00001021 addu r2,r0,r0 # return 0; 8008c7a8: 8fbf0034 lw r31,0x0034(r29) 8008c7ac: 8fb40030 lw r20,0x0030(r29) 8008c7b0: 8fb3002c lw r19,0x002c(r29) 8008c7b4: 8fb20028 lw r18,0x0028(r29) 8008c7b8: 8fb10024 lw r17,0x0024(r29) 8008c7bc: 8fb00020 lw r16,0x0020(r29) 8008c7c0: 27bd0038 addiu r29,r29,0x0038 8008c7c4: 03e00008 jr r31 8008c7c8: 00000000 nop