summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbriaguya <70942617+briaguya-ai@users.noreply.github.com>2025-02-03 15:58:49 -0800
committerGitHub <noreply@github.com>2025-02-03 18:58:49 -0500
commit8ae8770db8f1c3548e1b2da26c5da72a40c32d33 (patch)
tree40c3ea745550ac11998a02c7c07d073501badbef
parentc7f335f23c3af94eea5a7af6602481dc088bebf1 (diff)
pull in `startMode` docs (#4988)
-rw-r--r--soh/include/z64player.h23
-rw-r--r--soh/src/overlays/actors/ovl_player_actor/z_player.c91
2 files changed, 69 insertions, 45 deletions
diff --git a/soh/include/z64player.h b/soh/include/z64player.h
index 6f00eb3ef..a00d86557 100644
--- a/soh/include/z64player.h
+++ b/soh/include/z64player.h
@@ -7,6 +7,29 @@
struct Player;
+// Determines behavior when spawning. See `PlayerStartMode`.
+#define PLAYER_GET_START_MODE(thisx) (thisx->params & 0xF00) >> 8
+
+typedef enum PlayerStartMode {
+ /* 0 */ PLAYER_START_MODE_NOTHING, // Update is empty and draw function is NULL, nothing occurs. Useful in cutscenes, for example.
+ /* 1 */ PLAYER_START_MODE_TIME_TRAVEL, // Arriving from time travel. Automatically adjusts by age.
+ /* 2 */ PLAYER_START_MODE_BLUE_WARP, // Arriving from a blue warp.
+ /* 3 */ PLAYER_START_MODE_DOOR, // Unused. Use a door immediately if one is nearby. If no door is in usable range, a softlock occurs.
+ /* 4 */ PLAYER_START_MODE_GROTTO, // Arriving from a grotto, launched upward from the ground.
+ /* 5 */ PLAYER_START_MODE_WARP_SONG, // Arriving from a warp song.
+ /* 6 */ PLAYER_START_MODE_FARORES_WIND, // Arriving from a Farores Wind warp.
+ /* 7 */ PLAYER_START_MODE_KNOCKED_OVER, // Knocked over on the ground and flashing red.
+ /* 8 */ PLAYER_START_MODE_UNUSED_8, // Unused, behaves the same as PLAYER_START_MODE_MOVE_FORWARD_SLOW.
+ /* 9 */ PLAYER_START_MODE_UNUSED_9, // Unused, behaves the same as PLAYER_START_MODE_MOVE_FORWARD_SLOW.
+ /* 10 */ PLAYER_START_MODE_UNUSED_10, // Unused, behaves the same as PLAYER_START_MODE_MOVE_FORWARD_SLOW.
+ /* 11 */ PLAYER_START_MODE_UNUSED_11, // Unused, behaves the same as PLAYER_START_MODE_MOVE_FORWARD_SLOW.
+ /* 12 */ PLAYER_START_MODE_UNUSED_12, // Unused, behaves the same as PLAYER_START_MODE_MOVE_FORWARD_SLOW.
+ /* 13 */ PLAYER_START_MODE_IDLE, // Idle standing still, or swim if in water.
+ /* 14 */ PLAYER_START_MODE_MOVE_FORWARD_SLOW, // Take a few steps forward at a slow speed (2.0f), or swim if in water.
+ /* 15 */ PLAYER_START_MODE_MOVE_FORWARD, // Take a few steps forward, using the speed from the last exit (gSaveContext.entranceSpeed), or swim if in water.
+ /* 16 */ PLAYER_START_MODE_MAX // Note: By default, this param has 4 bits allocated. The max value is 16.
+} PlayerStartMode;
+
typedef enum PlayerSword {
/* 0 */ PLAYER_SWORD_NONE,
/* 1 */ PLAYER_SWORD_KOKIRI,
diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c
index 762814076..34bee2f6f 100644
--- a/soh/src/overlays/actors/ovl_player_actor/z_player.c
+++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c
@@ -157,17 +157,17 @@ s32 func_80835C08(Player* this, PlayState* play);
void Player_UseItem(PlayState* play, Player* this, s32 item);
void func_80839F90(Player* this, PlayState* play);
s32 func_8083C61C(PlayState* play, Player* this);
-void func_8083CA20(PlayState* play, Player* this);
-void func_8083CA54(PlayState* play, Player* this);
-void func_8083CA9C(PlayState* play, Player* this);
-void func_80846648(PlayState* play, Player* this);
-void func_80846660(PlayState* play, Player* this);
-void func_808467D4(PlayState* play, Player* this);
-void func_808468A8(PlayState* play, Player* this);
-void func_808468E8(PlayState* play, Player* this);
-void func_80846978(PlayState* play, Player* this);
-void func_808469BC(PlayState* play, Player* this);
-void func_80846A68(PlayState* play, Player* this);
+void Player_StartMode_Idle(PlayState* play, Player* this);
+void Player_StartMode_MoveForwardSlow(PlayState* play, Player* this);
+void Player_StartMode_MoveForward(PlayState* play, Player* this);
+void Player_StartMode_Nothing(PlayState* play, Player* this);
+void Player_StartMode_BlueWarp(PlayState* play, Player* this);
+void Player_StartMode_TimeTravel(PlayState* play, Player* this);
+void Player_StartMode_Door(PlayState* play, Player* this);
+void Player_StartMode_Grotto(PlayState* play, Player* this);
+void Player_StartMode_KnockedOver(PlayState* play, Player* this);
+void Player_StartMode_WarpSong(PlayState* play, Player* this);
+void Player_StartMode_FaroresWind(PlayState* play, Player* this);
void Player_UpdateCommon(Player* this, PlayState* play, Input* input);
void func_8084FF7C(Player* this);
void Player_UpdateBunnyEars(Player* this);
@@ -6618,13 +6618,13 @@ s32 func_8083C910(PlayState* play, Player* this, f32 arg2) {
return 1;
}
-void func_8083CA20(PlayState* play, Player* this) {
+void Player_StartMode_Idle(PlayState* play, Player* this) {
if (func_8083C910(play, this, 180.0f)) {
this->av2.actionVar2 = -20;
}
}
-void func_8083CA54(PlayState* play, Player* this) {
+void Player_StartMode_MoveForwardSlow(PlayState* play, Player* this) {
this->linearVelocity = 2.0f;
gSaveContext.entranceSpeed = 2.0f;
if (func_8083C910(play, this, 120.0f)) {
@@ -6632,7 +6632,7 @@ void func_8083CA54(PlayState* play, Player* this) {
}
}
-void func_8083CA9C(PlayState* play, Player* this) {
+void Player_StartMode_MoveForward(PlayState* play, Player* this) {
if (gSaveContext.entranceSpeed < 0.1f) {
gSaveContext.entranceSpeed = 0.1f;
}
@@ -10614,12 +10614,12 @@ static ColliderQuadInit D_808546A0 = {
void func_8084663C(Actor* thisx, PlayState* play) {
}
-void func_80846648(PlayState* play, Player* this) {
+void Player_StartMode_Nothing(PlayState* play, Player* this) {
this->actor.update = func_8084663C;
this->actor.draw = NULL;
}
-void func_80846660(PlayState* play, Player* this) {
+void Player_StartMode_BlueWarp(PlayState* play, Player* this) {
Player_SetupAction(play, this, Player_Action_8084F710, 0);
if ((play->sceneNum == SCENE_LAKE_HYLIA) && (gSaveContext.sceneSetupIndex >= 4)) {
this->av1.actionVar1 = 1;
@@ -10652,7 +10652,7 @@ void func_80846720(PlayState* play, Player* this, s32 arg2) {
static Vec3f D_808546F4 = { -1.0f, 69.0f, 20.0f };
-void func_808467D4(PlayState* play, Player* this) {
+void Player_StartMode_TimeTravel(PlayState* play, Player* this) {
Player_SetupAction(play, this, Player_Action_8084E9AC, 0);
this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE;
Math_Vec3f_Copy(&this->actor.world.pos, &D_808546F4);
@@ -10666,12 +10666,12 @@ void func_808467D4(PlayState* play, Player* this) {
this->av2.actionVar2 = 20;
}
-void func_808468A8(PlayState* play, Player* this) {
+void Player_StartMode_Door(PlayState* play, Player* this) {
Player_SetupAction(play, this, Player_Action_8084F9A0, 0);
Player_StartAnimMovement(play, this, 0x9B);
}
-void func_808468E8(PlayState* play, Player* this) {
+void Player_StartMode_Grotto(PlayState* play, Player* this) {
func_808389E8(this, &gPlayerAnim_link_normal_jump, 12.0f, play);
Player_SetupAction(play, this, Player_Action_8084F9C0, 0);
this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE;
@@ -10679,11 +10679,11 @@ void func_808468E8(PlayState* play, Player* this) {
OnePointCutscene_Init(play, 5110, 40, &this->actor, MAIN_CAM);
}
-void func_80846978(PlayState* play, Player* this) {
+void Player_StartMode_KnockedOver(PlayState* play, Player* this) {
func_80837C0C(play, this, PLAYER_HIT_RESPONSE_KNOCKBACK_LARGE, 2.0f, 2.0f, this->actor.shape.rot.y + 0x8000, 0);
}
-void func_808469BC(PlayState* play, Player* this) {
+void Player_StartMode_WarpSong(PlayState* play, Player* this) {
Player_SetupAction(play, this, Player_Action_8084F698, 0);
this->actor.draw = NULL;
this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE;
@@ -10696,7 +10696,7 @@ Actor* Player_SpawnMagicSpell(PlayState* play, Player* this, s32 spell) {
this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0, true);
}
-void func_80846A68(PlayState* play, Player* this) {
+void Player_StartMode_FaroresWind(PlayState* play, Player* this) {
this->actor.draw = NULL;
Player_SetupAction(play, this, Player_Action_8085076C, 0);
this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE;
@@ -10743,23 +10743,23 @@ void Player_InitCommon(Player* this, PlayState* play, FlexSkeletonHeader* skelHe
this->ivanDamageMultiplier = 1;
}
-static void (*D_80854738[])(PlayState* play, Player* this) = {
- /* 0x0 */ func_80846648,
- /* 0x1 */ func_808467D4, // From time travel
- /* 0x2 */ func_80846660,
- /* 0x3 */ func_808468A8,
- /* 0x4 */ func_808468E8,
- /* 0x5 */ func_808469BC,
- /* 0x6 */ func_80846A68,
- /* 0x7 */ func_80846978,
- /* 0x8 */ func_8083CA54,
- /* 0x9 */ func_8083CA54,
- /* 0xA */ func_8083CA54,
- /* 0xB */ func_8083CA54,
- /* 0xC */ func_8083CA54,
- /* 0xD */ func_8083CA20,
- /* 0xE */ func_8083CA54,
- /* 0xF */ func_8083CA9C,
+static void (*sStartModeFuncs[PLAYER_START_MODE_MAX])(PlayState* play, Player* this) = {
+ Player_StartMode_Nothing, // PLAYER_START_MODE_NOTHING
+ Player_StartMode_TimeTravel, // PLAYER_START_MODE_TIME_TRAVEL
+ Player_StartMode_BlueWarp, // PLAYER_START_MODE_BLUE_WARP
+ Player_StartMode_Door, // PLAYER_START_MODE_DOOR
+ Player_StartMode_Grotto, // PLAYER_START_MODE_GROTTO
+ Player_StartMode_WarpSong, // PLAYER_START_MODE_WARP_SONG
+ Player_StartMode_FaroresWind, // PLAYER_START_MODE_FARORES_WIND
+ Player_StartMode_KnockedOver, // PLAYER_START_MODE_KNOCKED_OVER
+ Player_StartMode_MoveForwardSlow, // PLAYER_START_MODE_UNUSED_8
+ Player_StartMode_MoveForwardSlow, // PLAYER_START_MODE_UNUSED_9
+ Player_StartMode_MoveForwardSlow, // PLAYER_START_MODE_UNUSED_10
+ Player_StartMode_MoveForwardSlow, // PLAYER_START_MODE_UNUSED_11
+ Player_StartMode_MoveForwardSlow, // PLAYER_START_MODE_UNUSED_12
+ Player_StartMode_Idle, // PLAYER_START_MODE_IDLE
+ Player_StartMode_MoveForwardSlow, // PLAYER_START_MODE_MOVE_FORWARD_SLOW
+ Player_StartMode_MoveForward, // PLAYER_START_MODE_MOVE_FORWARD
};
static Vec3f D_80854778 = { 0.0f, 50.0f, 0.0f };
@@ -10769,7 +10769,7 @@ void Player_Init(Actor* thisx, PlayState* play2) {
PlayState* play = play2;
SceneTableEntry* scene = play->loadedScene;
u32 titleFileSize;
- s32 initMode;
+ s32 startMode;
s32 respawnFlag;
s32 respawnMode;
@@ -10858,16 +10858,17 @@ void Player_Init(Actor* thisx, PlayState* play2) {
gSaveContext.infTable[26] |= gBitFlags[play->sceneNum];
}
- initMode = (thisx->params & 0xF00) >> 8;
- if ((initMode == 5) || (initMode == 6)) {
+ startMode = PLAYER_GET_START_MODE(thisx);
+
+ if ((startMode == PLAYER_START_MODE_WARP_SONG) || (startMode == PLAYER_START_MODE_FARORES_WIND)) {
if (gSaveContext.cutsceneIndex >= 0xFFF0) {
- initMode = 13;
+ startMode = PLAYER_START_MODE_IDLE;
}
}
- D_80854738[initMode](play, this);
+ sStartModeFuncs[startMode](play, this);
- if (initMode != 0) {
+ if (startMode != PLAYER_START_MODE_NOTHING) {
if ((gSaveContext.gameMode == 0) || (gSaveContext.gameMode == 3)) {
this->naviActor = Player_SpawnFairy(play, this, &thisx->world.pos, &D_80854778, FAIRY_NAVI);
if (gSaveContext.dogParams != 0) {