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

Player doc: some rotation logic/data #1443

Merged
merged 24 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
33fcb7c
Docs: some player rotation logic/data
Dragorn421 Nov 19, 2022
0683296
Merge branch 'master' into doc_player_4
Dragorn421 Nov 30, 2022
05b3d51
Merge branch 'master' into doc_player_4
Dragorn421 Dec 12, 2022
7e14223
Improve misleading comment
Dragorn421 Dec 12, 2022
0b9e965
rename temps
Dragorn421 Dec 12, 2022
7190cb5
Merge branch 'master' into doc_player_4
Dragorn421 Dec 13, 2022
1f06c20
Merge branch 'master' into doc_player_4
Dragorn421 Dec 19, 2022
988199b
Merge branch 'master' into doc_player_4
Dragorn421 Dec 30, 2022
02b5701
Merge branch 'master' into doc_player_4
Dragorn421 Jan 13, 2023
9729589
Merge branch 'master' into doc_player_4
Dragorn421 Aug 15, 2023
436e60d
Merge branch 'main' into doc_player_4
Dragorn421 Oct 15, 2023
50a1f24
Merge branch 'main' into doc_player_4
Dragorn421 Jan 28, 2024
cbad30d
unk_6AE_rotFlags
Dragorn421 Jan 28, 2024
2b8bb6d
Merge branch 'main' into doc_player_4
Dragorn421 Feb 5, 2024
5ae9ea1
Merge branch 'main' into doc_player_4
Dragorn421 Aug 19, 2024
74c6eb4
Merge branch 'main' into doc_player_4
Dragorn421 Aug 21, 2024
cdc1e97
Merge branch 'main' into doc_player_4
Dragorn421 Sep 4, 2024
03f7bab
Merge branch 'main' into doc_player_4
Dragorn421 Sep 5, 2024
b210530
format
Dragorn421 Sep 5, 2024
b448392
disasm metadata
Dragorn421 Sep 5, 2024
bfe17f0
Merge branch 'main' into doc_player_4
Dragorn421 Sep 11, 2024
277e3c5
Merge branch 'main' into doc_player_4
Dragorn421 Sep 18, 2024
bd2e36a
Merge branch 'main' into doc_player_4
Dragorn421 Sep 25, 2024
125cd5c
Merge branch 'main' into doc_player_4
Dragorn421 Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions include/z64player.h
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,16 @@ typedef void (*PlayerActionFunc)(struct Player*, struct PlayState*);
typedef s32 (*UpperActionFunc)(struct Player*, struct PlayState*);
typedef void (*AfterPutAwayFunc)(struct PlayState*, struct Player*);

#define UNK6AE_ROT_FOCUS_X (1 << 0)
#define UNK6AE_ROT_FOCUS_Y (1 << 1)
#define UNK6AE_ROT_FOCUS_Z (1 << 2)
#define UNK6AE_ROT_HEAD_X (1 << 3)
#define UNK6AE_ROT_HEAD_Y (1 << 4)
#define UNK6AE_ROT_HEAD_Z (1 << 5)
#define UNK6AE_ROT_UPPER_X (1 << 6)
#define UNK6AE_ROT_UPPER_Y (1 << 7)
#define UNK6AE_ROT_UPPER_Z (1 << 8)

typedef struct Player {
/* 0x0000 */ Actor actor;
/* 0x014C */ s8 currentTunic; // current tunic from `PlayerTunic`
Expand Down Expand Up @@ -832,15 +842,11 @@ typedef struct Player {
/* 0x06A8 */ Actor* unk_6A8;
/* 0x06AC */ s8 unk_6AC;
/* 0x06AD */ u8 unk_6AD;
/* 0x06AE */ u16 unk_6AE;
/* 0x06B0 */ s16 unk_6B0;
/* 0x06AE */ u16 unk_6AE_rotFlags; // See `UNK6AE_ROT_` macros. If its flag isn't set, a rot steps to 0.
/* 0x06B0 */ s16 upperLimbYawSecondary;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the secondary yaw? Is upperLimbRot.y the primary yaw? Could you add a small comment on how they differ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like its only meaningfully used when riding a horse. Id be fine with this temporary name (and no comment) for now until we figure it out more, i imagine the name will change

/* 0x06B2 */ char unk_6B4[0x004];
/* 0x06B6 */ s16 unk_6B6;
/* 0x06B8 */ s16 unk_6B8;
/* 0x06BA */ s16 unk_6BA;
/* 0x06BC */ s16 unk_6BC;
/* 0x06BE */ s16 unk_6BE;
/* 0x06C0 */ s16 unk_6C0;
/* 0x06B6 */ Vec3s headLimbRot;
/* 0x06BC */ Vec3s upperLimbRot;
/* 0x06C2 */ s16 unk_6C2;
/* 0x06C4 */ f32 unk_6C4;
/* 0x06C8 */ SkelAnime upperSkelAnime;
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ int func_8002DD6C(Player* player) {
}

int func_8002DD78(Player* player) {
return func_8002DD6C(player) && player->unk_834;
return func_8002DD6C(player) && (player->unk_834 != 0);
}

int func_8002DDA8(PlayState* play) {
Expand Down
24 changes: 12 additions & 12 deletions src/code/z_player_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,22 +1295,22 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx**
}

if (limbIndex == PLAYER_LIMB_HEAD) {
rot->x += this->unk_6BA;
rot->y -= this->unk_6B8;
rot->z += this->unk_6B6;
rot->x += this->headLimbRot.z;
rot->y -= this->headLimbRot.y;
rot->z += this->headLimbRot.x;
} else if (limbIndex == PLAYER_LIMB_UPPER) {
if (this->unk_6B0 != 0) {
if (this->upperLimbYawSecondary != 0) {
Matrix_RotateZ(BINANG_TO_RAD(0x44C), MTXMODE_APPLY);
Matrix_RotateY(BINANG_TO_RAD(this->unk_6B0), MTXMODE_APPLY);
Matrix_RotateY(BINANG_TO_RAD(this->upperLimbYawSecondary), MTXMODE_APPLY);
}
if (this->unk_6BE != 0) {
Matrix_RotateY(BINANG_TO_RAD(this->unk_6BE), MTXMODE_APPLY);
if (this->upperLimbRot.y != 0) {
Matrix_RotateY(BINANG_TO_RAD(this->upperLimbRot.y), MTXMODE_APPLY);
}
if (this->unk_6BC != 0) {
Matrix_RotateX(BINANG_TO_RAD(this->unk_6BC), MTXMODE_APPLY);
if (this->upperLimbRot.x != 0) {
Matrix_RotateX(BINANG_TO_RAD(this->upperLimbRot.x), MTXMODE_APPLY);
}
if (this->unk_6C0 != 0) {
Matrix_RotateZ(BINANG_TO_RAD(this->unk_6C0), MTXMODE_APPLY);
if (this->upperLimbRot.z != 0) {
Matrix_RotateZ(BINANG_TO_RAD(this->upperLimbRot.z), MTXMODE_APPLY);
}
} else if (limbIndex == PLAYER_LIMB_L_THIGH) {
s32 pad;
Expand Down Expand Up @@ -1788,7 +1788,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve
Matrix_MtxFToYXZRotS(&sp44, &heldActor->world.rot, 0);
heldActor->shape.rot = heldActor->world.rot;

if (func_8002DD78(this) != 0) {
if (func_8002DD78(this)) {
Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY);
Player_DrawHookshotReticle(play, this,
(this->heldItemAction == PLAYER_IA_HOOKSHOT) ? 38600.0f : 77600.0f);
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_En_Horse/z_en_horse.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ void EnHorse_ResetRace(EnHorse* this, PlayState* play) {
s32 EnHorse_PlayerCanMove(EnHorse* this, PlayState* play) {
Player* player = GET_PLAYER(play);

if ((player->stateFlags1 & PLAYER_STATE1_0) || func_8002DD78(GET_PLAYER(play)) == 1 ||
if ((player->stateFlags1 & PLAYER_STATE1_0) || func_8002DD78(GET_PLAYER(play)) == true ||
(player->stateFlags1 & PLAYER_STATE1_20) || ((this->stateFlags & ENHORSE_FLAG_19) && !this->inRace) ||
this->action == ENHORSE_ACT_HBA || player->actor.flags & ACTOR_FLAG_TALK ||
play->csCtx.state != CS_STATE_IDLE) {
Expand Down
Loading