From 6b5157b2a3b2d81f83a910b211834cde5cd3a238 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 21 Dec 2017 17:46:03 +0100 Subject: [PATCH] decompile bike.s --- asm/bike.s | 2199 --------------------------------- asm/field_control_avatar.s | 2 +- asm/field_effect.s | 12 +- asm/field_player_avatar.s | 176 +-- asm/field_screen.s | 20 +- asm/field_tasks.s | 2 +- asm/item_use.s | 2 +- asm/overworld.s | 6 +- asm/rom6.s | 12 +- asm/rotating_gate.s | 4 +- asm/trainer_card.s | 2 +- data/bike.s | 58 - data/specials.inc | 2 +- include/bike.h | 78 ++ include/field_player_avatar.h | 21 + include/global.fieldmap.h | 45 +- ld_script.txt | 4 +- src/bike.c | 1078 ++++++++++++++++ src/evolution_scene.c | 6 +- sym_ewram.txt | 4 +- 20 files changed, 1335 insertions(+), 2398 deletions(-) delete mode 100644 asm/bike.s delete mode 100644 data/bike.s create mode 100644 include/bike.h create mode 100644 src/bike.c diff --git a/asm/bike.s b/asm/bike.s deleted file mode 100644 index 89791b987..000000000 --- a/asm/bike.s +++ /dev/null @@ -1,2199 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start MovePlayerOnBike -@ void MovePlayerOnBike(int dpad_direction, int buttons_new, int buttons_held) -MovePlayerOnBike: @ 8119164 - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 16 - lsrs r2, 16 - ldr r0, =gPlayerAvatar - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0811918C - adds r0, r3, 0 - adds r1, r4, 0 - bl MovePlayerOnMachBike - b _08119194 - .pool -_0811918C: - adds r0, r3, 0 - adds r1, r4, 0 - bl MovePlayerOnAcroBike -_08119194: - pop {r4} - pop {r0} - bx r0 - thumb_func_end MovePlayerOnBike - - thumb_func_start MovePlayerOnMachBike -MovePlayerOnMachBike: @ 811919C - push {r4,lr} - sub sp, 0x4 - mov r1, sp - strb r0, [r1] - ldr r4, =gUnknown_0859744C - mov r0, sp - bl CheckMovementInputMachBike - lsls r0, 24 - lsrs r0, 22 - adds r0, r4 - mov r1, sp - ldrb r1, [r1] - ldr r2, [r0] - adds r0, r1, 0 - bl _call_via_r2 - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end MovePlayerOnMachBike - - thumb_func_start CheckMovementInputMachBike -CheckMovementInputMachBike: @ 81191CC - push {r4,lr} - adds r4, r0, 0 - bl player_get_direction_upper_nybble - lsls r0, 24 - lsrs r0, 24 - adds r3, r0, 0 - ldrb r1, [r4] - cmp r1, 0 - bne _081191F4 - strb r0, [r4] - ldr r2, =gPlayerAvatar - ldrb r0, [r2, 0xB] - cmp r0, 0 - bne _08119208 - strb r1, [r2, 0x2] - movs r0, 0 - b _0811921C - .pool -_081191F4: - ldr r2, =gPlayerAvatar - cmp r1, r3 - beq _08119218 - ldrb r0, [r2, 0x2] - cmp r0, 0x2 - beq _08119218 - ldrb r0, [r2, 0xB] - cmp r0, 0 - beq _08119214 - strb r3, [r4] -_08119208: - movs r0, 0x2 - strb r0, [r2, 0x2] - movs r0, 0x3 - b _0811921C - .pool -_08119214: - movs r0, 0x1 - b _0811921A -_08119218: - movs r0, 0x2 -_0811921A: - strb r0, [r2, 0x2] -_0811921C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end CheckMovementInputMachBike - - thumb_func_start sub_8119224 -sub_8119224: @ 8119224 - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl PlayerFaceDirection - bl sub_811A128 - pop {r0} - bx r0 - thumb_func_end sub_8119224 - - thumb_func_start sub_8119238 -sub_8119238: @ 8119238 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r4, r0, r1 - ldrb r1, [r4, 0x1E] - adds r0, r5, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - beq _08119270 - adds r0, r5, 0 - bl PlayerTurnInPlace - bl sub_811A128 - b _0811927A - .pool -_08119270: - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl sub_8119224 -_0811927A: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8119238 - - thumb_func_start sub_8119280 -sub_8119280: @ 8119280 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r7, r5, 0 - ldr r6, =gPlayerAvatar - ldrb r1, [r6, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r4, r0, r1 - ldrb r1, [r4, 0x1E] - adds r0, r5, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _081192C6 - ldrb r0, [r6, 0xB] - cmp r0, 0 - beq _081192BC - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl sub_8119344 - b _0811933A - .pool -_081192BC: - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl sub_8119224 - b _0811933A -_081192C6: - adds r0, r5, 0 - bl sub_8119E38 - lsls r0, 24 - lsrs r4, r0, 24 - movs r1, 0xFF - lsls r1, 24 - adds r0, r1 - lsrs r0, 24 - cmp r0, 0xA - bhi _08119316 - cmp r4, 0x6 - bne _081192E8 - adds r0, r5, 0 - bl PlayerJumpLedge - b _0811933A -_081192E8: - bl sub_811A128 - cmp r4, 0x4 - bne _08119304 - adds r0, r5, 0 - bl IsPlayerCollidingWithFarawayIslandMew - lsls r0, 24 - cmp r0, 0 - beq _08119304 - adds r0, r5, 0 - bl PlayerOnBikeCollideWithFarawayIslandMew - b _0811933A -_08119304: - subs r0, r4, 0x5 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bls _0811933A - adds r0, r7, 0 - bl PlayerOnBikeCollide - b _0811933A -_08119316: - ldr r1, =gUnknown_0859745C - ldrb r0, [r6, 0xA] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - adds r0, r7, 0 - bl _call_via_r1 - ldrb r2, [r6, 0xA] - lsls r0, r2, 24 - lsrs r1, r0, 24 - lsrs r0, 25 - adds r0, r2, r0 - strb r0, [r6, 0xB] - cmp r1, 0x1 - bhi _0811933A - adds r0, r2, 0x1 - strb r0, [r6, 0xA] -_0811933A: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8119280 - - thumb_func_start sub_8119344 -sub_8119344: @ 8119344 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r7, r5, 0 - ldr r6, =gPlayerAvatar - ldrb r0, [r6, 0xB] - cmp r0, 0 - beq _0811935A - subs r0, 0x1 - strb r0, [r6, 0xB] - strb r0, [r6, 0xA] -_0811935A: - adds r0, r5, 0 - bl sub_8119E38 - lsls r0, 24 - lsrs r4, r0, 24 - movs r1, 0xFF - lsls r1, 24 - adds r0, r1 - lsrs r0, 24 - cmp r0, 0xA - bhi _081193AE - cmp r4, 0x6 - bne _08119380 - adds r0, r5, 0 - bl PlayerJumpLedge - b _081193BE - .pool -_08119380: - bl sub_811A128 - cmp r4, 0x4 - bne _0811939C - adds r0, r5, 0 - bl IsPlayerCollidingWithFarawayIslandMew - lsls r0, 24 - cmp r0, 0 - beq _0811939C - adds r0, r5, 0 - bl PlayerOnBikeCollideWithFarawayIslandMew - b _081193BE -_0811939C: - subs r0, r4, 0x5 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bls _081193BE - adds r0, r7, 0 - bl PlayerOnBikeCollide - b _081193BE -_081193AE: - ldr r0, =gUnknown_0859745C - ldrb r1, [r6, 0xA] - lsls r1, 2 - adds r1, r0 - ldr r1, [r1] - adds r0, r7, 0 - bl _call_via_r1 -_081193BE: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8119344 - - thumb_func_start MovePlayerOnAcroBike -@ void MovePlayerOnAcroBike(int dpad_direction, int buttons_new, int buttons_held) -MovePlayerOnAcroBike: @ 81193C8 - push {r4,lr} - sub sp, 0x4 - mov r3, sp - strb r0, [r3] - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - ldr r4, =gUnknown_08597468 - mov r0, sp - bl CheckMovementInputAcroBike - lsls r0, 24 - lsrs r0, 22 - adds r0, r4 - mov r1, sp - ldrb r1, [r1] - ldr r2, [r0] - adds r0, r1, 0 - bl _call_via_r2 - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end MovePlayerOnAcroBike - - thumb_func_start CheckMovementInputAcroBike -CheckMovementInputAcroBike: @ 8119400 - push {r4,lr} - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - ldr r4, =gUnknown_0859749C - ldr r3, =gPlayerAvatar - ldrb r3, [r3, 0x8] - lsls r3, 2 - adds r3, r4 - ldr r3, [r3] - bl _call_via_r3 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end CheckMovementInputAcroBike - - thumb_func_start CheckMovementInputAcroBikeNormal -CheckMovementInputAcroBikeNormal: @ 811942C - push {r4-r6,lr} - adds r4, r0, 0 - lsls r1, 16 - lsrs r6, r1, 16 - lsls r2, 16 - lsrs r5, r2, 16 - bl player_get_direction_upper_nybble - lsls r0, 24 - lsrs r3, r0, 24 - ldr r2, =gPlayerAvatar - movs r0, 0 - strb r0, [r2, 0xA] - ldrb r1, [r4] - cmp r1, 0 - bne _0811946C - movs r0, 0x2 - ands r0, r6 - cmp r0, 0 - beq _08119464 - strb r3, [r4] - strb r1, [r2, 0x2] - movs r0, 0x2 - strb r0, [r2, 0x8] - movs r0, 0x3 - b _081194C0 - .pool -_08119464: - strb r3, [r4] - strb r1, [r2, 0x2] - movs r0, 0 - b _081194C0 -_0811946C: - cmp r1, r3 - bne _08119492 - movs r0, 0x2 - ands r0, r5 - cmp r0, 0 - beq _0811948A - ldrb r0, [r2, 0xB] - cmp r0, 0 - bne _0811948A - adds r0, 0x1 - strb r0, [r2, 0xB] - movs r0, 0x4 - strb r0, [r2, 0x8] - movs r0, 0xB - b _081194C0 -_0811948A: - ldrb r0, [r4] - ldr r2, =gPlayerAvatar - cmp r0, r3 - beq _081194BC -_08119492: - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x2] - adds r2, r0, 0 - cmp r1, 0x2 - beq _081194BC - movs r1, 0 - movs r0, 0x1 - strb r0, [r2, 0x8] - ldrb r0, [r4] - strb r0, [r2, 0x9] - strb r1, [r2, 0x2] - adds r0, r4, 0 - adds r1, r6, 0 - adds r2, r5, 0 - bl CheckMovementInputAcroBike - lsls r0, 24 - lsrs r0, 24 - b _081194C0 - .pool -_081194BC: - movs r0, 0x2 - strb r0, [r2, 0x2] -_081194C0: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end CheckMovementInputAcroBikeNormal - - thumb_func_start CheckMovementInputAcroBikeChangingDirection -CheckMovementInputAcroBikeChangingDirection: @ 81194C8 - push {r4-r6,lr} - adds r5, r0, 0 - ldr r4, =gPlayerAvatar - ldrb r0, [r4, 0x9] - strb r0, [r5] - ldrb r0, [r4, 0xA] - adds r0, 0x1 - strb r0, [r4, 0xA] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x6 - bls _081194F4 - movs r0, 0x1 - strb r0, [r4, 0x2] - movs r0, 0 - strb r0, [r4, 0x8] - bl sub_811A128 - movs r0, 0x1 - b _0811953A - .pool -_081194F4: - bl player_get_direction_upper_nybble - lsls r0, 24 - lsrs r6, r0, 24 - bl sub_8119D30 - ldrb r1, [r5] - lsls r0, 24 - lsrs r0, 24 - cmp r1, r0 - bne _08119536 - bl sub_811A128 - movs r0, 0x1 - strb r0, [r4, 0xB] - adds r0, r6, 0 - bl GetOppositeDirection - ldrb r1, [r5] - lsls r0, 24 - lsrs r0, 24 - cmp r1, r0 - bne _0811952A - movs r0, 0x6 - strb r0, [r4, 0x8] - movs r0, 0x9 - b _0811953A -_0811952A: - movs r0, 0x2 - strb r0, [r4, 0x2] - movs r0, 0x5 - strb r0, [r4, 0x8] - movs r0, 0x8 - b _0811953A -_08119536: - strb r6, [r5] - movs r0, 0 -_0811953A: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end CheckMovementInputAcroBikeChangingDirection - - thumb_func_start CheckMovementInputAcroBikeStandingWheelie -CheckMovementInputAcroBikeStandingWheelie: @ 8119540 - push {r4-r7,lr} - adds r7, r0, 0 - lsls r4, r2, 16 - lsrs r4, 16 - bl player_get_direction_upper_nybble - lsls r0, 24 - lsrs r6, r0, 24 - ldr r5, =gPlayerAvatar - ldrb r1, [r5, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r1, r0, r1 - movs r0, 0 - strb r0, [r5, 0x2] - movs r0, 0x2 - ands r4, r0 - lsls r4, 16 - lsrs r4, 16 - cmp r4, 0 - bne _08119594 - strb r4, [r5, 0xA] - ldrb r0, [r1, 0x1E] - bl MetatileBehavior_IsBumpySlope - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _0811959A - strb r6, [r7] - strb r0, [r5, 0x8] - bl sub_811A128 - movs r0, 0x4 - b _081195D8 - .pool -_08119594: - ldrb r0, [r5, 0xA] - adds r0, 0x1 - strb r0, [r5, 0xA] -_0811959A: - ldr r1, =gPlayerAvatar - ldrb r0, [r1, 0xA] - cmp r0, 0x27 - bls _081195B4 - strb r6, [r7] - movs r0, 0x3 - strb r0, [r1, 0x8] - bl sub_811A128 - movs r0, 0x6 - b _081195D8 - .pool -_081195B4: - ldrb r0, [r7] - cmp r0, r6 - bne _081195CA - movs r0, 0x2 - strb r0, [r1, 0x2] - movs r0, 0x4 - strb r0, [r1, 0x8] - bl sub_811A128 - movs r0, 0xA - b _081195D8 -_081195CA: - cmp r0, 0 - beq _081195D4 - movs r0, 0x1 - strb r0, [r1, 0x2] - b _081195D6 -_081195D4: - strb r6, [r7] -_081195D6: - movs r0, 0x5 -_081195D8: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end CheckMovementInputAcroBikeStandingWheelie - - thumb_func_start CheckMovementInputAcroBikeBunnyHop -CheckMovementInputAcroBikeBunnyHop: @ 81195E0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r6, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r9, r1 - lsls r2, 16 - lsrs r2, 16 - mov r8, r2 - bl player_get_direction_upper_nybble - lsls r0, 24 - lsrs r5, r0, 24 - adds r2, r5, 0 - ldr r4, =gPlayerAvatar - ldrb r1, [r4, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r7, r0, r1 - movs r0, 0x2 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - bne _08119652 - bl sub_811A128 - ldrb r0, [r7, 0x1E] - bl MetatileBehavior_IsBumpySlope - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _08119648 - movs r0, 0x2 - strb r0, [r4, 0x8] - adds r0, r6, 0 - mov r1, r9 - mov r2, r8 - bl CheckMovementInputAcroBike - lsls r0, 24 - lsrs r0, 24 - b _08119676 - .pool -_08119648: - strb r5, [r6] - strb r0, [r4, 0x2] - strb r0, [r4, 0x8] - movs r0, 0x4 - b _08119676 -_08119652: - ldrb r0, [r6] - cmp r0, 0 - bne _0811965C - strb r5, [r6] - b _08119668 -_0811965C: - cmp r0, r2 - beq _0811966E - ldrb r0, [r4, 0x2] - cmp r0, 0x2 - beq _0811966E - movs r0, 0x1 -_08119668: - strb r0, [r4, 0x2] - movs r0, 0x6 - b _08119676 -_0811966E: - ldr r1, =gPlayerAvatar - movs r0, 0x2 - strb r0, [r1, 0x2] - movs r0, 0x7 -_08119676: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end CheckMovementInputAcroBikeBunnyHop - - thumb_func_start CheckMovementInputAcroBikeMovingWheelie -CheckMovementInputAcroBikeMovingWheelie: @ 8119688 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r6, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - lsls r2, 16 - lsrs r2, 16 - mov r8, r2 - bl player_get_direction_lower_nybble - lsls r0, 24 - lsrs r5, r0, 24 - adds r2, r5, 0 - ldr r4, =gPlayerAvatar - ldrb r1, [r4, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r7, r0, r1 - movs r0, 0x2 - mov r9, r0 - movs r0, 0x2 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - bne _08119720 - bl sub_811A128 - ldrb r0, [r7, 0x1E] - bl MetatileBehavior_IsBumpySlope - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _0811970C - strb r1, [r4, 0x8] - ldrb r0, [r6] - cmp r0, 0 - bne _081196EC - strb r5, [r6] - b _081196F6 - .pool -_081196EC: - cmp r0, r5 - beq _081196FC - ldrb r0, [r4, 0x2] - cmp r0, 0x2 - beq _081196FC -_081196F6: - strb r1, [r4, 0x2] - movs r0, 0x4 - b _08119750 -_081196FC: - ldr r1, =gPlayerAvatar - movs r0, 0x2 - strb r0, [r1, 0x2] - movs r0, 0xC - b _08119750 - .pool -_0811970C: - mov r0, r9 - strb r0, [r4, 0x8] - adds r0, r6, 0 - mov r1, r10 - mov r2, r8 - bl CheckMovementInputAcroBike - lsls r0, 24 - lsrs r0, 24 - b _08119750 -_08119720: - ldrb r0, [r6] - cmp r0, 0 - bne _08119736 - strb r5, [r6] - mov r1, r9 - strb r1, [r4, 0x8] - strb r0, [r4, 0x2] - bl sub_811A128 - movs r0, 0x5 - b _08119750 -_08119736: - cmp r2, r0 - beq _08119748 - ldrb r0, [r4, 0x2] - cmp r0, 0x2 - beq _08119748 - movs r0, 0 - strb r0, [r4, 0x2] - movs r0, 0x5 - b _08119750 -_08119748: - ldr r1, =gPlayerAvatar - movs r0, 0x2 - strb r0, [r1, 0x2] - movs r0, 0xA -_08119750: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end CheckMovementInputAcroBikeMovingWheelie - - thumb_func_start CheckMovementInputAcroBikeUnknownMode5 -CheckMovementInputAcroBikeUnknownMode5: @ 8119764 - push {r4-r6,lr} - mov r6, r8 - push {r6} - mov r8, r0 - adds r4, r1, 0 - adds r5, r2, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - ldr r6, =gPlayerAvatar - ldrb r1, [r6, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldrb r2, [r0, 0x1] - movs r1, 0x3 - negs r1, r1 - ands r1, r2 - strb r1, [r0, 0x1] - ldrb r1, [r0, 0x18] - lsls r1, 28 - lsrs r1, 28 - bl FieldObjectSetDirection - movs r0, 0 - strb r0, [r6, 0x8] - mov r0, r8 - adds r1, r4, 0 - adds r2, r5, 0 - bl CheckMovementInputAcroBike - lsls r0, 24 - lsrs r0, 24 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end CheckMovementInputAcroBikeUnknownMode5 - - thumb_func_start CheckMovementInputAcroBikeUnknownMode6 -CheckMovementInputAcroBikeUnknownMode6: @ 81197C0 - push {r4,lr} - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - ldr r4, =gPlayerAvatar - movs r3, 0 - strb r3, [r4, 0x8] - bl CheckMovementInputAcroBike - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end CheckMovementInputAcroBikeUnknownMode6 - - thumb_func_start sub_81197E4 -sub_81197E4: @ 81197E4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl PlayerFaceDirection - pop {r0} - bx r0 - thumb_func_end sub_81197E4 - - thumb_func_start sub_81197F4 -sub_81197F4: @ 81197F4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x1E] - adds r0, r4, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _0811981A - ldrb r0, [r5, 0x18] - lsrs r4, r0, 4 -_0811981A: - adds r0, r4, 0 - bl PlayerFaceDirection - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81197F4 - - thumb_func_start sub_8119830 -sub_8119830: @ 8119830 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r6, r5, 0 - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r4, r0, r1 - ldrb r1, [r4, 0x1E] - adds r0, r5, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _08119868 - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl sub_81197E4 - b _081198BA - .pool -_08119868: - adds r0, r5, 0 - bl sub_8119E38 - lsls r0, 24 - lsrs r4, r0, 24 - movs r1, 0xFF - lsls r1, 24 - adds r0, r1 - lsrs r0, 24 - cmp r0, 0xA - bhi _081198B4 - cmp r4, 0x6 - bne _0811988A - adds r0, r5, 0 - bl PlayerJumpLedge - b _081198BA -_0811988A: - cmp r4, 0x4 - bne _081198A2 - adds r0, r5, 0 - bl IsPlayerCollidingWithFarawayIslandMew - lsls r0, 24 - cmp r0, 0 - beq _081198A2 - adds r0, r5, 0 - bl PlayerOnBikeCollideWithFarawayIslandMew - b _081198BA -_081198A2: - subs r0, r4, 0x5 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bls _081198BA - adds r0, r6, 0 - bl PlayerOnBikeCollide - b _081198BA -_081198B4: - adds r0, r6, 0 - bl PlayerGoSpeed2 -_081198BA: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8119830 - - thumb_func_start sub_81198C0 -sub_81198C0: @ 81198C0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x1E] - adds r0, r4, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _081198E6 - ldrb r0, [r5, 0x18] - lsrs r4, r0, 4 -_081198E6: - adds r0, r4, 0 - bl sub_808B8C0 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81198C0 - - thumb_func_start sub_81198FC -sub_81198FC: @ 81198FC - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x1E] - adds r0, r4, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _08119922 - ldrb r0, [r5, 0x18] - lsrs r4, r0, 4 -_08119922: - adds r0, r4, 0 - bl sub_808B8D8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81198FC - - thumb_func_start sub_8119938 -sub_8119938: @ 8119938 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x1E] - adds r0, r4, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _0811995E - ldrb r0, [r5, 0x18] - lsrs r4, r0, 4 -_0811995E: - adds r0, r4, 0 - bl sub_808B8A8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8119938 - - thumb_func_start sub_8119974 -sub_8119974: @ 8119974 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x1E] - adds r0, r4, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _0811999A - ldrb r0, [r5, 0x18] - lsrs r4, r0, 4 -_0811999A: - adds r0, r4, 0 - bl sub_808B8F0 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8119974 - - thumb_func_start sub_81199B0 -sub_81199B0: @ 81199B0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x1E] - adds r0, r4, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _081199E4 - ldrb r0, [r5, 0x18] - lsrs r0, 4 - bl sub_8119974 - b _08119A1E - .pool -_081199E4: - adds r0, r4, 0 - bl sub_8119E38 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - beq _08119A18 - cmp r1, 0x9 - beq _08119A18 - cmp r1, 0x6 - bne _08119A02 - adds r0, r4, 0 - bl sub_808B938 - b _08119A1E -_08119A02: - subs r0, r1, 0x5 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bls _08119A1E - cmp r1, 0xB - bhi _08119A18 - adds r0, r4, 0 - bl sub_8119974 - b _08119A1E -_08119A18: - adds r0, r4, 0 - bl sub_808B914 -_08119A1E: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81199B0 - - thumb_func_start sub_8119A24 -sub_8119A24: @ 8119A24 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r5, 0 - bl sub_8119E38 - lsls r0, 24 - lsrs r0, 24 - adds r1, r0, 0 - cmp r0, 0 - beq _08119A58 - cmp r0, 0x7 - beq _08119A84 - cmp r0, 0x9 - bls _08119A50 - adds r0, r1, 0 - adds r1, r5, 0 - bl sub_8119FC4 - lsls r0, 24 - cmp r0, 0 - bne _08119A58 -_08119A50: - adds r0, r5, 0 - bl sub_81197F4 - b _08119A84 -_08119A58: - ldr r0, =gPlayerAvatar - ldrb r0, [r0, 0x5] - lsls r4, r0, 3 - adds r4, r0 - lsls r4, 2 - ldr r0, =gMapObjects - adds r4, r0 - movs r0, 0x22 - bl PlaySE - ldrb r0, [r4, 0x1] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4, 0x1] - adds r0, r5, 0 - bl sub_8093514 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x2 - bl player_npc_set_state_and_x22_etc -_08119A84: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8119A24 - - thumb_func_start sub_8119A94 -sub_8119A94: @ 8119A94 - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl sub_808B95C - pop {r0} - bx r0 - thumb_func_end sub_8119A94 - - thumb_func_start sub_8119AA4 -sub_8119AA4: @ 8119AA4 - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - ldr r7, =gPlayerAvatar - ldrb r1, [r7, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x1E] - adds r0, r4, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _08119ADC - ldrb r0, [r5, 0x18] - lsrs r0, 4 - bl sub_808B8A8 - b _08119B2C - .pool -_08119ADC: - adds r0, r4, 0 - bl sub_8119E38 - lsls r0, 24 - lsrs r1, r0, 24 - movs r2, 0xFF - lsls r2, 24 - adds r0, r2 - lsrs r0, 24 - cmp r0, 0xA - bhi _08119B22 - cmp r1, 0x6 - bne _08119AFE - adds r0, r4, 0 - bl sub_808B938 - b _08119B2C -_08119AFE: - cmp r1, 0x9 - beq _08119B12 - cmp r1, 0x4 - bhi _08119B2C - ldrb r0, [r5, 0x1E] - bl MetatileBehavior_IsBumpySlope - lsls r0, 24 - cmp r0, 0 - beq _08119B1A -_08119B12: - adds r0, r4, 0 - bl sub_808B8A8 - b _08119B2C -_08119B1A: - adds r0, r4, 0 - bl sub_808B980 - b _08119B2C -_08119B22: - adds r0, r6, 0 - bl sub_808B9BC - movs r0, 0x2 - strb r0, [r7, 0x2] -_08119B2C: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8119AA4 - - thumb_func_start sub_8119B34 -sub_8119B34: @ 8119B34 - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - ldr r7, =gPlayerAvatar - ldrb r1, [r7, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x1E] - adds r0, r4, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _08119B6C - ldrb r0, [r5, 0x18] - lsrs r0, 4 - bl sub_808B8C0 - b _08119BBC - .pool -_08119B6C: - adds r0, r4, 0 - bl sub_8119E38 - lsls r0, 24 - lsrs r1, r0, 24 - movs r2, 0xFF - lsls r2, 24 - adds r0, r2 - lsrs r0, 24 - cmp r0, 0xA - bhi _08119BB2 - cmp r1, 0x6 - bne _08119B8E - adds r0, r4, 0 - bl sub_808B938 - b _08119BBC -_08119B8E: - cmp r1, 0x9 - beq _08119BA2 - cmp r1, 0x4 - bhi _08119BBC - ldrb r0, [r5, 0x1E] - bl MetatileBehavior_IsBumpySlope - lsls r0, 24 - cmp r0, 0 - beq _08119BAA -_08119BA2: - adds r0, r4, 0 - bl sub_808B8A8 - b _08119BBC -_08119BAA: - adds r0, r4, 0 - bl sub_808B980 - b _08119BBC -_08119BB2: - adds r0, r6, 0 - bl sub_808B9A4 - movs r0, 0x2 - strb r0, [r7, 0x2] -_08119BBC: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8119B34 - - thumb_func_start sub_8119BC4 -sub_8119BC4: @ 8119BC4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x1E] - adds r0, r4, 0 - bl sub_8119F74 - lsls r0, 24 - cmp r0, 0 - bne _08119BFC - ldrb r0, [r5, 0x18] - lsrs r0, 4 - bl sub_808B8D8 - b _08119C36 - .pool -_08119BFC: - adds r0, r4, 0 - bl sub_8119E38 - lsls r0, 24 - lsrs r1, r0, 24 - movs r2, 0xFF - lsls r2, 24 - adds r0, r2 - lsrs r0, 24 - cmp r0, 0xA - bhi _08119C30 - cmp r1, 0x6 - bne _08119C1E - adds r0, r4, 0 - bl PlayerJumpLedge - b _08119C36 -_08119C1E: - subs r0, r1, 0x5 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bls _08119C36 - adds r0, r4, 0 - bl sub_808B8D8 - b _08119C36 -_08119C30: - adds r0, r6, 0 - bl npc_use_some_d2s -_08119C36: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8119BC4 - - thumb_func_start sub_8119C3C -@ void sub_8119C3C(int buttons_new, int buttons_held) -sub_8119C3C: @ 8119C3C - push {lr} - lsls r0, 16 - lsrs r3, r0, 16 - lsls r1, 16 - lsrs r2, r1, 16 - ldr r0, =gPlayerAvatar - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _08119C5A - adds r0, r3, 0 - adds r1, r2, 0 - bl sub_8119C64 -_08119C5A: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8119C3C - - thumb_func_start sub_8119C64 -@ void sub_8119C64(int buttons_new, int buttons_held) -sub_8119C64: @ 8119C64 - push {r4,r5,lr} - lsls r1, 16 - lsrs r5, r1, 16 - adds r0, r5, 0 - bl sub_8119DF8 - lsls r0, 24 - lsrs r2, r0, 24 - ldr r4, =gPlayerAvatar - ldr r0, [r4, 0xC] - movs r1, 0xF - ands r0, r1 - cmp r2, r0 - bne _08119C90 - ldrb r0, [r4, 0x14] - cmp r0, 0xFE - bhi _08119C9A - adds r0, 0x1 - strb r0, [r4, 0x14] - b _08119C9A - .pool -_08119C90: - adds r0, r2, 0 - bl sub_8119D80 - movs r0, 0 - strb r0, [r4, 0xB] -_08119C9A: - movs r0, 0xF - adds r2, r5, 0 - ands r2, r0 - ldr r4, =gPlayerAvatar - ldr r0, [r4, 0x10] - movs r1, 0xF - ands r0, r1 - cmp r2, r0 - bne _08119CBC - ldrb r0, [r4, 0x1C] - cmp r0, 0xFE - bhi _08119CC6 - adds r0, 0x1 - strb r0, [r4, 0x1C] - b _08119CC6 - .pool -_08119CBC: - adds r0, r2, 0 - bl sub_8119DBC - movs r0, 0 - strb r0, [r4, 0xB] -_08119CC6: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8119C64 - - thumb_func_start sub_8119CCC -sub_8119CCC: @ 8119CCC - push {r4,r5,lr} - adds r3, r0, 0 - adds r4, r1, 0 - movs r2, 0 - ldrb r0, [r3] - cmp r0, 0 - beq _08119CF6 - ldr r5, =gUnknown_020375A4 -_08119CDC: - adds r0, r2, r5 - adds r1, r3, r2 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bhi _08119D0C - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - adds r0, r3, r2 - ldrb r0, [r0] - cmp r0, 0 - bne _08119CDC -_08119CF6: - movs r2, 0 - ldrb r0, [r4] - cmp r0, 0 - beq _08119D26 - ldr r3, =gUnknown_020375AC -_08119D00: - adds r0, r2, r3 - adds r1, r4, r2 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bls _08119D18 -_08119D0C: - movs r0, 0 - b _08119D28 - .pool -_08119D18: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - adds r0, r4, r2 - ldrb r0, [r0] - cmp r0, 0 - bne _08119D00 -_08119D26: - movs r0, 0x1 -_08119D28: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8119CCC - - thumb_func_start sub_8119D30 -sub_8119D30: @ 8119D30 - push {r4-r6,lr} - movs r6, 0 - movs r5, 0 -_08119D36: - ldr r0, =gUnknown_085974C0 - adds r4, r5, r0 - ldr r0, =gPlayerAvatar - ldr r1, [r0, 0xC] - ldr r2, [r0, 0x10] - ldr r0, [r4, 0x8] - ands r1, r0 - ldr r0, [r4, 0xC] - ands r2, r0 - ldr r0, [r4] - cmp r1, r0 - bne _08119D70 - ldr r0, [r4, 0x4] - cmp r2, r0 - bne _08119D70 - ldr r0, [r4, 0x10] - ldr r1, [r4, 0x14] - bl sub_8119CCC - lsls r0, 24 - cmp r0, 0 - beq _08119D70 - ldrb r0, [r4, 0x18] - b _08119D7A - .pool -_08119D70: - adds r5, 0x1C - adds r6, 0x1 - cmp r6, 0x3 - bls _08119D36 - movs r0, 0 -_08119D7A: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8119D30 - - thumb_func_start sub_8119D80 -sub_8119D80: @ 8119D80 - push {r4,lr} - lsls r0, 24 - ldr r3, =gPlayerAvatar - ldr r2, [r3, 0xC] - lsls r2, 4 - movs r1, 0xF0 - lsls r1, 20 - ands r1, r0 - lsrs r1, 24 - orrs r2, r1 - str r2, [r3, 0xC] - movs r1, 0x7 - adds r4, r3, 0 - adds r3, 0x14 -_08119D9C: - adds r2, r1, r3 - subs r1, 0x1 - adds r0, r1, r3 - ldrb r0, [r0] - strb r0, [r2] - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0 - bne _08119D9C - movs r0, 0x1 - strb r0, [r4, 0x14] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8119D80 - - thumb_func_start sub_8119DBC -sub_8119DBC: @ 8119DBC - push {r4,lr} - lsls r0, 24 - ldr r3, =gPlayerAvatar - ldr r2, [r3, 0x10] - lsls r2, 4 - movs r1, 0xF0 - lsls r1, 20 - ands r1, r0 - lsrs r1, 24 - orrs r2, r1 - str r2, [r3, 0x10] - movs r1, 0x7 - adds r4, r3, 0 - adds r3, 0x1C -_08119DD8: - adds r2, r1, r3 - subs r1, 0x1 - adds r0, r1, r3 - ldrb r0, [r0] - strb r0, [r2] - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0 - bne _08119DD8 - movs r0, 0x1 - strb r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8119DBC - - thumb_func_start sub_8119DF8 -sub_8119DF8: @ 8119DF8 - push {lr} - lsls r0, 16 - lsrs r1, r0, 16 - adds r2, r1, 0 - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08119E0C - movs r0, 0x2 - b _08119E32 -_08119E0C: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08119E18 - movs r0, 0x1 - b _08119E32 -_08119E18: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08119E24 - movs r0, 0x3 - b _08119E32 -_08119E24: - movs r0, 0x10 - ands r2, r0 - cmp r2, 0 - bne _08119E30 - movs r0, 0 - b _08119E32 -_08119E30: - movs r0, 0x4 -_08119E32: - pop {r1} - bx r1 - thumb_func_end sub_8119DF8 - - thumb_func_start sub_8119E38 -sub_8119E38: @ 8119E38 - push {r4-r6,lr} - sub sp, 0x8 - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - ldr r0, =gPlayerAvatar - ldrb r0, [r0, 0x5] - lsls r4, r0, 3 - adds r4, r0 - lsls r4, 2 - ldr r0, =gMapObjects - adds r4, r0 - ldrh r1, [r4, 0x10] - add r0, sp, 0x4 - strh r1, [r0] - ldrh r0, [r4, 0x12] - mov r5, sp - adds r5, 0x6 - strh r0, [r5] - adds r0, r6, 0 - add r1, sp, 0x4 - adds r2, r5, 0 - bl MoveCoords - add r0, sp, 0x4 - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - add r1, sp, 0x4 - movs r3, 0 - ldrsh r1, [r1, r3] - movs r3, 0 - ldrsh r2, [r5, r3] - str r0, [sp] - adds r0, r4, 0 - adds r3, r6, 0 - bl sub_8119EA4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x8 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8119E38 - - thumb_func_start sub_8119EA4 -sub_8119EA4: @ 8119EA4 - push {r4,r5,lr} - sub sp, 0x4 - ldr r4, [sp, 0x10] - lsls r3, 24 - lsrs r3, 24 - lsls r4, 24 - lsrs r4, 24 - adds r5, r4, 0 - lsls r1, 16 - asrs r1, 16 - lsls r2, 16 - asrs r2, 16 - str r5, [sp] - bl CheckForFieldObjectCollision - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x4 - bhi _08119EE4 - cmp r4, 0 - bne _08119EE0 - adds r0, r5, 0 - bl IsRunningDisallowedByMetatile - lsls r0, 24 - cmp r0, 0 - beq _08119EDC - movs r4, 0x2 -_08119EDC: - cmp r4, 0 - beq _08119EE4 -_08119EE0: - bl sub_8119F50 -_08119EE4: - adds r0, r4, 0 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8119EA4 - - thumb_func_start sub_8119EF0 -sub_8119EF0: @ 8119EF0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl IsRunningDisallowedByMetatile - lsls r0, 24 - cmp r0, 0 - bne _08119F08 - ldr r0, =gMapHeader - ldrb r0, [r0, 0x17] - cmp r0, 0x8 - bne _08119F10 -_08119F08: - movs r0, 0x1 - b _08119F12 - .pool -_08119F10: - movs r0, 0 -_08119F12: - pop {r1} - bx r1 - thumb_func_end sub_8119EF0 - - thumb_func_start IsRunningDisallowedByMetatile -@ bool8 IsRunningDisallowedByMetatile(u8 metatileBehavior) -IsRunningDisallowedByMetatile: @ 8119F18 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsRunningDisallowed - lsls r0, 24 - cmp r0, 0 - bne _08119F42 - adds r0, r4, 0 - bl MetatileBehavior_IsFortreeBridge - lsls r0, 24 - cmp r0, 0 - beq _08119F46 - bl PlayerGetZCoord - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - bne _08119F46 -_08119F42: - movs r0, 0x1 - b _08119F48 -_08119F46: - movs r0, 0 -_08119F48: - pop {r4} - pop {r1} - bx r1 - thumb_func_end IsRunningDisallowedByMetatile - - thumb_func_start sub_8119F50 -sub_8119F50: @ 8119F50 - push {lr} - ldr r0, =gUnknown_0203AB54 - ldrb r0, [r0] - cmp r0, 0 - beq _08119F66 - ldr r1, =gUnknown_0203AB55 - ldrb r0, [r1] - cmp r0, 0x63 - bhi _08119F66 - adds r0, 0x1 - strb r0, [r1] -_08119F66: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8119F50 - - thumb_func_start sub_8119F74 -sub_8119F74: @ 8119F74 - push {r4,r5,lr} - lsls r0, 24 - lsls r1, 24 - lsrs r4, r1, 24 - adds r5, r4, 0 - movs r1, 0xFD - lsls r1, 24 - adds r0, r1 - lsrs r0, 24 - cmp r0, 0x1 - bhi _08119F9E - adds r0, r4, 0 - bl MetatileBehavior_IsIsolatedVerticalRail - lsls r0, 24 - cmp r0, 0 - bne _08119FB6 - adds r0, r4, 0 - bl MetatileBehavior_IsVerticalRail - b _08119FB0 -_08119F9E: - adds r0, r5, 0 - bl MetatileBehavior_IsIsolatedHorizontalRail - lsls r0, 24 - cmp r0, 0 - bne _08119FB6 - adds r0, r5, 0 - bl MetatileBehavior_IsHorizontalRail -_08119FB0: - lsls r0, 24 - cmp r0, 0 - beq _08119FBA -_08119FB6: - movs r0, 0 - b _08119FBC -_08119FBA: - movs r0, 0x1 -_08119FBC: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8119F74 - - thumb_func_start sub_8119FC4 -sub_8119FC4: @ 8119FC4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - adds r2, r0, 0 - lsls r1, 24 - movs r3, 0xFF - lsls r3, 24 - adds r1, r3 - lsrs r1, 24 - cmp r1, 0x1 - bhi _08119FE4 - cmp r0, 0xA - beq _08119FEC - cmp r0, 0xC - bne _08119FF0 - b _08119FEC -_08119FE4: - cmp r2, 0xB - beq _08119FEC - cmp r2, 0xD - bne _08119FF0 -_08119FEC: - movs r0, 0 - b _08119FF2 -_08119FF0: - movs r0, 0x1 -_08119FF2: - pop {r1} - bx r1 - thumb_func_end sub_8119FC4 - - thumb_func_start sub_8119FF8 -sub_8119FF8: @ 8119FF8 - push {r4,lr} - sub sp, 0x4 - ldr r0, =gPlayerAvatar - ldrb r1, [r0] - movs r0, 0x18 - ands r0, r1 - cmp r0, 0 - bne _0811A038 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl IsRunningDisallowedByMetatile - lsls r0, 24 - cmp r0, 0 - bne _0811A038 - movs r0, 0 - b _0811A03A - .pool -_0811A038: - movs r0, 0x1 -_0811A03A: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8119FF8 - - thumb_func_start player_should_look_direction_be_enforced_upon_movement -player_should_look_direction_be_enforced_upon_movement: @ 811A044 - push {lr} - movs r0, 0x4 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _0811A078 - ldr r2, =gMapObjects - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1E] - bl MetatileBehavior_IsBumpySlope - lsls r0, 24 - cmp r0, 0 - beq _0811A078 - movs r0, 0 - b _0811A07A - .pool -_0811A078: - movs r0, 0x1 -_0811A07A: - pop {r1} - bx r1 - thumb_func_end player_should_look_direction_be_enforced_upon_movement - - thumb_func_start GetOnOffBike -@ void GetOnOffBike(u8 transitionFlags) -GetOnOffBike: @ 811A080 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gUnknown_02037348 - movs r0, 0 - strb r0, [r1] - ldr r0, =gPlayerAvatar - ldrb r1, [r0] - movs r0, 0x6 - ands r0, r1 - cmp r0, 0 - beq _0811A0B0 - movs r0, 0x1 - bl SetPlayerAvatarTransitionFlags - bl Overworld_ClearSavedMusic - bl sub_8085784 - b _0811A0C4 - .pool -_0811A0B0: - adds r0, r2, 0 - bl SetPlayerAvatarTransitionFlags - ldr r4, =0x00000193 - adds r0, r4, 0 - bl Overworld_SetSavedMusic - adds r0, r4, 0 - bl Overworld_ChangeMusicTo -_0811A0C4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end GetOnOffBike - - thumb_func_start sub_811A0D0 -sub_811A0D0: @ 811A0D0 - push {lr} - ldr r2, =gPlayerAvatar - movs r3, 0 - strb r3, [r2, 0x8] - strb r3, [r2, 0x9] - strb r3, [r2, 0xA] - strb r3, [r2, 0xB] - str r0, [r2, 0xC] - str r1, [r2, 0x10] - movs r1, 0 - adds r2, 0x14 -_0811A0E6: - adds r0, r1, r2 - strb r3, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x7 - bls _0811A0E6 - movs r1, 0 - ldr r3, =gUnknown_020375AC - movs r2, 0 -_0811A0FA: - adds r0, r1, r3 - strb r2, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x7 - bls _0811A0FA - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A0D0 - - thumb_func_start sub_811A114 -sub_811A114: @ 811A114 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gPlayerAvatar - strb r0, [r2, 0xA] - lsrs r1, r0, 1 - adds r0, r1 - strb r0, [r2, 0xB] - bx lr - .pool - thumb_func_end sub_811A114 - - thumb_func_start sub_811A128 -sub_811A128: @ 811A128 - ldr r1, =gPlayerAvatar - movs r0, 0 - strb r0, [r1, 0xA] - strb r0, [r1, 0xB] - bx lr - .pool - thumb_func_end sub_811A128 - - thumb_func_start sub_811A138 -sub_811A138: @ 811A138 - push {lr} - sub sp, 0x8 - ldr r1, =gUnknown_085974B8 - mov r0, sp - movs r2, 0x6 - bl memcpy - ldr r2, =gPlayerAvatar - ldrb r1, [r2] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0811A168 - ldrb r0, [r2, 0xA] - lsls r0, 1 - add r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - b _0811A182 - .pool -_0811A168: - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0811A174 - movs r0, 0x3 - b _0811A182 -_0811A174: - movs r0, 0x88 - ands r0, r1 - cmp r0, 0 - bne _0811A180 - movs r0, 0x1 - b _0811A182 -_0811A180: - movs r0, 0x2 -_0811A182: - add sp, 0x8 - pop {r1} - bx r1 - thumb_func_end sub_811A138 - - thumb_func_start sub_811A188 -sub_811A188: @ 811A188 - push {r4,r5,lr} - sub sp, 0x4 - ldr r5, =gPlayerAvatar - ldrb r1, [r5] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0811A1D0 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsBumpySlope - lsls r0, 24 - cmp r0, 0 - beq _0811A1D0 - movs r0, 0x2 - strb r0, [r5, 0x8] - bl player_get_direction_upper_nybble - lsls r0, 24 - lsrs r0, 24 - bl sub_808C1B4 -_0811A1D0: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A188 - - thumb_func_start IsRunningDisallowed -@ bool8 IsRunningDisallowed(u8 metatileBehavior) -IsRunningDisallowed: @ 811A1DC - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gMapHeader - ldrb r1, [r0, 0x1A] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0811A1FC - adds r0, r2, 0 - bl IsRunningDisallowedByMetatile - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0811A204 -_0811A1FC: - movs r0, 0x1 - b _0811A206 - .pool -_0811A204: - movs r0, 0 -_0811A206: - pop {r1} - bx r1 - thumb_func_end IsRunningDisallowed - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 9252b79d2..e0e7b5efb 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -62,7 +62,7 @@ _0809BF3C: cmp r6, 0 bne _0809BFA2 _0809BF40: - bl sub_811A138 + bl GetPlayerSpeed lsls r0, 16 asrs r0, 16 cmp r0, 0x4 diff --git a/asm/field_effect.s b/asm/field_effect.s index 170aa6a63..b6b4803d8 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -2027,7 +2027,7 @@ _080B6A8A: thumb_func_start mapldr_08084390 mapldr_08084390: @ 80B6AA4 push {r4,lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_black ldr r0, =c3_080843F8 movs r1, 0 @@ -2113,7 +2113,7 @@ _080B6B58: thumb_func_start sub_80B6B68 sub_80B6B68: @ 80B6B68 push {lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_for_maplights bl ScriptContext2_Enable bl FreezeMapObjects @@ -2780,7 +2780,7 @@ _080B709C: thumb_func_start sub_80B70B4 sub_80B70B4: @ 80B70B4 push {lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_for_maplights bl ScriptContext2_Enable ldr r0, =sub_80B70DC @@ -3747,7 +3747,7 @@ _080B784C: thumb_func_start mapldr_080851BC mapldr_080851BC: @ 80B7868 push {lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_for_maplights bl ScriptContext2_Enable ldr r0, =gFieldCallback @@ -4458,7 +4458,7 @@ _080B7E40: thumb_func_start mapldr_080859D4 mapldr_080859D4: @ 80B7E48 push {lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_for_maplights bl ScriptContext2_Enable bl FreezeMapObjects @@ -4903,7 +4903,7 @@ _080B81E6: thumb_func_start mapldr_08085D88 mapldr_08085D88: @ 80B8200 push {lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_for_maplights bl ScriptContext2_Enable bl FreezeMapObjects diff --git a/asm/field_player_avatar.s b/asm/field_player_avatar.s index 62681e7fb..5385e2eba 100644 --- a/asm/field_player_avatar.s +++ b/asm/field_player_avatar.s @@ -57,7 +57,7 @@ player_step: @ 808A9C0 bne _0808AA26 adds r0, r7, 0 adds r1, r6, 0 - bl sub_8119C3C + bl Bike_TryAcroBikeHistoryUpdate adds r0, r5, 0 mov r1, r8 bl TryInterruptFieldObjectSpecialAnim @@ -405,7 +405,7 @@ DoForcedMovementInCurrentDirection: @ 808AC58 thumb_func_start ForcedMovement_Slip ForcedMovement_Slip: @ 808AC8C push {lr} - ldr r0, =PlayerGoSpeed1 + ldr r0, =PlayerGoSpeed2 bl DoForcedMovementInCurrentDirection lsls r0, 24 lsrs r0, 24 @@ -417,7 +417,7 @@ ForcedMovement_Slip: @ 808AC8C thumb_func_start ForcedMovement_WalkSouth ForcedMovement_WalkSouth: @ 808ACA0 push {lr} - ldr r1, =PlayerGoSpeed0 + ldr r1, =PlayerGoSpeed1 movs r0, 0x1 bl DoForcedMovement lsls r0, 24 @@ -430,7 +430,7 @@ ForcedMovement_WalkSouth: @ 808ACA0 thumb_func_start ForcedMovement_WalkNorth ForcedMovement_WalkNorth: @ 808ACB8 push {lr} - ldr r1, =PlayerGoSpeed0 + ldr r1, =PlayerGoSpeed1 movs r0, 0x2 bl DoForcedMovement lsls r0, 24 @@ -443,7 +443,7 @@ ForcedMovement_WalkNorth: @ 808ACB8 thumb_func_start ForcedMovement_WalkWest ForcedMovement_WalkWest: @ 808ACD0 push {lr} - ldr r1, =PlayerGoSpeed0 + ldr r1, =PlayerGoSpeed1 movs r0, 0x3 bl DoForcedMovement lsls r0, 24 @@ -456,7 +456,7 @@ ForcedMovement_WalkWest: @ 808ACD0 thumb_func_start ForcedMovement_WalkEast ForcedMovement_WalkEast: @ 808ACE8 push {lr} - ldr r1, =PlayerGoSpeed0 + ldr r1, =PlayerGoSpeed1 movs r0, 0x4 bl DoForcedMovement lsls r0, 24 @@ -469,7 +469,7 @@ ForcedMovement_WalkEast: @ 808ACE8 thumb_func_start ForcedMovement_PushedSouthByCurrent ForcedMovement_PushedSouthByCurrent: @ 808AD00 push {lr} - ldr r1, =PlayerGoSpeed2 + ldr r1, =PlayerGoSpeed3 movs r0, 0x1 bl DoForcedMovement lsls r0, 24 @@ -482,7 +482,7 @@ ForcedMovement_PushedSouthByCurrent: @ 808AD00 thumb_func_start ForcedMovement_PushedNorthByCurrent ForcedMovement_PushedNorthByCurrent: @ 808AD18 push {lr} - ldr r1, =PlayerGoSpeed2 + ldr r1, =PlayerGoSpeed3 movs r0, 0x2 bl DoForcedMovement lsls r0, 24 @@ -495,7 +495,7 @@ ForcedMovement_PushedNorthByCurrent: @ 808AD18 thumb_func_start ForcedMovement_PushedWestByCurrent ForcedMovement_PushedWestByCurrent: @ 808AD30 push {lr} - ldr r1, =PlayerGoSpeed2 + ldr r1, =PlayerGoSpeed3 movs r0, 0x3 bl DoForcedMovement lsls r0, 24 @@ -508,7 +508,7 @@ ForcedMovement_PushedWestByCurrent: @ 808AD30 thumb_func_start ForcedMovement_PushedEastByCurrent ForcedMovement_PushedEastByCurrent: @ 808AD48 push {lr} - ldr r1, =PlayerGoSpeed2 + ldr r1, =PlayerGoSpeed3 movs r0, 0x4 bl DoForcedMovement lsls r0, 24 @@ -548,7 +548,7 @@ ForcedMovement_Slide: @ 808AD60 thumb_func_start ForcedMovement_SlideSouth ForcedMovement_SlideSouth: @ 808AD98 push {lr} - ldr r1, =PlayerGoSpeed1 + ldr r1, =PlayerGoSpeed2 movs r0, 0x1 bl ForcedMovement_Slide lsls r0, 24 @@ -561,7 +561,7 @@ ForcedMovement_SlideSouth: @ 808AD98 thumb_func_start ForcedMovement_SlideNorth ForcedMovement_SlideNorth: @ 808ADB0 push {lr} - ldr r1, =PlayerGoSpeed1 + ldr r1, =PlayerGoSpeed2 movs r0, 0x2 bl ForcedMovement_Slide lsls r0, 24 @@ -574,7 +574,7 @@ ForcedMovement_SlideNorth: @ 808ADB0 thumb_func_start ForcedMovement_SlideWest ForcedMovement_SlideWest: @ 808ADC8 push {lr} - ldr r1, =PlayerGoSpeed1 + ldr r1, =PlayerGoSpeed2 movs r0, 0x3 bl ForcedMovement_Slide lsls r0, 24 @@ -587,7 +587,7 @@ ForcedMovement_SlideWest: @ 808ADC8 thumb_func_start ForcedMovement_SlideEast ForcedMovement_SlideEast: @ 808ADE0 push {lr} - ldr r1, =PlayerGoSpeed1 + ldr r1, =PlayerGoSpeed2 movs r0, 0x4 bl ForcedMovement_Slide lsls r0, 24 @@ -630,19 +630,19 @@ ForcedMovement_MuddySlope: @ 808AE10 ands r0, r1 cmp r0, 0x20 bne _0808AE36 - bl sub_811A138 + bl GetPlayerSpeed lsls r0, 16 asrs r0, 16 cmp r0, 0x3 bgt _0808AE60 _0808AE36: movs r0, 0 - bl sub_811A114 + bl Bike_UpdateBikeCounterSpeed ldrb r0, [r4, 0x1] movs r1, 0x2 orrs r0, r1 strb r0, [r4, 0x1] - ldr r1, =PlayerGoSpeed1 + ldr r1, =PlayerGoSpeed2 movs r0, 0x1 bl DoForcedMovement lsls r0, 24 @@ -791,7 +791,7 @@ _0808AF4E: cmp r0, 0 beq _0808AF68 adds r0, r5, 0 - bl PlayerGoSpeed1 + bl PlayerGoSpeed2 b _0808AFB6 .pool _0808AF68: @@ -829,7 +829,7 @@ _0808AF68: .pool _0808AFB0: adds r0, r5, 0 - bl PlayerGoSpeed0 + bl PlayerGoSpeed1 _0808AFB6: pop {r4-r6} pop {r0} @@ -1471,7 +1471,7 @@ PlayerAvatarTransition_MachBike: @ 808B46C bl SetPlayerAvatarStateMask movs r0, 0 movs r1, 0 - bl sub_811A0D0 + bl BikeClearState pop {r4} pop {r0} bx r0 @@ -1497,8 +1497,8 @@ PlayerAvatarTransition_AcroBike: @ 808B4A0 bl SetPlayerAvatarStateMask movs r0, 0 movs r1, 0 - bl sub_811A0D0 - bl sub_811A188 + bl BikeClearState + bl Bike_HandleBumpySlopeJump pop {r4} pop {r0} bx r0 @@ -1774,9 +1774,9 @@ sub_808B6BC: @ 808B6BC .pool thumb_func_end sub_808B6BC - thumb_func_start player_npc_set_state_and_x22_etc -@ void player_npc_set_state_and_x22_etc(u8 animState, u8 a2) -player_npc_set_state_and_x22_etc: @ 808B6E4 + thumb_func_start PlayerSetAnimId +@ void PlayerSetAnimId(u8 animState, u8 a2) +PlayerSetAnimId: @ 808B6E4 push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 @@ -1802,11 +1802,11 @@ _0808B712: pop {r0} bx r0 .pool - thumb_func_end player_npc_set_state_and_x22_etc + thumb_func_end PlayerSetAnimId - thumb_func_start PlayerGoSpeed0 -@ void PlayerGoSpeed0(u8 direction) -PlayerGoSpeed0: @ 808B720 + thumb_func_start PlayerGoSpeed1 +@ void PlayerGoSpeed1(u8 direction) +PlayerGoSpeed1: @ 808B720 push {lr} lsls r0, 24 lsrs r0, 24 @@ -1814,14 +1814,14 @@ PlayerGoSpeed0: @ 808B720 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 - thumb_func_end PlayerGoSpeed0 + thumb_func_end PlayerGoSpeed1 - thumb_func_start PlayerGoSpeed1 -@ void PlayerGoSpeed1(u8 direction) -PlayerGoSpeed1: @ 808B738 + thumb_func_start PlayerGoSpeed2 +@ void PlayerGoSpeed2(u8 direction) +PlayerGoSpeed2: @ 808B738 push {lr} lsls r0, 24 lsrs r0, 24 @@ -1829,14 +1829,14 @@ PlayerGoSpeed1: @ 808B738 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 - thumb_func_end PlayerGoSpeed1 + thumb_func_end PlayerGoSpeed2 - thumb_func_start PlayerGoSpeed2 -@ void PlayerGoSpeed2(u8 direction) -PlayerGoSpeed2: @ 808B750 + thumb_func_start PlayerGoSpeed3 +@ void PlayerGoSpeed3(u8 direction) +PlayerGoSpeed3: @ 808B750 push {lr} lsls r0, 24 lsrs r0, 24 @@ -1844,14 +1844,14 @@ PlayerGoSpeed2: @ 808B750 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 - thumb_func_end PlayerGoSpeed2 + thumb_func_end PlayerGoSpeed3 - thumb_func_start PlayerGoSpeed3 -@ void PlayerGoSpeed3(u8 direction) -PlayerGoSpeed3: @ 808B768 + thumb_func_start PlayerGoSpeed4 +@ void PlayerGoSpeed4(u8 direction) +PlayerGoSpeed4: @ 808B768 push {lr} lsls r0, 24 lsrs r0, 24 @@ -1859,10 +1859,10 @@ PlayerGoSpeed3: @ 808B768 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 - thumb_func_end PlayerGoSpeed3 + thumb_func_end PlayerGoSpeed4 thumb_func_start PlayerRun @ void PlayerRun(u8 direction) @@ -1874,7 +1874,7 @@ PlayerRun: @ 808B780 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 thumb_func_end PlayerRun @@ -1893,7 +1893,7 @@ PlayerOnBikeCollide: @ 808B798 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r4} pop {r0} bx r0 @@ -1909,7 +1909,7 @@ PlayerOnBikeCollideWithFarawayIslandMew: @ 808B7BC lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 thumb_func_end PlayerOnBikeCollideWithFarawayIslandMew @@ -1928,7 +1928,7 @@ PlayerNotOnBikeCollide: @ 808B7D4 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r4} pop {r0} bx r0 @@ -1944,7 +1944,7 @@ PlayerNotOnBikeCollideWithFarawayIslandMew: @ 808B7F8 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 thumb_func_end PlayerNotOnBikeCollideWithFarawayIslandMew @@ -1959,7 +1959,7 @@ PlayerFaceDirection: @ 808B810 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 thumb_func_end PlayerFaceDirection @@ -1974,7 +1974,7 @@ PlayerTurnInPlace: @ 808B828 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 thumb_func_end PlayerTurnInPlace @@ -1993,7 +1993,7 @@ PlayerJumpLedge: @ 808B840 lsls r0, 24 lsrs r0, 24 movs r1, 0x8 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r4} pop {r0} bx r0 @@ -2033,8 +2033,8 @@ _0808B89A: .pool thumb_func_end sub_808B864 - thumb_func_start sub_808B8A8 -sub_808B8A8: @ 808B8A8 + thumb_func_start PlayerIdleWheelie +PlayerIdleWheelie: @ 808B8A8 push {lr} lsls r0, 24 lsrs r0, 24 @@ -2042,13 +2042,13 @@ sub_808B8A8: @ 808B8A8 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 - thumb_func_end sub_808B8A8 + thumb_func_end PlayerIdleWheelie - thumb_func_start sub_808B8C0 -sub_808B8C0: @ 808B8C0 + thumb_func_start PlayerStartWheelie +PlayerStartWheelie: @ 808B8C0 push {lr} lsls r0, 24 lsrs r0, 24 @@ -2056,13 +2056,13 @@ sub_808B8C0: @ 808B8C0 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 - thumb_func_end sub_808B8C0 + thumb_func_end PlayerStartWheelie - thumb_func_start sub_808B8D8 -sub_808B8D8: @ 808B8D8 + thumb_func_start PlayerEndWheelie +PlayerEndWheelie: @ 808B8D8 push {lr} lsls r0, 24 lsrs r0, 24 @@ -2070,13 +2070,13 @@ sub_808B8D8: @ 808B8D8 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 - thumb_func_end sub_808B8D8 + thumb_func_end PlayerEndWheelie - thumb_func_start sub_808B8F0 -sub_808B8F0: @ 808B8F0 + thumb_func_start PlayerStandingHoppingWheelie +PlayerStandingHoppingWheelie: @ 808B8F0 push {r4,lr} adds r4, r0, 0 lsls r4, 24 @@ -2088,14 +2088,14 @@ sub_808B8F0: @ 808B8F0 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r4} pop {r0} bx r0 - thumb_func_end sub_808B8F0 + thumb_func_end PlayerStandingHoppingWheelie - thumb_func_start sub_808B914 -sub_808B914: @ 808B914 + thumb_func_start PlayerMovingHoppingWheelie +PlayerMovingHoppingWheelie: @ 808B914 push {r4,lr} adds r4, r0, 0 lsls r4, 24 @@ -2107,14 +2107,14 @@ sub_808B914: @ 808B914 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r4} pop {r0} bx r0 - thumb_func_end sub_808B914 + thumb_func_end PlayerMovingHoppingWheelie - thumb_func_start sub_808B938 -sub_808B938: @ 808B938 + thumb_func_start PlayerLedgeHoppingWheelie +PlayerLedgeHoppingWheelie: @ 808B938 push {r4,lr} adds r4, r0, 0 lsls r4, 24 @@ -2126,14 +2126,14 @@ sub_808B938: @ 808B938 lsls r0, 24 lsrs r0, 24 movs r1, 0x8 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r4} pop {r0} bx r0 - thumb_func_end sub_808B938 + thumb_func_end PlayerLedgeHoppingWheelie - thumb_func_start sub_808B95C -sub_808B95C: @ 808B95C + thumb_func_start PlayerAcroTurnJump +PlayerAcroTurnJump: @ 808B95C push {r4,lr} adds r4, r0, 0 lsls r4, 24 @@ -2145,11 +2145,11 @@ sub_808B95C: @ 808B95C lsls r0, 24 lsrs r0, 24 movs r1, 0x1 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r4} pop {r0} bx r0 - thumb_func_end sub_808B95C + thumb_func_end PlayerAcroTurnJump thumb_func_start sub_808B980 sub_808B980: @ 808B980 @@ -2164,7 +2164,7 @@ sub_808B980: @ 808B980 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r4} pop {r0} bx r0 @@ -2179,7 +2179,7 @@ sub_808B9A4: @ 808B9A4 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 thumb_func_end sub_808B9A4 @@ -2193,7 +2193,7 @@ sub_808B9BC: @ 808B9BC lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 thumb_func_end sub_808B9BC @@ -2207,7 +2207,7 @@ npc_use_some_d2s: @ 808B9D4 lsls r0, 24 lsrs r0, 24 movs r1, 0x2 - bl player_npc_set_state_and_x22_etc + bl PlayerSetAnimId pop {r0} bx r0 thumb_func_end npc_use_some_d2s @@ -2592,9 +2592,9 @@ sub_808BCF4: @ 808BCF4 lsls r0, 24 cmp r0, 0 beq _0808BD2C - bl sub_811A188 + bl Bike_HandleBumpySlopeJump movs r0, 0 - bl sub_811A114 + bl Bike_UpdateBikeCounterSpeed _0808BD2C: pop {r4} pop {r0} diff --git a/asm/field_screen.s b/asm/field_screen.s index 408f131c7..c16068a15 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -7975,7 +7975,7 @@ _080AF120: sub_80AF128: @ 80AF128 push {lr} bl ScriptContext2_Enable - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_black ldr r0, =task0A_nop_for_a_while movs r1, 0xA @@ -8006,7 +8006,7 @@ _080AF160: sub_80AF168: @ 80AF168 push {lr} bl ScriptContext2_Enable - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_black ldr r0, =task0A_asap_script_env_2_enable_and_set_ctx_running movs r1, 0xA @@ -8092,7 +8092,7 @@ _080AF20E: sub_80AF214: @ 80AF214 push {lr} bl ScriptContext2_Enable - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl palette_bg_faded_fill_black ldr r0, =task_mpl_807DD60 movs r1, 0xA @@ -8220,7 +8220,7 @@ _080AF30C: sub_80AF314: @ 80AF314 push {lr} bl ScriptContext2_Enable - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl palette_bg_faded_fill_black ldr r0, =sub_80AF234 movs r1, 0xA @@ -8279,7 +8279,7 @@ _080AF37E: thumb_func_start mapldr_default mapldr_default: @ 80AF398 push {lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_for_maplights bl sub_80AF334 bl ScriptContext2_Enable @@ -8290,7 +8290,7 @@ mapldr_default: @ 80AF398 thumb_func_start sub_80AF3B0 sub_80AF3B0: @ 80AF3B0 push {lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl sub_80AF08C bl sub_80AF334 bl ScriptContext2_Enable @@ -8304,7 +8304,7 @@ sub_80AF3C8: @ 80AF3C8 bl sub_81D6534 cmp r0, 0 bne _080AF3D6 - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic _080AF3D6: bl pal_fill_black bl sub_80AF334 @@ -8316,7 +8316,7 @@ _080AF3D6: thumb_func_start sub_80AF3E8 sub_80AF3E8: @ 80AF3E8 push {lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_for_maplights movs r0, 0x2E bl PlaySE @@ -8332,7 +8332,7 @@ sub_80AF3E8: @ 80AF3E8 thumb_func_start sub_80AF40C sub_80AF40C: @ 80AF40C push {lr} - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_for_maplights movs r0, 0x2E bl PlaySE @@ -8680,7 +8680,7 @@ sub_80AF6D4: @ 80AF6D4 sub_80AF6F0: @ 80AF6F0 push {lr} bl ScriptContext2_Enable - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl pal_fill_black ldr r0, =task_mpl_807E3C8 movs r1, 0xA diff --git a/asm/field_tasks.s b/asm/field_tasks.s index 39bd3b545..4befe0ca7 100644 --- a/asm/field_tasks.s +++ b/asm/field_tasks.s @@ -1662,7 +1662,7 @@ _0809E572: lsls r0, 24 cmp r0, 0 beq _0809E5D2 - bl sub_811A138 + bl GetPlayerSpeed lsls r0, 16 asrs r0, 16 cmp r0, 0x4 diff --git a/asm/item_use.s b/asm/item_use.s index f732c34e9..567c52206 100644 --- a/asm/item_use.s +++ b/asm/item_use.s @@ -354,7 +354,7 @@ _080FD320: bl sav1_map_is_biking_allowed cmp r0, 0x1 bne _080FD348 - bl sub_8119FF8 + bl IsBikingDisallowedByPlayer lsls r0, 24 cmp r0, 0 bne _080FD348 diff --git a/asm/overworld.s b/asm/overworld.s index fb3c023b1..2d282fa9c 100644 --- a/asm/overworld.s +++ b/asm/overworld.s @@ -2212,8 +2212,8 @@ call_ResetMapMusic: @ 8085778 bx r0 thumb_func_end call_ResetMapMusic - thumb_func_start sub_8085784 -sub_8085784: @ 8085784 + thumb_func_start Overworld_PlaySpecialMapMusic +Overworld_PlaySpecialMapMusic: @ 8085784 push {r4,lr} bl sav1_map_get_music lsls r0, 16 @@ -2261,7 +2261,7 @@ _080857E8: pop {r0} bx r0 .pool - thumb_func_end sub_8085784 + thumb_func_end Overworld_PlaySpecialMapMusic thumb_func_start Overworld_SetSavedMusic Overworld_SetSavedMusic: @ 80857F4 diff --git a/asm/rom6.s b/asm/rom6.s index f2fabec35..091a69f60 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -4668,7 +4668,7 @@ mapldr_080CA5C0: @ 8137C5C push {lr} sub sp, 0x4 bl ScriptContext2_Enable - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic bl sp109_CreatePCMenu bl sub_80E2514 movs r0, 0x1 @@ -4733,10 +4733,10 @@ Special_ViewWallClock: @ 8137CC8 thumb_func_start wild_pokemon_reroll wild_pokemon_reroll: @ 8137CEC - ldr r0, =gUnknown_0203AB54 + ldr r0, =gBikeCyclingChallenge movs r1, 0 strb r1, [r0] - ldr r0, =gUnknown_0203AB55 + ldr r0, =gBikeCollisions strb r1, [r0] ldr r1, =gUnknown_0203AB58 movs r0, 0 @@ -4747,10 +4747,10 @@ wild_pokemon_reroll: @ 8137CEC thumb_func_start sub_8137D0C sub_8137D0C: @ 8137D0C - ldr r1, =gUnknown_0203AB54 + ldr r1, =gBikeCyclingChallenge movs r0, 0x1 strb r0, [r1] - ldr r1, =gUnknown_0203AB55 + ldr r1, =gBikeCollisions movs r0, 0 strb r0, [r1] ldr r1, =gUnknown_0203AB58 @@ -4919,7 +4919,7 @@ sub_8137E6C: @ 8137E6C ldr r4, [r0, 0x20] ldr r0, [r1] subs r4, r0 - ldr r5, =gUnknown_0203AB55 + ldr r5, =gBikeCollisions ldrb r1, [r5] adds r0, r4, 0 bl sub_8137D5C diff --git a/asm/rotating_gate.s b/asm/rotating_gate.s index 5b7671bf8..da5e73034 100644 --- a/asm/rotating_gate.s +++ b/asm/rotating_gate.s @@ -410,7 +410,7 @@ sub_80FBAE4: @ 80FBAE4 adds r0, r4, 0x4 lsls r0, 24 lsrs r4, r0, 24 - bl sub_811A138 + bl GetPlayerSpeed lsls r0, 16 asrs r0, 16 cmp r0, 0x1 @@ -433,7 +433,7 @@ _080FBB2A: adds r0, 0x8 lsls r0, 24 lsrs r4, r0, 24 - bl sub_811A138 + bl GetPlayerSpeed lsls r0, 16 asrs r0, 16 cmp r0, 0x1 diff --git a/asm/trainer_card.s b/asm/trainer_card.s index 84d0cceab..e5d21adb8 100644 --- a/asm/trainer_card.s +++ b/asm/trainer_card.s @@ -5766,7 +5766,7 @@ sub_80C58D4: @ 80C58D4 beq _080C5914 cmp r0, 0x2 beq _080C591C - bl sub_8085784 + bl Overworld_PlaySpecialMapMusic b _080C5924 .pool _080C5914: diff --git a/data/bike.s b/data/bike.s deleted file mode 100644 index ffb33e52b..000000000 --- a/data/bike.s +++ /dev/null @@ -1,58 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - -gUnknown_0859744C:: @ 859744C - .4byte sub_8119224 - .4byte sub_8119238 - .4byte sub_8119280 - .4byte sub_8119344 - - .align 2 -gUnknown_0859745C:: @ 859745C - .4byte PlayerGoSpeed0 - .4byte PlayerGoSpeed1 - .4byte PlayerGoSpeed3 - - .align 2 -gUnknown_08597468:: @ 8597468 - .4byte sub_81197E4 - .4byte sub_81197F4 - .4byte sub_8119830 - .4byte sub_81198C0 - .4byte sub_81198FC - .4byte sub_8119938 - .4byte sub_8119974 - .4byte sub_81199B0 - .4byte sub_8119A24 - .4byte sub_8119A94 - .4byte sub_8119AA4 - .4byte sub_8119B34 - .4byte sub_8119BC4 - - .align 2 -gUnknown_0859749C:: @ 859749C - .4byte CheckMovementInputAcroBikeNormal - .4byte CheckMovementInputAcroBikeChangingDirection - .4byte CheckMovementInputAcroBikeStandingWheelie - .4byte CheckMovementInputAcroBikeBunnyHop - .4byte CheckMovementInputAcroBikeMovingWheelie - .4byte CheckMovementInputAcroBikeUnknownMode5 - .4byte CheckMovementInputAcroBikeUnknownMode6 - - .align 2 -gUnknown_085974B8:: @ 85974B8 - .2byte 0x0001, 0x0002, 0x0004 - - .align 1 -gUnknown_085974BE:: @ 85974BE - .2byte 0x0004 - - .align 2 -gUnknown_085974C0:: @ 85974C0 - .4byte 0x00000001, 0x00000002, 0x0000000f, 0x0000000f, gUnknown_085974BE, gUnknown_085974BE, 0x00000001 - .4byte 0x00000002, 0x00000002, 0x0000000f, 0x0000000f, gUnknown_085974BE, gUnknown_085974BE, 0x00000002 - .4byte 0x00000003, 0x00000002, 0x0000000f, 0x0000000f, gUnknown_085974BE, gUnknown_085974BE, 0x00000003 - .4byte 0x00000004, 0x00000002, 0x0000000f, 0x0000000f, gUnknown_085974BE, gUnknown_085974BE, 0x00000004 diff --git a/data/specials.inc b/data/specials.inc index d159df31f..e78c57d6c 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -163,7 +163,7 @@ gSpecials:: @ 81DBA64 def_special sub_8138BC8 def_special sub_8138B8C def_special sub_814FC9C - def_special sub_8085784 + def_special Overworld_PlaySpecialMapMusic def_special StartWallClock def_special Special_ViewWallClock def_special ChooseStarter diff --git a/include/bike.h b/include/bike.h new file mode 100644 index 000000000..e625ad438 --- /dev/null +++ b/include/bike.h @@ -0,0 +1,78 @@ +#ifndef GUARD_BIKE_H +#define GUARD_BIKE_H + +// the struct below is used for checking button combinations of the last input so that the acro can potentially perform a side/turn jump. +// its possible that at some point Game Freak intended for the acro bike to have more complex tricks: but only the acro jump combinations can be seen in the final ROM. +struct BikeHistoryInputInfo +{ + u32 dirHistoryMatch; // the direction you need to press + u32 abStartSelectHistoryMatch; // the button you need to press + u32 dirHistoryMask; // mask applied so that way only the recent nybble (the recent input) is checked + u32 abStartSelectHistoryMask; // mask applied so that way only the recent nybble (the recent input) is checked + const u8 *dirTimerHistoryList; // list of timers to check for direction before the button+dir combination can be verified. + const u8 *abStartSelectHistoryList; // list of timers to check for buttons before the button+dir combination can be verified. + u32 direction; // direction to jump +}; + +// Player speeds +enum +{ + SPEED_STANDING, + SPEED_NORMAL, + SPEED_FAST, + SPEED_FASTER, + SPEED_FASTEST, +}; + +// mach bike transitions enum +enum +{ + MACH_TRANS_FACE_DIRECTION, + MACH_TRANS_TURN_DIRECTION, + MACH_TRANS_KEEP_MOVING, + MACH_TRANS_START_MOVING +}; + +// Acro bike states +enum +{ + ACRO_STATE_NORMAL, + ACRO_STATE_TURNING, + ACRO_STATE_WHEELIE_STANDING, + ACRO_STATE_BUNNY_HOP, + ACRO_STATE_WHEELIE_MOVING, + ACRO_STATE_SIDE_JUMP, + ACRO_STATE_TURN_JUMP, +}; + +// Acro bike transitions +enum +{ + ACRO_TRANS_FACE_DIRECTION, + ACRO_TRANS_TURN_DIRECTION, + ACRO_TRANS_MOVING, + ACRO_TRANS_NORMAL_TO_WHEELIE, + ACRO_TRANS_WHEELIE_TO_NORMAL, + ACRO_TRANS_WHEELIE_IDLE, + ACRO_TRANS_WHEELIE_HOPPING_STANDING, + ACRO_TRANS_WHEELIE_HOPPING_MOVING, + ACRO_TRANS_SIDE_JUMP, + ACRO_TRANS_TURN_JUMP, + ACRO_TRANS_WHEELIE_MOVING, + ACRO_TRANS_WHEELIE_RISING_MOVING, + ACRO_TRANS_WHEELIE_LOWERING_MOVING, +}; + +void MovePlayerOnBike(u8 direction, u16 newKeys, u16 heldKeys); +void Bike_TryAcroBikeHistoryUpdate(u16 newKeys, u16 heldKeys); +bool8 RS_IsRunningDisallowed(u8 tile); +bool8 IsBikingDisallowedByPlayer(void); +bool8 player_should_look_direction_be_enforced_upon_movement(void); +void GetOnOffBike(u8 transitionFlags); +void BikeClearState(int newDirHistory, int newAbStartHistory); +void Bike_UpdateBikeCounterSpeed(u8 counter); +s16 GetPlayerSpeed(void); +void Bike_HandleBumpySlopeJump(void); +bool32 IsRunningDisallowed(u8 metatile); + +#endif // GUARD_BIKE_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 25b7f2d71..40a1c1f3b 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -9,6 +9,27 @@ void PlayerGetDestCoords(s16 *, s16 *); u8 player_get_direction_lower_nybble(void); u8 player_get_direction_upper_nybble(void); u8 player_get_x22(void); +void PlayerGoSpeed1(u8); +void PlayerGoSpeed2(u8); +void PlayerGoSpeed3(u8); +void PlayerGoSpeed4(u8); +void PlayerOnBikeCollide(u8); +void PlayerFaceDirection(u8 a); +void PlayerTurnInPlace(u8 a); +void PlayerJumpLedge(u8 a); +void PlayerIdleWheelie(u8 a); +void PlayerStartWheelie(u8 a); +void PlayerEndWheelie(u8 a); +void PlayerStandingHoppingWheelie(u8 a); +void PlayerMovingHoppingWheelie(u8 a); +void PlayerLedgeHoppingWheelie(u8 a); +void PlayerAcroTurnJump(u8 a); +void PlayerSetAnimId(u8 a, u8 b); +bool8 IsPlayerCollidingWithFarawayIslandMew(u8 direction); +void PlayerOnBikeCollideWithFarawayIslandMew(u8 direction); +u8 CheckForFieldObjectCollision(struct MapObject *a, s16 b, s16 c, u8 d, u8 e); +u8 PlayerGetZCoord(void); +void SetPlayerAvatarTransitionFlags(u16 a); void sub_808D074(u8); void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr); diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index abab1b5c4..a0d16fc50 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -299,25 +299,42 @@ enum COLLISION_LEDGE_JUMP = 6 }; -struct PlayerAvatar /* 0x202E858 */ +// player running states +enum +{ + NOT_MOVING, + TURN_DIRECTION, // not the same as turning! turns your avatar without moving. also known as a turn frame in some circles + MOVING, +}; + +// player tile transition states +enum +{ + T_NOT_MOVING, + T_TILE_TRANSITION, + T_TILE_CENTER, // player is on a frame in which they are centered on a tile during which the player either stops or keeps their momentum and keeps going, changing direction if necessary. +}; + +struct PlayerAvatar { /*0x00*/ u8 flags; - /*0x01*/ u8 bike; - /*0x02*/ u8 running2; - /*0x03*/ u8 running1; + /*0x01*/ u8 unk1; // used to be named bike, but its definitely not that. seems to be some transition flags + /*0x02*/ u8 runningState; // this is a static running state. 00 is not moving, 01 is turn direction, 02 is moving. + /*0x03*/ u8 tileTransitionState; // this is a transition running state: 00 is not moving, 01 is transition between tiles, 02 means you are on the frame in which you have centered on a tile but are about to keep moving, even if changing directions. 2 is also used for a ledge hop, since you are transitioning. /*0x04*/ u8 spriteId; /*0x05*/ u8 mapObjectId; - /*0x06*/ u8 unk6; + /*0x06*/ bool8 preventStep; /*0x07*/ u8 gender; - u8 acroBikeState; - u8 unk9; - u8 bikeFrameCounter; - u8 unkB; - u32 unkC; - u32 unk10; - u8 unk14[8]; - u8 unk1C[8]; - // TODO: rest of struct + /*0x08*/ u8 acroBikeState; // 00 is normal, 01 is turning, 02 is standing wheelie, 03 is hopping wheelie + /*0x09*/ u8 newDirBackup; // during bike movement, the new direction as opposed to player's direction is backed up here. + /*0x0A*/ u8 bikeFrameCounter; // on the mach bike, when this value is 1, the bike is moving but not accelerating yet for 1 tile. on the acro bike, this acts as a timer for acro bike. + /*0x0B*/ u8 bikeSpeed; + // acro bike only + /*0x0C*/ u32 directionHistory; // up/down/left/right history is stored in each nybble, but using the field directions and not the io inputs. + /*0x10*/ u32 abStartSelectHistory; // same as above but for A + B + start + select only + // these two are timer history arrays which [0] is the active timer for acro bike. every element is backed up to the next element upon update. + /*0x14*/ u8 dirTimerHistory[8]; + /*0x1C*/ u8 abStartSelectTimerHistory[8]; }; struct Camera diff --git a/ld_script.txt b/ld_script.txt index 7301ce357..f711c9fa3 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -162,7 +162,7 @@ SECTIONS { asm/contest_link_80FC4F4.o(.text); asm/item_use.o(.text); asm/battle_anim_80FE840.o(.text); - asm/bike.o(.text); + src/bike.o(.text); asm/easy_chat.o(.text); asm/mon_markings.o(.text); asm/mauville_old_man.o(.text); @@ -409,7 +409,7 @@ SECTIONS { data/rotating_gate.o(.rodata); data/item_use.o(.rodata); data/battle_anim_80FE840.o(.rodata); - data/bike.o(.rodata); + src/bike.o(.rodata); data/easy_chat.o(.rodata); data/mon_markings.o(.rodata); data/mauville_old_man.o(.rodata); diff --git a/src/bike.c b/src/bike.c new file mode 100644 index 000000000..b97a6dba6 --- /dev/null +++ b/src/bike.c @@ -0,0 +1,1078 @@ +#include "global.h" +#include "bike.h" +#include "field_map_obj.h" +#include "field_player_avatar.h" +#include "fieldmap.h" +#include "constants/flags.h" +#include "global.fieldmap.h" +#include "metatile_behavior.h" +#include "overworld.h" +#include "constants/songs.h" +#include "sound.h" + +extern bool8 gBikeCyclingChallenge; +extern u8 gBikeCollisions; +extern bool8 gUnknown_02037348; + +extern u8 sub_8093514(u8 direction); +extern u8 sub_808B980(u8 direction); +extern u8 sub_808B9BC(u8 direction); +extern u8 sub_808B9A4(u8 direction); +extern u8 sub_808C1B4(u8 direction); +extern u8 npc_use_some_d2s(u8 direction); +extern void Overworld_ClearSavedMusic(void); +extern void Overworld_PlaySpecialMapMusic(void); + +// this file's functions +static void MovePlayerOnMachBike(u8, u16, u16); +static u8 GetMachBikeTransition(u8 *); +static void MachBikeTransition_FaceDirection(u8); +static void MachBikeTransition_TurnDirection(u8); +static void MachBikeTransition_TrySpeedUp(u8); +static void MachBikeTransition_TrySlowDown(u8); +static void MovePlayerOnAcroBike(u8, u16, u16); +static u8 CheckMovementInputAcroBike(u8 *, u16, u16); +static u8 AcroBikeHandleInputNormal(u8 *, u16, u16); +static u8 AcroBikeHandleInputTurning(u8 *, u16, u16); +static u8 AcroBikeHandleInputWheelieStanding(u8 *, u16, u16); +static u8 AcroBikeHandleInputBunnyHop(u8 *, u16, u16); +static u8 AcroBikeHandleInputWheelieMoving(u8 *, u16, u16); +static u8 AcroBikeHandleInputSidewaysJump(u8 *, u16, u16); +static u8 AcroBikeHandleInputTurnJump(u8 *, u16, u16); +static void AcroBikeTransition_FaceDirection(u8); +static void AcroBikeTransition_TurnDirection(u8); +static void AcroBikeTransition_Moving(u8); +static void AcroBikeTransition_NormalToWheelie(u8); +static void AcroBikeTransition_WheelieToNormal(u8); +static void AcroBikeTransition_WheelieIdle(u8); +static void AcroBikeTransition_WheelieHoppingStanding(u8); +static void AcroBikeTransition_WheelieHoppingMoving(u8); +static void AcroBikeTransition_SideJump(u8); +static void AcroBikeTransition_TurnJump(u8); +static void AcroBikeTransition_WheelieMoving(u8); +static void AcroBikeTransition_WheelieRisingMoving(u8); +static void AcroBikeTransition_WheelieLoweringMoving(u8); +static void AcroBike_TryHistoryUpdate(u16, u16); +static u8 AcroBike_GetJumpDirection(void); +static void Bike_UpdateDirTimerHistory(u8); +static void Bike_UpdateABStartSelectHistory(u8); +static u8 Bike_DPadToDirection(u16); +static u8 get_some_collision(u8); +static u8 Bike_CheckCollisionTryAdvanceCollisionCount(struct MapObject *, s16, s16, u8, u8); +static bool8 IsRunningDisallowedByMetatile(u8); +static void Bike_TryAdvanceCyclingRoadCollisions(); +static u8 CanBikeFaceDirOnMetatile(u8, u8); +static bool8 WillPlayerCollideWithCollision(u8, u8); +static void Bike_SetBikeStill(void); + +// const rom data + +/* + A bike transition is a type of callback for the bike that actually + modifies the bicycle's direction or momentum or otherwise movement. + Alternatively, a bike may also have input handlers which process the + bike transition to call: the acro bike has input handlers while the mach + bike does not. This is because the Acro needs to know the button inputs + for its complex tricks and actions. +*/ + +static void (*const sMachBikeTransitions[])(u8) = +{ + MachBikeTransition_FaceDirection, // Face vs Turn: Face has no anim while Turn does. Turn checks for collision because if you turn right as opposed to face right, if there is a wall there, turn will make a bonk sound effect while face will not. + MachBikeTransition_TurnDirection, + MachBikeTransition_TrySpeedUp, + MachBikeTransition_TrySlowDown, +}; + +// bikeFrameCounter is input which is represented by sMachBikeSpeeds in order: 0 is normal speed (1 speed), 1 is fast speed (2 speed), 2 is fastest speed (4 speed) +static void (*const sMachBikeSpeedCallbacks[])(u8) = +{ + PlayerGoSpeed1, // normal speed (1 speed) + PlayerGoSpeed2, // fast speed (2 speed) + PlayerGoSpeed4, // fastest speed (4 speed) +}; + +static void (*const sAcroBikeTransitions[])(u8) = +{ + AcroBikeTransition_FaceDirection, + AcroBikeTransition_TurnDirection, + AcroBikeTransition_Moving, + AcroBikeTransition_NormalToWheelie, + AcroBikeTransition_WheelieToNormal, + AcroBikeTransition_WheelieIdle, + AcroBikeTransition_WheelieHoppingStanding, + AcroBikeTransition_WheelieHoppingMoving, + AcroBikeTransition_SideJump, + AcroBikeTransition_TurnJump, + AcroBikeTransition_WheelieMoving, + AcroBikeTransition_WheelieRisingMoving, + AcroBikeTransition_WheelieLoweringMoving, +}; + +static u8 (*const sAcroBikeInputHandlers[])(u8 *, u16, u16) = +{ + AcroBikeHandleInputNormal, + AcroBikeHandleInputTurning, + AcroBikeHandleInputWheelieStanding, + AcroBikeHandleInputBunnyHop, + AcroBikeHandleInputWheelieMoving, + AcroBikeHandleInputSidewaysJump, + AcroBikeHandleInputTurnJump, +}; + +// used with bikeFrameCounter from mach bike +static const u16 sMachBikeSpeeds[] = {SPEED_NORMAL, SPEED_FAST, SPEED_FASTEST}; + +// this is a list of timers to compare against later, terminated with 0. the only timer being compared against is 4 frames in this list. +static const u8 sAcroBikeJumpTimerList[] = {4, 0}; + +// this is a list of history inputs to do in order to do the check to retrieve a jump direction for acro bike. it seems to be an extensible list, so its possible that Game Freak may have intended for the Acro Bike to have more complex tricks at some point. The final list only has the acro jump. +static const struct BikeHistoryInputInfo sAcroBikeTricksList[] = +{ + // the 0xF is a mask performed with each byte of the array in order to perform the check on only the last entry of the history list, otherwise the check wouldn't work as there can be 0xF0 as opposed to 0x0F. + {DIR_SOUTH, B_BUTTON, 0xF, 0xF, sAcroBikeJumpTimerList, sAcroBikeJumpTimerList, DIR_SOUTH}, + {DIR_NORTH, B_BUTTON, 0xF, 0xF, sAcroBikeJumpTimerList, sAcroBikeJumpTimerList, DIR_NORTH}, + {DIR_WEST, B_BUTTON, 0xF, 0xF, sAcroBikeJumpTimerList, sAcroBikeJumpTimerList, DIR_WEST}, + {DIR_EAST, B_BUTTON, 0xF, 0xF, sAcroBikeJumpTimerList, sAcroBikeJumpTimerList, DIR_EAST}, +}; + +// code +void MovePlayerOnBike(u8 direction, u16 newKeys, u16 heldKeys) +{ + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) + MovePlayerOnMachBike(direction, newKeys, heldKeys); + else + MovePlayerOnAcroBike(direction, newKeys, heldKeys); +} + +static void MovePlayerOnMachBike(u8 direction, u16 newKeys, u16 heldKeys) +{ + sMachBikeTransitions[GetMachBikeTransition(&direction)](direction); +} + +// dirTraveling is a variable that is 0 when the player is standing still. +static u8 GetMachBikeTransition(u8 *dirTraveling) +{ + // if the dir updated before this function, get the relevent new direction to check later. + u8 direction = player_get_direction_upper_nybble(); + + // is the player standing still? + if (*dirTraveling == 0) + { + *dirTraveling = direction; // update the direction, since below we either faced a direction or we started moving. + if (gPlayerAvatar.bikeSpeed == SPEED_STANDING) + { + gPlayerAvatar.runningState = NOT_MOVING; + return MACH_TRANS_FACE_DIRECTION; + } + gPlayerAvatar.runningState = MOVING; + return MACH_TRANS_START_MOVING; + } + + // we need to check if the last traveled direction changed from the new direction as well as ensuring that we dont update the state while the player is moving: see the else check. + if (*dirTraveling != direction && gPlayerAvatar.runningState != MOVING) + { + if (gPlayerAvatar.bikeSpeed != SPEED_STANDING) + { + *dirTraveling = direction; // implement the new direction + gPlayerAvatar.runningState = MOVING; + return MACH_TRANS_START_MOVING; + } + // if you didnt start moving but your dir was different, do a turn direction instead. + gPlayerAvatar.runningState = TURN_DIRECTION; + return MACH_TRANS_TURN_DIRECTION; + } + else // the player is either going in the current direction and hasnt changed or their state is currently moving. + { + gPlayerAvatar.runningState = MOVING; + return MACH_TRANS_KEEP_MOVING; + } +} + +// the difference between face direction and turn direction is that one changes direction while the other does the animation of turning as well as changing direction. +static void MachBikeTransition_FaceDirection(u8 direction) +{ + PlayerFaceDirection(direction); + Bike_SetBikeStill(); +} + +static void MachBikeTransition_TurnDirection(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E)) + { + PlayerTurnInPlace(direction); + Bike_SetBikeStill(); + } + else + { + MachBikeTransition_FaceDirection(playerMapObj->mapobj_unk_18); + } +} + +static void MachBikeTransition_TrySpeedUp(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + u8 collision; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == FALSE) + { + // we cannot go forward, so either slow down or, if we are stopped, idle face direction. + if (gPlayerAvatar.bikeSpeed) + MachBikeTransition_TrySlowDown(playerMapObj->placeholder18); + else + MachBikeTransition_FaceDirection(playerMapObj->placeholder18); + } + else + { + collision = get_some_collision(direction); + if (collision > 0 && collision < 12) + { + // we hit a solid object, but check to see if its a ledge and then jump. + if (collision == COLLISION_LEDGE_JUMP) + { + PlayerJumpLedge(direction); + } + else + { + // we hit a solid object that is not a ledge, so perform the collision. + Bike_SetBikeStill(); + if (collision == 4 && IsPlayerCollidingWithFarawayIslandMew(direction)) + PlayerOnBikeCollideWithFarawayIslandMew(direction); + else if (collision < 5 || collision > 8) + PlayerOnBikeCollide(direction); + } + } + else + { + // we did not hit anything that can slow us down, so perform the advancement callback depending on the bikeFrameCounter and try to increase the mach bike's speed. + sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction); + gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // same as dividing by 2, but compiler is insistent on >> 1 + if (gPlayerAvatar.bikeFrameCounter < 2) // do not go faster than the last element in the mach bike array + gPlayerAvatar.bikeFrameCounter++; + } + } +} + +static void MachBikeTransition_TrySlowDown(u8 direction) +{ + u8 collision; + + if (gPlayerAvatar.bikeSpeed != SPEED_STANDING) + gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed; + + collision = get_some_collision(direction); + + if (collision > 0 && collision < 12) + { + if (collision == COLLISION_LEDGE_JUMP) + { + PlayerJumpLedge(direction); + } + else + { + Bike_SetBikeStill(); + if (collision == 4 && IsPlayerCollidingWithFarawayIslandMew(direction)) + PlayerOnBikeCollideWithFarawayIslandMew(direction); + else if (collision < 5 || collision > 8) + PlayerOnBikeCollide(direction); + } + } + else + { + sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction); + } +} + +// the acro bike requires the input handler to be executed before the transition can. +static void MovePlayerOnAcroBike(u8 newDirection, u16 newKeys, u16 heldKeys) +{ + sAcroBikeTransitions[CheckMovementInputAcroBike(&newDirection, newKeys, heldKeys)](newDirection); +} + +static u8 CheckMovementInputAcroBike(u8 *newDirection, u16 newKeys, u16 heldKeys) +{ + return sAcroBikeInputHandlers[gPlayerAvatar.acroBikeState](newDirection, newKeys, heldKeys); +} + +static u8 AcroBikeHandleInputNormal(u8 *newDirection, u16 newKeys, u16 heldKeys) +{ + u8 direction = player_get_direction_upper_nybble(); + + gPlayerAvatar.bikeFrameCounter = 0; + if (*newDirection == DIR_NONE) + { + if (newKeys & B_BUTTON) + { + //We're standing still with the B button held. + //Do a wheelie. + *newDirection = direction; + gPlayerAvatar.runningState = NOT_MOVING; + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + return ACRO_TRANS_NORMAL_TO_WHEELIE; + } + else + { + *newDirection = direction; + gPlayerAvatar.runningState = NOT_MOVING; + return ACRO_TRANS_FACE_DIRECTION; + } + } + if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == SPEED_STANDING) + { + gPlayerAvatar.bikeSpeed++; + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING; + return ACRO_TRANS_WHEELIE_RISING_MOVING; + } + if (*newDirection != direction && gPlayerAvatar.runningState != MOVING) + { + gPlayerAvatar.acroBikeState = ACRO_STATE_TURNING; + gPlayerAvatar.newDirBackup = *newDirection; + gPlayerAvatar.runningState = NOT_MOVING; + return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys); + } + gPlayerAvatar.runningState = MOVING; + return ACRO_TRANS_MOVING; +} + +static u8 AcroBikeHandleInputTurning(u8 *newDirection, u16 newKeys, u16 heldKeys) +{ + u8 direction; + + *newDirection = gPlayerAvatar.newDirBackup; + gPlayerAvatar.bikeFrameCounter++; + + // Wait 6 frames before actually changing direction + if (gPlayerAvatar.bikeFrameCounter > 6) // ... because it takes 6 frames to advance 1 tile. + { + gPlayerAvatar.runningState = TURN_DIRECTION; + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + Bike_SetBikeStill(); + return ACRO_TRANS_TURN_DIRECTION; + } + direction = player_get_direction_upper_nybble(); + if (*newDirection == AcroBike_GetJumpDirection()) + { + Bike_SetBikeStill(); // Bike_SetBikeStill sets speed to standing, but the next line immediately overrides it. could have just reset acroBikeState to 0 here instead of wasting a jump. + gPlayerAvatar.bikeSpeed = SPEED_NORMAL; + if (*newDirection == GetOppositeDirection(direction)) + { + // do a turn jump. + // no need to update runningState, didnt move. + gPlayerAvatar.acroBikeState = ACRO_STATE_TURN_JUMP; + return ACRO_TRANS_TURN_JUMP; + } + else + { + // do a sideways jump. + gPlayerAvatar.runningState = MOVING; // we need to move, set state to moving. + gPlayerAvatar.acroBikeState = ACRO_STATE_SIDE_JUMP; + return ACRO_TRANS_SIDE_JUMP; + } + } + *newDirection = direction; + return ACRO_TRANS_FACE_DIRECTION; +} + +static u8 AcroBikeHandleInputWheelieStanding(u8 *newDirection, u16 newKeys, u16 heldKeys) +{ + u8 direction; + struct MapObject *playerMapObj; + + direction = player_get_direction_upper_nybble(); + playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + gPlayerAvatar.runningState = NOT_MOVING; + + if (heldKeys & B_BUTTON) + gPlayerAvatar.bikeFrameCounter++; + else + { + // B button was released. + gPlayerAvatar.bikeFrameCounter = 0; + if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + { + // Go back to normal on flat ground + *newDirection = direction; + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + Bike_SetBikeStill(); + return ACRO_TRANS_WHEELIE_TO_NORMAL; + } + } + if (gPlayerAvatar.bikeFrameCounter >= 40) + { + *newDirection = direction; + gPlayerAvatar.acroBikeState = ACRO_STATE_BUNNY_HOP; + Bike_SetBikeStill(); + return ACRO_TRANS_WHEELIE_HOPPING_STANDING; + } + if (*newDirection == direction) + { + gPlayerAvatar.runningState = MOVING; + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING; + Bike_SetBikeStill(); + return ACRO_TRANS_WHEELIE_MOVING; + } + if (*newDirection == 0) + { + *newDirection = direction; + return ACRO_TRANS_WHEELIE_IDLE; + } + gPlayerAvatar.runningState = TURN_DIRECTION; + return ACRO_TRANS_WHEELIE_IDLE; +} + +static u8 AcroBikeHandleInputBunnyHop(u8 *newDirection, u16 newKeys, u16 heldKeys) +{ + u8 direction; + struct MapObject *playerMapObj; + + direction = player_get_direction_upper_nybble(); + playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (!(heldKeys & B_BUTTON)) + { + // B button was released + Bike_SetBikeStill(); + if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + { + // even though B was released, dont undo the wheelie on the bumpy slope. + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys); + } + else + { + // .. otherwise, go back to normal on flat ground + *newDirection = direction; + gPlayerAvatar.runningState = NOT_MOVING; + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + return ACRO_TRANS_WHEELIE_TO_NORMAL; + } + } + + // B Button is still held + + if (*newDirection == DIR_NONE) + { + // we did not move, so keep hopping in place without moving. + *newDirection = direction; + gPlayerAvatar.runningState = NOT_MOVING; + return ACRO_TRANS_WHEELIE_HOPPING_STANDING; + } + if (*newDirection != direction && gPlayerAvatar.runningState != MOVING) + { + // we changed direction, so turn but do not move hop. + gPlayerAvatar.runningState = TURN_DIRECTION; + return ACRO_TRANS_WHEELIE_HOPPING_STANDING; + } + // otherwise, we started moving while hopping + gPlayerAvatar.runningState = MOVING; + return ACRO_TRANS_WHEELIE_HOPPING_MOVING; +} + +static u8 AcroBikeHandleInputWheelieMoving(u8 *newDirection, u16 newKeys, u16 heldKeys) +{ + u8 direction; + struct MapObject *playerMapObj; + + direction = player_get_direction_lower_nybble(); + playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (!(heldKeys & B_BUTTON)) + { + // we were moving on a wheelie, but we let go while moving. reset bike still status + Bike_SetBikeStill(); + if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + { + // we let go of B and arent on a bumpy slope, set state to normal because now we need to handle this + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + if (*newDirection == DIR_NONE) + { + // we stopped moving but are turning, still try to lower the wheelie in place. + *newDirection = direction; + gPlayerAvatar.runningState = NOT_MOVING; + return ACRO_TRANS_WHEELIE_TO_NORMAL; + } + if (*newDirection != direction && gPlayerAvatar.runningState != MOVING) + { + // we did not turn while lowering wheelie, so do so without turning. + gPlayerAvatar.runningState = NOT_MOVING; + return ACRO_TRANS_WHEELIE_TO_NORMAL; + } + // if we are moving while lowering wheelie, put the acro into a lowering state while moving. + gPlayerAvatar.runningState = MOVING; + return ACRO_TRANS_WHEELIE_LOWERING_MOVING; + } + // please do not undo the wheelie on a bumpy slope + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys); + } + // we are still holding B. + if (*newDirection == DIR_NONE) + { + // idle the wheelie in place because we're holding B without moving. + *newDirection = direction; + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + gPlayerAvatar.runningState = NOT_MOVING; + Bike_SetBikeStill(); + return ACRO_TRANS_WHEELIE_IDLE; + } + if (direction != *newDirection && gPlayerAvatar.runningState != MOVING) + { + gPlayerAvatar.runningState = NOT_MOVING; + return ACRO_TRANS_WHEELIE_IDLE; + } + gPlayerAvatar.runningState = MOVING; + return ACRO_TRANS_WHEELIE_MOVING; +} + +static u8 AcroBikeHandleInputSidewaysJump(u8 *ptr, u16 newKeys, u16 heldKeys) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + playerMapObj->mapobj_bit_9 = 0; + FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18); + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + return CheckMovementInputAcroBike(ptr, newKeys, heldKeys); +} + +static u8 AcroBikeHandleInputTurnJump(u8 *ptr, u16 newKeys, u16 heldKeys) +{ + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + return CheckMovementInputAcroBike(ptr, newKeys, heldKeys); +} + +static void AcroBikeTransition_FaceDirection(u8 direction) +{ + PlayerFaceDirection(direction); +} + +static void AcroBikeTransition_TurnDirection(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + PlayerFaceDirection(direction); +} + +static void AcroBikeTransition_Moving(u8 direction) +{ + u8 collision; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + AcroBikeTransition_FaceDirection(playerMapObj->placeholder18); + return; + } + collision = get_some_collision(direction); + if (collision > 0 && collision < 12) + { + if (collision == COLLISION_LEDGE_JUMP) + PlayerJumpLedge(direction); + else if (collision == 4 && IsPlayerCollidingWithFarawayIslandMew(direction)) + PlayerOnBikeCollideWithFarawayIslandMew(direction); + else if (collision < 5 || collision > 8) + PlayerOnBikeCollide(direction); + } + else + { + PlayerGoSpeed3(direction); + } +} + +static void AcroBikeTransition_NormalToWheelie(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + PlayerStartWheelie(direction); +} + +static void AcroBikeTransition_WheelieToNormal(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + PlayerEndWheelie(direction); +} + +static void AcroBikeTransition_WheelieIdle(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + PlayerIdleWheelie(direction); +} + +static void AcroBikeTransition_WheelieHoppingStanding(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + PlayerStandingHoppingWheelie(direction); +} + +static void AcroBikeTransition_WheelieHoppingMoving(u8 direction) +{ + u8 collision; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + AcroBikeTransition_WheelieHoppingStanding(playerMapObj->placeholder18); + return; + } + collision = get_some_collision(direction); + // TODO: Try to get rid of this goto + if (collision == 0 || collision == 9) + { + goto derp; + } + else if (collision == 6) + { + PlayerLedgeHoppingWheelie(direction); + } + else if (collision < 5 || collision > 8) + { + if (collision <= 11) + { + AcroBikeTransition_WheelieHoppingStanding(direction); + } + else + { + derp: + PlayerMovingHoppingWheelie(direction); + } + } +} + +static void AcroBikeTransition_SideJump(u8 direction) +{ + u8 collision; + struct MapObject *playerMapObj; + + collision = get_some_collision(direction); + if (collision != 0) + { + if (collision == 7) + return; + if (collision < 10) + { + AcroBikeTransition_TurnDirection(direction); + return; + } + if (WillPlayerCollideWithCollision(collision, direction) == FALSE) + { + AcroBikeTransition_TurnDirection(direction); + return; + } + } + playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + PlaySE(SE_JITE_PYOKO); + playerMapObj->mapobj_bit_9 = 1; + PlayerSetAnimId(sub_8093514(direction), 2); +} + +static void AcroBikeTransition_TurnJump(u8 direction) +{ + PlayerAcroTurnJump(direction); +} + +static void AcroBikeTransition_WheelieMoving(u8 direction) +{ + u8 collision; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + PlayerIdleWheelie(playerMapObj->placeholder18); + return; + } + collision = get_some_collision(direction); + if (collision > 0 && collision < 12) + { + if (collision == 6) + { + PlayerLedgeHoppingWheelie(direction); + } + else if (collision == 9) + { + PlayerIdleWheelie(direction); + } + else if (collision <= 4) + { + if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + PlayerIdleWheelie(direction); + else + sub_808B980(direction); //hit wall? + } + return; + } + sub_808B9BC(direction); + gPlayerAvatar.runningState = MOVING; +} + +static void AcroBikeTransition_WheelieRisingMoving(u8 direction) +{ + u8 collision; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + PlayerStartWheelie(playerMapObj->placeholder18); + return; + } + collision = get_some_collision(direction); + if (collision > 0 && collision < 12) + { + if (collision == 6) + { + PlayerLedgeHoppingWheelie(direction); + } + else if (collision == 9) + { + PlayerIdleWheelie(direction); + } + else if (collision <= 4) + { + if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + PlayerIdleWheelie(direction); + else + sub_808B980(direction); //hit wall? + } + return; + } + sub_808B9A4(direction); + gPlayerAvatar.runningState = MOVING; +} + +static void AcroBikeTransition_WheelieLoweringMoving(u8 direction) +{ + u8 collision; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + PlayerEndWheelie(playerMapObj->placeholder18); + return; + } + collision = get_some_collision(direction); + if (collision > 0 && collision < 12) + { + if (collision == 6) + PlayerJumpLedge(direction); + else if (collision < 5 || collision > 8) + PlayerEndWheelie(direction); + return; + } + npc_use_some_d2s(direction); +} + +void Bike_TryAcroBikeHistoryUpdate(u16 newKeys, u16 heldKeys) +{ + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE) + AcroBike_TryHistoryUpdate(newKeys, heldKeys); +} + +static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is unused +{ + u8 direction = Bike_DPadToDirection(heldKeys); + + if (direction == (gPlayerAvatar.directionHistory & 0xF)) + { + // increment the timer for direction history since last input. + if (gPlayerAvatar.dirTimerHistory[0] < 0xFF) + gPlayerAvatar.dirTimerHistory[0]++; + } + else + { + Bike_UpdateDirTimerHistory(direction); + gPlayerAvatar.bikeSpeed = SPEED_STANDING; + } + + direction = heldKeys & (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON); // directions is reused for some reason. + if (direction == (gPlayerAvatar.abStartSelectHistory & 0xF)) + { + if (gPlayerAvatar.abStartSelectTimerHistory[0] < 0xFF) + gPlayerAvatar.abStartSelectTimerHistory[0]++; + } + else + { + Bike_UpdateABStartSelectHistory(direction); + gPlayerAvatar.bikeSpeed = SPEED_STANDING; + } +} + +static bool8 HasPlayerInputTakenLongerThanList(const u8 *dirTimerList, const u8 *abStartSelectTimerList) +{ + u8 i; + + for (i = 0; dirTimerList[i] != 0; i++) + { + if (gPlayerAvatar.dirTimerHistory[i] > dirTimerList[i]) + return FALSE; + } + for (i = 0; abStartSelectTimerList[i] != 0; i++) + { + if (gPlayerAvatar.abStartSelectTimerHistory[i] > abStartSelectTimerList[i]) + return FALSE; + } + return TRUE; +} + +static u8 AcroBike_GetJumpDirection(void) +{ + u32 i; + + for (i = 0; i < ARRAY_COUNT(sAcroBikeTricksList); i++) + { + const struct BikeHistoryInputInfo *historyInputInfo = &sAcroBikeTricksList[i]; + u32 dirHistory = gPlayerAvatar.directionHistory; + u32 abStartSelectHistory = gPlayerAvatar.abStartSelectHistory; + + dirHistory &= historyInputInfo->dirHistoryMask; + abStartSelectHistory &= historyInputInfo->abStartSelectHistoryMask; + if (dirHistory == historyInputInfo->dirHistoryMatch && abStartSelectHistory == historyInputInfo->abStartSelectHistoryMatch && HasPlayerInputTakenLongerThanList(historyInputInfo->dirTimerHistoryList, historyInputInfo->abStartSelectHistoryList)) + return historyInputInfo->direction; + } + return 0; +} + +static void Bike_UpdateDirTimerHistory(u8 dir) +{ + u8 i; + + gPlayerAvatar.directionHistory = (gPlayerAvatar.directionHistory << 4) | (dir & 0xF); + + for (i = 7; i != 0; i--) + gPlayerAvatar.dirTimerHistory[i] = gPlayerAvatar.dirTimerHistory[i - 1]; + gPlayerAvatar.dirTimerHistory[0] = 1; +} + +static void Bike_UpdateABStartSelectHistory(u8 input) +{ + u8 i; + + gPlayerAvatar.abStartSelectHistory = (gPlayerAvatar.abStartSelectHistory << 4) | (input & 0xF); + + for (i = 7; i != 0; i--) + gPlayerAvatar.abStartSelectTimerHistory[i] = gPlayerAvatar.abStartSelectTimerHistory[i - 1]; + gPlayerAvatar.abStartSelectTimerHistory[0] = 1; +} + +static u8 Bike_DPadToDirection(u16 heldKeys) +{ + if (heldKeys & DPAD_UP) + return DIR_NORTH; + if (heldKeys & DPAD_DOWN) + return DIR_SOUTH; + if (heldKeys & DPAD_LEFT) + return DIR_WEST; + if (heldKeys & DPAD_RIGHT) + return DIR_EAST; + return DIR_NONE; +} + +static u8 get_some_collision(u8 direction) +{ + s16 x; + s16 y; + u8 metatitleBehavior; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + x = playerMapObj->coords2.x; + y = playerMapObj->coords2.y; + MoveCoords(direction, &x, &y); + metatitleBehavior = MapGridGetMetatileBehaviorAt(x, y); + return Bike_CheckCollisionTryAdvanceCollisionCount(playerMapObj, x, y, direction, metatitleBehavior); +} + +static u8 Bike_CheckCollisionTryAdvanceCollisionCount(struct MapObject *mapObject, s16 x, s16 y, u8 direction, u8 metatitleBehavior) +{ + u8 collision = CheckForFieldObjectCollision(mapObject, x, y, direction, metatitleBehavior); + + if (collision > 4) + return collision; + + if (collision == 0 && IsRunningDisallowedByMetatile(metatitleBehavior)) + collision = 2; + + if (collision) + Bike_TryAdvanceCyclingRoadCollisions(); + + return collision; +} + +bool8 RS_IsRunningDisallowed(u8 tile) +{ + if (IsRunningDisallowedByMetatile(tile) != FALSE || gMapHeader.mapType == MAP_TYPE_INDOOR) + return TRUE; + else + return FALSE; +} + +static bool8 IsRunningDisallowedByMetatile(u8 tile) +{ + if (MetatileBehavior_IsRunningDisallowed(tile)) + return TRUE; + if (MetatileBehavior_IsFortreeBridge(tile) && (PlayerGetZCoord() & 1) == 0) + return TRUE; + return FALSE; +} + +static void Bike_TryAdvanceCyclingRoadCollisions(void) +{ + if (gBikeCyclingChallenge != FALSE && gBikeCollisions < 100) + gBikeCollisions++; +} + +static bool8 CanBikeFaceDirOnMetatile(u8 direction, u8 tile) +{ + if (direction == DIR_EAST || direction == DIR_WEST) + { + // Bike cannot face east or west on a vertical rail + if (MetatileBehavior_IsIsolatedVerticalRail(tile) + || MetatileBehavior_IsVerticalRail(tile)) + return FALSE; + } + else + { + // Bike cannot face north or south on a horizontal rail + if (MetatileBehavior_IsIsolatedHorizontalRail(tile) + || MetatileBehavior_IsHorizontalRail(tile)) + return FALSE; + } + return TRUE; +} + +static bool8 WillPlayerCollideWithCollision(u8 newTileCollision, u8 direction) +{ + if (direction == DIR_NORTH || direction == DIR_SOUTH) + { + if (newTileCollision == 10 || newTileCollision == 12) + return FALSE; + } + else if (newTileCollision == 11 || newTileCollision == 13) + { + return FALSE; + } + + return TRUE; +} + +bool8 IsBikingDisallowedByPlayer(void) +{ + s16 x, y; + u8 tileBehavior; + + if (!(gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_4))) + { + PlayerGetDestCoords(&x, &y); + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (!IsRunningDisallowedByMetatile(tileBehavior)) + return FALSE; + } + return TRUE; +} + +bool8 player_should_look_direction_be_enforced_upon_movement(void) +{ + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE) != FALSE && MetatileBehavior_IsBumpySlope(gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E) != FALSE) + return FALSE; + else + return TRUE; +} + +void GetOnOffBike(u8 transitionFlags) +{ + gUnknown_02037348 = FALSE; + + if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) + { + SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT); + Overworld_ClearSavedMusic(); + Overworld_PlaySpecialMapMusic(); + } + else + { + SetPlayerAvatarTransitionFlags(transitionFlags); + Overworld_SetSavedMusic(BGM_CYCLING); + Overworld_ChangeMusicTo(BGM_CYCLING); + } +} + +void BikeClearState(int newDirHistory, int newAbStartHistory) +{ + u8 i; + + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + gPlayerAvatar.newDirBackup = DIR_NONE; + gPlayerAvatar.bikeFrameCounter = 0; + gPlayerAvatar.bikeSpeed = SPEED_STANDING; + gPlayerAvatar.directionHistory = newDirHistory; + gPlayerAvatar.abStartSelectHistory = newAbStartHistory; + + for (i = 0; i < 8; i++) + gPlayerAvatar.dirTimerHistory[i] = 0; + + for (i = 0; i < 8; i++) + gPlayerAvatar.abStartSelectTimerHistory[i] = 0; +} + +void Bike_UpdateBikeCounterSpeed(u8 counter) +{ + gPlayerAvatar.bikeFrameCounter = counter; + gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // lazy way of multiplying by 1.5. +} + +static void Bike_SetBikeStill(void) +{ + gPlayerAvatar.bikeFrameCounter = 0; + gPlayerAvatar.bikeSpeed = SPEED_STANDING; +} + +s16 GetPlayerSpeed(void) +{ + // because the player pressed a direction, it won't ever return a speed of 0 since this function returns the player's current speed. + s16 machSpeeds[3]; + + memcpy(machSpeeds, sMachBikeSpeeds, sizeof(machSpeeds)); + + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) + return machSpeeds[gPlayerAvatar.bikeFrameCounter]; + else if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE) + return SPEED_FASTER; + else if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_DASH)) + return SPEED_FAST; + else + return SPEED_NORMAL; +} + +void Bike_HandleBumpySlopeJump(void) +{ + s16 x, y; + u8 tileBehavior; + + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE) + { + PlayerGetDestCoords(&x, &y); + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (MetatileBehavior_IsBumpySlope(tileBehavior)) + { + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + sub_808C1B4(player_get_direction_upper_nybble()); + } + } +} + +bool32 IsRunningDisallowed(u8 metatile) +{ + if (!(gMapHeader.flags & 4) || IsRunningDisallowedByMetatile(metatile) == TRUE) + return TRUE; + else + return FALSE; +} diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 2b88fec3a..ea5c77399 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -86,7 +86,7 @@ extern void sub_806A068(u16, u8); extern void sub_807F19C(void); extern void sub_807B140(void); extern void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies); -extern void sub_8085784(void); +extern void Overworld_PlaySpecialMapMusic(void); extern void sub_81BFA38(struct Pokemon *party, u8 monId, u8 partyCount, void *CB2_ptr, u16 move); extern u8 sub_81C1B94(void); extern void sub_807F1A8(u8 arg0, const u8 *arg1, u8 arg2); @@ -698,7 +698,7 @@ static void Task_EvolutionScene(u8 taskID) if (!(gTasks[taskID].tBits & TASK_BIT_LEARN_MOVE)) { StopMapMusic(); - sub_8085784(); + Overworld_PlaySpecialMapMusic(); } gTasks[taskID].tBits |= TASK_BIT_LEARN_MOVE; @@ -727,7 +727,7 @@ static void Task_EvolutionScene(u8 taskID) if (!(gTasks[taskID].tBits & TASK_BIT_LEARN_MOVE)) { StopMapMusic(); - sub_8085784(); + Overworld_PlaySpecialMapMusic(); } if (!gTasks[taskID].tEvoWasStopped) CreateShedinja(gTasks[taskID].tPreEvoSpecies, mon); diff --git a/sym_ewram.txt b/sym_ewram.txt index 31ecf2085..c090ad1ae 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1130,10 +1130,10 @@ gUnknown_0203AB4E: @ 203AB4E gUnknown_0203AB50: @ 203AB50 .space 0x4 -gUnknown_0203AB54: @ 203AB54 +gBikeCyclingChallenge: @ 203AB54 .space 0x1 -gUnknown_0203AB55: @ 203AB55 +gBikeCollisions: @ 203AB55 .space 0x3 gUnknown_0203AB58: @ 203AB58