Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of a few player functions #180

Merged
merged 12 commits into from
Jan 12, 2025
2 changes: 1 addition & 1 deletion include/game/stage/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void sub_80232D0(Player *);
void sub_8023610(Player *);
void Player_TouchGround(Player *p);
void Player_80261D8(Player *p);
void sub_8027EF0(Player *p);
void Player_HandlePhysicsWithAirInput(Player *p);
void sub_8028204(Player *p);
void sub_80282EC(Player *p);
void sub_80283C4(Player *p);
Expand Down
34 changes: 17 additions & 17 deletions src/game/player_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void Player_SonicAmy_WindupSkidAttack(Player *p)
}
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

void Player_SonicAmy_SkidAttack(Player *p)
Expand Down Expand Up @@ -265,7 +265,7 @@ void Player_SonicAmy_SkidAttack(Player *p)
}
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);

if (!(p->moveState & MOVESTATE_IN_AIR)) {
sub_8029FA4(p);
Expand Down Expand Up @@ -507,7 +507,7 @@ void Player_80123D0(Player *p)
PLAYERFN_SET(Player_TouchGround);
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

void Player_SonicAmy_WindupStopNSlam(Player *p)
Expand Down Expand Up @@ -543,7 +543,7 @@ void Player_SonicAmy_StopNSlam_AfterGroundCollision(Player *p)

void Player_SonicAmy_StopNSlam_FallAfterCollision(Player *p)
{
sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);

if (!(p->moveState & MOVESTATE_IN_AIR)) {
p->transition = PLTRANS_TOUCH_GROUND;
Expand All @@ -564,7 +564,7 @@ void Player_Sonic_HomingAttack(Player *p)
p->moveState &= ~MOVESTATE_BOOST_EFFECT_ON;
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);

if (!(p->moveState & MOVESTATE_IN_AIR)) {
// Hit ground instead of targeted enemy
Expand Down Expand Up @@ -719,7 +719,7 @@ void Player_Cream_ChaoAttack(Player *p)
}
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

void Player_Cream_InitStepAttack(Player *p)
Expand Down Expand Up @@ -778,7 +778,7 @@ void Player_Cream_StepAttack(Player *p)
}
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

// Mid-Air: Down-B
Expand All @@ -790,7 +790,7 @@ void Player_Cream_ChaoRollingAttack(Player *p)
}
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);

if (!(p->moveState & MOVESTATE_IN_AIR)) {
p->transition = PLTRANS_TOUCH_GROUND;
Expand All @@ -799,7 +799,7 @@ void Player_Cream_ChaoRollingAttack(Player *p)

void Player_Cream_WindupMidAirChaoAttack(Player *p)
{
sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);

if (!(p->moveState & MOVESTATE_IN_AIR)) {
p->transition = PLTRANS_TOUCH_GROUND;
Expand Down Expand Up @@ -1005,7 +1005,7 @@ void Player_Tails_TailSwipe(Player *p)
PLAYERFN_SET(Player_TouchGround);
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

/* Character: Knuckles */
Expand Down Expand Up @@ -1103,7 +1103,7 @@ void Player_Knuckles_PunchLeft(Player *p)
}
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

void Player_Knuckles_PunchRight(Player *p)
Expand All @@ -1130,7 +1130,7 @@ void Player_Knuckles_PunchRight(Player *p)
}
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

void Player_Knuckles_InitSpiralAttack(Player *p)
Expand Down Expand Up @@ -1178,7 +1178,7 @@ void Player_Knuckles_SpiralAttack(Player *p)
PLAYERFN_SET(Player_8013B6C);
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

void Player_Knuckles_Glide_UpdateFrames(Player *p)
Expand Down Expand Up @@ -1816,7 +1816,7 @@ void Player_8013B6C(Player *p)
}
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

void Player_Knuckles_Glide(Player *p)
Expand All @@ -1840,7 +1840,7 @@ void Player_Knuckles_GlideSoftLanding(Player *p)
p->transition = PLTRANS_TOUCH_GROUND;
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}

void Player_Knuckles_GlideHardLanding(Player *p)
Expand Down Expand Up @@ -1990,7 +1990,7 @@ void Player_Knuckles_DrillClaw(Player *p)

void Player_8013E34(Player *p)
{
sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);

p->speedGroundX = 0;
p->speedAirX = 0;
Expand Down Expand Up @@ -2090,5 +2090,5 @@ void Player_Amy_HammerAttack(Player *p)
PLAYERFN_SET(Player_TouchGround);
}

sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);
}
28 changes: 15 additions & 13 deletions src/game/stage/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void Player_8026BCC(Player *);

s32 sub_8029BB8(Player *p, u8 *p1, s32 *out);

void Player_8025A0C(Player *p);
void Player_SpinAttack(Player *p);

void Player_Idle(Player *);
void Player_8025AB8(Player *);
Expand Down Expand Up @@ -115,7 +115,7 @@ bool32 Player_TryCrouchOrSpinAttack(Player *);
bool32 Player_TryInitSpindash(Player *);
void Player_InitCrouch(Player *);
void Player_InitIceSlide(Player *);
void Player_802A3B8(Player *);
void PlayerFn_Cmd_HandlePhysics(Player *);
void Player_802A3C4(Player *);
void Player_CameraShift(Player *);
void Player_InitSpecialStageTransition(Player *);
Expand Down Expand Up @@ -3385,7 +3385,7 @@ void CallPlayerTransition(Player *p)
PLAYERFN_SET(Player_TouchGround);
} break;
case PLTRANS_PT2 - 1: {
PLAYERFN_SET(Player_8025A0C);
PLAYERFN_SET(Player_SpinAttack);
} break;
case PLTRANS_INIT_JUMP - 1: {
p->moveState &= ~(MOVESTATE_400000 | MOVESTATE_IGNORE_INPUT);
Expand Down Expand Up @@ -4194,7 +4194,7 @@ void Player_Crouch(Player *p)
}
}

void Player_8025A0C(Player *p)
void Player_SpinAttack(Player *p)
{
if (IS_BOSS_STAGE(gCurrentLevel)) {
if ((p->moveState & MOVESTATE_IN_AIR)) {
Expand Down Expand Up @@ -4547,7 +4547,7 @@ void Player_Spindash(Player *p)

p->speedGroundX = speed;

gPlayer.callback = Player_8025A0C;
gPlayer.callback = Player_SpinAttack;

m4aSongNumStart(SE_SPIN_DASH_RELEASE);
} else {
Expand Down Expand Up @@ -4957,7 +4957,7 @@ void Player_8026E24(Player *p)

m4aSongNumStart(SE_SPIN);

PLAYERFN_SET_AND_CALL(Player_802A3B8, p);
PLAYERFN_SET_AND_CALL(PlayerFn_Cmd_HandlePhysics, p);
}

void Player_8026F10(Player *p)
Expand Down Expand Up @@ -5461,7 +5461,8 @@ void Player_8027D3C(Player *p)
}
}

void sub_8027EF0(Player *p)
// Generic function for movement and collision, has aerial input, used in character aerial/landing states
void Player_HandlePhysicsWithAirInput(Player *p)
{
if (p->moveState & MOVESTATE_IN_AIR) {
sub_8023610(p);
Expand All @@ -5485,7 +5486,8 @@ void sub_8027EF0(Player *p)
}
}

void sub_802808C(Player *p)
// Generic function for movement and collision that doesn't allow player influence
void Player_HandlePhysics(Player *p)
{
if (p->moveState & MOVESTATE_IN_AIR) {
sub_80232D0(p);
Expand Down Expand Up @@ -6746,7 +6748,7 @@ bool32 Player_TryCrouchOrSpinAttack(Player *p)
return TRUE;
} else if (((u16)(p->speedGroundX + (Q(0.5) - 1)) > Q(1.0) - 2)
&& !(p->moveState & (MOVESTATE_1000000 | MOVESTATE_4 | MOVESTATE_IN_AIR))) {
PLAYERFN_SET(Player_8025A0C);
PLAYERFN_SET(Player_SpinAttack);
m4aSongNumStart(SE_SPIN_ATTACK);
return TRUE;
}
Expand Down Expand Up @@ -6799,7 +6801,7 @@ void Player_802A258(Player *p)
{
if (!(p->moveState & MOVESTATE_IN_AIR)) {
if (p->moveState & MOVESTATE_4)
Player_8025A0C(p);
Player_SpinAttack(p);
else
Player_TouchGround(p);
} else {
Expand Down Expand Up @@ -6842,14 +6844,14 @@ void Player_InitDashRing(Player *p)

void Player_InitIceSlide(Player *p) { Player_InitIceSlide_inline(p); }

void Player_802A3B8(Player *p) { sub_802808C(p); }
void PlayerFn_Cmd_HandlePhysics(Player *p) { Player_HandlePhysics(p); }

void Player_802A3C4(Player *p)
{
sub_8027EF0(p);
Player_HandlePhysicsWithAirInput(p);

if (p->spriteInfoBody->s.frameFlags & SPRITE_FLAG_MASK_ANIM_OVER)
PLAYERFN_SET(Player_8025A0C);
PLAYERFN_SET(Player_SpinAttack);
}

void Player_CameraShift(Player *p) { Player_CameraShift_inline(p); }
Expand Down