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

Start Player Item Docs #1396

Merged
merged 8 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ s32 func_80123448(PlayState* play);
s32 Player_IsGoronOrDeku(Player* player);
s32 func_801234D4(PlayState* play);
s32 func_80123590(PlayState* play, Actor* actor);
ItemId func_8012364C(PlayState* play, Player* player, s32 arg2);
ItemId Player_GetItemOnButton(PlayState* play, Player* player, s32 arg2);
PlayerItemAction func_80123810(PlayState* play);
PlayerModelGroup Player_ActionToModelGroup(Player* player, PlayerItemAction itemAction);
void Player_SetModelsForHoldingShield(Player* player);
Expand Down
12 changes: 6 additions & 6 deletions include/z64player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ typedef enum PlayerCueId {
// breman mask march?
#define PLAYER_STATE3_20000000 (1 << 29)
//
#define PLAYER_STATE3_40000000 (1 << 30)
#define PLAYER_STATE3_START_CHANGING_HELD_ITEM (1 << 30)
// TARGETING_HOSTILE?
#define PLAYER_STATE3_80000000 (1 << 31)

Expand Down Expand Up @@ -1095,7 +1095,7 @@ typedef struct Player {
/* 0x14B */ u8 transformation; // PlayerTransformation enum
/* 0x14C */ u8 modelGroup; // PlayerModelGroup enum
/* 0x14D */ u8 nextModelGroup;
/* 0x14E */ s8 unk_14E;
/* 0x14E */ s8 itemChangeType;
/* 0x14F */ u8 modelAnimType; // PlayerAnimType enum
/* 0x150 */ u8 leftHandType;
/* 0x151 */ u8 rightHandType;
Expand All @@ -1122,7 +1122,7 @@ typedef struct Player {
/* 0x238 */ OSMesg maskObjectLoadMsg;
/* 0x23C */ void* maskObjectSegment;
/* 0x240 */ SkelAnime skelAnime;
/* 0x284 */ SkelAnime unk_284;
/* 0x284 */ SkelAnime skelAnimeUpper;
/* 0x2C8 */ SkelAnime unk_2C8;
/* 0x30C */ Vec3s jointTable[5];
/* 0x32A */ Vec3s morphTable[5];
Expand Down Expand Up @@ -1176,8 +1176,8 @@ typedef struct Player {
/* 0x74C */ u8 jointTableBuffer[PLAYER_LIMB_BUF_SIZE];
/* 0x7EB */ u8 morphTableBuffer[PLAYER_LIMB_BUF_SIZE];
/* 0x88A */ u8 blendTableBuffer[PLAYER_LIMB_BUF_SIZE];
/* 0x929 */ u8 unk_929[PLAYER_LIMB_BUF_SIZE];
/* 0x9C8 */ u8 unk_9C8[PLAYER_LIMB_BUF_SIZE];
/* 0x929 */ u8 jointTableUpperBuffer[PLAYER_LIMB_BUF_SIZE];
/* 0x9C8 */ u8 morphTableUpperBuffer[PLAYER_LIMB_BUF_SIZE];
/* 0xA68 */ PlayerAgeProperties* ageProperties; // repurposed as "transformation properties"?
/* 0xA6C */ u32 stateFlags1;
/* 0xA70 */ u32 stateFlags2;
Expand Down Expand Up @@ -1206,7 +1206,7 @@ typedef struct Player {
/* 0xABC */ f32 unk_ABC;
/* 0xAC0 */ f32 unk_AC0;
/* 0xAC4 */ PlayerUpperActionFunc upperActionFunc; // Upper body/item action functions
/* 0xAC8 */ f32 unk_AC8;
/* 0xAC8 */ f32 skelAnimeUpperBlendWeight;
/* 0xACC */ s16 unk_ACC;
/* 0xACE */ s8 unk_ACE;
/* 0xACF */ u8 putAwayCountdown; // Frames to wait before showing "Put Away" on A
Expand Down
10 changes: 5 additions & 5 deletions src/code/z_player_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ s32 func_801235DC(PlayState* play, f32 arg1, s16 arg2) {
return false;
}

ItemId func_8012364C(PlayState* play, Player* player, s32 arg2) {
ItemId Player_GetItemOnButton(PlayState* play, Player* player, s32 arg2) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at the usage of this function it seems like arg2 is always passed a value equivalent to EquipSlot.

Suggested change
ItemId Player_GetItemOnButton(PlayState* play, Player* player, s32 arg2) {
ItemId Player_GetItemOnButton(PlayState* play, Player* player, EquipSlot slot) {

thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was about to do this before PR'ing, but the one call to this function in z_player_lib.c made me hesitate, i.e. in function func_80123810 since the arg i seems shifted up by 1 from C btns. Is i suppose to be EquipSlot when it's fed into this function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alright, I think I see how it works. It just shifts i from an enum of just C buttons to an enum with B and C buttons. EquipSlot has buttons B, C, A so I'm not sure if it's suppose to be all 3 or not, so it's worth revisiting this later. See zeldaret/oot#1228 for this kind of discussion

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wouldn't say it is shifting from an enum of just C buttons to another enum, but instead it is just accounting for the fact that sCItemButtons doesn't include the B button. That array could have comments like the following considering how it is used

u16 sCItemButtons[] = {
    BTN_CLEFT, // EQUIP_SLOT_C_LEFT
    BTN_CDOWN, // EQUIP_SLOT_C_DOWN
    BTN_CRIGHT, // EQUIP_SLOT_C_RIGHT
};

Copy link
Collaborator Author

@engineer124 engineer124 Sep 27, 2023

Choose a reason for hiding this comment

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

I would argue sCItemButtons is more of a map from:

typedef enum {
    /* 0 */ INTERACT_C_BTN_C_LEFT,
    /* 1 */ INTERACT_C_BTN_C_DOWN,
    /* 2 */ INTERACT_C_BTN_C_RIGHT,
    /* 3 */ INTERACT_C_BTN_MAX
} InteractCButton;

to controller buttons, then i++ is really the macro #define INTERACT_C_BTN_TO_BC_BTN(btnsC) ((btnsC) + 1) being applied to i and storing the result back into i. So I'll leave the comments out for now until these different enums are introduced in MM.

For reference, equip slot would be InteractBCAButton from that PR, but then it might make more sense for Player_GetItemOnButton to take InteractBCButton as it's enum arg and not InteractBCAButton. Just something to be careful of

if (arg2 >= 4) {
return ITEM_NONE;
}
Expand Down Expand Up @@ -630,7 +630,7 @@ PlayerItemAction func_80123810(PlayState* play) {
for (i = 0; i < ARRAY_COUNT(sCItemButtons); i++) {
if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, sCItemButtons[i])) {
i++;
itemId = func_8012364C(play, player, i);
itemId = Player_GetItemOnButton(play, player, i);

play->interfaceCtx.unk_222 = 0;
play->interfaceCtx.unk_224 = 0;
Expand Down Expand Up @@ -2092,7 +2092,7 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx**
EnArrow* bubble = NULL;

if (((player->skelAnime.animation == &gPlayerAnim_pn_drinkend)) ||
(player->unk_284.animation == &gPlayerAnim_pn_tamahaki) ||
(player->skelAnimeUpper.animation == &gPlayerAnim_pn_tamahaki) ||
((player->stateFlags3 & PLAYER_STATE3_40) && ((bubble = (EnArrow*)player->heldActor) != NULL))) {
Matrix_TranslateRotateZYX(pos, rot);
func_80125340();
Expand All @@ -2108,7 +2108,7 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx**
} else if (player->skelAnime.animation == &gPlayerAnim_pn_drinkend) {
func_80124618(D_801C03E0, player->skelAnime.curFrame, player->unk_AF0);
} else {
func_80124618(D_801C03C0, player->unk_284.curFrame, player->unk_AF0);
func_80124618(D_801C03C0, player->skelAnimeUpper.curFrame, player->unk_AF0);
}

Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY);
Expand Down Expand Up @@ -3784,7 +3784,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G
Matrix_MultVec3f(&sPlayerFocusHeadLimbModelPos, &player->actor.focus.pos);
Matrix_MultVec3f(&D_801C0E94, sPlayerCurBodyPartPos);
if ((player->skelAnime.animation == &gPlayerAnim_pn_drinkend) ||
(player->unk_284.animation == &gPlayerAnim_pn_tamahaki) ||
(player->skelAnimeUpper.animation == &gPlayerAnim_pn_tamahaki) ||
((player->stateFlags3 & PLAYER_STATE3_40) && ((spA8 = player->heldActor) != NULL))) {
if (spA8 != NULL) {
static Vec3f D_801C0EA0 = { 1300.0f, -400.0f, 0.0f };
Expand Down
Loading