From b6430098d4f97d37ec994e8483d97be09f8ea9bc Mon Sep 17 00:00:00 2001 From: cbt6 <91667135+cbt6@users.noreply.github.com> Date: Sun, 28 Nov 2021 11:35:01 +0800 Subject: [PATCH 1/2] Rename speed parameter to distance in jump functions --- src/event_object_movement.c | 56 ++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index d92569d32..ba13a7a1d 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -45,7 +45,6 @@ enum { #define sTypeFuncId data[1] // Index into corresponding gMovementTypeFuncs_* table #define sActionFuncId data[2] // Index into corresponding gMovementActionFuncs_* table #define sDirection data[3] -#define sSpeed data[4] #define movement_type_def(setup, table) \ @@ -5386,7 +5385,7 @@ enum { JUMP_TYPE_NORMAL, }; -static void InitJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed, u8 type) +static void InitJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 distance, u8 type) { s16 displacements[ARRAY_COUNT(sJumpInitDisplacements)]; s16 x; @@ -5396,22 +5395,24 @@ static void InitJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 x = 0; y = 0; SetObjectEventDirection(objectEvent, direction); - MoveCoordsInDirection(direction, &x, &y, displacements[speed], displacements[speed]); + MoveCoordsInDirection(direction, &x, &y, displacements[distance], displacements[distance]); ShiftObjectEventCoords(objectEvent, objectEvent->currentCoords.x + x, objectEvent->currentCoords.y + y); - SetJumpSpriteData(sprite, direction, speed, type); + SetJumpSpriteData(sprite, direction, distance, type); sprite->sActionFuncId = 1; sprite->animPaused = FALSE; objectEvent->triggerGroundEffectsOnMove = TRUE; objectEvent->disableCoveringGroundEffects = TRUE; } -static void InitJumpRegular(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed, u8 type) +static void InitJumpRegular(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 distance, u8 type) { - InitJump(objectEvent, sprite, direction, speed, type); + InitJump(objectEvent, sprite, direction, distance, type); SetStepAnimHandleAlternation(objectEvent, sprite, GetMoveDirectionAnimNum(objectEvent->facingDirection)); DoShadowFieldEffect(objectEvent); } +#define sDistance data[4] + static u8 UpdateJumpAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 callback(struct Sprite *)) { s16 displacements[ARRAY_COUNT(sJumpDisplacements)]; @@ -5421,11 +5422,11 @@ static u8 UpdateJumpAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, memcpy(displacements, sJumpDisplacements, sizeof sJumpDisplacements); result = callback(sprite); - if (result == JUMP_HALFWAY && displacements[sprite->sSpeed] != 0) + if (result == JUMP_HALFWAY && displacements[sprite->sDistance] != 0) { x = 0; y = 0; - MoveCoordsInDirection(objectEvent->movementDirection, &x, &y, displacements[sprite->sSpeed], displacements[sprite->sSpeed]); + MoveCoordsInDirection(objectEvent->movementDirection, &x, &y, displacements[sprite->sDistance], displacements[sprite->sDistance]); ShiftObjectEventCoords(objectEvent, objectEvent->currentCoords.x + x, objectEvent->currentCoords.y + y); objectEvent->triggerGroundEffectsOnMove = TRUE; objectEvent->disableCoveringGroundEffects = TRUE; @@ -5440,6 +5441,8 @@ static u8 UpdateJumpAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, return result; } +#undef sDistance + static u8 DoJumpAnimStep(struct ObjectEvent *objectEvent, struct Sprite *sprite) { return UpdateJumpAnim(objectEvent, sprite, DoJumpSpriteMovement); @@ -6800,9 +6803,9 @@ bool8 MovementAction_Figure8_Step1(struct ObjectEvent *objectEvent, struct Sprit return FALSE; } -static void InitAcroWheelieJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed, u8 type) +static void InitAcroWheelieJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 distance, u8 type) { - InitJump(objectEvent, sprite, direction, speed, type); + InitJump(objectEvent, sprite, direction, distance, type); StartSpriteAnimIfDifferent(sprite, GetAcroWheelieDirectionAnimNum(direction)); DoShadowFieldEffect(objectEvent); } @@ -8166,6 +8169,7 @@ static void Step8(struct Sprite *sprite, u8 dir) sprite->y += 8 * (u16) sDirectionToVectors[dir].y; } +#define sSpeed data[4] #define sTimer data[5] static void SetSpriteDataForNormalStep(struct Sprite *sprite, u8 direction, u8 speed) @@ -8259,6 +8263,7 @@ static bool8 NpcTakeStep(struct Sprite *sprite) return TRUE; } +#undef sSpeed #undef sTimer #define sTimer data[4] @@ -8393,34 +8398,35 @@ static s16 GetJumpY(s16 i, u8 type) return sJumpYTable[type][i]; } +#define sDistance data[4] #define sJumpType data[5] #define sTimer data[6] -static void SetJumpSpriteData(struct Sprite *sprite, u8 direction, u8 speed, u8 type) +static void SetJumpSpriteData(struct Sprite *sprite, u8 direction, u8 distance, u8 type) { sprite->sDirection = direction; - sprite->sSpeed = speed; + sprite->sDistance = distance; sprite->sJumpType = type; sprite->sTimer = 0; } static u8 DoJumpSpriteMovement(struct Sprite *sprite) { - s16 speedToTime[] = {16, 16, 32}; - u8 speedToShift[] = {0, 0, 1}; + s16 distanceToTime[] = {16, 16, 32}; + u8 distanceToShift[] = {0, 0, 1}; u8 result = 0; - if (sprite->sSpeed) + if (sprite->sDistance) Step1(sprite, sprite->sDirection); - sprite->y2 = GetJumpY(sprite->sTimer >> speedToShift[sprite->sSpeed], sprite->sJumpType); + sprite->y2 = GetJumpY(sprite->sTimer >> distanceToShift[sprite->sDistance], sprite->sJumpType); sprite->sTimer++; - if (sprite->sTimer == speedToTime[sprite->sSpeed] >> 1) + if (sprite->sTimer == distanceToTime[sprite->sDistance] >> 1) result = JUMP_HALFWAY; - if (sprite->sTimer >= speedToTime[sprite->sSpeed]) + if (sprite->sTimer >= distanceToTime[sprite->sDistance]) { sprite->y2 = 0; result = JUMP_FINISHED; @@ -8431,21 +8437,21 @@ static u8 DoJumpSpriteMovement(struct Sprite *sprite) static u8 DoJumpSpecialSpriteMovement(struct Sprite *sprite) { - s16 speedToTime[] = {32, 32, 64}; - u8 speedToShift[] = {1, 1, 2}; + s16 distanceToTime[] = {32, 32, 64}; + u8 distanceToShift[] = {1, 1, 2}; u8 result = 0; - if (sprite->sSpeed && !(sprite->sTimer & 1)) + if (sprite->sDistance && !(sprite->sTimer & 1)) Step1(sprite, sprite->sDirection); - sprite->y2 = GetJumpY(sprite->sTimer >> speedToShift[sprite->sSpeed], sprite->sJumpType); + sprite->y2 = GetJumpY(sprite->sTimer >> distanceToShift[sprite->sDistance], sprite->sJumpType); sprite->sTimer++; - if (sprite->sTimer == speedToTime[sprite->sSpeed] >> 1) + if (sprite->sTimer == distanceToTime[sprite->sDistance] >> 1) result = JUMP_HALFWAY; - if (sprite->sTimer >= speedToTime[sprite->sSpeed]) + if (sprite->sTimer >= distanceToTime[sprite->sDistance]) { sprite->y2 = 0; result = JUMP_FINISHED; @@ -8454,7 +8460,7 @@ static u8 DoJumpSpecialSpriteMovement(struct Sprite *sprite) return result; } -#undef sSpeed +#undef sDistance #undef sJumpType #undef sTimer From c59c7b0518c17696b656c2fafaac297bee9077f1 Mon Sep 17 00:00:00 2001 From: cbt6 <91667135+cbt6@users.noreply.github.com> Date: Sun, 28 Nov 2021 11:56:26 +0800 Subject: [PATCH 2/2] Use enums for jump distances --- .../movement_action_func_tables.h | 12 ++- src/event_object_movement.c | 92 ++++++++++++------- 2 files changed, 67 insertions(+), 37 deletions(-) diff --git a/src/data/object_events/movement_action_func_tables.h b/src/data/object_events/movement_action_func_tables.h index f601cf82b..8070e9877 100755 --- a/src/data/object_events/movement_action_func_tables.h +++ b/src/data/object_events/movement_action_func_tables.h @@ -706,8 +706,16 @@ u8 (*const gMovementActionFuncs_WalkNormalRight[])(struct ObjectEvent *, struct MovementAction_PauseSpriteAnim, }; -static const s16 sJumpInitDisplacements[] = {0, 1, 1}; -static const s16 sJumpDisplacements[] = {0, 0, 1}; +static const s16 sJumpInitDisplacements[] = { + [JUMP_DISTANCE_IN_PLACE] = 0, + [JUMP_DISTANCE_NORMAL] = 1, + [JUMP_DISTANCE_FAR] = 1, +}; +static const s16 sJumpDisplacements[] = { + [JUMP_DISTANCE_IN_PLACE] = 0, + [JUMP_DISTANCE_NORMAL] = 0, + [JUMP_DISTANCE_FAR] = 1, +}; u8 (*const gMovementActionFuncs_Jump2Down[])(struct ObjectEvent *, struct Sprite *) = { MovementAction_Jump2Down_Step0, diff --git a/src/event_object_movement.c b/src/event_object_movement.c index ba13a7a1d..2c7ceedf4 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -40,6 +40,12 @@ enum { MOVE_SPEED_FASTEST, }; +enum { + JUMP_DISTANCE_IN_PLACE, + JUMP_DISTANCE_NORMAL, + JUMP_DISTANCE_FAR, +}; + // Sprite data used throughout #define sObjEventId data[0] #define sTypeFuncId data[1] // Index into corresponding gMovementTypeFuncs_* table @@ -5485,7 +5491,7 @@ static bool8 DoJumpInPlaceAnim(struct ObjectEvent *objectEvent, struct Sprite *s bool8 MovementAction_Jump2Down_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_SOUTH, 2, JUMP_TYPE_HIGH); + InitJumpRegular(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH); return MovementAction_Jump2Down_Step1(objectEvent, sprite); } @@ -5502,7 +5508,7 @@ bool8 MovementAction_Jump2Down_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_Jump2Up_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_NORTH, 2, JUMP_TYPE_HIGH); + InitJumpRegular(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH); return MovementAction_Jump2Up_Step1(objectEvent, sprite); } @@ -5519,7 +5525,7 @@ bool8 MovementAction_Jump2Up_Step1(struct ObjectEvent *objectEvent, struct Sprit bool8 MovementAction_Jump2Left_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_WEST, 2, JUMP_TYPE_HIGH); + InitJumpRegular(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH); return MovementAction_Jump2Left_Step1(objectEvent, sprite); } @@ -5536,7 +5542,7 @@ bool8 MovementAction_Jump2Left_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_Jump2Right_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_EAST, 2, JUMP_TYPE_HIGH); + InitJumpRegular(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH); return MovementAction_Jump2Right_Step1(objectEvent, sprite); } @@ -6067,7 +6073,7 @@ bool8 MovementAction_WaitSpriteAnim(struct ObjectEvent *objectEvent, struct Spri static void InitJumpSpecial(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) { - InitJump(objectEvent, sprite, direction, 1, JUMP_TYPE_HIGH); + InitJump(objectEvent, sprite, direction, JUMP_DISTANCE_NORMAL, JUMP_TYPE_HIGH); StartSpriteAnim(sprite, GetJumpSpecialDirectionAnimNum(direction)); } @@ -6181,7 +6187,7 @@ bool8 MovementAction_UnlockFacingDirection_Step0(struct ObjectEvent *objectEvent bool8 MovementAction_JumpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_SOUTH, 1, JUMP_TYPE_NORMAL); + InitJumpRegular(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_NORMAL, JUMP_TYPE_NORMAL); return MovementAction_JumpDown_Step1(objectEvent, sprite); } @@ -6198,7 +6204,7 @@ bool8 MovementAction_JumpDown_Step1(struct ObjectEvent *objectEvent, struct Spri bool8 MovementAction_JumpUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_NORTH, 1, JUMP_TYPE_NORMAL); + InitJumpRegular(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_NORMAL, JUMP_TYPE_NORMAL); return MovementAction_JumpUp_Step1(objectEvent, sprite); } @@ -6215,7 +6221,7 @@ bool8 MovementAction_JumpUp_Step1(struct ObjectEvent *objectEvent, struct Sprite bool8 MovementAction_JumpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_WEST, 1, JUMP_TYPE_NORMAL); + InitJumpRegular(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_NORMAL, JUMP_TYPE_NORMAL); return MovementAction_JumpLeft_Step1(objectEvent, sprite); } @@ -6232,7 +6238,7 @@ bool8 MovementAction_JumpLeft_Step1(struct ObjectEvent *objectEvent, struct Spri bool8 MovementAction_JumpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_EAST, 1, JUMP_TYPE_NORMAL); + InitJumpRegular(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_NORMAL, JUMP_TYPE_NORMAL); return MovementAction_JumpRight_Step1(objectEvent, sprite); } @@ -6249,7 +6255,7 @@ bool8 MovementAction_JumpRight_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_JumpInPlaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_SOUTH, 0, JUMP_TYPE_HIGH); + InitJumpRegular(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_HIGH); return MovementAction_JumpInPlaceDown_Step1(objectEvent, sprite); } @@ -6266,7 +6272,7 @@ bool8 MovementAction_JumpInPlaceDown_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_JumpInPlaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_NORTH, 0, JUMP_TYPE_HIGH); + InitJumpRegular(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_HIGH); return MovementAction_JumpInPlaceUp_Step1(objectEvent, sprite); } @@ -6283,7 +6289,7 @@ bool8 MovementAction_JumpInPlaceUp_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_JumpInPlaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_WEST, 0, JUMP_TYPE_HIGH); + InitJumpRegular(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_HIGH); return MovementAction_JumpInPlaceLeft_Step1(objectEvent, sprite); } @@ -6300,7 +6306,7 @@ bool8 MovementAction_JumpInPlaceLeft_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_JumpInPlaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_EAST, 0, JUMP_TYPE_HIGH); + InitJumpRegular(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_HIGH); return MovementAction_JumpInPlaceRight_Step1(objectEvent, sprite); } @@ -6317,7 +6323,7 @@ bool8 MovementAction_JumpInPlaceRight_Step1(struct ObjectEvent *objectEvent, str bool8 MovementAction_JumpInPlaceDownUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_SOUTH, 0, JUMP_TYPE_NORMAL); + InitJumpRegular(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_NORMAL); return MovementAction_JumpInPlaceDownUp_Step1(objectEvent, sprite); } @@ -6334,7 +6340,7 @@ bool8 MovementAction_JumpInPlaceDownUp_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_JumpInPlaceUpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_NORTH, 0, JUMP_TYPE_NORMAL); + InitJumpRegular(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_NORMAL); return MovementAction_JumpInPlaceUpDown_Step1(objectEvent, sprite); } @@ -6351,7 +6357,7 @@ bool8 MovementAction_JumpInPlaceUpDown_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_JumpInPlaceLeftRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_WEST, 0, JUMP_TYPE_NORMAL); + InitJumpRegular(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_NORMAL); return MovementAction_JumpInPlaceLeftRight_Step1(objectEvent, sprite); } @@ -6368,7 +6374,7 @@ bool8 MovementAction_JumpInPlaceLeftRight_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_JumpInPlaceRightLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitJumpRegular(objectEvent, sprite, DIR_EAST, 0, JUMP_TYPE_NORMAL); + InitJumpRegular(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_NORMAL); return MovementAction_JumpInPlaceRightLeft_Step1(objectEvent, sprite); } @@ -6812,7 +6818,7 @@ static void InitAcroWheelieJump(struct ObjectEvent *objectEvent, struct Sprite * bool8 MovementAction_AcroWheelieHopFaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, 0, JUMP_TYPE_LOW); + InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopFaceDown_Step1(objectEvent, sprite); } @@ -6829,7 +6835,7 @@ bool8 MovementAction_AcroWheelieHopFaceDown_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroWheelieHopFaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, 0, JUMP_TYPE_LOW); + InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopFaceUp_Step1(objectEvent, sprite); } @@ -6846,7 +6852,7 @@ bool8 MovementAction_AcroWheelieHopFaceUp_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieHopFaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, 0, JUMP_TYPE_LOW); + InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopFaceLeft_Step1(objectEvent, sprite); } @@ -6863,7 +6869,7 @@ bool8 MovementAction_AcroWheelieHopFaceLeft_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroWheelieHopFaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, 0, JUMP_TYPE_LOW); + InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopFaceRight_Step1(objectEvent, sprite); } @@ -6880,7 +6886,7 @@ bool8 MovementAction_AcroWheelieHopFaceRight_Step1(struct ObjectEvent *objectEve bool8 MovementAction_AcroWheelieHopDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, 1, JUMP_TYPE_LOW); + InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_NORMAL, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopDown_Step1(objectEvent, sprite); } @@ -6897,7 +6903,7 @@ bool8 MovementAction_AcroWheelieHopDown_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_AcroWheelieHopUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, 1, JUMP_TYPE_LOW); + InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_NORMAL, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopUp_Step1(objectEvent, sprite); } @@ -6914,7 +6920,7 @@ bool8 MovementAction_AcroWheelieHopUp_Step1(struct ObjectEvent *objectEvent, str bool8 MovementAction_AcroWheelieHopLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, 1, JUMP_TYPE_LOW); + InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_NORMAL, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopLeft_Step1(objectEvent, sprite); } @@ -6931,7 +6937,7 @@ bool8 MovementAction_AcroWheelieHopLeft_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_AcroWheelieHopRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, 1, JUMP_TYPE_LOW); + InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_NORMAL, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopRight_Step1(objectEvent, sprite); } @@ -6948,7 +6954,7 @@ bool8 MovementAction_AcroWheelieHopRight_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, 2, JUMP_TYPE_HIGH); + InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH); return MovementAction_AcroWheelieJumpDown_Step1(objectEvent, sprite); } @@ -6965,7 +6971,7 @@ bool8 MovementAction_AcroWheelieJumpDown_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, 2, JUMP_TYPE_HIGH); + InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH); return MovementAction_AcroWheelieJumpUp_Step1(objectEvent, sprite); } @@ -6982,7 +6988,7 @@ bool8 MovementAction_AcroWheelieJumpUp_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_AcroWheelieJumpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, 2, JUMP_TYPE_HIGH); + InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH); return MovementAction_AcroWheelieJumpLeft_Step1(objectEvent, sprite); } @@ -6999,7 +7005,7 @@ bool8 MovementAction_AcroWheelieJumpLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, 2, JUMP_TYPE_HIGH); + InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH); return MovementAction_AcroWheelieJumpRight_Step1(objectEvent, sprite); } @@ -8412,11 +8418,19 @@ static void SetJumpSpriteData(struct Sprite *sprite, u8 direction, u8 distance, static u8 DoJumpSpriteMovement(struct Sprite *sprite) { - s16 distanceToTime[] = {16, 16, 32}; - u8 distanceToShift[] = {0, 0, 1}; + s16 distanceToTime[] = { + [JUMP_DISTANCE_IN_PLACE] = 16, + [JUMP_DISTANCE_NORMAL] = 16, + [JUMP_DISTANCE_FAR] = 32, + }; + u8 distanceToShift[] = { + [JUMP_DISTANCE_IN_PLACE] = 0, + [JUMP_DISTANCE_NORMAL] = 0, + [JUMP_DISTANCE_FAR] = 1, + }; u8 result = 0; - if (sprite->sDistance) + if (sprite->sDistance != JUMP_DISTANCE_IN_PLACE) Step1(sprite, sprite->sDirection); sprite->y2 = GetJumpY(sprite->sTimer >> distanceToShift[sprite->sDistance], sprite->sJumpType); @@ -8437,11 +8451,19 @@ static u8 DoJumpSpriteMovement(struct Sprite *sprite) static u8 DoJumpSpecialSpriteMovement(struct Sprite *sprite) { - s16 distanceToTime[] = {32, 32, 64}; - u8 distanceToShift[] = {1, 1, 2}; + s16 distanceToTime[] = { + [JUMP_DISTANCE_IN_PLACE] = 32, + [JUMP_DISTANCE_NORMAL] = 32, + [JUMP_DISTANCE_FAR] = 64, + }; + u8 distanceToShift[] = { + [JUMP_DISTANCE_IN_PLACE] = 1, + [JUMP_DISTANCE_NORMAL] = 1, + [JUMP_DISTANCE_FAR] = 2, + }; u8 result = 0; - if (sprite->sDistance && !(sprite->sTimer & 1)) + if (sprite->sDistance != JUMP_DISTANCE_IN_PLACE && !(sprite->sTimer & 1)) Step1(sprite, sprite->sDirection); sprite->y2 = GetJumpY(sprite->sTimer >> distanceToShift[sprite->sDistance], sprite->sJumpType);