From 5515e328b2c44240d1bcc5656a3818b1b3b8343e Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 12 Aug 2022 21:18:10 -0400 Subject: [PATCH] Clean up lock/unlock anim movement --- asm/macros/movement.inc | 4 +-- data/maps/Route111/scripts.inc | 2 +- include/constants/event_object_movement.h | 4 +-- include/event_object_movement.h | 2 +- .../movement_action_func_tables.h | 12 +++---- src/event_object_movement.c | 34 +++++++++---------- src/rotating_tile_puzzle.c | 16 ++++----- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/asm/macros/movement.inc b/asm/macros/movement.inc index 62618379b..a43dc07ac 100644 --- a/asm/macros/movement.inc +++ b/asm/macros/movement.inc @@ -152,8 +152,8 @@ create_movement_action walk_slow_diag_northeast, MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_RIGHT create_movement_action walk_slow_diag_southwest, MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_LEFT create_movement_action walk_slow_diag_southeast, MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_RIGHT - create_movement_action store_lock_anim, MOVEMENT_ACTION_STORE_AND_LOCK_ANIM - create_movement_action free_unlock_anim, MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM + create_movement_action lock_anim, MOVEMENT_ACTION_LOCK_ANIM + create_movement_action unlock_anim, MOVEMENT_ACTION_UNLOCK_ANIM create_movement_action walk_left_affine, MOVEMENT_ACTION_WALK_LEFT_AFFINE create_movement_action walk_right_affine, MOVEMENT_ACTION_WALK_RIGHT_AFFINE create_movement_action levitate, MOVEMENT_ACTION_LEVITATE diff --git a/data/maps/Route111/scripts.inc b/data/maps/Route111/scripts.inc index 6cb83b452..f97326c54 100644 --- a/data/maps/Route111/scripts.inc +++ b/data/maps/Route111/scripts.inc @@ -144,7 +144,7 @@ Route111_EventScript_RootFossilDisappeared:: @ Unused Route111_Movement_PlayerFall:: - store_lock_anim + lock_anim walk_fast_down walk_fast_down walk_fast_down diff --git a/include/constants/event_object_movement.h b/include/constants/event_object_movement.h index a9d59935e..af5af5340 100755 --- a/include/constants/event_object_movement.h +++ b/include/constants/event_object_movement.h @@ -232,8 +232,8 @@ #define MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_RIGHT 0x91 #define MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_LEFT 0x92 #define MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_RIGHT 0x93 -#define MOVEMENT_ACTION_STORE_AND_LOCK_ANIM 0x94 -#define MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM 0x95 +#define MOVEMENT_ACTION_LOCK_ANIM 0x94 +#define MOVEMENT_ACTION_UNLOCK_ANIM 0x95 #define MOVEMENT_ACTION_WALK_LEFT_AFFINE 0x96 #define MOVEMENT_ACTION_WALK_RIGHT_AFFINE 0x97 #define MOVEMENT_ACTION_LEVITATE 0x98 diff --git a/include/event_object_movement.h b/include/event_object_movement.h index d31802a67..22cef4921 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -63,7 +63,7 @@ struct PairedPalettes struct LockedAnimObjectEvents { - u8 objectEventIds[OBJECT_EVENTS_COUNT]; + u8 localIds[OBJECT_EVENTS_COUNT]; u8 count; }; diff --git a/src/data/object_events/movement_action_func_tables.h b/src/data/object_events/movement_action_func_tables.h index 8070e9877..2e1b6b3b3 100755 --- a/src/data/object_events/movement_action_func_tables.h +++ b/src/data/object_events/movement_action_func_tables.h @@ -253,9 +253,9 @@ u8 MovementAction_AcroEndWheelieMoveRight_Step1(struct ObjectEvent *, struct Spr u8 MovementAction_Levitate_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_StopLevitate_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_StopLevitateAtTop_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_LockAnim_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_Finish(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_FreeAndUnlockAnim_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_UnlockAnim_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_FlyUp_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_FlyUp_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementAction_Fly_Finish(struct ObjectEvent *, struct Sprite *); @@ -410,8 +410,8 @@ u8 (*const gMovementActionFuncs_WalkSlowDiagonalUpLeft[])(struct ObjectEvent *, u8 (*const gMovementActionFuncs_WalkSlowDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_WalkSlowDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_WalkSlowDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_StoreAndLockAnim[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_FreeAndUnlockAnim[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_LockAnim[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_UnlockAnim[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_WalkLeftAffine[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_WalkRightAffine[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_Levitate[])(struct ObjectEvent *, struct Sprite *); @@ -570,8 +570,8 @@ u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *) [MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_RIGHT] = gMovementActionFuncs_WalkSlowDiagonalUpRight, [MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_LEFT] = gMovementActionFuncs_WalkSlowDiagonalDownLeft, [MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_RIGHT] = gMovementActionFuncs_WalkSlowDiagonalDownRight, - [MOVEMENT_ACTION_STORE_AND_LOCK_ANIM] = gMovementActionFuncs_StoreAndLockAnim, - [MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM] = gMovementActionFuncs_FreeAndUnlockAnim, + [MOVEMENT_ACTION_LOCK_ANIM] = gMovementActionFuncs_LockAnim, + [MOVEMENT_ACTION_UNLOCK_ANIM] = gMovementActionFuncs_UnlockAnim, [MOVEMENT_ACTION_WALK_LEFT_AFFINE] = gMovementActionFuncs_WalkLeftAffine, [MOVEMENT_ACTION_WALK_RIGHT_AFFINE] = gMovementActionFuncs_WalkRightAffine, [MOVEMENT_ACTION_LEVITATE] = gMovementActionFuncs_Levitate, diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 7ea712be6..e411082bb 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -8746,13 +8746,13 @@ static void DoRippleFieldEffect(struct ObjectEvent *objectEvent, struct Sprite * FieldEffectStart(FLDEFF_RIPPLE); } -u8 (*const gMovementActionFuncs_StoreAndLockAnim[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_StoreAndLockAnim_Step0, +u8 (*const gMovementActionFuncs_LockAnim[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_LockAnim_Step0, MovementAction_Finish, }; -u8 (*const gMovementActionFuncs_FreeAndUnlockAnim[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_FreeAndUnlockAnim_Step0, +u8 (*const gMovementActionFuncs_UnlockAnim[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_UnlockAnim_Step0, MovementAction_Finish, }; @@ -8768,36 +8768,36 @@ u8 (*const gMovementActionFuncs_FlyDown[])(struct ObjectEvent *, struct Sprite * MovementAction_Fly_Finish, }; -u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +u8 MovementAction_LockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { bool32 ableToStore = FALSE; if (sLockedAnimObjectEvents == NULL) { sLockedAnimObjectEvents = AllocZeroed(sizeof(struct LockedAnimObjectEvents)); - sLockedAnimObjectEvents->objectEventIds[0] = objectEvent->localId; + sLockedAnimObjectEvents->localIds[0] = objectEvent->localId; sLockedAnimObjectEvents->count = 1; ableToStore = TRUE; } else { u8 i; - u8 firstFreeSlot; - bool32 found; - for (firstFreeSlot = 16, found = FALSE, i = 0; i < 16; i++) + u8 firstFreeSlot = OBJECT_EVENTS_COUNT; + bool32 found = FALSE; + for (i = 0; i < OBJECT_EVENTS_COUNT; i++) { - if (firstFreeSlot == 16 && sLockedAnimObjectEvents->objectEventIds[i] == 0) + if (firstFreeSlot == OBJECT_EVENTS_COUNT && sLockedAnimObjectEvents->localIds[i] == 0) firstFreeSlot = i; - if (sLockedAnimObjectEvents->objectEventIds[i] == objectEvent->localId) + if (sLockedAnimObjectEvents->localIds[i] == objectEvent->localId) { found = TRUE; break; } } - if (!found && firstFreeSlot != 16) + if (!found && firstFreeSlot != OBJECT_EVENTS_COUNT) { - sLockedAnimObjectEvents->objectEventIds[firstFreeSlot] = objectEvent->localId; + sLockedAnimObjectEvents->localIds[firstFreeSlot] = objectEvent->localId; sLockedAnimObjectEvents->count++; ableToStore = TRUE; } @@ -8813,7 +8813,7 @@ u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *objectEvent, struct return TRUE; } -u8 MovementAction_FreeAndUnlockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +u8 MovementAction_UnlockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { bool32 ableToStore; u8 index; @@ -8823,9 +8823,9 @@ u8 MovementAction_FreeAndUnlockAnim_Step0(struct ObjectEvent *objectEvent, struc { ableToStore = FALSE; index = FindLockedObjectEventIndex(objectEvent); - if (index != 16) + if (index != OBJECT_EVENTS_COUNT) { - sLockedAnimObjectEvents->objectEventIds[index] = 0; + sLockedAnimObjectEvents->localIds[index] = 0; sLockedAnimObjectEvents->count--; ableToStore = TRUE; } @@ -8848,7 +8848,7 @@ u8 FindLockedObjectEventIndex(struct ObjectEvent *objectEvent) for (i = 0; i < OBJECT_EVENTS_COUNT; i++) { - if (sLockedAnimObjectEvents->objectEventIds[i] == objectEvent->localId) + if (sLockedAnimObjectEvents->localIds[i] == objectEvent->localId) return i; } return OBJECT_EVENTS_COUNT; diff --git a/src/rotating_tile_puzzle.c b/src/rotating_tile_puzzle.c index 4581f6e5b..7581b8107 100644 --- a/src/rotating_tile_puzzle.c +++ b/src/rotating_tile_puzzle.c @@ -27,33 +27,33 @@ struct RotatingTilePuzzle static const u8 sMovement_ShiftRight[] = { - MOVEMENT_ACTION_STORE_AND_LOCK_ANIM, + MOVEMENT_ACTION_LOCK_ANIM, MOVEMENT_ACTION_WALK_NORMAL_RIGHT, - MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM, + MOVEMENT_ACTION_UNLOCK_ANIM, MOVEMENT_ACTION_STEP_END }; static const u8 sMovement_ShiftDown[] = { - MOVEMENT_ACTION_STORE_AND_LOCK_ANIM, + MOVEMENT_ACTION_LOCK_ANIM, MOVEMENT_ACTION_WALK_NORMAL_DOWN, - MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM, + MOVEMENT_ACTION_UNLOCK_ANIM, MOVEMENT_ACTION_STEP_END }; static const u8 sMovement_ShiftLeft[] = { - MOVEMENT_ACTION_STORE_AND_LOCK_ANIM, + MOVEMENT_ACTION_LOCK_ANIM, MOVEMENT_ACTION_WALK_NORMAL_LEFT, - MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM, + MOVEMENT_ACTION_UNLOCK_ANIM, MOVEMENT_ACTION_STEP_END }; static const u8 sMovement_ShiftUp[] = { - MOVEMENT_ACTION_STORE_AND_LOCK_ANIM, + MOVEMENT_ACTION_LOCK_ANIM, MOVEMENT_ACTION_WALK_NORMAL_UP, - MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM, + MOVEMENT_ACTION_UNLOCK_ANIM, MOVEMENT_ACTION_STEP_END };