diff --git a/include/attributes.h b/include/attributes.h new file mode 100644 index 000000000..13fbe70f4 --- /dev/null +++ b/include/attributes.h @@ -0,0 +1,12 @@ +#ifndef ATTRIBUTES_H +#define ATTRIBUTES_H + +#ifndef __GNUC__ +#define __attribute__(x) +#endif + +#define UNUSED __attribute__((unused)) +#define FALLTHROUGH __attribute__((fallthrough)) +#define NORETURN __attribute__((noreturn)) + +#endif diff --git a/include/fault.h b/include/fault.h index cc3211102..ec77334b2 100644 --- a/include/fault.h +++ b/include/fault.h @@ -44,8 +44,8 @@ void Fault_Init(void); // Fatal Errors -void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2); -void Fault_AddHungupAndCrash(const char* file, s32 line); +NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2); +NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line); // Client Registration diff --git a/include/functions.h b/include/functions.h index 5670fc33b..41d595a29 100644 --- a/include/functions.h +++ b/include/functions.h @@ -33,13 +33,13 @@ void Locale_ResetRegion(void); u32 func_80001F48(void); u32 func_80001F8C(void); u32 Locale_IsRegionNative(void); -void __assert(const char* exp, const char* file, s32 line); +NORETURN void __assert(const char* exp, const char* file, s32 line); void isPrintfInit(void); void osSyncPrintfUnused(const char* fmt, ...); void osSyncPrintf(const char* fmt, ...); void rmonPrintf(const char* fmt, ...); void* is_proutSyncPrintf(void* arg, const char* str, u32 count); -void func_80002384(const char* exp, const char* file, u32 line); +NORETURN void func_80002384(const char* exp, const char* file, u32 line); OSPiHandle* osDriveRomInit(void); void Mio0_Decompress(Yaz0Header* hdr, u8* dst); void StackCheck_Init(StackEntry* entry, void* stackBottom, void* stackTop, u32 initValue, s32 minSpace, @@ -465,7 +465,7 @@ void Enemy_StartFinishingBlow(PlayState* play, Actor* actor); s16 func_80032CB4(s16* arg0, s16 arg1, s16 arg2, s16 arg3); void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play); void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s32 maxLimbIndex, u32 count, Gfx** dList, - s16 objectId); + s16 objectSlot); s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s16 type); void Actor_SpawnFloorDustRing(PlayState* play, Actor* actor, Vec3f* posXZ, f32 radius, s32 amountMinusOne, f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting); @@ -1058,7 +1058,7 @@ s32 Player_OverrideLimbDrawGameplayCrawling(PlayState* play, s32 limbIndex, Gfx* u8 func_80090480(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newTip, Vec3f* newBase); void Player_DrawGetItem(PlayState* play, Player* this); void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx); -u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime); +u32 Player_InitPauseDrawData(PlayState* play, u8* segment, SkelAnime* skelAnime); void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots); void PreNMI_Init(GameState* thisx); @@ -1088,7 +1088,7 @@ void Gfx_SetupDL_37Opa(GraphicsContext* gfxCtx); Gfx* Gfx_SetupDL_39(Gfx* gfx); void Gfx_SetupDL_39Opa(GraphicsContext* gfxCtx); void Gfx_SetupDL_39Overlay(GraphicsContext* gfxCtx); -void Gfx_SetupDL_39Ptr(Gfx** gfxp); +void Gfx_SetupDL_39Ptr(Gfx** gfxP); void Gfx_SetupDL_40Opa(GraphicsContext* gfxCtx); void Gfx_SetupDL_41Opa(GraphicsContext* gfxCtx); void Gfx_SetupDL_47Xlu(GraphicsContext* gfxCtx); @@ -1100,8 +1100,8 @@ void Gfx_SetupDL_42Overlay(GraphicsContext* gfxCtx); void Gfx_SetupDL_27Xlu(GraphicsContext* gfxCtx); void Gfx_SetupDL_60NoCDXlu(GraphicsContext* gfxCtx); void Gfx_SetupDL_61Xlu(GraphicsContext* gfxCtx); -void Gfx_SetupDL_56Ptr(Gfx** gfxp); -Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height); +void Gfx_SetupDL_56Ptr(Gfx** gfxP); +Gfx* Gfx_BranchTexScroll(Gfx** gfxP, u32 x, u32 y, s32 width, s32 height); Gfx* func_80094E78(GraphicsContext* gfxCtx, u32 x, u32 y); Gfx* Gfx_TexScroll(GraphicsContext* gfxCtx, u32 x, u32 y, s32 width, s32 height); Gfx* Gfx_TwoTexScroll(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, @@ -1125,11 +1125,10 @@ void Sample_Init(GameState* thisx); void Inventory_ChangeEquipment(s16 equipment, u16 value); u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment); void Inventory_ChangeUpgrade(s16 upgrade, s16 value); -s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId); -void Object_InitBank(PlayState* play, ObjectContext* objectCtx); -void Object_UpdateBank(ObjectContext* objectCtx); -s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId); -s32 Object_IsLoaded(ObjectContext* objectCtx, s32 bankIndex); +void Object_InitContext(PlayState* play, ObjectContext* objectCtx); +void Object_UpdateEntries(ObjectContext* objectCtx); +s32 Object_GetSlot(ObjectContext* objectCtx, s16 objectId); +s32 Object_IsLoaded(ObjectContext* objectCtx, s32 slot); void func_800981B8(ObjectContext* objectCtx); s32 Scene_ExecuteCommands(PlayState* play, SceneCmd* sceneCmd); void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx); @@ -1206,7 +1205,7 @@ void View_Apply(View* view, s32 mask); s32 View_ApplyOrthoToOverlay(View* view); s32 View_ApplyPerspectiveToOverlay(View* view); s32 View_UpdateViewingMatrix(View* view); -s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp); +s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxP); s32 View_ErrorCheckEyePosition(f32 eyeX, f32 eyeY, f32 eyeZ); void ViMode_LogPrint(OSViMode* osViMode); void ViMode_Configure(ViMode* viMode, s32 type, s32 tvType, s32 loRes, s32 antialiasOff, s32 modeN, s32 fb16Bit, @@ -1217,15 +1216,6 @@ void ViMode_Init(ViMode* viMode); void ViMode_Destroy(ViMode* viMode); void ViMode_ConfigureFeatures(ViMode* viMode, s32 viFeatures); void ViMode_Update(ViMode* viMode, Input* input); -void func_800ACE70(struct_801664F0* this); -void func_800ACE90(struct_801664F0* this); -void func_800ACE98(struct_801664F0* this, Gfx** gfxp); -void VisMono_Init(VisMono* this); -void VisMono_Destroy(VisMono* this); -void VisMono_Draw(VisMono* this, Gfx** gfxp); -void func_800AD920(struct_80166500* this); -void func_800AD950(struct_80166500* this); -void func_800AD958(struct_80166500* this, Gfx** gfxp); void PlayerCall_InitFuncPtrs(void); void TransitionTile_Destroy(TransitionTile* this); TransitionTile* TransitionTile_Init(TransitionTile* this, s32 cols, s32 rows); @@ -1332,16 +1322,16 @@ void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void PreRender_Init(PreRender* this); void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf); void PreRender_Destroy(PreRender* this); -void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a); -void func_800C1AE8(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave); -void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxp); -void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp); -void PreRender_DrawCoverage(PreRender* this, Gfx** gfxp); -void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxp); -void func_800C213C(PreRender* this, Gfx** gfxp); -void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxp); -void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxp); #ifdef ENABLE_PAUSE_BG_AA +void func_800C170C(PreRender* this, Gfx** gfxP, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a); +void func_800C1AE8(PreRender* this, Gfx** gfxP, void* fbuf, void* fbufSave); +void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxP); +void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxP); +void PreRender_DrawCoverage(PreRender* this, Gfx** gfxP); +void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxP); +void func_800C213C(PreRender* this, Gfx** gfxP); +void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxP); +void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxP); void PreRender_ApplyFilters(PreRender* this); #endif void AudioMgr_StopAllSfx(void); @@ -1352,9 +1342,9 @@ void AudioMgr_ThreadEntry(void* arg0); void AudioMgr_Unlock(AudioMgr* audioMgr); void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, Scheduler* sched, IrqMgr* irqMgr); void GameState_FaultPrint(void); -void GameState_SetFBFilter(Gfx** gfx); +void GameState_SetFBFilter(Gfx** gfxP); #ifdef SHOW_INPUT_DISPLAY -void GameState_DrawInputDisplay(u16 input, Gfx** gfx); +void GameState_DrawInputDisplay(u16 input, Gfx** gfxP); #endif void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx); void GameState_SetFrameBuffer(GraphicsContext* gfxCtx); @@ -1393,7 +1383,7 @@ void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, Gfx* Graph_GfxPlusOne(Gfx* gfx); Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst); -void* Graph_DlistAlloc(Gfx** gfx, u32 size); +void* Graph_DlistAlloc(Gfx** gfxP, u32 size); ListAlloc* ListAlloc_Init(ListAlloc* this); void* ListAlloc_Alloc(ListAlloc* this, u32 size); void ListAlloc_Free(ListAlloc* this, void* data); @@ -1511,7 +1501,7 @@ u64* SysUcode_GetUCodeBoot(void); size_t SysUcode_GetUCodeBootSize(void); u64* SysUcode_GetUCode(void); u64* SysUcode_GetUCodeData(void); -void func_800D31A0(void); +NORETURN void func_800D31A0(void); void func_800D31F0(void); void func_800D3210(void); diff --git a/include/macros.h b/include/macros.h index c6bae4ae9..76cfdb51d 100644 --- a/include/macros.h +++ b/include/macros.h @@ -3,19 +3,12 @@ #include "config.h" -#ifndef __GNUC__ -#define __attribute__(x) -#endif - #ifndef AVOID_UB #define BAD_RETURN(type) type #else #define BAD_RETURN(type) void #endif -#define UNUSED __attribute__((unused)) -#define FALLTHROUGH __attribute__((fallthrough)) - #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) #define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0])) diff --git a/include/z64.h b/include/z64.h index 41078fb16..06fb615a5 100644 --- a/include/z64.h +++ b/include/z64.h @@ -3,6 +3,7 @@ #include "ultra64.h" #include "ultra64/gs2dex.h" +#include "attributes.h" #include "z64save.h" #include "z64light.h" #include "z64bgcheck.h" @@ -34,6 +35,7 @@ #include "z64skybox.h" #include "z64sram.h" #include "z64view.h" +#include "z64vis.h" #include "alignment.h" #include "seqcmd.h" #include "sequence.h" @@ -808,29 +810,4 @@ typedef struct { /* 0x84 */ u32 unk_84; } ViMode; // size = 0x88 -// Vis... -typedef struct { - /* 0x00 */ u32 type; - /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8_u32 color; - /* 0x0C */ Color_RGBA8_u32 envColor; -} struct_801664F0; // size = 0x10 - -typedef struct { - /* 0x00 */ u32 unk_00; - /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8_u32 primColor; - /* 0x0C */ Color_RGBA8_u32 envColor; - /* 0x10 */ u16* tlut; - /* 0x14 */ Gfx* dList; -} VisMono; // size = 0x18 - -// Vis... -typedef struct { - /* 0x00 */ u32 useRgba; - /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8_u32 primColor; - /* 0x08 */ Color_RGBA8_u32 envColor; -} struct_80166500; // size = 0x10 - #endif diff --git a/include/z64actor.h b/include/z64actor.h index 4c1d0ec68..8fdbbf1db 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -199,7 +199,7 @@ typedef struct Actor { /* 0x004 */ u32 flags; // Flags used for various purposes /* 0x008 */ PosRot home; // Initial position/rotation when spawned. Can be used for other purposes /* 0x01C */ s16 params; // Configurable variable set by the actor's spawn data; original name: "args_data" - /* 0x01E */ s8 objBankIndex; // Object bank index of the actor's object dependency; original name: "bank" + /* 0x01E */ s8 objectSlot; // Object slot (in ObjectContext) corresponding to the actor's object; original name: "bank" /* 0x01F */ s8 targetMode; // Controls how far the actor can be targeted from and how far it can stay locked on /* 0x020 */ u16 sfx; // SFX ID to play. Sfx plays when value is set, then is cleared the following update cycle /* 0x024 */ PosRot world; // Position/rotation in the world @@ -287,14 +287,14 @@ typedef struct DynaPolyActor { typedef struct { /* 0x00 */ MtxF* matrices; - /* 0x04 */ s16* objectIds; + /* 0x04 */ s16* objectSlots; /* 0x08 */ s16 count; /* 0x0C */ Gfx** dLists; /* 0x10 */ s32 val; // used for various purposes: both a status indicator and counter /* 0x14 */ s32 prevLimbIndex; } BodyBreak; -#define BODYBREAK_OBJECT_DEFAULT -1 // use the same object as the actor +#define BODYBREAK_OBJECT_SLOT_DEFAULT -1 // use the same object as the actor #define BODYBREAK_STATUS_READY -1 #define BODYBREAK_STATUS_FINISHED 0 diff --git a/include/z64effect.h b/include/z64effect.h index e0dca34c0..4189edc5b 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -246,7 +246,7 @@ typedef struct { #define rgEnvColorG regs[8] #define rgEnvColorB regs[9] #define rgEnvColorA regs[10] -#define rgObjBankIdx regs[11] +#define rgObjectSlot regs[11] #define DEFINE_EFFECT_SS(_0, enum) enum, #define DEFINE_EFFECT_SS_UNSET(enum) enum, diff --git a/include/z64object.h b/include/z64object.h index 3f80fee7a..aa7c2a85e 100644 --- a/include/z64object.h +++ b/include/z64object.h @@ -4,24 +4,22 @@ #include "ultra64.h" #include "z64dma.h" -#define OBJECT_EXCHANGE_BANK_MAX 19 - typedef struct { - /* 0x00 */ s16 id; - /* 0x04 */ void* segment; - /* 0x08 */ DmaRequest dmaRequest; + /* 0x00 */ s16 id; + /* 0x04 */ void* segment; + /* 0x08 */ DmaRequest dmaRequest; /* 0x28 */ OSMesgQueue loadQueue; - /* 0x40 */ OSMesg loadMsg; -} ObjectStatus; // size = 0x44 + /* 0x40 */ OSMesg loadMsg; +} ObjectEntry; // size = 0x44 typedef struct { - /* 0x0000 */ void* spaceStart; - /* 0x0004 */ void* spaceEnd; // original name: "endSegment" - /* 0x0008 */ u8 num; // number of objects in bank - /* 0x0009 */ u8 unk_09; - /* 0x000A */ u8 mainKeepIndex; // "gameplay_keep" index in bank - /* 0x000B */ u8 subKeepIndex; // "gameplay_field_keep" or "gameplay_dangeon_keep" index in bank - /* 0x000C */ ObjectStatus status[OBJECT_EXCHANGE_BANK_MAX]; + /* 0x0000 */ void* spaceStart; + /* 0x0004 */ void* spaceEnd; // original name: "endSegment" + /* 0x0008 */ u8 numEntries; // total amount of used entries + /* 0x0009 */ u8 numPersistentEntries; // amount of entries that won't be reused when loading a new object list (when loading a new room) + /* 0x000A */ u8 mainKeepSlot; // "gameplay_keep" slot + /* 0x000B */ u8 subKeepSlot; // "gameplay_field_keep" or "gameplay_dangeon_keep" slot + /* 0x000C */ ObjectEntry slots[19]; } ObjectContext; // size = 0x518 #define DEFINE_OBJECT(_0, enum) enum, @@ -31,7 +29,7 @@ typedef struct { typedef enum { #include "tables/object_table.h" /* 0x0192 */ OBJECT_ID_MAX -} ObjectID; +} ObjectId; #undef DEFINE_OBJECT #undef DEFINE_OBJECT_NULL diff --git a/include/z64pause.h b/include/z64pause.h index 5781bf96b..137adb8d2 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -28,6 +28,40 @@ typedef enum { #define PAUSE_EQUIP_BUFFER_SIZE sizeof(u16[PAUSE_EQUIP_PLAYER_HEIGHT][PAUSE_EQUIP_PLAYER_WIDTH]) #define PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE 0x5000 +typedef enum { + /* 0 */ PAUSE_STATE_OFF, + /* 1 */ PAUSE_STATE_WAIT_LETTERBOX, // Request no letterboxing and wait for it. + /* 2 */ PAUSE_STATE_WAIT_BG_PRERENDER, // Wait for the pause background prerender to be done. + /* 3 */ PAUSE_STATE_INIT, // Load data and initialize/setup various things. + /* 4 */ PAUSE_STATE_OPENING_1, // Animate the pause menu coming together with rotations and other animations. + /* 5 */ PAUSE_STATE_OPENING_2, // Finish some animations for opening the menu. + /* 6 */ PAUSE_STATE_6, // Pause menu ready for player inputs. + /* 7 */ PAUSE_STATE_SAVE_PROMPT, // Save prompt in the pause menu + /* 8 */ PAUSE_STATE_8, + /* 9 */ PAUSE_STATE_9, + /* 10 */ PAUSE_STATE_10, + /* 11 */ PAUSE_STATE_11, + /* 12 */ PAUSE_STATE_12, + /* 13 */ PAUSE_STATE_13, + /* 14 */ PAUSE_STATE_14, + /* 15 */ PAUSE_STATE_15, + /* 16 */ PAUSE_STATE_16, + /* 17 */ PAUSE_STATE_17, + /* 18 */ PAUSE_STATE_CLOSING, // Animate the pause menu closing + /* 19 */ PAUSE_STATE_RESUME_GAMEPLAY // Handles returning to normal gameplay once the pause menu is visually closed +} PauseState; + +#define IS_PAUSE_STATE_GAMEOVER(pauseCtx) \ + (((pauseCtx)->state >= PAUSE_STATE_8) && ((pauseCtx)->state <= PAUSE_STATE_17)) + +#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) +#define IS_PAUSED(pauseCtx) \ + (((pauseCtx)->state != PAUSE_STATE_OFF) || ((pauseCtx)->debugState != 0)) +#else +#define IS_PAUSED(pauseCtx) \ + ((pauseCtx)->state != PAUSE_STATE_OFF) +#endif + typedef struct { /* 0x0000 */ View view; /* 0x0128 */ u8* iconItemSegment; diff --git a/include/z64player.h b/include/z64player.h index a0a62b058..8d97ab96f 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -459,8 +459,16 @@ typedef enum { /* 0x67 */ PLAYER_CSMODE_MAX } PlayerCutsceneMode; +typedef enum { + /* 0 */ PLAYER_LEDGE_CLIMB_NONE, + /* 1 */ PLAYER_LEDGE_CLIMB_1, + /* 2 */ PLAYER_LEDGE_CLIMB_2, + /* 3 */ PLAYER_LEDGE_CLIMB_3, + /* 4 */ PLAYER_LEDGE_CLIMB_4 +} PlayerLedgeClimbType; + typedef struct { - /* 0x00 */ f32 unk_00; + /* 0x00 */ f32 ceilingCheckHeight; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; /* 0x0C */ f32 unk_0C; @@ -474,7 +482,7 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; + /* 0x38 */ f32 wallCheckRadius; /* 0x3C */ f32 unk_3C; /* 0x40 */ f32 unk_40; /* 0x44 */ Vec3s unk_44; @@ -501,6 +509,8 @@ typedef struct { /* 0x10 */ Vec3f base; } WeaponInfo; // size = 0x1C +#define LEDGE_DIST_MAX 399.96002f + #define PLAYER_STATE1_0 (1 << 0) #define PLAYER_STATE1_SWINGING_BOTTLE (1 << 1) #define PLAYER_STATE1_2 (1 << 2) @@ -509,7 +519,7 @@ typedef struct { #define PLAYER_STATE1_5 (1 << 5) #define PLAYER_STATE1_6 (1 << 6) #define PLAYER_STATE1_7 (1 << 7) -#define PLAYER_STATE1_8 (1 << 8) +#define PLAYER_STATE1_START_CHANGING_HELD_ITEM (1 << 8) #define PLAYER_STATE1_9 (1 << 9) #define PLAYER_STATE1_10 (1 << 10) #define PLAYER_STATE1_11 (1 << 11) @@ -543,7 +553,7 @@ typedef struct { #define PLAYER_STATE2_6 (1 << 6) #define PLAYER_STATE2_7 (1 << 7) #define PLAYER_STATE2_8 (1 << 8) -#define PLAYER_STATE2_9 (1 << 9) +#define PLAYER_STATE2_FORCE_SAND_FLOOR_SOUND (1 << 9) #define PLAYER_STATE2_10 (1 << 10) #define PLAYER_STATE2_11 (1 << 11) #define PLAYER_STATE2_12 (1 << 12) @@ -578,185 +588,185 @@ typedef struct { #define PLAYER_ALLOC_GI_MIN 0x2880 // title card maximum file size -typedef void (*PlayerFunc674)(struct Player*, struct PlayState*); -typedef s32 (*PlayerFunc82C)(struct Player*, struct PlayState*); +typedef void (*PlayerActionFunc)(struct Player*, struct PlayState*); +typedef s32 (*ItemActionFunc)(struct Player*, struct PlayState*); typedef void (*PlayerFuncA74)(struct PlayState*, struct Player*); typedef struct Player { - /* 0x0000 */ Actor actor; - /* 0x014C */ s8 currentTunic; // current tunic from `PlayerTunic` - /* 0x014D */ s8 currentSwordItemId; - /* 0x014E */ s8 currentShield; // current shield from `PlayerShield` - /* 0x014F */ s8 currentBoots; // current boots from `PlayerBoots` - /* 0x0150 */ s8 heldItemButton; // Button index for the item currently used - /* 0x0151 */ s8 heldItemAction; // Item action for the item currently used - /* 0x0152 */ u8 heldItemId; // Item id for the item currently used - /* 0x0153 */ s8 prevBoots; // previous boots from `PlayerBoots` - /* 0x0154 */ s8 itemAction; // the difference between this and heldItemAction is unclear - /* 0x0155 */ char unk_155[0x003]; - /* 0x0158 */ u8 modelGroup; - /* 0x0159 */ u8 nextModelGroup; - /* 0x015A */ s8 unk_15A; - /* 0x015B */ u8 modelAnimType; - /* 0x015C */ u8 leftHandType; - /* 0x015D */ u8 rightHandType; - /* 0x015E */ u8 sheathType; - /* 0x015F */ u8 currentMask; // current mask equipped from `PlayerMask` - /* 0x0160 */ Gfx** rightHandDLists; - /* 0x0164 */ Gfx** leftHandDLists; - /* 0x0168 */ Gfx** sheathDLists; - /* 0x016C */ Gfx** waistDLists; - /* 0x0170 */ u8 giObjectLoading; + /* 0x0000 */ Actor actor; + /* 0x014C */ s8 currentTunic; // current tunic from `PlayerTunic` + /* 0x014D */ s8 currentSwordItemId; + /* 0x014E */ s8 currentShield; // current shield from `PlayerShield` + /* 0x014F */ s8 currentBoots; // current boots from `PlayerBoots` + /* 0x0150 */ s8 heldItemButton; // Button index for the item currently used + /* 0x0151 */ s8 heldItemAction; // Item action for the item currently used + /* 0x0152 */ u8 heldItemId; // Item id for the item currently used + /* 0x0153 */ s8 prevBoots; // previous boots from `PlayerBoots` + /* 0x0154 */ s8 itemAction; // the difference between this and heldItemAction is unclear + /* 0x0155 */ char unk_155[0x003]; + /* 0x0158 */ u8 modelGroup; + /* 0x0159 */ u8 nextModelGroup; + /* 0x015A */ s8 itemChangeType; + /* 0x015B */ u8 modelAnimType; + /* 0x015C */ u8 leftHandType; + /* 0x015D */ u8 rightHandType; + /* 0x015E */ u8 sheathType; + /* 0x015F */ u8 currentMask; // current mask equipped from `PlayerMask` + /* 0x0160 */ Gfx** rightHandDLists; + /* 0x0164 */ Gfx** leftHandDLists; + /* 0x0168 */ Gfx** sheathDLists; + /* 0x016C */ Gfx** waistDLists; + /* 0x0170 */ u8 giObjectLoading; /* 0x0174 */ DmaRequest giObjectDmaRequest; /* 0x0194 */ OSMesgQueue giObjectLoadQueue; - /* 0x01AC */ OSMesg giObjectLoadMsg; - /* 0x01B0 */ void* giObjectSegment; // also used for title card textures - /* 0x01B4 */ SkelAnime skelAnime; - /* 0x01F8 */ Vec3s jointTable[PLAYER_LIMB_BUF_COUNT]; - /* 0x0288 */ Vec3s morphTable[PLAYER_LIMB_BUF_COUNT]; - /* 0x0318 */ Vec3s blendTable[PLAYER_LIMB_BUF_COUNT]; - /* 0x03A8 */ s16 unk_3A8[2]; - /* 0x03AC */ Actor* heldActor; - /* 0x03B0 */ Vec3f leftHandPos; - /* 0x03BC */ Vec3s unk_3BC; - /* 0x03C4 */ Actor* unk_3C4; - /* 0x03C8 */ Vec3f unk_3C8; - /* 0x03D4 */ char unk_3D4[0x058]; - /* 0x042C */ s8 doorType; - /* 0x042D */ s8 doorDirection; - /* 0x042E */ s16 doorTimer; - /* 0x0430 */ Actor* doorActor; - /* 0x0434 */ s8 getItemId; - /* 0x0436 */ u16 getItemDirection; - /* 0x0438 */ Actor* interactRangeActor; - /* 0x043C */ s8 mountSide; - /* 0x043D */ char unk_43D[0x003]; - /* 0x0440 */ Actor* rideActor; - /* 0x0444 */ u8 csMode; - /* 0x0445 */ u8 prevCsMode; - /* 0x0446 */ u8 cueId; - /* 0x0447 */ u8 unk_447; - /* 0x0448 */ Actor* unk_448; - /* 0x044C */ char unk_44C[0x004]; - /* 0x0450 */ Vec3f unk_450; - /* 0x045C */ Vec3f unk_45C; - /* 0x0468 */ char unk_468[0x002]; - /* 0x046A */ s16 doorBgCamIndex; - /* 0x046C */ s16 subCamId; - /* 0x046E */ char unk_46E[0x02A]; + /* 0x01AC */ OSMesg giObjectLoadMsg; + /* 0x01B0 */ void* giObjectSegment; // also used for title card textures + /* 0x01B4 */ SkelAnime skelAnime; + /* 0x01F8 */ Vec3s jointTable[PLAYER_LIMB_BUF_COUNT]; + /* 0x0288 */ Vec3s morphTable[PLAYER_LIMB_BUF_COUNT]; + /* 0x0318 */ Vec3s blendTable[PLAYER_LIMB_BUF_COUNT]; + /* 0x03A8 */ s16 unk_3A8[2]; + /* 0x03AC */ Actor* heldActor; + /* 0x03B0 */ Vec3f leftHandPos; + /* 0x03BC */ Vec3s unk_3BC; + /* 0x03C4 */ Actor* unk_3C4; + /* 0x03C8 */ Vec3f unk_3C8; + /* 0x03D4 */ char unk_3D4[0x058]; + /* 0x042C */ s8 doorType; + /* 0x042D */ s8 doorDirection; + /* 0x042E */ s16 doorTimer; + /* 0x0430 */ Actor* doorActor; + /* 0x0434 */ s8 getItemId; + /* 0x0436 */ u16 getItemDirection; + /* 0x0438 */ Actor* interactRangeActor; + /* 0x043C */ s8 mountSide; + /* 0x043D */ char unk_43D[0x003]; + /* 0x0440 */ Actor* rideActor; + /* 0x0444 */ u8 csMode; + /* 0x0445 */ u8 prevCsMode; + /* 0x0446 */ u8 cueId; + /* 0x0447 */ u8 unk_447; + /* 0x0448 */ Actor* unk_448; + /* 0x044C */ char unk_44C[0x004]; + /* 0x0450 */ Vec3f unk_450; + /* 0x045C */ Vec3f unk_45C; + /* 0x0468 */ char unk_468[0x002]; + /* 0x046A */ s16 doorBgCamIndex; + /* 0x046C */ s16 subCamId; + /* 0x046E */ char unk_46E[0x02A]; /* 0x0498 */ ColliderCylinder cylinder; /* 0x04E4 */ ColliderQuad meleeWeaponQuads[2]; /* 0x05E4 */ ColliderQuad shieldQuad; - /* 0x0664 */ Actor* unk_664; - /* 0x0668 */ char unk_668[0x004]; - /* 0x066C */ s32 unk_66C; - /* 0x0670 */ s32 meleeWeaponEffectIndex; - /* 0x0674 */ PlayerFunc674 func_674; + /* 0x0664 */ Actor* unk_664; + /* 0x0668 */ char unk_668[0x004]; + /* 0x066C */ s32 unk_66C; + /* 0x0670 */ s32 meleeWeaponEffectIndex; + /* 0x0674 */ PlayerActionFunc actionFunc; /* 0x0678 */ PlayerAgeProperties* ageProperties; - /* 0x067C */ u32 stateFlags1; - /* 0x0680 */ u32 stateFlags2; - /* 0x0684 */ Actor* unk_684; - /* 0x0688 */ Actor* boomerangActor; - /* 0x068C */ Actor* naviActor; - /* 0x0690 */ s16 naviTextId; - /* 0x0692 */ u8 stateFlags3; - /* 0x0693 */ s8 exchangeItemId; - /* 0x0694 */ Actor* targetActor; - /* 0x0698 */ f32 targetActorDistance; - /* 0x069C */ char unk_69C[0x004]; - /* 0x06A0 */ f32 unk_6A0; - /* 0x06A4 */ f32 closestSecretDistSq; - /* 0x06A8 */ Actor* unk_6A8; - /* 0x06AC */ s8 unk_6AC; - /* 0x06AD */ u8 unk_6AD; - /* 0x06AE */ u16 unk_6AE; - /* 0x06B0 */ s16 unk_6B0; - /* 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; - /* 0x06C2 */ s16 unk_6C2; - /* 0x06C4 */ f32 unk_6C4; - /* 0x06C8 */ SkelAnime skelAnime2; - /* 0x070C */ Vec3s jointTable2[PLAYER_LIMB_BUF_COUNT]; - /* 0x079C */ Vec3s morphTable2[PLAYER_LIMB_BUF_COUNT]; - /* 0x082C */ PlayerFunc82C func_82C; - /* 0x0830 */ f32 unk_830; - /* 0x0834 */ s16 unk_834; - /* 0x0836 */ s8 unk_836; - /* 0x0837 */ u8 unk_837; - /* 0x0838 */ f32 speedXZ; // Controls horizontal speed, used for `actor.speed`. Current or target value depending on context. - /* 0x083C */ s16 yaw; // General yaw value, used both for world and shape rotation. Current or target value depending on context. - /* 0x083E */ s16 zTargetYaw; // yaw relating to Z targeting/"parallel" mode - /* 0x0840 */ u16 underwaterTimer; - /* 0x0842 */ s8 meleeWeaponAnimation; - /* 0x0843 */ s8 meleeWeaponState; - /* 0x0844 */ s8 unk_844; - /* 0x0845 */ u8 unk_845; - /* 0x0846 */ u8 unk_846; - /* 0x0847 */ s8 unk_847[4]; - /* 0x084B */ s8 unk_84B[4]; - /* 0x084F */ s8 unk_84F; - /* 0x0850 */ s16 unk_850; // multipurpose timer - /* 0x0854 */ f32 unk_854; - /* 0x0858 */ f32 unk_858; - /* 0x085C */ f32 unk_85C; // stick length among other things - /* 0x0860 */ s16 unk_860; // stick flame timer among other things - /* 0x0862 */ s8 unk_862; // get item draw ID + 1 - /* 0x0864 */ f32 unk_864; - /* 0x0868 */ f32 unk_868; - /* 0x086C */ f32 unk_86C; - /* 0x0870 */ f32 unk_870; - /* 0x0874 */ f32 unk_874; - /* 0x0878 */ f32 unk_878; - /* 0x087C */ s16 unk_87C; - /* 0x087E */ s16 unk_87E; - /* 0x0880 */ f32 unk_880; - /* 0x0884 */ f32 wallHeight; // height used to determine whether link can climb or grab a ledge at the top - /* 0x0888 */ f32 wallDistance; // distance to the colliding wall plane - /* 0x088C */ u8 unk_88C; - /* 0x088D */ u8 unk_88D; - /* 0x088E */ u8 unk_88E; - /* 0x088F */ u8 unk_88F; - /* 0x0890 */ u8 unk_890; - /* 0x0891 */ u8 shockTimer; - /* 0x0892 */ u8 unk_892; - /* 0x0893 */ u8 hoverBootsTimer; - /* 0x0894 */ s16 fallStartHeight; // last truncated Y position before falling - /* 0x0896 */ s16 fallDistance; // truncated Y distance the player has fallen so far (positive is down) - /* 0x0898 */ s16 unk_898; - /* 0x089A */ s16 unk_89A; - /* 0x089C */ s16 unk_89C; - /* 0x089E */ u16 floorSfxOffset; - /* 0x08A0 */ u8 unk_8A0; - /* 0x08A1 */ u8 unk_8A1; - /* 0x08A2 */ s16 unk_8A2; - /* 0x08A4 */ f32 unk_8A4; - /* 0x08A8 */ f32 unk_8A8; - /* 0x08AC */ f32 pushedSpeed; // Pushing player, examples include water currents, floor conveyors, climbing sloped surfaces - /* 0x08B0 */ s16 pushedYaw; // Yaw direction of player being pushed + /* 0x067C */ u32 stateFlags1; + /* 0x0680 */ u32 stateFlags2; + /* 0x0684 */ Actor* unk_684; + /* 0x0688 */ Actor* boomerangActor; + /* 0x068C */ Actor* naviActor; + /* 0x0690 */ s16 naviTextId; + /* 0x0692 */ u8 stateFlags3; + /* 0x0693 */ s8 exchangeItemId; + /* 0x0694 */ Actor* targetActor; + /* 0x0698 */ f32 targetActorDistance; + /* 0x069C */ char unk_69C[0x004]; + /* 0x06A0 */ f32 unk_6A0; + /* 0x06A4 */ f32 closestSecretDistSq; + /* 0x06A8 */ Actor* unk_6A8; + /* 0x06AC */ s8 unk_6AC; + /* 0x06AD */ u8 unk_6AD; + /* 0x06AE */ u16 unk_6AE; + /* 0x06B0 */ s16 unk_6B0; + /* 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; + /* 0x06C2 */ s16 unk_6C2; + /* 0x06C4 */ f32 unk_6C4; + /* 0x06C8 */ SkelAnime skelAnimeUpper; + /* 0x070C */ Vec3s jointTableUpper[PLAYER_LIMB_BUF_COUNT]; + /* 0x079C */ Vec3s morphTableUpper[PLAYER_LIMB_BUF_COUNT]; + /* 0x082C */ ItemActionFunc itemActionFunc; + /* 0x0830 */ f32 skelAnimeUpperBlendWeight; + /* 0x0834 */ s16 unk_834; + /* 0x0836 */ s8 unk_836; + /* 0x0837 */ u8 unk_837; + /* 0x0838 */ f32 speedXZ; // Controls horizontal speed, used for `actor.speed`. Current or target value depending on context. + /* 0x083C */ s16 yaw; // General yaw value, used both for world and shape rotation. Current or target value depending on context. + /* 0x083E */ s16 zTargetYaw; // yaw relating to Z targeting/"parallel" mode + /* 0x0840 */ u16 underwaterTimer; + /* 0x0842 */ s8 meleeWeaponAnimation; + /* 0x0843 */ s8 meleeWeaponState; + /* 0x0844 */ s8 unk_844; + /* 0x0845 */ u8 unk_845; + /* 0x0846 */ u8 unk_846; + /* 0x0847 */ s8 unk_847[4]; + /* 0x084B */ s8 unk_84B[4]; + /* 0x084F */ s8 actionVar1; // context dependent variable that has different meanings depending on what action is currently running + /* 0x0850 */ s16 actionVar2; // context dependent variable that has different meanings depending on what action is currently running + /* 0x0854 */ f32 unk_854; + /* 0x0858 */ f32 unk_858; + /* 0x085C */ f32 unk_85C; // stick length among other things + /* 0x0860 */ s16 unk_860; // stick flame timer among other things + /* 0x0862 */ s8 unk_862; // get item draw ID + 1 + /* 0x0864 */ f32 unk_864; + /* 0x0868 */ f32 unk_868; + /* 0x086C */ f32 unk_86C; + /* 0x0870 */ f32 unk_870; + /* 0x0874 */ f32 unk_874; + /* 0x0878 */ f32 unk_878; + /* 0x087C */ s16 unk_87C; + /* 0x087E */ s16 unk_87E; + /* 0x0880 */ f32 unk_880; + /* 0x0884 */ f32 yDistToLedge; // y distance to ground above an interact wall. LEDGE_DIST_MAX if no ground is found + /* 0x0888 */ f32 distToInteractWall; // xyz distance to the interact wall + /* 0x088C */ u8 ledgeClimbType; + /* 0x088D */ u8 ledgeClimbDelayTimer; + /* 0x088E */ u8 unk_88E; + /* 0x088F */ u8 unk_88F; + /* 0x0890 */ u8 unk_890; + /* 0x0891 */ u8 shockTimer; + /* 0x0892 */ u8 unk_892; + /* 0x0893 */ u8 hoverBootsTimer; + /* 0x0894 */ s16 fallStartHeight; // last truncated Y position before falling + /* 0x0896 */ s16 fallDistance; // truncated Y distance the player has fallen so far (positive is down) + /* 0x0898 */ s16 floorPitch; // angle of the floor slope in the direction of current world yaw (positive for ascending slope) + /* 0x089A */ s16 floorPitchAlt; // the calculation for this value is bugged and doesn't represent anything meaningful + /* 0x089C */ s16 unk_89C; + /* 0x089E */ u16 floorSfxOffset; + /* 0x08A0 */ u8 unk_8A0; + /* 0x08A1 */ u8 unk_8A1; + /* 0x08A2 */ s16 unk_8A2; + /* 0x08A4 */ f32 unk_8A4; + /* 0x08A8 */ f32 unk_8A8; + /* 0x08AC */ f32 pushedSpeed; // Pushing player, examples include water currents, floor conveyors, climbing sloped surfaces + /* 0x08B0 */ s16 pushedYaw; // Yaw direction of player being pushed /* 0x08B4 */ WeaponInfo meleeWeaponInfo[3]; - /* 0x0908 */ Vec3f bodyPartsPos[PLAYER_BODYPART_MAX]; - /* 0x09E0 */ MtxF mf_9E0; - /* 0x0A20 */ MtxF shieldMf; - /* 0x0A60 */ u8 isBurning; - /* 0x0A61 */ u8 flameTimers[PLAYER_BODYPART_MAX]; // one flame per body part - /* 0x0A73 */ u8 unk_A73; + /* 0x0908 */ Vec3f bodyPartsPos[PLAYER_BODYPART_MAX]; + /* 0x09E0 */ MtxF mf_9E0; + /* 0x0A20 */ MtxF shieldMf; + /* 0x0A60 */ u8 isBurning; + /* 0x0A61 */ u8 flameTimers[PLAYER_BODYPART_MAX]; // one flame per body part + /* 0x0A73 */ u8 unk_A73; /* 0x0A74 */ PlayerFuncA74 func_A74; - /* 0x0A78 */ s8 invincibilityTimer; // prevents damage when nonzero (positive = visible, counts towards zero each frame) - /* 0x0A79 */ u8 unk_A79; - /* 0x0A7A */ u8 unk_A7A; - /* 0x0A7B */ u8 unk_A7B; - /* 0x0A7C */ f32 unk_A7C; - /* 0x0A80 */ s16 unk_A80; - /* 0x0A82 */ u16 prevFloorSfxOffset; - /* 0x0A84 */ s16 unk_A84; - /* 0x0A86 */ s8 unk_A86; - /* 0x0A87 */ u8 unk_A87; - /* 0x0A88 */ Vec3f unk_A88; // previous body part 0 position + /* 0x0A78 */ s8 invincibilityTimer; // prevents damage when nonzero (positive = visible, counts towards zero each frame) + /* 0x0A79 */ u8 floorTypeTimer; // counts up every frame the current floor type is the same as the last frame + /* 0x0A7A */ u8 floorProperty; + /* 0x0A7B */ u8 prevFloorType; + /* 0x0A7C */ f32 unk_A7C; + /* 0x0A80 */ s16 unk_A80; + /* 0x0A82 */ u16 prevFloorSfxOffset; + /* 0x0A84 */ s16 unk_A84; + /* 0x0A86 */ s8 unk_A86; + /* 0x0A87 */ u8 unk_A87; + /* 0x0A88 */ Vec3f unk_A88; // previous body part 0 position } Player; // size = 0xA94 #endif diff --git a/include/z64save.h b/include/z64save.h index dfeac65ac..327fb3723 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -329,6 +329,18 @@ typedef enum { /* 0x06 */ HS_DAMPE_RACE } HighScores; +// the score value for the fishing minigame also stores many flags. +#define HS_FISH_LENGTH_CHILD 0x7F // mask for record length of catch as child. +#define HS_FISH_LENGTH_ADULT 0x7F000000 // mask for record length of catch as adult. +#define HS_FISH_PLAYED_CHILD 0x100 // set when first talking to owner as child +#define HS_FISH_PLAYED_ADULT 0x200 // set when first talking to owner as adult +#define HS_FISH_PRIZE_CHILD 0x400 // won the Piece of Heart +#define HS_FISH_PRIZE_ADULT 0x800 // won the Golden Scale +#define HS_FISH_STOLE_HAT 0x1000 // Pond owner is visibly bald as Adult Link. +#define HS_FISH_CHEAT_CHILD 0x80 // used Sinking Lure as child to catch record fish +#define HS_FISH_CHEAT_ADULT 0x80000000 // used Sinking Lure as adult to catch record fish +#define HS_FISH_PLAYED 0x10000 // incremented for every play. controls weather. + typedef enum { /* 0 */ SUNSSONG_INACTIVE, /* 1 */ SUNSSONG_START, // the suns ocarina effect signals that the song has finished playing diff --git a/include/z64vis.h b/include/z64vis.h new file mode 100644 index 000000000..c88d6de48 --- /dev/null +++ b/include/z64vis.h @@ -0,0 +1,87 @@ +#ifndef Z64_VIS_H +#define Z64_VIS_H + +#include "ultra64.h" +#include "color.h" + +typedef enum { + /* 0 */ FB_FILTER_NONE, + /* 1 */ FB_FILTER_CVG_RGB, + /* 2 */ FB_FILTER_CVG_RGB_UNIFORM, + /* 3 */ FB_FILTER_CVG_ONLY, + /* 4 */ FB_FILTER_CVG_RGB_FOG, // Not recommended, easily overflows blender + /* 5 */ FB_FILTER_ZBUF_IA, + /* 6 */ FB_FILTER_ZBUF_RGBA, + /* 7 */ FB_FILTER_MONO +} FramebufferFilterType; + +typedef enum { + /* 0 */ VIS_NO_SETSCISSOR, + /* 1 */ VIS_SETSCISSOR +} VisScissorType; + +typedef struct { + /* 0x00 */ u32 type; + /* 0x04 */ u32 scissorType; + /* 0x08 */ Color_RGBA8_u32 primColor; + /* 0x0C */ Color_RGBA8_u32 envColor; +} Vis; // size = 0x10 + + + +/* Cvg: Coverage */ + +#define FB_FILTER_TO_CVG_TYPE(filter) (filter) + +typedef enum { + /* 0 */ VIS_CVG_TYPE_NONE = FB_FILTER_TO_CVG_TYPE(FB_FILTER_NONE), + /* 1 */ VIS_CVG_TYPE_CVG_RGB = FB_FILTER_TO_CVG_TYPE(FB_FILTER_CVG_RGB), + /* 2 */ VIS_CVG_TYPE_CVG_RGB_UNIFORM = FB_FILTER_TO_CVG_TYPE(FB_FILTER_CVG_RGB_UNIFORM), + /* 3 */ VIS_CVG_TYPE_CVG_ONLY = FB_FILTER_TO_CVG_TYPE(FB_FILTER_CVG_ONLY), + /* 4 */ VIS_CVG_TYPE_CVG_RGB_FOG = FB_FILTER_TO_CVG_TYPE(FB_FILTER_CVG_RGB_FOG) +} VisCvgType; + +typedef struct { + /* 0x00 */ Vis vis; +} VisCvg; // size = 0x10 + +void VisCvg_Init(VisCvg* this); +void VisCvg_Destroy(VisCvg* this); +void VisCvg_Draw(VisCvg* this, Gfx** gfxP); + + + +/* Mono: Desaturation */ + +// Only one type + +typedef struct { + /* 0x00 */ Vis vis; + /* 0x10 */ u16* tlut; + /* 0x14 */ Gfx* dList; +} VisMono; // size = 0x18 + +void VisMono_Init(VisMono* this); +void VisMono_Destroy(VisMono* this); +void VisMono_Draw(VisMono* this, Gfx** gfxP); + + + +/* ZBuf: Z-Buffer */ + +#define FB_FILTER_TO_ZBUF_TYPE(filter) ((filter) - FB_FILTER_ZBUF_IA) + +typedef enum { + /* 0 */ VIS_ZBUF_TYPE_IA = FB_FILTER_TO_ZBUF_TYPE(FB_FILTER_ZBUF_IA), + /* 1 */ VIS_ZBUF_TYPE_RGBA = FB_FILTER_TO_ZBUF_TYPE(FB_FILTER_ZBUF_RGBA) +} VisZBufType; + +typedef struct { + /* 0x00 */ Vis vis; +} VisZBuf; // size = 0x10 + +void VisZBuf_Init(VisZBuf* this); +void VisZBuf_Destroy(VisZBuf* this); +void VisZBuf_Draw(VisZBuf* this, Gfx** gfxP); + +#endif diff --git a/spec b/spec index b63ecf9c4..a06b7c1f9 100644 --- a/spec +++ b/spec @@ -388,9 +388,9 @@ beginseg include "build/data/unk_8012ABC0.data.o" include "build/src/code/z_view.o" include "build/src/code/z_vimode.o" - include "build/src/code/code_800ACE70.o" + include "build/src/code/z_viscvg.o" include "build/src/code/z_vismono.o" - include "build/src/code/code_800AD920.o" + include "build/src/code/z_viszbuf.o" include "build/src/code/z_vr_box.o" include "build/src/code/z_vr_box_draw.o" include "build/src/code/z_player_call.o" diff --git a/src/boot/assert.c b/src/boot/assert.c index b7895dddd..438432d42 100644 --- a/src/boot/assert.c +++ b/src/boot/assert.c @@ -1,6 +1,6 @@ #include "global.h" -void __assert(const char* exp, const char* file, s32 line) { +NORETURN void __assert(const char* exp, const char* file, s32 line) { char msg[256]; osSyncPrintf("Assertion failed: %s, file %s, line %d, thread %d\n", exp, file, line, osGetThreadId(NULL)); diff --git a/src/boot/is_debug.c b/src/boot/is_debug.c index c064c43a3..5e501f3af 100644 --- a/src/boot/is_debug.c +++ b/src/boot/is_debug.c @@ -86,7 +86,7 @@ void* is_proutSyncPrintf(void* arg, const char* str, u32 count) { return (void*)1; } -void func_80002384(const char* exp, const char* file, u32 line) { +NORETURN void func_80002384(const char* exp, const char* file, u32 line) { osSyncPrintf("File:%s Line:%d %s \n", file, line, exp); while (true) { ; diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index faef6e1c2..e11da9e17 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -231,7 +231,7 @@ void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size) { * * This function does not return. */ -void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) { +NORETURN void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) { uintptr_t vrom = req->vromAddr; void* ram = req->dramAddr; size_t size = req->size; diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 0ff2a15c7..8cdc2897e 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -43,19 +43,19 @@ void PreRender_Destroy(PreRender* this) { /** * Copies RGBA16 image `img` to `imgDst` * - * @param gfxp Display list pointer + * @param gfxP Display list pointer * @param img Image to copy from * @param imgDst Buffer to copy to */ -void PreRender_CopyImage(PreRender* this, Gfx** gfxp, void* img, void* imgDst) { +void PreRender_CopyImage(PreRender* this, Gfx** gfxP, void* img, void* imgDst) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LogUtils_CheckNullPointer("this", this, "../PreRender.c", 215); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 216); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 216); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 218); gDPPipeSync(gfx++); @@ -101,22 +101,22 @@ void PreRender_CopyImage(PreRender* this, Gfx** gfxp, void* img, void* imgDst) { gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - *gfxp = gfx; + *gfxP = gfx; } /** * Copies part of `this->fbufSave` in the region (this->ulx, this->uly), (this->lrx, this->lry) to the same location in * `this->fbuf`. */ -void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxp) { +void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxP) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LogUtils_CheckNullPointer("this", this, "../PreRender.c", 278); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 279); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 279); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 281); gDPPipeSync(gfx++); @@ -164,22 +164,22 @@ void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxp) { gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); - *gfxp = gfx; + *gfxP = gfx; } /** * Copies `buf` to `bufSave`, discarding the alpha channel and modulating the RGB channel by * the color ('r', 'g', 'b', 'a') */ -void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a) { +void func_800C170C(PreRender* this, Gfx** gfxP, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LogUtils_CheckNullPointer("this", this, "../PreRender.c", 343); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 344); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 344); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 346); gDPPipeSync(gfx++); @@ -232,33 +232,33 @@ void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r, gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - *gfxp = gfx; + *gfxP = gfx; } /** * Copies `fbuf` to `fbufSave`, discarding the alpha channel and leaving the rgb channel unchanged */ -void func_800C1AE8(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave) { - func_800C170C(this, gfxp, fbuf, fbufSave, 255, 255, 255, 255); +void func_800C1AE8(PreRender* this, Gfx** gfxP, void* fbuf, void* fbufSave) { + func_800C170C(this, gfxP, fbuf, fbufSave, 255, 255, 255, 255); } /** * Reads the coverage values stored in the RGBA16 format `img` with dimensions `this->width`, `this->height` and * converts it to an 8-bpp intensity image. * - * @param gfxp Display list pointer + * @param gfxP Display list pointer * @param img Image to read coverage from * @param cvgDst Buffer to store coverage into */ -void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxp, void* img, void* cvgDst) { +void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxP, void* img, void* cvgDst) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LogUtils_CheckNullPointer("this", this, "../PreRender.c", 422); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 423); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 423); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 425); gDPPipeSync(gfx++); @@ -326,30 +326,30 @@ void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxp, void* img, void* // Reset the color image to the current framebuffer gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - *gfxp = gfx; + *gfxP = gfx; } /** * Saves zbuf to zbufSave */ -void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxp) { +void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxP) { LogUtils_CheckNullPointer("this->zbuf_save", this->zbufSave, "../PreRender.c", 481); LogUtils_CheckNullPointer("this->zbuf", this->zbuf, "../PreRender.c", 482); if ((this->zbufSave != NULL) && (this->zbuf != NULL)) { - PreRender_CopyImage(this, gfxp, this->zbuf, this->zbufSave); + PreRender_CopyImage(this, gfxP, this->zbuf, this->zbufSave); } } /** * Saves fbuf to fbufSave */ -void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp) { +void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxP) { LogUtils_CheckNullPointer("this->fbuf_save", this->fbufSave, "../PreRender.c", 495); LogUtils_CheckNullPointer("this->fbuf", this->fbuf, "../PreRender.c", 496); if ((this->fbufSave != NULL) && (this->fbuf != NULL)) { - func_800C1AE8(this, gfxp, this->fbuf, this->fbufSave); + func_800C1AE8(this, gfxP, this->fbuf, this->fbufSave); } } @@ -357,8 +357,8 @@ void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp) { * Fetches the coverage of the current framebuffer into an image of the same format as the current color image, storing * it over the framebuffer in memory. */ -void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp) { - Gfx* gfx = *gfxp; +void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxP) { + Gfx* gfx = *gfxP; gDPPipeSync(gfx++); // Set the blend color to full white and set maximum depth. @@ -392,33 +392,33 @@ void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp) { gDPFillRectangle(gfx++, 0, 0, this->width, this->height); gDPPipeSync(gfx++); - *gfxp = gfx; + *gfxP = gfx; } /** * Draws the coverage of the current framebuffer `this->fbuf` to an I8 image at `this->cvgSave`. Overwrites * `this->fbuf` in the process. */ -void PreRender_DrawCoverage(PreRender* this, Gfx** gfxp) { - PreRender_FetchFbufCoverage(this, gfxp); +void PreRender_DrawCoverage(PreRender* this, Gfx** gfxP) { + PreRender_FetchFbufCoverage(this, gfxP); LogUtils_CheckNullPointer("this->cvg_save", this->cvgSave, "../PreRender.c", 532); if (this->cvgSave != NULL) { - PreRender_CoverageRgba16ToI8(this, gfxp, this->fbuf, this->cvgSave); + PreRender_CoverageRgba16ToI8(this, gfxP, this->fbuf, this->cvgSave); } } /** * Restores zbufSave to zbuf */ -void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxp) { - PreRender_CopyImage(this, gfxp, this->zbufSave, this->zbuf); +void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxP) { + PreRender_CopyImage(this, gfxP, this->zbufSave, this->zbuf); } /** * Draws a full-screen image to the current framebuffer, that sources the rgb channel from `this->fbufSave` and * the alpha channel from `this->cvgSave` modulated by environment color. */ -void func_800C213C(PreRender* this, Gfx** gfxp) { +void func_800C213C(PreRender* this, Gfx** gfxP) { Gfx* gfx; s32 rowsRemaining; s32 curRow; @@ -427,8 +427,8 @@ void func_800C213C(PreRender* this, Gfx** gfxp) { if (this->cvgSave != NULL) { LogUtils_CheckNullPointer("this", this, "../PreRender.c", 563); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 564); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 564); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 566); gDPPipeSync(gfx++); @@ -482,23 +482,23 @@ void func_800C213C(PreRender* this, Gfx** gfxp) { } gDPPipeSync(gfx++); - *gfxp = gfx; + *gfxP = gfx; } } /** * Copies fbufSave to fbuf */ -void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxp) { - PreRender_CopyImage(this, gfxp, this->fbufSave, this->fbuf); +void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxP) { + PreRender_CopyImage(this, gfxP, this->fbufSave, this->fbuf); } /** * Copies part of `this->fbufSave` in the region (this->ulx, this->uly), (this->lrx, this->lry) to the same location in * `this->fbuf`. */ -void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxp) { - PreRender_CopyImageRegionImpl(this, gfxp); +void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxP) { + PreRender_CopyImageRegionImpl(this, gfxP); } /** diff --git a/src/code/code_800ACE70.c b/src/code/code_800ACE70.c deleted file mode 100644 index a7252904d..000000000 --- a/src/code/code_800ACE70.c +++ /dev/null @@ -1,97 +0,0 @@ -#include "global.h" - -// Note : This file is related to z_vismono, the original name was probably z_vis - -Gfx D_8012AC00[] = { - gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, - G_AC_NONE | G_ZS_PRIM | G_RM_VISCVG | G_RM_VISCVG2), - gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), - gsDPPipeSync(), - gsDPSetBlendColor(0, 0, 0, 8), - gsSPEndDisplayList(), -}; - -Gfx D_8012AC28[] = { - gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, - G_AC_NONE | G_ZS_PRIM | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL | - GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM) | - GBL_c2(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM)), - gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), - gsSPEndDisplayList(), -}; - -Gfx D_8012AC40[] = { - gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, - G_AC_NONE | G_ZS_PRIM | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL | - GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) | - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)), - - gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), - gsSPEndDisplayList(), -}; - -Gfx D_8012AC58[] = { - gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE), - gsDPSetOtherMode(G_AD_NOTPATTERN | G_CD_DISABLE | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, - G_AC_NONE | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2), - gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), - gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, - G_AC_NONE | G_ZS_PRIM | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL | - GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) | - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)), - gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), - gsSPEndDisplayList(), -}; - -// Init -void func_800ACE70(struct_801664F0* this) { - this->type = 0; - this->setScissor = false; - this->color.r = 255; - this->color.g = 255; - this->color.b = 255; - this->color.a = 255; -} - -// Destroy -void func_800ACE90(struct_801664F0* this) { -} - -// Draw -void func_800ACE98(struct_801664F0* this, Gfx** gfxp) { - Gfx* gfx = *gfxp; - - gDPPipeSync(gfx++); - gDPSetPrimDepth(gfx++, 0xFFFF, 0xFFFF); - - if (this->setScissor == true) { - gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - } - - switch (this->type) { - case 1: - gSPDisplayList(gfx++, D_8012AC40); - break; - case 2: - gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba); - gSPDisplayList(gfx++, D_8012AC58); - break; - case 3: - gDPSetColor(gfx++, G_SETBLENDCOLOR, this->color.rgba); - gSPDisplayList(gfx++, D_8012AC00); - break; - case 4: - gDPSetColor(gfx++, G_SETFOGCOLOR, this->color.rgba); - gSPDisplayList(gfx++, D_8012AC28); - break; - } - - gDPPipeSync(gfx++); - *gfxp = gfx; -} diff --git a/src/code/code_800AD920.c b/src/code/code_800AD920.c deleted file mode 100644 index 94479e164..000000000 --- a/src/code/code_800AD920.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "global.h" - -// Note : This file is related to z_vismono, the original name was probably z_vis - -// z-buffer -extern u16 D_0E000000[]; - -// Init -void func_800AD920(struct_80166500* this) { - this->useRgba = false; - this->setScissor = false; - this->primColor.r = 255; - this->primColor.g = 255; - this->primColor.b = 255; - this->primColor.a = 255; - this->envColor.a = 255; - this->envColor.r = 0; - this->envColor.g = 0; - this->envColor.b = 0; -} - -// Destroy -void func_800AD950(struct_80166500* this) { -} - -// Draw -void func_800AD958(struct_80166500* this, Gfx** gfxp) { - Gfx* gfx = *gfxp; - u16* tex = D_0E000000; - s32 fmt = !this->useRgba ? G_IM_FMT_IA : G_IM_FMT_RGBA; - s32 y; - s32 height = 6; - - gDPPipeSync(gfx++); - if (this->setScissor == true) { - gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - } - - gDPSetOtherMode(gfx++, - G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, - G_AC_NONE | G_ZS_PRIM | G_RM_OPA_SURF | G_RM_OPA_SURF2); - gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, - PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT); - - gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba); - gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba); - - for (y = 0; y <= SCREEN_HEIGHT - height; y += height) { - gDPLoadTextureBlock(gfx++, tex, fmt, G_IM_SIZ_16b, SCREEN_WIDTH, height, 0, G_TX_NOMIRROR | G_TX_CLAMP, - G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - - gSPTextureRectangle(gfx++, 0, y << 2, SCREEN_WIDTH << 2, (y + height) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, - 1 << 10); - tex += SCREEN_WIDTH * height; - } - - gDPPipeSync(gfx++); - *gfxp = gfx; -} diff --git a/src/code/code_800BB0A0.c b/src/code/code_800BB0A0.c index e525a0069..421f9a280 100644 --- a/src/code/code_800BB0A0.c +++ b/src/code/code_800BB0A0.c @@ -61,7 +61,7 @@ s32 func_800BB2B4(Vec3f* pos, f32* roll, f32* fov, CutsceneCameraPoint* point, s } *curFrame += advance; if (*curFrame >= 1) { - if (point[++*keyFrame + 3].continueFlag == CS_CMD_STOP) { + if (point[++*keyFrame + 3].continueFlag == CS_CAM_STOP) { *keyFrame = 0; ret = true; } diff --git a/src/code/code_800D31A0.c b/src/code/code_800D31A0.c index 6bfa18d97..a6540c429 100644 --- a/src/code/code_800D31A0.c +++ b/src/code/code_800D31A0.c @@ -3,7 +3,7 @@ u32 gIsCtrlr2Valid = false; -void func_800D31A0(void) { +NORETURN void func_800D31A0(void) { osSyncPrintf(VT_FGCOL(RED) "\n**** Freeze!! ****\n" VT_RST); while (true) { Sleep_Msec(1000); diff --git a/src/code/fault.c b/src/code/fault.c index 19348bc7f..084522218 100644 --- a/src/code/fault.c +++ b/src/code/fault.c @@ -1164,19 +1164,25 @@ void Fault_HungupFaultClient(const char* exp1, const char* exp2) { * error occurs. The parameters specify two messages detailing the error, one * or both may be NULL. */ -void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) { +NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) { FaultClient client; s32 pad; Fault_AddClient(&client, Fault_HungupFaultClient, (void*)exp1, (void*)exp2); *(u32*)0x11111111 = 0; // trigger an exception via unaligned memory access + + // Since the above line triggers an exception and transfers execution to the fault handler + // this function does not return and the rest of the function is unreachable. +#ifdef __GNUC__ + __builtin_unreachable(); +#endif } /** * Like `Fault_AddHungupAndCrashImpl`, however provides a fixed message containing * filename and line number */ -void Fault_AddHungupAndCrash(const char* file, s32 line) { +NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line) { char msg[256]; sprintf(msg, "HungUp %s:%d", file, line); diff --git a/src/code/game.c b/src/code/game.c index 86b550ae6..38d95d41c 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -7,9 +7,9 @@ SpeedMeter D_801664D0; #endif -struct_801664F0 D_801664F0; -struct_80166500 D_80166500; -VisMono sMonoColors; +VisCvg sVisCvg; +VisZBuf sVisZBuf; +VisMono sVisMono; ViMode sViMode; FaultClient sGameFaultClient; u16 sLastButtonPressed; @@ -27,40 +27,43 @@ void GameState_FaultPrint(void) { } } -void GameState_SetFBFilter(Gfx** gfx) { - Gfx* gfxP = *gfx; +void GameState_SetFBFilter(Gfx** gfxP) { + Gfx* gfx = *gfxP; - if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) { - D_801664F0.type = R_FB_FILTER_TYPE; - D_801664F0.color.r = R_FB_FILTER_PRIM_COLOR(0); - D_801664F0.color.g = R_FB_FILTER_PRIM_COLOR(1); - D_801664F0.color.b = R_FB_FILTER_PRIM_COLOR(2); - D_801664F0.color.a = R_FB_FILTER_A; - func_800ACE98(&D_801664F0, &gfxP); - } else if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) { - D_80166500.useRgba = (R_FB_FILTER_TYPE == 6); - D_80166500.primColor.r = R_FB_FILTER_PRIM_COLOR(0); - D_80166500.primColor.g = R_FB_FILTER_PRIM_COLOR(1); - D_80166500.primColor.b = R_FB_FILTER_PRIM_COLOR(2); - D_80166500.primColor.a = R_FB_FILTER_A; - D_80166500.envColor.r = R_FB_FILTER_ENV_COLOR(0); - D_80166500.envColor.g = R_FB_FILTER_ENV_COLOR(1); - D_80166500.envColor.b = R_FB_FILTER_ENV_COLOR(2); - D_80166500.envColor.a = R_FB_FILTER_A; - func_800AD958(&D_80166500, &gfxP); - } else if (R_FB_FILTER_TYPE == 7) { - sMonoColors.unk_00 = 0; - sMonoColors.primColor.r = R_FB_FILTER_PRIM_COLOR(0); - sMonoColors.primColor.g = R_FB_FILTER_PRIM_COLOR(1); - sMonoColors.primColor.b = R_FB_FILTER_PRIM_COLOR(2); - sMonoColors.primColor.a = R_FB_FILTER_A; - sMonoColors.envColor.r = R_FB_FILTER_ENV_COLOR(0); - sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1); - sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2); - sMonoColors.envColor.a = R_FB_FILTER_A; - VisMono_Draw(&sMonoColors, &gfxP); + if ((R_FB_FILTER_TYPE >= FB_FILTER_CVG_RGB) && (R_FB_FILTER_TYPE <= FB_FILTER_CVG_RGB_FOG)) { + // Visualize coverage + sVisCvg.vis.type = FB_FILTER_TO_CVG_TYPE(R_FB_FILTER_TYPE); + sVisCvg.vis.primColor.r = R_FB_FILTER_PRIM_COLOR(0); + sVisCvg.vis.primColor.g = R_FB_FILTER_PRIM_COLOR(1); + sVisCvg.vis.primColor.b = R_FB_FILTER_PRIM_COLOR(2); + sVisCvg.vis.primColor.a = R_FB_FILTER_A; + VisCvg_Draw(&sVisCvg, &gfx); + } else if ((R_FB_FILTER_TYPE == FB_FILTER_ZBUF_IA) || (R_FB_FILTER_TYPE == FB_FILTER_ZBUF_RGBA)) { + // Visualize z-buffer + sVisZBuf.vis.type = (R_FB_FILTER_TYPE == FB_FILTER_ZBUF_RGBA); + sVisZBuf.vis.primColor.r = R_FB_FILTER_PRIM_COLOR(0); + sVisZBuf.vis.primColor.g = R_FB_FILTER_PRIM_COLOR(1); + sVisZBuf.vis.primColor.b = R_FB_FILTER_PRIM_COLOR(2); + sVisZBuf.vis.primColor.a = R_FB_FILTER_A; + sVisZBuf.vis.envColor.r = R_FB_FILTER_ENV_COLOR(0); + sVisZBuf.vis.envColor.g = R_FB_FILTER_ENV_COLOR(1); + sVisZBuf.vis.envColor.b = R_FB_FILTER_ENV_COLOR(2); + sVisZBuf.vis.envColor.a = R_FB_FILTER_A; + VisZBuf_Draw(&sVisZBuf, &gfx); + } else if (R_FB_FILTER_TYPE == FB_FILTER_MONO) { + // Monochrome filter + sVisMono.vis.type = 0; + sVisMono.vis.primColor.r = R_FB_FILTER_PRIM_COLOR(0); + sVisMono.vis.primColor.g = R_FB_FILTER_PRIM_COLOR(1); + sVisMono.vis.primColor.b = R_FB_FILTER_PRIM_COLOR(2); + sVisMono.vis.primColor.a = R_FB_FILTER_A; + sVisMono.vis.envColor.r = R_FB_FILTER_ENV_COLOR(0); + sVisMono.vis.envColor.g = R_FB_FILTER_ENV_COLOR(1); + sVisMono.vis.envColor.b = R_FB_FILTER_ENV_COLOR(2); + sVisMono.vis.envColor.a = R_FB_FILTER_A; + VisMono_Draw(&sVisMono, &gfx); } - *gfx = gfxP; + *gfxP = gfx; } void func_800C4344(GameState* gameState) { @@ -119,7 +122,7 @@ void func_800C4344(GameState* gameState) { #ifdef SHOW_INPUT_DISPLAY -void GameState_DrawInputDisplay(u16 input, Gfx** gfx) { +void GameState_DrawInputDisplay(u16 input, Gfx** gfxP) { static const u16 sInpDispBtnColors[] = { GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(120, 120, 120, 1), GPACK_RGBA5551(120, 120, 120, 1), @@ -129,10 +132,10 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfx) { GPACK_RGBA5551(0, 0, 255, 1), }; s32 i, j, k; - Gfx* gfxP = *gfx; + Gfx* gfx = *gfxP; - gDPPipeSync(gfxP++); - gDPSetOtherMode(gfxP++, + gDPPipeSync(gfx++); + gDPSetOtherMode(gfx++, G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_FILL | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); @@ -140,14 +143,14 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfx) { for (i = 0; i < 16; i++) { j = i; if (input & (1 << i)) { - gDPSetFillColor(gfxP++, (sInpDispBtnColors[i] << 0x10) | sInpDispBtnColors[i]); + gDPSetFillColor(gfx++, (sInpDispBtnColors[i] << 0x10) | sInpDispBtnColors[i]); k = i + 1; - gDPFillRectangle(gfxP++, (j * 4) + 226, 220, (k * 4) + 225, 223); - gDPPipeSync(gfxP++); + gDPFillRectangle(gfx++, (j * 4) + 226, 220, (k * 4) + 225, 223); + gDPPipeSync(gfx++); } } - *gfx = gfxP; + *gfxP = gfx; } #endif @@ -437,9 +440,9 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g startTime = endTime; LogUtils_CheckNullPointer("this->cleanup", gameState->destroy, "../game.c", 1088); - func_800ACE70(&D_801664F0); - func_800AD920(&D_80166500); - VisMono_Init(&sMonoColors); + VisCvg_Init(&sVisCvg); + VisZBuf_Init(&sVisZBuf); + VisMono_Init(&sVisMono); if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) { ViMode_Init(&sViMode); } @@ -475,9 +478,9 @@ void GameState_Destroy(GameState* gameState) { SpeedMeter_Destroy(&D_801664D0); #endif - func_800ACE90(&D_801664F0); - func_800AD950(&D_80166500); - VisMono_Destroy(&sMonoColors); + VisCvg_Destroy(&sVisCvg); + VisZBuf_Destroy(&sVisZBuf); + VisMono_Destroy(&sVisMono); if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) { ViMode_Destroy(&sViMode); } diff --git a/src/code/graph.c b/src/code/graph.c index 74ab43103..d894f6232 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -537,17 +537,17 @@ Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst) { return dst; } -void* Graph_DlistAlloc(Gfx** gfx, u32 size) { +void* Graph_DlistAlloc(Gfx** gfxP, u32 size) { u8* ptr; Gfx* dst; size = ALIGN8(size); - ptr = (u8*)(*gfx + 1); + ptr = (u8*)(*gfxP + 1); dst = (Gfx*)(ptr + size); - gSPBranchList(*gfx, dst); + gSPBranchList(*gfxP, dst); - *gfx = dst; + *gfxP = dst; return ptr; } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 519007c4d..d105e12e2 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -802,7 +802,7 @@ void Actor_SetScale(Actor* actor, f32 scale) { } void Actor_SetObjectDependency(PlayState* play, Actor* actor) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[actor->objBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[actor->objectSlot].segment); } void Actor_Init(Actor* actor, PlayState* play) { @@ -821,7 +821,7 @@ void Actor_Init(Actor* actor, PlayState* play) { CollisionCheck_InitInfo(&actor->colChkInfo); actor->floorBgId = BGCHECK_SCENE; ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); - if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, actor->objectSlot)) { Actor_SetObjectDependency(play, actor); actor->init(actor, play); actor->init = NULL; @@ -2146,13 +2146,13 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { actor->sfx = 0; if (actor->init != NULL) { - if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, actor->objectSlot)) { Actor_SetObjectDependency(play, actor); actor->init(actor, play); actor->init = NULL; } actor = actor->next; - } else if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + } else if (!Object_IsLoaded(&play->objectCtx, actor->objectSlot)) { Actor_Kill(actor); actor = actor->next; } else if ((requiredActorFlag && !(actor->flags & requiredActorFlag)) || @@ -2275,8 +2275,8 @@ void Actor_Draw(PlayState* play, Actor* actor) { Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY); Actor_SetObjectDependency(play, actor); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment); - gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[actor->objectSlot].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.slots[actor->objectSlot].segment); if (actor->colorFilterTimer != 0) { Color_RGBA8 color = { 0, 0, 0, 255 }; @@ -2573,7 +2573,7 @@ void Actor_KillAllWithMissingObject(PlayState* play, ActorContext* actorCtx) { for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { actor = actorCtx->actorLists[i].head; while (actor != NULL) { - if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + if (!Object_IsLoaded(&play->objectCtx, actor->objectSlot)) { Actor_Kill(actor); } actor = actor->next; @@ -2748,7 +2748,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos s32 pad; Actor* actor; ActorInit* actorInit; - s32 objBankIndex; + s32 objectSlot; ActorOverlay* overlayEntry; uintptr_t temp; char* name; @@ -2831,13 +2831,13 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos : NULL); } - objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId); + objectSlot = Object_GetSlot(&play->objectCtx, actorInit->objectId); - if ((objBankIndex < 0) || + if ((objectSlot < 0) || ((actorInit->category == ACTORCAT_ENEMY) && Flags_GetClear(play, play->roomCtx.curRoom.num))) { // "No data bank!! (profilep->bank=%d)" osSyncPrintf(VT_COL(RED, WHITE) "データバンク無し!!<データバンク=%d>(profilep->bank=%d)\n" VT_RST, - objBankIndex, actorInit->objectId); + objectSlot, actorInit->objectId); Actor_FreeOverlay(overlayEntry); return NULL; } @@ -2867,10 +2867,10 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos actor->flags = actorInit->flags; if (actorInit->id == ACTOR_EN_PART) { - actor->objBankIndex = rotZ; + actor->objectSlot = rotZ; rotZ = 0; } else { - actor->objBankIndex = objBankIndex; + actor->objectSlot = objectSlot; } actor->init = actorInit->init; @@ -3164,7 +3164,7 @@ s16 func_80032D60(s16* arg0, s16 arg1, s16 arg2, s16 arg3) { void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) { u32 matricesSize; u32 dListsSize; - u32 objectIdsSize; + u32 objectSlotsSize; matricesSize = (count + 1) * sizeof(*bodyBreak->matrices); bodyBreak->matrices = ZeldaArena_MallocDebug(matricesSize, "../z_actor.c", 7540); @@ -3174,13 +3174,13 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) { bodyBreak->dLists = ZeldaArena_MallocDebug(dListsSize, "../z_actor.c", 7543); if (bodyBreak->dLists != NULL) { - objectIdsSize = (count + 1) * sizeof(*bodyBreak->objectIds); - bodyBreak->objectIds = ZeldaArena_MallocDebug(objectIdsSize, "../z_actor.c", 7546); + objectSlotsSize = (count + 1) * sizeof(*bodyBreak->objectSlots); + bodyBreak->objectSlots = ZeldaArena_MallocDebug(objectSlotsSize, "../z_actor.c", 7546); - if (bodyBreak->objectIds != NULL) { + if (bodyBreak->objectSlots != NULL) { Lib_MemSet((u8*)bodyBreak->matrices, matricesSize, 0); Lib_MemSet((u8*)bodyBreak->dLists, dListsSize, 0); - Lib_MemSet((u8*)bodyBreak->objectIds, objectIdsSize, 0); + Lib_MemSet((u8*)bodyBreak->objectSlots, objectSlotsSize, 0); bodyBreak->val = 1; return; } @@ -3195,20 +3195,20 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) { ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7561); } - if (bodyBreak->objectIds != NULL) { - ZeldaArena_FreeDebug(bodyBreak->objectIds, "../z_actor.c", 7564); + if (bodyBreak->objectSlots != NULL) { + ZeldaArena_FreeDebug(bodyBreak->objectSlots, "../z_actor.c", 7564); } } void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s32 maxLimbIndex, u32 count, Gfx** dList, - s16 objectId) { + s16 objectSlot) { PlayState* play = Effect_GetPlayState(); if ((play->actorCtx.freezeFlashTimer == 0) && (bodyBreak->val > 0)) { if ((limbIndex >= minLimbIndex) && (limbIndex <= maxLimbIndex) && (*dList != NULL)) { bodyBreak->dLists[bodyBreak->val] = *dList; Matrix_Get(&bodyBreak->matrices[bodyBreak->val]); - bodyBreak->objectIds[bodyBreak->val] = objectId; + bodyBreak->objectSlots[bodyBreak->val] = objectSlot; bodyBreak->val++; } @@ -3228,7 +3228,7 @@ void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s3 s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s16 type) { EnPart* spawnedEnPart; MtxF* mtx; - s16 objBankIndex; + s16 objectSlot; if (bodyBreak->val != BODYBREAK_STATUS_READY) { return false; @@ -3240,17 +3240,17 @@ s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s1 Matrix_Get(&bodyBreak->matrices[bodyBreak->count]); if (1) { - if (bodyBreak->objectIds[bodyBreak->count] >= 0) { - objBankIndex = bodyBreak->objectIds[bodyBreak->count]; + if (bodyBreak->objectSlots[bodyBreak->count] > BODYBREAK_OBJECT_SLOT_DEFAULT) { + objectSlot = bodyBreak->objectSlots[bodyBreak->count]; } else { - objBankIndex = actor->objBankIndex; + objectSlot = actor->objectSlot; } } mtx = &bodyBreak->matrices[bodyBreak->count]; spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, mtx->xw, mtx->yw, - mtx->zw, 0, 0, objBankIndex, type); + mtx->zw, 0, 0, objectSlot, type); if (spawnedEnPart != NULL) { Matrix_MtxFToYXZRotS(&bodyBreak->matrices[bodyBreak->count], &spawnedEnPart->actor.shape.rot, 0); @@ -3265,7 +3265,7 @@ s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s1 ZeldaArena_FreeDebug(bodyBreak->matrices, "../z_actor.c", 7678); ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7679); - ZeldaArena_FreeDebug(bodyBreak->objectIds, "../z_actor.c", 7680); + ZeldaArena_FreeDebug(bodyBreak->objectSlots, "../z_actor.c", 7680); return true; } @@ -4342,7 +4342,7 @@ Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, EnPart* spawnedEnPart; spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, spawnPos->x, spawnPos->y, - spawnPos->z, spawnRot->x, spawnRot->y, actor->objBankIndex, params); + spawnPos->z, spawnRot->x, spawnRot->y, actor->objectSlot, params); if (spawnedEnPart != NULL) { spawnedEnPart->actor.scale = actor->scale; spawnedEnPart->actor.speed = arg3[0]; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 305923dc5..abedf324e 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -3145,7 +3145,7 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) { f32 result; f32 intersect2; s32 i2; - s32 pauseState; + s32 isPaused; DynaPolyActor* dynaActor; s32 pad; Vec3f polyVtx[3]; @@ -3214,13 +3214,8 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) { dynaActor = DynaPoly_GetActor(dynaRaycastDown->colCtx, *dynaRaycastDown->bgId); if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycastDown->play != NULL)) { - pauseState = dynaRaycastDown->play->pauseCtx.state != 0; -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if (pauseState == 0) { - pauseState = dynaRaycastDown->play->pauseCtx.debugState != 0; - } -#endif - if (!pauseState && (dynaRaycastDown->colCtx->dyna.bgActorFlags[*dynaRaycastDown->bgId] & BGACTOR_1)) { + isPaused = IS_PAUSED(&dynaRaycastDown->play->pauseCtx); + if (!isPaused && (dynaRaycastDown->colCtx->dyna.bgActorFlags[*dynaRaycastDown->bgId] & BGACTOR_1)) { curTransform = &dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].curTransform; polyMin = &dynaRaycastDown->dyna diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 94d2a42ac..a098ba3cc 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -6879,7 +6879,7 @@ s32 Camera_Special9(Camera* camera) { f32 playerYOffset; s32 pad3; PosRot* playerPosRot = &camera->playerPosRot; - PosRot adjustedPlayerPosRot; + PosRot referencePosRot; f32 yNormal; DoorParams* doorParams = &camera->paramData.doorParams; Special9ReadOnlyData* roData = &camera->paramData.spec9.roData; @@ -6905,11 +6905,11 @@ s32 Camera_Special9(Camera* camera) { } if (doorParams->doorActor != NULL) { - Actor_GetWorldPosShapeRot(&adjustedPlayerPosRot, doorParams->doorActor); + Actor_GetWorldPosShapeRot(&referencePosRot, doorParams->doorActor); } else { - adjustedPlayerPosRot = *playerPosRot; - adjustedPlayerPosRot.pos.y += playerYOffset + roData->yOffset; - adjustedPlayerPosRot.rot.x = 0; + referencePosRot = *playerPosRot; + referencePosRot.pos.y += playerYOffset + roData->yOffset; + referencePosRot.rot.x = 0; } OLib_Vec3fDiffToVecGeo(&atEyeOffsetGeo, at, eye); @@ -6922,9 +6922,15 @@ s32 Camera_Special9(Camera* camera) { case 0: camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); camera->animState++; - rwData->targetYaw = ABS(playerPosRot->rot.y - adjustedPlayerPosRot.rot.y) >= 0x4000 - ? adjustedPlayerPosRot.rot.y - 0x7FFF - : adjustedPlayerPosRot.rot.y; + + //! @bug The angle passed to ABS should be cast to s16. + //! The lack of a cast means that a door which has an angle of around 0x8000 will calculate an incorrect + //! angle and use an incorrect `targetYaw`. + //! In-game, this means if the player opens a susceptible door at a slanted angle, the camera will not + //! appear correctly on the other side after the player has walked through the door. + rwData->targetYaw = ABS(playerPosRot->rot.y - referencePosRot.rot.y) >= 0x4000 + ? referencePosRot.rot.y - 0x7FFF + : referencePosRot.rot.y; FALLTHROUGH; case 1: doorParams->timer1--; diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 08df0da30..4b04c5417 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -49,7 +49,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) { MtxF mfTransBillboard; s32 pad1; Mtx* mtx; - void* object = play->objectCtx.status[this->rgObjBankIdx].segment; + void* objectPtr = play->objectCtx.slots[this->rgObjectSlot].segment; OPEN_DISPS(gfxCtx); @@ -58,8 +58,8 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) { SkinMatrix_SetScale(&mfScale, scale, scale, scale); SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); - gSPSegment(POLY_XLU_DISP++, 0x06, object); + gSegments[6] = VIRTUAL_TO_PHYSICAL(objectPtr); + gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 00bc3837a..0c63dbae1 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -236,7 +236,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { this->scale = 0.01f; break; case ITEM00_SHIELD_DEKU: - this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_1); + this->actor.objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_SHIELD_1); Actor_SetObjectDependency(play, &this->actor); Actor_SetScale(&this->actor, 0.5f); this->scale = 0.5f; @@ -245,7 +245,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { this->actor.world.rot.x = 0x4000; break; case ITEM00_SHIELD_HYLIAN: - this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_2); + this->actor.objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_SHIELD_2); Actor_SetObjectDependency(play, &this->actor); Actor_SetScale(&this->actor, 0.5f); this->scale = 0.5f; @@ -255,7 +255,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { break; case ITEM00_TUNIC_ZORA: case ITEM00_TUNIC_GORON: - this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_CLOTHES); + this->actor.objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_CLOTHES); Actor_SetObjectDependency(play, &this->actor); Actor_SetScale(&this->actor, 0.5f); this->scale = 0.5f; @@ -765,10 +765,10 @@ void EnItem00_Draw(Actor* thisx, PlayState* play) { case ITEM00_RECOVERY_HEART: if (this->despawnTimer < 0) { if (this->despawnTimer == -1) { - s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART); + s8 objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_HEART); - if (Object_IsLoaded(&play->objectCtx, bankIndex)) { - this->actor.objBankIndex = bankIndex; + if (Object_IsLoaded(&play->objectCtx, objectSlot)) { + this->actor.objectSlot = objectSlot; Actor_SetObjectDependency(play, &this->actor); this->despawnTimer = -2; } diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 14f71fc6e..796ce358d 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -95,7 +95,7 @@ void GameOver_Update(PlayState* play) { gGameOverTimer--; if (gGameOverTimer == 0) { - play->pauseCtx.state = 8; + play->pauseCtx.state = PAUSE_STATE_8; gameOverCtx->state++; Rumble_Reset(); } diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 8680d1db3..4278b12ef 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -56,34 +56,30 @@ void KaleidoScopeCall_Update(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; PauseContext* pauseCtx = &play->pauseCtx; -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((pauseCtx->state != 0) || (pauseCtx->debugState != 0)) { -#else - if (pauseCtx->state != 0) { -#endif - if (pauseCtx->state == 1) { + if (IS_PAUSED(pauseCtx)) { + if (pauseCtx->state == PAUSE_STATE_WAIT_LETTERBOX) { if (Letterbox_GetSize() == 0) { R_HREG_MODE = HREG_MODE_UCODE_DISAS; R_UCODE_DISAS_LOG_MODE = 3; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; pauseCtx->unk_1E4 = 0; pauseCtx->unk_1EC = 0; - pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; + pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; // PAUSE_STATE_WAIT_BG_PRERENDER } - } else if (pauseCtx->state == 8) { + } else if (pauseCtx->state == PAUSE_STATE_8) { R_HREG_MODE = HREG_MODE_UCODE_DISAS; R_UCODE_DISAS_LOG_MODE = 3; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; pauseCtx->unk_1E4 = 0; pauseCtx->unk_1EC = 0; - pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; - } else if ((pauseCtx->state == 2) || (pauseCtx->state == 9)) { + pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; // PAUSE_STATE_9 + } else if ((pauseCtx->state == PAUSE_STATE_WAIT_BG_PRERENDER) || (pauseCtx->state == PAUSE_STATE_9)) { osSyncPrintf("PR_KAREIDOSCOPE_MODE=%d\n", R_PAUSE_BG_PRERENDER_STATE); if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_READY) { - pauseCtx->state++; + pauseCtx->state++; // PAUSE_STATE_INIT or PAUSE_STATE_10 } - } else if (pauseCtx->state != 0) { + } else if (pauseCtx->state != PAUSE_STATE_OFF) { if (gKaleidoMgrCurOvl != kaleidoScopeOvl) { if (gKaleidoMgrCurOvl != NULL) { osSyncPrintf(VT_FGCOL(GREEN)); @@ -105,11 +101,7 @@ void KaleidoScopeCall_Update(PlayState* play) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { sKaleidoScopeUpdateFunc(play); -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { -#else - if ((play->pauseCtx.state == 0)) { -#endif + if (!IS_PAUSED(&play->pauseCtx)) { osSyncPrintf(VT_FGCOL(GREEN)); // "Kaleido area Kaleidoscope Emission" osSyncPrintf("カレイド領域 カレイドスコープ排出\n"); @@ -127,8 +119,8 @@ void KaleidoScopeCall_Draw(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_READY) { - if (((play->pauseCtx.state >= 4) && (play->pauseCtx.state <= 7)) || - ((play->pauseCtx.state >= 11) && (play->pauseCtx.state <= 18))) { + if (((play->pauseCtx.state >= PAUSE_STATE_OPENING_1) && (play->pauseCtx.state <= PAUSE_STATE_SAVE_PROMPT)) || + ((play->pauseCtx.state >= PAUSE_STATE_11) && (play->pauseCtx.state <= PAUSE_STATE_CLOSING))) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { sKaleidoScopeDrawFunc(play); } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 49d8e366a..b6e998baa 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -12,22 +12,13 @@ void KaleidoSetup_Update(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; Input* input = &play->state.input[0]; - u8 canUpdate = ( - play->gameOverCtx.state == GAMEOVER_INACTIVE && + if (!IS_PAUSED(pauseCtx) && play->gameOverCtx.state == GAMEOVER_INACTIVE && play->transitionTrigger == TRANS_TRIGGER_OFF && play->transitionMode == TRANS_MODE_OFF && gSaveContext.save.cutsceneIndex < 0xFFF0 && gSaveContext.nextCutsceneIndex < 0xFFF0 && !Play_InCsMode(play) && play->shootingGalleryStatus <= 1 && gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY && gSaveContext.magicState != MAGIC_STATE_FILL && (play->sceneId != SCENE_BOMBCHU_BOWLING_ALLEY || !Flags_GetSwitch(play, 0x38)) - ); - -#ifdef ENABLE_INV_EDITOR - canUpdate = (pauseCtx->state == 0 && pauseCtx->debugState == 0) && canUpdate; -#else - canUpdate = (pauseCtx->state == 0) && canUpdate; -#endif - - if (canUpdate) { + ) { #ifdef ENABLE_EVENT_EDITOR if (CHECK_BTN_ALL(input->cur.button, BTN_L) && CHECK_BTN_ALL(input->press.button, BTN_CUP)) { @@ -38,6 +29,7 @@ void KaleidoSetup_Update(PlayState* play) { #else if (CHECK_BTN_ALL(input->press.button, BTN_START)) { #endif + // The start button was pressed, pause gSaveContext.prevHudVisibilityMode = gSaveContext.hudVisibilityMode; WREG(16) = -175; @@ -57,13 +49,13 @@ void KaleidoSetup_Update(PlayState* play) { } pauseCtx->mode = (u16)(pauseCtx->pageIndex * 2) + 1; - pauseCtx->state = 1; + pauseCtx->state = PAUSE_STATE_WAIT_LETTERBOX; osSyncPrintf("Mode=%d eye.x=%f, eye.z=%f kscp_pos=%d\n", pauseCtx->mode, pauseCtx->eye.x, pauseCtx->eye.z, pauseCtx->pageIndex); } - if (pauseCtx->state == 1) { + if (pauseCtx->state == PAUSE_STATE_WAIT_LETTERBOX) { WREG(2) = -6240; R_UPDATE_RATE = 2; @@ -80,7 +72,7 @@ void KaleidoSetup_Init(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; u64 temp = 0; // Necessary to match - pauseCtx->state = 0; + pauseCtx->state = PAUSE_STATE_OFF; #if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) pauseCtx->debugState = 0; #endif diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 9e8b90842..883d1c796 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -433,7 +433,7 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused) play->csCtx.actorCues[i] = NULL; } - if (Object_GetIndex(&play->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP) < 0 && !play->envCtx.sunMoonDisabled) { + if (Object_GetSlot(&play->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP) < 0 && !play->envCtx.sunMoonDisabled) { play->envCtx.sunMoonDisabled = true; // "Sun setting other than field keep! So forced release!" osSyncPrintf(VT_COL(YELLOW, BLACK) "\n\nフィールド常駐以外、太陽設定!よって強制解除!\n" VT_RST); @@ -891,12 +891,8 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex Rumble_ClearRequests(); } - if (pauseCtx->state == 0) { -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { -#else - if ((play->pauseCtx.state == 0)) { -#endif + if (pauseCtx->state == PAUSE_STATE_OFF) { + if (!IS_PAUSED(&play->pauseCtx)) { if (play->skyboxId == SKYBOX_NORMAL_SKY) { play->skyboxCtx.rot.y -= 0.001f; } else if (play->skyboxId == SKYBOX_CUTSCENE_MAP) { @@ -927,7 +923,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex } } - if ((pauseCtx->state == 0) && (gameOverCtx->state == GAMEOVER_INACTIVE)) { + if ((pauseCtx->state == PAUSE_STATE_OFF) && (gameOverCtx->state == GAMEOVER_INACTIVE)) { if (((msgCtx->msgLength == 0) && (msgCtx->msgMode == MSGMODE_NONE)) || (((void)0, gSaveContext.gameMode) == GAMEMODE_END_CREDITS)) { diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index a118f4ccc..1b56785ab 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -510,16 +510,7 @@ void Health_UpdateBeatingHeart(PlayState* play) { if (interfaceCtx->beatingHeartOscillator <= 0) { interfaceCtx->beatingHeartOscillator = 0; interfaceCtx->beatingHeartOscillatorDirection = 0; - - canPlayLowHealthSFX = (!Player_InCsMode(play) && (play->pauseCtx.state == 0)); - -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - canPlayLowHealthSFX = - canPlayLowHealthSFX && (play->pauseCtx.debugState == 0) && Health_IsCritical() && !Play_InCsMode(play); -#else - canPlayLowHealthSFX = (canPlayLowHealthSFX && Health_IsCritical() && !Play_InCsMode(play)); -#endif - if (canPlayLowHealthSFX) { + if (!Player_InCsMode(play) && !IS_PAUSED(&play->pauseCtx) && Health_IsCritical() && !Play_InCsMode(play)) { #ifdef ENABLE_LOW_HEALTH_BEEP Sfx_PlaySfxCentered(NA_SE_SY_HITPOINT_ALARM); #endif diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 1be3e7c53..0f6ff928a 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -367,7 +367,7 @@ void Minimap_Draw(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - if (play->pauseCtx.state < 3) { + if (play->pauseCtx.state < PAUSE_STATE_INIT) { switch (play->sceneId) { case SCENE_DEKU_TREE: case SCENE_DODONGOS_CAVERN: @@ -527,11 +527,7 @@ void Map_Update(PlayState* play) { s16 floor; s16 i; -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { -#else - if (play->pauseCtx.state == 0) { -#endif + if (!IS_PAUSED(&play->pauseCtx)) { switch (play->sceneId) { case SCENE_DEKU_TREE: case SCENE_DODONGOS_CAVERN: diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 7e535ba28..ec357dfcf 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2152,7 +2152,7 @@ void Interface_SetDoAction(PlayState* play, u16 action) { interfaceCtx->unk_1EC = 1; interfaceCtx->unk_1F4 = 0.0f; Interface_LoadActionLabel(interfaceCtx, action, 1); - if (pauseCtx->state != 0) { + if (pauseCtx->state != PAUSE_STATE_OFF) { interfaceCtx->unk_1EC = 3; } } @@ -2569,13 +2569,9 @@ void Magic_Update(PlayState* play) { case MAGIC_STATE_CONSUME_LENS: // Slowly consume magic while lens is on - if ((play->pauseCtx.state == 0) && -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - (play->pauseCtx.debugState == 0) && -#endif - (msgCtx->msgMode == MSGMODE_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && - (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && - !Play_InCsMode(play)) { + if (!IS_PAUSED(&play->pauseCtx) && (msgCtx->msgMode == MSGMODE_NONE) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) { if ((gSaveContext.save.info.playerData.magic == 0) || ((Player_GetEnvironmentalHazard(play) >= PLAYER_ENV_HAZARD_UNDERWATER_FLOOR) && (Player_GetEnvironmentalHazard(play) <= PLAYER_ENV_HAZARD_UNDERWATER_FREE)) || @@ -2850,12 +2846,8 @@ void Interface_DrawItemButtons(PlayState* play) { WIDE_INCR(((R_ITEM_BTN_X(3) + R_ITEM_BTN_WIDTH(3)) << 2), WIDE_CRIGHT_SHIFT - 29), (R_ITEM_BTN_Y(3) + R_ITEM_BTN_WIDTH(3)) << 2, G_TX_RENDERTILE, 0, 0, WIDE_DIV(R_ITEM_BTN_DD(3), WIDE_GET_RATIO) << 1, R_ITEM_BTN_DD(3) << 1); - if ((pauseCtx->state < 8) || (pauseCtx->state >= 18)) { -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugState != 0)) { -#else - if (play->pauseCtx.state != 0) { -#endif + if (!IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { + if (IS_PAUSED(&play->pauseCtx)) { // Start Button Texture, Color & Label gDPPipeSync(OVERLAY_DISP++); #ifdef N64_BTN_COLORS @@ -2889,11 +2881,7 @@ void Interface_DrawItemButtons(PlayState* play) { } } - if (interfaceCtx->naviCalling && (play->pauseCtx.state == 0) && -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - (play->pauseCtx.debugState == 0) && -#endif - (play->csCtx.state == CS_STATE_IDLE)) { + if (interfaceCtx->naviCalling && !IS_PAUSED(&play->pauseCtx) && (play->csCtx.state == CS_STATE_IDLE)) { if (!sCUpInvisible) { // C-Up Button Texture, Color & Label (Navi Text) gDPPipeSync(OVERLAY_DISP++); @@ -3447,7 +3435,7 @@ void Interface_Draw(PlayState* play) { func_8008A994(interfaceCtx); - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 3)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 3)) { // Inventory Equip Effects gSPSegment(OVERLAY_DISP++, 0x08, pauseCtx->iconItemSegment); Gfx_SetupDL_42Overlay(play->state.gfxCtx); @@ -3498,11 +3486,7 @@ void Interface_Draw(PlayState* play) { Gfx_SetupDL_39Overlay(play->state.gfxCtx); -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { -#else - if (play->pauseCtx.state == 0) { -#endif + if (!IS_PAUSED(&play->pauseCtx)) { if (gSaveContext.minigameState != 1) { // Carrots rendering if the action corresponds to riding a horse if (interfaceCtx->unk_1EE == 8) { @@ -3600,14 +3584,10 @@ void Interface_Draw(PlayState* play) { } } - if ((play->pauseCtx.state == 0) && -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - (play->pauseCtx.debugState == 0) && -#endif - (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (msgCtx->msgMode == MSGMODE_NONE) && - !(player->stateFlags2 & PLAYER_STATE2_24) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && - (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play) && (gSaveContext.minigameState != 1) && - (play->shootingGalleryStatus <= 1) && + if (!IS_PAUSED(&play->pauseCtx) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (msgCtx->msgMode == MSGMODE_NONE) && !(player->stateFlags2 & PLAYER_STATE2_24) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !Play_InCsMode(play) && (gSaveContext.minigameState != 1) && (play->shootingGalleryStatus <= 1) && !((play->sceneId == SCENE_BOMBCHU_BOWLING_ALLEY) && Flags_GetSwitch(play, 0x38))) { timerId = TIMER_ID_MAIN; @@ -4053,11 +4033,18 @@ void Interface_Update(PlayState* play) { u16 action; Input* debugInput = &play->state.input[2]; -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { -#else - if (play->pauseCtx.state == 0) { -#endif + if (CHECK_BTN_ALL(debugInput->press.button, BTN_DLEFT)) { + gSaveContext.language = LANGUAGE_ENG; + osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language); + } else if (CHECK_BTN_ALL(debugInput->press.button, BTN_DUP)) { + gSaveContext.language = LANGUAGE_GER; + osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language); + } else if (CHECK_BTN_ALL(debugInput->press.button, BTN_DRIGHT)) { + gSaveContext.language = LANGUAGE_FRA; + osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language); + } + + if (!IS_PAUSED(&play->pauseCtx)) { if ((gSaveContext.minigameState == 1) || !IS_CUTSCENE_LAYER || ((play->sceneId == SCENE_LON_LON_RANCH) && (gSaveContext.sceneLayer == 4))) { if ((msgCtx->msgMode == MSGMODE_NONE) || @@ -4210,14 +4197,10 @@ void Interface_Update(PlayState* play) { Health_UpdateMeter(play); - if ((gSaveContext.timerState >= TIMER_STATE_ENV_HAZARD_MOVE) && (play->pauseCtx.state == 0) && -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - (play->pauseCtx.debugState == 0) && -#endif + if ((gSaveContext.timerState >= TIMER_STATE_ENV_HAZARD_MOVE) && !IS_PAUSED(&play->pauseCtx) && (msgCtx->msgMode == MSGMODE_NONE) && !(player->stateFlags2 & PLAYER_STATE2_24) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && - !Play_InCsMode(play)) { - } + !Play_InCsMode(play)) {} if (gSaveContext.rupeeAccumulator != 0) { if (gSaveContext.rupeeAccumulator > 0) { @@ -4300,13 +4283,9 @@ void Interface_Update(PlayState* play) { WREG(7) = interfaceCtx->unk_1F4; // Update Magic - if ((play->pauseCtx.state == 0) && -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - (play->pauseCtx.debugState == 0) && -#endif - (msgCtx->msgMode == MSGMODE_NONE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && - (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionMode == TRANS_MODE_OFF) && - ((play->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(play))) { + if (!IS_PAUSED(&play->pauseCtx) && (msgCtx->msgMode == MSGMODE_NONE) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->transitionMode == TRANS_MODE_OFF) && ((play->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(play))) { if (gSaveContext.save.info.playerData.isMagicAcquired && (gSaveContext.save.info.playerData.magicLevel == 0)) { gSaveContext.save.info.playerData.magicLevel = gSaveContext.save.info.playerData.isDoubleMagicAcquired + 1; diff --git a/src/code/z_play.c b/src/code/z_play.c index 053322a96..e170ce821 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -10,7 +10,7 @@ Input* D_8012D1F8 = NULL; TransitionTile sTransitionTile; s32 gTransitionTileState; -VisMono D_80161498; +VisMono sPlayVisMono; Color_RGBA8_u32 gVisMonoColor; FaultClient D_801614B8; s16 sTransitionFillTimer; @@ -201,7 +201,7 @@ void Play_Destroy(GameState* thisx) { Letterbox_Destroy(); TransitionFade_Destroy(&this->transitionFadeFlash); - VisMono_Destroy(&D_80161498); + VisMono_Destroy(&sPlayVisMono); if (gSaveContext.save.linkAge != this->linkAgeOnLoad) { Inventory_SwapAgeEquipment(); @@ -396,7 +396,7 @@ void Play_Init(GameState* thisx) { TransitionFade_SetType(&this->transitionFadeFlash, TRANS_INSTANCE_TYPE_FADE_FLASH); TransitionFade_SetColor(&this->transitionFadeFlash, RGBA8(160, 160, 160, 255)); TransitionFade_Start(&this->transitionFadeFlash); - VisMono_Init(&D_80161498); + VisMono_Init(&sPlayVisMono); gVisMonoColor.a = 0; CutsceneFlags_UnsetAll(this); @@ -453,7 +453,7 @@ void Play_Init(GameState* thisx) { void Play_Update(PlayState* this) { s32 pad1; - s32 sp80; + s32 isPaused; Input* input; u32 i; s32 pad2; @@ -488,8 +488,8 @@ void Play_Update(PlayState* this) { ActorOverlayTable_LogPrint(); } - gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); - gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment); + gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment); gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment); #ifdef ENABLE_FRAMERATE_OPTIONS @@ -857,21 +857,17 @@ void Play_Update(PlayState* this) { } PLAY_LOG(3551); -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - sp80 = (this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0); -#else - sp80 = (this->pauseCtx.state != 0); -#endif + isPaused = IS_PAUSED(&this->pauseCtx); PLAY_LOG(3555); AnimationContext_Reset(&this->animationCtx); PLAY_LOG(3561); - Object_UpdateBank(&this->objectCtx); + Object_UpdateEntries(&this->objectCtx); PLAY_LOG(3577); - if ((sp80 == 0) && (IREG(72) == 0)) { + if (!isPaused && (IREG(72) == 0)) { PLAY_LOG(3580); this->gameplayFrames++; @@ -938,11 +934,7 @@ void Play_Update(PlayState* this) { if (this->viewpoint != VIEWPOINT_NONE) { if (CHECK_BTN_ALL(input[0].press.button, BTN_CUP)) { -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) { -#else - if (this->pauseCtx.state != 0) { -#endif + if (IS_PAUSED(&this->pauseCtx)) { // "Changing viewpoint is prohibited due to the kaleidoscope" osSyncPrintf(VT_FGCOL(CYAN) "カレイドスコープ中につき視点変更を禁止しております\n" VT_RST); } else if (Player_InCsMode(this)) { @@ -966,11 +958,7 @@ void Play_Update(PlayState* this) { PLAY_LOG(3716); -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) { -#else - if (this->pauseCtx.state != 0) { -#endif + if (IS_PAUSED(&this->pauseCtx)) { PLAY_LOG(3721); KaleidoScopeCall_Update(this); } else if (this->gameOverCtx.state != GAMEOVER_INACTIVE) { @@ -1010,9 +998,9 @@ skip: PLAY_LOG(3801); #ifdef ENABLE_CAMERA_DEBUGGER - if ((sp80 == 0) || gDebugCamEnabled) { + if (!isPaused || gDebugCamEnabled) { #else - if (sp80 == 0) { + if (!isPaused) { #endif s32 pad3[5]; s32 i; @@ -1039,11 +1027,7 @@ skip: } void Play_DrawOverlayElements(PlayState* this) { -#if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) { -#else - if (this->pauseCtx.state != 0) { -#endif + if (IS_PAUSED(&this->pauseCtx)) { KaleidoScopeCall_Draw(this); } @@ -1065,21 +1049,21 @@ void Play_Draw(PlayState* this) { OPEN_DISPS(gfxCtx); - gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); - gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment); + gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment); gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment); gSPSegment(POLY_OPA_DISP++, 0x00, NULL); gSPSegment(POLY_XLU_DISP++, 0x00, NULL); gSPSegment(OVERLAY_DISP++, 0x00, NULL); - gSPSegment(POLY_OPA_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); - gSPSegment(POLY_XLU_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); - gSPSegment(OVERLAY_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment); + gSPSegment(POLY_XLU_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment); + gSPSegment(OVERLAY_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment); - gSPSegment(POLY_OPA_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment); - gSPSegment(POLY_XLU_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment); - gSPSegment(OVERLAY_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x05, this->objectCtx.slots[this->objectCtx.subKeepSlot].segment); + gSPSegment(POLY_XLU_DISP++, 0x05, this->objectCtx.slots[this->objectCtx.subKeepSlot].segment); + gSPSegment(OVERLAY_DISP++, 0x05, this->objectCtx.slots[this->objectCtx.subKeepSlot].segment); gSPSegment(POLY_OPA_DISP++, 0x02, this->sceneSegment); gSPSegment(POLY_XLU_DISP++, 0x02, this->sceneSegment); @@ -1133,8 +1117,8 @@ void Play_Draw(PlayState* this) { TransitionFade_Draw(&this->transitionFadeFlash, &gfxP); if (gVisMonoColor.a > 0) { - D_80161498.primColor.rgba = gVisMonoColor.rgba; - VisMono_Draw(&D_80161498, &gfxP); + sPlayVisMono.vis.primColor.rgba = gVisMonoColor.rgba; + VisMono_Draw(&sPlayVisMono, &gfxP); } gSPEndDisplayList(gfxP++); @@ -1470,7 +1454,7 @@ void Play_InitScene(PlayState* this, s32 spawn) { this->numActorEntries = 0; - Object_InitBank(this, &this->objectCtx); + Object_InitContext(this, &this->objectCtx); LightContext_Init(this, &this->lightCtx); TransitionActor_InitContext(&this->state, &this->transiActorCtx); func_80096FD4(this, &this->roomCtx.curRoom); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 824923ce9..bc5141aa4 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1370,7 +1370,7 @@ void Player_DrawHookshotReticle(PlayState* play, Player* this, f32 arg2) { gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_player_lib.c", 2587), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment); + gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.slots[this->actor.objectSlot].segment); gSPDisplayList(OVERLAY_DISP++, gLinkAdultHookshotReticleDL); CLOSE_DISPS(play->state.gfxCtx); @@ -1641,7 +1641,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve } } -u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime) { +u32 Player_InitPauseDrawData(PlayState* play, u8* segment, SkelAnime* skelAnime) { s16 linkObjectId = gLinkObjectIds[(void)0, gSaveContext.save.linkAge]; u32 size; void* ptr; @@ -1663,7 +1663,7 @@ u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime) { SkelAnime_InitLink(play, skelAnime, gPlayerSkelHeaders[(void)0, gSaveContext.save.linkAge], &gPlayerAnim_link_normal_wait, 9, ptr, ptr, PLAYER_LIMB_MAX); - return size + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE + + return PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE + size + sizeof(Vec3s[PLAYER_LIMB_BUF_COUNT]); } diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 189d1d6b0..90de47b09 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -907,8 +907,8 @@ Gfx* Gfx_SetupDL(Gfx* gfx, u32 i) { return Gfx_SetupDLImpl(gfx, i); } -void Gfx_SetupDLAtPtr(Gfx** gfxp, u32 i) { - *gfxp = Gfx_SetupDL(*gfxp, i); +void Gfx_SetupDLAtPtr(Gfx** gfxP, u32 i) { + *gfxP = Gfx_SetupDL(*gfxP, i); } Gfx* Gfx_SetupDL_57(Gfx* gfx) { @@ -1193,11 +1193,11 @@ void Gfx_SetupDL_39Overlay(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx); } -void Gfx_SetupDL_39Ptr(Gfx** gfxp) { - Gfx* gfx = *gfxp; +void Gfx_SetupDL_39Ptr(Gfx** gfxP) { + Gfx* gfx = *gfxP; gSPDisplayList(gfx++, sSetupDL[SETUPDL_39]); - *gfxp = gfx; + *gfxP = gfx; } void Gfx_SetupDL_40Opa(GraphicsContext* gfxCtx) { @@ -1345,12 +1345,12 @@ void Gfx_SetupDL_56Opa(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx); } -void Gfx_SetupDL_56Ptr(Gfx** gfxp) { - Gfx* gfx = *gfxp; +void Gfx_SetupDL_56Ptr(Gfx** gfxP) { + Gfx* gfx = *gfxP; gSPDisplayList(gfx++, sSetupDL[SETUPDL_56]); - *gfxp = gfx; + *gfxP = gfx; } void Gfx_SetupDL_59Opa(GraphicsContext* gfxCtx) { @@ -1361,8 +1361,8 @@ void Gfx_SetupDL_59Opa(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx); } -Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) { - Gfx* displayList = Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx)); +Gfx* Gfx_BranchTexScroll(Gfx** gfxP, u32 x, u32 y, s32 width, s32 height) { + Gfx* displayList = Graph_DlistAlloc(gfxP, 3 * sizeof(Gfx)); gDPTileSync(displayList); gDPSetTileSize(displayList + 1, G_TX_RENDERTILE, x, y, x + ((width - 1) << 2), y + ((height - 1) << 2)); @@ -1371,8 +1371,8 @@ Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) { return displayList; } -Gfx* func_80094E54(Gfx** gfxp, u32 x, u32 y) { - return Gfx_BranchTexScroll(gfxp, x, y, 0, 0); +Gfx* func_80094E54(Gfx** gfxP, u32 x, u32 y) { + return Gfx_BranchTexScroll(gfxP, x, y, 0, 0); } Gfx* func_80094E78(GraphicsContext* gfxCtx, u32 x, u32 y) { diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 7de8b3a22..72d77af17 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -3,64 +3,77 @@ RomFile sNaviQuestHintFiles[]; -s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) { +/** + * Spawn an object file of a specified ID that will persist through room changes. + * + * This waits for the file to be fully loaded, the data is available when the function returns. + * + * @return The new object slot corresponding to the requested object ID. + * + * @note This function is not meant to be called externally to spawn object files on the fly. + * When an object is spawned with this function, all objects that come before it in the entry list will be treated as + * persistent, which will likely cause either the amount of free slots or object space memory to run out. + * This function is only meant to be called internally on scene load, before the object list from any room is processed. + */ +s32 Object_SpawnPersistent(ObjectContext* objectCtx, s16 objectId) { u32 size; - objectCtx->status[objectCtx->num].id = objectId; + objectCtx->slots[objectCtx->numEntries].id = objectId; size = gObjectTable[objectId].vromEnd - gObjectTable[objectId].vromStart; - osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectId, size / 1024.0f, objectCtx->status[objectCtx->num].segment); + osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectId, size / 1024.0f, + objectCtx->slots[objectCtx->numEntries].segment); - osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (uintptr_t)objectCtx->status[objectCtx->num].segment + size, - objectCtx->spaceEnd); + osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->numEntries, + (uintptr_t)objectCtx->slots[objectCtx->numEntries].segment + size, objectCtx->spaceEnd); - ASSERT(((objectCtx->num < OBJECT_EXCHANGE_BANK_MAX) && - (((uintptr_t)objectCtx->status[objectCtx->num].segment + size) < (uintptr_t)objectCtx->spaceEnd)), + ASSERT(((objectCtx->numEntries < ARRAY_COUNT(objectCtx->slots)) && + (((uintptr_t)objectCtx->slots[objectCtx->numEntries].segment + size) < (uintptr_t)objectCtx->spaceEnd)), "this->num < OBJECT_EXCHANGE_BANK_MAX && (this->status[this->num].Segment + size) < this->endSegment", "../z_scene.c", 142); - DmaMgr_RequestSyncDebug(objectCtx->status[objectCtx->num].segment, gObjectTable[objectId].vromStart, size, + DmaMgr_RequestSyncDebug(objectCtx->slots[objectCtx->numEntries].segment, gObjectTable[objectId].vromStart, size, "../z_scene.c", 145); - if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) { - objectCtx->status[objectCtx->num + 1].segment = - (void*)ALIGN16((uintptr_t)objectCtx->status[objectCtx->num].segment + size); + if (objectCtx->numEntries < (ARRAY_COUNT(objectCtx->slots) - 1)) { + objectCtx->slots[objectCtx->numEntries + 1].segment = + (void*)ALIGN16((uintptr_t)objectCtx->slots[objectCtx->numEntries].segment + size); } - objectCtx->num++; - objectCtx->unk_09 = objectCtx->num; + objectCtx->numEntries++; + objectCtx->numPersistentEntries = objectCtx->numEntries; - return objectCtx->num - 1; + return objectCtx->numEntries - 1; } -void Object_InitBank(PlayState* play, ObjectContext* objectCtx) { - PlayState* play2 = play; // Needs to be a new variable to match (possibly a sub struct?) +void Object_InitContext(PlayState* play, ObjectContext* objectCtx) { + PlayState* play2 = play; u32 spaceSize; s32 i; if (play2->sceneId == SCENE_HYRULE_FIELD) { - spaceSize = 1024000; + spaceSize = 1000 * 1024; } else if (play2->sceneId == SCENE_GANON_BOSS) { if (gSaveContext.sceneLayer != 4) { - spaceSize = 1177600; + spaceSize = 1150 * 1024; } else { - spaceSize = 1024000; + spaceSize = 1000 * 1024; } } else if (play2->sceneId == SCENE_SPIRIT_TEMPLE_BOSS) { - spaceSize = 1075200; + spaceSize = 1050 * 1024; } else if (play2->sceneId == SCENE_CHAMBER_OF_THE_SAGES) { - spaceSize = 1075200; + spaceSize = 1050 * 1024; } else if (play2->sceneId == SCENE_GANONDORF_BOSS) { - spaceSize = 1075200; + spaceSize = 1050 * 1024; } else { - spaceSize = 1024000; + spaceSize = 1000 * 1024; } - objectCtx->num = objectCtx->unk_09 = 0; - objectCtx->mainKeepIndex = objectCtx->subKeepIndex = 0; + objectCtx->numEntries = objectCtx->numPersistentEntries = 0; + objectCtx->mainKeepSlot = objectCtx->subKeepSlot = 0; - for (i = 0; i < OBJECT_EXCHANGE_BANK_MAX; i++) { - objectCtx->status[i].id = OBJECT_INVALID; + for (i = 0; i < ARRAY_COUNT(objectCtx->slots); i++) { + objectCtx->slots[i].id = OBJECT_INVALID; } osSyncPrintf(VT_FGCOL(GREEN)); @@ -68,42 +81,43 @@ void Object_InitBank(PlayState* play, ObjectContext* objectCtx) { osSyncPrintf("オブジェクト入れ替えバンク情報 %8.3fKB\n", spaceSize / 1024.0f); osSyncPrintf(VT_RST); - objectCtx->spaceStart = objectCtx->status[0].segment = - GameState_Alloc(&play->state, spaceSize, "../z_scene.c", 219); + objectCtx->spaceStart = objectCtx->slots[0].segment = GameState_Alloc(&play->state, spaceSize, "../z_scene.c", 219); objectCtx->spaceEnd = (void*)((uintptr_t)objectCtx->spaceStart + spaceSize); - objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP); - gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment); + objectCtx->mainKeepSlot = Object_SpawnPersistent(objectCtx, OBJECT_GAMEPLAY_KEEP); + gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->slots[objectCtx->mainKeepSlot].segment); } -void Object_UpdateBank(ObjectContext* objectCtx) { +void Object_UpdateEntries(ObjectContext* objectCtx) { s32 i; - ObjectStatus* status = &objectCtx->status[0]; + ObjectEntry* entry = &objectCtx->slots[0]; RomFile* objectFile; u32 size; - for (i = 0; i < objectCtx->num; i++) { - if (status->id < 0) { - if (status->dmaRequest.vromAddr == 0) { - osCreateMesgQueue(&status->loadQueue, &status->loadMsg, 1); - objectFile = &gObjectTable[-status->id]; + for (i = 0; i < objectCtx->numEntries; i++) { + if (entry->id < 0) { + if (entry->dmaRequest.vromAddr == 0) { + osCreateMesgQueue(&entry->loadQueue, &entry->loadMsg, 1); + objectFile = &gObjectTable[-entry->id]; size = objectFile->vromEnd - objectFile->vromStart; - osSyncPrintf("OBJECT EXCHANGE BANK-%2d SIZE %8.3fK SEG=%08x\n", i, size / 1024.0f, status->segment); - DmaMgr_RequestAsync(&status->dmaRequest, status->segment, objectFile->vromStart, size, 0, - &status->loadQueue, NULL, "../z_scene.c", 266); - } else if (osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { - status->id = -status->id; + + osSyncPrintf("OBJECT EXCHANGE BANK-%2d SIZE %8.3fK SEG=%08x\n", i, size / 1024.0f, entry->segment); + + DmaMgr_RequestAsync(&entry->dmaRequest, entry->segment, objectFile->vromStart, size, 0, + &entry->loadQueue, NULL, "../z_scene.c", 266); + } else if (osRecvMesg(&entry->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { + entry->id = -entry->id; } } - status++; + entry++; } } -s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) { +s32 Object_GetSlot(ObjectContext* objectCtx, s16 objectId) { s32 i; - for (i = 0; i < objectCtx->num; i++) { - if (ABS(objectCtx->status[i].id) == objectId) { + for (i = 0; i < objectCtx->numEntries; i++) { + if (ABS(objectCtx->slots[i].id) == objectId) { return i; } } @@ -111,8 +125,8 @@ s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) { return -1; } -s32 Object_IsLoaded(ObjectContext* objectCtx, s32 bankIndex) { - if (objectCtx->status[bankIndex].id > 0) { +s32 Object_IsLoaded(ObjectContext* objectCtx, s32 slot) { + if (objectCtx->slots[slot].id > 0) { return true; } else { return false; @@ -124,30 +138,30 @@ void func_800981B8(ObjectContext* objectCtx) { s32 id; u32 size; - for (i = 0; i < objectCtx->num; i++) { - id = objectCtx->status[i].id; + for (i = 0; i < objectCtx->numEntries; i++) { + id = objectCtx->slots[i].id; size = gObjectTable[id].vromEnd - gObjectTable[id].vromStart; - osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->status[i].id, size / 1024.0f, - objectCtx->status[i].segment); - osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (uintptr_t)objectCtx->status[i].segment + size, + osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->slots[i].id, size / 1024.0f, + objectCtx->slots[i].segment); + osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->numEntries, (uintptr_t)objectCtx->slots[i].segment + size, objectCtx->spaceEnd); - DmaMgr_RequestSyncDebug(objectCtx->status[i].segment, gObjectTable[id].vromStart, size, "../z_scene.c", 342); + DmaMgr_RequestSyncDebug(objectCtx->slots[i].segment, gObjectTable[id].vromStart, size, "../z_scene.c", 342); } } -void* func_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId) { - ObjectStatus* status = &objectCtx->status[bankIndex]; +void* func_800982FC(ObjectContext* objectCtx, s32 slot, s16 objectId) { + ObjectEntry* entry = &objectCtx->slots[slot]; RomFile* objectFile = &gObjectTable[objectId]; u32 size; void* nextPtr; - status->id = -objectId; - status->dmaRequest.vromAddr = 0; + entry->id = -objectId; + entry->dmaRequest.vromAddr = 0; size = objectFile->vromEnd - objectFile->vromStart; - osSyncPrintf("OBJECT EXCHANGE NO=%2d BANK=%3d SIZE=%8.3fK\n", bankIndex, objectId, size / 1024.0f); + osSyncPrintf("OBJECT EXCHANGE NO=%2d BANK=%3d SIZE=%8.3fK\n", slot, objectId, size / 1024.0f); - nextPtr = (void*)ALIGN16((uintptr_t)status->segment + size); + nextPtr = (void*)ALIGN16((uintptr_t)entry->segment + size); ASSERT(nextPtr < objectCtx->spaceEnd, "nextptr < this->endSegment", "../z_scene.c", 381); @@ -191,7 +205,7 @@ void Scene_CommandPlayerEntryList(PlayState* play, SceneCmd* cmd) { linkObjectId = gLinkObjectIds[((void)0, gSaveContext.save.linkAge)]; gActorOverlayTable[playerEntry->id].initInfo->objectId = linkObjectId; - Object_Spawn(&play->objectCtx, linkObjectId); + Object_SpawnPersistent(&play->objectCtx, linkObjectId); } void Scene_CommandActorEntryList(PlayState* play, SceneCmd* cmd) { @@ -226,8 +240,8 @@ void Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd) { void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd) { if (cmd->specialFiles.keepObjectId != OBJECT_INVALID) { - play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, cmd->specialFiles.keepObjectId); - gSegments[5] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); + play->objectCtx.subKeepSlot = Object_SpawnPersistent(&play->objectCtx, cmd->specialFiles.keepObjectId); + gSegments[5] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[play->objectCtx.subKeepSlot].segment); } if (cmd->specialFiles.naviQuestHintFileId != NAVI_QUEST_HINTS_NONE) { @@ -250,25 +264,27 @@ void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) { s32 i; s32 j; s32 k; - ObjectStatus* status; - ObjectStatus* status2; - ObjectStatus* firstStatus; - s16* objectEntry = SEGMENTED_TO_VIRTUAL(cmd->objectList.data); + ObjectEntry* entry; + ObjectEntry* invalidatedEntry; + ObjectEntry* entries; + s16* objectListEntry = SEGMENTED_TO_VIRTUAL(cmd->objectList.data); void* nextPtr; k = 0; - i = play->objectCtx.unk_09; - firstStatus = &play->objectCtx.status[0]; - status = &play->objectCtx.status[i]; + i = play->objectCtx.numPersistentEntries; + entries = play->objectCtx.slots; + entry = &play->objectCtx.slots[i]; - while (i < play->objectCtx.num) { - if (status->id != *objectEntry) { - status2 = &play->objectCtx.status[i]; - for (j = i; j < play->objectCtx.num; j++) { - status2->id = OBJECT_INVALID; - status2++; + while (i < play->objectCtx.numEntries) { + if (entry->id != *objectListEntry) { + + invalidatedEntry = &play->objectCtx.slots[i]; + for (j = i; j < play->objectCtx.numEntries; j++) { + invalidatedEntry->id = OBJECT_INVALID; + invalidatedEntry++; } - play->objectCtx.num = i; + + play->objectCtx.numEntries = i; Actor_KillAllWithMissingObject(play, &play->actorCtx); continue; @@ -276,24 +292,24 @@ void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) { i++; k++; - objectEntry++; - status++; + objectListEntry++; + entry++; } - ASSERT(cmd->objectList.length <= OBJECT_EXCHANGE_BANK_MAX, + ASSERT(cmd->objectList.length <= ARRAY_COUNT(play->objectCtx.slots), "scene_info->object_bank.num <= OBJECT_EXCHANGE_BANK_MAX", "../z_scene.c", 705); while (k < cmd->objectList.length) { - nextPtr = func_800982FC(&play->objectCtx, i, *objectEntry); - if (i < OBJECT_EXCHANGE_BANK_MAX - 1) { - firstStatus[i + 1].segment = nextPtr; + nextPtr = func_800982FC(&play->objectCtx, i, *objectListEntry); + if (i < (ARRAY_COUNT(play->objectCtx.slots) - 1)) { + entries[i + 1].segment = nextPtr; } i++; k++; - objectEntry++; + objectListEntry++; } - play->objectCtx.num = i; + play->objectCtx.numEntries = i; } void Scene_CommandLightList(PlayState* play, SceneCmd* cmd) { diff --git a/src/code/z_view.c b/src/code/z_view.c index 27d05ce30..25faa9f4d 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -543,8 +543,8 @@ s32 View_UpdateViewingMatrix(View* view) { return 1; } -s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp) { - Gfx* gfx = *gfxp; +s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxP) { + Gfx* gfx = *gfxP; GraphicsContext* gfxCtx = view->gfxCtx; s32 width; s32 height; @@ -610,7 +610,7 @@ s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp) { } view->flags = 0; - *gfxp = gfx; + *gfxP = gfx; return 1; } diff --git a/src/code/z_viscvg.c b/src/code/z_viscvg.c new file mode 100644 index 000000000..9caf39a3f --- /dev/null +++ b/src/code/z_viscvg.c @@ -0,0 +1,145 @@ +/** + * @file z_viscvg.c + * + * This file implements full-screen frame buffer effects involving the visualization of Coverage in various ways. + * + * Coverage is roughly how much of a pixel is covered by a primitive; the final coverage for a frame is stored in the + * color image alpha component where it is used for antialiasing, see PreRender.c and §15 of the programming manual for + * details. + * + * To understand this file, it is helpful to remember that A_MEM is essentially synonymous with coverage, and that + * `GBL_c1/2(p, a, m, b)` usually represents the RDP blender calculation `(p * a + m * b)`. + * Note the division step that is often included in the blender calculation is omitted; the division is skipped if + * force blending (FORCE_BL) is set, which is the case for all render modes used in this file. + * + * Coverage is full when not on an edge, while on an edge it is usually lower. Since coverage is treated as an alpha + * value, edges of primitives where coverage is lower will show up darker than primitive interiors in all of the + * available modes. + * + * Coverage is abbreviated to "cvg"; "FB RGB" ("framebuffer red/green/blue") is the color the pixel originally had + * before the filter is applied. + */ + +#include "global.h" + +/** + * Draws only coverage: does not retain any of the original pixel RGB, primColor is used as background color. + */ +Gfx sCoverageOnlyDL[] = { + gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | G_RM_VISCVG | G_RM_VISCVG2), + // (blendColor RGB) * (cvg) + gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), + gsDPPipeSync(), + gsDPSetBlendColor(0, 0, 0, 8), + gsSPEndDisplayList(), +}; + +/** + * Draws fog + coverage * RGB of pixels + * + * @bug This easily overflows the blender because the fog value is added to the coverage value. + */ +Gfx sCoverageRGBFogDL[] = { + gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL | + GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM) | + GBL_c2(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM)), + // (fog RGB) * (fog alpha) + (FB RGB) * (cvg) + gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), + gsSPEndDisplayList(), +}; + +/** + * Draws coverage and RGB of pixels + */ +Gfx sCoverageRGBDL[] = { + gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL | + GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) | + GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)), + // (FB RGB) * (cvg) + gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), + gsSPEndDisplayList(), +}; + +/** + * Two stage filtering: + * + * 1. Apply a uniform color filter by transparently blending primColor with original frame. The "cloud surface" + * RenderMode is used to preserve the coverage for the second stage. + * 2. Second half is the same as `sCoverageRGBDL`'s, i.e. (RGB from stage 1) * cvg + */ +Gfx sCoverageRGBUniformDL[] = { + gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE), + gsDPSetOtherMode(G_AD_NOTPATTERN | G_CD_DISABLE | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2), + // stage 1 color = (primColor RGB) * (primColor Alpha) + (FB RGB) * (1 - primColor Alpha) + gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), + + gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL | + GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) | + GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)), + // final color = (stage 1 RGB) * (cvg) + gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), + gsSPEndDisplayList(), +}; + +void VisCvg_Init(VisCvg* this) { + this->vis.type = FB_FILTER_NONE; + this->vis.scissorType = VIS_NO_SETSCISSOR; + this->vis.primColor.r = 255; + this->vis.primColor.g = 255; + this->vis.primColor.b = 255; + this->vis.primColor.a = 255; +} + +void VisCvg_Destroy(VisCvg* this) { +} + +void VisCvg_Draw(VisCvg* this, Gfx** gfxP) { + Gfx* gfx = *gfxP; + + gDPPipeSync(gfx++); + gDPSetPrimDepth(gfx++, 0xFFFF, 0xFFFF); + + if (this->vis.scissorType == VIS_SETSCISSOR) { + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } + + switch (this->vis.type) { + case FB_FILTER_CVG_RGB: + gSPDisplayList(gfx++, sCoverageRGBDL); + break; + + case FB_FILTER_CVG_RGB_UNIFORM: + // Set primitive color for uniform color filter in custom RenderMode + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->vis.primColor.rgba); + gSPDisplayList(gfx++, sCoverageRGBUniformDL); + break; + + case FB_FILTER_CVG_ONLY: + // Set background color for G_RM_VISCVG + gDPSetColor(gfx++, G_SETBLENDCOLOR, this->vis.primColor.rgba); + gSPDisplayList(gfx++, sCoverageOnlyDL); + break; + + case FB_FILTER_CVG_RGB_FOG: + // Set fog color for custom RenderMode, needs to be close to 0 to not overflow + gDPSetColor(gfx++, G_SETFOGCOLOR, this->vis.primColor.rgba); + gSPDisplayList(gfx++, sCoverageRGBFogDL); + break; + + default: + break; + } + + gDPPipeSync(gfx++); + *gfxP = gfx; +} diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c index de065988e..8f0a5653f 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.c @@ -1,13 +1,19 @@ /** - * Color frame buffer effect to desaturate the colors. + * @file z_vismono.c + * + * This file implements a full-screen framebuffer effect for desaturating the contents of the framebuffer image. + * + * Broadly, this effect is achieved by reinterpreting the contents of the RGBA16 color image as indices into an IA16 + * color palette that converts each color into the desaturated equivalent. More precise details can be found in inline + * comments. */ #include "global.h" // Height of the fragments the color frame buffer (CFB) is split into. // It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into -// the half of tmem (0x800 bytes) dedicated to color-indexed data. -#define VISMONO_CFBFRAG_HEIGHT (0x800 / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES)) +// the half of TMEM dedicated to color-indexed data. +#define VISMONO_CFBFRAG_HEIGHT ((TMEM_SIZE / 2) / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES)) // Maximum size of the dlist written by `VisMono_DesaturateDList`. // `VisMono_DesaturateDList` consistently uses `VISMONO_DLSIZE - 2` double words, so this can be 2 less. @@ -26,16 +32,16 @@ extern u16 D_0F000000[]; void VisMono_Init(VisMono* this) { bzero(this, sizeof(VisMono)); - this->unk_00 = 0; - this->setScissor = false; - this->primColor.r = 255; - this->primColor.g = 255; - this->primColor.b = 255; - this->primColor.a = 255; - this->envColor.r = 0; - this->envColor.g = 0; - this->envColor.b = 0; - this->envColor.a = 0; + this->vis.type = 0; + this->vis.scissorType = VIS_NO_SETSCISSOR; + this->vis.primColor.r = 255; + this->vis.primColor.g = 255; + this->vis.primColor.b = 255; + this->vis.primColor.a = 255; + this->vis.envColor.r = 0; + this->vis.envColor.g = 0; + this->vis.envColor.b = 0; + this->vis.envColor.a = 0; } void VisMono_Destroy(VisMono* this) { @@ -95,6 +101,8 @@ Gfx* VisMono_DesaturateDList(VisMono* this, Gfx* gfx) { // Set texel 1 to be a CI8 image with width `SCREEN_WIDTH * 2` and height `VISMONO_CFBFRAG_HEIGHT` // Its position in texture image space is shifted along +S by 1 + // Note the palette index for this tile has also been incremented from 0 to 1, however the palette index is + // ignored for CI8 texture sampling. gDPSetTile(gfx++, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2 * G_IM_SIZ_8b_LINE_BYTES / 8, 0x0, 1, 1, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0); gDPSetTileSize(gfx++, 1, 1 << 2, 0, (SCREEN_WIDTH * 2) << 2, (VISMONO_CFBFRAG_HEIGHT - 1) << 2); @@ -129,8 +137,8 @@ Gfx* VisMono_DesaturateDList(VisMono* this, Gfx* gfx) { return gfx; } -void VisMono_Draw(VisMono* this, Gfx** gfxp) { - Gfx* gfx = *gfxp; +void VisMono_Draw(VisMono* this, Gfx** gfxP) { + Gfx* gfx = *gfxP; u16* tlut; Gfx* dList; Gfx* dListEnd; @@ -159,12 +167,12 @@ void VisMono_Draw(VisMono* this, Gfx** gfxp) { gDPPipeSync(gfx++); - if (this->setScissor == true) { + if (this->vis.scissorType == VIS_SETSCISSOR) { gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } - gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba); - gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba); + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->vis.primColor.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, this->vis.envColor.rgba); gDPLoadTLUT_pal256(gfx++, tlut); @@ -172,7 +180,7 @@ void VisMono_Draw(VisMono* this, Gfx** gfxp) { gDPPipeSync(gfx++); - *gfxp = gfx; + *gfxP = gfx; } void VisMono_DrawOld(VisMono* this) { diff --git a/src/code/z_viszbuf.c b/src/code/z_viszbuf.c new file mode 100644 index 000000000..90080b79c --- /dev/null +++ b/src/code/z_viszbuf.c @@ -0,0 +1,111 @@ +/** + * @file z_viszbuf.c + * + * This file implements a full-screen framebuffer effect for visualizing the z-buffer (AKA depth buffer), using either + * cycling RGBA or a single fading color. + * + * This is done by reading the z-buffer as if it were a color image, the format of which is specified by the selected + * vis type: + * - VIS_ZBUF_TYPE_IA : Produces a monotonic fade from primColor to envColor as depth increases. + * - VIS_ZBUF_TYPE_RGBA : Produces vibrant almost-periodic-looking bands. + * + * In both cases this occurs because of the format the depth information takes: it is 18-bit, and is a nonnegative + * floating-point number with + * bbb mmmmmmmmmmm dd|dd + * exponent mantissa dz value (only first 16 bits visible to CPU, the least significant 2 bits of dz are ignored) + * + * Reading z-buffer as IA16: + * bbbmmmmm mmmmmmdd + * iiiiiiii aaaaaaaa + * + * Since floating-point numbers of this format have the same ordering as their binary/hex representation, increasing + * the depth also increases the intensity in the IA16 representation and hence the interpolation parameter used to + * combine primColor and envColor. The alpha is ignored by the RenderMode. + * + * Reading z-buffer as RGBA16: + * bbbmm mmmmm mmmmd d + * rrrrr ggggg bbbbb a + * + * The red increases monotonically with the depth. The significant visible oscillation is the green component, because + * it rolls over every time the second-most-significant bit of the mantissa increments. The blue component oscillates + * too rapidly to be particularly visible (it rolls over when the 7th-most-significant bit increments). The alpha is + * again ignored by the RenderMode. + */ + +#include "global.h" + +// Height of the fragments the z-buffer is split into. +// It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into TMEM. +#define VISZBUF_ZBUFFRAG_HEIGHT (TMEM_SIZE / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES)) + +// z-buffer +extern u16 D_0E000000[]; + +/** + * Initialise to IA type with white and black as default colors. + */ +void VisZBuf_Init(VisZBuf* this) { + this->vis.type = VIS_ZBUF_TYPE_IA; + this->vis.scissorType = VIS_NO_SETSCISSOR; + this->vis.primColor.r = 255; + this->vis.primColor.g = 255; + this->vis.primColor.b = 255; + this->vis.primColor.a = 255; + this->vis.envColor.a = 255; + this->vis.envColor.r = 0; + this->vis.envColor.g = 0; + this->vis.envColor.b = 0; +} + +void VisZBuf_Destroy(VisZBuf* this) { +} + +void VisZBuf_Draw(VisZBuf* this, Gfx** gfxP) { + Gfx* gfx = *gfxP; + u16* zbufFrag = D_0E000000; + s32 fmt; + s32 y; + s32 height; + + if (this->vis.type == VIS_ZBUF_TYPE_IA) { + fmt = G_IM_FMT_IA; + } else { // VIS_ZBUF_TYPE_RGBA + fmt = G_IM_FMT_RGBA; + } + + height = VISZBUF_ZBUFFRAG_HEIGHT; + + gDPPipeSync(gfx++); + // Scissoring is only required if the scissor has not been set prior. + if (this->vis.scissorType == VIS_SETSCISSOR) { + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } + + // No palette so can use all of TMEM. + // G_RM_OPA_SURF discards all information previously in the pixel, and the current alpha, leaving only the color + // from this filter. + gDPSetOtherMode(gfx++, + G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | G_RM_OPA_SURF | G_RM_OPA_SURF2); + + // LERP between primColor and envColor in 1-cycle mode using the z-buffer value. + gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT); + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->vis.primColor.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, this->vis.envColor.rgba); + + for (y = 0; y <= SCREEN_HEIGHT - height; y += height) { + // Load a few lines of the z-buffer, as many as can fit in TMEM at once. + gDPLoadTextureBlock(gfx++, zbufFrag, fmt, G_IM_SIZ_16b, SCREEN_WIDTH, height, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + // Overwrite them with the calculated colors. + gSPTextureRectangle(gfx++, 0, y << 2, SCREEN_WIDTH << 2, (y + height) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); + zbufFrag += SCREEN_WIDTH * height; + } + + gDPPipeSync(gfx++); + *gfxP = gfx; +} diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index a829d2d24..2312fd272 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -103,10 +103,10 @@ void BgBreakwall_Init(Actor* thisx, PlayState* play) { this->dyna.actor.world.pos.y -= 40.0f; } - this->bankIndex = (wallType >= BWALL_KD_FLOOR) ? Object_GetIndex(&play->objectCtx, OBJECT_KINGDODONGO) - : Object_GetIndex(&play->objectCtx, OBJECT_BWALL); + this->requiredObjectSlot = (wallType >= BWALL_KD_FLOOR) ? Object_GetSlot(&play->objectCtx, OBJECT_KINGDODONGO) + : Object_GetSlot(&play->objectCtx, OBJECT_BWALL); - if (this->bankIndex < 0) { + if (this->requiredObjectSlot < 0) { Actor_Kill(&this->dyna.actor); } else { BgBreakwall_SetupAction(this, BgBreakwall_WaitForObject); @@ -201,11 +201,11 @@ Actor* BgBreakwall_SpawnFragments(PlayState* play, BgBreakwall* this, Vec3f* pos * Sets up the collision model as well is the object dependency and action function to use. */ void BgBreakwall_WaitForObject(BgBreakwall* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { CollisionHeader* colHeader = NULL; s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF; - this->dyna.actor.objBankIndex = this->bankIndex; + this->dyna.actor.objectSlot = this->requiredObjectSlot; Actor_SetObjectDependency(play, &this->dyna.actor); this->dyna.actor.flags &= ~ACTOR_FLAG_4; this->dyna.actor.draw = BgBreakwall_Draw; diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h index 022a439f2..6880026c2 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h @@ -12,7 +12,7 @@ typedef struct BgBreakwall { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ Gfx* bombableWallDList; /* 0x0168 */ s8 colType; - /* 0x0169 */ s8 bankIndex; + /* 0x0169 */ s8 requiredObjectSlot; /* 0x016C */ ColliderQuad collider; /* 0x01EC */ BgBreakwallActionFunc actionFunc; } BgBreakwall; // size = 0x01F0 diff --git a/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c b/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c index 0b6152497..6cdba3e07 100644 --- a/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c +++ b/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c @@ -60,7 +60,7 @@ void func_8087B758(BgHaka* this, Player* player) { func_8002DBD0(&this->dyna.actor, &sp1C, &player->actor.world.pos); if (fabsf(sp1C.x) < 34.6f && sp1C.z > -112.8f && sp1C.z < -36.0f) { - player->stateFlags2 |= PLAYER_STATE2_9; + player->stateFlags2 |= PLAYER_STATE2_FORCE_SAND_FLOOR_SOUND; } } diff --git a/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c b/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c index 2c1b5ca9b..e734780de 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c +++ b/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c @@ -66,12 +66,12 @@ void BgHakaMegane_Init(Actor* thisx, PlayState* play) { DynaPolyActor_Init(&this->dyna, 0); if (thisx->params < 3) { - this->objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_HAKACH_OBJECTS); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_HAKACH_OBJECTS); } else { - this->objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_HAKA_OBJECTS); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_HAKA_OBJECTS); } - if (this->objBankIndex < 0) { + if (this->requiredObjectSlot < 0) { Actor_Kill(thisx); } else { this->actionFunc = func_8087DB24; @@ -88,8 +88,8 @@ void func_8087DB24(BgHakaMegane* this, PlayState* play) { CollisionHeader* colHeader; CollisionHeader* collision; - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { - this->dyna.actor.objBankIndex = this->objBankIndex; + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->dyna.actor.objectSlot = this->requiredObjectSlot; this->dyna.actor.draw = BgHakaMegane_Draw; Actor_SetObjectDependency(play, &this->dyna.actor); if (play->roomCtx.curRoom.lensMode != LENS_MODE_HIDE_ACTORS) { diff --git a/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.h b/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.h index 9de05508f..e82c0a97c 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.h +++ b/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.h @@ -12,7 +12,7 @@ typedef struct BgHakaMegane { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgHakaMeganeActionFunc actionFunc; /* 0x0168 */ char unk_168[0x1]; - /* 0x0169 */ s8 objBankIndex; + /* 0x0169 */ s8 requiredObjectSlot; /* 0x016A */ char unk_16A[0x2]; } BgHakaMegane; // size = 0x016C diff --git a/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c b/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c index 9e76939f4..9dcf1f52c 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c +++ b/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c @@ -169,16 +169,16 @@ void BgHakaSgami_Init(Actor* thisx, PlayState* play) { Effect_Add(play, &this->blureEffectIndex[1], EFFECT_BLURE1, 0, 0, &blureInit); if (thisx->params == SCYTHE_TRAP_SHADOW_TEMPLE) { - this->requiredObjBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_HAKA_OBJECTS); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_HAKA_OBJECTS); thisx->flags &= ~ACTOR_FLAG_0; } else { - this->requiredObjBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_ICE_OBJECTS); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_ICE_OBJECTS); this->colliderScytheCenter.dim.radius = 30; this->colliderScytheCenter.dim.height = 70; Actor_SetFocus(thisx, 40.0f); } - if (this->requiredObjBankIndex < 0) { + if (this->requiredObjectSlot < 0) { Actor_Kill(thisx); return; } @@ -196,8 +196,8 @@ void BgHakaSgami_Destroy(Actor* thisx, PlayState* play) { } void BgHakaSgami_SetupSpin(BgHakaSgami* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex)) { - this->actor.objBankIndex = this->requiredObjBankIndex; + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->actor.objectSlot = this->requiredObjectSlot; this->actor.draw = BgHakaSgami_Draw; this->timer = SCYTHE_SPIN_TIME; this->actor.flags &= ~ACTOR_FLAG_4; diff --git a/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.h b/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.h index 6f140a39c..d13418053 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.h +++ b/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.h @@ -11,7 +11,7 @@ typedef void (*BgHakaSgamiActionFunc)(struct BgHakaSgami*, PlayState*); typedef struct BgHakaSgami { /* 0x0000 */ Actor actor; /* 0x014C */ BgHakaSgamiActionFunc actionFunc; - /* 0x0150 */ s8 requiredObjBankIndex; + /* 0x0150 */ s8 requiredObjectSlot; /* 0x0151 */ s8 unk_151; /* 0x0152 */ s16 timer; /* 0x0154 */ s32 blureEffectIndex[2]; diff --git a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c index 4286c35b3..bccdea961 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c +++ b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c @@ -102,11 +102,11 @@ void BgHakaZou_Init(Actor* thisx, PlayState* play) { } } - this->requiredObjBankIndex = (thisx->params == STA_BOMBABLE_RUBBLE) - ? Object_GetIndex(&play->objectCtx, OBJECT_HAKACH_OBJECTS) - : Object_GetIndex(&play->objectCtx, OBJECT_HAKA_OBJECTS); + this->requiredObjectSlot = (thisx->params == STA_BOMBABLE_RUBBLE) + ? Object_GetSlot(&play->objectCtx, OBJECT_HAKACH_OBJECTS) + : Object_GetSlot(&play->objectCtx, OBJECT_HAKA_OBJECTS); - if (this->requiredObjBankIndex < 0) { + if (this->requiredObjectSlot < 0) { Actor_Kill(thisx); } else if ((thisx->params != STA_UNKNOWN) && Flags_GetSwitch(play, this->switchFlag)) { if (thisx->params != STA_GIANT_BIRD_STATUE) { @@ -158,8 +158,8 @@ void func_808828F4(BgHakaZou* this, PlayState* play) { void BgHakaZou_Wait(BgHakaZou* this, PlayState* play) { CollisionHeader* colHeader; - if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex)) { - this->dyna.actor.objBankIndex = this->requiredObjBankIndex; + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->dyna.actor.objectSlot = this->requiredObjectSlot; this->dyna.actor.draw = BgHakaZou_Draw; if (this->dyna.actor.params == STA_UNKNOWN) { diff --git a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.h b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.h index b5fe2a2fd..6eb5ddcae 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.h +++ b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.h @@ -11,7 +11,7 @@ typedef void (*BgHakaZouActionFunc)(struct BgHakaZou*, PlayState*); typedef struct BgHakaZou { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgHakaZouActionFunc actionFunc; - /* 0x0168 */ s8 requiredObjBankIndex; + /* 0x0168 */ s8 requiredObjectSlot; /* 0x0169 */ u8 switchFlag; /* 0x016A */ s16 timer; /* 0x016C */ ColliderCylinder collider; diff --git a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c index d54743a75..18155a913 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c +++ b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c @@ -117,8 +117,8 @@ void BgJyaBigmirror_SetBombiwaFlag(Actor* thisx, PlayState* play) { } void BgJyaBigmirror_HandleMirRay(Actor* thisx, PlayState* play) { - static s16 sMirRayParamss[] = { 0x0005, 0x0007, 0x0008 }; - static Vec3f sMirRayPoss[] = { + static s16 sMirRayParamsVals[] = { 0x0005, 0x0007, 0x0008 }; + static Vec3f sMirRayPositions[] = { { 60.0f, 1802.0f, -1102.0f }, { -560.0f, 1800.0f, -310.0f }, { 60.0f, 1800.0f, -310.0f }, @@ -127,11 +127,11 @@ void BgJyaBigmirror_HandleMirRay(Actor* thisx, PlayState* play) { s32 puzzleSolved; s32 lightBeamToggles[3]; s32 i; - s32 objBankIndex; + s32 mirRayObjectSlot; - objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_MIR_RAY); + mirRayObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MIR_RAY); - if ((objBankIndex < 0) || (objBankIndex != this->mirRayObjIndex)) { + if ((mirRayObjectSlot < 0) || (mirRayObjectSlot != this->mirRayObjectSlot)) { this->lightBeams[2] = NULL; this->lightBeams[1] = NULL; this->lightBeams[0] = NULL; @@ -152,9 +152,11 @@ void BgJyaBigmirror_HandleMirRay(Actor* thisx, PlayState* play) { for (i = 0; i < 3; i++) { if (lightBeamToggles[i]) { - if ((this->lightBeams[i] == NULL) && Object_IsLoaded(&play->objectCtx, objBankIndex)) { - this->lightBeams[i] = Actor_Spawn(&play->actorCtx, play, ACTOR_MIR_RAY, sMirRayPoss[i].x, - sMirRayPoss[i].y, sMirRayPoss[i].z, 0, 0, 0, sMirRayParamss[i]); + if ((this->lightBeams[i] == NULL) && Object_IsLoaded(&play->objectCtx, mirRayObjectSlot)) { + + this->lightBeams[i] = + Actor_Spawn(&play->actorCtx, play, ACTOR_MIR_RAY, sMirRayPositions[i].x, sMirRayPositions[i].y, + sMirRayPositions[i].z, 0, 0, 0, sMirRayParamsVals[i]); if (this->lightBeams[i] == NULL) { // "Mir Ray generation failed" @@ -169,7 +171,7 @@ void BgJyaBigmirror_HandleMirRay(Actor* thisx, PlayState* play) { } } } - this->mirRayObjIndex = objBankIndex; + this->mirRayObjectSlot = mirRayObjectSlot; } void BgJyaBigmirror_Init(Actor* thisx, PlayState* play) { @@ -186,7 +188,7 @@ void BgJyaBigmirror_Init(Actor* thisx, PlayState* play) { this->actor.room = -1; sIsSpawned = true; this->spawned = true; - this->mirRayObjIndex = -1; + this->mirRayObjectSlot = -1; // "jya Bigmirror" osSyncPrintf("(jya 大鏡)(arg_data 0x%04x)\n", this->actor.params); diff --git a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.h b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.h index 298d95692..90647a7a8 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.h +++ b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.h @@ -25,7 +25,7 @@ typedef struct BgJyaBigmirror { /* 0x015C */ u8 puzzleFlags; /* 0x015D */ u8 spawned; /* 0x0160 */ Actor* lightBeams[3]; - /* 0x016C */ s32 mirRayObjIndex; + /* 0x016C */ s32 mirRayObjectSlot; /* 0x0170 */ f32 liftHeight; } BgJyaBigmirror; // size = 0x0174 diff --git a/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.c b/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.c index 377d6007e..bea420dc0 100644 --- a/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.c +++ b/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.c @@ -45,7 +45,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), }; -static s16 sObjectIDs[] = { OBJECT_MJIN_FLASH, OBJECT_MJIN_DARK, OBJECT_MJIN_FLAME, +static s16 sObjectIds[] = { OBJECT_MJIN_FLASH, OBJECT_MJIN_DARK, OBJECT_MJIN_FLAME, OBJECT_MJIN_ICE, OBJECT_MJIN_SOUL, OBJECT_MJIN_WIND }; void BgMjin_SetupAction(BgMjin* this, BgMjinActionFunc actionFunc) { @@ -54,12 +54,12 @@ void BgMjin_SetupAction(BgMjin* this, BgMjinActionFunc actionFunc) { void BgMjin_Init(Actor* thisx, PlayState* play) { BgMjin* this = (BgMjin*)thisx; - s8 objBankIndex; + s8 objectSlot; Actor_ProcessInitChain(thisx, sInitChain); - objBankIndex = Object_GetIndex(&play->objectCtx, (thisx->params != 0 ? OBJECT_MJIN : OBJECT_MJIN_OKA)); - this->objBankIndex = objBankIndex; - if (objBankIndex < 0) { + objectSlot = Object_GetSlot(&play->objectCtx, (thisx->params != 0 ? OBJECT_MJIN : OBJECT_MJIN_OKA)); + this->requiredObjectSlot = objectSlot; + if (objectSlot < 0) { Actor_Kill(thisx); } else { BgMjin_SetupAction(this, func_808A0850); @@ -76,10 +76,10 @@ void func_808A0850(BgMjin* this, PlayState* play) { CollisionHeader* colHeader; CollisionHeader* collision; - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { colHeader = NULL; this->dyna.actor.flags &= ~ACTOR_FLAG_4; - this->dyna.actor.objBankIndex = this->objBankIndex; + this->dyna.actor.objectSlot = this->requiredObjectSlot; Actor_SetObjectDependency(play, &this->dyna.actor); DynaPolyActor_Init(&this->dyna, 0); collision = this->dyna.actor.params != 0 ? &gWarpPadCol : &gOcarinaWarpPadCol; @@ -106,10 +106,10 @@ void BgMjin_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); if (thisx->params != 0) { - s32 objBankIndex = Object_GetIndex(&play->objectCtx, sObjectIDs[thisx->params - 1]); + s32 objectSlot = Object_GetSlot(&play->objectCtx, sObjectIds[thisx->params - 1]); - if (objBankIndex >= 0) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objBankIndex].segment); + if (objectSlot >= 0) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); } gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(&D_06000000)); diff --git a/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.h b/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.h index 415625574..03e18fbb7 100644 --- a/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.h +++ b/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.h @@ -10,7 +10,7 @@ typedef void (*BgMjinActionFunc)(struct BgMjin*, PlayState*); typedef struct BgMjin { /* 0x0000 */ DynaPolyActor dyna; - /* 0x0164 */ s8 objBankIndex; + /* 0x0164 */ s8 requiredObjectSlot; /* 0x0168 */ BgMjinActionFunc actionFunc; } BgMjin; // size = 0x016C diff --git a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c index c6bd7b641..f92026b92 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c +++ b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c @@ -77,8 +77,8 @@ void BgMoriBigst_Init(Actor* thisx, PlayState* play) { GET_PLAYER(play)->actor.world.pos.y); BgMoriBigst_InitDynapoly(this, play, &gMoriBigstCol, 0); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->moriTexObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { + this->moriTexObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_TEX); + if (this->moriTexObjectSlot < 0) { // "【Big Stalfos key ceiling】 bank danger!" osSyncPrintf("【ビッグスタルフォス鍵型天井】 バンク危険!\n"); osSyncPrintf("%s %d\n", "../z_bg_mori_bigst.c", 234); @@ -108,7 +108,7 @@ void BgMoriBigst_SetupWaitForMoriTex(BgMoriBigst* this, PlayState* play) { void BgMoriBigst_WaitForMoriTex(BgMoriBigst* this, PlayState* play) { Actor* thisx = &this->dyna.actor; - if (Object_IsLoaded(&play->objectCtx, this->moriTexObjIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->moriTexObjectSlot)) { thisx->draw = BgMoriBigst_Draw; if (Flags_GetClear(play, thisx->room) && (GET_PLAYER(play)->actor.world.pos.y > 700.0f)) { if (Flags_GetSwitch(play, (thisx->params >> 8) & 0x3F)) { @@ -248,7 +248,7 @@ void BgMoriBigst_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.status[this->moriTexObjIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.slots[this->moriTexObjectSlot].segment); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_bg_mori_bigst.c", 548), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.h b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.h index c2a97444e..c71eac7ab 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.h +++ b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.h @@ -12,7 +12,7 @@ typedef struct BgMoriBigst { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgMoriBigstActionFunc actionFunc; /* 0x0168 */ s16 waitTimer; - /* 0x016A */ s8 moriTexObjIndex; + /* 0x016A */ s8 moriTexObjectSlot; } BgMoriBigst; // size = 0x016C #endif diff --git a/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c b/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c index f2ece3bd1..3c9a45143 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c +++ b/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c @@ -87,8 +87,8 @@ void BgMoriElevator_Init(Actor* thisx, PlayState* play) { CollisionHeader* colHeader = NULL; this->unk_172 = sIsSpawned; - this->moriTexObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { + this->moriTexObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_TEX); + if (this->moriTexObjectSlot < 0) { Actor_Kill(thisx); // "Forest Temple obj elevator Bank Danger!" osSyncPrintf("Error : 森の神殿 obj elevator バンク危険!(%s %d)\n", "../z_bg_mori_elevator.c", 277); @@ -134,7 +134,7 @@ void BgMoriElevator_SetupWaitAfterInit(BgMoriElevator* this) { } void BgMoriElevator_WaitAfterInit(BgMoriElevator* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->moriTexObjIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->moriTexObjectSlot)) { if (Flags_GetSwitch(play, this->dyna.actor.params & 0x3F)) { if (play->roomCtx.curRoom.num == 2) { this->dyna.actor.world.pos.y = 73.0f; @@ -255,7 +255,7 @@ void BgMoriElevator_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.status[this->moriTexObjIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.slots[this->moriTexObjectSlot].segment); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_bg_mori_elevator.c", 580), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gMoriElevatorDL); diff --git a/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.h b/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.h index a981c71dd..e7bcc5018 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.h +++ b/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.h @@ -14,7 +14,7 @@ typedef struct BgMoriElevator { /* 0x0168 */ f32 targetY; /* 0x016C */ s32 unk_16C; /* 0x0170 */ u8 unk_170; - /* 0x0171 */ s8 moriTexObjIndex; + /* 0x0171 */ s8 moriTexObjectSlot; /* 0x0172 */ s16 unk_172; } BgMoriElevator; // size = 0x0174 diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c b/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c index c1a624d3d..8624f1239 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c +++ b/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c @@ -164,8 +164,8 @@ void BgMoriHashigo_Init(Actor* thisx, PlayState* play) { return; } } - this->moriTexObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { + this->moriTexObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_TEX); + if (this->moriTexObjectSlot < 0) { // "Bank danger!" osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", this->dyna.actor.params, "../z_bg_mori_hashigo.c", 312); @@ -194,7 +194,7 @@ void BgMoriHashigo_SetupWaitForMoriTex(BgMoriHashigo* this) { } void BgMoriHashigo_WaitForMoriTex(BgMoriHashigo* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->moriTexObjIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->moriTexObjectSlot)) { if (this->dyna.actor.params == HASHIGO_CLASP) { BgMoriHashigo_SetupClasp(this); } else if (this->dyna.actor.params == HASHIGO_LADDER) { @@ -285,7 +285,7 @@ void BgMoriHashigo_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx); if (1) {} - gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.status[this->moriTexObjIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.slots[this->moriTexObjectSlot].segment); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_bg_mori_hashigo.c", 521), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.h b/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.h index fc5d99cc3..5e957f403 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.h +++ b/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.h @@ -15,7 +15,7 @@ typedef struct BgMoriHashigo { /* 0x01C4 */ BgMoriHashigoActionFunc actionFunc; /* 0x01C8 */ s16 hitTimer; /* 0x01CA */ s16 bounceCounter; - /* 0x01CC */ s8 moriTexObjIndex; + /* 0x01CC */ s8 moriTexObjectSlot; } BgMoriHashigo; // size = 0x01D0 typedef enum { diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c b/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c index 2d39d2306..173c67777 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c +++ b/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c @@ -78,8 +78,8 @@ void BgMoriHashira4_Init(Actor* thisx, PlayState* play) { BgMoriHashira4_InitDynaPoly(this, play, &gMoriHashira2Col, 0); } Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->moriTexObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { + this->moriTexObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_TEX); + if (this->moriTexObjectSlot < 0) { Actor_Kill(&this->dyna.actor); // "Bank danger!" osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", this->dyna.actor.params, @@ -109,7 +109,7 @@ void BgMoriHashira4_SetupWaitForMoriTex(BgMoriHashira4* this) { } void BgMoriHashira4_WaitForMoriTex(BgMoriHashira4* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->moriTexObjIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->moriTexObjectSlot)) { this->gateTimer = 0; if (this->dyna.actor.params == 0) { BgMoriHashira4_SetupPillarsRotate(this); @@ -163,7 +163,7 @@ void BgMoriHashira4_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.status[this->moriTexObjIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.slots[this->moriTexObjectSlot].segment); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_bg_mori_hashira4.c", 344), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.h b/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.h index 797688bdb..a36a6ef36 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.h +++ b/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.h @@ -11,7 +11,7 @@ typedef void (*BgMoriHashira4ActionFunc)(struct BgMoriHashira4*, PlayState*); typedef struct BgMoriHashira4 { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgMoriHashira4ActionFunc actionFunc; - /* 0x0168 */ s8 moriTexObjIndex; + /* 0x0168 */ s8 moriTexObjectSlot; /* 0x0169 */ s8 switchFlag; /* 0x016A */ s16 gateTimer; } BgMoriHashira4; // size = 0x016C diff --git a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c index bd14f2a4e..1fc6e7c3f 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c +++ b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c @@ -54,7 +54,7 @@ static Gfx* sDLists[] = { void BgMoriHineri_Init(Actor* thisx, PlayState* play) { BgMoriHineri* this = (BgMoriHineri*)thisx; - s8 moriHineriObjIdx; + s8 objectSlot; u32 switchFlagParam; s32 t6; @@ -78,26 +78,26 @@ void BgMoriHineri_Init(Actor* thisx, PlayState* play) { this->dyna.actor.params = 3; } } - this->boxObjIdx = -1; + this->boxObjectSlot = -1; if (this->dyna.actor.params == 0) { - this->moriHineriObjIdx = Object_GetIndex(&play->objectCtx, OBJECT_MORI_HINERI1); + this->moriHineriObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_HINERI1); if (t6 == 0) { - this->boxObjIdx = Object_GetIndex(&play->objectCtx, OBJECT_BOX); + this->boxObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_BOX); } } else { if (this->dyna.actor.params == 1) { - moriHineriObjIdx = Object_GetIndex(&play->objectCtx, OBJECT_MORI_HINERI1A); + objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_HINERI1A); } else { - moriHineriObjIdx = (this->dyna.actor.params == 2) ? Object_GetIndex(&play->objectCtx, OBJECT_MORI_HINERI2) - : Object_GetIndex(&play->objectCtx, OBJECT_MORI_HINERI2A); + objectSlot = (this->dyna.actor.params == 2) ? Object_GetSlot(&play->objectCtx, OBJECT_MORI_HINERI2) + : Object_GetSlot(&play->objectCtx, OBJECT_MORI_HINERI2A); } - this->moriHineriObjIdx = moriHineriObjIdx; + this->moriHineriObjectSlot = objectSlot; } - this->moriTexObjIdx = Object_GetIndex(&play->objectCtx, OBJECT_MORI_TEX); + this->moriTexObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_TEX); if (t6 != 0) { this->dyna.actor.params += 4; } - if ((this->moriHineriObjIdx < 0) || (this->moriTexObjIdx < 0)) { + if ((this->moriHineriObjectSlot < 0) || (this->moriTexObjectSlot < 0)) { Actor_Kill(&this->dyna.actor); } else { this->actionFunc = func_808A39FC; @@ -112,22 +112,22 @@ void BgMoriHineri_Destroy(Actor* thisx, PlayState* play) { void func_808A39FC(BgMoriHineri* this, PlayState* play) { CollisionHeader* colHeader; - if (Object_IsLoaded(&play->objectCtx, this->moriHineriObjIdx) && - Object_IsLoaded(&play->objectCtx, this->moriTexObjIdx) && - ((this->boxObjIdx < 0) || Object_IsLoaded(&play->objectCtx, this->boxObjIdx))) { - this->dyna.actor.objBankIndex = this->moriHineriObjIdx; + if (Object_IsLoaded(&play->objectCtx, this->moriHineriObjectSlot) && + Object_IsLoaded(&play->objectCtx, this->moriTexObjectSlot) && + ((this->boxObjectSlot < 0) || Object_IsLoaded(&play->objectCtx, this->boxObjectSlot))) { + this->dyna.actor.objectSlot = this->moriHineriObjectSlot; if (this->dyna.actor.params >= 4) { this->dyna.actor.params -= 4; if (this->dyna.actor.params == 0) { - this->moriHineriObjIdx = Object_GetIndex(&play->objectCtx, OBJECT_MORI_HINERI1A); + this->moriHineriObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_HINERI1A); } else if (this->dyna.actor.params == 1) { - this->moriHineriObjIdx = Object_GetIndex(&play->objectCtx, OBJECT_MORI_HINERI1); + this->moriHineriObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_HINERI1); } else { - this->moriHineriObjIdx = (this->dyna.actor.params == 2) - ? Object_GetIndex(&play->objectCtx, OBJECT_MORI_HINERI2A) - : Object_GetIndex(&play->objectCtx, OBJECT_MORI_HINERI2); + this->moriHineriObjectSlot = (this->dyna.actor.params == 2) + ? Object_GetSlot(&play->objectCtx, OBJECT_MORI_HINERI2A) + : Object_GetSlot(&play->objectCtx, OBJECT_MORI_HINERI2); } - if (this->moriHineriObjIdx < 0) { + if (this->moriHineriObjectSlot < 0) { Actor_Kill(&this->dyna.actor); } else { this->actionFunc = func_808A3D58; @@ -194,13 +194,13 @@ void func_808A3D58(BgMoriHineri* this, PlayState* play) { } void func_808A3E54(BgMoriHineri* this, PlayState* play) { - s8 objBankIndex; + s8 objectSlot; if (play->activeCamId == sSubCamId) { if (sSubCamId != SUB_CAM_ID_DONE) { - objBankIndex = this->dyna.actor.objBankIndex; - this->dyna.actor.objBankIndex = this->moriHineriObjIdx; - this->moriHineriObjIdx = objBankIndex; + objectSlot = this->dyna.actor.objectSlot; + this->dyna.actor.objectSlot = this->moriHineriObjectSlot; + this->moriHineriObjectSlot = objectSlot; this->dyna.actor.params ^= 1; sSubCamId = SUB_CAM_ID_DONE; Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR); @@ -223,17 +223,17 @@ void BgMoriHineri_Update(Actor* thisx, PlayState* play) { void BgMoriHineri_DrawHallAndRoom(Actor* thisx, PlayState* play) { BgMoriHineri* this = (BgMoriHineri*)thisx; - s8 objIndex; + s32 pad; MtxF mtx; OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.status[this->moriTexObjIdx].segment); + gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.slots[this->moriTexObjectSlot].segment); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_bg_mori_hineri.c", 618), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sDLists[this->dyna.actor.params]); - if (this->boxObjIdx > 0) { + if (this->boxObjectSlot > 0) { Matrix_Get(&mtx); } if ((this->actionFunc == func_808A3C8C) && (this->dyna.actor.shape.rot.z != 0)) { @@ -249,9 +249,9 @@ void BgMoriHineri_DrawHallAndRoom(Actor* thisx, PlayState* play) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gDungeonDoorDL); } - if ((this->boxObjIdx > 0) && ((this->boxObjIdx = Object_GetIndex(&play->objectCtx, OBJECT_BOX)) > 0) && - Object_IsLoaded(&play->objectCtx, this->boxObjIdx)) { - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->boxObjIdx].segment); + if ((this->boxObjectSlot > 0) && ((this->boxObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_BOX)) > 0) && + Object_IsLoaded(&play->objectCtx, this->boxObjectSlot)) { + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->boxObjectSlot].segment); gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); Matrix_Put(&mtx); Matrix_Translate(147.0f, -245.0f, -453.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.h b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.h index e42c23a43..8d4323e63 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.h +++ b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.h @@ -11,9 +11,9 @@ typedef void (*BgMoriHineriActionFunc)(struct BgMoriHineri*, PlayState*); typedef struct BgMoriHineri { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgMoriHineriActionFunc actionFunc; - /* 0x0168 */ s8 moriHineriObjIdx; - /* 0x0169 */ s8 moriTexObjIdx; - /* 0x016A */ s8 boxObjIdx; + /* 0x0168 */ s8 moriHineriObjectSlot; + /* 0x0169 */ s8 moriTexObjectSlot; + /* 0x016A */ s8 boxObjectSlot; /* 0x016B */ s8 switchFlag; } BgMoriHineri; // size = 0x016C diff --git a/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c b/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c index fe1157dcc..8ea9ae1a8 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c +++ b/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c @@ -66,8 +66,8 @@ void BgMoriIdomizu_Init(Actor* thisx, PlayState* play) { this->actor.world.pos.y = 184.0f; BgMoriIdomizu_SetWaterLevel(play, 184); } - this->moriTexObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { + this->moriTexObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_TEX); + if (this->moriTexObjectSlot < 0) { Actor_Kill(&this->actor); // "Bank danger!" osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", this->actor.params, "../z_bg_mori_idomizu.c", @@ -96,7 +96,7 @@ void BgMoriIdomizu_SetupWaitForMoriTex(BgMoriIdomizu* this) { } void BgMoriIdomizu_WaitForMoriTex(BgMoriIdomizu* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->moriTexObjIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->moriTexObjectSlot)) { BgMoriIdomizu_SetupMain(this); this->actor.draw = BgMoriIdomizu_Draw; } @@ -169,7 +169,7 @@ void BgMoriIdomizu_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_bg_mori_idomizu.c", 360), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, play->objectCtx.status[this->moriTexObjIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x08, play->objectCtx.slots[this->moriTexObjectSlot].segment); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 128); diff --git a/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.h b/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.h index d2e6f173a..3e7036ec4 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.h +++ b/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.h @@ -15,7 +15,7 @@ typedef struct BgMoriIdomizu { /* 0x0154 */ s32 prevSwitchFlagSet; /* 0x0158 */ s16 isLoaded; /* 0x015A */ s16 drainTimer; - /* 0x015C */ s8 moriTexObjIndex; + /* 0x015C */ s8 moriTexObjectSlot; } BgMoriIdomizu; // size = 0x0160 #endif diff --git a/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c b/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c index 5876eb500..4ffa4052a 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c +++ b/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c @@ -56,8 +56,8 @@ void BgMoriKaitenkabe_Init(Actor* thisx, PlayState* play) { DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&gMoriKaitenkabeCol, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - this->moriTexObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { + this->moriTexObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_TEX); + if (this->moriTexObjectSlot < 0) { Actor_Kill(&this->dyna.actor); // "【Rotating wall】 Bank danger!" osSyncPrintf("【回転壁】 バンク危険!(%s %d)\n", "../z_bg_mori_kaitenkabe.c", 176); @@ -74,7 +74,7 @@ void BgMoriKaitenkabe_Destroy(Actor* thisx, PlayState* play) { } void BgMoriKaitenkabe_WaitForMoriTex(BgMoriKaitenkabe* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->moriTexObjIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->moriTexObjectSlot)) { BgMoriKaitenkabe_SetupWait(this); this->dyna.actor.draw = BgMoriKaitenkabe_Draw; } @@ -163,7 +163,7 @@ void BgMoriKaitenkabe_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.status[this->moriTexObjIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.slots[this->moriTexObjectSlot].segment); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_bg_mori_kaitenkabe.c", 352), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.h b/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.h index 05272c6f2..7bd6939d3 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.h +++ b/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.h @@ -16,7 +16,7 @@ typedef struct BgMoriKaitenkabe { /* 0x0170 */ f32 rotSpeed; /* 0x0174 */ f32 rotYdeg; /* 0x0178 */ Vec3f lockedPlayerPos; - /* 0x0184 */ s8 moriTexObjIndex; + /* 0x0184 */ s8 moriTexObjectSlot; } BgMoriKaitenkabe; // size = 0x0188 #endif diff --git a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c index 863da4e8d..735904254 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c +++ b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c @@ -64,8 +64,8 @@ void BgMoriRakkatenjo_Init(Actor* thisx, PlayState* play) { // "The set Angle has changed. Let's fix the program." osSyncPrintf("Warning : セット Angle が変更されています。プログラムを修正しましょう。\n"); } - this->moriTexObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { + this->moriTexObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MORI_TEX); + if (this->moriTexObjectSlot < 0) { // "Forest Temple obj Falling Ceiling Bank Danger!" osSyncPrintf("Error : 森の神殿 obj 落下天井 バンク危険!(%s %d)\n", "../z_bg_mori_rakkatenjo.c", 205); Actor_Kill(&this->dyna.actor); @@ -102,7 +102,7 @@ void BgMoriRakkatenjo_SetupWaitForMoriTex(BgMoriRakkatenjo* this) { } void BgMoriRakkatenjo_WaitForMoriTex(BgMoriRakkatenjo* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->moriTexObjIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->moriTexObjectSlot)) { BgMoriRakkatenjo_SetupWait(this); this->dyna.actor.draw = BgMoriRakkatenjo_Draw; } @@ -226,7 +226,7 @@ void BgMoriRakkatenjo_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.status[this->moriTexObjIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x08, play->objectCtx.slots[this->moriTexObjectSlot].segment); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_bg_mori_rakkatenjo.c", 502), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.h b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.h index b263892f0..97bdbc0bf 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.h +++ b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.h @@ -14,7 +14,7 @@ typedef struct BgMoriRakkatenjo { /* 0x0168 */ s32 timer; /* 0x016C */ s32 bounceCount; /* 0x0170 */ s32 fallCount; - /* 0x0174 */ s8 moriTexObjIndex; + /* 0x0174 */ s8 moriTexObjectSlot; } BgMoriRakkatenjo; // size = 0x0178 #endif diff --git a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c index 4fec9780c..4b723b551 100644 --- a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c +++ b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c @@ -59,8 +59,8 @@ void BgSpot01Objects2_Init(Actor* thisx, PlayState* play) { } if (this->objectId >= 0) { - this->objBankIndex = Object_GetIndex(&play->objectCtx, this->objectId); - if (this->objBankIndex < 0) { + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, this->objectId); + if (this->requiredObjectSlot < 0) { // "There was no bank setting." osSyncPrintf("-----------------------------バンク設定ありませんでした."); Actor_Kill(&this->dyna.actor); @@ -91,12 +91,12 @@ void func_808AC2BC(BgSpot01Objects2* this, PlayState* play) { s32 pad; Vec3f position; - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { // "---- Successful bank switching!!" osSyncPrintf("-----バンク切り換え成功!!\n"); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->requiredObjectSlot].segment); - this->dyna.actor.objBankIndex = this->objBankIndex; + this->dyna.actor.objectSlot = this->requiredObjectSlot; DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); switch (this->dyna.actor.params & 7) { diff --git a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.h b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.h index 1da5f4f3f..d1d96d045 100644 --- a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.h +++ b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.h @@ -13,7 +13,7 @@ typedef struct BgSpot01Objects2 { /* 0x0164 */ BgSpot01Objects2ActionFunc actionFunc; /* 0x0168 */ char unk_168[0x10]; /* 0x0178 */ s32 objectId; - /* 0x017C */ s8 objBankIndex; + /* 0x017C */ s8 requiredObjectSlot; } BgSpot01Objects2; // size = 0x0180 #endif diff --git a/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c b/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c index 5a2661ec9..8244d04ed 100644 --- a/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c +++ b/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c @@ -218,9 +218,9 @@ s32 func_808B4E58(BgSpot16Bombstone* this, PlayState* play) { actor->shape.rot.z = D_808B5DD8[actor->params][9]; this->dList = object_bombiwa_DL_0009E0; - this->bombiwaBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_BOMBIWA); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_BOMBIWA); - if (this->bombiwaBankIndex < 0) { + if (this->requiredObjectSlot < 0) { osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", actor->params, "../z_bg_spot16_bombstone.c", 589); return false; @@ -486,7 +486,7 @@ void func_808B5AF0(BgSpot16Bombstone* this) { } void func_808B5B04(BgSpot16Bombstone* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->bombiwaBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { func_808B5B58(this); this->actor.draw = BgSpot16Bombstone_Draw; } @@ -546,7 +546,7 @@ void BgSpot16Bombstone_Draw(Actor* thisx, PlayState* play) { gSPDisplayList(POLY_OPA_DISP++, this->dList); } else { // The boulder is debris - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->bombiwaBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->requiredObjectSlot].segment); gSPDisplayList(POLY_OPA_DISP++, this->dList); } diff --git a/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.h b/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.h index 499b01031..01fb4cc3e 100644 --- a/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.h +++ b/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.h @@ -22,7 +22,7 @@ typedef struct BgSpot16Bombstone { /* 0x01C4 */ ColliderCylinder colliderCylinder; /* 0x0210 */ s16 unk_210; /* 0x0212 */ s16 unk_212; - /* 0x0214 */ s8 bombiwaBankIndex; + /* 0x0214 */ s8 requiredObjectSlot; } BgSpot16Bombstone; // size = 0x0218 #endif diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index c076def6a..e021aa0d6 100644 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -321,8 +321,8 @@ void BossGanon_SetColliderPos(Vec3f* pos, ColliderCylinder* collider) { } void BossGanon_SetAnimationObject(BossGanon* this, PlayState* play, s32 objectId) { - this->animBankIndex = Object_GetIndex(&play->objectCtx, objectId); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->animBankIndex].segment); + this->animObjectSlot = Object_GetSlot(&play->objectCtx, objectId); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->animObjectSlot].segment); } static InitChainEntry sInitChain[] = { @@ -474,18 +474,18 @@ void BossGanon_Destroy(Actor* thisx, PlayState* play) { void BossGanon_SetupIntroCutscene(BossGanon* this, PlayState* play) { s32 pad; - s32 animBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GANON_ANIME2); + s32 animObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GANON_ANIME2); - if (animBankIndex < 0) { + if (animObjectSlot < 0) { Actor_Kill(&this->actor); return; } - if (Object_IsLoaded(&play->objectCtx, animBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, animObjectSlot)) { this->actionFunc = BossGanon_IntroCutscene; this->unk_198 = 1; - this->animBankIndex = animBankIndex; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[animBankIndex].segment); + this->animObjectSlot = animObjectSlot; + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[animObjectSlot].segment); Animation_MorphToLoop(&this->skelAnime, &gGanondorfPlayOrganAnim, 0.0f); } else { this->actionFunc = BossGanon_SetupIntroCutscene; @@ -533,7 +533,7 @@ void BossGanon_IntroCutscene(BossGanon* this, PlayState* play) { f32 cos; Camera* mainCam; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->animBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->animObjectSlot].segment); sCape->backPush = -2.0f; sCape->backSwayMagnitude = 0.25f; @@ -1079,8 +1079,8 @@ void BossGanon_IntroCutscene(BossGanon* this, PlayState* play) { } if (this->csTimer == 50) { - gSegments[6] = VIRTUAL_TO_PHYSICAL( - play->objectCtx.status[Object_GetIndex(&play->objectCtx, OBJECT_GANON)].segment); + gSegments[6] = + VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[Object_GetSlot(&play->objectCtx, OBJECT_GANON)].segment); if (!GET_EVENTCHKINF(EVENTCHKINF_78)) { TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gGanondorfTitleCardTex), @@ -1163,14 +1163,14 @@ void BossGanon_IntroCutscene(BossGanon* this, PlayState* play) { void BossGanon_SetupDeathCutscene(BossGanon* this, PlayState* play) { s32 pad; - s32 animBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GANON_ANIME2); + s32 animObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GANON_ANIME2); - if (Object_IsLoaded(&play->objectCtx, animBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, animObjectSlot)) { this->actionFunc = BossGanon_DeathAndTowerCutscene; this->csTimer = this->csState = 0; this->unk_198 = 1; - this->animBankIndex = animBankIndex; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[animBankIndex].segment); + this->animObjectSlot = animObjectSlot; + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[animObjectSlot].segment); Animation_MorphToPlayOnce(&this->skelAnime, &gGanondorfDefeatedStartAnim, 0.0f); this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gGanondorfDefeatedStartAnim); this->unk_508 = 0.0f; @@ -1179,11 +1179,11 @@ void BossGanon_SetupDeathCutscene(BossGanon* this, PlayState* play) { void BossGanon_SetupTowerCutscene(BossGanon* this, PlayState* play) { s32 pad; - s32 animBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GANON_ANIME2); + s32 animObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GANON_ANIME2); - if (Object_IsLoaded(&play->objectCtx, animBankIndex)) { - this->animBankIndex = animBankIndex; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[animBankIndex].segment); + if (Object_IsLoaded(&play->objectCtx, animObjectSlot)) { + this->animObjectSlot = animObjectSlot; + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[animObjectSlot].segment); Animation_MorphToPlayOnce(&this->skelAnime, &gGanondorfDefeatedStartAnim, 0.0f); this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gGanondorfDefeatedStartAnim); this->actionFunc = BossGanon_DeathAndTowerCutscene; @@ -1226,7 +1226,7 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, PlayState* play) { Camera* mainCam; Vec3f sp64; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->animBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->animObjectSlot].segment); this->csTimer++; SkelAnime_Update(&this->skelAnime); @@ -2796,7 +2796,7 @@ void BossGanon_Update(Actor* thisx, PlayState* play2) { if ((this->actionFunc != BossGanon_IntroCutscene) && (this->actionFunc != BossGanon_DeathAndTowerCutscene)) { BossGanon_SetAnimationObject(this, play, OBJECT_GANON_ANIME1); } else { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->animBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->animObjectSlot].segment); } if (this->windowShatterState != GDF_WINDOW_SHATTER_OFF) { diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.h b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.h index c1db63792..85bbc27f1 100644 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.h +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.h @@ -85,7 +85,7 @@ typedef enum { typedef struct BossGanon { /* 0x0000 */ Actor actor; - /* 0x014C */ s32 animBankIndex; + /* 0x014C */ s32 animObjectSlot; /* 0x0150 */ SkelAnime skelAnime; /* 0x0194 */ BossGanonActionFunc actionFunc; /* 0x0198 */ u8 unk_198; diff --git a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index 20b8d7da2..8fab69699 100644 --- a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -78,15 +78,15 @@ void func_808FD080(s32 idx, ColliderJntSph* collider, Vec3f* arg2) { void BossGanon2_SetObjectSegment(BossGanon2* this, PlayState* play, s32 objectId, u8 setRSPSegment) { s32 pad; - s32 objectIdx = Object_GetIndex(&play->objectCtx, objectId); + s32 objectSlot = Object_GetSlot(&play->objectCtx, objectId); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIdx].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); if (setRSPSegment) { OPEN_DISPS(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[objectIdx].segment); - gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[objectIdx].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[objectSlot].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.slots[objectSlot].segment); CLOSE_DISPS(play->state.gfxCtx); } @@ -183,7 +183,7 @@ void func_808FD5F4(BossGanon2* this, PlayState* play) { s16 pad; u8 sp8D; Player* player; - s32 objectIdx; + s32 objectSlot; s32 zero = 0; s32 pad2; @@ -193,8 +193,8 @@ void func_808FD5F4(BossGanon2* this, PlayState* play) { switch (this->unk_39C) { case 0: - objectIdx = Object_GetIndex(&play->objectCtx, OBJECT_GANON_ANIME3); - if (Object_IsLoaded(&play->objectCtx, objectIdx)) { + objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GANON_ANIME3); + if (Object_IsLoaded(&play->objectCtx, objectSlot)) { Cutscene_StartManual(play, &play->csCtx); func_8002DF54(play, &this->actor, PLAYER_CSMODE_8); this->subCamId = Play_CreateSubCamera(play); @@ -1040,10 +1040,10 @@ void func_808FFCFC(BossGanon2* this, PlayState* play) { void func_808FFDB0(BossGanon2* this, PlayState* play) { s32 sp28; - s32 objectIdx = Object_GetIndex(&play->objectCtx, OBJECT_GANON2); + s32 objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GANON2); - if (Object_IsLoaded(&play->objectCtx, objectIdx)) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIdx].segment); + if (Object_IsLoaded(&play->objectCtx, objectSlot)) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); Animation_MorphToLoop(&this->skelAnime, &gGanonGuardIdleAnim, -10.0f); this->actionFunc = func_808FFEBC; diff --git a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c index 570c7a3af..4e475b99b 100644 --- a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c @@ -2083,7 +2083,7 @@ void BossGoma_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* r sDeadLimbLifetime[limbIndex] + 100); if (babyGohma != NULL) { babyGohma->bossLimbDL = *dList; - babyGohma->actor.objBankIndex = this->actor.objBankIndex; + babyGohma->actor.objectSlot = this->actor.objectSlot; } } diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index d17161472..873f68362 100644 --- a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -756,7 +756,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) { } } if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_GRAB) { - player->unk_850 = 0xA; + player->actionVar2 = 0xA; player->actor.speed = player->actor.velocity.y = 0; Math_ApproachF(&player->actor.world.pos.x, this->grabPosRot.pos.x, 0.5f, 20.0f); Math_ApproachF(&player->actor.world.pos.y, this->grabPosRot.pos.y, 0.5f, 20.0f); @@ -814,7 +814,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) { Math_ApproachS(&this->tentRot[indS1].z, tempf2, 1.0f / this->tentMaxAngle, this->tentSpeed); } } - player->unk_850 = 0xA; + player->actionVar2 = 0xA; player->actor.world.pos.x = this->grabPosRot.pos.x; player->actor.world.pos.y = this->grabPosRot.pos.y; player->actor.world.pos.z = this->grabPosRot.pos.z; @@ -833,7 +833,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) { this->work[MO_TENT_ACTION_STATE] = MO_TENT_RETREAT; this->work[MO_TENT_INVINC_TIMER] = 50; if (&this->actor == player->actor.parent) { - player->unk_850 = 0x65; + player->actionVar2 = 0x65; player->actor.parent = NULL; player->csMode = PLAYER_CSMODE_NONE; if (this->timers[0] == 0) { @@ -863,7 +863,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) { case MO_TENT_CUT: Sfx_PlaySfxAtPos(&this->tentTipPos, NA_SE_EV_WATER_WALL - SFX_FLAG); if (&this->actor == player->actor.parent) { - player->unk_850 = 0x65; + player->actionVar2 = 0x65; player->actor.parent = NULL; player->csMode = PLAYER_CSMODE_NONE; } @@ -1784,7 +1784,7 @@ void BossMo_CoreCollisionCheck(BossMo* this, PlayState* play) { sMorphaTent2->tent2KillTimer = 1; } if (player->actor.parent != NULL) { - player->unk_850 = 0x65; + player->actionVar2 = 0x65; player->actor.parent = NULL; player->csMode = PLAYER_CSMODE_NONE; } @@ -1803,7 +1803,7 @@ void BossMo_CoreCollisionCheck(BossMo* this, PlayState* play) { sMorphaTent1->timers[0] = 40; sMorphaTent1->actor.flags &= ~ACTOR_FLAG_0; if (player->actor.parent == &sMorphaTent1->actor) { - player->unk_850 = 0x65; + player->actionVar2 = 0x65; player->actor.parent = NULL; player->csMode = PLAYER_CSMODE_NONE; } diff --git a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c index a9bc06999..1c5495a19 100644 --- a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c @@ -1749,7 +1749,7 @@ void BossSst_HandClap(BossSst* this, PlayState* play) { } if (player->actor.parent == &this->actor) { - player->unk_850 = 0; + player->actionVar2 = 0; player->actor.world.pos = this->actor.world.pos; } } @@ -1844,7 +1844,7 @@ void BossSst_HandGrab(BossSst* this, PlayState* play) { this->actor.world.pos.x += this->actor.speed * Math_SinS(this->actor.world.rot.y); this->actor.world.pos.z += this->actor.speed * Math_CosS(this->actor.world.rot.y); if (player->stateFlags2 & PLAYER_STATE2_7) { - player->unk_850 = 0; + player->actionVar2 = 0; player->actor.world.pos = this->actor.world.pos; player->actor.shape.rot.y = this->actor.shape.rot.y; } @@ -1938,7 +1938,7 @@ void BossSst_HandSwing(BossSst* this, PlayState* play) { } if (player->stateFlags2 & PLAYER_STATE2_7) { - player->unk_850 = 0; + player->actionVar2 = 0; Math_Vec3f_Copy(&player->actor.world.pos, &this->actor.world.pos); player->actor.shape.rot.x = this->actor.shape.rot.x; player->actor.shape.rot.z = (this->vParity * -0x4000) + this->actor.shape.rot.z; @@ -2422,7 +2422,7 @@ void BossSst_HandReleasePlayer(BossSst* this, PlayState* play, s32 dropPlayer) { if (player->actor.parent == &this->actor) { player->actor.parent = NULL; - player->unk_850 = 100; + player->actionVar2 = 100; this->colliderJntSph.base.ocFlags1 |= OC1_ON; OTHER_HAND(this)->colliderJntSph.base.ocFlags1 |= OC1_ON; if (dropPlayer) { diff --git a/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c b/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c index dc8618b42..ec58e7a40 100644 --- a/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c +++ b/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c @@ -17,7 +17,7 @@ void Demo6K_Init(Actor* thisx, PlayState* play); void Demo6K_Destroy(Actor* thisx, PlayState* play); void Demo6K_Update(Actor* thisx, PlayState* play); -void func_80966DB0(Demo6K* this, PlayState* play); +void Demo6K_WaitForObject(Demo6K* this, PlayState* play); void func_80966E04(Demo6K* this, PlayState* play); void func_80966E98(Demo6K* this, PlayState* play); void func_80966F84(Demo6K* this, PlayState* play); @@ -69,26 +69,26 @@ void Demo6K_Init(Actor* thisx, PlayState* play) { Demo6K* this = (Demo6K*)thisx; s32 pad; s32 params = this->actor.params; - s32 objBankIndex; + s32 objectSlot; s32 i; osSyncPrintf("no = %d\n", params); if (sObjectIds[params] != OBJECT_GAMEPLAY_KEEP) { - objBankIndex = Object_GetIndex(&play->objectCtx, sObjectIds[params]); + objectSlot = Object_GetSlot(&play->objectCtx, sObjectIds[params]); } else { - objBankIndex = 0; + objectSlot = 0; } - osSyncPrintf("bank_ID = %d\n", objBankIndex); + osSyncPrintf("bank_ID = %d\n", objectSlot); - if (objBankIndex < 0) { + if (objectSlot < 0) { ASSERT(0, "0", "../z_demo_6k.c", 334); } else { - this->objBankIndex = objBankIndex; + this->requiredObjectSlot = objectSlot; } - Demo6K_SetupAction(this, func_80966DB0); + Demo6K_SetupAction(this, Demo6K_WaitForObject); this->timer1 = 0; this->flags = 0; this->timer2 = 0; @@ -197,9 +197,9 @@ void Demo6K_Destroy(Actor* thisx, PlayState* play) { LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } -void func_80966DB0(Demo6K* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { - this->actor.objBankIndex = this->objBankIndex; +void Demo6K_WaitForObject(Demo6K* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->actor.objectSlot = this->requiredObjectSlot; this->actor.draw = this->drawFunc; this->actionFunc = this->initActionFunc; } diff --git a/src/overlays/actors/ovl_Demo_6K/z_demo_6k.h b/src/overlays/actors/ovl_Demo_6K/z_demo_6k.h index 5d6a5367a..09d9c175f 100644 --- a/src/overlays/actors/ovl_Demo_6K/z_demo_6k.h +++ b/src/overlays/actors/ovl_Demo_6K/z_demo_6k.h @@ -27,7 +27,7 @@ typedef struct Demo6K { /* 0x028C */ u16 flags; /* 0x028E */ u16 timer1; /* 0x0290 */ u16 timer2; - /* 0x0292 */ u8 objBankIndex; + /* 0x0292 */ u8 requiredObjectSlot; /* 0x0293 */ u8 unk_293; } Demo6K; // size = 0x0294 diff --git a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c index 834b46e5a..a3d2a2f61 100644 --- a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c +++ b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c @@ -314,22 +314,22 @@ void DemoEc_DrawSkeletonCustomColor(DemoEc* this, PlayState* play, Gfx* arg2, Gf void DemoEc_UseDrawObject(DemoEc* this, PlayState* play) { s32 pad[2]; - s32 drawObjBankIndex = this->drawObjBankIndex; + s32 drawObjectSlot = this->drawObjectSlot; GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[drawObjBankIndex].segment); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[drawObjBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[drawObjectSlot].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[drawObjectSlot].segment); if (!play) {} CLOSE_DISPS(gfxCtx); } void DemoEc_UseAnimationObject(DemoEc* this, PlayState* play) { - s32 animObjBankIndex = this->animObjBankIndex; + s32 animObjectSlot = this->animObjectSlot; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[animObjBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[animObjectSlot].segment); } CsCmdActorCue* DemoEc_GetCue(PlayState* play, s32 cueChannel) { @@ -1083,7 +1083,7 @@ void DemoEc_UpdateFishingOwner(DemoEc* this, PlayState* play) { void DemoEc_FishingOwnerPostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { DemoEc* this = (DemoEc*)thisx; - if ((limbIndex == 8) && !(HIGH_SCORE(HS_FISHING) & 0x1000)) { + if ((limbIndex == 8) && !(HIGH_SCORE(HS_FISHING) & HS_FISH_STOLE_HAT)) { gSPDisplayList((*gfx)++, SEGMENTED_TO_VIRTUAL(gFishingOwnerHatDL)); } } @@ -1261,26 +1261,27 @@ void DemoEc_InitCommon(DemoEc* this, PlayState* play) { s32 type; s16 pad2; s16 sp28; - s32 primaryBankIndex; - s32 secondaryBankIndex; + s32 primaryObjectSlot; + s32 secondaryObjectSlot; type = this->actor.params; primary = sDrawObjects[type]; sp28 = sAnimationObjects[type]; - primaryBankIndex = Object_GetIndex(&play->objectCtx, primary); - secondaryBankIndex = Object_GetIndex(&play->objectCtx, sp28); + primaryObjectSlot = Object_GetSlot(&play->objectCtx, primary); + secondaryObjectSlot = Object_GetSlot(&play->objectCtx, sp28); - if ((secondaryBankIndex < 0) || (primaryBankIndex < 0)) { + if ((secondaryObjectSlot < 0) || (primaryObjectSlot < 0)) { // "Demo_Ec_main_bank: Bank unreadable arg_data = %d!" osSyncPrintf(VT_FGCOL(RED) "Demo_Ec_main_bank:バンクを読めない arg_data = %d!\n" VT_RST, type); Actor_Kill(&this->actor); return; } - if (Object_IsLoaded(&play->objectCtx, primaryBankIndex) && Object_IsLoaded(&play->objectCtx, secondaryBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, primaryObjectSlot) && + Object_IsLoaded(&play->objectCtx, secondaryObjectSlot)) { - this->drawObjBankIndex = primaryBankIndex; - this->animObjBankIndex = secondaryBankIndex; + this->drawObjectSlot = primaryObjectSlot; + this->animObjectSlot = secondaryObjectSlot; DemoEc_InitNpc(this, play); } diff --git a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.h b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.h index a93a8589a..fe7148350 100644 --- a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.h +++ b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.h @@ -18,8 +18,8 @@ typedef struct DemoEc { /* 0x0194 */ s32 updateMode; /* 0x0198 */ s32 drawConfig; /* 0x019C */ s32 cueId; - /* 0x01A0 */ s32 drawObjBankIndex; - /* 0x01A4 */ s32 animObjBankIndex; + /* 0x01A0 */ s32 drawObjectSlot; + /* 0x01A4 */ s32 animObjectSlot; } DemoEc; // size = 0x01A8 #endif diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index f223d7862..c2d299950 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -28,7 +28,7 @@ void DemoEffect_DrawLightEffect(Actor* thisx, PlayState* play); void DemoEffect_DrawTimeWarp(Actor* thisx, PlayState* play); void DemoEffect_DrawJewel(Actor* thisx, PlayState* play2); -void DemoEffect_Wait(DemoEffect* this, PlayState* play); +void DemoEffect_WaitForObject(DemoEffect* this, PlayState* play); void DemoEffect_InitTimeWarp(DemoEffect* this, PlayState* play); void DemoEffect_InitTimeWarpTimeblock(DemoEffect* this, PlayState* play); void DemoEffect_InitCreationFireball(DemoEffect* this, PlayState* play); @@ -166,7 +166,7 @@ void DemoEffect_Init(Actor* thisx, PlayState* play2) { DemoEffect* this = (DemoEffect*)thisx; s32 effectType; s32 lightEffect; - s32 objectIndex; + s32 objectSlot; DemoEffect* crystalLight; DemoEffect* lightRing; @@ -175,16 +175,16 @@ void DemoEffect_Init(Actor* thisx, PlayState* play2) { osSyncPrintf(VT_FGCOL(CYAN) " no = %d\n" VT_RST, effectType); - objectIndex = sEffectTypeObjects[effectType] == OBJECT_GAMEPLAY_KEEP - ? 0 - : Object_GetIndex(&play->objectCtx, sEffectTypeObjects[effectType]); + objectSlot = sEffectTypeObjects[effectType] == OBJECT_GAMEPLAY_KEEP + ? 0 + : Object_GetSlot(&play->objectCtx, sEffectTypeObjects[effectType]); - osSyncPrintf(VT_FGCOL(CYAN) " bank_ID = %d\n" VT_RST, objectIndex); + osSyncPrintf(VT_FGCOL(CYAN) " bank_ID = %d\n" VT_RST, objectSlot); - if (objectIndex < 0) { + if (objectSlot < 0) { ASSERT(0, "0", "../z_demo_effect.c", 723); } else { - this->initObjectBankIndex = objectIndex; + this->requiredObjectSlot = objectSlot; } this->effectFlags = 0; @@ -499,7 +499,7 @@ void DemoEffect_Init(Actor* thisx, PlayState* play2) { } ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - DemoEffect_SetupUpdate(this, DemoEffect_Wait); + DemoEffect_SetupUpdate(this, DemoEffect_WaitForObject); } void DemoEffect_Destroy(Actor* thisx, PlayState* play) { @@ -518,9 +518,9 @@ void DemoEffect_Destroy(Actor* thisx, PlayState* play) { * They are copied to actor.draw and updateFunc. * initUpdateFunc/initDrawFunc are set during initialization and are NOT executed. */ -void DemoEffect_Wait(DemoEffect* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->initObjectBankIndex)) { - this->actor.objBankIndex = this->initObjectBankIndex; +void DemoEffect_WaitForObject(DemoEffect* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->actor.objectSlot = this->requiredObjectSlot; this->actor.draw = this->initDrawFunc; this->updateFunc = this->initUpdateFunc; diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h index 8dea6944c..2e7263e58 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -79,7 +79,7 @@ typedef struct { typedef struct DemoEffect { /* 0x0000 */ Actor actor; /* 0x014C */ SkelCurve skelCurve; - /* 0x016C */ u8 initObjectBankIndex; + /* 0x016C */ u8 requiredObjectSlot; /* 0x0170 */ Gfx* jewelDisplayList; /* 0x0174 */ Gfx* jewelHolderDisplayList; /* 0x0178 */ u8 primXluColor[3]; diff --git a/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.c b/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.c index 0a0378dc8..a1492bf0f 100644 --- a/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.c +++ b/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.c @@ -23,7 +23,7 @@ void func_80978308(DemoGeff* this, PlayState* play); void func_809784D4(DemoGeff* this, PlayState* play); void func_80978344(DemoGeff* this, PlayState* play); -static s16 sObjectIDs[] = { +static s16 sObjectIds[] = { OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, }; @@ -86,13 +86,13 @@ void func_80977EA8(PlayState* play, Gfx* dlist) { void func_80977F80(DemoGeff* this, PlayState* play) { s32 pad[2]; - s32 objBankIndex = this->objBankIndex; + s32 objectSlot = this->objectSlot; GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[objBankIndex].segment); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[objectSlot].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); // Necessary to match if (!play) {} @@ -188,17 +188,17 @@ void func_809783D4(DemoGeff* this, PlayState* play) { ObjectContext* objCtx = &play->objectCtx; Actor* thisx = &this->actor; s32 params = thisx->params; - s16 objectId = sObjectIDs[params]; - s32 objBankIndex = Object_GetIndex(objCtx, objectId); + s16 objectId = sObjectIds[params]; + s32 objectSlot = Object_GetSlot(objCtx, objectId); s32 pad; - if (objBankIndex < 0) { + if (objectSlot < 0) { osSyncPrintf(VT_FGCOL(RED) "Demo_Geff_main_bank:バンクを読めない arg_data = %d!\n" VT_RST, params); Actor_Kill(thisx); return; } - if (Object_IsLoaded(objCtx, objBankIndex)) { - this->objBankIndex = objBankIndex; + if (Object_IsLoaded(objCtx, objectSlot)) { + this->objectSlot = objectSlot; func_80978370(this, play); } } diff --git a/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.h b/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.h index a21eb64a2..ca719594a 100644 --- a/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.h +++ b/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.h @@ -16,7 +16,7 @@ typedef struct DemoGeff { /* 0x0000 */ Actor actor; /* 0x014C */ s32 action; /* 0x0150 */ s32 drawConfig; - /* 0x0154 */ s32 objBankIndex; + /* 0x0154 */ s32 objectSlot; /* 0x0158 */ DemoGt* demoGt; /* 0x015C */ f32 deltaPosX; /* 0x0160 */ f32 deltaPosY; diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index e191a535f..618e34df4 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -52,7 +52,7 @@ ActorInit Demo_Kankyo_InitVars = { (ActorFunc)DemoKankyo_Draw, }; -static s16 sObjIds[] = { +static s16 sObjectIds[] = { OBJECT_EFC_STAR_FIELD, OBJECT_EFC_STAR_FIELD, OBJECT_EFC_STAR_FIELD, OBJECT_EFC_STAR_FIELD, OBJECT_EFC_STAR_FIELD, OBJECT_EFC_STAR_FIELD, OBJECT_EFC_STAR_FIELD, OBJECT_GAMEPLAY_KEEP, OBJECT_GI_MELODY, OBJECT_GI_MELODY, OBJECT_GI_MELODY, OBJECT_GI_MELODY, OBJECT_GI_MELODY, OBJECT_TOKI_OBJECTS, OBJECT_TOKI_OBJECTS, @@ -181,13 +181,13 @@ void DemoKankyo_SetupAction(DemoKankyo* this, DemoKankyoActionFunc actionFunc) { void DemoKankyo_Init(Actor* thisx, PlayState* play) { DemoKankyo* this = (DemoKankyo*)thisx; s16 i; - s32 objBankIndex = Object_GetIndex(&play->objectCtx, sObjIds[this->actor.params]); + s32 objectSlot = Object_GetSlot(&play->objectCtx, sObjectIds[this->actor.params]); - osSyncPrintf("bank_ID = %d\n", objBankIndex); - if (objBankIndex < 0) { + osSyncPrintf("bank_ID = %d\n", objectSlot); + if (objectSlot < 0) { ASSERT(0, "0", "../z_demo_kankyo.c", 521); } else { - this->objBankIndex = objBankIndex; + this->requiredObjectSlot = objectSlot; } switch (this->actor.params) { @@ -279,7 +279,7 @@ void DemoKankyo_SetupType(DemoKankyo* this, PlayState* play) { Player* player = GET_PLAYER(play); f32 temp; - if (this->actor.objBankIndex == this->objBankIndex) { + if (this->actor.objectSlot == this->requiredObjectSlot) { switch (this->actor.params) { case DEMOKANKYO_ROCK_1: case DEMOKANKYO_ROCK_2: @@ -432,7 +432,7 @@ void DemoKankyo_Update(Actor* thisx, PlayState* play) { void DemoKankyo_Draw(Actor* thisx, PlayState* play) { DemoKankyo* this = (DemoKankyo*)thisx; - if (this->actor.objBankIndex == this->objBankIndex) { + if (this->actor.objectSlot == this->requiredObjectSlot) { switch (this->actor.params) { case DEMOKANKYO_BLUE_RAIN: case DEMOKANKYO_BLUE_RAIN_2: @@ -480,8 +480,8 @@ void DemoKankyo_Draw(Actor* thisx, PlayState* play) { break; } } - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { - this->actor.objBankIndex = this->objBankIndex; + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->actor.objectSlot = this->requiredObjectSlot; } } diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h index 89ad474b3..0103812c6 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h @@ -42,7 +42,7 @@ typedef struct { typedef struct DemoKankyo { /* 0x0000 */ Actor actor; - /* 0x014C */ u8 objBankIndex; + /* 0x014C */ u8 requiredObjectSlot; /* 0x014D */ u8 sparkleCounter; /* 0x014E */ u8 warpTimer; /* 0x0150 */ DemoKankyoUnk150 unk_150[30]; diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index a48f4365e..f670f1385 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -129,7 +129,7 @@ void DoorAna_WaitOpen(DoorAna* this, PlayState* play) { player = GET_PLAYER(play); if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f)) { if ((this->actor.targetMode != 0) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && - (player->stateFlags1 & PLAYER_STATE1_31) && (player->unk_84F == 0)) { + (player->stateFlags1 & PLAYER_STATE1_31) && (player->actionVar1 == 0)) { destinationIdx = ((this->actor.params >> 0xC) & 7) - 1; Play_SetupRespawnPoint(play, RESPAWN_MODE_RETURN, 0x4FF); gSaveContext.respawn[RESPAWN_MODE_RETURN].pos.y = this->actor.world.pos.y; diff --git a/src/overlays/actors/ovl_Door_Killer/z_door_killer.c b/src/overlays/actors/ovl_Door_Killer/z_door_killer.c index de645eaa0..fe5890153 100644 --- a/src/overlays/actors/ovl_Door_Killer/z_door_killer.c +++ b/src/overlays/actors/ovl_Door_Killer/z_door_killer.c @@ -25,7 +25,7 @@ void DoorKiller_Init(Actor* thisx, PlayState* play2); void DoorKiller_Destroy(Actor* thisx, PlayState* play); void DoorKiller_Update(Actor* thisx, PlayState* play); void DoorKiller_Wait(DoorKiller* this, PlayState* play); -void DoorKiller_SetProperties(DoorKiller* this, PlayState* play); +void DoorKiller_WaitForObject(DoorKiller* this, PlayState* play); void DoorKiller_DrawDoor(Actor* thisx, PlayState* play); void DoorKiller_DrawRubble(Actor* thisx, PlayState* play); @@ -99,18 +99,19 @@ void DoorKiller_Init(Actor* thisx, PlayState* play2) { PlayState* play = play2; f32 randF; DoorKiller* this = (DoorKiller*)thisx; - s32 bankIndex; + s32 objectSlot; s32 i; // Look in the object bank for one of the four objects containing door textures - bankIndex = -1; - for (i = 0; bankIndex < 0; i++) { - bankIndex = Object_GetIndex(&play->objectCtx, sDoorTextures[i].objectId); + objectSlot = -1; + //! @bug If no objectSlot is found, `sDoorTextures` will be read out of bounds + for (i = 0; objectSlot < 0; i++) { + objectSlot = Object_GetSlot(&play->objectCtx, sDoorTextures[i].objectId); this->textureEntryIndex = i; } - osSyncPrintf("bank_ID = %d\n", bankIndex); + osSyncPrintf("bank_ID = %d\n", objectSlot); osSyncPrintf("status = %d\n", this->textureEntryIndex); - this->doorObjBankIndex = bankIndex; + this->requiredObjectSlot = objectSlot; this->texture = sDoorTextures[this->textureEntryIndex].texture; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); @@ -126,8 +127,8 @@ void DoorKiller_Init(Actor* thisx, PlayState* play2) { // play any animations it does not cause problems, but it would need to be changed otherwise. SkelAnime_InitFlex(play, &this->skelAnime, &object_door_killer_Skel_001BC8, NULL, this->jointTable, this->jointTable, 9); - this->actionFunc = DoorKiller_SetProperties; - DoorKiller_SetProperties(this, play); + this->actionFunc = DoorKiller_WaitForObject; + DoorKiller_WaitForObject(this, play); // manually set the overall rotation of the door this->jointTable[1].x = this->jointTable[1].z = 0x4000; @@ -152,8 +153,8 @@ void DoorKiller_Init(Actor* thisx, PlayState* play2) { case DOOR_KILLER_RUBBLE_PIECE_2: case DOOR_KILLER_RUBBLE_PIECE_3: case DOOR_KILLER_RUBBLE_PIECE_4: - this->actionFunc = DoorKiller_SetProperties; - DoorKiller_SetProperties(this, play); + this->actionFunc = DoorKiller_WaitForObject; + DoorKiller_WaitForObject(this, play); this->actor.gravity = -0.6f; this->actor.minVelocityY = -6.0f; @@ -459,17 +460,17 @@ void DoorKiller_Wait(DoorKiller* this, PlayState* play) { void DoorKiller_UpdateTexture(Actor* thisx, PlayState* play) { DoorKiller* this = (DoorKiller*)thisx; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->doorObjBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->requiredObjectSlot].segment); this->texture = SEGMENTED_TO_VIRTUAL(this->texture); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[thisx->objBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->actor.objectSlot].segment); } /** * Gets the correct door texture, defines the appropriate draw fucntion and action function based on type behaviour * (door or rubble). */ -void DoorKiller_SetProperties(DoorKiller* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->doorObjBankIndex)) { +void DoorKiller_WaitForObject(DoorKiller* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { DoorKiller_UpdateTexture(&this->actor, play); switch (this->actor.params & 0xFF) { case DOOR_KILLER_DOOR: diff --git a/src/overlays/actors/ovl_Door_Killer/z_door_killer.h b/src/overlays/actors/ovl_Door_Killer/z_door_killer.h index 37865805e..1b3256450 100644 --- a/src/overlays/actors/ovl_Door_Killer/z_door_killer.h +++ b/src/overlays/actors/ovl_Door_Killer/z_door_killer.h @@ -25,7 +25,7 @@ typedef struct DoorKiller { /* 0x0214 */ void* texture; /* 0x0218 */ u16 hasHitPlayerOrGround; /* 0x021A */ u16 timer; - /* 0x021C */ u8 doorObjBankIndex; + /* 0x021C */ u8 requiredObjectSlot; /* 0x021D */ u8 textureEntryIndex; /* 0x0220 */ ColliderJntSph colliderJntSph; /* 0x0240 */ ColliderJntSphElement colliderJntSphItems[1]; diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 141019b96..1345a1485 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -402,7 +402,7 @@ void DoorShutter_Init(Actor* thisx, PlayState* play2) { PlayState* play = play2; s32 styleType; s32 pad; - s32 objectIndex; + s32 objectSlot; s32 i; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -432,9 +432,8 @@ void DoorShutter_Init(Actor* thisx, PlayState* play2) { } else { // DOORSHUTTER_STYLE_PHANTOM_GANON, DOORSHUTTER_STYLE_GOHMA_BLOCK this->dyna.actor.room = -1; } - - if (this->requiredObjBankIndex = objectIndex = Object_GetIndex(&play->objectCtx, sStyleInfo[styleType].objectId), - (s8)objectIndex < 0) { + if (this->requiredObjectSlot = objectSlot = Object_GetSlot(&play->objectCtx, sStyleInfo[styleType].objectId), + (s8)objectSlot < 0) { Actor_Kill(&this->dyna.actor); return; } @@ -468,8 +467,8 @@ void DoorShutter_Destroy(Actor* thisx, PlayState* play) { } void DoorShutter_WaitForObject(DoorShutter* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex)) { - this->dyna.actor.objBankIndex = this->requiredObjBankIndex; + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->dyna.actor.objectSlot = this->requiredObjectSlot; if (this->doorType == SHUTTER_PG_BARS || this->doorType == SHUTTER_GOHMA_BLOCK) { // Init dynapoly for shutters of the type that uses it CollisionHeader* colHeader = NULL; @@ -977,7 +976,7 @@ void DoorShutter_Draw(Actor* thisx, PlayState* play) { DoorShutter* this = (DoorShutter*)thisx; //! @bug This actor is not fully initialized until the required object dependency is loaded. - //! In most cases, the check for objBankIndex to equal requiredObjBankIndex prevents the actor + //! In most cases, the check for objectSlot to equal requiredObjectSlot prevents the actor //! from drawing until initialization is complete. However if the required object is the same as the //! object dependency listed in init vars (gameplay_keep in this case), the check will pass even though //! initialization has not completed. When this happens, it will try to draw the display list of the @@ -988,7 +987,7 @@ void DoorShutter_Draw(Actor* thisx, PlayState* play) { //! The best way to fix this issue (and what was done in Majora's Mask) is to null out the draw function in //! the init vars for the actor, and only set draw after initialization is complete. - if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex && + if (this->dyna.actor.objectSlot == this->requiredObjectSlot && (this->styleType == DOORSHUTTER_STYLE_PHANTOM_GANON || DoorShutter_ShouldDraw(this, play))) { s32 pad[2]; DoorShutterGfxInfo* gfxInfo = &sGfxInfo[this->gfxType]; diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h index 4dd268ea8..3eb39148c 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h @@ -48,7 +48,7 @@ typedef struct DoorShutter { /* 0x016A */ u8 doorType; /* 0x016B */ u8 styleType; /* 0x016C */ u8 gfxType; - /* 0x016D */ s8 requiredObjBankIndex; + /* 0x016D */ s8 requiredObjectSlot; /* 0x016E */ s8 unlockTimer; // non-0 if the door is locked, ticks down while the door is unlocking /* 0x016F */ s8 actionTimer; /* 0x0170 */ f32 barsClosedAmount; // Ranges from 0.0f (unbarred) to 1.0f (barred) diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 37dfc37fe..783ec844a 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -1267,7 +1267,7 @@ void EnBb_Update(Actor* thisx, PlayState* play2) { void EnBb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { EnBb* this = (EnBb*)thisx; - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 4, 15, 15, dList, BODYBREAK_OBJECT_DEFAULT); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 4, 15, 15, dList, BODYBREAK_OBJECT_SLOT_DEFAULT); } static Vec3f sFireIceOffsets[] = { diff --git a/src/overlays/actors/ovl_En_Cs/z_en_cs.c b/src/overlays/actors/ovl_En_Cs/z_en_cs.c index 29eb4f5c1..ab94569c9 100644 --- a/src/overlays/actors/ovl_En_Cs/z_en_cs.c +++ b/src/overlays/actors/ovl_En_Cs/z_en_cs.c @@ -470,18 +470,18 @@ void EnCs_Draw(Actor* thisx, PlayState* play) { EnCs_OverrideLimbDraw, EnCs_PostLimbDraw, &this->actor); if (GET_ITEMGETINF(ITEMGETINF_3A)) { - s32 childLinkObjectIndex = Object_GetIndex(&play->objectCtx, OBJECT_LINK_CHILD); + s32 linkChildObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_LINK_CHILD); // Handle attaching the Spooky Mask to the boy's face - if (childLinkObjectIndex >= 0) { + if (linkChildObjectSlot >= 0) { Mtx* mtx; Matrix_Put(&this->spookyMaskMtx); mtx = Matrix_NewMtx(play->state.gfxCtx, "../z_en_cs.c", 1000); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[childLinkObjectIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[linkChildObjectSlot].segment); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx - 7); gSPDisplayList(POLY_OPA_DISP++, gLinkChildSpookyMaskDL); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->actor.objectSlot].segment); } } diff --git a/src/overlays/actors/ovl_En_Dha/z_en_dha.c b/src/overlays/actors/ovl_En_Dha/z_en_dha.c index 7406f29cf..472903dab 100644 --- a/src/overlays/actors/ovl_En_Dha/z_en_dha.c +++ b/src/overlays/actors/ovl_En_Dha/z_en_dha.c @@ -245,7 +245,7 @@ void EnDha_Wait(EnDha* this, PlayState* play) { if ((player->stateFlags2 & PLAYER_STATE2_7) && (&this->actor == player->actor.parent)) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; } if (this->actor.home.rot.z != 0) { @@ -285,7 +285,7 @@ void EnDha_Wait(EnDha* this, PlayState* play) { if ((player->stateFlags2 & PLAYER_STATE2_7) && (&this->actor == player->actor.parent)) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; } this->actor.home.rot.z = 1; @@ -306,7 +306,7 @@ void EnDha_TakeDamage(EnDha* this, PlayState* play) { if ((player->stateFlags2 & PLAYER_STATE2_7) && (&this->actor == player->actor.parent)) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; } Math_SmoothStepToS(&this->limbAngleX[1], 0, 1, 2000, 0); @@ -344,7 +344,7 @@ void EnDha_Die(EnDha* this, PlayState* play) { if ((player->stateFlags2 & PLAYER_STATE2_7) && (&this->actor == player->actor.parent)) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; } Math_SmoothStepToS(&this->limbAngleX[1], 0, 1, 0x7D0, 0); diff --git a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c index 6f5657620..03b8f2761 100644 --- a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c +++ b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c @@ -124,7 +124,7 @@ void EnDntNomal_Init(Actor* thisx, PlayState* play) { } this->actor.flags &= ~ACTOR_FLAG_0; this->actor.colChkInfo.mass = 0xFF; - this->objId = -1; + this->objectId = -1; if (this->type == ENDNTNOMAL_TARGET) { osSyncPrintf("\n\n"); // "Deku Scrub target" @@ -132,21 +132,21 @@ void EnDntNomal_Init(Actor* thisx, PlayState* play) { Collider_InitQuad(play, &this->targetQuad); Collider_SetQuad(play, &this->targetQuad, &this->actor, &sTargetQuadInit); this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->objId = OBJECT_HINTNUTS; + this->objectId = OBJECT_HINTNUTS; } else { osSyncPrintf("\n\n"); // "Deku Scrub mask show audience" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ デグナッツお面品評会一般人 ☆☆☆☆☆ \n" VT_RST); Collider_InitCylinder(play, &this->bodyCyl); Collider_SetCylinder(play, &this->bodyCyl, &this->actor, &sBodyCylinderInit); - this->objId = OBJECT_DNK; + this->objectId = OBJECT_DNK; } - if (this->objId >= 0) { - this->objIndex = Object_GetIndex(&play->objectCtx, this->objId); - if (this->objIndex < 0) { + if (this->objectId >= 0) { + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, this->objectId); + if (this->requiredObjectSlot < 0) { Actor_Kill(&this->actor); // "What?" - osSyncPrintf(VT_FGCOL(MAGENTA) " なにみの? %d\n" VT_RST "\n", this->objIndex); + osSyncPrintf(VT_FGCOL(MAGENTA) " なにみの? %d\n" VT_RST "\n", this->requiredObjectSlot); // "Bank is funny" osSyncPrintf(VT_FGCOL(CYAN) " バンクおかしいしぞ!%d\n" VT_RST "\n", this->actor.params); return; @@ -169,9 +169,9 @@ void EnDntNomal_Destroy(Actor* thisx, PlayState* play) { } void EnDntNomal_WaitForObject(EnDntNomal* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objIndex].segment); - this->actor.objBankIndex = this->objIndex; + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->requiredObjectSlot].segment); + this->actor.objectSlot = this->requiredObjectSlot; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); this->actor.gravity = -2.0f; Actor_SetScale(&this->actor, 0.01f); diff --git a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.h b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.h index 0b5c6f12e..13974bb1b 100644 --- a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.h +++ b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.h @@ -24,7 +24,7 @@ typedef struct EnDntNomal { /* 0x0260 */ s16 blinkTimer; /* 0x0262 */ s16 unkCounter; /* 0x0264 */ s16 timer3; - /* 0x0266 */ s16 objId; + /* 0x0266 */ s16 objectId; /* 0x0268 */ s16 eyeState; /* 0x026A */ s16 type; /* 0x026C */ s16 hitCounter; @@ -35,7 +35,7 @@ typedef struct EnDntNomal { /* 0x0276 */ u8 ignore; /* 0x0277 */ u8 spawnedItem; /* 0x0278 */ u8 stagePrize; - /* 0x0279 */ s8 objIndex; + /* 0x0279 */ s8 requiredObjectSlot; /* 0x027C */ Vec3f mouthPos; /* 0x0288 */ Vec3f targetPos; /* 0x0294 */ ColliderQuad targetQuad; diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index 8f1f12d34..076bf40f3 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -111,7 +111,7 @@ void EnDoor_Init(Actor* thisx, PlayState* play2) { EnDoor* this = (EnDoor*)thisx; EnDoorInfo* objectInfo; s32 i; - s32 objBankIndex; + s32 objectSlot; f32 xOffset; f32 zOffset; @@ -124,20 +124,20 @@ void EnDoor_Init(Actor* thisx, PlayState* play2) { break; } } - if (i >= ARRAY_COUNT(sDoorInfo) - 2 && Object_GetIndex(&play->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP) >= 0) { + if (i >= ARRAY_COUNT(sDoorInfo) - 2 && Object_GetSlot(&play->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP) >= 0) { objectInfo++; } this->dListIndex = objectInfo->dListIndex; - objBankIndex = Object_GetIndex(&play->objectCtx, objectInfo->objectId); - if (objBankIndex < 0) { + objectSlot = Object_GetSlot(&play->objectCtx, objectInfo->objectId); + if (objectSlot < 0) { Actor_Kill(&this->actor); return; } - this->requiredObjBankIndex = objBankIndex; + this->requiredObjectSlot = objectSlot; this->dListIndex = objectInfo->dListIndex; - if (this->actor.objBankIndex == this->requiredObjBankIndex) { + if (this->actor.objectSlot == this->requiredObjectSlot) { EnDoor_SetupType(this, play); } else { this->actionFunc = EnDoor_SetupType; @@ -175,10 +175,10 @@ void EnDoor_Destroy(Actor* thisx, PlayState* play) { void EnDoor_SetupType(EnDoor* this, PlayState* play) { s32 doorType; - if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { doorType = ENDOOR_GET_TYPE(&this->actor); this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.objBankIndex = this->requiredObjBankIndex; + this->actor.objectSlot = this->requiredObjectSlot; this->actionFunc = EnDoor_Idle; if (doorType == DOOR_EVENING) { doorType = (gSaveContext.save.dayTime > CLOCK_TIME(18, 0) && gSaveContext.save.dayTime < CLOCK_TIME(21, 0)) @@ -360,7 +360,7 @@ s32 EnDoor_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* void EnDoor_Draw(Actor* thisx, PlayState* play) { EnDoor* this = (EnDoor*)thisx; - if (this->actor.objBankIndex == this->requiredObjBankIndex) { + if (this->actor.objectSlot == this->requiredObjectSlot) { OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.h b/src/overlays/actors/ovl_En_Door/z_en_door.h index 05c41e16c..58ff784ee 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -49,7 +49,7 @@ typedef void (*EnDoorActionFunc)(struct EnDoor*, PlayState*); typedef struct EnDoor { /* 0x0000 */ DOOR_ACTOR_BASE; /* 0x0192 */ u8 unk_192; - /* 0x0193 */ s8 requiredObjBankIndex; + /* 0x0193 */ s8 requiredObjectSlot; /* 0x0194 */ s8 dListIndex; /* 0x0196 */ s16 lockTimer; /* 0x0198 */ Vec3s jointTable[5]; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index cbf60ba56..fb7d72253 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -342,15 +342,15 @@ void EnEncount2_DrawEffects(Actor* thisx, PlayState* play) { EnEncount2Effect* effect = this->effects; GraphicsContext* gfxCtx = play->state.gfxCtx; s16 i; - s32 objBankIndex; + s32 objectSlot; OPEN_DISPS(gfxCtx); - objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_EFC_STAR_FIELD); + objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_EFC_STAR_FIELD); - if (objBankIndex >= 0) { + if (objectSlot >= 0) { gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[objBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[objectSlot].segment); for (i = 0; i < EN_ENCOUNT2_EFFECT_COUNT; effect++, i++) { if (effect->isAlive) { diff --git a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c index dba05cc50..2ac40a2d6 100644 --- a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c +++ b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c @@ -60,23 +60,23 @@ void EnExItem_Init(Actor* thisx, PlayState* play) { // "What will come out?" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ なにがでるかな? ☆☆☆☆☆ %d\n" VT_RST, this->unusedParam); this->initPos = this->actor.world.pos; - this->getItemObjId = -1; + this->getItemObjectId = -1; switch (this->type) { case EXITEM_BOMB_BAG_BOWLING: case EXITEM_BOMB_BAG_COUNTER: - this->getItemObjId = OBJECT_GI_BOMBPOUCH; + this->getItemObjectId = OBJECT_GI_BOMBPOUCH; break; case EXITEM_HEART_PIECE_BOWLING: case EXITEM_HEART_PIECE_COUNTER: - this->getItemObjId = OBJECT_GI_HEARTS; + this->getItemObjectId = OBJECT_GI_HEARTS; break; case EXITEM_BOMBCHUS_BOWLING: case EXITEM_BOMBCHUS_COUNTER: - this->getItemObjId = OBJECT_GI_BOMB_2; + this->getItemObjectId = OBJECT_GI_BOMB_2; break; case EXITEM_BOMBS_BOWLING: case EXITEM_BOMBS_COUNTER: - this->getItemObjId = OBJECT_GI_BOMB_1; + this->getItemObjectId = OBJECT_GI_BOMB_1; break; case EXITEM_PURPLE_RUPEE_BOWLING: case EXITEM_PURPLE_RUPEE_COUNTER: @@ -85,7 +85,7 @@ void EnExItem_Init(Actor* thisx, PlayState* play) { case EXITEM_RED_RUPEE_CHEST: case EXITEM_13: case EXITEM_14: - this->getItemObjId = OBJECT_GI_RUPY; + this->getItemObjectId = OBJECT_GI_RUPY; break; case EXITEM_SMALL_KEY_CHEST: this->scale = 0.05f; @@ -96,16 +96,16 @@ void EnExItem_Init(Actor* thisx, PlayState* play) { case EXITEM_MAGIC_FIRE: case EXITEM_MAGIC_WIND: case EXITEM_MAGIC_DARK: - this->getItemObjId = OBJECT_GI_GODDESS; + this->getItemObjectId = OBJECT_GI_GODDESS; break; case EXITEM_BULLET_BAG: - this->getItemObjId = OBJECT_GI_DEKUPOUCH; + this->getItemObjectId = OBJECT_GI_DEKUPOUCH; } - if (this->getItemObjId >= 0) { - this->objectIdx = Object_GetIndex(&play->objectCtx, this->getItemObjId); + if (this->getItemObjectId >= 0) { + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, this->getItemObjectId); this->actor.draw = NULL; - if (this->objectIdx < 0) { + if (this->requiredObjectSlot < 0) { Actor_Kill(&this->actor); // "What?" osSyncPrintf("なにみの? %d\n", this->actor.params); @@ -120,14 +120,14 @@ void EnExItem_Init(Actor* thisx, PlayState* play) { void EnExItem_WaitForObject(EnExItem* this, PlayState* play) { s32 onCounter; - if (Object_IsLoaded(&play->objectCtx, this->objectIdx)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { // "End of transfer" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params, this); osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params, this); osSyncPrintf(VT_FGCOL(BLUE) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params, this); osSyncPrintf(VT_FGCOL(MAGENTA) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params, this); osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n\n" VT_RST, this->actor.params, this); - this->actor.objBankIndex = this->objectIdx; + this->actor.objectSlot = this->requiredObjectSlot; this->actor.draw = EnExItem_Draw; this->stopRotate = false; onCounter = false; diff --git a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h index b8e4d2712..6c6ff404a 100644 --- a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h +++ b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h @@ -12,7 +12,7 @@ typedef void (*EnExItemLightFunc)(Actor*, PlayState*, s32); typedef struct EnExItem { /* 0x0000 */ Actor actor; /* 0x014C */ EnExItemActionFunc actionFunc; - /* 0x0150 */ s16 getItemObjId; + /* 0x0150 */ s16 getItemObjectId; /* 0x0152 */ s16 type; /* 0x0152 */ s16 unusedParam; /* 0x0156 */ s16 giDrawId; @@ -23,7 +23,7 @@ typedef struct EnExItem { /* 0x0160 */ s16 killItem; /* 0x0164 */ f32 scale; /* 0x0168 */ f32 unkFloat; // set to the same value as scale, but unused - /* 0x016C */ s8 objectIdx; + /* 0x016C */ s8 requiredObjectSlot; /* 0x0170 */ Vec3f initPos; // unused /* 0x017C */ EnExItemLightFunc unk_17C; /* 0x0180 */ EnExItemLightFunc unk_180; diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index ac2fe3511..e35d3ac60 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -251,8 +251,8 @@ void EnFr_Init(Actor* thisx, PlayState* play) { ASSERT(0, "0", "../z_en_fr.c", 372); } - this->objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP); - if (this->objBankIndex < 0) { + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP); + if (this->requiredObjectSlot < 0) { Actor_Kill(&this->actor); osSyncPrintf(VT_COL(RED, WHITE)); // "There is no bank!!" @@ -278,7 +278,7 @@ void EnFr_Update(Actor* thisx, PlayState* play) { s32 frogIndex; s32 pad2; - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { this->actor.flags &= ~ACTOR_FLAG_4; frogIndex = this->actor.params - 1; sEnFrPointers.frogs[frogIndex] = this; diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.h b/src/overlays/actors/ovl_En_Fr/z_en_fr.h index c5425e6b2..530bb8f66 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.h +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.h @@ -39,7 +39,7 @@ typedef struct EnFr { /* 0x0354 */ EnFrActionFunc actionFunc; /* 0x0358 */ LightNode* lightNode; // Frogs light up during the Frog Song, specifically the frog with the next note. /* 0x035C */ LightInfo lightInfo; - /* 0x036A */ s8 objBankIndex; + /* 0x036A */ s8 requiredObjectSlot; /* 0x036C */ s32 jumpCounter; // cyclic clock used to time celebratory frog jumps every 4 frames when child song is played. /* 0x0370 */ s32 blinkTimer; // blinking timer /* 0x0374 */ EnFrBlinkFunc blinkFunc; // unique case of using a function pointer for blinking diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 5c54720f2..dafada3d2 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -16,7 +16,7 @@ typedef struct { /* 0x0010 */ Vec3f velocity; /* 0x001C */ Vec3f accel; /* 0x0028 */ char unk_28[0x4]; - /* 0x002C */ s16 primAlpha; // transparency in RGBA colour system + /* 0x002C */ s16 primAlpha; // transparency in RGBA color system /* 0x002E */ s16 primAlphaState; // 0: increasing (more opaque) 1: decreasing (more transparent) 2: collision /* 0x0030 */ f32 xyScale; /* 0x0034 */ f32 xyScaleTarget; @@ -42,7 +42,7 @@ typedef struct EnFz { /* 0x024C */ f32 iceSmokeFreezingSpawnHeight; // Height for Ice Smoke Spawn, only when freezing /* 0x0250 */ f32 unusedFloat; // Set to 135.0f /* 0x0254 */ f32 speedXZ; // Set to 4.0f when moving - /* 0x0258 */ u32 envAlpha; // transparency in RGBA colour system + /* 0x0258 */ u32 envAlpha; // transparency in RGBA color system /* 0x025C */ u16 unusedNum1; // Only set to 0 /* 0x025E */ u16 unusedNum2; // Set to either 0 when hidden or 4000 when growing /* 0x0260 */ u8 state; // 0 (hidden) 1 (growning/shrinking) 2 (full size) 3 (melting from fire) diff --git a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c index 1ada0baae..b329885f2 100644 --- a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c +++ b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c @@ -137,12 +137,12 @@ void EnGSwitch_Init(Actor* thisx, PlayState* play) { this->actor.scale.y = 0.45f; this->actor.scale.z = 0.25f; this->collider.info.bumper.dmgFlags = DMG_ARROW; - this->objId = OBJECT_TSUBO; - this->objIndex = Object_GetIndex(&play->objectCtx, this->objId); - if (this->objIndex < 0) { + this->objectId = OBJECT_TSUBO; + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, this->objectId); + if (this->requiredObjectSlot < 0) { Actor_Kill(&this->actor); // "what?" - osSyncPrintf(VT_FGCOL(MAGENTA) " なにみの? %d\n" VT_RST "\n", this->objIndex); + osSyncPrintf(VT_FGCOL(MAGENTA) " なにみの? %d\n" VT_RST "\n", this->requiredObjectSlot); // "bank is funny" osSyncPrintf(VT_FGCOL(CYAN) " バンクおかしいしぞ!%d\n" VT_RST "\n", this->actor.params); } @@ -198,9 +198,9 @@ void EnGSwitch_Break(EnGSwitch* this, PlayState* play) { } void EnGSwitch_WaitForObject(EnGSwitch* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objIndex].segment); - this->actor.objBankIndex = this->objIndex; + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->requiredObjectSlot].segment); + this->actor.objectSlot = this->requiredObjectSlot; this->actor.draw = EnGSwitch_DrawPot; this->actionFunc = EnGSwitch_ArcheryPot; } diff --git a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h index b79c6e456..3631d1170 100644 --- a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h +++ b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h @@ -46,7 +46,7 @@ typedef struct EnGSwitch { /* 0x0158 */ s16 colorIdx; /* 0x015A */ s16 broken; /* 0x015C */ s16 numEffects; - /* 0x015E */ s16 objId; + /* 0x015E */ s16 objectId; /* 0x0160 */ s16 index; // first or second rupee in two-rupee patterns /* 0x0162 */ s16 delayTimer; // delay between the two blue rupees appearing /* 0x0164 */ s16 waitTimer; // time rupee waits before retreating @@ -54,7 +54,7 @@ typedef struct EnGSwitch { /* 0x0168 */ s16 moveState; // Appear or retreat (for blue rupees and the stationary green one) /* 0x016A */ s16 noteIndex; /* 0x016C */ Vec3f targetPos; - /* 0x0178 */ s8 objIndex; + /* 0x0178 */ s8 requiredObjectSlot; /* 0x017C */ ColliderCylinder collider; /* 0x01C8 */ EnGSwitchEffect effects[EN_GSWITCH_EFFECT_COUNT]; } EnGSwitch; // size = 0x12F8 diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index 6dee49a5a..1a93d1a42 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -15,7 +15,7 @@ void EnGirlA_Update(Actor* thisx, PlayState* play); void EnGirlA_SetItemOutOfStock(PlayState* play, EnGirlA* this); void EnGirlA_UpdateStockedItem(PlayState* play, EnGirlA* this); -void EnGirlA_InitializeItemAction(EnGirlA* this, PlayState* play); +void EnGirlA_WaitForObject(EnGirlA* this, PlayState* play); void EnGirlA_Update2(EnGirlA* this, PlayState* play); void func_80A3C498(Actor* thisx, PlayState* play, s32 flags); void EnGirlA_Draw(Actor* thisx, PlayState* play); @@ -387,9 +387,9 @@ void EnGirlA_InitItem(EnGirlA* this, PlayState* play) { return; } - this->objBankIndex = Object_GetIndex(&play->objectCtx, shopItemEntries[params].objID); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, shopItemEntries[params].objID); - if (this->objBankIndex < 0) { + if (this->requiredObjectSlot < 0) { Actor_Kill(&this->actor); osSyncPrintf(VT_COL(RED, WHITE)); osSyncPrintf("バンクが無いよ!!(%s)\n", sShopItemDescriptions[params]); @@ -399,7 +399,7 @@ void EnGirlA_InitItem(EnGirlA* this, PlayState* play) { } this->actor.params = params; - this->actionFunc2 = EnGirlA_InitializeItemAction; + this->actionFunc2 = EnGirlA_WaitForObject; } void EnGirlA_Init(Actor* thisx, PlayState* play) { @@ -976,13 +976,13 @@ s32 EnGirlA_TrySetMaskItemDescription(EnGirlA* this, PlayState* play) { return false; } -void EnGirlA_InitializeItemAction(EnGirlA* this, PlayState* play) { +void EnGirlA_WaitForObject(EnGirlA* this, PlayState* play) { s16 params = this->actor.params; ShopItemEntry* itemEntry = &shopItemEntries[params]; - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.objBankIndex = this->objBankIndex; + this->actor.objectSlot = this->requiredObjectSlot; switch (this->actor.params) { case SI_KEATON_MASK: if (GET_ITEMGETINF(ITEMGETINF_38)) { diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h index 29d5d6682..65725c5c1 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h @@ -15,7 +15,7 @@ typedef struct EnGirlA { /* 0x0000 */ Actor actor; /* 0x014C */ SkelAnime skelAnime; /* 0x0190 */ EnGirlAActionFunc actionFunc; - /* 0x0194 */ s8 objBankIndex; + /* 0x0194 */ s8 requiredObjectSlot; /* 0x0198 */ EnGirlAActionFunc actionFunc2; /* 0x019C */ s32 isInitialized; /* 0x01A0 */ s16 itemBuyPromptTextId; diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index a9733228b..bc4d22ca7 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -70,9 +70,9 @@ void EnGm_Init(Actor* thisx, PlayState* play) { // "Medi Goron" osSyncPrintf(VT_FGCOL(GREEN) "%s[%d] : 中ゴロン[%d]" VT_RST "\n", "../z_en_gm.c", 133, this->actor.params); - this->objGmBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GM); + this->gmObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GM); - if (this->objGmBankIndex < 0) { + if (this->gmObjectSlot < 0) { osSyncPrintf(VT_COL(RED, WHITE)); // "There is no model bank! !! (Medi Goron)" osSyncPrintf("モデル バンクが無いよ!!(中ゴロン)\n"); @@ -102,10 +102,10 @@ s32 func_80A3D7C8(void) { } void func_80A3D838(EnGm* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objGmBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->gmObjectSlot)) { this->actor.flags &= ~ACTOR_FLAG_4; SkelAnime_InitFlex(play, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, 18); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objGmBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->gmObjectSlot].segment); Animation_Change(&this->skelAnime, &object_gm_Anim_0002B8, 1.0f, 0.0f, Animation_GetLastFrame(&object_gm_Anim_0002B8), ANIMMODE_LOOP, 0.0f); this->actor.draw = EnGm_Draw; @@ -274,7 +274,7 @@ void func_80A3DF60(EnGm* this, PlayState* play) { } void func_80A3DFBC(EnGm* this, PlayState* play) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objGmBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->gmObjectSlot].segment); this->timer++; this->actionFunc(this, play); this->actor.focus.rot.x = this->actor.world.rot.x; diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.h b/src/overlays/actors/ovl_En_Gm/z_en_gm.h index fd699d518..3cfedca01 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -17,7 +17,7 @@ typedef struct EnGm { /* 0x0268 */ EnGmUpdateFunc updateFunc; /* 0x026C */ EnGmActionFunc actionFunc; /* 0x0270 */ ColliderCylinder collider; - /* 0x02BC */ s8 objGmBankIndex; + /* 0x02BC */ s8 gmObjectSlot; /* 0x02BE */ s16 timer; /* 0x02C0 */ s16 blinkTimer; /* 0x02C2 */ u8 eyeTexIndex; diff --git a/src/overlays/actors/ovl_En_Guest/z_en_guest.c b/src/overlays/actors/ovl_En_Guest/z_en_guest.c index 28326ee0b..3a40b0a71 100644 --- a/src/overlays/actors/ovl_En_Guest/z_en_guest.c +++ b/src/overlays/actors/ovl_En_Guest/z_en_guest.c @@ -55,8 +55,8 @@ void EnGuest_Init(Actor* thisx, PlayState* play) { if (GET_INFTABLE(INFTABLE_76)) { Actor_Kill(&this->actor); } else { - this->osAnimeBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_OS_ANIME); - if (this->osAnimeBankIndex < 0) { + this->osAnimeObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_OS_ANIME); + if (this->osAnimeObjectSlot < 0) { osSyncPrintf(VT_COL(RED, WHITE)); // "No such bank!!" osSyncPrintf("%s[%d] : バンクが無いよ!!\n", "../z_en_guest.c", 129); @@ -76,13 +76,13 @@ void EnGuest_Update(Actor* thisx, PlayState* play) { EnGuest* this = (EnGuest*)thisx; s32 pad; - if (Object_IsLoaded(&play->objectCtx, this->osAnimeBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->osAnimeObjectSlot)) { this->actor.flags &= ~ACTOR_FLAG_4; Actor_ProcessInitChain(&this->actor, sInitChain); SkelAnime_InitFlex(play, &this->skelAnime, &object_boj_Skel_0000F0, NULL, this->jointTable, this->morphTable, 16); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->osAnimeBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->osAnimeObjectSlot].segment); Animation_Change(&this->skelAnime, &gObjOsAnim_42AC, 1.0f, 0.0f, Animation_GetLastFrame(&gObjOsAnim_42AC), ANIMMODE_LOOP, 0.0f); @@ -160,7 +160,7 @@ void func_80A505CC(Actor* thisx, PlayState* play) { func_80034F54(play, this->unk_2CC, this->unk_2EC, 16); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->osAnimeBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->osAnimeObjectSlot].segment); SkelAnime_Update(&this->skelAnime); Actor_SetFocus(&this->actor, 60.0f); diff --git a/src/overlays/actors/ovl_En_Guest/z_en_guest.h b/src/overlays/actors/ovl_En_Guest/z_en_guest.h index 2835a6d8c..6633f2741 100644 --- a/src/overlays/actors/ovl_En_Guest/z_en_guest.h +++ b/src/overlays/actors/ovl_En_Guest/z_en_guest.h @@ -20,7 +20,7 @@ typedef struct EnGuest { /* 0x02CA */ s16 unk_2CA; /* 0x02CC */ s16 unk_2CC[16]; /* 0x02EC */ s16 unk_2EC[16]; - /* 0x030C */ s8 osAnimeBankIndex; + /* 0x030C */ s8 osAnimeObjectSlot; /* 0x030D */ u8 unk_30D; /* 0x030E */ u8 unk_30E; } EnGuest; // size = 0x0310 diff --git a/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c b/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c index 3e275bc3b..d7919e3d3 100644 --- a/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c +++ b/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c @@ -838,7 +838,7 @@ void EnHeishi2_DrawKingGuard(Actor* thisx, PlayState* play) { void EnHeishi2_Draw(Actor* thisx, PlayState* play) { EnHeishi2* this = (EnHeishi2*)thisx; Mtx* mtx; - s32 linkObjBankIndex; + s32 linkChildObjectSlot; OPEN_DISPS(play->state.gfxCtx); @@ -847,17 +847,17 @@ void EnHeishi2_Draw(Actor* thisx, PlayState* play) { SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHeishi2_OverrideLimbDraw, EnHeishi2_PostLimbDraw, this); if ((this->type == 5) && GET_INFTABLE(INFTABLE_77)) { - linkObjBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_LINK_CHILD); - if (linkObjBankIndex >= 0) { + linkChildObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_LINK_CHILD); + if (linkChildObjectSlot >= 0) { Matrix_Put(&this->mtxf_330); Matrix_Translate(-570.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateZ(DEG_TO_RAD(70), MTXMODE_APPLY); mtx = Matrix_NewMtx(play->state.gfxCtx, "../z_en_heishi2.c", 1820) - 7; - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[linkObjBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[linkChildObjectSlot].segment); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); gSPDisplayList(POLY_OPA_DISP++, gLinkChildKeatonMaskDL); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->actor.objectSlot].segment); } } diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 319b7beab..7fad629bc 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -757,15 +757,15 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { this->actor.params &= ~0x8000; this->type = HORSE_HNI; - if ((this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_HNI)) < 0) { + if ((this->hniObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_HNI)) < 0) { Actor_Kill(&this->actor); return; } do { - } while (!Object_IsLoaded(&play->objectCtx, this->bankIndex)); + } while (!Object_IsLoaded(&play->objectCtx, this->hniObjectSlot)); - this->actor.objBankIndex = this->bankIndex; + this->actor.objectSlot = this->hniObjectSlot; Actor_SetObjectDependency(play, &this->actor); this->boostSpeed = 12; } else { diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.h b/src/overlays/actors/ovl_En_Horse/z_en_horse.h index 5a2f47f1b..785ddc8a9 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -97,7 +97,7 @@ typedef struct EnHorse { /* 0x0150 */ s32 noInputTimer; /* 0x0154 */ s32 noInputTimerMax; /* 0x0158 */ s32 type; - /* 0x015C */ s8 bankIndex; + /* 0x015C */ s8 hniObjectSlot; /* 0x0160 */ Skin skin; /* 0x01F0 */ u32 stateFlags; /* 0x01F4 */ Vec3f lastPos; diff --git a/src/overlays/actors/ovl_En_Hy/z_en_hy.c b/src/overlays/actors/ovl_En_Hy/z_en_hy.c index f05d2295e..e3e94ec05 100644 --- a/src/overlays/actors/ovl_En_Hy/z_en_hy.c +++ b/src/overlays/actors/ovl_En_Hy/z_en_hy.c @@ -207,9 +207,9 @@ static AnimationInfo sAnimationInfo[] = { typedef struct { /* 0x00 */ u8 headInfoIndex; // EnHyHeadIndex - /* 0x01 */ u8 skelInfoIndex2; // EnHySkeletonIndex, see EnHy.objBankIndexSkel2 + /* 0x01 */ u8 skelInfoIndex2; // EnHySkeletonIndex, see EnHy.objectSlotSkel2 /* 0x02 */ Color_RGBA8 envColorSeg8; - /* 0x06 */ u8 skelInfoIndex1; // EnHySkeletonIndex, see EnHy.objBankIndexSkel1 + /* 0x06 */ u8 skelInfoIndex1; // EnHySkeletonIndex, see EnHy.objectSlotSkel1 /* 0x07 */ Color_RGBA8 envColorSeg9; /* 0x0B */ u8 animInfoIndex; // EnHyAnimationIndex } EnHyModelInfo; // size = 0xC @@ -356,18 +356,18 @@ s32 EnHy_FindSkelAndHeadObjects(EnHy* this, PlayState* play) { u8 skelInfoIndex2 = sModelInfo[this->actor.params & 0x7F].skelInfoIndex2; u8 skelInfoIndex1 = sModelInfo[this->actor.params & 0x7F].skelInfoIndex1; - this->objBankIndexSkel1 = Object_GetIndex(&play->objectCtx, sSkeletonInfo[skelInfoIndex1].objectId); - if (this->objBankIndexSkel1 < 0) { + this->objectSlotSkel1 = Object_GetSlot(&play->objectCtx, sSkeletonInfo[skelInfoIndex1].objectId); + if (this->objectSlotSkel1 < 0) { return false; } - this->objBankIndexSkel2 = Object_GetIndex(&play->objectCtx, sSkeletonInfo[skelInfoIndex2].objectId); - if (this->objBankIndexSkel2 < 0) { + this->objectSlotSkel2 = Object_GetSlot(&play->objectCtx, sSkeletonInfo[skelInfoIndex2].objectId); + if (this->objectSlotSkel2 < 0) { return false; } - this->objBankIndexHead = Object_GetIndex(&play->objectCtx, sHeadInfo[headInfoIndex].objectId); - if (this->objBankIndexHead < 0) { + this->objectSlotHead = Object_GetSlot(&play->objectCtx, sHeadInfo[headInfoIndex].objectId); + if (this->objectSlotHead < 0) { return false; } @@ -375,15 +375,15 @@ s32 EnHy_FindSkelAndHeadObjects(EnHy* this, PlayState* play) { } s32 EnHy_AreSkelAndHeadObjectsLoaded(EnHy* this, PlayState* play) { - if (!Object_IsLoaded(&play->objectCtx, this->objBankIndexSkel1)) { + if (!Object_IsLoaded(&play->objectCtx, this->objectSlotSkel1)) { return false; } - if (!Object_IsLoaded(&play->objectCtx, this->objBankIndexSkel2)) { + if (!Object_IsLoaded(&play->objectCtx, this->objectSlotSkel2)) { return false; } - if (!Object_IsLoaded(&play->objectCtx, this->objBankIndexHead)) { + if (!Object_IsLoaded(&play->objectCtx, this->objectSlotHead)) { return false; } @@ -391,9 +391,9 @@ s32 EnHy_AreSkelAndHeadObjectsLoaded(EnHy* this, PlayState* play) { } s32 EnHy_FindOsAnimeObject(EnHy* this, PlayState* play) { - this->objBankIndexOsAnime = Object_GetIndex(&play->objectCtx, OBJECT_OS_ANIME); + this->objectSlotOsAnime = Object_GetSlot(&play->objectCtx, OBJECT_OS_ANIME); - if (this->objBankIndexOsAnime < 0) { + if (this->objectSlotOsAnime < 0) { return false; } @@ -401,7 +401,7 @@ s32 EnHy_FindOsAnimeObject(EnHy* this, PlayState* play) { } s32 EnHy_IsOsAnimeObjectLoaded(EnHy* this, PlayState* play) { - if (!Object_IsLoaded(&play->objectCtx, this->objBankIndexOsAnime)) { + if (!Object_IsLoaded(&play->objectCtx, this->objectSlotOsAnime)) { return false; } @@ -898,13 +898,13 @@ void EnHy_Destroy(Actor* thisx, PlayState* play) { void EnHy_InitImpl(EnHy* this, PlayState* play) { if (EnHy_IsOsAnimeObjectLoaded(this, play) && EnHy_AreSkelAndHeadObjectsLoaded(this, play)) { - this->actor.objBankIndex = this->objBankIndexSkel1; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->actor.objBankIndex].segment); + this->actor.objectSlot = this->objectSlotSkel1; + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->actor.objectSlot].segment); SkelAnime_InitFlex(play, &this->skelAnime, sSkeletonInfo[sModelInfo[this->actor.params & 0x7F].skelInfoIndex1].skeleton, NULL, this->jointTable, this->morphTable, 16); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndexOsAnime].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlotOsAnime].segment); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sColCylInit); EnHy_InitCollider(this); @@ -1082,7 +1082,7 @@ void EnHy_Update(Actor* thisx, PlayState* play) { EnHy* this = (EnHy*)thisx; if (this->actionFunc != EnHy_InitImpl) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndexOsAnime].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlotOsAnime].segment); SkelAnime_Update(&this->skelAnime); EnHy_UpdateEyes(this); @@ -1110,8 +1110,8 @@ s32 EnHy_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po OPEN_DISPS(play->state.gfxCtx); if (limbIndex == 15) { - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->objBankIndexHead].segment); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndexHead].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->objectSlotHead].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlotHead].segment); i = sModelInfo[this->actor.params & 0x7F].headInfoIndex; *dList = sHeadInfo[i].headDList; @@ -1120,7 +1120,7 @@ s32 EnHy_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(ptr)); } - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndexSkel1].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlotSkel1].segment); } if (limbIndex == 15) { @@ -1155,8 +1155,8 @@ void EnHy_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, OPEN_DISPS(play->state.gfxCtx); if (limbIndex == 7) { - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->objBankIndexSkel2].segment); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndexSkel2].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->objectSlotSkel2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlotSkel2].segment); } if ((this->actor.params & 0x7F) == ENHY_TYPE_BOJ_3 && limbIndex == 8) { diff --git a/src/overlays/actors/ovl_En_Hy/z_en_hy.h b/src/overlays/actors/ovl_En_Hy/z_en_hy.h index 086a4bf2e..760ed9dfe 100644 --- a/src/overlays/actors/ovl_En_Hy/z_en_hy.h +++ b/src/overlays/actors/ovl_En_Hy/z_en_hy.h @@ -39,10 +39,10 @@ typedef struct EnHy { /* 0x0190 */ EnHyActionFunc actionFunc; /* 0x0194 */ char unk_194; // unused /* 0x0195 */ u8 pathReverse; - /* 0x0196 */ s8 objBankIndexHead; - /* 0x0197 */ s8 objBankIndexSkel2; // 7 < limb < 15 (upper part?) (always same as objBankIndexSkel1) - /* 0x0198 */ s8 objBankIndexSkel1; // sets the object used when drawing the skeleton for limb <= 7 (lower part?) - /* 0x0199 */ s8 objBankIndexOsAnime; + /* 0x0196 */ s8 objectSlotHead; + /* 0x0197 */ s8 objectSlotSkel2; // 7 < limb < 15 (upper part?) (always same as objectSlotSkel1) + /* 0x0198 */ s8 objectSlotSkel1; // sets the object used when drawing the skeleton for limb <= 7 (lower part?) + /* 0x0199 */ s8 objectSlotOsAnime; /* 0x019C */ ColliderCylinder collider; /* 0x01E8 */ NpcInteractInfo interactInfo; /* 0x0210 */ Path* path; diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index 0fb828b99..ad727e411 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -928,7 +928,8 @@ void EnIk_PostLimbDrawEnemy(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* if (this->armorStatusFlag & ARMOR_BROKEN) { BodyBreak_SetInfo(&this->bodyBreak, limbIndex, IRON_KNUCKLE_LIMB_CHEST_ARMOR_FRONT, - IRON_KNUCKLE_LIMB_CHEST_ARMOR_BACK, IRON_KNUCKLE_LIMB_TORSO, dList, BODYBREAK_OBJECT_DEFAULT); + IRON_KNUCKLE_LIMB_CHEST_ARMOR_BACK, IRON_KNUCKLE_LIMB_TORSO, dList, + BODYBREAK_OBJECT_SLOT_DEFAULT); } if (limbIndex == IRON_KNUCKLE_LIMB_HELMET_ARMOR) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_en_ik_inFight.c", 1217), diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 9ce5e8089..aa4827d64 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -9,7 +9,7 @@ void EnIn_Destroy(Actor* thisx, PlayState* play); void EnIn_Update(Actor* thisx, PlayState* play); void EnIn_Draw(Actor* thisx, PlayState* play); -void func_80A79FB0(EnIn* this, PlayState* play); +void EnIn_WaitForObject(EnIn* this, PlayState* play); void func_80A7A304(EnIn* this, PlayState* play); void func_80A7A4C8(EnIn* this, PlayState* play); void func_80A7A568(EnIn* this, PlayState* play); @@ -481,8 +481,8 @@ void EnIn_Init(Actor* thisx, PlayState* play) { RespawnData* respawn = &gSaveContext.respawn[RESPAWN_MODE_DOWN]; Vec3f respawnPos; - this->ingoObjBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_IN); - if (this->ingoObjBankIndex < 0 && this->actor.params > 0) { + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_IN); + if (this->requiredObjectSlot < 0 && this->actor.params > 0) { this->actionFunc = NULL; Actor_Kill(&this->actor); return; @@ -493,21 +493,23 @@ void EnIn_Init(Actor* thisx, PlayState* play) { gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = 0; D_80A7B998 = 1; } - this->actionFunc = func_80A79FB0; + this->actionFunc = EnIn_WaitForObject; } void EnIn_Destroy(Actor* thisx, PlayState* play) { EnIn* this = (EnIn*)thisx; - if (this->actionFunc != NULL && this->actionFunc != func_80A79FB0) { + if (this->actionFunc != NULL && this->actionFunc != EnIn_WaitForObject) { Collider_DestroyCylinder(play, &this->collider); } } -void func_80A79FB0(EnIn* this, PlayState* play) { +// This function does not actually wait since it waits for OBJECT_IN, +// but the object is already loaded at this point from being set in the ActorInit data +void EnIn_WaitForObject(EnIn* this, PlayState* play) { s32 sp3C = 0; - if (Object_IsLoaded(&play->objectCtx, this->ingoObjBankIndex) || this->actor.params <= 0) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot) || this->actor.params <= 0) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_InitFlex(play, &this->skelAnime, &gIngoSkel, NULL, this->jointTable, this->morphTable, 20); Collider_InitCylinder(play, &this->collider); @@ -911,7 +913,7 @@ void EnIn_Update(Actor* thisx, PlayState* play) { ColliderCylinder* collider; EnIn* this = (EnIn*)thisx; - if (this->actionFunc == func_80A79FB0) { + if (this->actionFunc == EnIn_WaitForObject) { this->actionFunc(this, play); return; } @@ -1000,7 +1002,7 @@ void EnIn_Draw(Actor* thisx, PlayState* play) { EnIn* this = (EnIn*)thisx; OPEN_DISPS(play->state.gfxCtx); - if (this->actionFunc != func_80A79FB0) { + if (this->actionFunc != EnIn_WaitForObject) { Gfx_SetupDL_25Opa(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gIngoHeadGradient2Tex)); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.h b/src/overlays/actors/ovl_En_In/z_en_in.h index 2cf2668a4..57baa280d 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -38,7 +38,7 @@ typedef struct EnIn { /* 0x0190 */ EnInActionFunc actionFunc; /* 0x0194 */ ColliderCylinder collider; /* 0x01E0 */ f32 unk_1E0; - /* 0x01E4 */ s8 ingoObjBankIndex; + /* 0x01E4 */ s8 requiredObjectSlot; /* 0x01E6 */ s16 animationIdx; /* 0x01E8 */ s16 unk_1E8; /* 0x01EA */ s16 blinkTimer; diff --git a/src/overlays/actors/ovl_En_Ko/z_en_ko.c b/src/overlays/actors/ovl_En_Ko/z_en_ko.c index 48ae16c05..cbc8bd0ac 100644 --- a/src/overlays/actors/ovl_En_Ko/z_en_ko.c +++ b/src/overlays/actors/ovl_En_Ko/z_en_ko.c @@ -261,46 +261,46 @@ s32 EnKo_AreObjectsAvailable(EnKo* this, PlayState* play) { u8 bodyId = sModelInfo[ENKO_TYPE].bodyId; u8 legsId = sModelInfo[ENKO_TYPE].legsId; - this->legsObjectBankIdx = Object_GetIndex(&play->objectCtx, sSkeleton[legsId].objectId); - if (this->legsObjectBankIdx < 0) { + this->legsObjectSlot = Object_GetSlot(&play->objectCtx, sSkeleton[legsId].objectId); + if (this->legsObjectSlot < 0) { return false; } - this->bodyObjectBankIdx = Object_GetIndex(&play->objectCtx, sSkeleton[bodyId].objectId); - if (this->bodyObjectBankIdx < 0) { + this->bodyObjectSlot = Object_GetSlot(&play->objectCtx, sSkeleton[bodyId].objectId); + if (this->bodyObjectSlot < 0) { return false; } - this->headObjectBankIdx = Object_GetIndex(&play->objectCtx, sHead[headId].objectId); - if (this->headObjectBankIdx < 0) { + this->headObjectSlot = Object_GetSlot(&play->objectCtx, sHead[headId].objectId); + if (this->headObjectSlot < 0) { return false; } return true; } s32 EnKo_AreObjectsLoaded(EnKo* this, PlayState* play) { - if (!Object_IsLoaded(&play->objectCtx, this->legsObjectBankIdx)) { + if (!Object_IsLoaded(&play->objectCtx, this->legsObjectSlot)) { return false; } - if (!Object_IsLoaded(&play->objectCtx, this->bodyObjectBankIdx)) { + if (!Object_IsLoaded(&play->objectCtx, this->bodyObjectSlot)) { return false; } - if (!Object_IsLoaded(&play->objectCtx, this->headObjectBankIdx)) { + if (!Object_IsLoaded(&play->objectCtx, this->headObjectSlot)) { return false; } return true; } s32 EnKo_IsOsAnimeAvailable(EnKo* this, PlayState* play) { - this->osAnimeBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_OS_ANIME); - if (this->osAnimeBankIndex < 0) { + this->osAnimeObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_OS_ANIME); + if (this->osAnimeObjectSlot < 0) { return false; } return true; } s32 EnKo_IsOsAnimeLoaded(EnKo* this, PlayState* play) { - if (!Object_IsLoaded(&play->objectCtx, this->osAnimeBankIndex)) { + if (!Object_IsLoaded(&play->objectCtx, this->osAnimeObjectSlot)) { return false; } return true; @@ -1163,12 +1163,12 @@ void EnKo_Destroy(Actor* thisx, PlayState* play) { void func_80A99048(EnKo* this, PlayState* play) { if (EnKo_IsOsAnimeLoaded(this, play) && EnKo_AreObjectsLoaded(this, play)) { this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.objBankIndex = this->legsObjectBankIdx; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->actor.objBankIndex].segment); + this->actor.objectSlot = this->legsObjectSlot; + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->actor.objectSlot].segment); SkelAnime_InitFlex(play, &this->skelAnime, sSkeleton[sModelInfo[ENKO_TYPE].legsId].flexSkeletonHeader, NULL, this->jointTable, this->morphTable, 16); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->osAnimeBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->osAnimeObjectSlot].segment); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); @@ -1283,7 +1283,7 @@ void EnKo_Update(Actor* thisx, PlayState* play) { if (this->actionFunc != func_80A99048) { if ((s32)this->modelAlpha != 0) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->osAnimeBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->osAnimeObjectSlot].segment); SkelAnime_Update(&this->skelAnime); func_80A98DB4(this, play); EnKo_Blink(this); @@ -1315,8 +1315,8 @@ s32 EnKo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po s32 pad; if (limbIndex == 15) { - gSPSegment((*gfx)++, 0x06, play->objectCtx.status[this->headObjectBankIdx].segment); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->headObjectBankIdx].segment); + gSPSegment((*gfx)++, 0x06, play->objectCtx.slots[this->headObjectSlot].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->headObjectSlot].segment); headId = sModelInfo[ENKO_TYPE].headId; *dList = sHead[headId].dList; @@ -1324,7 +1324,7 @@ s32 EnKo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po eyeTexture = sHead[headId].eyeTextures[this->eyeTextureIndex]; gSPSegment((*gfx)++, 0x0A, SEGMENTED_TO_VIRTUAL(eyeTexture)); } - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->legsObjectBankIdx].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->legsObjectSlot].segment); } if (limbIndex == 8) { limbRot = this->interactInfo.torsoRot; @@ -1351,8 +1351,8 @@ void EnKo_PostLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3s* rot, Vec3f D_80A9A774 = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 7) { - gSPSegment((*gfx)++, 0x06, play->objectCtx.status[this->bodyObjectBankIdx].segment); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->bodyObjectBankIdx].segment); + gSPSegment((*gfx)++, 0x06, play->objectCtx.slots[this->bodyObjectSlot].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->bodyObjectSlot].segment); } if (limbIndex == 15) { Matrix_MultVec3f(&D_80A9A774, &this->actor.focus.pos); diff --git a/src/overlays/actors/ovl_En_Ko/z_en_ko.h b/src/overlays/actors/ovl_En_Ko/z_en_ko.h index 2828b067b..a33ac3e38 100644 --- a/src/overlays/actors/ovl_En_Ko/z_en_ko.h +++ b/src/overlays/actors/ovl_En_Ko/z_en_ko.h @@ -12,10 +12,10 @@ typedef struct EnKo { /* 0x0000 */ Actor actor; /* 0x014C */ SkelAnime skelAnime; /* 0x0190 */ EnKoActionFunc actionFunc; - /* 0x0194 */ s8 headObjectBankIdx; - /* 0x0195 */ s8 bodyObjectBankIdx; - /* 0x0196 */ s8 legsObjectBankIdx; - /* 0x0197 */ s8 osAnimeBankIndex; + /* 0x0194 */ s8 headObjectSlot; + /* 0x0195 */ s8 bodyObjectSlot; + /* 0x0196 */ s8 legsObjectSlot; + /* 0x0197 */ s8 osAnimeObjectSlot; /* 0x0198 */ ColliderCylinder collider; /* 0x01E4 */ Path* path; /* 0x01E8 */ NpcInteractInfo interactInfo; diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 48d8cefdc..193725512 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -20,7 +20,7 @@ void EnKusa_Update(Actor* thisx, PlayState* play); void EnKusa_Draw(Actor* thisx, PlayState* play); void EnKusa_SetupLiftedUp(EnKusa* this); -void EnKusa_SetupWaitObject(EnKusa* this); +void EnKusa_SetupWaitForObject(EnKusa* this); void EnKusa_SetupMain(EnKusa* this); void EnKusa_SetupFall(EnKusa* this); void EnKusa_SetupCut(EnKusa* this); @@ -28,7 +28,7 @@ void EnKusa_SetupUprootedWaitRegrow(EnKusa* this); void EnKusa_SetupRegrow(EnKusa* this); void EnKusa_Fall(EnKusa* this, PlayState* play); -void EnKusa_WaitObject(EnKusa* this, PlayState* play); +void EnKusa_WaitForObject(EnKusa* this, PlayState* play); void EnKusa_Main(EnKusa* this, PlayState* play); void EnKusa_LiftedUp(EnKusa* this, PlayState* play); void EnKusa_CutWaitRegrow(EnKusa* this, PlayState* play); @@ -253,16 +253,16 @@ void EnKusa_Init(Actor* thisx, PlayState* play) { return; } - this->objBankIndex = Object_GetIndex(&play->objectCtx, sObjectIds[thisx->params & 3]); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, sObjectIds[thisx->params & 3]); - if (this->objBankIndex < 0) { + if (this->requiredObjectSlot < 0) { // "Bank danger!" osSyncPrintf("Error : バンク危険! (arg_data 0x%04x)(%s %d)\n", thisx->params, "../z_en_kusa.c", 561); Actor_Kill(&this->actor); return; } - EnKusa_SetupWaitObject(this); + EnKusa_SetupWaitForObject(this); } void EnKusa_Destroy(Actor* thisx, PlayState* play2) { @@ -272,12 +272,12 @@ void EnKusa_Destroy(Actor* thisx, PlayState* play2) { Collider_DestroyCylinder(play, &this->collider); } -void EnKusa_SetupWaitObject(EnKusa* this) { - EnKusa_SetupAction(this, EnKusa_WaitObject); +void EnKusa_SetupWaitForObject(EnKusa* this) { + EnKusa_SetupAction(this, EnKusa_WaitForObject); } -void EnKusa_WaitObject(EnKusa* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { +void EnKusa_WaitForObject(EnKusa* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { if (this->actor.flags & ACTOR_FLAG_ENKUSA_CUT) { EnKusa_SetupCut(this); } else { @@ -285,7 +285,7 @@ void EnKusa_WaitObject(EnKusa* this, PlayState* play) { } this->actor.draw = EnKusa_Draw; - this->actor.objBankIndex = this->objBankIndex; + this->actor.objectSlot = this->requiredObjectSlot; this->actor.flags &= ~ACTOR_FLAG_4; } } diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h index 3a922ebce..8c8423223 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h @@ -19,7 +19,7 @@ typedef struct EnKusa { /* 0x014C */ EnKusaActionFunc actionFunc; /* 0x0150 */ ColliderCylinder collider; /* 0x019C */ s16 timer; - /* 0x019E */ s8 objBankIndex; + /* 0x019E */ s8 requiredObjectSlot; } EnKusa; // size = 0x01A0 #endif diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index d18d2d544..c7333c415 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -262,9 +262,9 @@ void EnMag_Update(Actor* thisx, PlayState* play) { } } -void EnMag_DrawTextureI8(Gfx** gfxp, void* texture, s16 texWidth, s16 texHeight, s16 rectLeft, s16 rectTop, +void EnMag_DrawTextureI8(Gfx** gfxP, void* texture, s16 texWidth, s16 texHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy) { - Gfx* gfx = *gfxp; + Gfx* gfx = *gfxP; gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_I, G_IM_SIZ_8b, texWidth, texHeight, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -272,13 +272,13 @@ void EnMag_DrawTextureI8(Gfx** gfxp, void* texture, s16 texWidth, s16 texHeight, gSPTextureRectangle(gfx++, WIDE_INCR(rectLeft, (u16)WIDE_GET_4_3) << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, WIDE_DIV(dsdx, WIDE_GET_RATIO), dtdy); - *gfxp = gfx; + *gfxP = gfx; } -void EnMag_DrawEffectTextures(Gfx** gfxp, void* maskTex, void* effectTex, s16 maskWidth, s16 maskHeight, +void EnMag_DrawEffectTextures(Gfx** gfxP, void* maskTex, void* effectTex, s16 maskWidth, s16 maskHeight, s16 effectWidth, s16 effectHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, u16 shifts, u16 shiftt, u16 flag, EnMag* this) { - Gfx* gfx = *gfxp; + Gfx* gfx = *gfxP; gDPLoadMultiBlock_4b(gfx++, maskTex, 0x0000, G_TX_RENDERTILE, G_IM_FMT_I, maskWidth, maskHeight, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, @@ -294,11 +294,11 @@ void EnMag_DrawEffectTextures(Gfx** gfxp, void* maskTex, void* effectTex, s16 ma gSPTextureRectangle(gfx++, WIDE_INCR(rectLeft, (u16)(WIDE_GET_16_9 * 10.0f)) << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, WIDE_DIV(dsdx, WIDE_GET_RATIO), dtdy); - *gfxp = gfx; + *gfxP = gfx; } -void EnMag_DrawImageRGBA32(Gfx** gfxp, s16 centerX, s16 centerY, u8* source, u32 width, u32 height) { - Gfx* gfx = *gfxp; +void EnMag_DrawImageRGBA32(Gfx** gfxP, s16 centerX, s16 centerY, u8* source, u32 width, u32 height) { + Gfx* gfx = *gfxP; u8* curTexture; s32 textureCount; u32 rectLeft; @@ -353,11 +353,11 @@ void EnMag_DrawImageRGBA32(Gfx** gfxp, s16 centerX, s16 centerY, u8* source, u32 } } - *gfxp = gfx; + *gfxP = gfx; } -void EnMag_DrawCharTexture(Gfx** gfxp, u8* texture, s32 rectLeft, s32 rectTop) { - Gfx* gfx = *gfxp; +void EnMag_DrawCharTexture(Gfx** gfxP, u8* texture, s32 rectLeft, s32 rectTop) { + Gfx* gfx = *gfxP; YREG(0) = 1024.0f / (YREG(1) / 100.0f); YREG(2) = 16.0f * (YREG(1) / 100.0f); @@ -368,10 +368,10 @@ void EnMag_DrawCharTexture(Gfx** gfxp, u8* texture, s32 rectLeft, s32 rectTop) { gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + YREG(2)) << 2, (rectTop + YREG(2)) << 2, G_TX_RENDERTILE, 0, 0, WIDE_DIV(YREG(0), WIDE_GET_RATIO), YREG(0)); - *gfxp = gfx; + *gfxP = gfx; } -void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxp) { +void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxP) { static s16 textAlpha = 0; static s16 textFadeDirection = 0; static s16 textFadeTimer = 0; @@ -389,12 +389,12 @@ void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxp) { EnMag* this = (EnMag*)thisx; Font* font = &this->font; s32 pad; - Gfx* gfx = *gfxp; + Gfx* gfx = *gfxP; u16 i, j, k; u16 rectLeft; u16 rectTop; - gSPSegment(gfx++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment); + gSPSegment(gfx++, 0x06, play->objectCtx.slots[this->actor.objectSlot].segment); Gfx_SetupDL_39Ptr(&gfx); @@ -559,7 +559,7 @@ void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxp) { } } - *gfxp = gfx; + *gfxP = gfx; } void EnMag_Draw(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Mb/z_en_mb.c b/src/overlays/actors/ovl_En_Mb/z_en_mb.c index 3046a0cf3..4f5afaef3 100644 --- a/src/overlays/actors/ovl_En_Mb/z_en_mb.c +++ b/src/overlays/actors/ovl_En_Mb/z_en_mb.c @@ -604,7 +604,7 @@ void EnMb_Stunned(EnMb* this, PlayState* play) { if ((player->stateFlags2 & PLAYER_STATE2_7) && player->actor.parent == &this->actor) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); this->attack = ENMB_ATTACK_NONE; } @@ -721,7 +721,7 @@ void EnMb_SpearPatrolEndCharge(EnMb* this, PlayState* play) { if ((player->stateFlags2 & PLAYER_STATE2_7) && player->actor.parent == &this->actor) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); } @@ -936,7 +936,7 @@ void EnMb_SpearPatrolPrepareAndCharge(EnMb* this, PlayState* play) { hasHitPlayer = true; player->actor.world.pos.z = this->actor.world.pos.z + Math_SinS(this->actor.shape.rot.y) * 10.0f + Math_CosS(this->actor.shape.rot.y) * 89.0f; - player->unk_850 = 0; + player->actionVar2 = 0; player->actor.speed = 0.0f; player->actor.velocity.y = 0.0f; } @@ -947,7 +947,7 @@ void EnMb_SpearPatrolPrepareAndCharge(EnMb* this, PlayState* play) { if (player->stateFlags2 & PLAYER_STATE2_7) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); } } @@ -1005,7 +1005,7 @@ void EnMb_SpearPatrolImmediateCharge(EnMb* this, PlayState* play) { hasHitPlayer = true; player->actor.world.pos.z = this->actor.world.pos.z + Math_SinS(this->actor.shape.rot.y) * 10.0f + Math_CosS(this->actor.shape.rot.y) * 89.0f; - player->unk_850 = 0; + player->actionVar2 = 0; player->actor.speed = 0.0f; player->actor.velocity.y = 0.0f; } @@ -1016,7 +1016,7 @@ void EnMb_SpearPatrolImmediateCharge(EnMb* this, PlayState* play) { if (player->stateFlags2 & PLAYER_STATE2_7) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); } this->attack = ENMB_ATTACK_NONE; @@ -1298,7 +1298,7 @@ void EnMb_SpearDead(EnMb* this, PlayState* play) { if ((player->stateFlags2 & PLAYER_STATE2_7) && player->actor.parent == &this->actor) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); this->attack = ENMB_ATTACK_NONE; } @@ -1381,7 +1381,7 @@ void EnMb_CheckColliding(EnMb* this, PlayState* play) { if ((player->stateFlags2 & PLAYER_STATE2_7) && player->actor.parent == &this->actor) { player->stateFlags2 &= ~PLAYER_STATE2_7; player->actor.parent = NULL; - player->unk_850 = 200; + player->actionVar2 = 200; func_8002F71C(play, &this->actor, 6.0f, this->actor.world.rot.y, 6.0f); } this->damageEffect = this->actor.colChkInfo.damageEffect; diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index 93d3e322b..16d3cdf9d 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -179,7 +179,7 @@ void EnMm_Init(Actor* thisx, PlayState* play) { this->actor.targetMode = 2; this->actor.gravity = -1.0f; this->speedXZ = 3.0f; - this->unk_204 = this->actor.objBankIndex; + this->unk_204 = this->actor.objectSlot; if (func_80AADA70() == 1) { this->mouthTexIndex = RM_MOUTH_OPEN; @@ -524,10 +524,10 @@ void EnMm_Draw(Actor* thisx, PlayState* play) { EnMm_OverrideLimbDraw, EnMm_PostLimbDraw, this); if (GET_ITEMGETINF(ITEMGETINF_3B)) { - s32 linkChildObjBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_LINK_CHILD); + s32 linkChildObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_LINK_CHILD); // Draw Bunny Hood - if (linkChildObjBankIndex >= 0) { + if (linkChildObjectSlot >= 0) { Mtx* mtx; Vec3s earRot; Mtx* mtx2; @@ -537,7 +537,7 @@ void EnMm_Draw(Actor* thisx, PlayState* play) { Matrix_Put(&this->unk_208); mtx2 = Matrix_NewMtx(play->state.gfxCtx, "../z_en_mm.c", 1111); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[linkChildObjBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[linkChildObjectSlot].segment); gSPSegment(POLY_OPA_DISP++, 0x0B, mtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx2 - 7); @@ -558,7 +558,7 @@ void EnMm_Draw(Actor* thisx, PlayState* play) { Matrix_ToMtx(mtx, "../z_en_mm.c", 1131); gSPDisplayList(POLY_OPA_DISP++, gLinkChildBunnyHoodDL); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->actor.objectSlot].segment); } } diff --git a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c index 9d47b71bd..073239fdd 100644 --- a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c +++ b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c @@ -70,9 +70,9 @@ void EnNiwLady_Init(Actor* thisx, PlayState* play) { s32 pad; EnNiwLady* this = (EnNiwLady*)thisx; - this->objectAneIndex = Object_GetIndex(&play->objectCtx, OBJECT_ANE); - this->objectOsAnimeIndex = Object_GetIndex(&play->objectCtx, OBJECT_OS_ANIME); - if ((this->objectOsAnimeIndex < 0) || (this->objectAneIndex < 0)) { + this->aneObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_ANE); + this->osAnimeObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_OS_ANIME); + if ((this->osAnimeObjectSlot < 0) || (this->aneObjectSlot < 0)) { Actor_Kill(thisx); return; } @@ -153,11 +153,11 @@ void func_80AB9F24(EnNiwLady* this, PlayState* play) { f32 frames; s32 pad; - if (Object_IsLoaded(&play->objectCtx, this->objectAneIndex) && - Object_IsLoaded(&play->objectCtx, this->objectOsAnimeIndex)) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objectAneIndex].segment); + if (Object_IsLoaded(&play->objectCtx, this->aneObjectSlot) && + Object_IsLoaded(&play->objectCtx, this->osAnimeObjectSlot)) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->aneObjectSlot].segment); SkelAnime_InitFlex(play, &this->skelAnime, &gCuccoLadySkel, NULL, this->jointTable, this->morphTable, 16); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objectOsAnimeIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->osAnimeObjectSlot].segment); this->unk_27E = 1; this->actor.gravity = -3.0f; Actor_SetScale(&this->actor, 0.01f); @@ -507,8 +507,8 @@ void EnNiwLady_Update(Actor* thisx, PlayState* play) { if (this->unk_276 == 0) { Math_SmoothStepToS(&this->headRot.y, 0, 5, 3000, 0); } - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objectOsAnimeIndex].segment); - if (this->objectOsAnimeIndex >= 0) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->osAnimeObjectSlot].segment); + if (this->osAnimeObjectSlot >= 0) { if (this->unk_27E != 0) { if (this->unk_26E != 0) { this->unk_26E--; @@ -517,8 +517,8 @@ void EnNiwLady_Update(Actor* thisx, PlayState* play) { } SkelAnime_Update(&this->skelAnime); } - this->objectAneIndex = Object_GetIndex(&play->objectCtx, OBJECT_ANE); - if (this->objectAneIndex >= 0) { + this->aneObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_ANE); + if (this->aneObjectSlot >= 0) { this->actionFunc(this, play); if (this->unusedTimer2 != 0) { this->unusedTimer2--; diff --git a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.h b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.h index f50f66494..7ecb165cc 100644 --- a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.h +++ b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.h @@ -35,8 +35,8 @@ typedef struct EnNiwLady { /* 0x027A */ s16 unk_27A; /* 0x027C */ s16 faceState; /* 0x027E */ s16 unk_27E; - /* 0x0280 */ s8 objectAneIndex; - /* 0x0281 */ s8 objectOsAnimeIndex; + /* 0x0280 */ s8 aneObjectSlot; + /* 0x0281 */ s8 osAnimeObjectSlot; /* 0x0284 */ s32 getItemId; /* 0x0288 */ NpcInteractInfo interactInfo; /* 0x02B0 */ ColliderCylinder collider; diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index 91790c3af..147dd9b3c 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -54,7 +54,7 @@ static ColliderCylinderInit sCylinderInit = { { 13, 13, 0, { 0 } }, }; -static s16 sObjectIDs[] = { +static s16 sObjectIds[] = { OBJECT_DEKUNUTS, OBJECT_HINTNUTS, OBJECT_SHOPNUTS, OBJECT_DNS, OBJECT_DNK, }; @@ -69,9 +69,9 @@ void EnNutsball_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 400.0f, ActorShadow_DrawCircle, 13.0f); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - this->objBankIndex = Object_GetIndex(&play->objectCtx, sObjectIDs[this->actor.params]); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, sObjectIds[this->actor.params]); - if (this->objBankIndex < 0) { + if (this->requiredObjectSlot < 0) { Actor_Kill(&this->actor); } else { this->actionFunc = func_80ABBB34; @@ -85,8 +85,8 @@ void EnNutsball_Destroy(Actor* thisx, PlayState* play) { } void func_80ABBB34(EnNutsball* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { - this->actor.objBankIndex = this->objBankIndex; + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->actor.objectSlot = this->requiredObjectSlot; this->actor.draw = EnNutsball_Draw; this->actor.shape.rot.y = 0; this->timer = 30; diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.h b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.h index 5a59e27d9..4dff4fa55 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.h +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.h @@ -11,7 +11,7 @@ typedef void (*EnNutsballActionFunc)(struct EnNutsball*, PlayState*); typedef struct EnNutsball { /* 0x0000 */ Actor actor; /* 0x014C */ EnNutsballActionFunc actionFunc; - /* 0x0150 */ s8 objBankIndex; + /* 0x0150 */ s8 requiredObjectSlot; /* 0x0152 */ s16 timer; /* 0x0154 */ ColliderCylinder collider; } EnNutsball; // size = 0x01A0 diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 342df4880..567b08b17 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -74,7 +74,7 @@ void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* this, PlayState* play) { void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, PlayState* play) { CutsceneFlags_Unset(play, 5); - if (((play->pauseCtx.state == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + if (((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->msgCtx.msgLength == 0) && #ifdef ENABLE_FRAMERATE_OPTIONS (!FrameAdvance_IsEnabled(play)) && diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index c7eafc0a2..c74a036a6 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -549,20 +549,20 @@ void EnOssan_UpdateCameraDirection(EnOssan* this, PlayState* play, f32 cameraFac s32 EnOssan_TryGetObjBankIndices(EnOssan* this, PlayState* play, s16* objectIds) { if (objectIds[1] != OBJECT_ID_MAX) { - this->objBankIndex2 = Object_GetIndex(&play->objectCtx, objectIds[1]); - if (this->objBankIndex2 < 0) { + this->objectSlot2 = Object_GetSlot(&play->objectCtx, objectIds[1]); + if (this->objectSlot2 < 0) { return false; } } else { - this->objBankIndex2 = -1; + this->objectSlot2 = -1; } if (objectIds[2] != OBJECT_ID_MAX) { - this->objBankIndex3 = Object_GetIndex(&play->objectCtx, objectIds[2]); - if (this->objBankIndex3 < 0) { + this->objectSlot3 = Object_GetSlot(&play->objectCtx, objectIds[2]); + if (this->objectSlot3 < 0) { return false; } } else { - this->objBankIndex3 = -1; + this->objectSlot3 = -1; } return true; } @@ -604,9 +604,9 @@ void EnOssan_Init(Actor* thisx, PlayState* play) { } objectIds = sShopkeeperObjectIds[this->actor.params]; - this->objBankIndex1 = Object_GetIndex(&play->objectCtx, objectIds[0]); + this->objectSlot1 = Object_GetSlot(&play->objectCtx, objectIds[0]); - if (this->objBankIndex1 < 0) { + if (this->objectSlot1 < 0) { Actor_Kill(&this->actor); osSyncPrintf(VT_COL(RED, WHITE)); osSyncPrintf("バンクが無いよ!!(%s)\n", sShopkeeperPrintName[this->actor.params]); @@ -1975,11 +1975,11 @@ void EnOssan_Blink(EnOssan* this) { } s32 EnOssan_AreShopkeeperObjectsLoaded(EnOssan* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex1)) { - if (this->objBankIndex2 >= 0 && !Object_IsLoaded(&play->objectCtx, this->objBankIndex2)) { + if (Object_IsLoaded(&play->objectCtx, this->objectSlot1)) { + if (this->objectSlot2 >= 0 && !Object_IsLoaded(&play->objectCtx, this->objectSlot2)) { return false; } - if (this->objBankIndex3 >= 0 && !Object_IsLoaded(&play->objectCtx, this->objBankIndex3)) { + if (this->objectSlot3 >= 0 && !Object_IsLoaded(&play->objectCtx, this->objectSlot3)) { return false; } return true; @@ -1995,7 +1995,7 @@ void EnOssan_InitBazaarShopkeeper(EnOssan* this, PlayState* play) { void EnOssan_InitKokiriShopkeeper(EnOssan* this, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gKm1Skel, NULL, NULL, NULL, 0); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndex3].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlot3].segment); Animation_Change(&this->skelAnime, &object_masterkokiri_Anim_0004A8, 1.0f, 0.0f, Animation_GetLastFrame(&object_masterkokiri_Anim_0004A8), 0, 0.0f); this->actor.draw = EnOssan_DrawKokiriShopkeeper; @@ -2006,7 +2006,7 @@ void EnOssan_InitKokiriShopkeeper(EnOssan* this, PlayState* play) { void EnOssan_InitGoronShopkeeper(EnOssan* this, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gGoronSkel, NULL, NULL, NULL, 0); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndex3].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlot3].segment); Animation_Change(&this->skelAnime, &gGoronShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGoronShopkeeperAnim), 0, 0.0f); this->actor.draw = EnOssan_DrawGoronShopkeeper; @@ -2015,7 +2015,7 @@ void EnOssan_InitGoronShopkeeper(EnOssan* this, PlayState* play) { void EnOssan_InitZoraShopkeeper(EnOssan* this, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gZoraSkel, NULL, NULL, NULL, 0); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndex3].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlot3].segment); Animation_Change(&this->skelAnime, &gZoraShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gZoraShopkeeperAnim), 0, 0.0f); this->actor.draw = EnOssan_DrawZoraShopkeeper; @@ -2108,7 +2108,7 @@ void EnOssan_InitActionFunc(EnOssan* this, PlayState* play) { if (EnOssan_AreShopkeeperObjectsLoaded(this, play)) { this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.objBankIndex = this->objBankIndex1; + this->actor.objectSlot = this->objectSlot1; Actor_SetObjectDependency(play, &this->actor); this->shelves = (EnTana*)Actor_Find(&play->actorCtx, ACTOR_EN_TANA, ACTORCAT_PROP); @@ -2198,7 +2198,7 @@ void EnOssan_InitActionFunc(EnOssan* this, PlayState* play) { } void EnOssan_Obj3ToSeg6(EnOssan* this, PlayState* play) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndex3].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlot3].segment); } void EnOssan_MainActionFunc(EnOssan* this, PlayState* play) { @@ -2365,8 +2365,8 @@ s32 EnOssan_OverrideLimbDrawKokiriShopkeeper(PlayState* play, s32 limbIndex, Gfx OPEN_DISPS(play->state.gfxCtx); if (limbIndex == 15) { - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->objBankIndex2].segment); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objBankIndex2].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->objectSlot2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->objectSlot2].segment); *dList = gKokiriShopkeeperHeadDL; gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(sKokiriShopkeeperEyeTextures[this->eyeTextureIdx])); } diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index 03538fbb6..236e47e86 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -41,9 +41,9 @@ typedef struct EnOssan { /* 0x0198 */ ColliderCylinder collider; // unused /* 0x01E4 */ s16 timer; /* 0x01E6 */ s16 delayTimer; - /* 0x01E8 */ s8 objBankIndex1; - /* 0x01E9 */ s8 objBankIndex2; - /* 0x01EA */ s8 objBankIndex3; + /* 0x01E8 */ s8 objectSlot1; + /* 0x01E9 */ s8 objectSlot2; + /* 0x01EA */ s8 objectSlot3; /* 0x01EB */ u8 happyMaskShopState; /* 0x01EC */ u8 happyMaskShopkeeperEyeIdx; /* 0x01EE */ s16 headRot; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index 0da6751c8..9a7eaaf46 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -230,16 +230,16 @@ void EnPoh_Init(Actor* thisx, PlayState* play) { } } if (this->actor.params < EN_POH_SHARP) { - this->objectIdx = Object_GetIndex(&play->objectCtx, OBJECT_POH); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_POH); this->infoIdx = EN_POH_INFO_NORMAL; this->actor.naviEnemyId = NAVI_ENEMY_POE; } else { - this->objectIdx = Object_GetIndex(&play->objectCtx, OBJECT_PO_COMPOSER); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_PO_COMPOSER); this->infoIdx = EN_POH_INFO_COMPOSER; this->actor.naviEnemyId = NAVI_ENEMY_POE_COMPOSER; } this->info = &sPoeInfo[this->infoIdx]; - if (this->objectIdx < 0) { + if (this->requiredObjectSlot < 0) { Actor_Kill(&this->actor); } } @@ -712,14 +712,14 @@ void func_80ADF894(EnPoh* this, PlayState* play) { } void EnPoh_Death(EnPoh* this, PlayState* play) { - s32 objId; + s32 objectId; if (this->unk_198 != 0) { this->unk_198--; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - objId = (this->infoIdx == EN_POH_INFO_COMPOSER) ? OBJECT_PO_COMPOSER : OBJECT_POH; - EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, objId, 10, + objectId = (this->infoIdx == EN_POH_INFO_COMPOSER) ? OBJECT_PO_COMPOSER : OBJECT_POH; + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, objectId, 10, this->info->lanternDisplayList); func_80ADE6D4(this); } else if (this->unk_198 == 0) { @@ -906,8 +906,8 @@ void EnPoh_UpdateVisibility(EnPoh* this) { void EnPoh_Update(Actor* thisx, PlayState* play) { EnPoh* this = (EnPoh*)thisx; - if (Object_IsLoaded(&play->objectCtx, this->objectIdx)) { - this->actor.objBankIndex = this->objectIdx; + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->actor.objectSlot = this->requiredObjectSlot; this->actor.update = EnPoh_UpdateLiving; Actor_SetObjectDependency(play, &this->actor); if (this->infoIdx == EN_POH_INFO_NORMAL) { diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.h b/src/overlays/actors/ovl_En_Poh/z_en_poh.h index 8c57fd512..1a44a60e8 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.h +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.h @@ -41,7 +41,7 @@ typedef struct EnPoh { /* 0x0190 */ EnPohActionFunc actionFunc; /* 0x0194 */ u8 unk_194; /* 0x0195 */ u8 unk_195; - /* 0x0196 */ s8 objectIdx; + /* 0x0196 */ s8 requiredObjectSlot; /* 0x0197 */ u8 infoIdx; /* 0x0198 */ s16 unk_198; /* 0x019A */ s16 visibilityTimer; diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index 10831f79d..fb61fbf8c 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -476,7 +476,7 @@ void EnSb_Update(Actor* thisx, PlayState* play) { void EnSb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { EnSb* this = (EnSb*)thisx; - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 6, 8, dList, BODYBREAK_OBJECT_DEFAULT); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 6, 8, dList, BODYBREAK_OBJECT_SLOT_DEFAULT); } void EnSb_Draw(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index ed6de74f6..9a55effdf 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -558,9 +558,9 @@ void EnSkb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Collider_UpdateSpheres(limbIndex, &this->collider); if ((this->breakFlags ^ 1) == 0) { - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 11, 12, 18, dList, BODYBREAK_OBJECT_DEFAULT); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 11, 12, 18, dList, BODYBREAK_OBJECT_SLOT_DEFAULT); } else if ((this->breakFlags ^ (this->breakFlags | 4)) == 0) { - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 18, 18, dList, BODYBREAK_OBJECT_DEFAULT); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 18, 18, dList, BODYBREAK_OBJECT_SLOT_DEFAULT); } } diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 9411bd674..175427bb5 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -17,7 +17,7 @@ void EnSth_Update(Actor* thisx, PlayState* play); void EnSth_Update2(Actor* thisx, PlayState* play); void EnSth_Draw(Actor* thisx, PlayState* play); -void EnSth_WaitForObjectLoaded(EnSth* this, PlayState* play); +void EnSth_WaitForObject(EnSth* this, PlayState* play); void EnSth_ParentRewardObtainedWait(EnSth* this, PlayState* play); void EnSth_RewardUnobtainedWait(EnSth* this, PlayState* play); void EnSth_ChildRewardObtainedWait(EnSth* this, PlayState* play); @@ -97,7 +97,7 @@ void EnSth_Init(Actor* thisx, PlayState* play) { s16 objectId; s32 params = this->actor.params; - s32 objectBankIdx; + s32 objectSlot; osSyncPrintf(VT_FGCOL(BLUE) "金スタル屋 no = %d\n" VT_RST, params); // "Gold Skulltula Shop" if (this->actor.params == 0) { @@ -116,19 +116,19 @@ void EnSth_Init(Actor* thisx, PlayState* play) { objectId = sObjectIds[params]; if (objectId != 1) { - objectBankIdx = Object_GetIndex(&play->objectCtx, objectId); + objectSlot = Object_GetSlot(&play->objectCtx, objectId); } else { - objectBankIdx = 0; + objectSlot = 0; } - osSyncPrintf("bank_ID = %d\n", objectBankIdx); - if (objectBankIdx < 0) { + osSyncPrintf("bank_ID = %d\n", objectSlot); + if (objectSlot < 0) { ASSERT(0, "0", "../z_en_sth.c", 1564); } - this->objectBankIdx = objectBankIdx; + this->requiredObjectSlot = objectSlot; this->drawFunc = EnSth_Draw; Actor_SetScale(&this->actor, 0.01f); - EnSth_SetupAction(this, EnSth_WaitForObjectLoaded); + EnSth_SetupAction(this, EnSth_WaitForObject); this->actor.draw = NULL; this->unk_2B2 = 0; this->actor.targetMode = 6; @@ -150,7 +150,7 @@ void EnSth_SetupAfterObjectLoaded(EnSth* this, PlayState* play) { s16* params; EnSth_SetupShapeColliderUpdate2AndDraw(this, play); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objectBankIdx].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->requiredObjectSlot].segment); SkelAnime_InitFlex(play, &this->skelAnime, sSkeletons[this->actor.params], NULL, this->jointTable, this->morphTable, 16); Animation_PlayLoop(&this->skelAnime, sAnimations[this->actor.params]); @@ -170,9 +170,9 @@ void EnSth_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void EnSth_WaitForObjectLoaded(EnSth* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objectBankIdx)) { - this->actor.objBankIndex = this->objectBankIdx; +void EnSth_WaitForObject(EnSth* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->actor.objectSlot = this->requiredObjectSlot; this->actionFunc = EnSth_SetupAfterObjectLoaded; } } @@ -389,7 +389,7 @@ void EnSth_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objectBankIdx].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->requiredObjectSlot].segment); Gfx_SetupDL_37Opa(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.h b/src/overlays/actors/ovl_En_Sth/z_en_sth.h index dec16c4e1..9408c542d 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.h +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.h @@ -16,7 +16,7 @@ typedef struct EnSth { /* 0x023C */ Vec3s morphTable[16]; /* 0x029C */ u16 eventFlag; /* 0x02A0 */ ActorFunc drawFunc; - /* 0x02A4 */ u8 objectBankIdx; + /* 0x02A4 */ u8 requiredObjectSlot; /* 0x02A6 */ Vec3s headRot; /* 0x02AC */ Vec3s unk_2AC; /* 0x02B2 */ u16 unk_2B2; diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 08a86d165..8e744d0ce 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -1865,7 +1865,7 @@ void EnTest_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot s32 pad; Vec3f sp50; - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 60, 60, dList, BODYBREAK_OBJECT_DEFAULT); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 60, 60, dList, BODYBREAK_OBJECT_SLOT_DEFAULT); if (limbIndex == STALFOS_LIMB_SWORD) { Matrix_MultVec3f(&D_8086467C, &this->swordCollider.dim.quad[1]); diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index df2f85bf8..45fd5eb3a 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -980,7 +980,7 @@ void EnTite_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** limbDList, Vec3s* break; } - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 24, 24, limbDList, BODYBREAK_OBJECT_DEFAULT); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 24, 24, limbDList, BODYBREAK_OBJECT_SLOT_DEFAULT); } void EnTite_Draw(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c index 658837590..72df80a4f 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -123,7 +123,7 @@ void EnViewer_InitAnimGanondorfOrZelda(EnViewer* this, PlayState* play, void* sk SkelAnime_Init(play, &this->skin.skelAnime, skeletonHeaderSeg, NULL, NULL, NULL, 0); } - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->animObjBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->animObjectSlot].segment); if (type == ENVIEWER_TYPE_3_GANONDORF || type == ENVIEWER_TYPE_7_GANONDORF || type == ENVIEWER_TYPE_8_GANONDORF || type == ENVIEWER_TYPE_9_GANONDORF) { Animation_PlayLoopSetSpeed(&this->skin.skelAnime, anim, 1.0f); @@ -134,7 +134,7 @@ void EnViewer_InitAnimGanondorfOrZelda(EnViewer* this, PlayState* play, void* sk void EnViewer_InitAnimImpa(EnViewer* this, PlayState* play, void* skeletonHeaderSeg, AnimationHeader* anim) { SkelAnime_InitFlex(play, &this->skin.skelAnime, skeletonHeaderSeg, NULL, NULL, NULL, 0); - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->animObjBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->animObjectSlot].segment); Animation_PlayLoopSetSpeed(&this->skin.skelAnime, anim, 3.0f); } @@ -167,21 +167,21 @@ static ActorShadowFunc sShadowDrawFuncs[] = { void EnViewer_InitImpl(EnViewer* this, PlayState* play) { EnViewerInitData* initData = &sInitData[this->actor.params >> 8]; - s32 skelObjBankIndex = Object_GetIndex(&play->objectCtx, initData->skeletonObject); + s32 skelObjectSlot = Object_GetSlot(&play->objectCtx, initData->skeletonObject); - ASSERT(skelObjBankIndex >= 0, "bank_ID >= 0", "../z_en_viewer.c", 576); + ASSERT(skelObjectSlot >= 0, "bank_ID >= 0", "../z_en_viewer.c", 576); - this->animObjBankIndex = Object_GetIndex(&play->objectCtx, initData->animObject); - ASSERT(this->animObjBankIndex >= 0, "this->anime_bank_ID >= 0", "../z_en_viewer.c", 579); + this->animObjectSlot = Object_GetSlot(&play->objectCtx, initData->animObject); + ASSERT(this->animObjectSlot >= 0, "this->anime_bank_ID >= 0", "../z_en_viewer.c", 579); - if (!Object_IsLoaded(&play->objectCtx, skelObjBankIndex) || - !Object_IsLoaded(&play->objectCtx, this->animObjBankIndex)) { + if (!Object_IsLoaded(&play->objectCtx, skelObjectSlot) || + !Object_IsLoaded(&play->objectCtx, this->animObjectSlot)) { this->actor.flags &= ~ACTOR_FLAG_6; return; } this->isVisible = true; - this->actor.objBankIndex = skelObjBankIndex; + this->actor.objectSlot = skelObjectSlot; Actor_SetObjectDependency(play, &this->actor); Actor_SetScale(&this->actor, initData->scale / 100.0f); ActorShape_Init(&this->actor.shape, initData->yOffset * 100, sShadowDrawFuncs[initData->shadowType], @@ -487,7 +487,7 @@ void EnViewer_UpdateImpl(EnViewer* this, PlayState* play) { void EnViewer_Update(Actor* thisx, PlayState* play) { EnViewer* this = (EnViewer*)thisx; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->animObjBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->animObjectSlot].segment); this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h index c24e0ff83..fee5fe762 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h @@ -89,7 +89,7 @@ typedef enum { typedef struct EnViewer { /* 0x0000 */ Actor actor; /* 0x014C */ Skin skin; - /* 0x01DC */ s8 animObjBankIndex; + /* 0x01DC */ s8 animObjectSlot; /* 0x01DD */ u8 drawFuncIndex; /* 0x01E0 */ EnViewerActionFunc actionFunc; /* 0x01E4 */ u8 unused; diff --git a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c index c6c521beb..730f9f427 100644 --- a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c +++ b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c @@ -589,9 +589,9 @@ void EnZl2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, } void func_80B4FCCC(EnZl2* this, PlayState* play) { - s32 unk_274 = this->unk_274; + s32 objectSlot = this->zl2Anime1ObjectSlot; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[unk_274].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); } void func_80B4FD00(EnZl2* this, AnimationHeader* animation, u8 arg2, f32 morphFrames, s32 arg4) { @@ -1605,16 +1605,16 @@ void func_80B52114(EnZl2* this, PlayState* play) { void func_80B521A0(EnZl2* this, PlayState* play) { s32 pad; ObjectContext* objectCtx = &play->objectCtx; - s32 bankIndex = Object_GetIndex(objectCtx, OBJECT_ZL2_ANIME1); + s32 objectSlot = Object_GetSlot(objectCtx, OBJECT_ZL2_ANIME1); s32 pad2; - if (bankIndex < 0) { + if (objectSlot < 0) { osSyncPrintf(VT_FGCOL(RED) "En_Zl2_main_bankアニメーションのバンクを読めない!!!!!!!!!!!!\n" VT_RST); return; } - if (Object_IsLoaded(objectCtx, bankIndex)) { - this->unk_274 = bankIndex; + if (Object_IsLoaded(objectCtx, objectSlot)) { + this->zl2Anime1ObjectSlot = objectSlot; func_80B4FCCC(this, play); this->unk_278 = Animation_GetLastFrame(&gZelda2Anime1Anim_0022D0); func_80B52114(this, play); diff --git a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.h b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.h index 51a620c54..c477ea57e 100644 --- a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.h +++ b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.h @@ -35,7 +35,7 @@ typedef struct EnZl2 { /* 0x0258 */ char unk_258[0xC]; /* 0x0264 */ s32 overrideLimbDrawConfig; /* 0x0268 */ char unk_268[0xC]; - /* 0x0274 */ s32 unk_274; + /* 0x0274 */ s32 zl2Anime1ObjectSlot; /* 0x0278 */ f32 unk_278; /* 0x027C */ f32 unk_27C; } EnZl2; // size = 0x0280 diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c index 915fe09ce..086f94c3d 100644 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -757,9 +757,9 @@ s32 func_80B54DD4(EnZl3* this) { } void func_80B54DE0(EnZl3* this, PlayState* play) { - s32 idx = this->unk_318; + s32 objectSlot = this->zl2Anime2ObjectSlot; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[idx].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); } void func_80B54E14(EnZl3* this, AnimationHeader* animation, u8 arg2, f32 morphFrames, s32 arg4) { @@ -2643,17 +2643,17 @@ void func_80B59B6C(EnZl3* this, PlayState* play) { void func_80B59DB8(EnZl3* this, PlayState* play) { s32 pad; - ObjectContext* objCtx = &play->objectCtx; - s32 objIndex = Object_GetIndex(objCtx, OBJECT_ZL2_ANIME2); + ObjectContext* objectCtx = &play->objectCtx; + s32 objectSlot = Object_GetSlot(objectCtx, OBJECT_ZL2_ANIME2); s32 pad2; - if (objIndex < 0) { + if (objectSlot < 0) { osSyncPrintf(VT_FGCOL(RED) "En_Zl3_main_bankアニメーションのバンクを読めない!!!!!!!!!!!!\n" VT_RST); return; } - if (Object_IsLoaded(objCtx, objIndex)) { - this->unk_318 = objIndex; + if (Object_IsLoaded(objectCtx, objectSlot)) { + this->zl2Anime2ObjectSlot = objectSlot; func_80B54DE0(this, play); func_80B59B6C(this, play); } diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.h b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.h index e7634ec6f..25c336f42 100644 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.h +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.h @@ -36,7 +36,7 @@ typedef struct EnZl3 { /* 0x030C */ Path* unk_30C; /* 0x0310 */ s32 unk_310; /* 0x0314 */ s32 unk_314; - /* 0x0318 */ s32 unk_318; + /* 0x0318 */ s32 zl2Anime2ObjectSlot; /* 0x031C */ Vec3f unk_31C; /* 0x0328 */ s32 unk_328; /* 0x032C */ Vec3f unk_32C; diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 45493adf1..a0af401a0 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -22,10 +22,10 @@ void Fishing_DrawFish(Actor* thisx, PlayState* play); void Fishing_DrawOwner(Actor* thisx, PlayState* play); typedef struct { - /* 0x00 */ u8 unk_00; + /* 0x00 */ u8 isLoach; /* 0x02 */ Vec3s pos; - /* 0x08 */ u8 unk_08; - /* 0x0C */ f32 unk_0C; + /* 0x08 */ u8 baseLength; + /* 0x0C */ f32 perception; } FishingFishInit; // size = 0x10 typedef enum { @@ -50,12 +50,10 @@ typedef struct { /* 0x25 */ u8 timer; /* 0x26 */ char unk_26[0x04]; /* 0x2A */ s16 alpha; - /* 0x2C */ s16 unk_2C; - /* 0x2E */ s16 unk_2E; - /* 0x30 */ f32 unk_30; - /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; - /* 0x3C */ f32 unk_3C; + /* 0x2C */ s16 state; + /* 0x2E */ s16 alphaMax; + /* 0x30 */ f32 scale; + /* 0x34 */ Vec3f rot; } FishingEffect; // size = 0x40 #define POND_PROP_COUNT 140 @@ -100,10 +98,10 @@ typedef struct { /* 0x00 */ u8 type; /* 0x02 */ s16 timer; /* 0x04 */ Vec3f pos; - /* 0x10 */ Vec3f unk_10; + /* 0x10 */ Vec3f homePos; /* 0x1C */ Vec3f projectedPos; - /* 0x28 */ f32 unk_28; - /* 0x2C */ f32 unk_2C; + /* 0x28 */ f32 velY; + /* 0x2C */ f32 scaleX; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; /* 0x38 */ f32 unk_38; @@ -114,6 +112,12 @@ typedef struct { /* 0x44 */ u8 shouldDraw; } FishingGroupFish; // size = 0x48 +typedef enum { + /* 0x00 */ FS_LURE_STOCK, + /* 0x01 */ FS_LURE_UNK, // hinted at with an "== 1" + /* 0x02 */ FS_LURE_SINKING +} FishingLureTypes; + #define LINE_SEG_COUNT 200 #define SINKING_LURE_SEG_COUNT 20 @@ -129,41 +133,47 @@ ActorInit Fishing_InitVars = { (ActorFunc)Fishing_DrawFish, }; -static f32 D_80B7A650 = 0.0f; +static f32 sStormStrength = 0.0f; -static u8 D_80B7A654 = 0; +static u8 sStormStrengthTarget = 0; -static f32 D_80B7A658 = 0.0f; +static f32 sFishingStormShade = 0.0f; -static Vec3f D_80B7A65C = { 0.0f, 0.0f, 0.0f }; +static Vec3f sFishingStormSfxPos = { 0.0f, 0.0f, 0.0f }; -static f32 D_80B7A668 = 0.0f; +static f32 sStormSfxFreqScale = 0.0f; static u8 sSinkingLureLocation = 0; -static f32 D_80B7A670 = 0.0f; +static f32 sFishOnHandLength = 0.0f; -static u8 D_80B7A674 = true; +static u8 sIsRodVisible = true; -static u16 D_80B7A678 = 0; +static u16 sFishLengthToWeigh = 0; -static u8 D_80B7A67C = 0; +static u8 sFishingCaughtTextDelay = 0; -static s32 D_80B7A680 = 0; +static s32 sFishingTimePlayed = 0; -static s16 D_80B7A684 = 0; +static s16 sOwnerTheftTimer = 0; -static u8 D_80B7A688 = 0; -static u8 D_80B7A68C = 0; -static u8 D_80B7A690 = 0; +typedef enum { + /* 0x00 */ FS_OWNER_BALD, + /* 0x01 */ FS_OWNER_CAPPED, + /* 0x02 */ FS_OWNER_HAIR +} FishingOwnerHair; -static s16 D_80B7A694 = 0; +static u8 sOwnerHair = FS_OWNER_BALD; +static u8 sIsOwnersHatHooked = false; // hat is on fishing hook +static u8 sIsOwnersHatSunk = false; // hat is sinking into pond. + +static s16 sRodCastState = 0; static Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; static u8 D_80B7A6A4 = 0; -static f32 D_80B7A6A8 = 0.0f; +static f32 sRodBendRotY = 0.0f; static f32 D_80B7A6AC = 0.0f; static f32 D_80B7A6B0 = 0.0f; static f32 D_80B7A6B4 = 0.0f; @@ -171,12 +181,12 @@ static f32 D_80B7A6B8 = 0.0f; static f32 D_80B7A6BC = 0.0f; static f32 D_80B7A6C0 = 0.0f; -static s16 D_80B7A6C4 = 0; -static s16 D_80B7A6C8 = 0; +static s16 sStickAdjXPrev = 0; +static s16 sStickAdjYPrev = 0; -static u8 D_80B7A6CC = 0; -static u8 D_80B7A6D0 = 0; -static u8 D_80B7A6D4 = 0; +static u8 sFishingPlayerCinematicState = 0; +static u8 sFishingCinematicTimer = 0; +static u8 sSinkingLureFound = false; static ColliderJntSphElementInit sJntSphElementsInit[12] = { { @@ -326,81 +336,81 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -static f32 D_80B7A898 = 0.0f; +static f32 sFishGroupVar = 0.0f; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -static Vec3f D_80B7A8A8 = { 0.0f, 0.0f, 2000.0f }; +static Vec3f sUnusedVec = { 0.0f, 0.0f, 2000.0f }; static Fishing* sFishingMain; -static u8 D_80B7E074; +static u8 sReelLock; static u8 sLinkAge; -static u8 D_80B7E076; -static u8 D_80B7E077; -static f32 D_80B7E078; -static u8 D_80B7E07C; -static u8 D_80B7E07D; -static u8 D_80B7E07E; -static s16 D_80B7E080; -static u8 D_80B7E082; -static u16 D_80B7E084; -static u16 D_80B7E086; -static s8 D_80B7E088; +static u8 sFishingFoggy; +static u8 sStormChanceTimer; +static f32 sFishingRecordLength; +static u8 sFishOnHandIsLoach; +static u8 sFishGameNumber; // increments for each purchased play. effects weather +static u8 sLureCaughtWith; +static s16 sFishFightTime; +static u8 sPondOwnerTextIdIndex; +static u16 sFishesCaught; +static u16 sFishingCaughtTextId; +static s8 sLureCameraZoomLevel; static Vec3f sOwnerHeadPos; -static Vec3s sEffOwnerHatRot; -static u8 D_80B7E0A2; -static s16 D_80B7E0A4; -static s16 D_80B7E0A6; +static Vec3s sEffOwnersHatRot; +static u8 sLureMoveDelay; // a small delay between the lure hitting the water, and being able to reel. +static s16 sRumbleDelay; +static s16 sFishingMusicDelay; static Fishing* sFishingHookedFish; -static s16 D_80B7E0AC; -static s16 D_80B7E0AE; +static s16 sFishingPlayingState; +static s16 sLureTimer; // AND'd for various effects/checks static s16 D_80B7E0B0; static s16 D_80B7E0B2; -static s16 D_80B7E0B4; -static u8 D_80B7E0B6; +static s16 sRodCastTimer; // used for the inital line casting +static u8 sLureEquipped; static Vec3f sLurePos; -static Vec3f D_80B7E0C8; +static Vec3f sLureDrawPos; static Vec3f sLureRot; -static Vec3f D_80B7E0E8; -static Vec3f D_80B7E0F8; -static f32 D_80B7E104; -static f32 D_80B7E108; -static f32 D_80B7E10C; -static f32 D_80B7E110; +static Vec3f sLurePosDelta; +static Vec3f sLureCastDelta; +static f32 sLure1Rotate; // lure type 1 is programmed to change this. +static f32 sLurePosZOffset; +static f32 sLureRotXTarget; +static f32 sLureRotXStep; static s8 D_80B7E114; -static s16 D_80B7E116; +static s16 sRodPullback; // holding A+Down to keep the fish on line static u8 D_80B7E118; -static f32 D_80B7E11C; -static u8 D_80B7E120; -static s16 D_80B7E122; -static u8 D_80B7E124; -static Vec3f D_80B7E128; -static f32 D_80B7E134; -static f32 D_80B7E138; -static s16 D_80B7E13C; -static f32 D_80B7E140; -static f32 D_80B7E144; +static f32 sRodReelingSpeed; +static u8 sWiggleAttraction; +static s16 sLureBitTimer; +static u8 sLineHooked; +static Vec3f sLureLineSegPosDelta; +static f32 sLureWiggleRotYTarget; +static f32 sLureWigglePosY; +static s16 sLureWiggleRotY; +static f32 sLureWiggleSign; // +/-1.0f +static f32 sRodLineSpooled; // 200 represents the full spool. static f32 D_80B7E148; -static f32 D_80B7E14C; +static f32 sFishingLineScale; static s16 D_80B7E150; -static f32 D_80B7E154; +static f32 sReelLinePosStep; static Vec3f sRodTipPos; static Vec3f sReelLinePos[LINE_SEG_COUNT]; static Vec3f sReelLineRot[LINE_SEG_COUNT]; static Vec3f sReelLineUnk[LINE_SEG_COUNT]; static Vec3f sLureHookRefPos[2]; static f32 sLureHookRotY[2]; -static u8 D_80B7FDA8; +static u8 sRodHitTimer; // brief timer for bending rod when line is snapped static Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; -static s16 D_80B7FEA0; +static s16 sSinkingLureSegmentIndex; static f32 sProjectedW; static Vec3f sSubCamEye; static Vec3f sSubCamAt; static s16 sSubCamId; -static f32 D_80B7FEC8; +static f32 sCatchCamX; static f32 sSubCamVelFactor; static f32 D_80B7FED0; static Vec3f sSinkingLureBasePos; -static f32 D_80B7FEE4; +static f32 sSinkingLureHeldY; // the lure going to its mark when being held up. static s32 sRandSeed0; static s32 sRandSeed1; static s32 sRandSeed2; @@ -462,7 +472,7 @@ s16 Fishing_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step) { return stepSize; } -void Fishing_SpawnRipple(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 arg3, f32 arg4, s16 arg5, +void Fishing_SpawnRipple(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale, f32 rotX, s16 alpha, s16 countLimit) { s16 i; @@ -476,18 +486,18 @@ void Fishing_SpawnRipple(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, effect->pos = *pos; effect->vel = sZeroVec; effect->accel = sZeroVec; - effect->unk_30 = arg3 * 0.0025f; - effect->unk_34 = arg4 * 0.0025f; + effect->scale = scale * 0.0025f; + effect->rot.x = rotX * 0.0025f; - if (arg3 > 300.0f) { + if (scale > 300.0f) { effect->alpha = 0; - effect->unk_2E = arg5; - effect->unk_2C = 0; - effect->unk_38 = (effect->unk_34 - effect->unk_30) * 0.05f; + effect->alphaMax = alpha; + effect->state = 0; + effect->rot.y = (effect->rot.x - effect->scale) * 0.05f; } else { - effect->alpha = arg5; - effect->unk_2C = 1; - effect->unk_38 = (effect->unk_34 - effect->unk_30) * 0.1f; + effect->alpha = alpha; + effect->state = 1; + effect->rot.y = (effect->rot.x - effect->scale) * 0.1f; } break; } @@ -512,7 +522,7 @@ void Fishing_SpawnDustSplash(Vec3f* projectedPos, FishingEffect* effect, Vec3f* effect->vel = *vel; effect->accel = accel; effect->alpha = 100 + (s16)Rand_ZeroFloat(100.0f); - effect->unk_30 = scale; + effect->scale = scale; break; } @@ -536,8 +546,8 @@ void Fishing_SpawnWaterDust(Vec3f* projectedPos, FishingEffect* effect, Vec3f* p effect->accel = accel; effect->alpha = 255; effect->timer = (s16)Rand_ZeroFloat(100.0f); - effect->unk_30 = scale; - effect->unk_34 = 2.0f * scale; + effect->scale = scale; + effect->rot.x = 2.0f * scale; break; } @@ -545,7 +555,7 @@ void Fishing_SpawnWaterDust(Vec3f* projectedPos, FishingEffect* effect, Vec3f* p } } -void Fishing_SpawnBubble(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale, u8 arg4) { +void Fishing_SpawnBubble(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale, u8 state) { s16 i; Vec3f vel = { 0.0f, 1.0f, 0.0f }; @@ -560,8 +570,8 @@ void Fishing_SpawnBubble(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, effect->vel = vel; effect->accel = sZeroVec; effect->timer = (s16)Rand_ZeroFloat(100.0f); - effect->unk_30 = scale; - effect->unk_2C = arg4; + effect->scale = scale; + effect->state = state; break; } @@ -584,9 +594,9 @@ void Fishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { effect->type = FS_EFF_RAIN_DROP; effect->pos = *pos; effect->accel = sZeroVec; - effect->unk_34 = rot->x; - effect->unk_38 = rot->y; - effect->unk_3C = rot->z; + effect->rot.x = rot->x; + effect->rot.y = rot->y; + effect->rot.z = rot->z; Matrix_RotateY(rot->y, MTXMODE_NEW); Matrix_RotateX(rot->x, MTXMODE_APPLY); Matrix_MultVec3f(&velSrc, &effect->vel); @@ -826,13 +836,13 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { sLinkAge = gSaveContext.save.linkAge; } - if (thisx->params < 100) { - D_80B7E074 = 0; + if (thisx->params < EN_FISH_PARAM) { + sReelLock = 0; sFishingMain = this; Collider_InitJntSph(play, &sFishingMain->collider); Collider_SetJntSph(play, &sFishingMain->collider, thisx, &sJntSphInit, sFishingMain->colliderElements); - thisx->params = 1; + thisx->params = EN_FISH_OWNER; SkelAnime_InitFlex(play, &this->skelAnime, &gFishingOwnerSkel, &gFishingOwnerAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingOwnerAnim, 0.0f); @@ -852,55 +862,55 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { thisx->flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; if (sLinkAge != LINK_AGE_CHILD) { - if (HIGH_SCORE(HS_FISHING) & 0x1000) { - D_80B7A688 = 0; + if (HIGH_SCORE(HS_FISHING) & HS_FISH_STOLE_HAT) { + sOwnerHair = FS_OWNER_BALD; } else { - D_80B7A688 = 1; + sOwnerHair = FS_OWNER_CAPPED; } } else { - D_80B7A688 = 2; + sOwnerHair = FS_OWNER_HAIR; } - D_80B7A684 = 20; + sOwnerTheftTimer = 20; play->specialEffects = sEffects; gTimeSpeed = 1; - D_80B7E0AC = 0; - D_80B7E0A6 = 10; + sFishingPlayingState = 0; + sFishingMusicDelay = 10; SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); if (sLinkAge == LINK_AGE_CHILD) { - if ((HIGH_SCORE(HS_FISHING) & 0x7F) != 0) { - D_80B7E078 = HIGH_SCORE(HS_FISHING) & 0x7F; + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_CHILD) != 0) { + sFishingRecordLength = HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_CHILD; } else { - D_80B7E078 = 40.0f; + sFishingRecordLength = 40.0f; // 6 lbs } } else { - if ((HIGH_SCORE(HS_FISHING) & 0x7F000000) != 0) { - D_80B7E078 = (HIGH_SCORE(HS_FISHING) & 0x7F000000) >> 0x18; + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_ADULT) != 0) { + sFishingRecordLength = (HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_ADULT) >> 0x18; } else { - D_80B7E078 = 45.0f; + sFishingRecordLength = 45.0f; // 7 lbs } } - D_80B7E07D = (HIGH_SCORE(HS_FISHING) & 0xFF0000) >> 0x10; - if ((D_80B7E07D & 7) == 7) { + sFishGameNumber = (HIGH_SCORE(HS_FISHING) & (HS_FISH_PLAYED * 255)) >> 0x10; + if ((sFishGameNumber & 7) == 7) { play->roomCtx.unk_74[0] = 90; - D_80B7E076 = 1; + sFishingFoggy = 1; } else { play->roomCtx.unk_74[0] = 40; - D_80B7E076 = 0; + sFishingFoggy = 0; } - if (((D_80B7E07D & 7) == 6) || (KREG(3) != 0)) { - D_80B7E077 = 100; + if (((sFishGameNumber & 7) == 6) || (KREG(3) != 0)) { + sStormChanceTimer = 100; if (KREG(3) != 0) { KREG(3) = 0; - HIGH_SCORE(HS_FISHING) &= 0xFF00FFFF; - HIGH_SCORE(HS_FISHING) |= 0x60000; + HIGH_SCORE(HS_FISHING) &= ~(HS_FISH_PLAYED * 255); + HIGH_SCORE(HS_FISHING) |= (HS_FISH_PLAYED * 6); } } else { - D_80B7E077 = 0; + sStormChanceTimer = 0; } for (i = 0; i < FISHING_EFFECT_COUNT; i++) { @@ -921,17 +931,17 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { fish->type = FS_GROUP_FISH_NORMAL; if (i <= 20) { - fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle1) * 720.0f; - fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle1) * 720.0f; + fish->homePos.x = fish->pos.x = sinf(sFishGroupAngle1) * 720.0f; + fish->homePos.z = fish->pos.z = cosf(sFishGroupAngle1) * 720.0f; } else if (i <= 40) { - fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle2) * 720.0f; - fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle2) * 720.0f; + fish->homePos.x = fish->pos.x = sinf(sFishGroupAngle2) * 720.0f; + fish->homePos.z = fish->pos.z = cosf(sFishGroupAngle2) * 720.0f; } else { - fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle3) * 720.0f; - fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle3) * 720.0f; + fish->homePos.x = fish->pos.x = sinf(sFishGroupAngle3) * 720.0f; + fish->homePos.z = fish->pos.z = cosf(sFishGroupAngle3) * 720.0f; } - fish->unk_10.y = fish->pos.y = -35.0f; + fish->homePos.y = fish->pos.y = -35.0f; fish->timer = Rand_ZeroFloat(100.0f); @@ -951,7 +961,7 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { ENKANBAN_FISHING); Actor_Spawn(&play->actorCtx, play, ACTOR_FISHING, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); - if ((KREG(1) == 1) || ((D_80B7E07D & 3) == 3)) { + if ((KREG(1) == 1) || ((sFishGameNumber & 3) == 3)) { if (sLinkAge != LINK_AGE_CHILD) { fishCount = 16; } else { @@ -966,7 +976,7 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { sFishInits[i].pos.z, 0, Rand_ZeroFloat(0x10000), 0, 100 + i); } } else { - if ((thisx->params < 115) || (thisx->params == 200)) { + if ((thisx->params < (EN_FISH_PARAM + 15)) || (thisx->params == EN_FISH_AQUARIUM)) { SkelAnime_InitFlex(play, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); } else { @@ -976,32 +986,34 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { SkelAnime_Update(&this->skelAnime); - if (thisx->params == 200) { - this->unk_158 = 100; + if (thisx->params == EN_FISH_AQUARIUM) { + this->fishState = 100; Actor_ChangeCategory(play, &play->actorCtx, thisx, ACTORCAT_PROP); thisx->targetMode = 0; thisx->flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); } else { - this->unk_158 = 10; - this->unk_15A = 10; + this->fishState = 10; + this->fishStateNext = 10; - this->unk_150 = sFishInits[thisx->params - 100].unk_00; - this->unk_1A8 = sFishInits[thisx->params - 100].unk_0C; - this->unk_1AC = sFishInits[thisx->params - 100].unk_08; + this->isLoach = sFishInits[thisx->params - EN_FISH_PARAM].isLoach; + this->perception = sFishInits[thisx->params - EN_FISH_PARAM].perception; + this->fishLength = sFishInits[thisx->params - EN_FISH_PARAM].baseLength; - this->unk_1AC += Rand_ZeroFloat(4.99999f); + this->fishLength += Rand_ZeroFloat(4.99999f); - if ((this->unk_1AC >= 65.0f) && (Rand_ZeroOne() < 0.05f)) { - this->unk_1AC += Rand_ZeroFloat(7.99999f); + // small chance to make big fish even bigger. + if ((this->fishLength >= 65.0f) && (Rand_ZeroOne() < 0.05f)) { + this->fishLength += Rand_ZeroFloat(7.99999f); } if (KREG(6) != 0) { - this->unk_1AC = KREG(6) + 80.0f; + this->fishLength = KREG(6) + 80.0f; } + // "Come back when you get older! The fish will be bigger, too!" if (sLinkAge == LINK_AGE_CHILD) { - this->unk_1AC *= 0.73f; + this->fishLength *= 0.73f; } } } @@ -1013,9 +1025,9 @@ void Fishing_Destroy(Actor* thisx, PlayState* play2) { SkelAnime_Free(&this->skelAnime, play); - if (thisx->params == 200) { + if (thisx->params == EN_FISH_AQUARIUM) { LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); - } else if (thisx->params == 1) { + } else if (thisx->params == EN_FISH_OWNER) { Collider_DestroyJntSph(play, &this->collider); } } @@ -1033,14 +1045,14 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { effect->vel.y += effect->accel.y; if (effect->type == FS_EFF_RIPPLE) { - Math_ApproachF(&effect->unk_30, effect->unk_34, 0.2f, effect->unk_38); + Math_ApproachF(&effect->scale, effect->rot.x, 0.2f, effect->rot.y); - if (effect->unk_2C == 0) { + if (effect->state == 0) { effect->alpha += 20; - if (effect->alpha >= effect->unk_2E) { - effect->alpha = effect->unk_2E; - effect->unk_2C++; + if (effect->alpha >= effect->alphaMax) { + effect->alpha = effect->alphaMax; + effect->state++; } } else { effect->alpha -= 8; @@ -1050,7 +1062,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { } } } else if (effect->type == FS_EFF_WATER_DUST) { - Math_ApproachF(&effect->unk_30, effect->unk_34, 0.1f, 0.1f); + Math_ApproachF(&effect->scale, effect->rot.x, 0.1f, 0.1f); effect->alpha -= 10; if (effect->pos.y > (WATER_SURFACE_Y(play) - 5.0f)) { @@ -1063,7 +1075,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { effect->type = FS_EFF_NONE; } } else if (effect->type == FS_EFF_BUBBLE) { - if (effect->unk_2C == 0) { + if (effect->state == 0) { rippleY = WATER_SURFACE_Y(play); } else { rippleY = 69.0f; @@ -1100,14 +1112,14 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { effect->pos.y = WATER_SURFACE_Y(play) + ((sqrtf(sqDistXZ) - 920.0f) * 0.11f); effect->timer = KREG(17) + 2; effect->type = FS_EFF_RAIN_SPLASH; - effect->unk_30 = (KREG(18) + 30) * 0.001f; + effect->scale = (KREG(18) + 30) * 0.001f; } else { effect->pos.y = WATER_SURFACE_Y(play) + 3.0f; effect->timer = 0; if (Rand_ZeroOne() < 0.75f) { effect->type = FS_EFF_RAIN_RIPPLE; effect->vel = sZeroVec; - effect->unk_30 = (KREG(18) + 30) * 0.001f; + effect->scale = (KREG(18) + 30) * 0.001f; } else { effect->type = FS_EFF_NONE; } @@ -1116,7 +1128,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { effect->vel = sZeroVec; } } else if (effect->type >= FS_EFF_RAIN_RIPPLE) { - effect->unk_30 += (KREG(18) + 30) * 0.001f; + effect->scale += (KREG(18) + 30) * 0.001f; if (effect->timer >= 6) { effect->type = FS_EFF_NONE; @@ -1125,11 +1137,11 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { f32 sqDistXZ; f32 bottomY; - effect->unk_30 = 0.010000001f; + effect->scale = 10 * .001f; - Math_ApproachS(&sEffOwnerHatRot.y, 0, 20, 100); - Math_ApproachS(&sEffOwnerHatRot.x, 0, 20, 100); - Math_ApproachS(&sEffOwnerHatRot.z, -0x4000, 20, 100); + Math_ApproachS(&sEffOwnersHatRot.y, 0, 20, 100); + Math_ApproachS(&sEffOwnersHatRot.x, 0, 20, 100); + Math_ApproachS(&sEffOwnersHatRot.z, -0x4000, 20, 100); sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); bottomY = WATER_SURFACE_Y(play) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); @@ -1144,19 +1156,19 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { Fishing_SpawnRipple(NULL, play->specialEffects, &pos, 30.0f, 300.0f, 150, 90); } - if (effect->unk_2C >= 0) { - effect->unk_2C++; + if (effect->state >= 0) { + effect->state++; } - if (effect->unk_2C == 30) { + if (effect->state == 30) { Message_StartTextbox(play, 0x40B3, NULL); } - if ((effect->unk_2C >= 100) && (Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT)) { + if ((effect->state >= 100) && (Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT)) { if (Message_ShouldAdvance(play) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { Message_CloseTextbox(play); Rupees_ChangeBy(-50); - effect->unk_2C = -1; + effect->state = -1; } } } @@ -1190,7 +1202,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); + Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2305), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1214,7 +1226,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2346), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1242,7 +1254,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2394), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1265,7 +1277,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2423), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1287,9 +1299,9 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_RotateY(effect->unk_38, MTXMODE_APPLY); - Matrix_RotateX(effect->unk_34, MTXMODE_APPLY); - Matrix_RotateZ(effect->unk_3C, MTXMODE_APPLY); + Matrix_RotateY(effect->rot.y, MTXMODE_APPLY); + Matrix_RotateX(effect->rot.x, MTXMODE_APPLY); + Matrix_RotateZ(effect->rot.z, MTXMODE_APPLY); Matrix_Scale(0.002f, 1.0f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2467), @@ -1314,7 +1326,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); + Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2504), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1343,7 +1355,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_RotateY(rotY, MTXMODE_APPLY); - Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2541), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1356,10 +1368,10 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { effect = firstEffect; if (effect->type == FS_EFF_OWNER_HAT) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_TO_RAD_ALT2(sEffOwnerHatRot.y), MTXMODE_APPLY); - Matrix_RotateX(BINANG_TO_RAD_ALT2(sEffOwnerHatRot.x), MTXMODE_APPLY); - Matrix_RotateZ(BINANG_TO_RAD_ALT2(sEffOwnerHatRot.z), MTXMODE_APPLY); - Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); + Matrix_RotateY(BINANG_TO_RAD_ALT2(sEffOwnersHatRot.y), MTXMODE_APPLY); + Matrix_RotateX(BINANG_TO_RAD_ALT2(sEffOwnersHatRot.x), MTXMODE_APPLY); + Matrix_RotateZ(BINANG_TO_RAD_ALT2(sEffOwnersHatRot.z), MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateX(M_PI / 2, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2560), @@ -1394,7 +1406,8 @@ void Fishing_DrawStreamSplash(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -s32 func_80B6C2EC(Vec3f* vec) { +// Checks if postion is above Fishing Pond owner's countertop. +s32 Fishing_IsAboveCounter(Vec3f* vec) { if (((vec->x >= 110.0f) && (vec->x <= 150.0f) && (vec->z <= 1400.0f) && (vec->z >= 1160.0f)) || ((vec->x >= 110.0f) && (vec->x <= 210.0f) && (vec->z <= 1200.0f) && (vec->z >= 1160.0f))) { if (vec->y <= 42.0f) { @@ -1415,14 +1428,14 @@ void Fishing_UpdateLine(PlayState* play, Vec3f* basePos, Vec3f* pos, Vec3f* rot, f32 ry; f32 dist; f32 spD8; - s16 temp_s2; + s16 spooled; s32 pad; f32 temp_f20; Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; Vec3f posStep; - f32 phi_f18; - Vec3f spA4; - Vec3f sp98; + f32 lineLength; + Vec3f tempPos; + Vec3f segPos; f32 sp94; f32 sp90; f32 sp8C; @@ -1432,36 +1445,36 @@ void Fishing_UpdateLine(PlayState* play, Vec3f* basePos, Vec3f* pos, Vec3f* rot, f32 phi_f2; if (D_80B7A6A4 != 0) { - spA4 = *basePos; - sp98 = pos[LINE_SEG_COUNT - 1]; + tempPos = *basePos; + segPos = pos[LINE_SEG_COUNT - 1]; - sp94 = sp98.x - spA4.x; - sp90 = sp98.y - spA4.y; - sp8C = sp98.z - spA4.z; + sp94 = segPos.x - tempPos.x; + sp90 = segPos.y - tempPos.y; + sp8C = segPos.z - tempPos.z; - phi_f18 = sqrtf(SQ(sp94) + SQ(sp90) + SQ(sp8C)) * 0.97f; - if (phi_f18 > 1000.0f) { - phi_f18 = 1000.0f; + lineLength = sqrtf(SQ(sp94) + SQ(sp90) + SQ(sp8C)) * 0.97f; + if (lineLength > 1000.0f) { + lineLength = 1000.0f; } - D_80B7E144 = 200.0f - (phi_f18 * 200.0f * 0.001f); + sRodLineSpooled = 200.0f - (lineLength * 200.0f * 0.001f); } - temp_s2 = D_80B7E144; + spooled = sRodLineSpooled; posSrc.z = 5.0f; for (i = 0; i < LINE_SEG_COUNT; i++) { - if (i <= temp_s2) { + if (i <= spooled) { pos[i] = *basePos; } else if (D_80B7A6A4 != 0) { - temp_f20 = (f32)(i - temp_s2) / (f32)(LINE_SEG_COUNT - temp_s2 + 1); - Math_ApproachF(&pos[i].x, (sp94 * temp_f20) + spA4.x, 1.0f, 20.0f); - Math_ApproachF(&pos[i].y, (sp90 * temp_f20) + spA4.y, 1.0f, 20.0f); - Math_ApproachF(&pos[i].z, (sp8C * temp_f20) + spA4.z, 1.0f, 20.0f); + temp_f20 = (f32)(i - spooled) / (f32)(LINE_SEG_COUNT - spooled + 1); + Math_ApproachF(&pos[i].x, (sp94 * temp_f20) + tempPos.x, 1.0f, 20.0f); + Math_ApproachF(&pos[i].y, (sp90 * temp_f20) + tempPos.y, 1.0f, 20.0f); + Math_ApproachF(&pos[i].z, (sp8C * temp_f20) + tempPos.z, 1.0f, 20.0f); } } - for (i = temp_s2 + 1, k = 0; i < LINE_SEG_COUNT; i++, k++) { + for (i = spooled + 1, k = 0; i < LINE_SEG_COUNT; i++, k++) { temp_f18 = 2.0f * D_80B7E148; dx = (pos + i)->x - (pos + i - 1)->x; @@ -1475,7 +1488,7 @@ void Fishing_UpdateLine(PlayState* play, Vec3f* basePos, Vec3f* pos, Vec3f* rot, phi_f12 = WATER_SURFACE_Y(play); } - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { if (spD8 < phi_f12) { phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.147f) + WATER_SURFACE_Y(play); if (spD8 > phi_f12) { @@ -1505,7 +1518,7 @@ void Fishing_UpdateLine(PlayState* play, Vec3f* basePos, Vec3f* pos, Vec3f* rot, } } - if (func_80B6C2EC(&pos[i])) { + if (Fishing_IsAboveCounter(&pos[i])) { spD8 = 42.0f; } @@ -1539,11 +1552,11 @@ void Fishing_UpdateLinePos(Vec3f* pos) { f32 dist; Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; Vec3f posStep; - s16 min = D_80B7E144; + s16 spooled = sRodLineSpooled; posSrc.z = 5.0f; - for (i = LINE_SEG_COUNT - 2; i > min; i--) { + for (i = LINE_SEG_COUNT - 2; i > spooled; i--) { dx = (pos + i)->x - (pos + i + 1)->x; dy = (pos + i)->y - (pos + i + 1)->y; dz = (pos + i)->z - (pos + i + 1)->z; @@ -1578,7 +1591,7 @@ void Fishing_DrawLureHook(PlayState* play, Vec3f* pos, Vec3f* refPos, u8 hookInd Matrix_Push(); - if ((D_80B7A694 == 3) && ((pos->y > WATER_SURFACE_Y(play)) || ((D_80B7A68C != 0) && hookIndex))) { + if ((sRodCastState == 3) && ((pos->y > WATER_SURFACE_Y(play)) || (sIsOwnersHatHooked && hookIndex))) { offsetY = 0.0f; } else if (pos->y < WATER_SURFACE_Y(play)) { offsetY = -1.0f; @@ -1604,7 +1617,7 @@ void Fishing_DrawLureHook(PlayState* play, Vec3f* pos, Vec3f* refPos, u8 hookInd Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_NEW); - if ((player->actor.speed == 0.0f) && (D_80B7E138 == 0.0f)) { + if ((player->actor.speed == 0.0f) && (sLureWigglePosY == 0.0f)) { Math_ApproachF(&sLureHookRotY[hookIndex], ry, 0.1f, 0.3f); } else { sLureHookRotY[hookIndex] = ry; @@ -1625,24 +1638,24 @@ void Fishing_DrawLureHook(PlayState* play, Vec3f* pos, Vec3f* refPos, u8 hookInd G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); - if ((hookIndex == 1) && (D_80B7A68C != 0)) { + if ((hookIndex == 1) && (sIsOwnersHatHooked)) { Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); Matrix_Translate(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); Matrix_Push(); - if (D_80B7A690 != 0) { + if (sIsOwnersHatSunk) { FishingEffect* effect = play->specialEffects; MtxF mf; Matrix_MultVec3f(&sZeroVec, &effect->pos); Matrix_Get(&mf); - Matrix_MtxFToYXZRotS(&mf, &sEffOwnerHatRot, 0); + Matrix_MtxFToYXZRotS(&mf, &sEffOwnersHatRot, 0); - D_80B7A690 = 0; - D_80B7A68C = 0; + sIsOwnersHatSunk = false; + sIsOwnersHatHooked = false; effect->type = FS_EFF_OWNER_HAT; - effect->unk_2C = 0; + effect->state = 0; effect->vel = sZeroVec; effect->accel = sZeroVec; } @@ -1682,7 +1695,7 @@ void Fishing_UpdateSinkingLure(PlayState* play) { sSinkingLurePos[0] = sLurePos; - if (D_80B7A6D4 != 0) { + if (sSinkingLureFound) { offsetY = -1.0f; } else if (sLurePos.y < WATER_SURFACE_Y(play)) { offsetY = 0.5f; @@ -1690,7 +1703,7 @@ void Fishing_UpdateSinkingLure(PlayState* play) { offsetY = -5.0f; } - if (D_80B7A694 == 5) { + if (sRodCastState == 5) { Matrix_RotateY(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); sp94.x = 5.0f; sp94.y = 0.0f; @@ -1701,7 +1714,7 @@ void Fishing_UpdateSinkingLure(PlayState* play) { for (i = 1; i < SINKING_LURE_SEG_COUNT; i++) { Vec3f* pos = sSinkingLurePos; - if ((i < 10) && (D_80B7A694 == 5)) { + if ((i < 10) && (sRodCastState == 5)) { offsetX = (10 - i) * sp88.x * 0.1f; offsetZ = (10 - i) * sp88.z * 0.1f; } else { @@ -1745,9 +1758,9 @@ void Fishing_DrawSinkingLure(PlayState* play) { gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentMaterialDL); for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { - if ((i + D_80B7FEA0) < SINKING_LURE_SEG_COUNT) { + if ((i + sSinkingLureSegmentIndex) < SINKING_LURE_SEG_COUNT) { Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); - scale = sSinkingLureSizes[i + D_80B7FEA0] * 0.04f; + scale = sSinkingLureSizes[i + sSinkingLureSegmentIndex] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); @@ -1762,9 +1775,9 @@ void Fishing_DrawSinkingLure(PlayState* play) { gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentMaterialDL); for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { - if ((i + D_80B7FEA0) < SINKING_LURE_SEG_COUNT) { + if ((i + sSinkingLureSegmentIndex) < SINKING_LURE_SEG_COUNT) { Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); - scale = sSinkingLureSizes[i + D_80B7FEA0] * 0.04f; + scale = sSinkingLureSizes[i + sSinkingLureSegmentIndex] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); @@ -1783,7 +1796,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Vec3f posStep; Vec3f hookPos[2]; s16 i; - s16 spB4 = D_80B7E144; + s16 spooled = sRodLineSpooled; s32 pad; Player* player = GET_PLAYER(play); @@ -1792,17 +1805,17 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Gfx_SetupDL_25Opa(play->state.gfxCtx); Matrix_Push(); - if (D_80B7A6D4 != 0) { + if (sSinkingLureFound) { Vec3f posTemp = sLurePos; sLurePos = sSinkingLureBasePos; Fishing_DrawSinkingLure(play); sLurePos = posTemp; } - if ((D_80B7A694 == 4) || (D_80B7A694 == 5)) { + if ((sRodCastState == 4) || (sRodCastState == 5)) { sLurePos = sFishingHookedFish->fishMouthPos; - if ((D_80B7A694 == 5) && (D_80B7E0B6 == 2)) { + if ((sRodCastState == 5) && (sLureEquipped == FS_LURE_SINKING)) { Matrix_RotateY(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); posSrc.x = 2.0f; posSrc.y = 0.0f; @@ -1811,7 +1824,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { sLurePos.x += posStep.x; sLurePos.z += posStep.z; } - } else if (D_80B7A694 == 0) { + } else if (sRodCastState == 0) { sLurePos = sReelLinePos[LINE_SEG_COUNT - 1]; sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; @@ -1822,12 +1835,12 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { } } - if (D_80B7E0B6 != 2) { + if (sLureEquipped != FS_LURE_SINKING) { Matrix_Translate(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); - Matrix_RotateY(sLureRot.y + D_80B7E104, MTXMODE_APPLY); + Matrix_RotateY(sLureRot.y + sLure1Rotate, MTXMODE_APPLY); Matrix_RotateX(sLureRot.x, MTXMODE_APPLY); Matrix_Scale(0.0039999997f, 0.0039999997f, 0.0039999997f, MTXMODE_APPLY); - Matrix_Translate(0.0f, 0.0f, D_80B7E108, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, sLurePosZOffset, MTXMODE_APPLY); Matrix_RotateZ(M_PI / 2, MTXMODE_APPLY); Matrix_RotateY(M_PI / 2, MTXMODE_APPLY); @@ -1840,7 +1853,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { posSrc.x = -850.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; - Matrix_MultVec3f(&posSrc, &D_80B7E0C8); + Matrix_MultVec3f(&posSrc, &sLureDrawPos); posSrc.x = 500.0f; posSrc.z = -300.0f; @@ -1858,7 +1871,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { gDPSetCombineMode(POLY_XLU_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 55); - if ((D_80B7A694 == 4) && ((D_80B7E124 != 0) || (D_80B7E0B6 != 2))) { + if ((sRodCastState == 4) && ((sLineHooked != 0) || (sLureEquipped != FS_LURE_SINKING))) { f32 rx; f32 ry; f32 dist; @@ -1879,14 +1892,14 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Matrix_Translate(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); Matrix_RotateY(ry, MTXMODE_APPLY); Matrix_RotateX(rx, MTXMODE_APPLY); - Matrix_Scale(D_80B7E14C, 1.0f, dist, MTXMODE_APPLY); + Matrix_Scale(sFishingLineScale, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 3444), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingLineModelDL); } else { - for (i = spB4; i < LINE_SEG_COUNT - 1; i++) { - if ((i == LINE_SEG_COUNT - 3) && (D_80B7E0B6 == 0) && (D_80B7A694 == 3)) { + for (i = spooled; i < LINE_SEG_COUNT - 1; i++) { + if ((i == LINE_SEG_COUNT - 3) && (sLureEquipped == FS_LURE_STOCK) && (sRodCastState == 3)) { f32 rx; f32 ry; f32 dist; @@ -1894,9 +1907,9 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { f32 dy; f32 dz; - dx = D_80B7E0C8.x - (linePos + i)->x; - dy = D_80B7E0C8.y - (linePos + i)->y; - dz = D_80B7E0C8.z - (linePos + i)->z; + dx = sLureDrawPos.x - (linePos + i)->x; + dy = sLureDrawPos.y - (linePos + i)->y; + dz = sLureDrawPos.z - (linePos + i)->z; ry = Math_FAtan2F(dx, dz); dist = sqrtf(SQ(dx) + SQ(dz)); @@ -1907,7 +1920,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); Matrix_RotateY(ry, MTXMODE_APPLY); Matrix_RotateX(rx, MTXMODE_APPLY); - Matrix_Scale(D_80B7E14C, 1.0f, dist, MTXMODE_APPLY); + Matrix_Scale(sFishingLineScale, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 3475), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1918,7 +1931,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); Matrix_RotateY((lineRot + i)->y, MTXMODE_APPLY); Matrix_RotateX((lineRot + i)->x, MTXMODE_APPLY); - Matrix_Scale(D_80B7E14C, 1.0f, 0.005f, MTXMODE_APPLY); + Matrix_Scale(sFishingLineScale, 1.0f, 0.005f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 3492), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1947,7 +1960,7 @@ static Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; void Fishing_DrawRod(PlayState* play) { s16 i; - f32 spC8; + f32 lureXZLen; f32 spC4; f32 spC0; Input* input = &play->state.input[0]; @@ -1956,8 +1969,8 @@ void Fishing_DrawRod(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - if (D_80B7FDA8 != 0) { - D_80B7FDA8--; + if (sRodHitTimer != 0) { + sRodHitTimer--; Math_ApproachF(&D_80B7A6C0, 35.0f, 1.0f, 100.0f); Math_ApproachF(&D_80B7A6BC, -0.8f, 1.0f, 0.4f); @@ -1965,8 +1978,8 @@ void Fishing_DrawRod(PlayState* play) { } else { s16 target = 0; - if ((D_80B7A694 == 4) && (D_80B7E124 != 0)) { - target = Math_SinS(D_80B7E0AE * 25600) * 1500.0f; + if ((sRodCastState == 4) && sLineHooked) { + target = Math_SinS(sLureTimer * 25600) * 1500.0f; } else { Math_ApproachZeroF(&D_80B7A6C0, 0.1f, 10.0f); Math_ApproachZeroF(&D_80B7A6BC, 1.0f, 0.05f); @@ -1975,17 +1988,17 @@ void Fishing_DrawRod(PlayState* play) { Math_ApproachS(&player->actor.shape.rot.x, target, 5, 1000); } - if ((D_80B7A694 == 3) || (D_80B7A694 == 4)) { - if ((input->rel.stick_x == 0) && (D_80B7A6C4 != 0)) { + if ((sRodCastState == 3) || (sRodCastState == 4)) { + if ((input->rel.stick_x == 0) && (sStickAdjXPrev != 0)) { D_80B7A6B0 = 0.0f; } - if ((input->rel.stick_y == 0) && (D_80B7A6C8 != 0)) { + if ((input->rel.stick_y == 0) && (sStickAdjYPrev != 0)) { D_80B7A6B4 = 0.0f; } - spC8 = player->unk_85C; + lureXZLen = player->unk_85C; Math_SmoothStepToF(&player->unk_85C, input->rel.stick_y * 0.02f, 0.3f, 5.0f, 0.0f); - spC8 = player->unk_85C - spC8; + lureXZLen = player->unk_85C - lureXZLen; spC4 = player->unk_858; Math_SmoothStepToF(&player->unk_858, input->rel.stick_x * 0.02f, 0.3f, 5.0f, 0.0f); @@ -2004,18 +2017,18 @@ void Fishing_DrawRod(PlayState* play) { player->unk_85C = -1.0f; } - Math_ApproachF(&D_80B7A6A8, spC4 * 70.0f * -0.01f, 1.0f, D_80B7A6B0); + Math_ApproachF(&sRodBendRotY, spC4 * 70.0f * -0.01f, 1.0f, D_80B7A6B0); Math_ApproachF(&D_80B7A6B0, 1.0f, 1.0f, 0.1f); - Math_ApproachF(&D_80B7A6AC, spC8 * 70.0f * 0.01f, 1.0f, D_80B7A6B4); + Math_ApproachF(&D_80B7A6AC, lureXZLen * 70.0f * 0.01f, 1.0f, D_80B7A6B4); Math_ApproachF(&D_80B7A6B4, 1.0f, 1.0f, 0.1f); Math_ApproachZeroF(&D_80B7A6B8, 1.0f, 0.05f); } else { Math_ApproachZeroF(&player->unk_85C, 1.0f, 0.1f); Math_ApproachZeroF(&player->unk_858, 1.0f, 0.1f); - Math_ApproachF(&D_80B7A6AC, (Math_SinS(D_80B7E0AE * 3000) * 0.025f) + -0.03f, 1.0f, 0.05f); - Math_ApproachZeroF(&D_80B7A6A8, 1.0f, 0.05f); + Math_ApproachF(&D_80B7A6AC, (Math_SinS(sLureTimer * 3000) * 0.025f) + -0.03f, 1.0f, 0.05f); + Math_ApproachZeroF(&sRodBendRotY, 1.0f, 0.05f); - if ((D_80B7E0B4 >= 19) && (D_80B7E0B4 <= 24)) { + if ((sRodCastTimer > 18) && (sRodCastTimer < 25)) { Math_ApproachF(&D_80B7A6B8, 0.8f, 1.0f, 0.2f); } else { Math_ApproachF(&D_80B7A6B8, 0.0f, 1.0f, 0.4f); @@ -2036,7 +2049,7 @@ void Fishing_DrawRod(PlayState* play) { Matrix_Translate(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); } - if (D_80B7A694 == 5) { + if (sRodCastState == 5) { Matrix_RotateY(0.56f * M_PI, MTXMODE_APPLY); } else { Matrix_RotateY(0.41f * M_PI, MTXMODE_APPLY); @@ -2052,7 +2065,7 @@ void Fishing_DrawRod(PlayState* play) { Matrix_Translate(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); for (i = 0; i < 22; i++) { - Matrix_RotateY(sRodBendRatios[i] * D_80B7A6A8 * 0.5f, MTXMODE_APPLY); + Matrix_RotateY(sRodBendRatios[i] * sRodBendRotY * 0.5f, MTXMODE_APPLY); Matrix_RotateX(sRodBendRatios[i] * spC0 * 0.5f, MTXMODE_APPLY); Matrix_Push(); @@ -2085,18 +2098,18 @@ void Fishing_DrawRod(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -static Vec3f D_80B7AF94 = { 0.0f, 0.0f, 0.0f }; +static Vec3f sSoundPos = { 0.0f, 0.0f, 0.0f }; void Fishing_UpdateLure(Fishing* this, PlayState* play) { f32 spE4; f32 spE0; - s16 phi_v0; + s16 timer; s16 spDC; f32 spD8; f32 spD4; f32 spD0; - f32 phi_f16; - f32 spC8; + f32 lengthCasted; + f32 lureXZLen; s16 i; Player* player = GET_PLAYER(play); Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; @@ -2108,12 +2121,12 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { f32 sp7C; f32 sp78; f32 phi_f0; - f32 sp70; + f32 wiggle; Vec3f sp64; Vec3f sp58; s32 pad; - D_80B7E0AE++; + sLureTimer++; if (D_80B7E0B0 != 0) { D_80B7E0B0--; @@ -2123,12 +2136,12 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { D_80B7E0B2--; } - if (D_80B7E0B4 != 0) { - D_80B7E0B4--; + if (sRodCastTimer != 0) { + sRodCastTimer--; } - if (D_80B7E122 != 0) { - D_80B7E122--; + if (sLureBitTimer != 0) { + sLureBitTimer--; } if (D_80B7E150 != 0) { @@ -2139,33 +2152,34 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { D_80B7A6A4--; } - if (D_80B7E0A4 != 0) { - D_80B7E0A4--; + if (sRumbleDelay != 0) { + sRumbleDelay--; } if (D_80B7E114 != 0) { D_80B7E114--; } - if (D_80B7E0AC == 1) { - D_80B7E0AC = 2; - D_80B7E084 = 0; - D_80B7E082 = 0; - D_80B7E0B6 = 0; + if (sFishingPlayingState == 1) { + sFishingPlayingState = 2; + sFishesCaught = 0; + sPondOwnerTextIdIndex = 0; + sLureEquipped = FS_LURE_STOCK; - if (((sLinkAge == LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & 0x400)) || - ((sLinkAge != LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & 0x800))) { + // if prize item won as child or adult, set the sinking lure location. + if (((sLinkAge == LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_CHILD)) || + ((sLinkAge != LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_ADULT))) { sSinkingLureLocation = (u8)Rand_ZeroFloat(3.999f) + 1; } D_80B7E148 = 520.0f; - D_80B7E144 = 195.0f; + sRodLineSpooled = 195.0f; - D_80B7A694 = D_80B7E0B6 = D_80B7E0AE = D_80B7E0B0 = D_80B7E0B2 = D_80B7E0B4 = D_80B7E120 = D_80B7E114 = + sRodCastState = sLureEquipped = sLureTimer = D_80B7E0B0 = D_80B7E0B2 = sRodCastTimer = sWiggleAttraction = D_80B7E114 = D_80B7E150 = 0; - D_80B7E104 = D_80B7E154 = D_80B7E108 = 0.0f; + sLure1Rotate = sReelLinePosStep = sLurePosZOffset = 0.0f; - D_80B7E128 = zeroVec; + sLureLineSegPosDelta = zeroVec; for (i = 0; i < LINE_SEG_COUNT; i++) { sReelLinePos[i] = zeroVec; @@ -2174,78 +2188,78 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { } } - SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sLurePos, &D_80B7AF94, &sProjectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sLurePos, &sSoundPos, &sProjectedW); - if (D_80B7A694 == 0) { - Math_ApproachF(&D_80B7E108, -800.0f, 1.0f, 20.0f); + if (sRodCastState == 0) { + Math_ApproachF(&sLurePosZOffset, -800.0f, 1.0f, 20.0f); } else { - Math_ApproachF(&D_80B7E108, 300.0f, 1.0f, 20.0f); + Math_ApproachF(&sLurePosZOffset, 300.0f, 1.0f, 20.0f); } - switch (D_80B7A694) { + switch (sRodCastState) { case 0: - D_80B7FEA0 = 0; + sSinkingLureSegmentIndex = 0; if (KREG(14) != 0) { KREG(14) = 0; - D_80B7E0B6 = 2 - D_80B7E0B6; - if (D_80B7E0B6 != 0) { - D_80B7E082 = 0; + sLureEquipped = FS_LURE_SINKING - sLureEquipped; + if (sLureEquipped != FS_LURE_STOCK) { + sPondOwnerTextIdIndex = 0; } } - Math_ApproachF(&D_80B7E144, 195.0f, 1.0f, 1.0f); + Math_ApproachF(&sRodLineSpooled, 195.0f, 1.0f, 1.0f); if (player->stateFlags1 & PLAYER_STATE1_27) { - D_80B7E0B4 = 0; + sRodCastTimer = 0; player->unk_860 = 0; } - if (D_80B7E0B4 == 0) { + if (sRodCastTimer == 0) { if ((D_80B7E0B0 == 0) && (player->unk_860 == 1)) { - D_80B7E0B4 = 37; + sRodCastTimer = 37; Message_CloseTextbox(play); } } else { sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; sLureRot.y = sReelLineRot[LINE_SEG_COUNT - 2].y; - if (D_80B7E0B4 == 18) { - D_80B7A694 = 1; + if (sRodCastTimer == 18) { + sRodCastState = 1; sLurePos = sRodTipPos; Matrix_RotateY(BINANG_TO_RAD_ALT(player->actor.shape.rot.y), MTXMODE_NEW); sp90.x = 0.0f; sp90.y = 0.0f; sp90.z = 25.0f; - Matrix_MultVec3f(&sp90, &D_80B7E0E8); - D_80B7E0E8.y = 15.0f; - D_80B7E0F8.x = D_80B7E0F8.z = 0.0f; - D_80B7E0F8.y = -1.0f; + Matrix_MultVec3f(&sp90, &sLurePosDelta); + sLurePosDelta.y = 15.0f; + sLureCastDelta.x = sLureCastDelta.z = 0.0f; + sLureCastDelta.y = -1.0f; D_80B7E148 = 0.0f; D_80B7E0B2 = 5; - D_80B7E11C = 0.5f; + sRodReelingSpeed = 0.5f; D_80B7E118 = Rand_ZeroFloat(1.9f); sFishMouthOffset.y = 500.0f; - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_IT_SWORD_SWING_HARD); + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_IT_SWORD_SWING_HARD); } } break; - case 1: + case 1: // casting the line spE0 = sLurePos.y; - sLurePos.x += D_80B7E0E8.x; - sLurePos.y += D_80B7E0E8.y; - sLurePos.z += D_80B7E0E8.z; + sLurePos.x += sLurePosDelta.x; + sLurePos.y += sLurePosDelta.y; + sLurePos.z += sLurePosDelta.z; - D_80B7E0E8.x += D_80B7E0F8.x; - D_80B7E0E8.y += D_80B7E0F8.y; - D_80B7E0E8.z += D_80B7E0F8.z; - - if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_80B7A68C != 0)) { - D_80B7E0E8.x *= 0.9f; - D_80B7E0E8.z *= 0.9f; - if (D_80B7A68C == 0) { + sLurePosDelta.x += sLureCastDelta.x; + sLurePosDelta.y += sLureCastDelta.y; + sLurePosDelta.z += sLureCastDelta.z; + // air drag by hat or reeling during cast. + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || sIsOwnersHatHooked) { + sLurePosDelta.x *= 0.9f; + sLurePosDelta.z *= 0.9f; + if (!sIsOwnersHatHooked) { Sfx_PlaySfxCentered(NA_SE_IT_FISHING_REEL_HIGH - SFX_FLAG); } } @@ -2262,14 +2276,14 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { sLureRot.y = Math_Atan2F(spD0, spD8) + M_PI; } - phi_f16 = sqrtf(SQ(spD8) + SQ(spD4) + SQ(spD0)); - if (phi_f16 > 1000.0f) { - phi_f16 = 1000.0f; + lengthCasted = sqrtf(SQ(spD8) + SQ(spD4) + SQ(spD0)); + if (lengthCasted > 1000.0f) { + lengthCasted = 1000.0f; } - D_80B7E144 = 200.0f - (phi_f16 * 200.0f * 0.001f); + sRodLineSpooled = 200.0f - (lengthCasted * 200.0f * 0.001f); - spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); - if (spC8 > SQ(920.0f)) { + lureXZLen = SQ(sLurePos.x) + SQ(sLurePos.z); + if (lureXZLen > SQ(920.0f)) { if ((KREG(56) != 0) || (sLurePos.y > 160.0f) || (sLurePos.x < 80.0f) || (sLurePos.x > 180.0f) || (sLurePos.z > 1350.0f) || (sLurePos.z < 1100.0f) || (sLurePos.y < 45.0f)) { sp80 = this->actor.world.pos; @@ -2279,50 +2293,50 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { this->actor.world.pos = sp80; if (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) { - D_80B7E0E8.y = -0.5f; + sLurePosDelta.y = -0.5f; } if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { - if (D_80B7E0E8.y > 0.0f) { - D_80B7E0E8.y = 0.0f; + if (sLurePosDelta.y > 0.0f) { + sLurePosDelta.y = 0.0f; } - D_80B7E0E8.x = D_80B7E0E8.z = 0.0f; + sLurePosDelta.x = sLurePosDelta.z = 0.0f; } } else { - if (func_80B6C2EC(&sLurePos) != 0) { - D_80B7A694 = 3; - D_80B7E154 = 0.0f; + if (Fishing_IsAboveCounter(&sLurePos)) { + sRodCastState = 3; + sReelLinePosStep = 0.0f; } } - spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); + spE4 = ((sqrtf(lureXZLen) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); if (sLurePos.y <= spE4) { sLurePos.y = spE4; - D_80B7E0E8.x = D_80B7E0E8.y = D_80B7E0E8.z = 0.0f; - D_80B7A694 = 3; - D_80B7E154 = 0.0; + sLurePosDelta.x = sLurePosDelta.y = sLurePosDelta.z = 0.0f; + sRodCastState = 3; + sReelLinePosStep = 0.0; } else { Math_ApproachF(&D_80B7E148, 0.0f, 1.0f, 0.05f); - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); } } else { spE4 = WATER_SURFACE_Y(play); if (sLurePos.y <= spE4) { - D_80B7A694 = 2; - D_80B7E154 = 0.0f; - D_80B7E0E8.x = D_80B7E0E8.z = 0.0f; + sRodCastState = 2; + sReelLinePosStep = 0.0f; + sLurePosDelta.x = sLurePosDelta.z = 0.0f; - if (D_80B7E0B6 == 2) { - D_80B7E0A2 = 0; + if (sLureEquipped == FS_LURE_SINKING) { + sLureMoveDelay = 0; } else { - D_80B7E0A2 = 10; + sLureMoveDelay = 10; } if ((sLurePos.y <= spE4) && (spE4 < spE0) && (spE4 == WATER_SURFACE_Y(play))) { D_80B7E114 = 10; - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_EV_BOMB_DROP_WATER); - D_80B7E0F8.y = 0.0f; - D_80B7E0E8.y *= 0.2f; + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_EV_BOMB_DROP_WATER); + sLureCastDelta.y = 0.0f; + sLurePosDelta.y *= 0.2f; for (i = 0; i < 50; i++) { sp7C = Rand_ZeroFloat(1.5f) + 0.5f; @@ -2346,7 +2360,7 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { } } else { Math_ApproachZeroF(&D_80B7E148, 1.0f, 0.05f); - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); } } @@ -2354,219 +2368,220 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y; sReelLinePos[LINE_SEG_COUNT - 1].z = sLurePos.z; - D_80B7E140 = 1.0f; - D_80B7E10C = 0.5f; + sLureWiggleSign = 1.0f; + sLureRotXTarget = 0.5f; break; case 2: if (sLurePos.y <= WATER_SURFACE_Y(play)) { - sLurePos.y += D_80B7E0E8.y; + sLurePos.y += sLurePosDelta.y; - Math_ApproachZeroF(&D_80B7E0E8.y, 1.0f, 1.0f); + Math_ApproachZeroF(&sLurePosDelta.y, 1.0f, 1.0f); - if (D_80B7E0B6 != 2) { + if (sLureEquipped != FS_LURE_SINKING) { Math_ApproachF(&sLurePos.y, WATER_SURFACE_Y(play), 0.5f, 1.0f); } } Math_ApproachF(&D_80B7E148, 2.0f, 1.0f, 0.1f); - if (D_80B7E0A2 == 0) { - D_80B7A694 = 3; + if (sLureMoveDelay == 0) { + sRodCastState = 3; } else { - D_80B7E0A2--; + sLureMoveDelay--; } break; case 3: - D_80B7FEA0 = 0; + sSinkingLureSegmentIndex = 0; - if ((D_80B7A68C != 0) && ((SQ(sLurePos.x) + SQ(sLurePos.z)) < SQ(500.0f))) { - D_80B7A690 = 1; + if (sIsOwnersHatHooked && ((SQ(sLurePos.x) + SQ(sLurePos.z)) < SQ(500.0f))) { + sIsOwnersHatSunk = true; } player->unk_860 = 2; - if (D_80B7E138 < 3.0f) { - spD0 = D_80B7E10C * Math_SinS(D_80B7E0AE * 0x1060); - Math_ApproachF(&sLureRot.x, -M_PI / 6.0f + spD0, 0.3f, D_80B7E110); - Math_ApproachF(&D_80B7E110, 0.5f, 1.0f, 0.02f); - Math_ApproachZeroF(&D_80B7E10C, 1.0f, 0.02f); + if (sLureWigglePosY < 3.0f) { + spD0 = sLureRotXTarget * Math_SinS(sLureTimer * 0x1060); + Math_ApproachF(&sLureRot.x, -M_PI / 6.0f + spD0, 0.3f, sLureRotXStep); + Math_ApproachF(&sLureRotXStep, 0.5f, 1.0f, 0.02f); + Math_ApproachZeroF(&sLureRotXTarget, 1.0f, 0.02f); } else { - D_80B7E110 = 0.0f; + sLureRotXStep = 0.0f; } spDC = 0x4000; spE4 = WATER_SURFACE_Y(play); - spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); - if (spC8 < SQ(920.0f)) { + lureXZLen = SQ(sLurePos.x) + SQ(sLurePos.z); + if (lureXZLen < SQ(920.0f)) { if (sLurePos.y <= (spE4 + 4.0f)) { - sp70 = 0.0f; + wiggle = 0.0f; if (D_80B7E150 == 0) { if (fabsf(input->rel.stick_x) > 30.0f) { - sp70 = fabsf((input->rel.stick_x - D_80B7A6C4) * (1.0f / 60.0f)); + wiggle = fabsf((input->rel.stick_x - sStickAdjXPrev) * (1.0f / 60.0f)); } else if (fabsf(input->rel.stick_y) > 30.0f) { - sp70 = fabsf((input->rel.stick_y - D_80B7A6C8) * (1.0f / 60.0f)); + wiggle = fabsf((input->rel.stick_y - sStickAdjYPrev) * (1.0f / 60.0f)); } } - if (sp70 > 1.0f) { - sp70 = 1.0f; + if (wiggle > 1.0f) { + wiggle = 1.0f; } if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - sp70 = 0.5f; + wiggle = 0.5f; } - if (D_80B7A68C != 0) { - if (sp70 > 0.3f) { - sp70 = 0.3f; + if (sIsOwnersHatHooked) { + if (wiggle > 0.3f) { + wiggle = 0.3f; } } - if ((sp70 > 0.2f) && (D_80B7E138 < 4.0f)) { + if ((wiggle > 0.2f) && (sLureWigglePosY < 4.0f)) { D_80B7E150 = 5; - if (sp70 > 0.8f) { - D_80B7E120 = 2; + if (wiggle > 0.8f) { + sWiggleAttraction = 2; } else { - D_80B7E120 = 1; + sWiggleAttraction = 1; } sp90.x = player->actor.world.pos.x - sLurePos.x; sp90.z = player->actor.world.pos.z - sLurePos.z; sp90.y = Math_Atan2F(sp90.z, sp90.x); - D_80B7E134 = (sp70 * D_80B7E140) + sp90.y; - D_80B7E140 = D_80B7E140 * -1.0f; - D_80B7E138 = fabsf(sp70) * 6.0f; + sLureWiggleRotYTarget = (wiggle * sLureWiggleSign) + sp90.y; + sLureWiggleSign *= -1.0f; + sLureWigglePosY = fabsf(wiggle) * 6.0f; sLureRot.x = 0.0f; - D_80B7E10C = 0.5f; - D_80B7E144 += (fabsf(sp70) * (7.5f + (KREG(25) * 0.1f))); + sLureRotXTarget = 0.5f; + sRodLineSpooled += (fabsf(wiggle) * (7.5f + (KREG(25) * 0.1f))); - func_800F436C(&D_80B7AF94, NA_SE_EV_LURE_MOVE_W, (sp70 * 1.999f * 0.25f) + 0.75f); + func_800F436C(&sSoundPos, NA_SE_EV_LURE_MOVE_W, (wiggle * 1.999f * 0.25f) + 0.75f); - if (D_80B7E0B6 == 2) { - D_80B7E128.y = 5.0f * sp70; - sReelLinePos[LINE_SEG_COUNT - 1].y += D_80B7E128.y; - sLurePos.y += D_80B7E128.y; + if (sLureEquipped == FS_LURE_SINKING) { + sLureLineSegPosDelta.y = 5.0f * wiggle; + sReelLinePos[LINE_SEG_COUNT - 1].y += sLureLineSegPosDelta.y; + sLurePos.y += sLureLineSegPosDelta.y; } } else if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { spDC = 0x500; - D_80B7E134 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sLureWiggleRotYTarget = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; sLureRot.x = 0.0f; - D_80B7E10C = 0.5f; - if (D_80B7E0B6 == 2) { - D_80B7E128.y = 0.2f; - sReelLinePos[LINE_SEG_COUNT - 1].y += D_80B7E128.y; - sLurePos.y += D_80B7E128.y; + sLureRotXTarget = 0.5f; + if (sLureEquipped == FS_LURE_SINKING) { + sLureLineSegPosDelta.y = 0.2f; + sReelLinePos[LINE_SEG_COUNT - 1].y += sLureLineSegPosDelta.y; + sLurePos.y += sLureLineSegPosDelta.y; } } } else { - if (D_80B7E144 > 150.0f) { + if (sRodLineSpooled > 150.0f) { sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; - D_80B7E134 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; - D_80B7E144 += 2.0f; + sLureWiggleRotYTarget = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sRodLineSpooled += 2.0f; } } } else { - spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); + spE4 = ((sqrtf(lureXZLen) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); if (sLurePos.y <= spE4) { sLurePos.y = spE4; spDC = 0x500; - D_80B7E134 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sLureWiggleRotYTarget = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; sLureRot.x = 0.0f; + // lure hopping on land if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - D_80B7E144 += 6.0f; - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_SAND); + sRodLineSpooled += 6.0f; + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_SAND); } } else { - if (D_80B7E144 > 150.0f) { + if (sRodLineSpooled > 150.0f) { sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; - D_80B7E134 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; - D_80B7E144 += 2.0f; + sLureWiggleRotYTarget = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sRodLineSpooled += 2.0f; } } } - Math_ApproachZeroF(&D_80B7E138, 1.0f, 0.3f); - Math_ApproachS(&D_80B7E13C, (D_80B7E134 * 32768.0f) / M_PI, 3, spDC); + Math_ApproachZeroF(&sLureWigglePosY, 1.0f, 0.3f); + Math_ApproachS(&sLureWiggleRotY, (sLureWiggleRotYTarget * 32768.0f) / M_PI, 3, spDC); - sLureRot.y = BINANG_TO_RAD_ALT(D_80B7E13C); + sLureRot.y = BINANG_TO_RAD_ALT(sLureWiggleRotY); sp90.x = 0.0f; sp90.y = 0.0f; - sp90.z = D_80B7E138; + sp90.z = sLureWigglePosY; Matrix_RotateY(sLureRot.y, MTXMODE_NEW); - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { Matrix_MultVec3f(&sp90, &sp64); - D_80B7E128.x = sp64.x; - D_80B7E128.z = sp64.z; + sLureLineSegPosDelta.x = sp64.x; + sLureLineSegPosDelta.z = sp64.z; phi_f0 = 10.0f; } else { - Matrix_MultVec3f(&sp90, &D_80B7E128); + Matrix_MultVec3f(&sp90, &sLureLineSegPosDelta); phi_f0 = 0.0f; } - D_80B7E104 = 0.0f; + sLure1Rotate = 0.0f; - if ((D_80B7E0B6 == 1) && CHECK_BTN_ALL(input->cur.button, BTN_A)) { - D_80B7E128.y = -2.0f; + if ((sLureEquipped == FS_LURE_UNK) && CHECK_BTN_ALL(input->cur.button, BTN_A)) { + sLureLineSegPosDelta.y = -2.0f; - if ((D_80B7E0AE & 1) != 0) { - D_80B7E104 = 0.5f; + if ((sLureTimer & 1) != 0) { + sLure1Rotate = 0.5f; } else { - D_80B7E104 = -0.5f; + sLure1Rotate = -0.5f; } } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(play) + phi_f0)) { - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { sp58 = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos = sLurePos; Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 30.0f, UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_6); this->actor.world.pos = sp58; - D_80B7E128.y += -0.5f; - if (D_80B7E128.y < -1.0f) { - D_80B7E128.y = -1.0f; + sLureLineSegPosDelta.y += -0.5f; + if (sLureLineSegPosDelta.y < -1.0f) { + sLureLineSegPosDelta.y = -1.0f; } if (sLurePos.y < (this->actor.floorHeight + 5.0f)) { sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y = this->actor.floorHeight + 5.0f; - D_80B7E128.y = 0.0f; + sLureLineSegPosDelta.y = 0.0f; } else { - D_80B7E120 = 1; + sWiggleAttraction = 1; } } else { - D_80B7E128.y = fabsf(sReelLinePos[LINE_SEG_COUNT - 1].y - WATER_SURFACE_Y(play)) * 0.2f; - if (D_80B7E128.y > 1.5f) { - D_80B7E128.y = 1.5f; + sLureLineSegPosDelta.y = fabsf(sReelLinePos[LINE_SEG_COUNT - 1].y - WATER_SURFACE_Y(play)) * 0.2f; + if (sLureLineSegPosDelta.y > 1.5f) { + sLureLineSegPosDelta.y = 1.5f; } } } - sReelLinePos[LINE_SEG_COUNT - 1].x += D_80B7E128.x; - sReelLinePos[LINE_SEG_COUNT - 1].y += D_80B7E128.y; - sReelLinePos[LINE_SEG_COUNT - 1].z += D_80B7E128.z; + sReelLinePos[LINE_SEG_COUNT - 1].x += sLureLineSegPosDelta.x; + sReelLinePos[LINE_SEG_COUNT - 1].y += sLureLineSegPosDelta.y; + sReelLinePos[LINE_SEG_COUNT - 1].z += sLureLineSegPosDelta.z; if (sReelLinePos[LINE_SEG_COUNT - 1].y > (spE4 + 6.0f)) { sReelLinePos[LINE_SEG_COUNT - 1].y -= 5.0f; } - D_80B7E0E8.x = D_80B7E0E8.y = D_80B7E0E8.z = D_80B7E0F8.y = 0.0f; + sLurePosDelta.x = sLurePosDelta.y = sLurePosDelta.z = sLureCastDelta.y = 0.0f; if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { if (CHECK_BTN_ALL(input->cur.button, BTN_R)) { - D_80B7E144 += 1.5f; + sRodLineSpooled += 1.5f; Sfx_PlaySfxCentered(NA_SE_IT_FISHING_REEL_HIGH - SFX_FLAG); - Math_ApproachF(&D_80B7E154, 1000.0f, 1.0f, 2.0f); + Math_ApproachF(&sReelLinePosStep, 1000.0f, 1.0f, 2.0f); } else { - D_80B7E144 += D_80B7E11C; + sRodLineSpooled += sRodReelingSpeed; Sfx_PlaySfxCentered(NA_SE_IT_FISHING_REEL_SLOW - SFX_FLAG); - Math_ApproachF(&D_80B7E154, 1000.0f, 1.0f, 0.2f); + Math_ApproachF(&sReelLinePosStep, 1000.0f, 1.0f, 0.2f); } if (sReelLinePos[LINE_SEG_COUNT - 1].y > (WATER_SURFACE_Y(play) + 4.0f)) { @@ -2578,31 +2593,31 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { Math_ApproachF(&D_80B7E148, 2.0f, 1.0f, 0.2f); } - Math_ApproachF(&sLurePos.x, sReelLinePos[LINE_SEG_COUNT - 1].x, 1.0f, D_80B7E154); - Math_ApproachF(&sLurePos.y, sReelLinePos[LINE_SEG_COUNT - 1].y, 1.0f, D_80B7E154); - Math_ApproachF(&sLurePos.z, sReelLinePos[LINE_SEG_COUNT - 1].z, 1.0f, D_80B7E154); + Math_ApproachF(&sLurePos.x, sReelLinePos[LINE_SEG_COUNT - 1].x, 1.0f, sReelLinePosStep); + Math_ApproachF(&sLurePos.y, sReelLinePos[LINE_SEG_COUNT - 1].y, 1.0f, sReelLinePosStep); + Math_ApproachF(&sLurePos.z, sReelLinePos[LINE_SEG_COUNT - 1].z, 1.0f, sReelLinePosStep); - if (D_80B7E138 > 1.0f) { - Math_ApproachF(&D_80B7E154, 1000.0f, 1.0f, 1.0f); + if (sLureWigglePosY > 1.0f) { + Math_ApproachF(&sReelLinePosStep, 1000.0f, 1.0f, 1.0f); } - Math_ApproachF(&D_80B7E154, 1000.0f, 1.0f, 0.1f); + Math_ApproachF(&sReelLinePosStep, 1000.0f, 1.0f, 0.1f); - if (D_80B7E144 >= 195.0f) { - D_80B7E144 = 195.0f; - D_80B7A694 = 0; + if (sRodLineSpooled >= 195.0f) { + sRodLineSpooled = 195.0f; + sRodCastState = 0; D_80B7E148 = 520.0f; - D_80B7A6CC = 3; + sFishingPlayerCinematicState = 3; } if ((sLurePos.y <= (WATER_SURFACE_Y(play) + 4.0f)) && (sLurePos.y >= (WATER_SURFACE_Y(play) - 4.0f))) { - phi_v0 = 63; - if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_80B7E138 > 1.0f)) { - phi_v0 = 1; + timer = 63; + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (sLureWigglePosY > 1.0f)) { + timer = 1; } - if ((D_80B7E0AE & phi_v0) == 0) { + if ((sLureTimer & timer) == 0) { spA8 = sLurePos; spA8.y = WATER_SURFACE_Y(play); Fishing_SpawnRipple(NULL, play->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); @@ -2613,20 +2628,20 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { case 4: if (this->unk_157 != 0) { this->unk_157--; - D_80B7E144 += D_80B7E11C; + sRodLineSpooled += sRodReelingSpeed; } if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { if ((SQ(sLurePos.x) + SQ(sLurePos.z)) > SQ(920.0f)) { - D_80B7E144 += (1.0f + (KREG(65) * 0.1f)); + sRodLineSpooled += (1.0f + (KREG(65) * 0.1f)); } else { - D_80B7E144 += D_80B7E11C; + sRodLineSpooled += sRodReelingSpeed; } Sfx_PlaySfxCentered(NA_SE_IT_FISHING_REEL_SLOW - SFX_FLAG); } - if ((D_80B7E0AE & 0x1F) == 0) { - if ((D_80B7E124 != 0) || (D_80B7E0B6 != 2)) { + if ((sLureTimer & 0x1F) == 0) { + if (sLineHooked || (sLureEquipped != FS_LURE_SINKING)) { D_80B7A6A4 = 5; } } @@ -2635,7 +2650,7 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { break; case 5: - D_80B7E14C = 0.0005000001f; + sFishingLineScale = 0.0005000001f; sReelLinePos[LINE_SEG_COUNT - 1].x = sLurePos.x; sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y; sReelLinePos[LINE_SEG_COUNT - 1].z = sLurePos.z; @@ -2644,7 +2659,7 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { } } -s32 func_80B70A2C(Fishing* this, PlayState* play, u8 ignorePosCheck) { +s32 Fishing_SplashBySize(Fishing* this, PlayState* play, u8 ignorePosCheck) { s16 i; s16 count; f32 scale; @@ -2658,9 +2673,9 @@ s32 func_80B70A2C(Fishing* this, PlayState* play, u8 ignorePosCheck) { } // Necessary to match - if (this->unk_1AC) {} + if (this->fishLength) {} - if (this->unk_1AC >= 40.0f) { + if (this->fishLength >= 40.0f) { count = 40; scale = 1.2f; } else { @@ -2690,12 +2705,12 @@ s32 func_80B70A2C(Fishing* this, PlayState* play, u8 ignorePosCheck) { Fishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &pos, 100.0f, 800.0f, 150, 90); - this->unk_151 = 30; + this->lilyTimer = 30; return true; } -void func_80B70CF0(Fishing* this, PlayState* play) { +void Fishing_SplashBySize2(Fishing* this, PlayState* play) { s16 count; s16 i; f32 scale; @@ -2705,9 +2720,9 @@ void func_80B70CF0(Fishing* this, PlayState* play) { f32 angle; // Necessary to match - if (this->unk_1AC) {} + if (this->fishLength) {} - if (this->unk_1AC >= 45.0f) { + if (this->fishLength >= 45.0f) { count = 30; scale = 0.5f; } else { @@ -2734,86 +2749,86 @@ void func_80B70CF0(Fishing* this, PlayState* play) { } void func_80B70ED4(Fishing* this, Input* input) { - Vec3f sp34; + Vec3f lineVec; Vec3f sp28; - f32 sp24; + f32 lineLengthSQ; - sp34.x = sLurePos.x - this->actor.world.pos.x; - sp34.y = sLurePos.y - this->actor.world.pos.y; - sp34.z = sLurePos.z - this->actor.world.pos.z; + lineVec.x = sLurePos.x - this->actor.world.pos.x; + lineVec.y = sLurePos.y - this->actor.world.pos.y; + lineVec.z = sLurePos.z - this->actor.world.pos.z; - sp24 = SQ(sp34.x) + SQ(sp34.y) + SQ(sp34.z); + lineLengthSQ = SQ(lineVec.x) + SQ(lineVec.y) + SQ(lineVec.z); - if ((D_80B7A694 == 3) && (this->unk_1A2 == 0) && (D_80B7A68C == 0)) { + if ((sRodCastState == 3) && (this->unk_1A2 == 0) && !sIsOwnersHatHooked) { Matrix_RotateY(BINANG_TO_RAD_ALT(-this->actor.shape.rot.y), MTXMODE_NEW); - Matrix_MultVec3f(&sp34, &sp28); + Matrix_MultVec3f(&lineVec, &sp28); - if ((sp28.z > 0.0f) || (this->unk_1AC < 40.0f)) { - if ((this->unk_158 == 7) && (sp24 < SQ(200.0f))) { - this->unk_158 = 4; - this->unk_1B4 = sLurePos; - this->unk_1B0 = 28672.0f; - this->unk_188 = 5.0f; + if ((sp28.z > 0.0f) || (this->fishLength < 40.0f)) { + if ((this->fishState == 7) && (lineLengthSQ < SQ(200.0f))) { + this->fishState = 4; + this->fishTargetPos = sLurePos; + this->rotationStep = 28672.0f; + this->speedTarget = 5.0f; } else { - if ((CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_80B7E138 > 1.0f)) && (sp24 < SQ(120.0f))) { - this->unk_158 = 2; + if ((CHECK_BTN_ALL(input->cur.button, BTN_A) || (sLureWigglePosY > 1.0f)) && (lineLengthSQ < SQ(120.0f))) { + this->fishState = 2; this->unk_15E = 0; - this->unk_17A[0] = 0; - this->unk_17A[2] = (s16)Rand_ZeroFloat(100.0f) + 100; - this->unk_1A8 = sFishInits[this->actor.params - 100].unk_0C; - this->unk_1B0 = 0.0f; + this->timerArray[0] = 0; + this->timerArray[2] = (s16)Rand_ZeroFloat(100.0f) + 100; + this->perception = sFishInits[this->actor.params - EN_FISH_PARAM].perception; + this->rotationStep = 0.0f; } - if ((this->unk_17A[1] == 0) && (sp24 < SQ(70.0f))) { - this->unk_158 = 2; + if ((this->timerArray[1] == 0) && (lineLengthSQ < SQ(70.0f))) { + this->fishState = 2; this->unk_15E = 0; - this->unk_17A[0] = 0; - this->unk_17A[2] = (s16)Rand_ZeroFloat(100.0f) + 100; - this->unk_1A8 = sFishInits[this->actor.params - 100].unk_0C; - this->unk_1B0 = 0.0f; + this->timerArray[0] = 0; + this->timerArray[2] = (s16)Rand_ZeroFloat(100.0f) + 100; + this->perception = sFishInits[this->actor.params - EN_FISH_PARAM].perception; + this->rotationStep = 0.0f; } } } - } else if ((D_80B7A694 == 4) && (D_80B7E124 != 0) && (sp24 < SQ(100.0f)) && (this->unk_158 >= 10)) { - this->unk_15A = 0; - this->unk_158 = 1; + } else if ((sRodCastState == 4) && sLineHooked && (lineLengthSQ < SQ(100.0f)) && (this->fishState >= 10)) { + this->fishStateNext = 0; + this->fishState = 1; this->unk_1A4 = 1000; this->unk_1A2 = 100; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } - if ((D_80B7E0B6 != 2) && (D_80B7E114 != 0) && (this->unk_1AC > 60.0f) && (sp24 < SQ(30.0f)) && - (this->unk_158 >= 10)) { - this->unk_15A = 0; - this->unk_158 = 1; + if ((sLureEquipped != FS_LURE_SINKING) && (D_80B7E114 != 0) && (this->fishLength > 60.0f) && + (lineLengthSQ < SQ(30.0f)) && (this->fishState >= 10)) { + this->fishStateNext = 0; + this->fishState = 1; this->unk_1A4 = 1000; this->unk_1A2 = 100; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } } -void func_80B71278(Fishing* this, u8 arg1) { +void Fishing_FishLeapSfx(Fishing* this, u8 outOfWater) { s16 sfxId; - u8 temp; + u8 length; - if (this->unk_150 == 0) { - temp = this->unk_1AC; + if (this->isLoach == 0) { + length = this->fishLength; } else { - temp = 2.0f * this->unk_1AC; + length = 2.0f * this->fishLength; } - if (arg1 == 0) { - if (temp >= 50) { + if (outOfWater == false) { + if (length >= 50) { sfxId = NA_SE_EV_DIVE_INTO_WATER; - } else if (temp >= 40) { + } else if (length >= 40) { sfxId = NA_SE_EV_BOMB_DROP_WATER; } else { sfxId = NA_SE_EV_BOMB_DROP_WATER; } } else { - if (temp >= 50) { + if (length >= 50) { sfxId = NA_SE_EV_JUMP_OUT_WATER; - } else if (temp >= 40) { + } else if (length >= 40) { sfxId = NA_SE_EV_OUT_OF_WATER; } else { sfxId = NA_SE_EV_OUT_OF_WATER; @@ -2825,8 +2840,8 @@ void func_80B71278(Fishing* this, u8 arg1) { void Fishing_HandleAquariumDialog(Fishing* this, PlayState* play) { if (sLinkAge == LINK_AGE_CHILD) { - if ((HIGH_SCORE(HS_FISHING) & 0x7F) != 0) { - if (HIGH_SCORE(HS_FISHING) & 0x80) { + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_CHILD) != 0) { + if (HIGH_SCORE(HS_FISHING) & HS_FISH_CHEAT_CHILD) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2835,8 +2850,8 @@ void Fishing_HandleAquariumDialog(Fishing* this, PlayState* play) { this->actor.textId = 0x40AE; } } else { - if ((HIGH_SCORE(HS_FISHING) & 0x7F000000) != 0) { - if (HIGH_SCORE(HS_FISHING) & 0x80000000) { + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_ADULT) != 0) { + if (HIGH_SCORE(HS_FISHING) & HS_FISH_CHEAT_ADULT) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2846,47 +2861,47 @@ void Fishing_HandleAquariumDialog(Fishing* this, PlayState* play) { } } - if (this->unk_1D3 == 0) { - if (this->unk_1D4 == 0) { + if (!this->isAquariumMessage) { + if (this->aquariumWaitTimer == 0) { this->actor.flags |= ACTOR_FLAG_0; if (Actor_ProcessTalkRequest(&this->actor, play)) { - D_80B7A678 = D_80B7E078; - this->unk_1D3 = 1; + sFishLengthToWeigh = sFishingRecordLength; + this->isAquariumMessage = true; } else { func_8002F2F4(&this->actor, play); } } else { - this->unk_1D4--; + this->aquariumWaitTimer--; this->actor.flags &= ~ACTOR_FLAG_0; } } else if (Actor_TextboxIsClosing(&this->actor, play)) { - this->unk_1D3 = 0; - this->unk_1D4 = 20; + this->isAquariumMessage = false; + this->aquariumWaitTimer = 20; } } void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { s16 i; - s16 sp134 = 10; - f32 sp130; - f32 sp12C; - f32 sp128; - f32 sp124; + s16 rotXYScale = 10; + f32 distX; + f32 distY; + f32 distZ; + f32 distToTarget; f32 multiplier; - f32 sp11C; - f32 sp118; - Vec3f sp10C; - Vec3f sp100; - s16 spFE; - s16 spFC; - s16 spFA; - s16 phi_v0; + f32 chance; + f32 playerSpeedMod; + Vec3f multiVecSrc; + Vec3f targetPosOffset; + s16 rotXTarget; + s16 rotYtarget; + s16 rotZScale; + s16 timer; s16 spF6; - s16 spF4; - s16 spF2; - s16 spF0; - s16 spEE; + s16 rotXScale; + s16 rotXStep; + s16 rotYScale; + s16 rotYStep; Fishing* this = (Fishing*)thisx; PlayState* play = play2; Player* player = GET_PLAYER(play); @@ -2894,47 +2909,47 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { f32 spD8; f32 phi_f0; f32 phi_f2; - Vec3f spC4; + Vec3f bubblePos; Vec3f spB8; u8 phi_v0_2; f32 temp_f0; f32 temp; s32 pad; - f32 spA4; - u16 spA2; - u8 phi_a1; + f32 rumbleStrength; + u16 attempts; + u8 rumbleStrength8; this->actor.uncullZoneForward = 700.0f; this->actor.uncullZoneScale = 50.0f; - if (this->unk_150 == 0) { - sp118 = (player->actor.speed * 0.15f) + 0.25f; + if (this->isLoach == 0) { + playerSpeedMod = (player->actor.speed * 0.15f) + 0.25f; } else { - sp118 = (player->actor.speed * 0.3f) + 0.25f; + playerSpeedMod = (player->actor.speed * 0.3f) + 0.25f; } if ((D_80B7E0B0 != 0) || (sSubCamId != SUB_CAM_ID_DONE) || - ((player->actor.world.pos.z > 1150.0f) && (this->unk_158 != 100))) { + ((player->actor.world.pos.z > 1150.0f) && (this->fishState != 100))) { this->actor.flags &= ~ACTOR_FLAG_0; } else { this->actor.flags |= ACTOR_FLAG_0; - if (D_80B7A694 != 0) { + if (sRodCastState != 0) { if (D_80B7E0B2 == 0) { this->actor.focus.pos = sLurePos; } else if (D_80B7E0B2 == 1) { - D_80B7A6CC = 1; + sFishingPlayerCinematicState = 1; D_80B7FED0 = 0.0f; - D_80B7E088 = 2; + sLureCameraZoomLevel = 2; } } this->actor.focus.pos = this->actor.world.pos; } - this->unk_15C++; + this->stateAndTimer++; for (i = 0; i < 4; i++) { - if (this->unk_17A[i] != 0) { - this->unk_17A[i]--; + if (this->timerArray[i] != 0) { + this->timerArray[i]--; } } @@ -2946,18 +2961,18 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_1A2--; } - if (this->unk_1A0 != 0) { - this->unk_1A0--; + if (this->bumpTimer != 0) { + this->bumpTimer--; } - if (this->unk_151 != 0) { - this->unk_151--; + if (this->lilyTimer != 0) { + this->lilyTimer--; } - Math_ApproachF(&this->unk_198, this->unk_190, 1.0f, 0.2f); + Math_ApproachF(&this->fishLimbRotPhaseStep, this->unk_190, 1.0f, 0.2f); - if (this->unk_158 == 6) { - Math_ApproachF(&this->unk_19C, this->unk_194, 0.2f, 200.0f); + if (this->fishState == 6) { + Math_ApproachF(&this->fishLimbRotPhaseMag, this->unk_194, 0.2f, 200.0f); } else { phi_f0 = 1.0f; phi_f2 = 1.0f; @@ -2965,62 +2980,62 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { phi_f0 = (KREG(64) * 0.1f) + 1.5f; phi_f2 = 3.0f; } - Math_ApproachF(&this->unk_19C, this->unk_194 * phi_f0, 1.0f, 500.0f * phi_f2); + Math_ApproachF(&this->fishLimbRotPhaseMag, this->unk_194 * phi_f0, 1.0f, 500.0f * phi_f2); } - Math_ApproachS(&this->unk_170, 0, 5, 0x1F4); + Math_ApproachS(&this->fishLimbDRotZDelta, 0, 5, 500); - if (this->unk_150 == 0) { - Actor_SetScale(&this->actor, this->unk_1AC * 15.0f * 0.00001f); + if (this->isLoach == 0) { + Actor_SetScale(&this->actor, this->fishLength * 15.0f * 0.00001f); - this->unk_18C += this->unk_198; + this->fishLimbRotPhase += this->fishLimbRotPhaseStep; - temp = cosf(this->unk_18C); - this->unk_16C = this->unk_16E + (s16)(temp * this->unk_19C); + temp = cosf(this->fishLimbRotPhase); + this->fishLimb23RotYDelta = this->unk_16E + (s16)(temp * this->fishLimbRotPhaseMag); - temp = cosf(this->unk_18C + -1.2f); - this->unk_176 = this->unk_16E + (s16)(temp * this->unk_19C * 1.6f); + temp = cosf(this->fishLimbRotPhase + -1.2f); + this->fishLimb4RotYDelta = this->unk_16E + (s16)(temp * this->fishLimbRotPhaseMag * 1.6f); } else { - Actor_SetScale(&this->actor, this->unk_1AC * 65.0f * 0.000001f); + Actor_SetScale(&this->actor, this->fishLength * 65.0f * 0.000001f); this->actor.scale.x = this->actor.scale.z * 1.1f; this->actor.scale.y = this->actor.scale.z * 1.1f; - this->unk_18C += this->unk_198 * 0.8f; + this->fishLimbRotPhase += this->fishLimbRotPhaseStep * 0.8f; for (i = 0; i < 3; i++) { - temp = cosf(this->unk_18C + (i * 2.1f)); - this->unk_1CC[i] = this->unk_16E + (s16)(temp * this->unk_19C * 2.0f); + temp = cosf(this->fishLimbRotPhase + (i * 2.1f)); + this->loachRotYDelta[i] = this->unk_16E + (s16)(temp * this->fishLimbRotPhaseMag * 2.0f); } - temp = cosf(this->unk_18C + 0.4f); - this->unk_16C = (this->unk_19C * temp * 2.0f) * 0.6f; + temp = cosf(this->fishLimbRotPhase + 0.4f); + this->fishLimb23RotYDelta = (this->fishLimbRotPhaseMag * temp * 2.0f) * 0.6f; } - sp130 = this->unk_1B4.x - this->actor.world.pos.x; - sp12C = this->unk_1B4.y - this->actor.world.pos.y; - sp128 = this->unk_1B4.z - this->actor.world.pos.z; + distX = this->fishTargetPos.x - this->actor.world.pos.x; + distY = this->fishTargetPos.y - this->actor.world.pos.y; + distZ = this->fishTargetPos.z - this->actor.world.pos.z; - spFC = Math_Atan2S(sp128, sp130); - sp124 = sqrtf(SQ(sp130) + SQ(sp128)); + rotYtarget = Math_Atan2S(distZ, distX); + distToTarget = sqrtf(SQ(distX) + SQ(distZ)); - spFE = Math_Atan2S(sp124, sp12C); - sp124 = sqrtf(SQ(sp130) + SQ(sp128) + SQ(sp12C)); + rotXTarget = Math_Atan2S(distToTarget, distY); + distToTarget = sqrtf(SQ(distX) + SQ(distZ) + SQ(distY)); - if ((this->unk_1A0 != 0) && (this->unk_158 != 2) && (this->unk_158 != 3) && (this->unk_158 != 4)) { - if ((this->unk_15C & 0x40) != 0) { - spFC += 0x4000; + if ((this->bumpTimer != 0) && (this->fishState != 2) && (this->fishState != 3) && (this->fishState != 4)) { + if ((this->stateAndTimer & 0x40) != 0) { + rotYtarget += 0x4000; } else { - spFC -= 0x4000; + rotYtarget -= 0x4000; } - if (((this->unk_15C + 0x20) & 0x40) != 0) { - spFE += 0x2000; + if (((this->stateAndTimer + 0x20) & 0x40) != 0) { + rotXTarget += 0x2000; } else { - spFE -= 0x2000; + rotXTarget -= 0x2000; } } - switch (this->unk_158) { + switch (this->fishState) { case 100: Fishing_HandleAquariumDialog(this, play); @@ -3031,109 +3046,109 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { (s16)this->actor.world.pos.y + 20.0f, (s16)this->actor.world.pos.z - 50.0f, 255, 255, 255, 255); - this->unk_1AC = D_80B7E078; - sp100.y = (f32)Math_SinS(play->gameplayFrames * 300) * 1; - sp100.z = (f32)Math_SinS(play->gameplayFrames * 230) * 2; + this->fishLength = sFishingRecordLength; + targetPosOffset.y = (f32)Math_SinS(play->gameplayFrames * 300) * 1; + targetPosOffset.z = (f32)Math_SinS(play->gameplayFrames * 230) * 2; this->actor.world.pos.x = 130.0f; - this->actor.world.pos.y = 55.0f + sp100.y; - this->actor.world.pos.z = 1300.0f + sp100.z; + this->actor.world.pos.y = 55.0f + targetPosOffset.y; + this->actor.world.pos.z = 1300.0f + targetPosOffset.z; this->actor.shape.rot.y = -0x8000; if ((this->actor.projectedPos.z < 200.0f) && (this->actor.projectedPos.z > 0.0f)) { - spC4.x = Rand_CenteredFloat(5.0f) + 130.0f; - spC4.y = 40.0f; - spC4.z = Rand_CenteredFloat(5.0f) + 1280.0f; - Fishing_SpawnBubble(NULL, play->specialEffects, &spC4, Rand_ZeroFloat(0.02f) + 0.03f, 1); + bubblePos.x = Rand_CenteredFloat(5.0f) + 130.0f; + bubblePos.y = 40.0f; + bubblePos.z = Rand_CenteredFloat(5.0f) + 1280.0f; + Fishing_SpawnBubble(NULL, play->specialEffects, &bubblePos, Rand_ZeroFloat(0.02f) + 0.03f, 1); } - Math_ApproachS(&this->unk_172, (Math_SinS(this->unk_15C * 0x800) * 2500.0f) + 2500.0f, 2, 0x7D0); - Math_ApproachS(&this->unk_174, Math_SinS(this->unk_15C * 0xA00) * 1500.0f, 2, 0x7D0); + Math_ApproachS(&this->fishLimbEFRotYDelta, (Math_SinS(this->stateAndTimer * 0x800) * 2500.0f) + 2500.0f, 2, 0x7D0); + Math_ApproachS(&this->fishLimb89RotYDelta, Math_SinS(this->stateAndTimer * 0xA00) * 1500.0f, 2, 0x7D0); this->unk_190 = 0.3f; this->unk_194 = 1000.0f / 3.0f; return; case 10: - this->unk_1B4 = this->actor.home.pos; + this->fishTargetPos = this->actor.home.pos; Math_ApproachF(&this->actor.speed, 2.0f, 1.0f, 0.5f); - Math_ApproachF(&this->unk_1B0, 4096.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 4096.0f, 1.0f, 256.0f); - if (sp124 < 40.0f) { - this->unk_158 = 11; + if (distToTarget < 40.0f) { + this->fishState = 11; this->unk_190 = 0.4f; this->unk_194 = 500.0f; } func_80B70ED4(this, input); - if (this->actor.xzDistToPlayer < (250.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; + if (this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) { + this->fishStateNext = this->fishState = 0; this->unk_1A4 = 1000; this->unk_1A2 = 200; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } break; case 11: - this->unk_1B4 = this->actor.home.pos; + this->fishTargetPos = this->actor.home.pos; Math_ApproachF(&this->actor.speed, 0.0f, 1.0f, 0.05f); - Math_ApproachF(&this->unk_1B0, 0.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 0.0f, 1.0f, 256.0f); - if (sp124 >= 40.0f) { - this->unk_158 = 10; + if (distToTarget >= 40.0f) { + this->fishState = 10; this->unk_190 = 1.0f; this->unk_194 = 2000.0f; } func_80B70ED4(this, input); - if (this->actor.xzDistToPlayer < (250.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; + if (this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) { + this->fishStateNext = this->fishState = 0; this->unk_1A4 = 1000; this->unk_1A2 = 200; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if ((gSaveContext.save.dayTime >= CLOCK_TIME(18, 0)) && (gSaveContext.save.dayTime <= CLOCK_TIME(18, 0) + 27)) { - this->unk_158 = 7; - this->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 200; + this->fishState = 7; + this->timerArray[3] = (s16)Rand_ZeroFloat(150.0f) + 200; } if ((gSaveContext.save.dayTime >= CLOCK_TIME(5, 30) - 1) && (gSaveContext.save.dayTime < CLOCK_TIME(5, 30) + 27)) { - this->unk_158 = 7; - this->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 200; + this->fishState = 7; + this->timerArray[3] = (s16)Rand_ZeroFloat(150.0f) + 200; } } if (KREG(15) != 0) { KREG(15) = 0; - this->unk_158 = 7; - this->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 2000; + this->fishState = 7; + this->timerArray[3] = (s16)Rand_ZeroFloat(150.0f) + 2000; } break; case 0: Math_ApproachF(&this->actor.speed, 1.0f, 1.0f, 0.05f); - Math_ApproachF(&this->unk_1B0, 0.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 0.0f, 1.0f, 256.0f); - if (this->unk_17A[0] == 0) { + if (this->timerArray[0] == 0) { if (this->unk_1A4 == 0) { - this->unk_158 = this->unk_15A = 10; + this->fishState = this->fishStateNext = 10; } else { - this->unk_158 = 1; - this->unk_17A[0] = (s16)Rand_ZeroFloat(30.0f) + 10; - this->unk_1B4.x = Rand_CenteredFloat(300.0f); - this->unk_1B4.y = (WATER_SURFACE_Y(play) - 50.0f) - Rand_ZeroFloat(50.0f); - this->unk_1B4.z = Rand_CenteredFloat(300.0f); + this->fishState = 1; + this->timerArray[0] = (s16)Rand_ZeroFloat(30.0f) + 10; + this->fishTargetPos.x = Rand_CenteredFloat(300.0f); + this->fishTargetPos.y = (WATER_SURFACE_Y(play) - 50.0f) - Rand_ZeroFloat(50.0f); + this->fishTargetPos.z = Rand_CenteredFloat(300.0f); this->unk_190 = 1.0f; this->unk_194 = 2000.0f; } } - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { func_80B70ED4(this, input); } else { this->actor.flags &= ~ACTOR_FLAG_0; @@ -3141,36 +3156,36 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { break; case 1: - if (this->unk_150 == 1) { - this->unk_158 = -1; + if (this->isLoach == 1) { + this->fishState = -1; this->unk_1A4 = 20000; this->unk_1A2 = 20000; - this->unk_1B4.x = 0.0f; - this->unk_1B4.y = -140.0f; - this->unk_1B4.z = 0.0f; + this->fishTargetPos.x = 0.0f; + this->fishTargetPos.y = -140.0f; + this->fishTargetPos.z = 0.0f; } else { - Math_ApproachF(&this->unk_1B0, 4096.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 4096.0f, 1.0f, 256.0f); - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - Math_ApproachF(&this->unk_1B0, 8192.0f, 1.0f, 768.0f); + if ((this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) || (this->timerArray[1] != 0)) { + Math_ApproachF(&this->rotationStep, 8192.0f, 1.0f, 768.0f); Math_ApproachF(&this->actor.speed, 4.2f, 1.0f, 0.75); this->unk_190 = 1.2f; this->unk_194 = 4000.0f; - this->unk_17A[0] = 20; + this->timerArray[0] = 20; } else { this->unk_190 = 1.0f; this->unk_194 = 2000.0f; Math_ApproachF(&this->actor.speed, 1.5f, 1.0f, 0.1f); } - if ((this->unk_17A[0] == 0) || (sp124 < 50.0f)) { - this->unk_158 = 0; - this->unk_17A[0] = (s16)Rand_ZeroFloat(30.0f) + 3; + if ((this->timerArray[0] == 0) || (distToTarget < 50.0f)) { + this->fishState = 0; + this->timerArray[0] = (s16)Rand_ZeroFloat(30.0f) + 3; this->unk_190 = 1.0f; this->unk_194 = 500.0f; } - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { func_80B70ED4(this, input); } else { this->actor.flags &= ~ACTOR_FLAG_0; @@ -3178,57 +3193,57 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } break; - case -1: - Math_ApproachS(&this->unk_166, 0, 0x14, 0x20); + case -1: // loach state 1 + Math_ApproachS(&this->rotationTarget.x, 0, 0x14, 0x20); - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { + if ((this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) || (this->timerArray[1] != 0)) { Math_ApproachF(&this->actor.speed, 3.0f, 1.0f, 0.75); this->unk_190 = 1.0f; - this->unk_17A[0] = 20; + this->timerArray[0] = 20; this->unk_194 = 4000.0f; - Math_ApproachF(&this->unk_1B0, 4096.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 4096.0f, 1.0f, 256.0f); if ((play->gameplayFrames % 32) == 0) { - this->unk_1B4.x = Rand_CenteredFloat(600.0f); - this->unk_1B4.z = Rand_CenteredFloat(600.0f); - this->unk_1B4.y = -120.0f; + this->fishTargetPos.x = Rand_CenteredFloat(600.0f); + this->fishTargetPos.z = Rand_CenteredFloat(600.0f); + this->fishTargetPos.y = -120.0f; } - } else if (sp124 > 50.0f) { + } else if (distToTarget > 50.0f) { this->unk_190 = 0.8f; this->unk_194 = 1500.0f; Math_ApproachF(&this->actor.speed, 1.0f, 1.0f, 0.1f); - Math_ApproachF(&this->unk_1B0, 2048.0f, 1.0f, 128.0f); + Math_ApproachF(&this->rotationStep, 2048.0f, 1.0f, 128.0f); } else { this->unk_190 = 0.4f; this->unk_194 = 500.0f; Math_ApproachZeroF(&this->actor.speed, 1.0f, 0.02f); - Math_ApproachF(&this->unk_1B0, 0.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 0.0f, 1.0f, 256.0f); } if (this->unk_1A4 == 0) { - this->unk_158 = 10; - this->unk_15A = 10; + this->fishState = 10; + this->fishStateNext = 10; } else if ((KREG(2) != 0) || (((this->unk_1A4 & 0x7FF) == 0) && (this->unk_1A4 < 15000))) { KREG(2) = 0; - this->unk_158 = -2; + this->fishState = -2; this->actor.world.rot.x = this->actor.shape.rot.x = 0; - this->unk_1B4.y = WATER_SURFACE_Y(play) + 10.0f; - this->unk_1B4.x = Rand_ZeroFloat(50.0f); - this->unk_1B4.z = Rand_ZeroFloat(50.0f); + this->fishTargetPos.y = WATER_SURFACE_Y(play) + 10.0f; + this->fishTargetPos.x = Rand_ZeroFloat(50.0f); + this->fishTargetPos.z = Rand_ZeroFloat(50.0f); } this->actor.flags &= ~ACTOR_FLAG_0; break; case -2: - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - this->unk_158 = -1; - this->unk_1B4.y = -120.0f; + if ((this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) || (this->timerArray[1] != 0)) { + this->fishState = -1; + this->fishTargetPos.y = -120.0f; } else { this->unk_190 = 0.6f; this->unk_194 = 1000.0f; - Math_ApproachS(&this->unk_166, -0x1000, 0x14, 0x100); + Math_ApproachS(&this->rotationTarget.x, -0x1000, 0x14, 0x100); if (this->actor.world.pos.y < (WATER_SURFACE_Y(play) - 20.0f)) { Math_ApproachF(&this->actor.speed, 0.5f, 1.0f, 0.1f); @@ -3236,11 +3251,11 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { Math_ApproachZeroF(&this->actor.speed, 1.0f, 0.01f); if ((this->actor.speed == 0.0f) || (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 5.0f))) { - this->unk_1B4.x = Rand_ZeroFloat(300.0f); - this->unk_1B4.z = Rand_ZeroFloat(300.0f); - this->unk_1B4.y = this->actor.floorHeight + 10.0f; - this->unk_158 = -25; - this->unk_1B0 = 0.0f; + this->fishTargetPos.x = Rand_ZeroFloat(300.0f); + this->fishTargetPos.z = Rand_ZeroFloat(300.0f); + this->fishTargetPos.y = this->actor.floorHeight + 10.0f; + this->fishState = -25; + this->rotationStep = 0.0f; spB8 = this->fishMouthPos; spB8.y = WATER_SURFACE_Y(play); @@ -3254,99 +3269,99 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } } - Math_ApproachF(&this->unk_1B0, 2048.0f, 1.0f, 128.0f); + Math_ApproachF(&this->rotationStep, 2048.0f, 1.0f, 128.0f); this->actor.flags &= ~ACTOR_FLAG_0; } break; case -25: - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - this->unk_158 = -1; - this->unk_1B4.y = -120.0f; + if ((this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) || (this->timerArray[1] != 0)) { + this->fishState = -1; + this->fishTargetPos.y = -120.0f; } else { - Math_ApproachS(&this->unk_166, 0x1000, 0x14, 0x6A); + Math_ApproachS(&this->rotationTarget.x, 0x1000, 0x14, 0x6A); - if (sp124 > 40.0f) { + if (distToTarget > 40.0f) { this->unk_190 = 0.7f; this->unk_194 = 1200.0f; Math_ApproachF(&this->actor.speed, 0.5f, 1.0f, 0.01f); - Math_ApproachF(&this->unk_1B0, 2048.0f, 1.0f, 128.0f); + Math_ApproachF(&this->rotationStep, 2048.0f, 1.0f, 128.0f); } else { - this->unk_158 = -1; + this->fishState = -1; } } break; case 2: if (((this->actor.params + D_80B7E118) & 1) != 0) { - sp10C.x = 10.0f; + multiVecSrc.x = 10.0f; } else { - sp10C.x = -10.0f; + multiVecSrc.x = -10.0f; } - sp10C.y = 0.0f; - sp10C.z = 0.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 0.0f; Matrix_RotateY(sLureRot.y, MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sp100); + Matrix_MultVec3f(&multiVecSrc, &targetPosOffset); - this->unk_1B4.x = sLurePos.x + sp100.x; - this->unk_1B4.z = sLurePos.z + sp100.z; + this->fishTargetPos.x = sLurePos.x + targetPosOffset.x; + this->fishTargetPos.z = sLurePos.z + targetPosOffset.z; - if (D_80B7E0B6 == 2) { - this->unk_1B4.y = sLurePos.y; - } else if (this->unk_150 == 0) { - this->unk_1B4.y = sLurePos.y - 15.0f; + if (sLureEquipped == FS_LURE_SINKING) { + this->fishTargetPos.y = sLurePos.y; + } else if (this->isLoach == 0) { + this->fishTargetPos.y = sLurePos.y - 15.0f; } else { - this->unk_1B4.y = sLurePos.y - 5.0f; + this->fishTargetPos.y = sLurePos.y - 5.0f; } - if (this->unk_1B4.y <= this->actor.floorHeight) { - this->unk_1B4.y = this->actor.floorHeight + 3.0f; + if (this->fishTargetPos.y <= this->actor.floorHeight) { + this->fishTargetPos.y = this->actor.floorHeight + 3.0f; } - if ((D_80B7E0B6 != 2) && (this->unk_1B4.y < this->actor.world.pos.y)) { - Math_ApproachF(&this->actor.world.pos.y, this->unk_1B4.y, 0.1f, - (this->actor.world.pos.y - this->unk_1B4.y) * 0.1f); + if ((sLureEquipped != FS_LURE_SINKING) && (this->fishTargetPos.y < this->actor.world.pos.y)) { + Math_ApproachF(&this->actor.world.pos.y, this->fishTargetPos.y, 0.1f, + (this->actor.world.pos.y - this->fishTargetPos.y) * 0.1f); } - Math_ApproachF(&this->unk_1B0, 8192.0f, 1.0f, (KREG(16) * 128) + 384.0f); + Math_ApproachF(&this->rotationStep, 8192.0f, 1.0f, (KREG(16) * 128) + 384.0f); if (CHECK_BTN_ALL(input->press.button, BTN_A)) { - this->unk_1A8 += 0.005f; + this->perception += 0.005f; } - if (D_80B7E120 != 0) { - if (D_80B7E120 == 1) { - this->unk_1A8 += 0.01f; + if (sWiggleAttraction != 0) { + if (sWiggleAttraction == 1) { + this->perception += 0.01f; } else { - this->unk_1A8 += 0.05f; + this->perception += 0.05f; } - D_80B7E120 = 0; + sWiggleAttraction = 0; } if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->unk_1A8 += 0.008f; + this->perception += 0.008f; } - if (sp124 < ((this->unk_1AC * 0.5f) + 20.0f)) { + if (distToTarget < ((this->fishLength * 0.5f) + 20.0f)) { if (this->unk_15E == 0) { this->unk_190 = 1.0f; this->unk_194 = 500.0f; - this->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 2; + this->timerArray[0] = (s16)Rand_ZeroFloat(10.0f) + 2; } Math_ApproachF(&this->actor.speed, -0.2f, 1.0f, 0.1f); this->unk_15E = 1; } else { if (this->unk_15E != 0) { this->unk_190 = 1.0f; - this->unk_1B0 = 0.0f; + this->rotationStep = 0.0f; this->unk_194 = 3000.0f; } Math_ApproachF(&this->actor.speed, 3.0f, 1.0f, 0.15f); this->unk_15E = 0; } - if (this->unk_1AC >= 60.0f) { + if (this->fishLength >= 60.0f) { multiplier = 0.3f; - } else if (this->unk_1AC >= 45.0f) { + } else if (this->fishLength >= 45.0f) { multiplier = 0.6f; } else { multiplier = 1.0f; @@ -3357,202 +3372,203 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } else if ((gSaveContext.save.dayTime >= CLOCK_TIME(5, 0)) && (gSaveContext.save.dayTime < CLOCK_TIME(7, 0))) { multiplier *= 1.5f; - } else if (D_80B7E076 != 0) { + } else if (sFishingFoggy != 0) { multiplier *= 1.5f; - } else if ((u8)D_80B7A650 != 0) { + } else if ((u8)sStormStrength != 0) { multiplier *= 3.0f; } - sp11C = 0.03f * multiplier; - if (D_80B7E0B6 == 2) { - sp11C *= 5.0f; + chance = 0.03f * multiplier; + if (sLureEquipped == FS_LURE_SINKING) { + chance *= 5.0f; } - if (((this->unk_17A[0] == 1) || (Rand_ZeroOne() < sp11C)) && - ((Rand_ZeroOne() < (this->unk_1A8 * multiplier)) || ((this->unk_150 + 1) == KREG(69)))) { - if (this->unk_150 == 0) { - this->unk_158 = 3; + if (((this->timerArray[0] == 1) || (Rand_ZeroOne() < chance)) && + ((Rand_ZeroOne() < (this->perception * multiplier)) || ((this->isLoach + 1) == KREG(69)))) { + if (this->isLoach == 0) { + this->fishState = 3; this->unk_190 = 1.2f; this->unk_194 = 5000.0f; - this->unk_17A[0] = Rand_ZeroFloat(10.0f); + this->timerArray[0] = Rand_ZeroFloat(10.0f); } else { - this->unk_158 = -3; + this->fishState = -3; this->unk_190 = 1.0f; this->unk_194 = 3000.0f; - this->unk_17A[0] = 40; + this->timerArray[0] = 40; } - if (D_80B7E0B6 == 2) { - this->unk_188 = Rand_ZeroFloat(1.5f) + 3.0f; + if (sLureEquipped == FS_LURE_SINKING) { + this->speedTarget = Rand_ZeroFloat(1.5f) + 3.0f; } else { - this->unk_188 = Rand_ZeroFloat(1.5f) + 4.5f; + this->speedTarget = Rand_ZeroFloat(1.5f) + 4.5f; } } - if ((D_80B7A694 != 3) || (this->unk_17A[2] == 0) || + if ((sRodCastState != 3) || (this->timerArray[2] == 0) || (sqrtf(SQ(this->actor.world.pos.x) + SQ(this->actor.world.pos.z)) > 800.0f)) { - this->unk_158 = this->unk_15A; - this->unk_17A[1] = (s16)Rand_ZeroFloat(30.0f) + 50; - this->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 5; + this->fishState = this->fishStateNext; + this->timerArray[1] = (s16)Rand_ZeroFloat(30.0f) + 50; + this->timerArray[0] = (s16)Rand_ZeroFloat(10.0f) + 5; this->unk_190 = 1.0f; - this->unk_1B0 = 0.0f; + this->rotationStep = 0.0f; this->unk_194 = 2000.0f; } - if (this->actor.xzDistToPlayer < (100.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; + if (this->actor.xzDistToPlayer < (100.0f * playerSpeedMod)) { + this->fishStateNext = this->fishState = 0; this->unk_1A4 = 1000; this->unk_1A2 = 200; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } break; case 3: - this->unk_151 = 6; - sp134 = 2; + this->lilyTimer = 6; + rotXYScale = 2; if ((((s16)player->actor.world.pos.x + D_80B7E118) & 1) != 0) { - sp10C.x = 30.0f; + multiVecSrc.x = 30.0f; } else { - sp10C.x = -30.0f; + multiVecSrc.x = -30.0f; } - sp10C.y = 0.0f; - sp10C.z = 30.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 30.0f; Matrix_RotateY(sLureRot.y, MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sp100); + Matrix_MultVec3f(&multiVecSrc, &targetPosOffset); - this->unk_1B4.x = sLurePos.x + sp100.x; - this->unk_1B4.z = sLurePos.z + sp100.z; - this->unk_1B4.y = sLurePos.y - 10.0f; - this->unk_1B0 = 4096.0f; - Math_ApproachF(&this->actor.speed, this->unk_188 * 0.8f, 1.0f, 1.0f); + this->fishTargetPos.x = sLurePos.x + targetPosOffset.x; + this->fishTargetPos.z = sLurePos.z + targetPosOffset.z; + this->fishTargetPos.y = sLurePos.y - 10.0f; + this->rotationStep = 4096.0f; + Math_ApproachF(&this->actor.speed, this->speedTarget * 0.8f, 1.0f, 1.0f); - if ((D_80B7A694 != 3) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || + if ((sRodCastState != 3) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { - this->unk_158 = this->unk_15A; - this->unk_17A[0] = 0; + this->fishState = this->fishStateNext; + this->timerArray[0] = 0; this->unk_190 = 1.0f; this->unk_194 = 2000.0f; - } else if ((this->unk_17A[0] == 0) || (sp124 < 30.0f)) { - this->unk_158 = 4; - this->unk_1B4 = sLurePos; - this->unk_1B0 = 16384.0f; + } else if ((this->timerArray[0] == 0) || (distToTarget < 30.0f)) { + this->fishState = 4; + this->fishTargetPos = sLurePos; + this->rotationStep = 16384.0f; this->unk_190 = 1.2f; this->unk_194 = 5000.0f; - this->unk_17A[0] = 20; + this->timerArray[0] = 20; } break; case 4: - Math_ApproachF(&this->unk_1B0, 16384.0f, 1.0f, 4096.0f); - Math_ApproachS(&this->unk_170, 0x4E20, 4, 0x1388); + Math_ApproachF(&this->rotationStep, 16384.0f, 1.0f, 4096.0f); + Math_ApproachS(&this->fishLimbDRotZDelta, 0x4E20, 4, 0x1388); - this->unk_151 = 50; - sp134 = 2; - this->unk_1B4 = sLurePos; - Math_ApproachF(&this->actor.speed, this->unk_188, 1.0f, 1.0f); + this->lilyTimer = 50; + rotXYScale = 2; + this->fishTargetPos = sLurePos; + Math_ApproachF(&this->actor.speed, this->speedTarget, 1.0f, 1.0f); - if ((D_80B7A694 != 3) || (this->unk_17A[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || + if ((sRodCastState != 3) || (this->timerArray[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { - this->unk_17A[0] = 0; - this->unk_158 = this->unk_15A; + this->timerArray[0] = 0; + this->fishState = this->fishStateNext; this->unk_190 = 1.0f; this->unk_194 = 2000.0f; - } else if (sp124 < 10.0f) { - if (func_80B70A2C(this, play, false)) { - func_80B71278(this, 0); + } else if (distToTarget < 10.0f) { + if (Fishing_SplashBySize(this, play, false)) { + Fishing_FishLeapSfx(this, false); } - this->unk_158 = 5; + this->fishState = 5; this->unk_190 = 1.2f; this->unk_194 = 5000.0f; - this->unk_17A[1] = 150; - this->unk_17A[0] = 0; - this->unk_17A[2] = 0; - this->unk_17A[3] = 120; + this->timerArray[1] = 150; + this->timerArray[0] = 0; + this->timerArray[2] = 0; + this->timerArray[3] = 120; - D_80B7A694 = 4; + sRodCastState = 4; sFishingHookedFish = this; sFishMouthOffset.y = 500.0f - Rand_ZeroFloat(400.0f); - if (D_80B7E0B6 == 2) { - if (this->unk_1AC > 70.0f) { - phi_v0 = (s16)Rand_ZeroFloat(20.0f) + 10; - } else if (this->unk_1AC > 60.0f) { - phi_v0 = (s16)Rand_ZeroFloat(30.0f) + 20; - } else if (this->unk_1AC > 50.0f) { - phi_v0 = (s16)Rand_ZeroFloat(30.0f) + 30; + // get rumble time based on size and lure used. + if (sLureEquipped == FS_LURE_SINKING) { + if (this->fishLength > 70.0f) { + timer = (s16)Rand_ZeroFloat(20.0f) + 10; + } else if (this->fishLength > 60.0f) { + timer = (s16)Rand_ZeroFloat(30.0f) + 20; + } else if (this->fishLength > 50.0f) { + timer = (s16)Rand_ZeroFloat(30.0f) + 30; } else { - phi_v0 = (s16)Rand_ZeroFloat(40.0f) + 40; + timer = (s16)Rand_ZeroFloat(40.0f) + 40; } - D_80B7E122 = phi_v0; - D_80B7E0A4 = phi_v0; - Rumble_Override(0.0f, 60, phi_v0 * 3, 10); + sLureBitTimer = timer; + sRumbleDelay = timer; + Rumble_Override(0.0f, 60, timer * 3, 10); } else { - if (this->unk_1AC > 70.0f) { - phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 10; - } else if (this->unk_1AC > 60.0f) { - phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 15; - } else if (this->unk_1AC > 50.0f) { - phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 17; + if (this->fishLength > 70.0f) { + timer = (s16)Rand_ZeroFloat(5.0f) + 10; + } else if (this->fishLength > 60.0f) { + timer = (s16)Rand_ZeroFloat(5.0f) + 15; + } else if (this->fishLength > 50.0f) { + timer = (s16)Rand_ZeroFloat(5.0f) + 17; } else { - phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 25; + timer = (s16)Rand_ZeroFloat(5.0f) + 25; } - D_80B7E122 = phi_v0; - D_80B7E0A4 = phi_v0; - Rumble_Override(0.0f, 180, phi_v0 * 3, 10); + sLureBitTimer = timer; + sRumbleDelay = timer; + Rumble_Override(0.0f, 180, timer * 3, 10); } - D_80B7E124 = 0; - D_80B7E116 = 100; - D_80B7E080 = 0; + sLineHooked = 0; + sRodPullback = 100; + sFishFightTime = 0; } break; case -3: - this->unk_151 = 50; - this->unk_1B4 = sLurePos; + this->lilyTimer = 50; + this->fishTargetPos = sLurePos; Math_ApproachF(&this->actor.speed, 2.0f, 1.0f, 1.0f); - if ((D_80B7A694 != 3) || (this->unk_17A[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || + if ((sRodCastState != 3) || (this->timerArray[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { - this->unk_17A[0] = 0; + this->timerArray[0] = 0; this->unk_190 = 1.0f; - this->unk_158 = this->unk_15A; + this->fishState = this->fishStateNext; this->unk_194 = 2000.0f; - } else if (sp124 < 10.0f) { + } else if (distToTarget < 10.0f) { if (sLurePos.y > (WATER_SURFACE_Y(play) - 10.0f)) { Actor_PlaySfx(&this->actor, NA_SE_EV_JUMP_OUT_WATER); Sfx_PlaySfxCentered(NA_SE_PL_CATCH_BOOMERANG); } - func_80B70A2C(this, play, false); - this->unk_158 = 5; + Fishing_SplashBySize(this, play, false); + this->fishState = 5; this->unk_190 = 1.2f; this->unk_194 = 5000.0f; - this->unk_17A[1] = 150; - this->unk_17A[0] = 0; - this->unk_17A[2] = 0; - this->unk_17A[3] = 120; + this->timerArray[1] = 150; + this->timerArray[0] = 0; + this->timerArray[2] = 0; + this->timerArray[3] = 120; - D_80B7A694 = 4; + sRodCastState = 4; sFishingHookedFish = this; - if (D_80B7E0B6 == 2) { - D_80B7E122 = 30; - D_80B7E0A4 = 100; + if (sLureEquipped == FS_LURE_SINKING) { + sLureBitTimer = 30; + sRumbleDelay = 100; Rumble_Override(0.0f, 60, 90, 10); } else { - D_80B7E122 = 30; - D_80B7E0A4 = 40; + sLureBitTimer = 30; + sRumbleDelay = 40; Rumble_Override(0.0f, 180, 90, 10); } - D_80B7E124 = 0; - D_80B7E116 = 100; - D_80B7E080 = 0; + sLineHooked = false; + sRodPullback = 100; + sFishFightTime = 0; } break; @@ -3560,23 +3576,24 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.uncullZoneForward = 1200.0f; this->actor.uncullZoneScale = 200.0f; - D_80B7E080++; - osSyncPrintf("HIT FISH %dcm\n", (u8)this->unk_1AC); + sFishFightTime++; + osSyncPrintf("HIT FISH %dcm\n", (u8)this->fishLength); - Math_ApproachS(&this->unk_170, 0x2AF8, 4, 0xBB8); + Math_ApproachS(&this->fishLimbDRotZDelta, 0x2AF8, 4, 0xBB8); sFishingHookedFish = this; Math_ApproachS(&player->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 5, 0x500); - if (D_80B7E124 == 0) { - if ((D_80B7FEA0 < 20) && ((D_80B7E0AE & 3) == 0)) { - D_80B7FEA0++; + if (sLineHooked == 0) { + if ((sSinkingLureSegmentIndex < 20) && ((sLureTimer & 3) == 0)) { + sSinkingLureSegmentIndex++; } } - if ((D_80B7E122 != 0) && (D_80B7E124 == 0)) { - if (((input->rel.stick_y < -50) && (D_80B7A6C8 > -40)) || CHECK_BTN_ALL(input->press.button, BTN_A)) { + if ((sLureBitTimer != 0) && (sLineHooked == 0)) { // pull the line to hook it + if (((input->rel.stick_y < -50) && (sStickAdjYPrev > -40)) || + CHECK_BTN_ALL(input->press.button, BTN_A)) { if (input->rel.stick_y < -50) { - temp_f0 = 40.0f - ((this->unk_1AC - 30.0f) * 1.333333f); + temp_f0 = 40.0f - ((this->fishLength - 30.0f) * 1.333333f); if (temp_f0 > 0.0f) { this->unk_152 = temp_f0; this->unk_154 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; @@ -3584,106 +3601,106 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } } - this->unk_198 = 1.7f; - this->unk_19C = 7000.0f; - D_80B7E124 = 1; + this->fishLimbRotPhaseStep = 1.7f; + this->fishLimbRotPhaseMag = 7000.0f; + sLineHooked = 1; SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 8, NA_BGM_ENEMY); - D_80B7E0A6 = 0; + sFishingMusicDelay = 0; - if (this->unk_150 == 1) { - spA4 = (this->unk_1AC * 3.0f) + 120.0f; + if (this->isLoach == 1) { + rumbleStrength = (this->fishLength * 3.0f) + 120.0f; } else { - spA4 = (2.0f * this->unk_1AC) + 120.0f; + rumbleStrength = (2.0f * this->fishLength) + 120.0f; } - if (spA4 > 255.0f) { - spA4 = 255.0f; + if (rumbleStrength > 255.0f) { + rumbleStrength = 255.0f; } - Rumble_Override(0.0f, spA4, 120, 5); - D_80B7E0A4 = 40; - D_80B7FDA8 = 10; + Rumble_Override(0.0f, rumbleStrength, 120, 5); + sRumbleDelay = 40; + sRodHitTimer = 10; Sfx_PlaySfxCentered(NA_SE_IT_FISHING_HIT); } } if (this->actor.world.pos.y < WATER_SURFACE_Y(play)) { - if (this->unk_17A[1] > 30) { + if (this->timerArray[1] > 30) { phi_v0_2 = 7; } else { phi_v0_2 = 0xF; } - if (((this->unk_15C & phi_v0_2) == 0) && (Rand_ZeroOne() < 0.75f) && (D_80B7E0A4 == 0)) { - if (this->unk_1AC >= 70.0f) { - spA4 = 255.0f; - } else if (this->unk_1AC >= 60.0f) { - spA4 = 230.0f; - } else if (this->unk_1AC >= 50.0f) { - spA4 = 200.0f; - } else if (this->unk_1AC >= 40.0f) { - spA4 = 170.0f; + if (((this->stateAndTimer & phi_v0_2) == 0) && (Rand_ZeroOne() < 0.75f) && (sRumbleDelay == 0)) { + if (this->fishLength >= 70.0f) { + rumbleStrength = 255.0f; + } else if (this->fishLength >= 60.0f) { + rumbleStrength = 230.0f; + } else if (this->fishLength >= 50.0f) { + rumbleStrength = 200.0f; + } else if (this->fishLength >= 40.0f) { + rumbleStrength = 170.0f; } else { - spA4 = 140.0f; + rumbleStrength = 140.0f; } if (phi_v0_2 == 0xF) { - spA4 *= 3.0f / 4.0f; + rumbleStrength *= 3.0f / 4.0f; } - Rumble_Override(0.0f, spA4, (s16)Rand_ZeroFloat(5.0f) + 10, 5); + Rumble_Override(0.0f, rumbleStrength, (s16)Rand_ZeroFloat(5.0f) + 10, 5); } - if (this->unk_17A[1] > 30) { - if (this->unk_17A[0] == 0) { - sp10C.x = 0.0f; - sp10C.y = 0.0f; - sp10C.z = 200.0f; + if (this->timerArray[1] > 30) { + if (this->timerArray[0] == 0) { + multiVecSrc.x = 0.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 200.0f; - for (spA2 = 0; spA2 < 100; spA2++) { + for (attempts = 0; attempts < 100; attempts++) { Matrix_RotateY(Rand_CenteredFloat(3.0f * M_PI / 4.0f) + BINANG_TO_RAD_ALT(this->actor.yawTowardsPlayer + 0x8000), MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sp100); + Matrix_MultVec3f(&multiVecSrc, &targetPosOffset); - this->unk_1B4.x = this->actor.world.pos.x + sp100.x; - this->unk_1B4.z = this->actor.world.pos.z + sp100.z; + this->fishTargetPos.x = this->actor.world.pos.x + targetPosOffset.x; + this->fishTargetPos.z = this->actor.world.pos.z + targetPosOffset.z; - if ((SQ(this->unk_1B4.x) + SQ(this->unk_1B4.z)) < SQ(750.0f)) { + if ((SQ(this->fishTargetPos.x) + SQ(this->fishTargetPos.z)) < SQ(750.0f)) { break; } } - if ((Rand_ZeroOne() < 0.1f) && (this->unk_17A[3] == 0)) { - if (this->unk_1AC >= 60.0f) { - phi_a1 = 255; - } else if (this->unk_1AC >= 50.0f) { - phi_a1 = 200; + if ((Rand_ZeroOne() < 0.1f) && (this->timerArray[3] == 0)) { + if (this->fishLength >= 60.0f) { + rumbleStrength8 = 255; + } else if (this->fishLength >= 50.0f) { + rumbleStrength8 = 200; } else { - phi_a1 = 180; + rumbleStrength8 = 180; } - Rumble_Override(0.0f, phi_a1, 90, 2); - this->unk_17A[0] = 20; - this->unk_17A[1] = 100; - this->unk_17A[2] = 20; - this->unk_17A[3] = 100; - this->unk_1B4.y = 300.0f; - D_80B7E0A4 = 0x28; - D_80B7E116 = (s16)Rand_ZeroFloat(30.0f) + 20; + Rumble_Override(0.0f, rumbleStrength8, 90, 2); + this->timerArray[0] = 20; + this->timerArray[1] = 100; + this->timerArray[2] = 20; + this->timerArray[3] = 100; + this->fishTargetPos.y = 300.0f; + sRumbleDelay = 40; + sRodPullback = (s16)Rand_ZeroFloat(30.0f) + 20; } else { - this->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 3; - this->unk_17A[2] = 0; - this->unk_1B4.y = -70.0f - Rand_ZeroFloat(150.0f); + this->timerArray[0] = (s16)Rand_ZeroFloat(10.0f) + 3; + this->timerArray[2] = 0; + this->fishTargetPos.y = -70.0f - Rand_ZeroFloat(150.0f); } } - if (this->unk_17A[2] != 0) { - D_80B7E11C = 0.0f; + if (this->timerArray[2] != 0) { + sRodReelingSpeed = 0.0f; this->unk_190 = 1.6f; this->unk_194 = 6000.0f; Math_ApproachF(&this->actor.speed, 7.5f, 1.0f, 1.0f); - Math_ApproachS(&this->unk_170, 0x4E20, 2, 0xFA0); + Math_ApproachS(&this->fishLimbDRotZDelta, 20000, 2, 4000); } else { - if ((D_80B7E124 == 0) && (D_80B7E0B6 == 2)) { + if ((sLineHooked == 0) && (sLureEquipped == FS_LURE_SINKING)) { this->unk_190 = 1.0f; this->unk_194 = 2000.0f; Math_ApproachF(&this->actor.speed, 3.0f, 1.0f, 0.2f); @@ -3693,15 +3710,15 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { Math_ApproachF(&this->actor.speed, 5.0f, 1.0f, 0.5f); } - if (this->unk_150 == 0) { - D_80B7E11C = 1.0f - (this->unk_1AC * 0.00899f); + if (this->isLoach == 0) { + sRodReelingSpeed = 1.0f - (this->fishLength * 0.00899f); } else { - D_80B7E11C = 1.0f - (this->unk_1AC * 0.00899f * 1.4f); + sRodReelingSpeed = 1.0f - (this->fishLength * 0.00899f * 1.4f); } } } else { - if (((this->unk_17A[1] & 0xF) == 0) && CHECK_BTN_ALL(input->cur.button, BTN_A) && - (!(this->unk_1AC >= 60.0f) || (D_80B7E080 >= 2000))) { + if (((this->timerArray[1] & 0xF) == 0) && CHECK_BTN_ALL(input->cur.button, BTN_A) && + (!(this->fishLength >= 60.0f) || (sFishFightTime >= 2000))) { this->unk_152 = (s16)Rand_ZeroFloat(30.0f) + 15; this->unk_154 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; } @@ -3709,57 +3726,57 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_190 = 1.0f; this->unk_194 = 4500.0f; - if (this->unk_150 == 0) { - D_80B7E11C = 1.3f - (this->unk_1AC * 0.00899f); + if (this->isLoach == 0) { + sRodReelingSpeed = 1.3f - (this->fishLength * 0.00899f); } else { - D_80B7E11C = 1.3f - (this->unk_1AC * 0.00899f * 1.4f); + sRodReelingSpeed = 1.3f - (this->fishLength * 0.00899f * 1.4f); } Math_ApproachF(&this->actor.speed, 2.0f, 1.0f, 0.5f); - if (this->unk_17A[1] == 0) { + if (this->timerArray[1] == 0) { this->unk_152 = 0; - if (D_80B7E080 < 2000) { - this->unk_17A[1] = (s16)Rand_ZeroFloat(50.0f) + 50; - } else if (D_80B7E080 < 3000) { - this->unk_17A[1] = (s16)Rand_ZeroFloat(20.0f) + 30; + if (sFishFightTime < 2000) { + this->timerArray[1] = (s16)Rand_ZeroFloat(50.0f) + 50; + } else if (sFishFightTime < 3000) { + this->timerArray[1] = (s16)Rand_ZeroFloat(20.0f) + 30; } else { - this->unk_17A[1] = (s16)Rand_ZeroFloat(10.0f) + 25; + this->timerArray[1] = (s16)Rand_ZeroFloat(10.0f) + 25; } } } } - if (D_80B7E074 != 0) { - D_80B7E11C = 0.0f; + if (sReelLock != 0) { + sRodReelingSpeed = 0.0f; } - if (D_80B7E124 || (D_80B7E0B6 != 2)) { + if (sLineHooked || (sLureEquipped != FS_LURE_SINKING)) { if (this->actor.speed < 3.0f) { - if ((D_80B7E0AE & 8) != 0) { - sp100.x = -0.8f; + if ((sLureTimer & 8) != 0) { + targetPosOffset.x = -0.8f; } else { - sp100.x = -0.75f; + targetPosOffset.x = -0.75f; } } else { - if ((D_80B7E0AE & 4) != 0) { - sp100.x = -0.9f; + if ((sLureTimer & 4) != 0) { + targetPosOffset.x = -0.9f; } else { - sp100.x = -0.85f; + targetPosOffset.x = -0.85f; } } Math_ApproachF(&D_80B7A6C0, 35.0f, 0.1f, 3.5f); - Math_ApproachF(&D_80B7A6BC, sp100.x, 0.3f, 0.1f); + Math_ApproachF(&D_80B7A6BC, targetPosOffset.x, 0.3f, 0.1f); } sReelLinePos[LINE_SEG_COUNT - 1] = this->fishMouthPos; - sp10C.x = sReelLinePos[LINE_SEG_COUNT - 1].x - sReelLinePos[LINE_SEG_COUNT - 2].x; - sp10C.y = sReelLinePos[LINE_SEG_COUNT - 1].y - sReelLinePos[LINE_SEG_COUNT - 2].y; - sp10C.z = sReelLinePos[LINE_SEG_COUNT - 1].z - sReelLinePos[LINE_SEG_COUNT - 2].z; + multiVecSrc.x = sReelLinePos[LINE_SEG_COUNT - 1].x - sReelLinePos[LINE_SEG_COUNT - 2].x; + multiVecSrc.y = sReelLinePos[LINE_SEG_COUNT - 1].y - sReelLinePos[LINE_SEG_COUNT - 2].y; + multiVecSrc.z = sReelLinePos[LINE_SEG_COUNT - 1].z - sReelLinePos[LINE_SEG_COUNT - 2].z; - if ((SQ(sp10C.x) + SQ(sp10C.y) + SQ(sp10C.z)) > SQ(20.0f)) { + if ((SQ(multiVecSrc.x) + SQ(multiVecSrc.y) + SQ(multiVecSrc.z)) > SQ(20.0f)) { Math_ApproachF(&this->actor.world.pos.x, sReelLinePos[LINE_SEG_COUNT - 2].x, 0.2f, 2.0f * (this->actor.speed * 1.5f)); Math_ApproachF(&this->actor.world.pos.y, sReelLinePos[LINE_SEG_COUNT - 2].y, 0.2f, @@ -3769,84 +3786,85 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (input->rel.stick_y < -30)) { - if (D_80B7E116 < 100) { - D_80B7E116++; + if (sRodPullback < 100) { + sRodPullback++; } } else { - if (D_80B7E116 != 0) { - D_80B7E116--; + if (sRodPullback != 0) { + sRodPullback--; } } - if ((D_80B7A694 < 3) || ((D_80B7E074 != 0) && (D_80B7E080 > 50)) || (D_80B7E080 >= 6000) || - ((D_80B7E122 == 0) && (D_80B7E124 == 0)) || (D_80B7E116 == 0) || - (((D_80B7E0AE & 0x7F) == 0) && (Rand_ZeroOne() < 0.05f) && (D_80B7E0B6 != 2) && (KREG(69) == 0))) { - D_80B7A67C = 20; + if ((sRodCastState < 3) || ((sReelLock != 0) && (sFishFightTime > 50)) || (sFishFightTime >= 6000) || + ((sLureBitTimer == 0) && (sLineHooked == 0)) || (sRodPullback == 0) || + (((sLureTimer & 0x7F) == 0) && (Rand_ZeroOne() < 0.05f) && (sLureEquipped != FS_LURE_SINKING) && + (KREG(69) == 0))) { + sFishingCaughtTextDelay = 20; - if ((D_80B7E122 == 0) && (D_80B7E124 == 0)) { - D_80B7E086 = 0x4081; - if (((sLinkAge == LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & 0x400)) || - ((sLinkAge != LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & 0x800))) { - D_80B7A67C = 0; + if ((sLureBitTimer == 0) && (sLineHooked == 0)) { + sFishingCaughtTextId = 0x4081; + if (((sLinkAge == LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_CHILD)) || + ((sLinkAge != LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_ADULT))) { + sFishingCaughtTextDelay = 0; } } else { - D_80B7E086 = 0x4082; + sFishingCaughtTextId = 0x4082; Rumble_Override(0.0f, 1, 3, 1); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10); } - this->unk_158 = this->unk_15A = 0; + this->fishState = this->fishStateNext = 0; this->unk_1A4 = 10000; this->unk_1A2 = 500; - this->unk_17A[1] = 50; - this->unk_17A[0] = 0; + this->timerArray[1] = 50; + this->timerArray[0] = 0; this->unk_190 = 1.0f; this->unk_194 = 3000.0f; - if (D_80B7A694 == 4) { - D_80B7A694 = 3; + if (sRodCastState == 4) { + sRodCastState = 3; } - D_80B7E0A6 = 50; - D_80B7E11C = 0.5f; + sFishingMusicDelay = 50; + sRodReelingSpeed = 0.5f; this->unk_152 = 0; } else if (this->actor.xzDistToPlayer < (KREG(59) + 50.0f)) { - this->unk_158 = 6; - this->unk_17A[0] = 100; + this->fishState = 6; + this->timerArray[0] = 100; player->unk_860 = 3; Rumble_Override(0.0f, 1, 3, 1); - D_80B7E084++; + sFishesCaught++; Cutscene_StartManual(play, &play->csCtx); - D_80B7A6CC = 100; - D_80B7FEC8 = 45.0f; - D_80B7A694 = 5; + sFishingPlayerCinematicState = 100; + sCatchCamX = 45.0f; + sRodCastState = 5; this->unk_190 = 1.0f; this->unk_194 = 500.0f; - this->unk_19C = 5000.0f; + this->fishLimbRotPhaseMag = 5000.0f; if (this->actor.world.pos.y <= WATER_SURFACE_Y(play)) { - func_80B71278(this, 1); - func_80B70A2C(this, play, true); + Fishing_FishLeapSfx(this, true); + Fishing_SplashBySize(this, play, true); } - goto case_6; + goto hoistCatch; } break; - case_6: + hoistCatch: case 6: - Math_ApproachS(&this->unk_170, 0x2AF8, 2, 0xFA0); - Math_ApproachF(&D_80B7FEC8, 15.0f, 0.05f, 0.75f); + Math_ApproachS(&this->fishLimbDRotZDelta, 11000, 2, 4000); + Math_ApproachF(&sCatchCamX, 15.0f, 0.05f, 0.75f); - sp10C.x = D_80B7FEC8; + multiVecSrc.x = sCatchCamX; if (sLinkAge != LINK_AGE_CHILD) { - sp10C.y = 30.0f; - sp10C.z = 55.0f; + multiVecSrc.y = 30.0f; + multiVecSrc.z = 55.0f; } else { - sp10C.y = 10.0f; - sp10C.z = 50.0f; + multiVecSrc.y = 10.0f; + multiVecSrc.z = 50.0f; } Matrix_RotateY(BINANG_TO_RAD_ALT(player->actor.shape.rot.y), MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sSubCamEye); + Matrix_MultVec3f(&multiVecSrc, &sSubCamEye); sSubCamEye.x += player->actor.world.pos.x; sSubCamEye.y += player->actor.world.pos.y; @@ -3859,75 +3877,76 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { sSubCamAt.y += 25.0f; } - if (this->unk_17A[0] == 90) { + if (this->timerArray[0] == 90) { SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 9, NA_BGM_HEART_GET); - D_80B7A67C = 40; + sFishingCaughtTextDelay = 40; - if (this->unk_150 == 0) { - D_80B7A678 = this->unk_1AC; + if (this->isLoach == 0) { + sFishLengthToWeigh = this->fishLength; - if (D_80B7A678 >= 75) { - D_80B7E086 = 0x409F; - } else if (D_80B7A678 >= 50) { - D_80B7E086 = 0x4091; + if (sFishLengthToWeigh >= 75) { + sFishingCaughtTextId = 0x409F; + } else if (sFishLengthToWeigh >= 50) { + sFishingCaughtTextId = 0x4091; } else { - D_80B7E086 = 0x4083; + sFishingCaughtTextId = 0x4083; } } else { - D_80B7A678 = 2.0f * this->unk_1AC; - D_80B7E086 = 0x4099; + sFishLengthToWeigh = 2.0f * this->fishLength; + sFishingCaughtTextId = 0x4099; } - this->unk_1D5 = 0; + this->keepState = 0; } this->unk_160 = -0x4000; this->actor.shape.rot.y = player->actor.shape.rot.y + 0x5000; this->actor.shape.rot.x = this->actor.shape.rot.z = this->unk_162 = this->unk_164 = this->unk_16E = 0; - sp10C.x = 4.0f; - sp10C.y = -10.0f; - sp10C.z = 5.0f; - Matrix_MultVec3f(&sp10C, &sp100); - Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].x + sp100.x, 1.0f, + multiVecSrc.x = 4.0f; + multiVecSrc.y = -10.0f; + multiVecSrc.z = 5.0f; + Matrix_MultVec3f(&multiVecSrc, &targetPosOffset); + Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].x + targetPosOffset.x, 1.0f, 6.0f); - Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].y + sp100.y, 1.0f, + Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].y + targetPosOffset.y, 1.0f, 6.0f); - Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].z + sp100.z, 1.0f, + Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].z + targetPosOffset.z, 1.0f, 6.0f); - D_80B7E144 = 188.0f; + sRodLineSpooled = 188.0f; - if (this->unk_17A[0] <= 50) { - switch (this->unk_1D5) { + if (this->timerArray[0] <= 50) { + switch (this->keepState) { case 0: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { if (Message_ShouldAdvance(play)) { Message_CloseTextbox(play); if (play->msgCtx.choiceIndex == 0) { - if (D_80B7A670 == 0.0f) { - D_80B7A670 = this->unk_1AC; - D_80B7E07C = this->unk_150; - D_80B7E07E = D_80B7E0B6; + if (sFishOnHandLength == 0.0f) { + sFishOnHandLength = this->fishLength; + sFishOnHandIsLoach = this->isLoach; + sLureCaughtWith = sLureEquipped; Actor_Kill(&this->actor); - } else if ((this->unk_150 == 0) && (D_80B7E07C == 0) && - ((s16)this->unk_1AC < (s16)D_80B7A670)) { - this->unk_1D5 = 1; - this->unk_17A[0] = 0x3C; + } else if ((this->isLoach == 0) && (sFishOnHandIsLoach == 0) && + ((s16)this->fishLength < (s16)sFishOnHandLength)) { + this->keepState = 1; + this->timerArray[0] = 0x3C; + Message_StartTextbox(play, 0x4098, NULL); } else { - f32 temp1 = D_80B7A670; - s16 temp2 = D_80B7E07C; - D_80B7A670 = this->unk_1AC; - D_80B7E07C = this->unk_150; - D_80B7E07E = D_80B7E0B6; - this->unk_1AC = temp1; - this->unk_150 = temp2; + f32 lengthTemp = sFishOnHandLength; + s16 loachTemp = sFishOnHandIsLoach; + sFishOnHandLength = this->fishLength; + sFishOnHandIsLoach = this->isLoach; + sLureCaughtWith = sLureEquipped; + this->fishLength = lengthTemp; + this->isLoach = loachTemp; } } - if (this->unk_1D5 == 0) { - D_80B7A694 = 0; + if (this->keepState == 0) { + sRodCastState = 0; } } } @@ -3938,32 +3957,32 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { if (Message_ShouldAdvance(play)) { Message_CloseTextbox(play); if (play->msgCtx.choiceIndex != 0) { - f32 temp1 = D_80B7A670; - s16 temp2 = D_80B7E07C; - D_80B7A670 = this->unk_1AC; - D_80B7E07E = D_80B7E0B6; - this->unk_1AC = temp1; - this->unk_150 = temp2; + f32 temp1 = sFishOnHandLength; + s16 temp2 = sFishOnHandIsLoach; + sFishOnHandLength = this->fishLength; + sLureCaughtWith = sLureEquipped; + this->fishLength = temp1; + this->isLoach = temp2; } - D_80B7A694 = 0; + sRodCastState = 0; } } break; } } - if (D_80B7A694 == 0) { + if (sRodCastState == 0) { if (this->actor.update != NULL) { - this->unk_158 = this->unk_15A = 0; + this->fishState = this->fishStateNext = 0; this->unk_1A4 = 10000; this->unk_1A2 = 500; - this->unk_17A[1] = 50; - this->unk_17A[0] = 0; + this->timerArray[1] = 50; + this->timerArray[0] = 0; this->unk_190 = 1.0f; this->unk_194 = 2000.0f; SkelAnime_Free(&this->skelAnime, play); - if (this->unk_150 == 0) { + if (this->isLoach == 0) { SkelAnime_InitFlex(play, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); } else { @@ -3974,92 +3993,93 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } D_80B7E148 = 520.0f; - D_80B7E144 = 195.0f; + sRodLineSpooled = 195.0f; SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10); - D_80B7E0A6 = 20; - D_80B7A6CC = 3; + sFishingMusicDelay = 20; + sFishingPlayerCinematicState = 3; } break; case 7: - this->unk_151 = 50; - sp134 = 5; - this->unk_1B0 = 12288.0f; + this->lilyTimer = 50; + rotXYScale = 5; + this->rotationStep = 12288.0f; - if (this->actor.params < 104) { - this->unk_1B4 = sGroupFishes[this->actor.params - 100].pos; - D_80B7A898 = 1; - } else if (this->actor.params < 108) { - this->unk_1B4 = sGroupFishes[this->actor.params - 100 + 16].pos; - D_80B7A898 = 2; + if (this->actor.params < (EN_FISH_PARAM + 4)) { + this->fishTargetPos = sGroupFishes[this->actor.params - EN_FISH_PARAM].pos; + sFishGroupVar = 1; + } else if (this->actor.params < (EN_FISH_PARAM + 8)) { + this->fishTargetPos = sGroupFishes[this->actor.params - EN_FISH_PARAM + 16].pos; + sFishGroupVar = 2; } else { - this->unk_1B4 = sGroupFishes[this->actor.params - 100 + 32].pos; - D_80B7A898 = 3; + this->fishTargetPos = sGroupFishes[this->actor.params - EN_FISH_PARAM + 32].pos; + sFishGroupVar = 3; } Math_ApproachF(&this->actor.speed, 5.0f, 1.0f, 1.0f); - if (sp124 < 20.0f) { - Math_ApproachS(&this->unk_170, 0x4E20, 2, 0xFA0); + if (distToTarget < 20.0f) { + Math_ApproachS(&this->fishLimbDRotZDelta, 20000, 2, 4000); - if ((this->unk_17A[2] == 0) && func_80B70A2C(this, play, false)) { - func_80B71278(this, Rand_ZeroFloat(1.99f)); - this->unk_17A[2] = (s16)Rand_ZeroFloat(20.0f) + 20; + if ((this->timerArray[2] == 0) && Fishing_SplashBySize(this, play, false)) { + Fishing_FishLeapSfx(this, Rand_ZeroFloat(1.99f)); + this->timerArray[2] = (s16)Rand_ZeroFloat(20.0f) + 20; } } - if (this->unk_17A[3] == 0) { - this->unk_158 = 10; - this->unk_15A = 10; + if (this->timerArray[3] == 0) { + this->fishState = 10; + this->fishStateNext = 10; } else { func_80B70ED4(this, input); - if (this->actor.xzDistToPlayer < (100.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; + if (this->actor.xzDistToPlayer < (100.0f * playerSpeedMod)) { + this->fishStateNext = this->fishState = 0; this->unk_1A4 = 500; this->unk_1A2 = 200; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } } break; } - Math_ApproachS(&this->unk_172, (Math_SinS(this->unk_15C * 0x1000) * 5000.0f) + 5000.0f, 2, 0x7D0); + Math_ApproachS(&this->fishLimbEFRotYDelta, (Math_SinS(this->stateAndTimer * 0x1000) * 5000.0f) + 5000.0f, 2, 0x7D0); - if (this->unk_158 != 6) { + if (this->fishState != 6) { if (this->actor.world.pos.y > WATER_SURFACE_Y(play)) { this->unk_190 = 1.5f; this->unk_194 = 5000.0f; Math_ApproachS(&this->unk_16E, 0, 5, 0x7D0); - spF4 = spF0 = spFA = 3; - spF2 = spEE = 0x2000; + rotXScale = rotYScale = rotZScale = 3; + rotXStep = rotYStep = 0x2000; - this->unk_17A[2] = 0; + this->timerArray[2] = 0; this->unk_184 -= 1.0f; } else { Math_ApproachZeroF(&this->unk_184, 1.0f, 2.0f); - if ((this->unk_158 != -1) && (this->unk_158 != -2) && (this->unk_158 != -25)) { - this->unk_166 = 0; + // check for Loach states + if ((this->fishState != -1) && (this->fishState != -2) && (this->fishState != -25)) { + this->rotationTarget.x = 0; } - this->unk_168 = this->unk_16A = 0; - spF4 = spF0 = spFA = 4; - spF2 = spEE = 0x2000; + this->rotationTarget.y = this->rotationTarget.z = 0; + rotXScale = rotYScale = rotZScale = 4; + rotXStep = rotYStep = 0x2000; - spF6 = Fishing_SmoothStepToS(&this->actor.world.rot.y, spFC, sp134, this->unk_1B0) * 3.0f; - Math_ApproachS(&this->actor.world.rot.x, spFE, sp134, this->unk_1B0 * 0.5f); + spF6 = Fishing_SmoothStepToS(&this->actor.world.rot.y, rotYtarget, rotXYScale, this->rotationStep) * 3.0f; + Math_ApproachS(&this->actor.world.rot.x, rotXTarget, rotXYScale, this->rotationStep * 0.5f); - if (spF6 > 0x1F40) { - spF6 = 0x1F40; - } else if (spF6 < -0x1F40) { - spF6 = -0x1F40; + if (spF6 > 8000) { + spF6 = 8000; + } else if (spF6 < -8000) { + spF6 = -8000; } if (this->actor.speed >= 3.2f) { - Math_ApproachS(&this->unk_16E, spF6, 2, 0x4E20); + Math_ApproachS(&this->unk_16E, spF6, 2, 20000); } else { - Math_ApproachS(&this->unk_16E, spF6, 3, 0xBB8); + Math_ApproachS(&this->unk_16E, spF6, 3, 3000); } Actor_UpdateVelocityXYZ(&this->actor); @@ -4070,25 +4090,25 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.world.pos.y += (this->unk_184 * 1.5f); if (this->unk_152 != 0) { - this->unk_168 = this->unk_154; + this->rotationTarget.y = this->unk_154; this->unk_152--; if (this->unk_156 != 0) { - spF0 = 5; - spEE = 0x4000; + rotYScale = 5; + rotYStep = 0x4000; } else { - spF0 = 10; - spEE = 0x800; + rotYScale = 10; + rotYStep = 0x800; } - this->unk_166 = -0x500 - this->actor.shape.rot.x; - spF4 = 5; - spF2 = 0x4000; + this->rotationTarget.x = -0x500 - this->actor.shape.rot.x; + rotXScale = 5; + rotXStep = 0x4000; } else { this->unk_156 = 0; } - Math_ApproachS(&this->unk_160, this->unk_166, spF4, spF2); - Math_ApproachS(&this->unk_162, this->unk_168, spF0, spEE); - Math_ApproachS(&this->unk_164, this->unk_16A, spFA, 0x2000); + Math_ApproachS(&this->unk_160, this->rotationTarget.x, rotXScale, rotXStep); + Math_ApproachS(&this->unk_162, this->rotationTarget.y, rotYScale, rotYStep); + Math_ApproachS(&this->unk_164, this->rotationTarget.z, rotZScale, 0x2000); if (this->actor.speed <= 0.5f) { Math_ApproachS(&this->actor.shape.rot.x, 0, 10, this->unk_178); @@ -4100,37 +4120,37 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->unk_158 != -1) && (this->unk_158 != -2) && (this->unk_158 != -25)) { + if ((this->fishState != -1) && (this->fishState != -2) && (this->fishState != -25)) { if ((this->actor.world.pos.y > WATER_SURFACE_Y(play)) && (this->actor.prevPos.y <= WATER_SURFACE_Y(play))) { - func_80B70A2C(this, play, true); - func_80B71278(this, 1); + Fishing_SplashBySize(this, play, true); + Fishing_FishLeapSfx(this, true); this->unk_184 = this->actor.velocity.y; this->actor.velocity.y = 0.0f; - this->unk_16A = Rand_CenteredFloat(32768.0f); + this->rotationTarget.z = Rand_CenteredFloat(32768.0f); } else if ((this->actor.world.pos.y < WATER_SURFACE_Y(play)) && (this->actor.prevPos.y >= WATER_SURFACE_Y(play))) { if (this->unk_184 < -5.0f) { this->unk_184 = -5.0f; } this->actor.world.rot.x = -0xFA0; - func_80B70A2C(this, play, true); - this->unk_1D2 = 20; - func_80B71278(this, 0); + Fishing_SplashBySize(this, play, true); + this->bubbleTime = 20; + Fishing_FishLeapSfx(this, 0); } } if ((this->actor.world.pos.y < WATER_SURFACE_Y(play)) && - (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 10.0f)) && ((this->unk_15C & 1) == 0) && + (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 10.0f)) && ((this->stateAndTimer & 1) == 0) && (this->actor.speed > 0.0f)) { Vec3f pos = this->actor.world.pos; pos.y = WATER_SURFACE_Y(play); Fishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &pos, 80.0f, 500.0f, 150, 90); } - if ((this->actor.speed > 0.0f) || (this->unk_158 == 5)) { + if ((this->actor.speed > 0.0f) || (this->fishState == 5)) { f32 velocityY = this->actor.velocity.y; - spD8 = this->unk_1AC * 0.1f; + spD8 = this->fishLength * 0.1f; this->actor.world.pos.y -= spD8; this->actor.prevPos.y -= spD8; @@ -4143,7 +4163,7 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.velocity.y = velocityY; if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { - this->unk_1A0 = 20; + this->bumpTimer = 20; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { @@ -4153,47 +4173,48 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.velocity.z = this->actor.world.pos.z * -0.003f; Actor_PlaySfx(&this->actor, NA_SE_EV_FISH_LEAP); - func_80B70CF0(this, play); + Fishing_SplashBySize2(this, play); + if (Rand_ZeroOne() < 0.5f) { - this->unk_16A = 0x4000; + this->rotationTarget.z = 0x4000; } else { - this->unk_16A = -0x4000; + this->rotationTarget.z = -0x4000; } if (Rand_ZeroOne() < 0.5f) { - this->unk_166 = 0; + this->rotationTarget.x = 0; } else { - this->unk_166 = (s16)Rand_CenteredFloat(32.0f) + 0x8000; + this->rotationTarget.x = (s16)Rand_CenteredFloat(32.0f) + 0x8000; } - this->unk_168 = (s16)Rand_CenteredFloat(16384.0f); + this->rotationTarget.y = (s16)Rand_CenteredFloat(16384.0f); this->unk_190 = 1.0f; this->unk_194 = 5000.0f; - this->unk_19C = 5000.0f; + this->fishLimbRotPhaseMag = 5000.0f; } else { this->unk_184 = 0.0f; - if ((this->unk_158 == 5) && ((this->unk_15C & 1) == 0)) { + if ((this->fishState == 5) && ((this->stateAndTimer & 1) == 0)) { Vec3f pos; pos.x = Rand_CenteredFloat(10.0f) + this->actor.world.pos.x; pos.z = Rand_CenteredFloat(10.0f) + this->actor.world.pos.z; pos.y = this->actor.floorHeight + 5.0f; Fishing_SpawnWaterDust(&this->actor.projectedPos, play->specialEffects, &pos, - (this->unk_1AC * 0.005f) + 0.15f); + (this->fishLength * 0.005f) + 0.15f); } } } } } - if (this->unk_1D2 != 0) { + if (this->bubbleTime != 0) { s16 i; Vec3f pos; - f32 range = (this->unk_1AC * 0.075f) + 10.0f; + f32 range = (this->fishLength * 0.075f) + 10.0f; - this->unk_1D2--; + this->bubbleTime--; for (i = 0; i < 2; i++) { pos.x = Rand_CenteredFloat(range) + this->actor.world.pos.x; @@ -4209,19 +4230,19 @@ s32 Fishing_FishOverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Ve Fishing* this = (Fishing*)thisx; if (limbIndex == 0xD) { - rot->z -= this->unk_170 - 11000; + rot->z -= this->fishLimbDRotZDelta - 11000; } else if ((limbIndex == 2) || (limbIndex == 3)) { - rot->y += this->unk_16C; + rot->y += this->fishLimb23RotYDelta; } else if (limbIndex == 4) { - rot->y += this->unk_176; + rot->y += this->fishLimb4RotYDelta; } else if (limbIndex == 0xE) { - rot->y -= this->unk_172; + rot->y -= this->fishLimbEFRotYDelta; } else if (limbIndex == 0xF) { - rot->y += this->unk_172; + rot->y += this->fishLimbEFRotYDelta; } else if (limbIndex == 8) { - rot->y += this->unk_174; + rot->y += this->fishLimb89RotYDelta; } else if (limbIndex == 9) { - rot->y -= this->unk_174; + rot->y -= this->fishLimb89RotYDelta; } return 0; @@ -4239,11 +4260,11 @@ s32 Fishing_LoachOverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, V Fishing* this = (Fishing*)thisx; if (limbIndex == 3) { - rot->y += this->unk_1CC[0]; + rot->y += this->loachRotYDelta[0]; } else if (limbIndex == 4) { - rot->y += this->unk_1CC[1]; + rot->y += this->loachRotYDelta[1]; } else if (limbIndex == 5) { - rot->y += this->unk_1CC[2]; + rot->y += this->loachRotYDelta[2]; } return 0; @@ -4269,15 +4290,15 @@ void Fishing_DrawFish(Actor* thisx, PlayState* play) { Matrix_RotateZ(BINANG_TO_RAD_ALT(this->unk_164 + this->actor.shape.rot.z), MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (this->unk_150 == 0) { - Matrix_RotateY(BINANG_TO_RAD(this->unk_16C) - (M_PI / 2), MTXMODE_APPLY); - Matrix_Translate(0.0f, 0.0f, this->unk_16C * 10.0f * 0.01f, MTXMODE_APPLY); + if (this->isLoach == 0) { + Matrix_RotateY(BINANG_TO_RAD(this->fishLimb23RotYDelta) - (M_PI / 2), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, this->fishLimb23RotYDelta * 10.0f * 0.01f, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Fishing_FishOverrideLimbDraw, Fishing_FishPostLimbDraw, this); } else { Matrix_Translate(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); - Matrix_RotateY(BINANG_TO_RAD(this->unk_16C), MTXMODE_APPLY); + Matrix_RotateY(BINANG_TO_RAD(this->fishLimb23RotYDelta), MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); Matrix_RotateY(-(M_PI / 2), MTXMODE_APPLY); @@ -4342,7 +4363,7 @@ void Fishing_UpdatePondProps(PlayState* play) { actor = play->actorCtx.actorLists[ACTORCAT_NPC].head; while (actor != NULL) { - if (!((actor->id == ACTOR_FISHING) && (actor->params >= 100))) { + if (!((actor->id == ACTOR_FISHING) && (actor->params >= EN_FISH_PARAM))) { actor = actor->next; } else { Fishing_HandleReedContact(prop, &actor->world.pos); @@ -4356,10 +4377,10 @@ void Fishing_UpdatePondProps(PlayState* play) { actor = play->actorCtx.actorLists[ACTORCAT_NPC].head; while (actor != NULL) { - if (!((actor->id == ACTOR_FISHING) && (actor->params >= 100))) { + if (!((actor->id == ACTOR_FISHING) && (actor->params >= EN_FISH_PARAM))) { actor = actor->next; } else { - Fishing_HandleLilyPadContact(prop, &actor->world.pos, ((Fishing*)actor)->unk_151); + Fishing_HandleLilyPadContact(prop, &actor->world.pos, ((Fishing*)actor)->lilyTimer); actor = actor->next; } } @@ -4510,7 +4531,7 @@ void Fishing_UpdateGroupFishes(PlayState* play) { f32 temp1; f32 temp2; - if ((D_80B7E114 != 0) || (D_80B7A694 == 4)) { + if ((D_80B7E114 != 0) || (sRodCastState == 4)) { refPos = &sLurePos; } else { refPos = &player->actor.world.pos; @@ -4526,7 +4547,7 @@ void Fishing_UpdateGroupFishes(PlayState* play) { if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { sFishGroupAngle1 += 0.3f; groupContactFlags |= 1; - } else if (D_80B7A898 != 0.0f) { + } else if (sFishGroupVar != 0.0f) { sFishGroupAngle1 += 0.05f; basePos[0].y = WATER_SURFACE_Y(play) - 5.0f; } else { @@ -4543,7 +4564,7 @@ void Fishing_UpdateGroupFishes(PlayState* play) { if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { sFishGroupAngle2 -= 0.3f; groupContactFlags |= 2; - } else if (D_80B7A898 != 0.0f) { + } else if (sFishGroupVar != 0.0f) { sFishGroupAngle2 -= 0.05f; basePos[1].y = WATER_SURFACE_Y(play) - 5.0f; } else { @@ -4560,7 +4581,7 @@ void Fishing_UpdateGroupFishes(PlayState* play) { if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { sFishGroupAngle3 -= 0.3f; groupContactFlags |= 4; - } else if (D_80B7A898 != 0.0f) { + } else if (sFishGroupVar != 0.0f) { sFishGroupAngle3 -= 0.05f; basePos[2].y = WATER_SURFACE_Y(play) - 5.0f; } else { @@ -4596,22 +4617,22 @@ void Fishing_UpdateGroupFishes(PlayState* play) { groupFlag = 4; } - dx = fish->unk_10.x - fish->pos.x; - dy = fish->unk_10.y - fish->pos.y; - dz = fish->unk_10.z - fish->pos.z; + dx = fish->homePos.x - fish->pos.x; + dy = fish->homePos.y - fish->pos.y; + dz = fish->homePos.z - fish->pos.z; spD4 = Math_Atan2S(dz, dx); dist = sqrtf(SQ(dx) + SQ(dz)); spD6 = Math_Atan2S(dist, dy); if ((dist < 10.0f) || (((fish->timer % 32) == 0) && (Rand_ZeroOne() > 0.5f))) { - fish->unk_10.y = basePos[groupIndex].y + Rand_CenteredFloat(10.0f); + fish->homePos.y = basePos[groupIndex].y + Rand_CenteredFloat(10.0f); - if (D_80B7A898 != 0.0f) { - fish->unk_10.x = basePos[groupIndex].x + Rand_CenteredFloat(200.0f); - fish->unk_10.z = basePos[groupIndex].z + Rand_CenteredFloat(200.0f); + if (sFishGroupVar != 0.0f) { + fish->homePos.x = basePos[groupIndex].x + Rand_CenteredFloat(200.0f); + fish->homePos.z = basePos[groupIndex].z + Rand_CenteredFloat(200.0f); } else { - fish->unk_10.x = basePos[groupIndex].x + Rand_CenteredFloat(100.0f); - fish->unk_10.z = basePos[groupIndex].z + Rand_CenteredFloat(100.0f); + fish->homePos.x = basePos[groupIndex].x + Rand_CenteredFloat(100.0f); + fish->homePos.z = basePos[groupIndex].z + Rand_CenteredFloat(100.0f); } ripplePos = fish->pos; @@ -4619,8 +4640,8 @@ void Fishing_UpdateGroupFishes(PlayState* play) { Fishing_SpawnRipple(&fish->projectedPos, play->specialEffects, &ripplePos, 20.0f, Rand_ZeroFloat(50.0f) + 100.0f, 150, 90); - if (fish->unk_28 < 1.5f) { - fish->unk_28 = 1.5f; + if (fish->velY < 1.5f) { + fish->velY = 1.5f; } fish->unk_34 = 1.5f; @@ -4628,32 +4649,32 @@ void Fishing_UpdateGroupFishes(PlayState* play) { } target = Fishing_SmoothStepToS(&fish->unk_3E, spD4, 5, 0x4000) * 3.0f; - if (target > 0x1F40) { - target = 0x1F40; - } else if (target < -0x1F40) { - target = -0x1F40; + if (target > 8000) { + target = 8000; + } else if (target < -8000) { + target = -8000; } - Math_ApproachS(&fish->unk_42, target, 3, 0x1388); + Math_ApproachS(&fish->unk_42, target, 3, 5000); offset = fish->unk_42 * -0.0001f; Math_ApproachS(&fish->unk_3C, spD6, 5, 0x4000); if (groupContactFlags & groupFlag) { fish->unk_38 = 1.0f; - fish->unk_28 = 6.0f; + fish->velY = 6.0f; fish->unk_34 = 2.0f; } - if (D_80B7A898 != 0.0f) { + if (sFishGroupVar != 0.0f) { fish->unk_38 = 1.0f; - fish->unk_28 = 4.0f; + fish->velY = 4.0f; fish->unk_34 = 2.0f; } - Math_ApproachF(&fish->unk_28, 0.75f, 1.0f, 0.05f); + Math_ApproachF(&fish->velY, 0.75f, 1.0f, 0.05f); - temp1 = fish->unk_28 * spD8; + temp1 = fish->velY * spD8; temp2 = Math_CosS(fish->unk_3C) * temp1; fish->pos.x += temp2 * Math_SinS(fish->unk_3E); @@ -4664,14 +4685,14 @@ void Fishing_UpdateGroupFishes(PlayState* play) { Math_ApproachF(&fish->unk_34, 1.0f, 1.0f, 0.1f); Math_ApproachF(&fish->unk_38, 0.4f, 1.0f, 0.04f); fish->unk_30 += fish->unk_34; - fish->unk_2C = (cosf(fish->unk_30) * fish->unk_38) + offset; + fish->scaleX = (cosf(fish->unk_30) * fish->unk_38) + offset; } } fish++; } - D_80B7A898 = 0.0f; + sFishGroupVar = 0.0f; } void Fishing_DrawGroupFishes(PlayState* play) { @@ -4703,7 +4724,7 @@ void Fishing_DrawGroupFishes(PlayState* play) { Matrix_Translate(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); Matrix_RotateY(BINANG_TO_RAD_ALT2((f32)fish->unk_3E), MTXMODE_APPLY); Matrix_RotateX(BINANG_TO_RAD_ALT2(-(f32)fish->unk_3C), MTXMODE_APPLY); - Matrix_Scale(fish->unk_2C * scale, scale, scale, MTXMODE_APPLY); + Matrix_Scale(fish->scaleX * scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 8093), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4716,14 +4737,15 @@ void Fishing_DrawGroupFishes(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -static u16 D_80B7AFB8[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; +static u16 sPondOwnerTextIds[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { - switch (this->unk_15C) { + switch (this->stateAndTimer) { case 0: - if (D_80B7E0AC == 0) { + if (sFishingPlayingState == 0) { if (sLinkAge != LINK_AGE_CHILD) { - if ((HIGH_SCORE(HS_FISHING) & 0x100) && !(HIGH_SCORE(HS_FISHING) & 0x200)) { + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_PLAYED_CHILD) && + !(HIGH_SCORE(HS_FISHING) & HS_FISH_PLAYED_ADULT)) { this->actor.textId = 0x4093; } else { this->actor.textId = 0x407B; @@ -4731,22 +4753,22 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { } else { this->actor.textId = 0x407B; } - } else if (D_80B7A68C == 0) { + } else if (!sIsOwnersHatHooked) { this->actor.textId = 0x4084; } else { this->actor.textId = 0x4097; } if (Actor_ProcessTalkRequest(&this->actor, play)) { - if (D_80B7E0AC == 0) { - this->unk_15C = 1; + if (sFishingPlayingState == 0) { + this->stateAndTimer = 1; if (sLinkAge != LINK_AGE_CHILD) { - HIGH_SCORE(HS_FISHING) |= 0x200; + HIGH_SCORE(HS_FISHING) |= HS_FISH_PLAYED_ADULT; } else { - HIGH_SCORE(HS_FISHING) |= 0x100; + HIGH_SCORE(HS_FISHING) |= HS_FISH_PLAYED_CHILD; } } else { - this->unk_15C = 10; + this->stateAndTimer = 10; } } else { func_8002F2CC(&this->actor, play, 100.0f); @@ -4767,15 +4789,15 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { this->actor.textId = 0x407D; } Message_ContinueTextbox(play, this->actor.textId); - this->unk_15C = 2; + this->stateAndTimer = 2; } else { Message_ContinueTextbox(play, 0x407E); - this->unk_15C = 3; + this->stateAndTimer = 3; } break; case 1: Message_ContinueTextbox(play, 0x2D); - this->unk_15C = 3; + this->stateAndTimer = 3; break; } } @@ -4785,17 +4807,17 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); Message_ContinueTextbox(play, 0x407F); - this->unk_15C = 4; + this->stateAndTimer = 4; } break; case 3: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - this->unk_15C = 0; + this->stateAndTimer = 0; } if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) { - this->unk_15C = 0; + this->stateAndTimer = 0; } break; @@ -4805,9 +4827,9 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: - D_80B7A678 = D_80B7E078; + sFishLengthToWeigh = sFishingRecordLength; Message_ContinueTextbox(play, 0x4080); - this->unk_15C = 5; + this->stateAndTimer = 5; break; case 1: Message_ContinueTextbox(play, 0x407F); @@ -4822,30 +4844,30 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { play->interfaceCtx.unk_260 = 1; play->startPlayerFishing(play); - D_80B7E0AC = 1; - D_80B7A684 = 20; - this->unk_15C = 0; + sFishingPlayingState = 1; + sOwnerTheftTimer = 20; + this->stateAndTimer = 0; if ((HIGH_SCORE(HS_FISHING) & 0xFF0000) < 0xFF0000) { - HIGH_SCORE(HS_FISHING) += 0x10000; + HIGH_SCORE(HS_FISHING) += HS_FISH_PLAYED; } } break; case 10: - if (D_80B7A68C != 0) { + if (sIsOwnersHatHooked) { // owner asks for hat back if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); switch (play->msgCtx.choiceIndex) { case 0: Message_ContinueTextbox(play, 0x40B2); - D_80B7A688 = 1; - D_80B7A68C = 0; - this->unk_15C = 20; + sOwnerHair = FS_OWNER_CAPPED; + sIsOwnersHatHooked = false; + this->stateAndTimer = 20; break; case 1: - this->unk_15C = 0; + this->stateAndTimer = 0; break; } } @@ -4855,73 +4877,74 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: - if (D_80B7A670 == 0.0f) { + if (sFishOnHandLength == 0.0f) { this->actor.textId = 0x408C; - this->unk_15C = 20; - } else if (D_80B7E07C == 0) { - D_80B7A678 = D_80B7A670; - if ((s16)D_80B7E078 < (s16)D_80B7A670) { - if (D_80B7E07E == 2) { + this->stateAndTimer = 20; + } else if (sFishOnHandIsLoach == 0) { + sFishLengthToWeigh = sFishOnHandLength; + if ((s16)sFishingRecordLength < (s16)sFishOnHandLength) { + if (sLureCaughtWith == FS_LURE_SINKING) { this->actor.textId = 0x40B0; } else { this->actor.textId = 0x4086; } - this->unk_15C = 11; + this->stateAndTimer = 11; } else { this->actor.textId = 0x408B; - this->unk_15C = 20; + this->stateAndTimer = 20; } } else { this->actor.textId = 0x409B; - this->unk_15C = 11; + this->stateAndTimer = 11; } Message_ContinueTextbox(play, this->actor.textId); break; case 1: - if (D_80B7A680 > 36000) { - D_80B7A680 = 30000; + if (sFishingTimePlayed > 36000) { + sFishingTimePlayed = 30000; Message_ContinueTextbox(play, 0x4088); } else { - if (D_80B7E076 == 0) { - if (D_80B7E082 == 0) { - D_80B7E082++; + if (sFishingFoggy == 0) { + if (sPondOwnerTextIdIndex == 0) { + sPondOwnerTextIdIndex++; } } - if ((D_80B7E0B6 == 2) && (D_80B7AFB8[D_80B7E082] == 0x408D)) { + if ((sLureEquipped == FS_LURE_SINKING) && + (sPondOwnerTextIds[sPondOwnerTextIdIndex] == 0x408D)) { Message_ContinueTextbox(play, 0x40AF); } else { - Message_ContinueTextbox(play, D_80B7AFB8[D_80B7E082]); + Message_ContinueTextbox(play, sPondOwnerTextIds[sPondOwnerTextIdIndex]); } - D_80B7E082++; + sPondOwnerTextIdIndex++; if (sLinkAge != LINK_AGE_CHILD) { - if (D_80B7E082 >= 6) { - D_80B7E082 = 0; + if (sPondOwnerTextIdIndex >= 6) { + sPondOwnerTextIdIndex = 0; } } else { - if (D_80B7E082 >= 4) { - D_80B7E082 = 0; + if (sPondOwnerTextIdIndex >= 4) { + sPondOwnerTextIdIndex = 0; } } } - this->unk_15C = 0; + this->stateAndTimer = 0; break; case 2: - if (D_80B7E084 == 0) { + if (sFishesCaught == 0) { Message_ContinueTextbox(play, 0x4085); } else if (sLinkAge == LINK_AGE_CHILD) { Message_ContinueTextbox(play, 0x4092); } - this->unk_15C = 22; + this->stateAndTimer = 22; break; } } } break; - case 11: + case 11: // collect prize, update record. if (((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) && Message_ShouldAdvance(play)) { @@ -4929,80 +4952,81 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { Message_CloseTextbox(play); - if (D_80B7E07C == 0) { - D_80B7E078 = D_80B7A670; - D_80B7A670 = 0.0f; + if (sFishOnHandIsLoach == 0) { + sFishingRecordLength = sFishOnHandLength; + sFishOnHandLength = 0.0f; if (sLinkAge == LINK_AGE_CHILD) { f32 temp; HIGH_SCORE(HS_FISHING) &= 0xFFFFFF00; - HIGH_SCORE(HS_FISHING) |= (s32)D_80B7E078 & 0x7F; + HIGH_SCORE(HS_FISHING) |= (s32)sFishingRecordLength & HS_FISH_LENGTH_CHILD; - temp = (HIGH_SCORE(HS_FISHING) & 0x7F000000) >> 0x18; - if (temp < D_80B7E078) { + temp = (HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_ADULT) >> 0x18; + if (temp < sFishingRecordLength) { HIGH_SCORE(HS_FISHING) &= 0xFFFFFF; - HIGH_SCORE(HS_FISHING) |= ((s32)D_80B7E078 & 0x7F) << 0x18; + HIGH_SCORE(HS_FISHING) |= ((s32)sFishingRecordLength & HS_FISH_LENGTH_CHILD) << 0x18; - if (D_80B7E07E == 2) { - HIGH_SCORE(HS_FISHING) |= 0x80000000; + if (sLureCaughtWith == FS_LURE_SINKING) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_CHEAT_ADULT; } } - if (D_80B7E07E == 2) { - HIGH_SCORE(HS_FISHING) |= 0x80; - this->unk_15C = 0; + if (sLureCaughtWith == FS_LURE_SINKING) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_CHEAT_CHILD; + this->stateAndTimer = 0; break; } } else { HIGH_SCORE(HS_FISHING) &= 0xFFFFFF; - HIGH_SCORE(HS_FISHING) |= ((s32)D_80B7E078 & 0x7F) << 0x18; + HIGH_SCORE(HS_FISHING) |= ((s32)sFishingRecordLength & HS_FISH_LENGTH_CHILD) << 0x18; - if (D_80B7E07E == 2) { - HIGH_SCORE(HS_FISHING) |= 0x80000000; - this->unk_15C = 0; + if (sLureCaughtWith == FS_LURE_SINKING) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_CHEAT_ADULT; + this->stateAndTimer = 0; break; } } - if (D_80B7E078 >= 60.0f) { + if (sFishingRecordLength >= 60.0f) { // 13 lbs getItemId = GI_RUPEE_PURPLE; - } else if (D_80B7E078 >= 50.0f) { + } else if (sFishingRecordLength >= 50.0f) { // 9 lbs getItemId = GI_RUPEE_RED; - } else if (D_80B7E078 >= 40.0f) { + } else if (sFishingRecordLength >= 40.0f) { // 6 lbs getItemId = GI_RUPEE_BLUE; } else { getItemId = GI_RUPEE_GREEN; } - if (sLinkAge == LINK_AGE_CHILD) { - if ((D_80B7E078 >= 50.0f) && !(HIGH_SCORE(HS_FISHING) & 0x400)) { - HIGH_SCORE(HS_FISHING) |= 0x400; + if (sLinkAge == LINK_AGE_CHILD) { // 9 lbs + if ((sFishingRecordLength >= 50.0f) && !(HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_CHILD)) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_PRIZE_CHILD; getItemId = GI_HEART_PIECE; sSinkingLureLocation = (u8)Rand_ZeroFloat(3.999f) + 1; } - } else { - if ((D_80B7E078 >= 60.0f) && !(HIGH_SCORE(HS_FISHING) & 0x800)) { - HIGH_SCORE(HS_FISHING) |= 0x800; + } else { // 13 lbs + if ((sFishingRecordLength >= 60.0f) && !(HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_ADULT)) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_PRIZE_ADULT; getItemId = GI_SCALE_GOLDEN; sSinkingLureLocation = (u8)Rand_ZeroFloat(3.999f) + 1; } } } else { getItemId = GI_RUPEE_PURPLE; - D_80B7A670 = 0.0f; + sFishOnHandLength = 0.0f; // doesn't record loach } this->actor.parent = NULL; + Actor_OfferGetItem(&this->actor, play, getItemId, 2000.0f, 1000.0f); - this->unk_15C = 23; + this->stateAndTimer = 23; } break; case 20: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - this->unk_15C = 0; + this->stateAndTimer = 0; } break; @@ -5012,15 +5036,15 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: - this->unk_15C = 0; + this->stateAndTimer = 0; break; case 1: - if (D_80B7E084 == 0) { + if (sFishesCaught == 0) { Message_ContinueTextbox(play, 0x4085); } else if (sLinkAge == LINK_AGE_CHILD) { Message_ContinueTextbox(play, 0x4092); } - this->unk_15C = 22; + this->stateAndTimer = 22; break; } } @@ -5030,56 +5054,56 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { if (play) {} if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { - this->unk_15C = 0; - if (D_80B7A68C != 0) { - D_80B7A688 = 1; - D_80B7A68C = 0; + this->stateAndTimer = 0; + if (sIsOwnersHatHooked) { + sOwnerHair = FS_OWNER_CAPPED; + sIsOwnersHatHooked = false; } - D_80B7E0AC = 0; + sFishingPlayingState = 0; play->interfaceCtx.unk_260 = 0; } break; case 23: - D_80B7A674 = false; + sIsRodVisible = false; if (Actor_HasParent(&this->actor, play)) { - this->unk_15C = 24; + this->stateAndTimer = 24; } else { Actor_OfferGetItem(&this->actor, play, GI_SCALE_GOLDEN, 2000.0f, 1000.0f); } break; case 24: - D_80B7A674 = false; + sIsRodVisible = false; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { - if (D_80B7E07C == 0) { - this->unk_15C = 0; + if (sFishOnHandIsLoach == 0) { + this->stateAndTimer = 0; } else { Message_StartTextbox(play, 0x409C, NULL); - this->unk_15C = 20; + this->stateAndTimer = 20; } } break; } } -static s16 D_80B7AFC4[] = { 0, 1, 2, 2, 1 }; +static s16 sOwnerBlinkIndex[] = { 0, 1, 2, 2, 1 }; static Vec3f sStreamSfxPos = { 670.0f, 0.0f, -600.0f }; -static Vec3s sSinkingLureLocationPos[] = { - { -364, -30, -269 }, - { 1129, 3, -855 }, - { -480, 0, -1055 }, - { 553, -48, -508 }, +static Vec3s sSinkingLureLocations[] = { + { -364, -30, -269 }, // in the pond, log past the lilies. + { 1129, 3, -855 }, // rock next to stream + { -480, 0, -1055 }, // wall opposite of entrance + { 553, -48, -508 }, // tip of log beside 3 posts }; void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { PlayState* play = play2; Fishing* this = (Fishing*)thisx; - Vec3f sp114; - Vec3f sp108; - Vec3f spFC; + Vec3f multiVecSrc; + Vec3f eyeTarget; + Vec3f lureDist; s16 headRotTarget; s16 playerShadowAlpha; f32 target; @@ -5110,7 +5134,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { SkelAnime_Update(&this->skelAnime); - if ((D_80B7A684 != 0) || (Message_GetState(&play->msgCtx) != TEXT_STATE_NONE)) { + if ((sOwnerTheftTimer != 0) || (Message_GetState(&play->msgCtx) != TEXT_STATE_NONE)) { this->actor.flags &= ~ACTOR_FLAG_0; } else { this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_5; @@ -5122,88 +5146,92 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { headRotTarget = 0; } - if (headRotTarget > 0x2710) { - headRotTarget = 0x2710; - } else if (headRotTarget < -0x2710) { - headRotTarget = -0x2710; + if (headRotTarget > 10000) { + headRotTarget = 10000; + } else if (headRotTarget < -10000) { + headRotTarget = -10000; } - Math_ApproachS(&this->unk_164, headRotTarget, 3, 0x1388); + Math_ApproachS(&this->unk_164, headRotTarget, 3, 5000); if (((play->gameplayFrames % 32) == 0) && (Rand_ZeroOne() < 0.3f)) { this->unk_162 = 4; } - this->unk_160 = D_80B7AFC4[this->unk_162]; + this->unk_160 = sOwnerBlinkIndex[this->unk_162]; if (this->unk_162 != 0) { this->unk_162--; } - if (D_80B7A684 != 0) { - D_80B7A684--; + if (sOwnerTheftTimer != 0) { + sOwnerTheftTimer--; } - if ((D_80B7A68C == 0) && (D_80B7E0B6 != 2) && (D_80B7A694 > 0) && (D_80B7A688 == 1) && (D_80B7A684 == 0)) { + // steal the owner's hat + if (!sIsOwnersHatHooked && (sLureEquipped != FS_LURE_SINKING) && (sRodCastState > 0) && + (sOwnerHair == FS_OWNER_CAPPED) && (sOwnerTheftTimer == 0)) { f32 dx = sOwnerHeadPos.x - sLurePos.x; f32 dy = sOwnerHeadPos.y - sLurePos.y; f32 dz = sOwnerHeadPos.z - sLurePos.z; if ((sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 25.0f) || (KREG(77) > 0)) { KREG(77) = 0; - D_80B7A688 = 0; - D_80B7A68C = 1; + sOwnerHair = FS_OWNER_BALD; + sIsOwnersHatHooked = true; Message_StartTextbox(play, 0x4087, NULL); } } - if (D_80B7A688 == 0) { - HIGH_SCORE(HS_FISHING) |= 0x1000; - } else if (D_80B7A688 == 1) { - HIGH_SCORE(HS_FISHING) &= ~0x1000; + // update hat flag. + if (sOwnerHair == FS_OWNER_BALD) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_STOLE_HAT; + } else if (sOwnerHair == FS_OWNER_CAPPED) { + HIGH_SCORE(HS_FISHING) &= ~HS_FISH_STOLE_HAT; } if (KREG(77) < 0) { KREG(77) = 0; - D_80B7A690 = 1; + sIsOwnersHatSunk = true; } - if (D_80B7A67C != 0) { - D_80B7A67C--; - if (D_80B7A67C == 0) { - Message_StartTextbox(play, D_80B7E086, NULL); + if (sFishingCaughtTextDelay != 0) { + sFishingCaughtTextDelay--; + if (sFishingCaughtTextDelay == 0) { + Message_StartTextbox(play, sFishingCaughtTextId, NULL); } } Fishing_HandleOwnerDialog(this, play); - D_80B7E14C = 0.0015f; - D_80B7A680++; + sFishingLineScale = 0.0015f; + sFishingTimePlayed++; - if ((D_80B7E0AC != 0) && D_80B7A674) { + if ((sFishingPlayingState != 0) && sIsRodVisible) { Fishing_UpdateLure(this, play); } Fishing_UpdateEffects(play->specialEffects, play); Fishing_UpdatePondProps(play); Fishing_UpdateGroupFishes(play); - - if ((D_80B7E0AC != 0) && (D_80B7A6CC == 0) && (player->actor.world.pos.z > 1360.0f) && + // can't leave with the rod + if ((sFishingPlayingState != 0) && (sFishingPlayerCinematicState == 0) && (player->actor.world.pos.z > 1360.0f) && (fabsf(player->actor.world.pos.x) < 25.0f)) { player->actor.world.pos.z = 1360.0f; player->actor.speed = 0.0f; - if (D_80B7A6D0 == 0) { - D_80B7A6CC = 10; + if (sFishingCinematicTimer == 0) { + sFishingPlayerCinematicState = 10; } } + // check if can/have found sinking lure. if ((sSinkingLureLocation != 0) && - (fabsf(player->actor.world.pos.x - sSinkingLureLocationPos[sSinkingLureLocation - 1].x) < 25.0f) && - (fabsf(player->actor.world.pos.y - sSinkingLureLocationPos[sSinkingLureLocation - 1].y) < 10.0f) && - (fabsf(player->actor.world.pos.z - sSinkingLureLocationPos[sSinkingLureLocation - 1].z) < 25.0f)) { + (fabsf(player->actor.world.pos.x - sSinkingLureLocations[sSinkingLureLocation - 1].x) < 25.0f) && + (fabsf(player->actor.world.pos.y - sSinkingLureLocations[sSinkingLureLocation - 1].y) < 10.0f) && + (fabsf(player->actor.world.pos.z - sSinkingLureLocations[sSinkingLureLocation - 1].z) < 25.0f)) { sSinkingLureLocation = 0; - D_80B7A6CC = 20; + sFishingPlayerCinematicState = 20; Rumble_Override(0.0f, 150, 10, 10); Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); @@ -5211,18 +5239,19 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { if (KREG(0) != 0) { KREG(0) = 0; - D_80B7E0B6 = 0; - D_80B7A6CC = 20; + sLureEquipped = FS_LURE_STOCK; + sFishingPlayerCinematicState = 20; Rumble_Override(0.0f, 150, 10, 10); Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); } - if (D_80B7A6D0 != 0) { - D_80B7A6D0--; + if (sFishingCinematicTimer != 0) { + sFishingCinematicTimer--; } - switch (D_80B7A6CC) { + // handle cinematics (i.e.: catching fish, finding sinking lure) + switch (sFishingPlayerCinematicState) { case 0: break; @@ -5239,7 +5268,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamAt.x = mainCam->at.x; sSubCamAt.y = mainCam->at.y; sSubCamAt.z = mainCam->at.z; - D_80B7A6CC = 2; + sFishingPlayerCinematicState = 2; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_A_B_MINIMAP); sSubCamVelFactor = 0.0f; FALLTHROUGH; @@ -5248,50 +5277,50 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { case 2: Letterbox_SetSizeTarget(27); - spFC.x = sLurePos.x - player->actor.world.pos.x; - spFC.z = sLurePos.z - player->actor.world.pos.z; - lureDistXZ = sqrtf(SQXZ(spFC)); - Matrix_RotateY(Math_Atan2F(spFC.z, spFC.x), MTXMODE_NEW); + lureDist.x = sLurePos.x - player->actor.world.pos.x; + lureDist.z = sLurePos.z - player->actor.world.pos.z; + lureDistXZ = sqrtf(SQXZ(lureDist)); + Matrix_RotateY(Math_Atan2F(lureDist.z, lureDist.x), MTXMODE_NEW); - sp114.x = 0.0f; - sp114.y = 0.0f; - sp114.z = 100.0f; - Matrix_MultVec3f(&sp114, &spFC); + multiVecSrc.x = 0.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 100.0f; + Matrix_MultVec3f(&multiVecSrc, &lureDist); - if (D_80B7A694 == 1) { + if (sRodCastState == 1) { subCamAtMaxVelFrac = 0.2f; } else { subCamAtMaxVelFrac = 0.1f; } - Math_ApproachF(&sSubCamAt.x, sLurePos.x, subCamAtMaxVelFrac, fabsf(spFC.x) * sSubCamVelFactor); + Math_ApproachF(&sSubCamAt.x, sLurePos.x, subCamAtMaxVelFrac, fabsf(lureDist.x) * sSubCamVelFactor); Math_ApproachF(&sSubCamAt.y, sLurePos.y, subCamAtMaxVelFrac, 50.0f * sSubCamVelFactor); - Math_ApproachF(&sSubCamAt.z, sLurePos.z, subCamAtMaxVelFrac, fabsf(spFC.z) * sSubCamVelFactor); + Math_ApproachF(&sSubCamAt.z, sLurePos.z, subCamAtMaxVelFrac, fabsf(lureDist.z) * sSubCamVelFactor); - sp114.x = 0.0f - D_80B7FED0; + multiVecSrc.x = 0.0f - D_80B7FED0; if (sLinkAge != LINK_AGE_CHILD) { - sp114.y = 80.0f; + multiVecSrc.y = 80.0f; } else { - sp114.y = 55.0f; + multiVecSrc.y = 55.0f; } - sp114.z = -80.0f; + multiVecSrc.z = -80.0f; - Matrix_MultVec3f(&sp114, &sp108); - sp108.x += player->actor.world.pos.x; - sp108.y += player->actor.world.pos.y; - sp108.z += player->actor.world.pos.z; + Matrix_MultVec3f(&multiVecSrc, &eyeTarget); + eyeTarget.x += player->actor.world.pos.x; + eyeTarget.y += player->actor.world.pos.y; + eyeTarget.z += player->actor.world.pos.z; Math_ApproachF(&D_80B7FED0, 30.0f, 0.1f, 0.4f); - if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { - if ((D_80B7E088 >= 0) && (D_80B7E122 == 0)) { - D_80B7E088++; + if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { // zoom in/out from the lure + if ((sLureCameraZoomLevel >= 0) && (sLureBitTimer == 0)) { + sLureCameraZoomLevel++; - if (D_80B7E088 >= 4) { - D_80B7E088 = 0; + if (sLureCameraZoomLevel >= 4) { + sLureCameraZoomLevel = 0; } - if ((D_80B7E088 == 0) || (D_80B7E088 == 3)) { + if ((sLureCameraZoomLevel == 0) || (sLureCameraZoomLevel == 3)) { Sfx_PlaySfxCentered(NA_SE_SY_CAMERA_ZOOM_DOWN); } else { Sfx_PlaySfxCentered(NA_SE_SY_CAMERA_ZOOM_UP); @@ -5299,44 +5328,44 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { } } - if (D_80B7A694 >= 3) { + if (sRodCastState >= 3) { if (lureDistXZ < 110.0f) { - D_80B7E088 = -1; - } else if ((lureDistXZ > 300.0f) && (D_80B7E088 < 0)) { - D_80B7E088 = 0; + sLureCameraZoomLevel = -1; + } else if ((lureDistXZ > 300.0f) && (sLureCameraZoomLevel < 0)) { + sLureCameraZoomLevel = 0; } } - if (D_80B7E088 > 0) { + if (sLureCameraZoomLevel > 0) { f32 dist; f32 offset; f32 factor; - dist = sqrtf(SQ(spFC.x) + SQ(spFC.z)) * 0.001f; + dist = sqrtf(SQ(lureDist.x) + SQ(lureDist.z)) * 0.001f; if (dist > 1.0f) { dist = 1.0f; } - if (D_80B7E088 == 2) { + if (sLureCameraZoomLevel == 2) { offset = 0.3f; } else { offset = 0.1f; } factor = 0.4f + offset + (dist * 0.4f); - sp108.x += (sLurePos.x - sp108.x) * factor; - sp108.y += ((sLurePos.y - sp108.y) * factor) + 20.0f; - sp108.z += (sLurePos.z - sp108.z) * factor; - D_80B7E14C = 0.0005000001f; + eyeTarget.x += (sLurePos.x - eyeTarget.x) * factor; + eyeTarget.y += ((sLurePos.y - eyeTarget.y) * factor) + 20.0f; + eyeTarget.z += (sLurePos.z - eyeTarget.z) * factor; + sFishingLineScale = 0.0005000001f; } - sp114.x = 0.0f; - sp114.y = 0.0f; - sp114.z = 100.0f; - Matrix_MultVec3f(&sp114, &spFC); + multiVecSrc.x = 0.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 100.0f; + Matrix_MultVec3f(&multiVecSrc, &lureDist); - Math_ApproachF(&sSubCamEye.x, sp108.x, 0.3f, fabsf(spFC.x) * sSubCamVelFactor); - Math_ApproachF(&sSubCamEye.y, sp108.y, 0.3f, 20.0f * sSubCamVelFactor); - Math_ApproachF(&sSubCamEye.z, sp108.z, 0.3f, fabsf(spFC.z) * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.x, eyeTarget.x, 0.3f, fabsf(lureDist.x) * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.y, eyeTarget.y, 0.3f, 20.0f * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.z, eyeTarget.z, 0.3f, fabsf(lureDist.z) * sSubCamVelFactor); break; case 3: { @@ -5347,7 +5376,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { mainCam->at = sSubCamAt; Play_ReturnToMainCam(play, sSubCamId, 0); Cutscene_StopManual(play, &play->csCtx); - D_80B7A6CC = 0; + sFishingPlayerCinematicState = 0; sSubCamId = SUB_CAM_ID_DONE; Environment_EnableUnderwaterLights(play, 0); play->envCtx.adjFogNear = 0; @@ -5356,7 +5385,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { break; } - case 10: { + case 10: { // owner tells you to return the rod. Camera* mainCam; Cutscene_StartManual(play, &play->csCtx); @@ -5372,7 +5401,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamAt.y = mainCam->at.y; sSubCamAt.z = mainCam->at.z; Message_StartTextbox(play, 0x409E, NULL); - D_80B7A6CC = 11; + sFishingPlayerCinematicState = 11; Rumble_Override(0.0f, 150, 10, 10); FALLTHROUGH; } @@ -5390,15 +5419,16 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { Play_ReturnToMainCam(play, sSubCamId, 0); Cutscene_StopManual(play, &play->csCtx); func_8002DF54(play, &this->actor, PLAYER_CSMODE_7); - D_80B7A6CC = 0; + sFishingPlayerCinematicState = 0; + sSubCamId = SUB_CAM_ID_DONE; - D_80B7A6D0 = 30; + sFishingCinematicTimer = 30; Environment_EnableUnderwaterLights(play, 0); play->envCtx.adjFogNear = 0; } break; - case 20: { + case 20: { // found the sinking lure Camera* mainCam; Cutscene_StartManual(play, &play->csCtx); @@ -5414,57 +5444,57 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamAt.y = mainCam->at.y; sSubCamAt.z = mainCam->at.z; Message_StartTextbox(play, 0x409A, NULL); - D_80B7A6CC = 21; - D_80B7FEC8 = 45.0f; - D_80B7A6D0 = 10; + sFishingPlayerCinematicState = 21; + sCatchCamX = 45.0f; + sFishingCinematicTimer = 10; FALLTHROUGH; } case 21: - if ((D_80B7A6D0 == 0) && Message_ShouldAdvance(play)) { - D_80B7A6CC = 22; - D_80B7A6D0 = 40; + if ((sFishingCinematicTimer == 0) && Message_ShouldAdvance(play)) { + sFishingPlayerCinematicState = 22; + sFishingCinematicTimer = 40; func_8002DF54(play, &this->actor, PLAYER_CSMODE_28); - D_80B7FEE4 = 0.0f; + sSinkingLureHeldY = 0.0f; } break; case 22: - if (D_80B7A6D0 == 30) { + if (sFishingCinematicTimer == 30) { SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 9, NA_BGM_ITEM_GET); } - D_80B7A6D4 = 1; + sSinkingLureFound = true; - Math_ApproachF(&D_80B7FEE4, 71.0f, 0.5f, 3.0f); + Math_ApproachF(&sSinkingLureHeldY, 71.0f, 0.5f, 3.0f); Matrix_RotateY(BINANG_TO_RAD_ALT(player->actor.shape.rot.y), MTXMODE_NEW); - sp114.x = Math_SinS(play->gameplayFrames * 0x1000); - sp114.y = D_80B7FEE4; - sp114.z = -5.0f; + multiVecSrc.x = Math_SinS(play->gameplayFrames * 0x1000); + multiVecSrc.y = sSinkingLureHeldY; + multiVecSrc.z = -5.0f; if (sLinkAge == LINK_AGE_CHILD) { - sp114.y -= 20.0f; + multiVecSrc.y -= 20.0f; } - Matrix_MultVec3f(&sp114, &sp108); + Matrix_MultVec3f(&multiVecSrc, &eyeTarget); - sSinkingLureBasePos.x = player->actor.world.pos.x + sp108.x; - sSinkingLureBasePos.y = player->actor.world.pos.y + sp108.y; - sSinkingLureBasePos.z = player->actor.world.pos.z + sp108.z; + sSinkingLureBasePos.x = player->actor.world.pos.x + eyeTarget.x; + sSinkingLureBasePos.y = player->actor.world.pos.y + eyeTarget.y; + sSinkingLureBasePos.z = player->actor.world.pos.z + eyeTarget.z; - Math_ApproachF(&D_80B7FEC8, 15.0f, 0.1f, 0.75f); + Math_ApproachF(&sCatchCamX, 15.0f, 0.1f, 0.75f); - sp114.x = D_80B7FEC8 - 15.0f; + multiVecSrc.x = sCatchCamX - 15.0f; if (sLinkAge != LINK_AGE_CHILD) { - sp114.y = 60.0f; - sp114.z = -30.0f; + multiVecSrc.y = 60.0f; + multiVecSrc.z = -30.0f; } else { - sp114.y = 40.0f; - sp114.z = -35.0f; + multiVecSrc.y = 40.0f; + multiVecSrc.z = -35.0f; } - Matrix_MultVec3f(&sp114, &sSubCamEye); + Matrix_MultVec3f(&multiVecSrc, &sSubCamEye); sSubCamEye.x += player->actor.world.pos.x; sSubCamEye.y += player->actor.world.pos.y; sSubCamEye.z += player->actor.world.pos.z; @@ -5476,7 +5506,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamAt.y += 40.0f; } - if (D_80B7A6D0 == 0) { + if (sFishingCinematicTimer == 0) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { if (Message_ShouldAdvance(play)) { @@ -5484,8 +5514,8 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { Message_CloseTextbox(play); if (play->msgCtx.choiceIndex == 0) { - D_80B7E0B6 = 2; - D_80B7E082 = 0; + sLureEquipped = FS_LURE_SINKING; + sPondOwnerTextIdIndex = 0; } mainCam->eye = sSubCamEye; @@ -5494,12 +5524,13 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { Play_ReturnToMainCam(play, sSubCamId, 0); Cutscene_StopManual(play, &play->csCtx); func_8002DF54(play, &this->actor, PLAYER_CSMODE_7); - D_80B7A6CC = 0; + sFishingPlayerCinematicState = 0; + sSubCamId = SUB_CAM_ID_DONE; player->unk_860 = -5; D_80B7E0B0 = 5; - D_80B7A6D4 = 0; - D_80B7E0A6 = 20; + sSinkingLureFound = false; + sFishingMusicDelay = 20; Environment_EnableUnderwaterLights(play, 0); play->envCtx.adjFogNear = 0; } @@ -5517,7 +5548,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { if (sSubCamEye.y <= (WATER_SURFACE_Y(play) + 1.0f)) { Environment_EnableUnderwaterLights(play, 1); - if (D_80B7E076 != 0) { + if (sFishingFoggy != 0) { play->envCtx.adjFogNear = -178; } else { play->envCtx.adjFogNear = -46; @@ -5566,15 +5597,15 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { } if (sREG(15) != 0) { - if (D_80B7A654 != (sREG(15) - 1)) { - if (D_80B7A654 == 0) { + if (sStormStrengthTarget != (sREG(15) - 1)) { + if (sStormStrengthTarget == 0) { play->envCtx.stormRequest = STORM_REQUEST_START; } else { play->envCtx.stormRequest = STORM_REQUEST_STOP; } } - D_80B7A654 = sREG(15) - 1; + sStormStrengthTarget = sREG(15) - 1; } if (sREG(14) == 1) { @@ -5590,53 +5621,55 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { osSyncPrintf("zelda_time %x\n", ((void)0, gSaveContext.save.dayTime)); osSyncPrintf(VT_RST); - if (D_80B7E077 >= 2) { - D_80B7E077--; + if (sStormChanceTimer >= 2) { + sStormChanceTimer--; } - if ((D_80B7E077 == 1) && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && ((D_80B7A680 & 0xFFF) == 0xFFF)) { - D_80B7E077 = 200; + if ((sStormChanceTimer == 1) && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && + ((sFishingTimePlayed & 0xFFF) == 0xFFF)) { + sStormChanceTimer = 200; if (Rand_ZeroOne() < 0.5f) { - D_80B7A654 = (u8)Rand_ZeroFloat(10.0f) + 5; + sStormStrengthTarget = (u8)Rand_ZeroFloat(10.0f) + 5; play->envCtx.stormRequest = STORM_REQUEST_START; } else { - D_80B7A654 = 0; + sStormStrengthTarget = 0; play->envCtx.stormRequest = STORM_REQUEST_STOP; } } - Math_ApproachF(&D_80B7A650, D_80B7A654, 1.0f, 0.05f); + Math_ApproachF(&sStormStrength, sStormStrengthTarget, 1.0f, 0.05f); - if (D_80B7A650 > 0.0f) { - target = (D_80B7A650 * 0.03f) + 0.8f; + if (sStormStrength > 0.0f) { + target = (sStormStrength * 0.03f) + 0.8f; if (target > 1.2f) { target = 1.2f; } - Math_ApproachF(&D_80B7A668, target, 1.0f, 0.01f); + Math_ApproachF(&sStormSfxFreqScale, target, 1.0f, 0.01f); } - target = (10.0f - D_80B7A650) * 150.1f; + target = (10.0f - sStormStrength) * 150.1f; if (target < 0.0f) { target = 0.0f; } if (1) {} if (1) {} - Math_ApproachF(&D_80B7A65C.z, target, 1.0f, 5.0f); + Math_ApproachF(&sFishingStormSfxPos.z, target, 1.0f, 5.0f); - if (D_80B7A65C.z < 1500.0f) { - func_800F436C(&D_80B7A65C, NA_SE_EV_RAIN - SFX_FLAG, D_80B7A668); + if (sFishingStormSfxPos.z < 1500.0f) { + func_800F436C(&sFishingStormSfxPos, NA_SE_EV_RAIN - SFX_FLAG, sStormSfxFreqScale); } - if (D_80B7A654 != 0) { - Math_ApproachF(&D_80B7A658, -200.0f, 1.0f, 2.0f); + if (sStormStrengthTarget != 0) { + Math_ApproachF(&sFishingStormShade, -200.0f, 1.0f, 2.0f); } else { - Math_ApproachZeroF(&D_80B7A658, 1.0f, 2.0f); + Math_ApproachZeroF(&sFishingStormShade, 1.0f, 2.0f); } - play->envCtx.adjLight1Color[0] = play->envCtx.adjLight1Color[1] = play->envCtx.adjLight1Color[2] = D_80B7A658; + play->envCtx.adjLight1Color[0] = play->envCtx.adjLight1Color[1] = play->envCtx.adjLight1Color[2] = + sFishingStormShade; - if ((u8)D_80B7A650 > 0) { + if ((u8)sStormStrength > 0) { s32 pad; Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); s16 i; @@ -5650,7 +5683,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { rot.y = 1.0f; rot.z = (Camera_GetInputDirYaw(mainCam) * -(M_PI / 0x8000)) + rot.y; - for (i = 0; i < (u8)D_80B7A650; i++) { + for (i = 0; i < (u8)sStormStrength; i++) { pos.x = Rand_CenteredFloat(700.0f) + play->view.eye.x; pos.y = (Rand_ZeroFloat(100.0f) + 150.0f) - 170.0f; pos.z = Rand_CenteredFloat(700.0f) + play->view.eye.z; @@ -5670,8 +5703,8 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sStreamSfxPos, &sStreamSfxProjectedPos, &sProjectedW); Sfx_PlaySfxAtPos(&sStreamSfxProjectedPos, NA_SE_EV_WATER_WALL - SFX_FLAG); - - gSaveContext.minigameScore = (SQ((f32)D_80B7A678) * 0.0036f) + 0.5f; + // convert length to weight. Theoretical max of 59 lbs (127^2*.0036+.5) + gSaveContext.minigameScore = (SQ((f32)sFishLengthToWeigh) * 0.0036f) + 0.5f; if (BREG(26) != 0) { BREG(26) = 0; @@ -5696,9 +5729,9 @@ void Fishing_OwnerPostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 OPEN_DISPS(play->state.gfxCtx); Matrix_MultVec3f(&sZeroVec, &sOwnerHeadPos); - if (D_80B7A688 == 1) { + if (sOwnerHair == FS_OWNER_CAPPED) { gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gFishingOwnerHatDL)); - } else if (D_80B7A688 == 2) { + } else if (sOwnerHair == FS_OWNER_HAIR) { gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gFishingOwnerHairDL)); } @@ -5735,10 +5768,10 @@ void Fishing_DrawOwner(Actor* thisx, PlayState* play) { Fishing_DrawGroupFishes(play); Fishing_DrawStreamSplash(play); - if (D_80B7E0A6 != 0) { - D_80B7E0A6--; + if (sFishingMusicDelay != 0) { + sFishingMusicDelay--; - if (D_80B7E0A6 == 0) { + if (sFishingMusicDelay == 0) { if (sLinkAge != LINK_AGE_CHILD) { SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_KAKARIKO_ADULT); } else { @@ -5753,17 +5786,17 @@ void Fishing_DrawOwner(Actor* thisx, PlayState* play) { } } - if ((D_80B7E0AC != 0) && D_80B7A674) { + if ((sFishingPlayingState != 0) && sIsRodVisible) { Fishing_DrawRod(play); Fishing_UpdateLinePos(sReelLinePos); Fishing_UpdateLine(play, &sRodTipPos, sReelLinePos, sReelLineRot, sReelLineUnk); Fishing_DrawLureAndLine(play, sReelLinePos, sReelLineRot); - D_80B7A6C4 = input->rel.stick_x; - D_80B7A6C8 = input->rel.stick_y; + sStickAdjXPrev = input->rel.stick_x; + sStickAdjYPrev = input->rel.stick_y; } - D_80B7A674 = true; + sIsRodVisible = true; Matrix_Translate(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); Matrix_Scale(0.08f, 0.12f, 0.14f, MTXMODE_APPLY); @@ -5776,7 +5809,7 @@ void Fishing_DrawOwner(Actor* thisx, PlayState* play) { gSPDisplayList(POLY_OPA_DISP++, gFishingAquariumBottomDL); gSPDisplayList(POLY_XLU_DISP++, gFishingAquariumContainerDL); - if ((D_80B7E0AC != 0) && (D_80B7E0B6 == 2)) { + if ((sFishingPlayingState != 0) && (sLureEquipped == FS_LURE_SINKING)) { Fishing_DrawSinkingLure(play); } diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.h b/src/overlays/actors/ovl_Fishing/z_fishing.h index 58483652c..40b7f908b 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.h +++ b/src/overlays/actors/ovl_Fishing/z_fishing.h @@ -9,50 +9,48 @@ struct Fishing; typedef struct Fishing { /* 0x0000 */ Actor actor; /* 0x014C */ char unk_14C[0x004]; - /* 0x0150 */ u8 unk_150; - /* 0x0151 */ u8 unk_151; + /* 0x0150 */ u8 isLoach; + /* 0x0151 */ u8 lilyTimer; // if near lily and >0, lily moves. Move more if >20 /* 0x0152 */ u8 unk_152; /* 0x0154 */ s16 unk_154; /* 0x0156 */ u8 unk_156; /* 0x0157 */ u8 unk_157; - /* 0x0158 */ s16 unk_158; - /* 0x015A */ s16 unk_15A; - /* 0x015C */ s16 unk_15C; + /* 0x0158 */ s16 fishState; // negative index for loach behavior + /* 0x015A */ s16 fishStateNext; + /* 0x015C */ s16 stateAndTimer; // fish use as timer that's AND'd, owner as talking state /* 0x015E */ s16 unk_15E; - /* 0x0160 */ s16 unk_160; - /* 0x0162 */ s16 unk_162; - /* 0x0164 */ s16 unk_164; - /* 0x0166 */ s16 unk_166; - /* 0x0168 */ s16 unk_168; - /* 0x016A */ s16 unk_16A; - /* 0x016C */ s16 unk_16C; + /* 0x0160 */ s16 unk_160; // fish use as rotateX, owner as index of eye texture + /* 0x0162 */ s16 unk_162; // fish use as rotateY, owner as index of eye texture + /* 0x0164 */ s16 unk_164; // fish use as rotateZ, owner as rotation of head + /* 0x0166 */ Vec3s rotationTarget; + /* 0x016C */ s16 fishLimb23RotYDelta; /* 0x016E */ s16 unk_16E; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ s16 unk_172; - /* 0x0174 */ s16 unk_174; - /* 0x0176 */ s16 unk_176; + /* 0x0170 */ s16 fishLimbDRotZDelta; + /* 0x0172 */ s16 fishLimbEFRotYDelta; + /* 0x0174 */ s16 fishLimb89RotYDelta; + /* 0x0176 */ s16 fishLimb4RotYDelta; /* 0x0178 */ s16 unk_178; - /* 0x017A */ s16 unk_17A[4]; + /* 0x017A */ s16 timerArray[4]; /* 0x0184 */ f32 unk_184; - /* 0x0188 */ f32 unk_188; - /* 0x018C */ f32 unk_18C; - /* 0x0190 */ f32 unk_190; - /* 0x0194 */ f32 unk_194; - /* 0x0198 */ f32 unk_198; - /* 0x019C */ f32 unk_19C; - /* 0x01A0 */ s16 unk_1A0; - /* 0x01A2 */ s16 unk_1A2; - /* 0x01A4 */ s16 unk_1A4; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ f32 unk_1AC; - /* 0x01B0 */ f32 unk_1B0; - /* 0x01B4 */ Vec3f unk_1B4; + /* 0x0188 */ f32 speedTarget; + /* 0x018C */ f32 fishLimbRotPhase; + /* 0x0190 */ f32 unk_190; // fishLimbRotPhaseStep target + /* 0x0194 */ f32 unk_194; // fishLimbRotPhaseMag target + /* 0x0198 */ f32 fishLimbRotPhaseStep; + /* 0x019C */ f32 fishLimbRotPhaseMag; + /* 0x01A0 */ s16 bumpTimer; // set when hitting a wall. + /* 0x01A2 */ s16 unk_1A2; // "scared" timer? + /* 0x01A4 */ s16 unk_1A4; // "scared" timer? set at same time as above + /* 0x01A8 */ f32 perception; // how easily they are drawn to the lure. + /* 0x01AC */ f32 fishLength; // fish are (x^2*.0036+.5) lbs, loach double that. + /* 0x01B0 */ f32 rotationStep; + /* 0x01B4 */ Vec3f fishTargetPos; /* 0x01C0 */ Vec3f fishMouthPos; - /* 0x01CC */ s16 unk_1CC[3]; - /* 0x01D2 */ u8 unk_1D2; - /* 0x01D3 */ u8 unk_1D3; - /* 0x01D4 */ u8 unk_1D4; - /* 0x01D5 */ u8 unk_1D5; + /* 0x01CC */ s16 loachRotYDelta[3]; // adds rotation to the loach limb 3-5. + /* 0x01D2 */ u8 bubbleTime; // spawn bubbles while >0 + /* 0x01D3 */ u8 isAquariumMessage; + /* 0x01D4 */ u8 aquariumWaitTimer; + /* 0x01D5 */ u8 keepState; // case-switch and keeping or releasing a fish /* 0x01D8 */ SkelAnime skelAnime; /* 0x021C */ LightNode* lightNode; /* 0x0220 */ LightInfo lightInfo; @@ -60,4 +58,8 @@ typedef struct Fishing { /* 0x0250 */ ColliderJntSphElement colliderElements[12]; } Fishing; // size = 0x0550 +#define EN_FISH_OWNER 1 // param for owner of pond. default if params<100 +#define EN_FISH_PARAM 100 // param base for fish in pond. +#define EN_FISH_AQUARIUM 200 // param for record fish in tank. + #endif diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index a59f8f4ec..b3fa044e5 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -14,7 +14,7 @@ void ItemEtcetera_Update(Actor* thisx, PlayState* play); void ItemEtcetera_DrawThroughLens(Actor* thisx, PlayState* play); void ItemEtcetera_Draw(Actor* thisx, PlayState* play); -void func_80B857D0(ItemEtcetera* this, PlayState* play); +void ItemEtcetera_WaitForObject(ItemEtcetera* this, PlayState* play); void func_80B85824(ItemEtcetera* this, PlayState* play); void func_80B858B4(ItemEtcetera* this, PlayState* play); void ItemEtcetera_SpawnSparkles(ItemEtcetera* this, PlayState* play); @@ -94,23 +94,23 @@ void ItemEtcetera_Init(Actor* thisx, PlayState* play) { ItemEtcetera* this = (ItemEtcetera*)thisx; s32 pad; s32 type; - s32 objBankIndex; + s32 objectSlot; type = this->actor.params & 0xFF; osSyncPrintf("no = %d\n", type); - objBankIndex = Object_GetIndex(&play->objectCtx, sObjectIds[type]); - osSyncPrintf("bank_ID = %d\n", objBankIndex); - if (objBankIndex < 0) { + objectSlot = Object_GetSlot(&play->objectCtx, sObjectIds[type]); + osSyncPrintf("bank_ID = %d\n", objectSlot); + if (objectSlot < 0) { ASSERT(0, "0", "../z_item_etcetera.c", 241); } else { - this->objBankIndex = objBankIndex; + this->requiredObjectSlot = objectSlot; } this->giDrawId = sDrawItemIndices[type]; this->getItemId = sGetItemIds[type]; this->futureActionFunc = func_80B85824; this->drawFunc = ItemEtcetera_Draw; Actor_SetScale(&this->actor, 0.25f); - ItemEtcetera_SetupAction(this, func_80B857D0); + ItemEtcetera_SetupAction(this, ItemEtcetera_WaitForObject); switch (type) { case ITEM_ETC_LETTER: Actor_SetScale(&this->actor, 0.5f); @@ -142,9 +142,9 @@ void ItemEtcetera_Init(Actor* thisx, PlayState* play) { void ItemEtcetera_Destroy(Actor* thisx, PlayState* play) { } -void func_80B857D0(ItemEtcetera* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { - this->actor.objBankIndex = this->objBankIndex; +void ItemEtcetera_WaitForObject(ItemEtcetera* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { + this->actor.objectSlot = this->requiredObjectSlot; this->actor.draw = this->drawFunc; this->actionFunc = this->futureActionFunc; } diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h index cb881828e..a77192c79 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h @@ -13,7 +13,7 @@ typedef struct ItemEtcetera { /* 0x014C */ ItemEtceteraActionFunc futureActionFunc; /* 0x0150 */ s16 giDrawId; /* 0x0152 */ s16 getItemId; - /* 0x0154 */ u8 objBankIndex; + /* 0x0154 */ u8 requiredObjectSlot; /* 0x0158 */ ActorFunc drawFunc; /* 0x015C */ ItemEtceteraActionFunc actionFunc; } ItemEtcetera; // size = 0x0160 diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c index d720145e2..f6c7f8004 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -135,8 +135,8 @@ void ObjTsubo_Init(Actor* thisx, PlayState* play) { Actor_Kill(&this->actor); return; } - this->objTsuboBankIndex = Object_GetIndex(&play->objectCtx, sObjectIds[(this->actor.params >> 8) & 1]); - if (this->objTsuboBankIndex < 0) { + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, sObjectIds[(this->actor.params >> 8) & 1]); + if (this->requiredObjectSlot < 0) { osSyncPrintf("Error : バンク危険! (arg_data 0x%04x)(%s %d)\n", this->actor.params, "../z_obj_tsubo.c", 410); Actor_Kill(&this->actor); } else { @@ -221,9 +221,9 @@ void ObjTsubo_SetupWaitForObject(ObjTsubo* this) { } void ObjTsubo_WaitForObject(ObjTsubo* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objTsuboBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { this->actor.draw = ObjTsubo_Draw; - this->actor.objBankIndex = this->objTsuboBankIndex; + this->actor.objectSlot = this->requiredObjectSlot; ObjTsubo_SetupIdle(this); this->actor.flags &= ~ACTOR_FLAG_4; } diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h index 62ea296f8..aa30398c7 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h @@ -12,7 +12,7 @@ typedef struct ObjTsubo { /* 0x0000 */ Actor actor; /* 0x014C */ ObjTsuboActionFunc actionFunc; /* 0x0150 */ ColliderCylinder collider; - /* 0x019C */ s8 objTsuboBankIndex; + /* 0x019C */ s8 requiredObjectSlot; } ObjTsubo; // size = 0x01A0 #endif diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 0065ea76c..2d95b4732 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -776,21 +776,21 @@ void ObjectKankyo_DrawLightning(Actor* thisx, PlayState* play) { } void ObjectKankyo_SunGraveSparkInit(ObjectKankyo* this, PlayState* play) { - s32 objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_SPOT02_OBJECTS); + s32 objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_SPOT02_OBJECTS); - if (objBankIndex < 0) { + if (objectSlot < 0) { ASSERT(0, "0", "../z_object_kankyo.c", 1251); } else { - this->requiredObjBankIndex = objBankIndex; + this->requiredObjectSlot = objectSlot; } ObjectKankyo_SetupAction(this, ObjectKankyo_WaitForSunGraveSparkObject); } void ObjectKankyo_WaitForSunGraveSparkObject(ObjectKankyo* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { this->requiredObjectLoaded = true; this->effects[0].alpha = 0; - this->actor.objBankIndex = this->requiredObjBankIndex; + this->actor.objectSlot = this->requiredObjectSlot; this->effects[0].size = 7.0f; ObjectKankyo_SetupAction(this, ObjectKankyo_SunGraveSpark); } @@ -875,20 +875,20 @@ void ObjectKankyo_DrawSunGraveSpark(Actor* thisx, PlayState* play2) { } void ObjectKankyo_InitBeams(ObjectKankyo* this, PlayState* play) { - s32 objectIndex = Object_GetIndex(&play->objectCtx, OBJECT_DEMO_KEKKAI); + s32 objectIndex = Object_GetSlot(&play->objectCtx, OBJECT_DEMO_KEKKAI); if (objectIndex < 0) { ASSERT(0, "0", "../z_object_kankyo.c", 1449); } else { - this->requiredObjBankIndex = objectIndex; + this->requiredObjectSlot = objectIndex; } ObjectKankyo_SetupAction(this, ObjectKankyo_WaitForBeamObject); } void ObjectKankyo_WaitForBeamObject(ObjectKankyo* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { this->requiredObjectLoaded = true; - this->actor.objBankIndex = this->requiredObjBankIndex; + this->actor.objectSlot = this->requiredObjectSlot; ObjectKankyo_SetupAction(this, ObjectKankyo_Beams); } } diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h index 48a2c9d27..4449fa013 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h @@ -30,7 +30,7 @@ typedef struct ObjectKankyo { /* 0x0000 */ Actor actor; /* 0x014C */ ObjectKankyoEffect effects[64]; /* 0x164C */ Vec3f prevEyePos; - /* 0x1658 */ u8 requiredObjBankIndex; + /* 0x1658 */ u8 requiredObjectSlot; /* 0x1659 */ u8 requiredObjectLoaded; /* 0x165C */ ObjectKankyoActionFunc actionFunc; } ObjectKankyo; // size = 0x1660 diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index fc822e9c2..d15af96a5 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -26,6 +26,10 @@ #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "assets/objects/object_link_child/object_link_child.h" +// Some player animations are played at this reduced speed, for reasons yet unclear. +// This is called "adjusted" for now. +#define PLAYER_ANIM_ADJUSTED_SPEED (2.0f / 3.0f) + typedef struct { /* 0x00 */ u8 itemId; /* 0x01 */ u8 field; // various bit-packed data @@ -85,8 +89,8 @@ typedef struct { typedef struct { /* 0x00 */ LinkAnimationHeader* anim; - /* 0x04 */ u8 unk_04; -} struct_808540F4; // size = 0x08 + /* 0x04 */ u8 changeFrame; +} ItemChangeInfo; // size = 0x08 typedef struct { /* 0x00 */ LinkAnimationHeader* unk_00; @@ -124,10 +128,10 @@ void func_8083377C(PlayState* play, Player* this); void func_808337D4(PlayState* play, Player* this); void func_80833910(PlayState* play, Player* this); void func_80833984(PlayState* play, Player* this); -void func_8083399C(PlayState* play, Player* this, s8 itemAction); +void Player_InitItemAction(PlayState* play, Player* this, s8 itemAction); s32 func_8083485C(Player* this, PlayState* play); s32 func_808349DC(Player* this, PlayState* play); -s32 func_80834A2C(Player* this, PlayState* play); +s32 Player_IA_ChangeHeldItem(Player* this, PlayState* play); s32 func_80834B5C(Player* this, PlayState* play); s32 func_80834C74(Player* this, PlayState* play); s32 func_8083501C(Player* this, PlayState* play); @@ -141,7 +145,7 @@ s32 func_808358F0(Player* this, PlayState* play); s32 func_808359FC(Player* this, PlayState* play); s32 func_80835B60(Player* this, PlayState* play); s32 func_80835C08(Player* this, PlayState* play); -void func_80835F44(PlayState* play, Player* this, s32 item); +void Player_UseItem(PlayState* play, Player* this, s32 item); void func_80839F90(Player* this, PlayState* play); s32 func_80838A14(Player* this, PlayState* play); s32 func_80839800(Player* this, PlayState* play); @@ -160,45 +164,6 @@ s32 func_8083E0FC(Player* this, PlayState* play); s32 func_8083E5A8(Player* this, PlayState* play); s32 func_8083EB44(Player* this, PlayState* play); s32 func_8083F7BC(Player* this, PlayState* play); -void func_80840450(Player* this, PlayState* play); -void func_808407CC(Player* this, PlayState* play); -void func_80840BC8(Player* this, PlayState* play); -void func_80840DE4(Player* this, PlayState* play); -void func_808414F8(Player* this, PlayState* play); -void func_8084170C(Player* this, PlayState* play); -void func_808417FC(Player* this, PlayState* play); -void func_8084193C(Player* this, PlayState* play); -void func_80841BA8(Player* this, PlayState* play); -void func_80842180(Player* this, PlayState* play); -void func_8084227C(Player* this, PlayState* play); -void func_8084279C(Player* this, PlayState* play); -void func_808423EC(Player* this, PlayState* play); -void func_8084251C(Player* this, PlayState* play); -void func_80843188(Player* this, PlayState* play); -void func_808435C4(Player* this, PlayState* play); -void func_8084370C(Player* this, PlayState* play); -void func_8084377C(Player* this, PlayState* play); -void func_80843954(Player* this, PlayState* play); -void func_80843A38(Player* this, PlayState* play); -void func_80843CEC(Player* this, PlayState* play); -void func_8084411C(Player* this, PlayState* play); -void func_80844708(Player* this, PlayState* play); -void func_80844A44(Player* this, PlayState* play); -void func_80844AF4(Player* this, PlayState* play); -void func_80844E68(Player* this, PlayState* play); -void func_80845000(Player* this, PlayState* play); -void func_80845308(Player* this, PlayState* play); -void func_80845668(Player* this, PlayState* play); -void func_808458D0(Player* this, PlayState* play); -void func_80845CA4(Player* this, PlayState* play); -void func_80845EF8(Player* this, PlayState* play); -void func_80846050(Player* this, PlayState* play); -void func_80846120(Player* this, PlayState* play); -void func_80846260(Player* this, PlayState* play); -void func_80846358(Player* this, PlayState* play); -void func_80846408(Player* this, PlayState* play); -void func_808464B0(Player* this, PlayState* play); -void func_80846578(Player* this, PlayState* play); void func_80846648(PlayState* play, Player* this); void func_80846660(PlayState* play, Player* this); void func_808467D4(PlayState* play, Player* this); @@ -207,61 +172,13 @@ 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 func_8084B1D8(Player* this, PlayState* play); -void func_8084B530(Player* this, PlayState* play); -void func_8084B78C(Player* this, PlayState* play); -void func_8084B898(Player* this, PlayState* play); -void func_8084B9E4(Player* this, PlayState* play); -void func_8084BBE4(Player* this, PlayState* play); -void func_8084BDFC(Player* this, PlayState* play); -void func_8084BF1C(Player* this, PlayState* play); void Player_UpdateCommon(Player* this, PlayState* play, Input* input); -void func_8084C5F8(Player* this, PlayState* play); -void func_8084C760(Player* this, PlayState* play); -void func_8084C81C(Player* this, PlayState* play); -void func_8084CC98(Player* this, PlayState* play); -void func_8084D3E4(Player* this, PlayState* play); -void func_8084D610(Player* this, PlayState* play); -void func_8084D7C4(Player* this, PlayState* play); -void func_8084D84C(Player* this, PlayState* play); -void func_8084DAB4(Player* this, PlayState* play); -void func_8084DC48(Player* this, PlayState* play); -void func_8084E1EC(Player* this, PlayState* play); -void func_8084E30C(Player* this, PlayState* play); -void func_8084E368(Player* this, PlayState* play); -void func_8084E3C4(Player* this, PlayState* play); -void func_8084E604(Player* this, PlayState* play); -void func_8084E6D4(Player* this, PlayState* play); -void func_8084E9AC(Player* this, PlayState* play); -void func_8084EAC0(Player* this, PlayState* play); -void func_8084ECA4(Player* this, PlayState* play); -void func_8084EED8(Player* this, PlayState* play); -void func_8084EFC0(Player* this, PlayState* play); -void func_8084F104(Player* this, PlayState* play); -void func_8084F390(Player* this, PlayState* play); -void func_8084F608(Player* this, PlayState* play); -void func_8084F698(Player* this, PlayState* play); -void func_8084F710(Player* this, PlayState* play); -void func_8084F88C(Player* this, PlayState* play); -void func_8084F9A0(Player* this, PlayState* play); -void func_8084F9C0(Player* this, PlayState* play); -void func_8084FA54(Player* this, PlayState* play); -void func_8084FB10(Player* this, PlayState* play); -void func_8084FBF4(Player* this, PlayState* play); #ifdef ENABLE_NO_CLIP s32 func_8084FCAC(Player* this, PlayState* play); #endif void func_8084FF7C(Player* this); void Player_UpdateBunnyEars(Player* this); s32 func_80850224(Player* this, PlayState* play); -void func_808502D0(Player* this, PlayState* play); -void func_808505DC(Player* this, PlayState* play); -void func_8085063C(Player* this, PlayState* play); -void func_8085076C(Player* this, PlayState* play); -void func_808507F4(Player* this, PlayState* play); -void func_80850AEC(Player* this, PlayState* play); -void func_80850C68(Player* this, PlayState* play); -void func_80850E84(Player* this, PlayState* play); void func_80851008(PlayState* play, Player* this, void* anim); void func_80851030(PlayState* play, Player* this, void* anim); void func_80851050(PlayState* play, Player* this, void* anim); @@ -336,7 +253,6 @@ void func_808528C8(PlayState* play, Player* this, CsCmdActorCue* cue); void func_80852944(PlayState* play, Player* this, CsCmdActorCue* cue); void func_808529D0(PlayState* play, Player* this, CsCmdActorCue* cue); void func_80852C50(PlayState* play, Player* this, CsCmdActorCue* cue); -void func_80852E14(Player* this, PlayState* play); s32 Player_IsDroppingFish(PlayState* play); s32 Player_StartFishing(PlayState* play); s32 func_80852F38(PlayState* play, Player* this); @@ -346,19 +262,131 @@ s32 Player_InflictDamage(PlayState* play, s32 damage); void func_80853148(PlayState* play, Actor* actor); u32 Player_GetGIAllocSize(); +void Player_Action_80840450(Player* this, PlayState* play); +void Player_Action_808407CC(Player* this, PlayState* play); +void Player_Action_80840BC8(Player* this, PlayState* play); +void Player_Action_80840DE4(Player* this, PlayState* play); +void Player_Action_808414F8(Player* this, PlayState* play); +void Player_Action_8084170C(Player* this, PlayState* play); +void Player_Action_808417FC(Player* this, PlayState* play); +void Player_Action_8084193C(Player* this, PlayState* play); +void Player_Action_80841BA8(Player* this, PlayState* play); +void Player_Action_80842180(Player* this, PlayState* play); +void Player_Action_8084227C(Player* this, PlayState* play); +void Player_Action_8084279C(Player* this, PlayState* play); +void Player_Action_808423EC(Player* this, PlayState* play); +void Player_Action_8084251C(Player* this, PlayState* play); +void Player_Action_80843188(Player* this, PlayState* play); +void Player_Action_808435C4(Player* this, PlayState* play); +void Player_Action_8084370C(Player* this, PlayState* play); +void Player_Action_8084377C(Player* this, PlayState* play); +void Player_Action_80843954(Player* this, PlayState* play); +void Player_Action_80843A38(Player* this, PlayState* play); +void Player_Action_80843CEC(Player* this, PlayState* play); +void Player_Action_8084411C(Player* this, PlayState* play); +void Player_Action_80844708(Player* this, PlayState* play); +void Player_Action_80844A44(Player* this, PlayState* play); +void Player_Action_80844AF4(Player* this, PlayState* play); +void Player_Action_80844E68(Player* this, PlayState* play); +void Player_Action_80845000(Player* this, PlayState* play); +void Player_Action_80845308(Player* this, PlayState* play); +void Player_Action_80845668(Player* this, PlayState* play); +void Player_Action_808458D0(Player* this, PlayState* play); +void Player_Action_80845CA4(Player* this, PlayState* play); +void Player_Action_80845EF8(Player* this, PlayState* play); +void Player_Action_80846050(Player* this, PlayState* play); +void Player_Action_80846120(Player* this, PlayState* play); +void Player_Action_80846260(Player* this, PlayState* play); +void Player_Action_80846358(Player* this, PlayState* play); +void Player_Action_80846408(Player* this, PlayState* play); +void Player_Action_808464B0(Player* this, PlayState* play); +void Player_Action_80846578(Player* this, PlayState* play); +void Player_Action_8084B1D8(Player* this, PlayState* play); +void Player_Action_8084B530(Player* this, PlayState* play); +void Player_Action_8084B78C(Player* this, PlayState* play); +void Player_Action_8084B898(Player* this, PlayState* play); +void Player_Action_8084B9E4(Player* this, PlayState* play); +void Player_Action_8084BBE4(Player* this, PlayState* play); +void Player_Action_8084BDFC(Player* this, PlayState* play); +void Player_Action_8084BF1C(Player* this, PlayState* play); +void Player_Action_8084C5F8(Player* this, PlayState* play); +void Player_Action_8084C760(Player* this, PlayState* play); +void Player_Action_8084C81C(Player* this, PlayState* play); +void Player_Action_8084CC98(Player* this, PlayState* play); +void Player_Action_8084D3E4(Player* this, PlayState* play); +void Player_Action_8084D610(Player* this, PlayState* play); +void Player_Action_8084D7C4(Player* this, PlayState* play); +void Player_Action_8084D84C(Player* this, PlayState* play); +void Player_Action_8084DAB4(Player* this, PlayState* play); +void Player_Action_8084DC48(Player* this, PlayState* play); +void Player_Action_8084E1EC(Player* this, PlayState* play); +void Player_Action_8084E30C(Player* this, PlayState* play); +void Player_Action_8084E368(Player* this, PlayState* play); +void Player_Action_8084E3C4(Player* this, PlayState* play); +void Player_Action_8084E604(Player* this, PlayState* play); +void Player_Action_8084E6D4(Player* this, PlayState* play); +void Player_Action_8084E9AC(Player* this, PlayState* play); +void Player_Action_8084EAC0(Player* this, PlayState* play); +void Player_Action_8084ECA4(Player* this, PlayState* play); +void Player_Action_8084EED8(Player* this, PlayState* play); +void Player_Action_8084EFC0(Player* this, PlayState* play); +void Player_Action_8084F104(Player* this, PlayState* play); +void Player_Action_8084F390(Player* this, PlayState* play); +void Player_Action_8084F608(Player* this, PlayState* play); +void Player_Action_8084F698(Player* this, PlayState* play); +void Player_Action_8084F710(Player* this, PlayState* play); +void Player_Action_8084F88C(Player* this, PlayState* play); +void Player_Action_8084F9A0(Player* this, PlayState* play); +void Player_Action_8084F9C0(Player* this, PlayState* play); +void Player_Action_8084FA54(Player* this, PlayState* play); +void Player_Action_8084FB10(Player* this, PlayState* play); +void Player_Action_8084FBF4(Player* this, PlayState* play); +void Player_Action_808502D0(Player* this, PlayState* play); +void Player_Action_808505DC(Player* this, PlayState* play); +void Player_Action_8085063C(Player* this, PlayState* play); +void Player_Action_8085076C(Player* this, PlayState* play); +void Player_Action_808507F4(Player* this, PlayState* play); +void Player_Action_80850AEC(Player* this, PlayState* play); +void Player_Action_80850C68(Player* this, PlayState* play); +void Player_Action_80850E84(Player* this, PlayState* play); +void Player_Action_80852E14(Player* this, PlayState* play); + // .bss part 1 static s32 D_80858AA0; static s32 D_80858AA4; -static Vec3f D_80858AA8; +static Vec3f sInteractWallCheckResult; static Input* sControlInput; // .data -static u8 D_80853410[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; +static u8 sUpperBodyLimbCopyMap[PLAYER_LIMB_MAX] = { + false, // PLAYER_LIMB_NONE + false, // PLAYER_LIMB_ROOT + false, // PLAYER_LIMB_WAIST + false, // PLAYER_LIMB_LOWER + false, // PLAYER_LIMB_R_THIGH + false, // PLAYER_LIMB_R_SHIN + false, // PLAYER_LIMB_R_FOOT + false, // PLAYER_LIMB_L_THIGH + false, // PLAYER_LIMB_L_SHIN + false, // PLAYER_LIMB_L_FOOT + true, // PLAYER_LIMB_UPPER + true, // PLAYER_LIMB_HEAD + true, // PLAYER_LIMB_HAT + true, // PLAYER_LIMB_COLLAR + true, // PLAYER_LIMB_L_SHOULDER + true, // PLAYER_LIMB_L_FOREARM + true, // PLAYER_LIMB_L_HAND + true, // PLAYER_LIMB_R_SHOULDER + true, // PLAYER_LIMB_R_FOREARM + true, // PLAYER_LIMB_R_HAND + true, // PLAYER_LIMB_SHEATH + true // PLAYER_LIMB_TORSO +}; static PlayerAgeProperties sAgeProperties[] = { { - 56.0f, // unk_00 + 56.0f, // ceilingCheckHeight 90.0f, // unk_04 1.0f, // unk_08 111.0f, // unk_0C @@ -372,7 +400,7 @@ static PlayerAgeProperties sAgeProperties[] = { 56.0f, // unk_2C 68.0f, // unk_30 70.0f, // unk_34 - 18.0f, // unk_38 + 18.0f, // wallCheckRadius 15.0f, // unk_3C 70.0f, // unk_40 { 9, 4671, 359 }, // unk_44 @@ -410,7 +438,7 @@ static PlayerAgeProperties sAgeProperties[] = { { &gPlayerAnim_link_normal_climb_endBR, &gPlayerAnim_link_normal_climb_endBL }, // unk_CC }, { - 40.0f, // unk_00 + 40.0f, // ceilingCheckHeight 60.0f, // unk_04 11.0f / 17.0f, // unk_08 71.0f, // unk_0C @@ -424,7 +452,7 @@ static PlayerAgeProperties sAgeProperties[] = { 32.0f, // unk_2C 48.0f, // unk_30 70.0f * (11.0f / 17.0f), // unk_34 - 14.0f, // unk_38 + 14.0f, // wallCheckRadius 12.0f, // unk_3C 55.0f, // unk_40 { -24, 3565, 876 }, // unk_44 @@ -468,20 +496,20 @@ static f32 D_808535D4 = 0.0f; static s16 D_808535D8 = 0; static s16 D_808535DC = 0; static s32 D_808535E0 = 0; -static s32 D_808535E4 = FLOOR_TYPE_0; +static s32 sFloorType = FLOOR_TYPE_0; static f32 D_808535E8 = 1.0f; static f32 D_808535EC = 1.0f; -static u32 sInteractWallFlags = 0; -static u32 sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; +static u32 sTouchedWallFlags = 0; +static u32 sConveyorSpeed = CONVEYOR_SPEED_DISABLED; static s16 sIsFloorConveyor = false; static s16 sConveyorYaw = 0; -static f32 D_80853600 = 0.0f; -static s32 D_80853604 = FLOOR_PROPERTY_0; -static s32 D_80853608 = 0; -static s32 D_8085360C = 0; -static s16 D_80853610 = 0; -static s32 D_80853614 = 0; -static s32 D_80853618 = 0; +static f32 sYDistToFloor = 0.0f; +static s32 sPrevFloorProperty = FLOOR_PROPERTY_0; // floor property from the previous frame +static s32 sShapeYawToTouchedWall = 0; +static s32 sWorldYawToTouchedWall = 0; +static s16 sFloorShapePitch = 0; +static s32 sUseHeldItem = false; // When true, the current held item is used. Is reset to false every frame. +static s32 sHeldItemButtonIsHeldDown = false; // Indicates if the button for the current held item is held down. static u16 D_8085361C[] = { NA_SE_VO_LI_SWEAT, @@ -1213,7 +1241,7 @@ static s8 sItemActions[] = { PLAYER_IA_SWORD_BIGGORON, // ITEM_SWORD_BIGGORON }; -static s32 (*D_80853EDC[])(Player* this, PlayState* play) = { +static s32 (*sItemActionUpdateFuncs[])(Player* this, PlayState* play) = { func_8083485C, // PLAYER_IA_NONE func_8083485C, // PLAYER_IA_LAST_USED func_8083485C, // PLAYER_IA_FISHING_POLE @@ -1283,7 +1311,7 @@ static s32 (*D_80853EDC[])(Player* this, PlayState* play) = { func_8083485C, // PLAYER_IA_LENS_OF_TRUTH }; -static void (*D_80853FE8[])(PlayState* play, Player* this) = { +static void (*sItemActionInitFuncs[])(PlayState* play, Player* this) = { func_80833770, // PLAYER_IA_NONE func_80833770, // PLAYER_IA_LAST_USED func_80833770, // PLAYER_IA_FISHING_POLE @@ -1354,53 +1382,55 @@ static void (*D_80853FE8[])(PlayState* play, Player* this) = { }; typedef enum { - /* 0 */ PLAYER_D_808540F4_0, - /* 1 */ PLAYER_D_808540F4_1, - /* 2 */ PLAYER_D_808540F4_2, - /* 3 */ PLAYER_D_808540F4_3, - /* 4 */ PLAYER_D_808540F4_4, - /* 5 */ PLAYER_D_808540F4_5, - /* 6 */ PLAYER_D_808540F4_6, - /* 7 */ PLAYER_D_808540F4_7, - /* 8 */ PLAYER_D_808540F4_8, - /* 9 */ PLAYER_D_808540F4_9, - /* 10 */ PLAYER_D_808540F4_10, - /* 11 */ PLAYER_D_808540F4_11, - /* 12 */ PLAYER_D_808540F4_12, - /* 13 */ PLAYER_D_808540F4_13, - /* 14 */ PLAYER_D_808540F4_MAX -} PlayerD_808540F4Index; + /* 0 */ PLAYER_ITEM_CHG_0, + /* 1 */ PLAYER_ITEM_CHG_1, + /* 2 */ PLAYER_ITEM_CHG_2, + /* 3 */ PLAYER_ITEM_CHG_3, + /* 4 */ PLAYER_ITEM_CHG_4, + /* 5 */ PLAYER_ITEM_CHG_5, + /* 6 */ PLAYER_ITEM_CHG_6, + /* 7 */ PLAYER_ITEM_CHG_7, + /* 8 */ PLAYER_ITEM_CHG_8, + /* 9 */ PLAYER_ITEM_CHG_9, + /* 10 */ PLAYER_ITEM_CHG_10, + /* 11 */ PLAYER_ITEM_CHG_11, + /* 12 */ PLAYER_ITEM_CHG_12, + /* 13 */ PLAYER_ITEM_CHG_13, + /* 14 */ PLAYER_ITEM_CHG_MAX +} ItemChangeType; -static struct_808540F4 D_808540F4[PLAYER_D_808540F4_MAX] = { - /* PLAYER_D_808540F4_0 */ { &gPlayerAnim_link_normal_free2free, 12 }, - /* PLAYER_D_808540F4_1 */ { &gPlayerAnim_link_normal_normal2fighter, 6 }, - /* PLAYER_D_808540F4_2 */ { &gPlayerAnim_link_hammer_normal2long, 8 }, - /* PLAYER_D_808540F4_3 */ { &gPlayerAnim_link_normal_normal2free, 8 }, - /* PLAYER_D_808540F4_4 */ { &gPlayerAnim_link_fighter_fighter2long, 8 }, - /* PLAYER_D_808540F4_5 */ { &gPlayerAnim_link_normal_fighter2free, 10 }, - /* PLAYER_D_808540F4_6 */ { &gPlayerAnim_link_hammer_long2free, 7 }, - /* PLAYER_D_808540F4_7 */ { &gPlayerAnim_link_hammer_long2long, 11 }, - /* PLAYER_D_808540F4_8 */ { &gPlayerAnim_link_normal_free2free, 12 }, - /* PLAYER_D_808540F4_9 */ { &gPlayerAnim_link_normal_normal2bom, 4 }, - /* PLAYER_D_808540F4_10 */ { &gPlayerAnim_link_normal_long2bom, 4 }, - /* PLAYER_D_808540F4_11 */ { &gPlayerAnim_link_normal_free2bom, 4 }, - /* PLAYER_D_808540F4_12 */ { &gPlayerAnim_link_anchor_anchor2fighter, 5 }, - /* PLAYER_D_808540F4_13 */ { &gPlayerAnim_link_normal_free2freeB, 13 }, +static ItemChangeInfo sItemChangeInfo[PLAYER_ITEM_CHG_MAX] = { + /* PLAYER_ITEM_CHG_0 */ { &gPlayerAnim_link_normal_free2free, 12 }, + /* PLAYER_ITEM_CHG_1 */ { &gPlayerAnim_link_normal_normal2fighter, 6 }, + /* PLAYER_ITEM_CHG_2 */ { &gPlayerAnim_link_hammer_normal2long, 8 }, + /* PLAYER_ITEM_CHG_3 */ { &gPlayerAnim_link_normal_normal2free, 8 }, + /* PLAYER_ITEM_CHG_4 */ { &gPlayerAnim_link_fighter_fighter2long, 8 }, + /* PLAYER_ITEM_CHG_5 */ { &gPlayerAnim_link_normal_fighter2free, 10 }, + /* PLAYER_ITEM_CHG_6 */ { &gPlayerAnim_link_hammer_long2free, 7 }, + /* PLAYER_ITEM_CHG_7 */ { &gPlayerAnim_link_hammer_long2long, 11 }, + /* PLAYER_ITEM_CHG_8 */ { &gPlayerAnim_link_normal_free2free, 12 }, + /* PLAYER_ITEM_CHG_9 */ { &gPlayerAnim_link_normal_normal2bom, 4 }, + /* PLAYER_ITEM_CHG_10 */ { &gPlayerAnim_link_normal_long2bom, 4 }, + /* PLAYER_ITEM_CHG_11 */ { &gPlayerAnim_link_normal_free2bom, 4 }, + /* PLAYER_ITEM_CHG_12 */ { &gPlayerAnim_link_anchor_anchor2fighter, 5 }, + /* PLAYER_ITEM_CHG_13 */ { &gPlayerAnim_link_normal_free2freeB, 13 }, }; -static s8 D_80854164[PLAYER_ANIMTYPE_MAX][PLAYER_ANIMTYPE_MAX] = { - { PLAYER_D_808540F4_8, -PLAYER_D_808540F4_5, -PLAYER_D_808540F4_3, -PLAYER_D_808540F4_6, PLAYER_D_808540F4_8, - PLAYER_D_808540F4_11 }, - { PLAYER_D_808540F4_5, PLAYER_D_808540F4_0, -PLAYER_D_808540F4_1, PLAYER_D_808540F4_4, PLAYER_D_808540F4_5, - PLAYER_D_808540F4_9 }, - { PLAYER_D_808540F4_3, PLAYER_D_808540F4_1, PLAYER_D_808540F4_0, PLAYER_D_808540F4_2, PLAYER_D_808540F4_3, - PLAYER_D_808540F4_9 }, - { PLAYER_D_808540F4_6, -PLAYER_D_808540F4_4, -PLAYER_D_808540F4_2, PLAYER_D_808540F4_7, PLAYER_D_808540F4_6, - PLAYER_D_808540F4_10 }, - { PLAYER_D_808540F4_8, -PLAYER_D_808540F4_5, -PLAYER_D_808540F4_3, -PLAYER_D_808540F4_6, PLAYER_D_808540F4_8, - PLAYER_D_808540F4_11 }, - { PLAYER_D_808540F4_8, -PLAYER_D_808540F4_5, -PLAYER_D_808540F4_3, -PLAYER_D_808540F4_6, PLAYER_D_808540F4_8, - PLAYER_D_808540F4_11 }, +// Maps the appropriate ItemChangeType based on current and next animtype. +// A negative type value means the corresponding animation should be played in reverse. +static s8 sItemChangeTypes[PLAYER_ANIMTYPE_MAX][PLAYER_ANIMTYPE_MAX] = { + { PLAYER_ITEM_CHG_8, -PLAYER_ITEM_CHG_5, -PLAYER_ITEM_CHG_3, -PLAYER_ITEM_CHG_6, PLAYER_ITEM_CHG_8, + PLAYER_ITEM_CHG_11 }, + { PLAYER_ITEM_CHG_5, PLAYER_ITEM_CHG_0, -PLAYER_ITEM_CHG_1, PLAYER_ITEM_CHG_4, PLAYER_ITEM_CHG_5, + PLAYER_ITEM_CHG_9 }, + { PLAYER_ITEM_CHG_3, PLAYER_ITEM_CHG_1, PLAYER_ITEM_CHG_0, PLAYER_ITEM_CHG_2, PLAYER_ITEM_CHG_3, + PLAYER_ITEM_CHG_9 }, + { PLAYER_ITEM_CHG_6, -PLAYER_ITEM_CHG_4, -PLAYER_ITEM_CHG_2, PLAYER_ITEM_CHG_7, PLAYER_ITEM_CHG_6, + PLAYER_ITEM_CHG_10 }, + { PLAYER_ITEM_CHG_8, -PLAYER_ITEM_CHG_5, -PLAYER_ITEM_CHG_3, -PLAYER_ITEM_CHG_6, PLAYER_ITEM_CHG_8, + PLAYER_ITEM_CHG_11 }, + { PLAYER_ITEM_CHG_8, -PLAYER_ITEM_CHG_5, -PLAYER_ITEM_CHG_3, -PLAYER_ITEM_CHG_6, PLAYER_ITEM_CHG_8, + PLAYER_ITEM_CHG_11 }, }; static ExplosiveInfo sExplosiveInfos[] = { @@ -1527,7 +1557,7 @@ static LinkAnimationHeader* D_80854378[] = { static u8 D_80854380[2] = { PLAYER_MWA_SPIN_ATTACK_1H, PLAYER_MWA_SPIN_ATTACK_2H }; static u8 D_80854384[2] = { PLAYER_MWA_BIG_SPIN_1H, PLAYER_MWA_BIG_SPIN_2H }; -static u16 D_80854388[] = { BTN_B, BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT }; +static u16 sItemButtons[] = { BTN_B, BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT }; static u8 sMagicSpellCosts[] = { 12, 24, 24, 12, 24, 12 }; @@ -1588,20 +1618,20 @@ s32 func_8083224C(PlayState* play) { return CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_8); } -void func_80832264(PlayState* play, Player* this, LinkAnimationHeader* anim) { +void Player_AnimPlayOnce(PlayState* play, Player* this, LinkAnimationHeader* anim) { LinkAnimation_PlayOnce(play, &this->skelAnime, anim); } -void func_80832284(PlayState* play, Player* this, LinkAnimationHeader* anim) { +void Player_AnimPlayLoop(PlayState* play, Player* this, LinkAnimationHeader* anim) { LinkAnimation_PlayLoop(play, &this->skelAnime, anim); } -void func_808322A4(PlayState* play, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, anim, 2.0f / 3.0f); +void Player_AnimPlayLoopAdjusted(PlayState* play, Player* this, LinkAnimationHeader* anim) { + LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, anim, PLAYER_ANIM_ADJUSTED_SPEED); } -void func_808322D0(PlayState* play, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 2.0f / 3.0f); +void Player_AnimPlayOnceAdjusted(PlayState* play, Player* this, LinkAnimationHeader* anim) { + LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, PLAYER_ANIM_ADJUSTED_SPEED); } void func_808322FC(Player* this) { @@ -1629,7 +1659,7 @@ void func_80832340(PlayState* play, Player* this) { this->stateFlags2 &= ~(PLAYER_STATE2_10 | PLAYER_STATE2_11); } -void func_808323B4(PlayState* play, Player* this) { +void Player_DetachHeldActor(PlayState* play, Player* this) { Actor* heldActor = this->heldActor; if ((heldActor != NULL) && !Player_HoldsHookshot(this)) { @@ -1641,7 +1671,7 @@ void func_808323B4(PlayState* play, Player* this) { } if (Player_GetExplosiveHeld(this) >= 0) { - func_8083399C(play, this, PLAYER_IA_NONE); + Player_InitItemAction(play, this, PLAYER_IA_NONE); this->heldItemId = ITEM_NONE_FE; } } @@ -1675,7 +1705,7 @@ void func_80832440(PlayState* play, Player* this) { s32 func_80832528(PlayState* play, Player* this) { if (this->heldItemAction >= PLAYER_IA_FISHING_POLE) { - func_80835F44(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); return 1; } else { return 0; @@ -1684,19 +1714,19 @@ s32 func_80832528(PlayState* play, Player* this) { void func_80832564(PlayState* play, Player* this) { func_80832440(play, this); - func_808323B4(play, this); + Player_DetachHeldActor(play, this); } s32 func_80832594(Player* this, s32 arg1, s32 arg2) { s16 temp = this->unk_A80 - D_808535D8; - this->unk_850 += arg1 + (s16)(ABS(temp) * fabsf(D_808535D4) * 2.5415802156203426e-06f); + this->actionVar2 += arg1 + (s16)(ABS(temp) * fabsf(D_808535D4) * 2.5415802156203426e-06f); if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B)) { - this->unk_850 += 5; + this->actionVar2 += 5; } - return this->unk_850 > arg2; + return this->actionVar2 > arg2; } void func_80832630(PlayState* play) { @@ -1822,49 +1852,49 @@ void func_80832924(Player* this, struct_80832924* entry) { } while (cont); } -void func_80832B0C(PlayState* play, Player* this, LinkAnimationHeader* anim) { +void Player_AnimChangeOnceMorph(PlayState* play, Player* this, LinkAnimationHeader* anim) { LinkAnimation_Change(play, &this->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, -6.0f); } -void func_80832B78(PlayState* play, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_Change(play, &this->skelAnime, anim, 2.0f / 3.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, - -6.0f); +void Player_AnimChangeOnceMorphAdjusted(PlayState* play, Player* this, LinkAnimationHeader* anim) { + LinkAnimation_Change(play, &this->skelAnime, anim, PLAYER_ANIM_ADJUSTED_SPEED, 0.0f, Animation_GetLastFrame(anim), + ANIMMODE_ONCE, -6.0f); } -void func_80832BE8(PlayState* play, Player* this, LinkAnimationHeader* anim) { +void Player_AnimChangeLoopMorph(PlayState* play, Player* this, LinkAnimationHeader* anim) { LinkAnimation_Change(play, &this->skelAnime, anim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f); } -void func_80832C2C(PlayState* play, Player* this, LinkAnimationHeader* anim) { +void Player_AnimChangeFreeze(PlayState* play, Player* this, LinkAnimationHeader* anim) { LinkAnimation_Change(play, &this->skelAnime, anim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); } -void func_80832C6C(PlayState* play, Player* this, LinkAnimationHeader* anim) { +void Player_AnimChangeLoopSlowMorph(PlayState* play, Player* this, LinkAnimationHeader* anim) { LinkAnimation_Change(play, &this->skelAnime, anim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -16.0f); } s32 func_80832CB0(PlayState* play, Player* this, LinkAnimationHeader* anim) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_80832284(play, this, anim); + Player_AnimPlayLoop(play, this, anim); return 1; } else { return 0; } } -void func_80832CFC(Player* this) { +void Player_SkelAnimeResetPrevTranslRot(Player* this) { this->skelAnime.prevTransl = this->skelAnime.baseTransl; this->skelAnime.prevRot = this->actor.shape.rot.y; } -void func_80832D20(Player* this) { - func_80832CFC(this); +void Player_SkelAnimeResetPrevTranslRotAgeScale(Player* this) { + Player_SkelAnimeResetPrevTranslRot(this); this->skelAnime.prevTransl.x *= this->ageProperties->unk_08; this->skelAnime.prevTransl.y *= this->ageProperties->unk_08; this->skelAnime.prevTransl.z *= this->ageProperties->unk_08; } -void func_80832DB0(Player* this) { +void Player_ZeroRootLimbYaw(Player* this) { this->skelAnime.jointTable[1].y = 0; } @@ -1880,7 +1910,7 @@ void func_80832DBC(Player* this) { } else { this->skelAnime.jointTable[0].y = this->skelAnime.baseTransl.y; } - func_80832CFC(this); + Player_SkelAnimeResetPrevTranslRot(this); this->skelAnime.moveFlags = 0; } } @@ -1911,14 +1941,14 @@ void func_80832E48(Player* this, s32 flags) { func_808322FC(this); } -#define FLAG_FUNC_80832F54_8 (1 << 8) -#define FLAG_FUNC_80832F54_9 (1 << 9) +#define ANIM_REPLACE_APPLY_FLAG_8 (1 << 8) +#define ANIM_REPLACE_APPLY_FLAG_9 (1 << 9) -void func_80832F54(PlayState* play, Player* this, s32 flags) { - if (flags & FLAG_FUNC_80832F54_9) { - func_80832D20(this); - } else if ((flags & FLAG_FUNC_80832F54_8) || (this->skelAnime.moveFlags != 0)) { - func_80832CFC(this); +void Player_AnimReplaceApplyFlags(PlayState* play, Player* this, s32 flags) { + if (flags & ANIM_REPLACE_APPLY_FLAG_9) { + Player_SkelAnimeResetPrevTranslRotAgeScale(this); + } else if ((flags & ANIM_REPLACE_APPLY_FLAG_8) || (this->skelAnime.moveFlags != 0)) { + Player_SkelAnimeResetPrevTranslRot(this); } else { this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; this->skelAnime.prevRot = this->actor.shape.rot.y; @@ -1929,38 +1959,42 @@ void func_80832F54(PlayState* play, Player* this, s32 flags) { AnimationContext_DisableQueue(play); } -void func_80832FFC(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, f32 playbackSpeed) { +void Player_AnimReplacePlayOnceSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, + f32 playbackSpeed) { LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, playbackSpeed); - func_80832F54(play, this, flags); + Player_AnimReplaceApplyFlags(play, this, flags); } -void func_8083303C(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { - func_80832FFC(play, this, anim, flags, 1.0f); +void Player_AnimReplacePlayOnce(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { + Player_AnimReplacePlayOnceSetSpeed(play, this, anim, flags, 1.0f); } -void func_80833064(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { - func_80832FFC(play, this, anim, flags, 2.0f / 3.0f); +void Player_AnimReplacePlayOnceAdjusted(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { + Player_AnimReplacePlayOnceSetSpeed(play, this, anim, flags, PLAYER_ANIM_ADJUSTED_SPEED); } -void func_8083308C(PlayState* play, Player* this, LinkAnimationHeader* anim) { - func_80833064(play, this, anim, ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE); +void Player_AnimReplaceNormalPlayOnceAdjusted(PlayState* play, Player* this, LinkAnimationHeader* anim) { + Player_AnimReplacePlayOnceAdjusted(play, this, anim, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE); } -void func_808330AC(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, f32 playbackSpeed) { +void Player_AnimReplacePlayLoopSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, + f32 playbackSpeed) { LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, anim, playbackSpeed); - func_80832F54(play, this, flags); + Player_AnimReplaceApplyFlags(play, this, flags); } -void func_808330EC(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { - func_808330AC(play, this, anim, flags, 1.0f); +void Player_AnimReplacePlayLoop(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { + Player_AnimReplacePlayLoopSetSpeed(play, this, anim, flags, 1.0f); } -void func_80833114(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { - func_808330AC(play, this, anim, flags, 2.0f / 3.0f); +void Player_AnimReplacePlayLoopAdjusted(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { + Player_AnimReplacePlayLoopSetSpeed(play, this, anim, flags, PLAYER_ANIM_ADJUSTED_SPEED); } -void func_8083313C(PlayState* play, Player* this, LinkAnimationHeader* anim) { - func_80833114(play, this, anim, ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE); +void Player_AnimReplaceNormalPlayLoopAdjusted(PlayState* play, Player* this, LinkAnimationHeader* anim) { + Player_AnimReplacePlayLoopAdjusted(play, this, anim, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE); } void func_8083315C(PlayState* play, Player* this) { @@ -2006,7 +2040,7 @@ void func_808332F4(Player* this, PlayState* play) { this->unk_862 = ABS(giEntry->gi); } -static LinkAnimationHeader* func_80833338(Player* this) { +LinkAnimationHeader* func_80833338(Player* this) { return GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType); } @@ -2087,31 +2121,31 @@ LinkAnimationHeader* func_808335F4(Player* this) { } } -void func_80833638(Player* this, PlayerFunc82C arg1) { - this->func_82C = arg1; +void Player_SetItemActionFunc(Player* this, ItemActionFunc itemActionFunc) { + this->itemActionFunc = itemActionFunc; this->unk_836 = 0; - this->unk_830 = 0.0f; + this->skelAnimeUpperBlendWeight = 0.0f; func_808326F0(this); } -void func_80833664(PlayState* play, Player* this, s8 itemAction) { +void Player_InitItemActionWithAnim(PlayState* play, Player* this, s8 itemAction) { LinkAnimationHeader* current = this->skelAnime.animation; LinkAnimationHeader** iter = D_80853914 + this->modelAnimType; - u32 i; + u32 animGroup; this->stateFlags1 &= ~(PLAYER_STATE1_3 | PLAYER_STATE1_24); - for (i = 0; i < PLAYER_ANIMGROUP_MAX; i++) { + for (animGroup = 0; animGroup < PLAYER_ANIMGROUP_MAX; animGroup++) { if (current == *iter) { break; } iter += PLAYER_ANIMTYPE_MAX; } - func_8083399C(play, this, itemAction); + Player_InitItemAction(play, this, itemAction); - if (i < PLAYER_ANIMGROUP_MAX) { - this->skelAnime.animation = GET_PLAYER_ANIM(i, this->modelAnimType); + if (animGroup < PLAYER_ANIMGROUP_MAX) { + this->skelAnime.animation = GET_PLAYER_ANIM(animGroup, this->modelAnimType); } } @@ -2194,7 +2228,7 @@ void func_80833984(PlayState* play, Player* this) { this->stateFlags1 |= PLAYER_STATE1_24; } -void func_8083399C(PlayState* play, Player* this, s8 itemAction) { +void Player_InitItemAction(PlayState* play, Player* this, s8 itemAction) { this->unk_860 = 0; this->unk_85C = 0.0f; this->unk_858 = 0.0f; @@ -2204,7 +2238,7 @@ void func_8083399C(PlayState* play, Player* this, s8 itemAction) { this->stateFlags1 &= ~(PLAYER_STATE1_3 | PLAYER_STATE1_24); - D_80853FE8[itemAction](play, this); + sItemActionInitFuncs[itemAction](play, this); Player_SetModelGroup(this, this->modelGroup); } @@ -2281,23 +2315,23 @@ void func_80833C3C(Player* this) { this->unk_870 = this->unk_874 = 0.0f; } -s32 func_80833C50(Player* this, s32 item) { +s32 Player_ItemIsInUse(Player* this, s32 item) { if ((item < ITEM_NONE_FE) && (Player_ItemToItemAction(item) == this->itemAction)) { - return 1; + return true; } else { - return 0; + return false; } } -s32 func_80833C98(s32 item1, s32 itemAction) { +s32 Player_ItemIsItemAction(s32 item1, s32 itemAction) { if ((item1 < ITEM_NONE_FE) && (Player_ItemToItemAction(item1) == itemAction)) { - return 1; + return true; } else { - return 0; + return false; } } -s32 func_80833CDC(PlayState* play, s32 index) { +s32 Player_GetItemOnButton(PlayState* play, s32 index) { if (index >= 4) { return ITEM_NONE; } else if (play->bombchuBowlingStatus != 0) { @@ -2313,114 +2347,129 @@ s32 func_80833CDC(PlayState* play, s32 index) { } } -void func_80833DF8(Player* this, PlayState* play) { +/** + * Handles the high level item usage and changing process based on the B and C buttons. + * + * Tasks include: + * - Put away a mask if it is not present on any C button + * - Put away an item if it is not present on the B button or any C button + * - Use an item on the B button or any C button if the corresponding button is pressed + * - Keep track of the current item button being held down + */ +void Player_ProcessItemButtons(Player* this, PlayState* play) { s32 maskItemAction; s32 item; s32 i; if (this->currentMask != PLAYER_MASK_NONE) { maskItemAction = this->currentMask - 1 + PLAYER_IA_MASK_KEATON; - if (!func_80833C98(C_BTN_ITEM(0), maskItemAction) && !func_80833C98(C_BTN_ITEM(1), maskItemAction) && - !func_80833C98(C_BTN_ITEM(2), maskItemAction)) { + + if (!Player_ItemIsItemAction(C_BTN_ITEM(0), maskItemAction) && + !Player_ItemIsItemAction(C_BTN_ITEM(1), maskItemAction) && + !Player_ItemIsItemAction(C_BTN_ITEM(2), maskItemAction)) { this->currentMask = PLAYER_MASK_NONE; } } if (!(this->stateFlags1 & (PLAYER_STATE1_11 | PLAYER_STATE1_29)) && !func_8008F128(this)) { if (this->itemAction >= PLAYER_IA_FISHING_POLE) { - if (!func_80833C50(this, B_BTN_ITEM) && !func_80833C50(this, C_BTN_ITEM(0)) && - !func_80833C50(this, C_BTN_ITEM(1)) && !func_80833C50(this, C_BTN_ITEM(2))) { - func_80835F44(play, this, ITEM_NONE); + if (!Player_ItemIsInUse(this, B_BTN_ITEM) && !Player_ItemIsInUse(this, C_BTN_ITEM(0)) && + !Player_ItemIsInUse(this, C_BTN_ITEM(1)) && !Player_ItemIsInUse(this, C_BTN_ITEM(2))) { + Player_UseItem(play, this, ITEM_NONE); return; } } - for (i = 0; i < ARRAY_COUNT(D_80854388); i++) { - if (CHECK_BTN_ALL(sControlInput->press.button, D_80854388[i])) { + for (i = 0; i < ARRAY_COUNT(sItemButtons); i++) { + if (CHECK_BTN_ALL(sControlInput->press.button, sItemButtons[i])) { break; } } - item = func_80833CDC(play, i); + item = Player_GetItemOnButton(play, i); + if (item >= ITEM_NONE_FE) { - for (i = 0; i < ARRAY_COUNT(D_80854388); i++) { - if (CHECK_BTN_ALL(sControlInput->cur.button, D_80854388[i])) { + for (i = 0; i < ARRAY_COUNT(sItemButtons); i++) { + if (CHECK_BTN_ALL(sControlInput->cur.button, sItemButtons[i])) { break; } } - item = func_80833CDC(play, i); + item = Player_GetItemOnButton(play, i); + if ((item < ITEM_NONE_FE) && (Player_ItemToItemAction(item) == this->heldItemAction)) { - D_80853618 = true; + sHeldItemButtonIsHeldDown = true; } } else { this->heldItemButton = i; - func_80835F44(play, this, item); + Player_UseItem(play, this, item); } } } -void func_808340DC(Player* this, PlayState* play) { +void Player_StartChangingHeldItem(Player* this, PlayState* play) { LinkAnimationHeader* anim; - f32 phi_f2; - f32 phi_f12; - f32 phi_f14; - f32 phi_f0; - s32 sp38; - s8 sp37; + f32 endFrameTemp; + f32 startFrame; + f32 endFrame; + f32 playSpeed; + s32 itemChangeType; + s8 heldItemAction; s32 nextAnimType; - sp37 = Player_ItemToItemAction(this->heldItemId); - func_80833638(this, func_80834A2C); + heldItemAction = Player_ItemToItemAction(this->heldItemId); + + Player_SetItemActionFunc(this, Player_IA_ChangeHeldItem); nextAnimType = gPlayerModelTypes[this->nextModelGroup][PLAYER_MODELGROUPENTRY_ANIM]; - sp38 = D_80854164[gPlayerModelTypes[this->modelGroup][PLAYER_MODELGROUPENTRY_ANIM]][nextAnimType]; - if ((sp37 == PLAYER_IA_BOTTLE) || (sp37 == PLAYER_IA_BOOMERANG) || - ((sp37 == PLAYER_IA_NONE) && + itemChangeType = sItemChangeTypes[gPlayerModelTypes[this->modelGroup][PLAYER_MODELGROUPENTRY_ANIM]][nextAnimType]; + + if ((heldItemAction == PLAYER_IA_BOTTLE) || (heldItemAction == PLAYER_IA_BOOMERANG) || + ((heldItemAction == PLAYER_IA_NONE) && ((this->heldItemAction == PLAYER_IA_BOTTLE) || (this->heldItemAction == PLAYER_IA_BOOMERANG)))) { - sp38 = (sp37 == PLAYER_IA_NONE) ? -PLAYER_D_808540F4_13 : PLAYER_D_808540F4_13; + itemChangeType = (heldItemAction == PLAYER_IA_NONE) ? -PLAYER_ITEM_CHG_13 : PLAYER_ITEM_CHG_13; } - this->unk_15A = ABS(sp38); + this->itemChangeType = ABS(itemChangeType); + anim = sItemChangeInfo[this->itemChangeType].anim; - anim = D_808540F4[this->unk_15A].anim; if ((anim == &gPlayerAnim_link_normal_fighter2free) && (this->currentShield == PLAYER_SHIELD_NONE)) { anim = &gPlayerAnim_link_normal_free2fighter_free; } - phi_f2 = Animation_GetLastFrame(anim); - phi_f14 = phi_f2; + endFrameTemp = Animation_GetLastFrame(anim); + endFrame = endFrameTemp; - if (sp38 >= 0) { - phi_f0 = 1.2f; - phi_f12 = 0.0f; + if (itemChangeType >= 0) { + playSpeed = 1.2f; + startFrame = 0.0f; } else { - phi_f14 = 0.0f; - phi_f0 = -1.2f; - phi_f12 = phi_f2; + endFrame = 0.0f; + playSpeed = -1.2f; + startFrame = endFrameTemp; } - if (sp37 != PLAYER_IA_NONE) { - phi_f0 *= 2.0f; + if (heldItemAction != PLAYER_IA_NONE) { + playSpeed *= 2.0f; } - LinkAnimation_Change(play, &this->skelAnime2, anim, phi_f0, phi_f12, phi_f14, ANIMMODE_ONCE, 0.0f); + LinkAnimation_Change(play, &this->skelAnimeUpper, anim, playSpeed, startFrame, endFrame, ANIMMODE_ONCE, 0.0f); - this->stateFlags1 &= ~PLAYER_STATE1_8; + this->stateFlags1 &= ~PLAYER_STATE1_START_CHANGING_HELD_ITEM; } -void func_80834298(Player* this, PlayState* play) { - if ((this->actor.category == ACTORCAT_PLAYER) && !(this->stateFlags1 & PLAYER_STATE1_8) && +void Player_UpdateItems(Player* this, PlayState* play) { + if ((this->actor.category == ACTORCAT_PLAYER) && !(this->stateFlags1 & PLAYER_STATE1_START_CHANGING_HELD_ITEM) && ((this->heldItemAction == this->itemAction) || (this->stateFlags1 & PLAYER_STATE1_22)) && (gSaveContext.save.info.playerData.health != 0) && (play->csCtx.state == CS_STATE_IDLE) && (this->csMode == PLAYER_CSMODE_NONE) && (play->shootingGalleryStatus == 0) && (play->activeCamId == CAM_ID_MAIN) && (play->transitionTrigger != TRANS_TRIGGER_START) && (gSaveContext.timerState != TIMER_STATE_STOP)) { - func_80833DF8(this, play); + Player_ProcessItemButtons(this, play); } - if (this->stateFlags1 & PLAYER_STATE1_8) { - func_808340DC(this, play); + if (this->stateFlags1 & PLAYER_STATE1_START_CHANGING_HELD_ITEM) { + Player_StartChangingHeldItem(this, play); } } @@ -2455,7 +2504,7 @@ s32 func_8083442C(Player* this, PlayState* play) { (gSaveContext.magicState != MAGIC_STATE_IDLE)) { Sfx_PlaySfxCentered(NA_SE_SY_ERROR); } else { - func_80833638(this, func_808351D4); + Player_SetItemActionFunc(this, func_808351D4); this->stateFlags1 |= PLAYER_STATE1_9; this->unk_834 = 14; @@ -2485,7 +2534,7 @@ s32 func_8083442C(Player* this, PlayState* play) { return 0; } -void func_80834594(PlayState* play, Player* this) { +void Player_FinishItemChange(PlayState* play, Player* this) { if (this->heldItemAction != PLAYER_IA_NONE) { if (func_8008F2BC(this, this->heldItemAction) >= 0) { func_808328EC(this, NA_SE_IT_SWORD_PUTAWAY); @@ -2494,7 +2543,7 @@ void func_80834594(PlayState* play, Player* this) { } } - func_80835F44(play, this, this->heldItemId); + Player_UseItem(play, this, this->heldItemId); if (func_8008F2BC(this, this->heldItemAction) >= 0) { func_808328EC(this, NA_SE_IT_SWORD_PICKOUT); @@ -2504,20 +2553,20 @@ void func_80834594(PlayState* play, Player* this) { } void func_80834644(PlayState* play, Player* this) { - if (func_80834A2C == this->func_82C) { - func_80834594(play, this); + if (Player_IA_ChangeHeldItem == this->itemActionFunc) { + Player_FinishItemChange(play, this); } - func_80833638(this, D_80853EDC[this->heldItemAction]); + Player_SetItemActionFunc(this, sItemActionUpdateFuncs[this->heldItemAction]); this->unk_834 = 0; this->unk_6AC = 0; - func_808323B4(play, this); - this->stateFlags1 &= ~PLAYER_STATE1_8; + Player_DetachHeldActor(play, this); + this->stateFlags1 &= ~PLAYER_STATE1_START_CHANGING_HELD_ITEM; } LinkAnimationHeader* func_808346C4(PlayState* play, Player* this) { - func_80833638(this, func_80834B5C); - func_808323B4(play, this); + Player_SetItemActionFunc(this, func_80834B5C); + Player_DetachHeldActor(play, this); if (this->unk_870 < 0.5f) { return D_808543A4[Player_HoldsTwoHandedWeapon(this)]; @@ -2537,7 +2586,7 @@ s32 func_80834758(PlayState* play, Player* this) { anim = func_808346C4(play, this); frame = Animation_GetLastFrame(anim); - LinkAnimation_Change(play, &this->skelAnime2, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); + LinkAnimation_Change(play, &this->skelAnimeUpper, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); Player_PlaySfx(this, NA_SE_IT_SHIELD_POSTURE); return 1; @@ -2555,33 +2604,33 @@ s32 func_8083485C(Player* this, PlayState* play) { } void func_80834894(Player* this) { - func_80833638(this, func_80834C74); + Player_SetItemActionFunc(this, func_80834C74); if (this->itemAction < 0) { func_8008EC70(this); } - Animation_Reverse(&this->skelAnime2); + Animation_Reverse(&this->skelAnimeUpper); Player_PlaySfx(this, NA_SE_IT_SHIELD_REMOVE); } -void func_808348EC(PlayState* play, Player* this) { - struct_808540F4* ptr = &D_808540F4[this->unk_15A]; - f32 temp; +void Player_WaitToFinishItemChange(PlayState* play, Player* this) { + ItemChangeInfo* itemChangeEntry = &sItemChangeInfo[this->itemChangeType]; + f32 changeFrame; - temp = ptr->unk_04; - temp = (this->skelAnime2.playSpeed < 0.0f) ? temp - 1.0f : temp; + changeFrame = itemChangeEntry->changeFrame; + changeFrame = (this->skelAnimeUpper.playSpeed < 0.0f) ? changeFrame - 1.0f : changeFrame; - if (LinkAnimation_OnFrame(&this->skelAnime2, temp)) { - func_80834594(play, this); + if (LinkAnimation_OnFrame(&this->skelAnimeUpper, changeFrame)) { + Player_FinishItemChange(play, this); } func_80833B54(this); } s32 func_8083499C(Player* this, PlayState* play) { - if (this->stateFlags1 & PLAYER_STATE1_8) { - func_808340DC(this, play); + if (this->stateFlags1 & PLAYER_STATE1_START_CHANGING_HELD_ITEM) { + Player_StartChangingHeldItem(this, play); } else { return 0; } @@ -2597,31 +2646,31 @@ s32 func_808349DC(Player* this, PlayState* play) { } } -s32 func_80834A2C(Player* this, PlayState* play) { - if (LinkAnimation_Update(play, &this->skelAnime2) || +s32 Player_IA_ChangeHeldItem(Player* this, PlayState* play) { + if (LinkAnimation_Update(play, &this->skelAnimeUpper) || ((Player_ItemToItemAction(this->heldItemId) == this->heldItemAction) && - (D_80853614 = - (D_80853614 || ((this->modelAnimType != PLAYER_ANIMTYPE_3) && (play->shootingGalleryStatus == 0)))))) { - func_80833638(this, D_80853EDC[this->heldItemAction]); + (sUseHeldItem = + (sUseHeldItem || ((this->modelAnimType != PLAYER_ANIMTYPE_3) && (play->shootingGalleryStatus == 0)))))) { + Player_SetItemActionFunc(this, sItemActionUpdateFuncs[this->heldItemAction]); this->unk_834 = 0; this->unk_6AC = 0; - D_80853618 = D_80853614; - return this->func_82C(this, play); + sHeldItemButtonIsHeldDown = sUseHeldItem; + return this->itemActionFunc(this, play); } if (func_80833350(this) != 0) { - func_808348EC(play, this); - func_80832264(play, this, func_80833338(this)); + Player_WaitToFinishItemChange(play, this); + Player_AnimPlayOnce(play, this, func_80833338(this)); this->unk_6AC = 0; } else { - func_808348EC(play, this); + Player_WaitToFinishItemChange(play, this); } return 1; } s32 func_80834B5C(Player* this, PlayState* play) { - LinkAnimation_Update(play, &this->skelAnime2); + LinkAnimation_Update(play, &this->skelAnimeUpper); if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { func_80834894(this); @@ -2637,10 +2686,10 @@ s32 func_80834BD4(Player* this, PlayState* play) { LinkAnimationHeader* anim; f32 frame; - if (LinkAnimation_Update(play, &this->skelAnime2)) { + if (LinkAnimation_Update(play, &this->skelAnimeUpper)) { anim = func_808346C4(play, this); frame = Animation_GetLastFrame(anim); - LinkAnimation_Change(play, &this->skelAnime2, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); + LinkAnimation_Change(play, &this->skelAnimeUpper, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); } this->stateFlags1 |= PLAYER_STATE1_22; @@ -2650,13 +2699,14 @@ s32 func_80834BD4(Player* this, PlayState* play) { } s32 func_80834C74(Player* this, PlayState* play) { - D_80853614 = D_80853618; + sUseHeldItem = sHeldItemButtonIsHeldDown; - if (D_80853614 || LinkAnimation_Update(play, &this->skelAnime2)) { - func_80833638(this, D_80853EDC[this->heldItemAction]); - LinkAnimation_PlayLoop(play, &this->skelAnime2, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType)); + if (sUseHeldItem || LinkAnimation_Update(play, &this->skelAnimeUpper)) { + Player_SetItemActionFunc(this, sItemActionUpdateFuncs[this->heldItemAction]); + LinkAnimation_PlayLoop(play, &this->skelAnimeUpper, + GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType)); this->unk_6AC = 0; - this->func_82C(this, play); + this->itemActionFunc(this, play); return 0; } @@ -2676,17 +2726,17 @@ s32 func_80834D2C(Player* this, PlayState* play) { } else { anim = &gPlayerAnim_link_hook_shot_ready; } - LinkAnimation_PlayOnce(play, &this->skelAnime2, anim); + LinkAnimation_PlayOnce(play, &this->skelAnimeUpper, anim); } else { - func_80833638(this, func_80835884); + Player_SetItemActionFunc(this, func_80835884); this->unk_834 = 10; - LinkAnimation_PlayOnce(play, &this->skelAnime2, &gPlayerAnim_link_boom_throw_wait2waitR); + LinkAnimation_PlayOnce(play, &this->skelAnimeUpper, &gPlayerAnim_link_boom_throw_wait2waitR); } if (this->stateFlags1 & PLAYER_STATE1_23) { - func_80832284(play, this, &gPlayerAnim_link_uma_anim_walk); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_uma_anim_walk); } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !func_80833B54(this)) { - func_80832284(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType)); + Player_AnimPlayLoop(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType)); } return 1; @@ -2716,7 +2766,7 @@ s32 func_80834EB8(Player* this, PlayState* play) { s32 func_80834F2C(Player* this, PlayState* play) { if ((this->doorType == PLAYER_DOORTYPE_NONE) && !(this->stateFlags1 & PLAYER_STATE1_25)) { - if (D_80853614 || func_80834E44(play)) { + if (sUseHeldItem || func_80834E44(play)) { if (func_80834D2C(this, play)) { return func_80834EB8(this, play); } @@ -2805,10 +2855,10 @@ s32 func_808351D4(Player* this, PlayState* play) { if ((this->unk_836 == 0) && (func_80833350(this) == 0) && (this->skelAnime.animation == &gPlayerAnim_link_bow_side_walk)) { - LinkAnimation_PlayOnce(play, &this->skelAnime2, D_808543CC[sp2C]); + LinkAnimation_PlayOnce(play, &this->skelAnimeUpper, D_808543CC[sp2C]); this->unk_836 = -1; - } else if (LinkAnimation_Update(play, &this->skelAnime2)) { - LinkAnimation_PlayLoop(play, &this->skelAnime2, D_808543D4[sp2C]); + } else if (LinkAnimation_Update(play, &this->skelAnimeUpper)) { + LinkAnimation_PlayLoop(play, &this->skelAnimeUpper, D_808543D4[sp2C]); this->unk_836 = 1; } else if (this->unk_836 == 1) { this->unk_836 = 2; @@ -2820,8 +2870,8 @@ s32 func_808351D4(Player* this, PlayState* play) { func_80834EB8(this, play); - if ((this->unk_836 > 0) && ((this->unk_860 < 0) || (!D_80853618 && !func_80834E7C(play)))) { - func_80833638(this, func_808353D8); + if ((this->unk_836 > 0) && ((this->unk_860 < 0) || (!sHeldItemButtonIsHeldDown && !func_80834E7C(play)))) { + Player_SetItemActionFunc(this, func_808353D8); if (this->unk_860 >= 0) { if (sp2C == 0) { if (!func_808350A4(play, this)) { @@ -2841,20 +2891,21 @@ s32 func_808351D4(Player* this, PlayState* play) { } s32 func_808353D8(Player* this, PlayState* play) { - LinkAnimation_Update(play, &this->skelAnime2); + LinkAnimation_Update(play, &this->skelAnimeUpper); if (Player_HoldsHookshot(this) && !func_80834FBC(this)) { return 1; } - if (!func_80834758(play, this) && (D_80853614 || ((this->unk_860 < 0) && D_80853618) || func_80834E44(play))) { + if (!func_80834758(play, this) && + (sUseHeldItem || ((this->unk_860 < 0) && sHeldItemButtonIsHeldDown) || func_80834E44(play))) { this->unk_860 = ABS(this->unk_860); if (func_8083442C(this, play)) { if (Player_HoldsHookshot(this)) { this->unk_836 = 1; } else { - LinkAnimation_PlayOnce(play, &this->skelAnime2, &gPlayerAnim_link_bow_bow_shoot_next); + LinkAnimation_PlayOnce(play, &this->skelAnimeUpper, &gPlayerAnim_link_bow_bow_shoot_next); } } } else { @@ -2870,10 +2921,10 @@ s32 func_808353D8(Player* this, PlayState* play) { } if (Player_HoldsHookshot(this)) { - func_80833638(this, func_8083501C); + Player_SetItemActionFunc(this, func_8083501C); } else { - func_80833638(this, func_80835588); - LinkAnimation_PlayOnce(play, &this->skelAnime2, &gPlayerAnim_link_bow_bow_shoot_end); + Player_SetItemActionFunc(this, func_80835588); + LinkAnimation_PlayOnce(play, &this->skelAnimeUpper, &gPlayerAnim_link_bow_bow_shoot_end); } this->unk_834 = 0; @@ -2883,8 +2934,8 @@ s32 func_808353D8(Player* this, PlayState* play) { } s32 func_80835588(Player* this, PlayState* play) { - if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || LinkAnimation_Update(play, &this->skelAnime2)) { - func_80833638(this, func_8083501C); + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || LinkAnimation_Update(play, &this->skelAnimeUpper)) { + Player_SetItemActionFunc(this, func_8083501C); } return 1; @@ -2894,7 +2945,7 @@ void func_808355DC(Player* this) { this->stateFlags1 |= PLAYER_STATE1_17; if (!(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_7) && - (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (D_80853608 < 0x2000)) { + (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (sShapeYawToTouchedWall < 0x2000)) { this->yaw = this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; } @@ -2913,8 +2964,8 @@ s32 func_80835644(PlayState* play, Player* this, Actor* arg2) { void func_80835688(Player* this, PlayState* play) { if (!func_80835644(play, this, this->heldActor)) { - func_80833638(this, func_808356E8); - LinkAnimation_PlayLoop(play, &this->skelAnime2, &gPlayerAnim_link_normal_carryB_wait); + Player_SetItemActionFunc(this, func_808356E8); + LinkAnimation_PlayLoop(play, &this->skelAnimeUpper, &gPlayerAnim_link_normal_carryB_wait); } } @@ -2930,8 +2981,8 @@ s32 func_808356E8(Player* this, PlayState* play) { } if (this->stateFlags1 & PLAYER_STATE1_11) { - if (LinkAnimation_Update(play, &this->skelAnime2)) { - LinkAnimation_PlayLoop(play, &this->skelAnime2, &gPlayerAnim_link_normal_carryB_wait); + if (LinkAnimation_Update(play, &this->skelAnimeUpper)) { + LinkAnimation_PlayLoop(play, &this->skelAnimeUpper, &gPlayerAnim_link_normal_carryB_wait); } if ((heldActor->id == ACTOR_EN_NIW) && (this->actor.velocity.y <= 0.0f)) { @@ -2956,7 +3007,7 @@ s32 func_80835800(Player* this, PlayState* play) { } if (this->stateFlags1 & PLAYER_STATE1_25) { - func_80833638(this, func_80835B60); + Player_SetItemActionFunc(this, func_80835B60); } else if (func_80834F2C(this, play)) { return 1; } @@ -2965,9 +3016,9 @@ s32 func_80835800(Player* this, PlayState* play) { } s32 func_80835884(Player* this, PlayState* play) { - if (LinkAnimation_Update(play, &this->skelAnime2)) { - func_80833638(this, func_808358F0); - LinkAnimation_PlayLoop(play, &this->skelAnime2, &gPlayerAnim_link_boom_throw_waitR); + if (LinkAnimation_Update(play, &this->skelAnimeUpper)) { + Player_SetItemActionFunc(this, func_808358F0); + LinkAnimation_PlayLoop(play, &this->skelAnimeUpper, &gPlayerAnim_link_boom_throw_waitR); } func_80834EB8(this, play); @@ -2980,17 +3031,17 @@ s32 func_808358F0(Player* this, PlayState* play) { if ((func_808334E4(this) == animSeg) || (func_80833528(this) == animSeg) || (func_808335B0(this) == animSeg) || (func_808335F4(this) == animSeg)) { - AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime2.jointTable, + AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnimeUpper.jointTable, this->skelAnime.jointTable); } else { - LinkAnimation_Update(play, &this->skelAnime2); + LinkAnimation_Update(play, &this->skelAnimeUpper); } func_80834EB8(this, play); - if (!D_80853618) { - func_80833638(this, func_808359FC); - LinkAnimation_PlayOnce(play, &this->skelAnime2, + if (!sHeldItemButtonIsHeldDown) { + Player_SetItemActionFunc(this, func_808359FC); + LinkAnimation_PlayOnce(play, &this->skelAnimeUpper, (this->unk_870 < 0.5f) ? &gPlayerAnim_link_boom_throwR : &gPlayerAnim_link_boom_throwL); } @@ -2998,10 +3049,10 @@ s32 func_808358F0(Player* this, PlayState* play) { } s32 func_808359FC(Player* this, PlayState* play) { - if (LinkAnimation_Update(play, &this->skelAnime2)) { - func_80833638(this, func_80835B60); + if (LinkAnimation_Update(play, &this->skelAnimeUpper)) { + Player_SetItemActionFunc(this, func_80835B60); this->unk_834 = 0; - } else if (LinkAnimation_OnFrame(&this->skelAnime2, 6.0f)) { + } else if (LinkAnimation_OnFrame(&this->skelAnimeUpper, 6.0f)) { f32 posX = (Math_SinS(this->actor.shape.rot.y) * 10.0f) + this->actor.world.pos.x; f32 posZ = (Math_CosS(this->actor.shape.rot.y) * 10.0f) + this->actor.world.pos.z; s32 yaw = (this->unk_664 != NULL) ? this->actor.shape.rot.y + 14000 : this->actor.shape.rot.y; @@ -3032,8 +3083,8 @@ s32 func_80835B60(Player* this, PlayState* play) { } if (!(this->stateFlags1 & PLAYER_STATE1_25)) { - func_80833638(this, func_80835C08); - LinkAnimation_PlayOnce(play, &this->skelAnime2, &gPlayerAnim_link_boom_catch); + Player_SetItemActionFunc(this, func_80835C08); + LinkAnimation_PlayOnce(play, &this->skelAnimeUpper, &gPlayerAnim_link_boom_catch); func_808357E8(this, gPlayerLeftHandBoomerangDLs); Player_PlaySfx(this, NA_SE_PL_CATCH_BOOMERANG); func_80832698(this, NA_SE_VO_LI_SWORD_N); @@ -3044,26 +3095,26 @@ s32 func_80835B60(Player* this, PlayState* play) { } s32 func_80835C08(Player* this, PlayState* play) { - if (!func_80835800(this, play) && LinkAnimation_Update(play, &this->skelAnime2)) { - func_80833638(this, func_80835800); + if (!func_80835800(this, play) && LinkAnimation_Update(play, &this->skelAnimeUpper)) { + Player_SetItemActionFunc(this, func_80835800); } return 1; } -s32 func_80835C58(PlayState* play, Player* this, PlayerFunc674 func, s32 flags) { - if (func == this->func_674) { +s32 Player_SetupAction(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 flags) { + if (actionFunc == this->actionFunc) { return 0; } - if (func_8084E3C4 == this->func_674) { + if (Player_Action_8084E3C4 == this->actionFunc) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); this->stateFlags2 &= ~(PLAYER_STATE2_24 | PLAYER_STATE2_25); - } else if (func_808507F4 == this->func_674) { + } else if (Player_Action_808507F4 == this->actionFunc) { func_80832340(play, this); } - this->func_674 = func; + this->actionFunc = actionFunc; if ((this->itemAction != this->heldItemAction) && (!(flags & 1) || !(this->stateFlags1 & PLAYER_STATE1_22))) { func_8008EC70(this); @@ -3075,34 +3126,38 @@ s32 func_80835C58(PlayState* play, Player* this, PlayerFunc674 func, s32 flags) } func_80832DBC(this); + this->stateFlags1 &= ~(PLAYER_STATE1_2 | PLAYER_STATE1_6 | PLAYER_STATE1_26 | PLAYER_STATE1_28 | PLAYER_STATE1_29 | PLAYER_STATE1_31); this->stateFlags2 &= ~(PLAYER_STATE2_19 | PLAYER_STATE2_27 | PLAYER_STATE2_28); this->stateFlags3 &= ~(PLAYER_STATE3_1 | PLAYER_STATE3_3 | PLAYER_STATE3_7); - this->unk_84F = 0; - this->unk_850 = 0; + + this->actionVar1 = 0; + this->actionVar2 = 0; + this->unk_6AC = 0; + func_808326F0(this); return 1; } -void func_80835DAC(PlayState* play, Player* this, PlayerFunc674 func, s32 flags) { +void func_80835DAC(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 flags) { s32 temp; temp = this->skelAnime.moveFlags; this->skelAnime.moveFlags = 0; - func_80835C58(play, this, func, flags); + Player_SetupAction(play, this, actionFunc, flags); this->skelAnime.moveFlags = temp; } -void func_80835DE4(PlayState* play, Player* this, PlayerFunc674 func, s32 flags) { +void func_80835DE4(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 flags) { s32 temp; if (this->itemAction >= 0) { temp = this->itemAction; this->itemAction = this->heldItemAction; - func_80835C58(play, this, func, flags); + Player_SetupAction(play, this, actionFunc, flags); this->itemAction = temp; Player_SetModels(this, Player_ActionToModelGroup(this, this->itemAction)); } @@ -3123,7 +3178,7 @@ void func_80835EA4(PlayState* play, s32 arg1) { Camera_SetCameraData(Play_GetCamera(play, CAM_ID_MAIN), 4, NULL, NULL, arg1, 0, 0); } -void func_80835EFC(Player* this) { +void Player_DestroyHookshot(Player* this) { if (Player_HoldsHookshot(this)) { Actor* heldActor = this->heldActor; @@ -3135,7 +3190,7 @@ void func_80835EFC(Player* this) { } } -void func_80835F44(PlayState* play, Player* this, s32 item) { +void Player_UseItem(PlayState* play, Player* this, s32 item) { s8 itemAction; s32 temp; s32 nextAnimType; @@ -3157,8 +3212,11 @@ void func_80835F44(PlayState* play, Player* this, s32 item) { (temp = Player_ActionToExplosive(this, itemAction), ((temp >= 0) && ((AMMO(sExplosiveInfos[temp].itemId) == 0) || (play->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].length >= 3)))))) { + // Prevent some items from being used if player is out of ammo. + // Also prevent explosives from being used if there are 3 or more active (outside of bombchu bowling) Sfx_PlaySfxCentered(NA_SE_SY_ERROR); } else if (itemAction == PLAYER_IA_LENS_OF_TRUTH) { + // Handle Lens of Truth if (Magic_RequestChange(play, 0, MAGIC_CONSUME_LENS)) { if (play->actorCtx.lensActive) { Actor_DisableLens(play); @@ -3171,12 +3229,14 @@ void func_80835F44(PlayState* play, Player* this, s32 item) { Sfx_PlaySfxCentered(NA_SE_SY_ERROR); } } else if (itemAction == PLAYER_IA_DEKU_NUT) { + // Handle Deku Nuts if (AMMO(ITEM_DEKU_NUT) != 0) { func_8083C61C(play, this); } else { Sfx_PlaySfxCentered(NA_SE_SY_ERROR); } } else if ((temp = Player_ActionToMagicSpell(this, itemAction)) >= 0) { + // Handle magic spells if (((itemAction == PLAYER_IA_FARORES_WIND) && (gSaveContext.respawn[RESPAWN_MODE_TOP].data > 0)) || ((gSaveContext.magicCapacity != 0) && (gSaveContext.magicState == MAGIC_STATE_IDLE) && (gSaveContext.save.info.playerData.magic >= sMagicSpellCosts[temp]))) { @@ -3186,6 +3246,7 @@ void func_80835F44(PlayState* play, Player* this, s32 item) { Sfx_PlaySfxCentered(NA_SE_SY_ERROR); } } else if (itemAction >= PLAYER_IA_MASK_KEATON) { + // Handle wearable masks if (this->currentMask != PLAYER_MASK_NONE) { this->currentMask = PLAYER_MASK_NONE; } else { @@ -3195,6 +3256,7 @@ void func_80835F44(PlayState* play, Player* this, s32 item) { func_808328EC(this, NA_SE_PL_CHANGE_ARMS); } else if (((itemAction >= PLAYER_IA_OCARINA_FAIRY) && (itemAction <= PLAYER_IA_OCARINA_OF_TIME)) || (itemAction >= PLAYER_IA_BOTTLE_FISH)) { + // Handle "cutscene items" if (!func_8008E9C4(this) || ((itemAction >= PLAYER_IA_BOTTLE_POTION_RED) && (itemAction <= PLAYER_IA_BOTTLE_FAIRY))) { TitleCard_Clear(play, &play->actorCtx.titleCtx); @@ -3203,22 +3265,26 @@ void func_80835F44(PlayState* play, Player* this, s32 item) { } } else if ((itemAction != this->heldItemAction) || ((this->heldActor == NULL) && (Player_ActionToExplosive(this, itemAction) >= 0))) { + // Handle using a new held item this->nextModelGroup = Player_ActionToModelGroup(this, itemAction); nextAnimType = gPlayerModelTypes[this->nextModelGroup][PLAYER_MODELGROUPENTRY_ANIM]; if ((this->heldItemAction >= 0) && (Player_ActionToMagicSpell(this, itemAction) < 0) && (item != this->heldItemId) && - (D_80854164[gPlayerModelTypes[this->modelGroup][PLAYER_MODELGROUPENTRY_ANIM]][nextAnimType] != - PLAYER_D_808540F4_0)) { + (sItemChangeTypes[gPlayerModelTypes[this->modelGroup][PLAYER_MODELGROUPENTRY_ANIM]][nextAnimType] != + PLAYER_ITEM_CHG_0)) { + // Start the held item change process this->heldItemId = item; - this->stateFlags1 |= PLAYER_STATE1_8; + this->stateFlags1 |= PLAYER_STATE1_START_CHANGING_HELD_ITEM; } else { - func_80835EFC(this); - func_808323B4(play, this); - func_80833664(play, this, itemAction); + // Init new held item for use + Player_DestroyHookshot(this); + Player_DetachHeldActor(play, this); + Player_InitItemActionWithAnim(play, this, itemAction); } } else { - D_80853614 = D_80853618 = true; + // Handle using the held item already in hand + sUseHeldItem = sHeldItemButtonIsHeldDown = true; } } } @@ -3229,11 +3295,11 @@ void func_80836448(PlayState* play, Player* this, LinkAnimationHeader* anim) { func_80832564(play, this); - func_80835C58(play, this, cond ? func_8084E368 : func_80843CEC, 0); + Player_SetupAction(play, this, cond ? Player_Action_8084E368 : Player_Action_80843CEC, 0); this->stateFlags1 |= PLAYER_STATE1_7; - func_80832264(play, this, anim); + Player_AnimPlayOnce(play, this, anim); if (anim == &gPlayerAnim_link_derth_rebirth) { this->skelAnime.endFrame = 84.0f; } @@ -3246,7 +3312,7 @@ void func_80836448(PlayState* play, Player* this, LinkAnimationHeader* anim) { if (Inventory_ConsumeFairy(play)) { play->gameOverCtx.state = GAMEOVER_REVIVE_START; - this->unk_84F = 1; + this->actionVar1 = 1; } else { play->gameOverCtx.state = GAMEOVER_DEATH_START; Audio_StopBgmAndFanfare(0); @@ -3260,21 +3326,22 @@ void func_80836448(PlayState* play, Player* this, LinkAnimationHeader* anim) { } } -s32 func_808365C8(Player* this) { - return (!(func_808458D0 == this->func_674) || - ((this->stateFlags1 & PLAYER_STATE1_8) && +s32 Player_CanUpdateItems(Player* this) { + return (!(Player_Action_808458D0 == this->actionFunc) || + ((this->stateFlags1 & PLAYER_STATE1_START_CHANGING_HELD_ITEM) && ((this->heldItemId == ITEM_LAST_USED) || (this->heldItemId == ITEM_NONE)))) && - (!(func_80834A2C == this->func_82C) || (Player_ItemToItemAction(this->heldItemId) == this->heldItemAction)); + (!(Player_IA_ChangeHeldItem == this->itemActionFunc) || + (Player_ItemToItemAction(this->heldItemId) == this->heldItemAction)); } -s32 func_80836670(Player* this, PlayState* play) { +s32 Player_UpdateUpperBody(Player* this, PlayState* play) { if (!(this->stateFlags1 & PLAYER_STATE1_23) && (this->actor.parent != NULL) && Player_HoldsHookshot(this)) { - func_80835C58(play, this, func_80850AEC, 1); + Player_SetupAction(play, this, Player_Action_80850AEC, 1); this->stateFlags3 |= PLAYER_STATE3_7; - func_80832264(play, this, &gPlayerAnim_link_hook_fly_start); - func_80832F54(play, this, - ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | - ANIM_FLAG_PLAYER_7); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_hook_fly_start); + Player_AnimReplaceApplyFlags(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); func_80832224(this); this->yaw = this->actor.shape.rot.y; this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; @@ -3284,31 +3351,31 @@ s32 func_80836670(Player* this, PlayState* play) { return 1; } - if (func_808365C8(this)) { - func_80834298(this, play); - if (func_8084E604 == this->func_674) { + if (Player_CanUpdateItems(this)) { + Player_UpdateItems(this, play); + if (Player_Action_8084E604 == this->actionFunc) { return 1; } } - if (!this->func_82C(this, play)) { + if (!this->itemActionFunc(this, play)) { return 0; } - if (this->unk_830 != 0.0f) { + if (this->skelAnimeUpperBlendWeight != 0.0f) { if ((func_80833350(this) == 0) || (this->speedXZ != 0.0f)) { - AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->skelAnime2.jointTable, - this->skelAnime.jointTable, D_80853410); + AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->skelAnimeUpper.jointTable, + this->skelAnime.jointTable, sUpperBodyLimbCopyMap); } - Math_StepToF(&this->unk_830, 0.0f, 0.25f); + Math_StepToF(&this->skelAnimeUpperBlendWeight, 0.0f, 0.25f); AnimationContext_SetInterp(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable, 1.0f - this->unk_830); + this->skelAnimeUpper.jointTable, 1.0f - this->skelAnimeUpperBlendWeight); } else if ((func_80833350(this) == 0) || (this->speedXZ != 0.0f)) { AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable, D_80853410); + this->skelAnimeUpper.jointTable, sUpperBodyLimbCopyMap); } else { AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable); + this->skelAnimeUpper.jointTable); } return 1; @@ -3316,7 +3383,7 @@ s32 func_80836670(Player* this, PlayState* play) { s32 func_80836898(PlayState* play, Player* this, PlayerFuncA74 func) { this->func_A74 = func; - func_80835C58(play, this, func_808458D0, 0); + Player_SetupAction(play, this, Player_Action_808458D0, 0); this->stateFlags2 |= PLAYER_STATE2_6; return func_80832528(play, this); } @@ -3515,7 +3582,7 @@ s32 func_80836FAC(PlayState* play, Player* this, f32* arg2, s16* arg3, f32 arg4) } if (D_808535D4 != 0.0f) { - temp_f0 = Math_SinS(this->unk_898); + temp_f0 = Math_SinS(this->floorPitch); temp_f12 = this->unk_880; temp_f14 = CLAMP(temp_f0, 0.0f, 0.6f); @@ -3582,8 +3649,8 @@ s32 func_80837348(PlayState* play, Player* this, s8* arg2, s32 arg3) { if (!(this->stateFlags1 & (PLAYER_STATE1_0 | PLAYER_STATE1_7 | PLAYER_STATE1_29))) { if (arg3 != 0) { - D_808535E0 = func_80836670(this, play); - if (func_8084E604 == this->func_674) { + D_808535E0 = Player_UpdateUpperBody(this, play); + if (Player_Action_8084E604 == this->actionFunc) { return 1; } } @@ -3593,7 +3660,8 @@ s32 func_80837348(PlayState* play, Player* this, s8* arg2, s32 arg3) { return 1; } - if (!(this->stateFlags1 & PLAYER_STATE1_8) && (func_80834A2C != this->func_82C)) { + if (!(this->stateFlags1 & PLAYER_STATE1_START_CHANGING_HELD_ITEM) && + (Player_IA_ChangeHeldItem != this->itemActionFunc)) { while (*arg2 >= 0) { if (D_80854448[*arg2](this, play)) { return 1; @@ -3696,7 +3764,7 @@ void func_80837704(PlayState* play, Player* this) { } void func_808377DC(PlayState* play, Player* this) { - func_80835C58(play, this, func_80844E68, 1); + Player_SetupAction(play, this, Player_Action_80844E68, 1); func_80837704(play, this); } @@ -3774,7 +3842,7 @@ void func_80837948(PlayState* play, Player* this, s32 arg2) { u32 dmgFlags; s32 temp; - func_80835C58(play, this, func_808502D0, 0); + Player_SetupAction(play, this, Player_Action_808502D0, 0); this->unk_844 = 8; if (!((arg2 >= PLAYER_MWA_FLIPSLASH_FINISH) && (arg2 <= PLAYER_MWA_JUMPSLASH_FINISH))) { func_80832318(this); @@ -3791,9 +3859,9 @@ void func_80837948(PlayState* play, Player* this, s32 arg2) { this->meleeWeaponAnimation = arg2; - func_808322D0(play, this, D_80854190[arg2].unk_00); + Player_AnimPlayOnceAdjusted(play, this, D_80854190[arg2].unk_00); if ((arg2 != PLAYER_MWA_FLIPSLASH_START) && (arg2 != PLAYER_MWA_JUMPSLASH_START)) { - func_80832F54(play, this, FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_PLAYER_SETMOVE); + Player_AnimReplaceApplyFlags(play, this, ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_0 | ANIM_FLAG_PLAYER_SETMOVE); } this->yaw = this->actor.shape.rot.y; @@ -3842,9 +3910,9 @@ void func_80837B60(Player* this) { } void func_80837B9C(Player* this, PlayState* play) { - func_80835C58(play, this, func_8084411C, 0); - func_80832284(play, this, &gPlayerAnim_link_normal_landing_wait); - this->unk_850 = 1; + Player_SetupAction(play, this, Player_Action_8084411C, 0); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_normal_landing_wait); + this->actionVar2 = 1; if (this->unk_6AD != 3) { this->unk_6AD = 0; } @@ -3857,7 +3925,7 @@ static LinkAnimationHeader* D_808544B0[] = { }; void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, s16 arg5, s32 arg6) { - LinkAnimationHeader* sp2C = NULL; + LinkAnimationHeader* anim = NULL; LinkAnimationHeader** sp28; if (this->stateFlags1 & PLAYER_STATE1_13) { @@ -3879,9 +3947,9 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, func_80837AE0(this, arg6); if (arg2 == 3) { - func_80835C58(play, this, func_8084FB10, 0); + Player_SetupAction(play, this, Player_Action_8084FB10, 0); - sp2C = &gPlayerAnim_link_normal_ice_down; + anim = &gPlayerAnim_link_normal_ice_down; func_80832224(this); Player_RequestRumble(this, 255, 10, 40, 0); @@ -3889,29 +3957,29 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, Player_PlaySfx(this, NA_SE_PL_FREEZE_S); func_80832698(this, NA_SE_VO_LI_FREEZE); } else if (arg2 == 4) { - func_80835C58(play, this, func_8084FBF4, 0); + Player_SetupAction(play, this, Player_Action_8084FBF4, 0); Player_RequestRumble(this, 255, 80, 150, 0); - func_808322A4(play, this, &gPlayerAnim_link_normal_electric_shock); + Player_AnimPlayLoopAdjusted(play, this, &gPlayerAnim_link_normal_electric_shock); func_80832224(this); - this->unk_850 = 20; + this->actionVar2 = 20; } else { arg5 -= this->actor.shape.rot.y; if (this->stateFlags1 & PLAYER_STATE1_27) { - func_80835C58(play, this, func_8084E30C, 0); + Player_SetupAction(play, this, Player_Action_8084E30C, 0); Player_RequestRumble(this, 180, 20, 50, 0); this->speedXZ = 4.0f; this->actor.velocity.y = 0.0f; - sp2C = &gPlayerAnim_link_swimer_swim_hit; + anim = &gPlayerAnim_link_swimer_swim_hit; func_80832698(this, NA_SE_VO_LI_DAMAGE_S); } else if ((arg2 == 1) || (arg2 == 2) || !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->stateFlags1 & (PLAYER_STATE1_13 | PLAYER_STATE1_14 | PLAYER_STATE1_21))) { - func_80835C58(play, this, func_8084377C, 0); + Player_SetupAction(play, this, Player_Action_8084377C, 0); this->stateFlags3 |= PLAYER_STATE3_1; @@ -3919,13 +3987,13 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, func_80832224(this); if (arg2 == 2) { - this->unk_850 = 4; + this->actionVar2 = 4; this->actor.speed = 3.0f; this->speedXZ = 3.0f; this->actor.velocity.y = 6.0f; - func_80832C2C(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_damage_run, this->modelAnimType)); + Player_AnimChangeFreeze(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_damage_run, this->modelAnimType)); func_80832698(this, NA_SE_VO_LI_DAMAGE_S); } else { this->actor.speed = arg3; @@ -3933,9 +4001,9 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, this->actor.velocity.y = arg4; if (ABS(arg5) > 0x4000) { - sp2C = &gPlayerAnim_link_normal_front_downA; + anim = &gPlayerAnim_link_normal_front_downA; } else { - sp2C = &gPlayerAnim_link_normal_back_downA; + anim = &gPlayerAnim_link_normal_back_downA; } if ((this->actor.category != ACTORCAT_PLAYER) && (this->actor.colChkInfo.health == 0)) { @@ -3957,7 +4025,7 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, sp28 = D_808544B0; - func_80835C58(play, this, func_8084370C, 0); + Player_SetupAction(play, this, Player_Action_8084370C, 0); func_80833C3C(this); if (this->actor.colChkInfo.damage < 5) { @@ -3976,7 +4044,7 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, sp28 += 1; } - sp2C = *sp28; + anim = *sp28; func_80832698(this, NA_SE_VO_LI_DAMAGE_S); } @@ -3993,8 +4061,8 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, this->stateFlags1 |= PLAYER_STATE1_26; - if (sp2C != NULL) { - func_808322D0(play, this, sp2C); + if (anim != NULL) { + Player_AnimPlayOnceAdjusted(play, this, anim); } } @@ -4057,7 +4125,7 @@ s32 func_808382DC(Player* this, PlayState* play) { } else { sp68 = ((Player_GetHeight(this) - 8.0f) < (this->unk_6C4 * this->actor.scale.y)); - if (sp68 || (this->actor.bgCheckFlags & BGCHECKFLAG_CRUSHED) || (D_808535E4 == FLOOR_TYPE_9) || + if (sp68 || (this->actor.bgCheckFlags & BGCHECKFLAG_CRUSHED) || (sFloorType == FLOOR_TYPE_9) || (this->stateFlags2 & PLAYER_STATE2_31)) { func_80832698(this, NA_SE_VO_LI_DAMAGE_S); @@ -4116,23 +4184,23 @@ s32 func_808382DC(Player* this, PlayState* play) { if (!Player_IsChildWithHylianShield(this)) { if (this->invincibilityTimer >= 0) { LinkAnimationHeader* anim; - s32 sp54 = func_80843188 == this->func_674; + s32 sp54 = Player_Action_80843188 == this->actionFunc; if (!func_808332B8(this)) { - func_80835C58(play, this, func_808435C4, 0); + Player_SetupAction(play, this, Player_Action_808435C4, 0); } - if (!(this->unk_84F = sp54)) { - func_80833638(this, func_80834BD4); + if (!(this->actionVar1 = sp54)) { + Player_SetItemActionFunc(this, func_80834BD4); if (this->unk_870 < 0.5f) { anim = D_808543BC[Player_HoldsTwoHandedWeapon(this)]; } else { anim = D_808543B4[Player_HoldsTwoHandedWeapon(this)]; } - LinkAnimation_PlayOnce(play, &this->skelAnime2, anim); + LinkAnimation_PlayOnce(play, &this->skelAnimeUpper, anim); } else { - func_80832264(play, this, D_808543C4[Player_HoldsTwoHandedWeapon(this)]); + Player_AnimPlayOnce(play, this, D_808543C4[Player_HoldsTwoHandedWeapon(this)]); } } @@ -4181,15 +4249,15 @@ s32 func_808382DC(Player* this, PlayState* play) { return 0; } else { static u8 D_808544F4[] = { 120, 60 }; - s32 sp48 = func_80838144(D_808535E4); + s32 sp48 = func_80838144(sFloorType); if (((this->actor.wallPoly != NULL) && func_80042108(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) || ((sp48 >= 0) && func_80042108(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) && - (this->unk_A79 >= D_808544F4[sp48])) || + (this->floorTypeTimer >= D_808544F4[sp48])) || ((sp48 >= 0) && - ((this->currentTunic != PLAYER_TUNIC_GORON) || (this->unk_A79 >= D_808544F4[sp48])))) { - this->unk_A79 = 0; + ((this->currentTunic != PLAYER_TUNIC_GORON) || (this->floorTypeTimer >= D_808544F4[sp48])))) { + this->floorTypeTimer = 0; this->actor.colChkInfo.damage = 4; func_80837C0C(play, this, 0, 4.0f, 5.0f, this->actor.shape.rot.y, 20); } else { @@ -4203,10 +4271,10 @@ s32 func_808382DC(Player* this, PlayState* play) { } void func_80838940(Player* this, LinkAnimationHeader* anim, f32 arg2, PlayState* play, u16 sfxId) { - func_80835C58(play, this, func_8084411C, 1); + Player_SetupAction(play, this, Player_Action_8084411C, 1); if (anim != NULL) { - func_808322D0(play, this, anim); + Player_AnimPlayOnceAdjusted(play, this, anim); } this->actor.velocity.y = arg2 * D_808535E8; @@ -4225,74 +4293,75 @@ void func_808389E8(Player* this, LinkAnimationHeader* anim, f32 arg2, PlayState* s32 func_80838A14(Player* this, PlayState* play) { s32 sp3C; - LinkAnimationHeader* sp38; + LinkAnimationHeader* anim; f32 sp34; f32 temp; f32 wallPolyNormalX; f32 wallPolyNormalZ; f32 sp24; - if (!(this->stateFlags1 & PLAYER_STATE1_11) && (this->unk_88C >= 2) && - (!(this->stateFlags1 & PLAYER_STATE1_27) || (this->ageProperties->unk_14 > this->wallHeight))) { + if (!(this->stateFlags1 & PLAYER_STATE1_11) && (this->ledgeClimbType >= PLAYER_LEDGE_CLIMB_2) && + (!(this->stateFlags1 & PLAYER_STATE1_27) || (this->ageProperties->unk_14 > this->yDistToLedge))) { sp3C = 0; if (func_808332B8(this)) { if (this->actor.yDistToWater < 50.0f) { - if ((this->unk_88C < 2) || (this->wallHeight > this->ageProperties->unk_10)) { + if ((this->ledgeClimbType < PLAYER_LEDGE_CLIMB_2) || + (this->yDistToLedge > this->ageProperties->unk_10)) { return 0; } - } else if ((this->currentBoots != PLAYER_BOOTS_IRON) || (this->unk_88C > 2)) { + } else if ((this->currentBoots != PLAYER_BOOTS_IRON) || (this->ledgeClimbType > PLAYER_LEDGE_CLIMB_2)) { return 0; } } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || - ((this->ageProperties->unk_14 <= this->wallHeight) && (this->stateFlags1 & PLAYER_STATE1_27))) { + ((this->ageProperties->unk_14 <= this->yDistToLedge) && (this->stateFlags1 & PLAYER_STATE1_27))) { return 0; } - if ((this->actor.wallBgId != BGCHECK_SCENE) && (sInteractWallFlags & WALL_FLAG_6)) { - if (this->unk_88D >= 6) { + if ((this->actor.wallBgId != BGCHECK_SCENE) && (sTouchedWallFlags & WALL_FLAG_6)) { + if (this->ledgeClimbDelayTimer >= 6) { this->stateFlags2 |= PLAYER_STATE2_2; if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { sp3C = 1; } } - } else if ((this->unk_88D >= 6) || CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { + } else if ((this->ledgeClimbDelayTimer >= 6) || CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { sp3C = 1; } if (sp3C != 0) { - func_80835C58(play, this, func_80845668, 0); + Player_SetupAction(play, this, Player_Action_80845668, 0); this->stateFlags1 |= PLAYER_STATE1_18; - sp34 = this->wallHeight; + sp34 = this->yDistToLedge; if (this->ageProperties->unk_14 <= sp34) { - sp38 = &gPlayerAnim_link_normal_250jump_start; + anim = &gPlayerAnim_link_normal_250jump_start; this->speedXZ = 1.0f; } else { wallPolyNormalX = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); wallPolyNormalZ = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); - sp24 = this->wallDistance + 0.5f; + sp24 = this->distToInteractWall + 0.5f; this->stateFlags1 |= PLAYER_STATE1_14; if (func_808332B8(this)) { - sp38 = &gPlayerAnim_link_swimer_swim_15step_up; + anim = &gPlayerAnim_link_swimer_swim_15step_up; sp34 -= (60.0f * this->ageProperties->unk_08); this->stateFlags1 &= ~PLAYER_STATE1_27; } else if (this->ageProperties->unk_18 <= sp34) { - sp38 = &gPlayerAnim_link_normal_150step_up; + anim = &gPlayerAnim_link_normal_150step_up; sp34 -= (59.0f * this->ageProperties->unk_08); } else { - sp38 = &gPlayerAnim_link_normal_100step_up; + anim = &gPlayerAnim_link_normal_100step_up; sp34 -= (41.0f * this->ageProperties->unk_08); } this->actor.shape.yOffset -= sp34 * 100.0f; this->actor.world.pos.x -= sp24 * wallPolyNormalX; - this->actor.world.pos.y += this->wallHeight; + this->actor.world.pos.y += this->yDistToLedge; this->actor.world.pos.z -= sp24 * wallPolyNormalZ; func_80832224(this); @@ -4300,15 +4369,16 @@ s32 func_80838A14(Player* this, PlayState* play) { this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND; - LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, sp38, 1.3f); + LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 1.3f); AnimationContext_DisableQueue(play); this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000; return 1; } - } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->unk_88C == 1) && (this->unk_88D >= 3)) { - temp = (this->wallHeight * 0.08f) + 5.5f; + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->ledgeClimbType == PLAYER_LEDGE_CLIMB_1) && + (this->ledgeClimbDelayTimer >= 3)) { + temp = (this->yDistToLedge * 0.08f) + 5.5f; func_808389E8(this, &gPlayerAnim_link_normal_jump, temp, play); this->speedXZ = 2.5f; @@ -4319,25 +4389,25 @@ s32 func_80838A14(Player* this, PlayState* play) { } void func_80838E70(PlayState* play, Player* this, f32 arg2, s16 arg3) { - func_80835C58(play, this, func_80845CA4, 0); + Player_SetupAction(play, this, Player_Action_80845CA4, 0); func_80832440(play, this); - this->unk_84F = 1; - this->unk_850 = 1; + this->actionVar1 = 1; + this->actionVar2 = 1; this->unk_450.x = (Math_SinS(arg3) * arg2) + this->actor.world.pos.x; this->unk_450.z = (Math_CosS(arg3) * arg2) + this->actor.world.pos.z; - func_80832264(play, this, func_80833338(this)); + Player_AnimPlayOnce(play, this, func_80833338(this)); } void func_80838F18(PlayState* play, Player* this) { - func_80835C58(play, this, func_8084D610, 0); - func_80832C6C(play, this, &gPlayerAnim_link_swimer_swim_wait); + Player_SetupAction(play, this, Player_Action_8084D610, 0); + Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim_wait); } void func_80838F5C(PlayState* play, Player* this) { - func_80835C58(play, this, func_8084F88C, 0); + Player_SetupAction(play, this, Player_Action_8084F88C, 0); this->stateFlags1 |= PLAYER_STATE1_29 | PLAYER_STATE1_31; @@ -4347,7 +4417,7 @@ void func_80838F5C(PlayState* play, Player* this) { s32 func_80838FB8(PlayState* play, Player* this) { if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (this->stateFlags1 & PLAYER_STATE1_31)) { func_80838F5C(play, this); - func_80832284(play, this, &gPlayerAnim_link_normal_landing_wait); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_normal_landing_wait); func_80832698(this, NA_SE_VO_LI_FALL_S); Sfx_PlaySfxCentered2(NA_SE_OC_SECRET_WARP_IN); return 1; @@ -4409,7 +4479,7 @@ u8 sReturnEntranceGroupIndices[] = { 0, // ENTR_RETURN_GREAT_FAIRYS_FOUNTAIN_MAGIC }; -s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) { +s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) { s32 exitIndex; s32 temp; s32 sp34; @@ -4422,12 +4492,12 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) if (!(this->stateFlags1 & PLAYER_STATE1_7) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (this->csMode == PLAYER_CSMODE_NONE) && !(this->stateFlags1 & PLAYER_STATE1_0) && (((poly != NULL) && (exitIndex = SurfaceType_GetExitIndex(&play->colCtx, poly, bgId), exitIndex != 0)) || - (func_8083816C(D_808535E4) && (this->unk_A7A == FLOOR_PROPERTY_12)))) { + (func_8083816C(sFloorType) && (this->floorProperty == FLOOR_PROPERTY_12)))) { sp34 = this->unk_A84 - (s32)this->actor.world.pos.y; if (!(this->stateFlags1 & (PLAYER_STATE1_23 | PLAYER_STATE1_27 | PLAYER_STATE1_29)) && - !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (sp34 < 100) && (D_80853600 > 100.0f)) { + !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (sp34 < 100) && (sYDistToFloor > 100.0f)) { return 0; } @@ -4491,7 +4561,7 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) gSaveContext.entranceSpeed = speedXZ; } - if (sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { + if (sConveyorSpeed != CONVEYOR_SPEED_DISABLED) { yaw = sConveyorYaw; } else { yaw = this->actor.world.rot.y; @@ -4513,13 +4583,13 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) if (play->transitionTrigger == TRANS_TRIGGER_OFF) { if ((this->actor.world.pos.y < -4000.0f) || - (((this->unk_A7A == FLOOR_PROPERTY_5) || (this->unk_A7A == FLOOR_PROPERTY_12)) && - ((D_80853600 < 100.0f) || (this->fallDistance > 400.0f) || + (((this->floorProperty == FLOOR_PROPERTY_5) || (this->floorProperty == FLOOR_PROPERTY_12)) && + ((sYDistToFloor < 100.0f) || (this->fallDistance > 400.0f) || ((play->sceneId != SCENE_SHADOW_TEMPLE) && (this->fallDistance > 200.0f)))) || ((play->sceneId == SCENE_GANONS_TOWER_COLLAPSE_EXTERIOR) && (this->fallDistance > 320.0f))) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - if (this->unk_A7A == FLOOR_PROPERTY_5) { + if (this->floorProperty == FLOOR_PROPERTY_5) { Play_TriggerRespawn(play); } else { Play_TriggerVoidOut(play); @@ -4528,11 +4598,11 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) Sfx_PlaySfxCentered(NA_SE_OC_ABYSS); } else { func_80838F5C(play, this); - this->unk_850 = 9999; - if (this->unk_A7A == FLOOR_PROPERTY_5) { - this->unk_84F = -1; + this->actionVar2 = 9999; + if (this->floorProperty == FLOOR_PROPERTY_5) { + this->actionVar1 = -1; } else { - this->unk_84F = 1; + this->actionVar1 = 1; } } } @@ -4545,25 +4615,30 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) return 0; } -void func_808395DC(Player* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { +/** + * Gets a position relative to player's yaw. + * An offset is applied to the provided base position in the direction of shape y rotation. + * The resulting position is stored in `dest` + */ +void Player_GetRelativePosition(Player* this, Vec3f* base, Vec3f* offset, Vec3f* dest) { f32 cos = Math_CosS(this->actor.shape.rot.y); f32 sin = Math_SinS(this->actor.shape.rot.y); - arg3->x = arg1->x + ((arg2->x * cos) + (arg2->z * sin)); - arg3->y = arg1->y + arg2->y; - arg3->z = arg1->z + ((arg2->z * cos) - (arg2->x * sin)); + dest->x = base->x + ((offset->x * cos) + (offset->z * sin)); + dest->y = base->y + offset->y; + dest->z = base->z + ((offset->z * cos) - (offset->x * sin)); } Actor* Player_SpawnFairy(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3, s32 type) { Vec3f pos; - func_808395DC(this, arg2, arg3, &pos); + Player_GetRelativePosition(this, arg2, arg3, &pos); return Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, pos.x, pos.y, pos.z, 0, 0, 0, type); } f32 func_808396F4(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, s32* arg5) { - func_808395DC(this, &this->actor.world.pos, arg2, arg3); + Player_GetRelativePosition(this, &this->actor.world.pos, arg2, arg3); return BgCheck_EntityRaycastDown3(&play->colCtx, arg4, arg5, arg3); } @@ -4575,17 +4650,25 @@ f32 func_8083973C(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3) { return func_808396F4(play, this, arg2, arg3, &sp24, &sp20); } -s32 func_80839768(PlayState* play, Player* this, Vec3f* arg2, CollisionPoly** arg3, s32* arg4, Vec3f* arg5) { - Vec3f sp44; - Vec3f sp38; +/** + * Checks if a line between the player's position and the provided `offset` intersect a wall. + * + * Point A of the line is at player's world position offset by the height provided in `offset`. + * Point B of the line is at player's world position offset by the entire `offset` vector. + * Point A and B are always at the same height, meaning this is a horizontal line test. + */ +s32 Player_PosVsWallLineTest(PlayState* play, Player* this, Vec3f* offset, CollisionPoly** wallPoly, s32* bgId, + Vec3f* posResult) { + Vec3f posA; + Vec3f posB; - sp44.x = this->actor.world.pos.x; - sp44.y = this->actor.world.pos.y + arg2->y; - sp44.z = this->actor.world.pos.z; + posA.x = this->actor.world.pos.x; + posA.y = this->actor.world.pos.y + offset->y; + posA.z = this->actor.world.pos.z; - func_808395DC(this, &this->actor.world.pos, arg2, &sp38); + Player_GetRelativePosition(this, &this->actor.world.pos, offset, &posB); - return BgCheck_EntityLineTest1(&play->colCtx, &sp44, &sp38, arg5, arg3, true, false, false, true, arg4); + return BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, posResult, wallPoly, true, false, false, true, bgId); } s32 func_80839800(Player* this, PlayState* play) { @@ -4606,7 +4689,7 @@ s32 func_80839800(Player* this, PlayState* play) { if ((this->doorType != PLAYER_DOORTYPE_NONE) && (!(this->stateFlags1 & PLAYER_STATE1_11) || ((this->heldActor != NULL) && (this->heldActor->id == ACTOR_EN_RU1)))) { - if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) || (func_8084F9A0 == this->func_674)) { + if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) || (Player_Action_8084F9A0 == this->actionFunc)) { doorActor = this->doorActor; if (this->doorType <= PLAYER_DOORTYPE_AJAR) { @@ -4634,7 +4717,7 @@ s32 func_80839800(Player* this, PlayState* play) { func_80838E70(play, this, 50.0f, this->actor.shape.rot.y); - this->unk_84F = 0; + this->actionVar1 = 0; this->unk_447 = this->doorType; this->stateFlags1 |= PLAYER_STATE1_29; @@ -4647,8 +4730,8 @@ s32 func_80839800(Player* this, PlayState* play) { func_80832224(this); if (this->doorTimer != 0) { - this->unk_850 = 0; - func_80832B0C(play, this, func_80833338(this)); + this->actionVar2 = 0; + Player_AnimChangeOnceMorph(play, this, func_80833338(this)); this->skelAnime.endFrame = 0.0f; } else { this->speedXZ = 0.1f; @@ -4680,7 +4763,7 @@ s32 func_80839800(Player* this, PlayState* play) { sp5C = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_doorB, this->modelAnimType); } - func_80835C58(play, this, func_80845EF8, 0); + Player_SetupAction(play, this, Player_Action_80845EF8, 0); func_80832528(play, this); if (doorDirection < 0) { @@ -4702,9 +4785,9 @@ s32 func_80839800(Player* this, PlayState* play) { } func_80832224(this); - func_80832F54(play, this, - FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | - ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplaceApplyFlags(play, this, + ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); // If this door is the second half of a double door (spawned as child) if (doorActor->parent != NULL) { @@ -4728,7 +4811,7 @@ s32 func_80839800(Player* this, PlayState* play) { BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &checkPos); //! @bug groundPoly's bgId is not guaranteed to be BGCHECK_SCENE - if (func_80839034(play, this, groundPoly, BGCHECK_SCENE)) { + if (Player_HandleExitsAndVoids(play, this, groundPoly, BGCHECK_SCENE)) { gSaveContext.entranceSpeed = 2.0f; gSaveContext.entranceSound = NA_SE_OC_DOOR_OPEN; } @@ -4768,7 +4851,7 @@ s32 func_80839800(Player* this, PlayState* play) { void func_80839E88(Player* this, PlayState* play) { LinkAnimationHeader* anim; - func_80835C58(play, this, func_80840450, 1); + Player_SetupAction(play, this, Player_Action_80840450, 1); if (this->unk_870 < 0.5f) { anim = func_808334E4(this); @@ -4779,13 +4862,13 @@ void func_80839E88(Player* this, PlayState* play) { } this->unk_874 = this->unk_870; - func_80832284(play, this, anim); + Player_AnimPlayLoop(play, this, anim); this->yaw = this->actor.shape.rot.y; } void func_80839F30(Player* this, PlayState* play) { - func_80835C58(play, this, func_808407CC, 1); - func_80832B0C(play, this, func_80833338(this)); + Player_SetupAction(play, this, Player_Action_808407CC, 1); + Player_AnimChangeOnceMorph(play, this, func_80833338(this)); this->yaw = this->actor.shape.rot.y; } @@ -4800,23 +4883,23 @@ void func_80839F90(Player* this, PlayState* play) { } void func_80839FFC(Player* this, PlayState* play) { - PlayerFunc674 func; + PlayerActionFunc actionFunc; if (func_8008E9C4(this)) { - func = func_80840450; + actionFunc = Player_Action_80840450; } else if (func_80833B2C(this)) { - func = func_808407CC; + actionFunc = Player_Action_808407CC; } else { - func = func_80840BC8; + actionFunc = Player_Action_80840BC8; } - func_80835C58(play, this, func, 1); + Player_SetupAction(play, this, actionFunc, 1); } void func_8083A060(Player* this, PlayState* play) { func_80839FFC(this, play); if (func_8008E9C4(this)) { - this->unk_850 = 1; + this->actionVar2 = 1; } } @@ -4836,21 +4919,21 @@ void func_8083A0F4(PlayState* play, Player* this) { if (interactActorId == ACTOR_BG_TOKI_SWD) { this->interactRangeActor->parent = &this->actor; - func_80835C58(play, this, func_8084F608, 0); + Player_SetupAction(play, this, Player_Action_8084F608, 0); this->stateFlags1 |= PLAYER_STATE1_29; } else { LinkAnimationHeader* anim; if (interactActorId == ACTOR_BG_HEAVY_BLOCK) { - func_80835C58(play, this, func_80846120, 0); + Player_SetupAction(play, this, Player_Action_80846120, 0); this->stateFlags1 |= PLAYER_STATE1_29; anim = &gPlayerAnim_link_normal_heavy_carry; } else if ((interactActorId == ACTOR_EN_ISHI) && ((interactRangeActor->params & 0xF) == 1)) { - func_80835C58(play, this, func_80846260, 0); + Player_SetupAction(play, this, Player_Action_80846260, 0); anim = &gPlayerAnim_link_silver_carry; } else if (((interactActorId == ACTOR_EN_BOMBF) || (interactActorId == ACTOR_EN_KUSA)) && (Player_GetStrength() <= PLAYER_STR_NONE)) { - func_80835C58(play, this, func_80846408, 0); + Player_SetupAction(play, this, Player_Action_80846408, 0); this->actor.world.pos.x = (Math_SinS(interactRangeActor->yawTowardsPlayer) * 20.0f) + interactRangeActor->world.pos.x; this->actor.world.pos.z = @@ -4858,11 +4941,11 @@ void func_8083A0F4(PlayState* play, Player* this) { this->yaw = this->actor.shape.rot.y = interactRangeActor->yawTowardsPlayer + 0x8000; anim = &gPlayerAnim_link_normal_nocarry_free; } else { - func_80835C58(play, this, func_80846050, 0); + Player_SetupAction(play, this, Player_Action_80846050, 0); anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_carryB, this->modelAnimType); } - func_80832264(play, this, anim); + Player_AnimPlayOnce(play, this, anim); } } else { func_80839F90(this, play); @@ -4871,7 +4954,7 @@ void func_8083A0F4(PlayState* play, Player* this) { } void func_8083A2F8(PlayState* play, Player* this) { - func_80835DAC(play, this, func_8084B530, 0); + func_80835DAC(play, this, Player_Action_8084B530, 0); this->stateFlags1 |= PLAYER_STATE1_6 | PLAYER_STATE1_29; @@ -4882,37 +4965,37 @@ void func_8083A2F8(PlayState* play, Player* this) { } void func_8083A360(PlayState* play, Player* this) { - func_80835DAC(play, this, func_8084CC98, 0); + func_80835DAC(play, this, Player_Action_8084CC98, 0); } void func_8083A388(PlayState* play, Player* this) { - func_80835C58(play, this, func_8084B78C, 0); + Player_SetupAction(play, this, Player_Action_8084B78C, 0); } void func_8083A3B0(PlayState* play, Player* this) { - s32 sp1C = this->unk_850; - s32 sp18 = this->unk_84F; + s32 sp1C = this->actionVar2; + s32 sp18 = this->actionVar1; - func_80835DAC(play, this, func_8084BF1C, 0); + func_80835DAC(play, this, Player_Action_8084BF1C, 0); this->actor.velocity.y = 0.0f; - this->unk_850 = sp1C; - this->unk_84F = sp18; + this->actionVar2 = sp1C; + this->actionVar1 = sp18; } void func_8083A40C(PlayState* play, Player* this) { - func_80835DAC(play, this, func_8084C760, 0); + func_80835DAC(play, this, Player_Action_8084C760, 0); } void func_8083A434(PlayState* play, Player* this) { - func_80835DAC(play, this, func_8084E6D4, 0); + func_80835DAC(play, this, Player_Action_8084E6D4, 0); this->stateFlags1 |= PLAYER_STATE1_10 | PLAYER_STATE1_29; if (this->getItemId == GI_HEART_CONTAINER_2) { - this->unk_850 = 20; + this->actionVar2 = 20; } else if (this->getItemId >= 0) { - this->unk_850 = 1; + this->actionVar2 = 1; } else { this->getItemId = -this->getItemId; } @@ -4938,25 +5021,25 @@ s32 func_8083A4A8(Player* this, PlayState* play) { } func_80838940(this, anim, temp, play, NA_SE_VO_LI_AUTO_JUMP); - this->unk_850 = 1; + this->actionVar2 = 1; return 1; } -void func_8083A5C4(PlayState* play, Player* this, CollisionPoly* arg2, f32 arg3, LinkAnimationHeader* arg4) { +void func_8083A5C4(PlayState* play, Player* this, CollisionPoly* arg2, f32 arg3, LinkAnimationHeader* anim) { f32 nx = COLPOLY_GET_NORMAL(arg2->normal.x); f32 nz = COLPOLY_GET_NORMAL(arg2->normal.z); - func_80835C58(play, this, func_8084BBE4, 0); + Player_SetupAction(play, this, Player_Action_8084BBE4, 0); func_80832564(play, this); - func_80832264(play, this, arg4); + Player_AnimPlayOnce(play, this, anim); this->actor.world.pos.x -= (arg3 + 1.0f) * nx; this->actor.world.pos.z -= (arg3 + 1.0f) * nz; this->actor.shape.rot.y = this->yaw = Math_Atan2S(nz, nx); func_80832224(this); - func_80832CFC(this); + Player_SkelAnimeResetPrevTranslRot(this); } s32 func_8083A6AC(Player* this, PlayState* play) { @@ -4966,7 +5049,10 @@ s32 func_8083A6AC(Player* this, PlayState* play) { Vec3f sp68; f32 temp1; - if ((this->actor.yDistToWater < -80.0f) && (ABS(this->unk_898) < 2730) && (ABS(this->unk_89A) < 2730)) { + //! @bug `floorPitch` and `floorPitchAlt` are cleared to 0 before this function is called, because the player + //! left the ground. The angles will always be zero and therefore will always pass these checks. + //! The intention seems to be to prevent ledge hanging or vine grabbing when walking off of a steep enough slope. + if ((this->actor.yDistToWater < -80.0f) && (ABS(this->floorPitch) < 0xAAA) && (ABS(this->floorPitchAlt) < 0xAAA)) { sp74.x = this->actor.prevPos.x - this->actor.world.pos.x; sp74.z = this->actor.prevPos.z - this->actor.world.pos.z; @@ -4992,7 +5078,7 @@ s32 func_8083A6AC(Player* this, PlayState* play) { sp54 = Math3D_UDistPlaneToPos(nx, ny, nz, sp84->dist, &this->actor.world.pos); - sp50 = D_80853604 == FLOOR_PROPERTY_6; + sp50 = (sPrevFloorProperty == FLOOR_PROPERTY_6); if (!sp50 && (SurfaceType_GetWallFlags(&play->colCtx, sp84, sp80) & WALL_FLAG_3)) { sp50 = 1; } @@ -5007,12 +5093,12 @@ s32 func_8083A6AC(Player* this, PlayState* play) { this->actor.shape.rot.y = this->yaw; this->stateFlags1 |= PLAYER_STATE1_21; - func_80832F54(play, this, - ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | - ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplaceApplyFlags(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); - this->unk_850 = -1; - this->unk_84F = sp50; + this->actionVar2 = -1; + this->actionVar1 = sp50; } else { this->stateFlags1 |= PLAYER_STATE1_13; this->stateFlags1 &= ~PLAYER_STATE1_17; @@ -5028,7 +5114,7 @@ s32 func_8083A6AC(Player* this, PlayState* play) { } void func_8083A9B8(Player* this, LinkAnimationHeader* anim, PlayState* play) { - func_80835C58(play, this, func_8084BDFC, 0); + Player_SetupAction(play, this, Player_Action_8084BDFC, 0); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 1.3f); } @@ -5048,16 +5134,16 @@ void func_8083AA10(Player* this, PlayState* play) { if (!(this->stateFlags1 & (PLAYER_STATE1_27 | PLAYER_STATE1_29)) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (!func_80838FB8(play, this)) { - if (D_80853604 == FLOOR_PROPERTY_8) { + if (sPrevFloorProperty == FLOOR_PROPERTY_8) { this->actor.world.pos.x = this->actor.prevPos.x; this->actor.world.pos.z = this->actor.prevPos.z; return; } if (!(this->stateFlags3 & PLAYER_STATE3_1) && !(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_7) && - (func_8084411C != this->func_674) && (func_80844A44 != this->func_674)) { + (Player_Action_8084411C != this->actionFunc) && (Player_Action_80844A44 != this->actionFunc)) { - if ((D_80853604 == FLOOR_PROPERTY_7) || (this->meleeWeaponState != 0)) { + if ((sPrevFloorProperty == FLOOR_PROPERTY_7) || (this->meleeWeaponState != 0)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); Player_ZeroSpeedXZ(this); return; @@ -5065,22 +5151,23 @@ void func_8083AA10(Player* this, PlayState* play) { if (this->hoverBootsTimer != 0) { this->actor.velocity.y = 1.0f; - D_80853604 = FLOOR_PROPERTY_9; + sPrevFloorProperty = FLOOR_PROPERTY_9; return; } sp5C = (s16)(this->yaw - this->actor.shape.rot.y); - func_80835C58(play, this, func_8084411C, 1); + Player_SetupAction(play, this, Player_Action_8084411C, 1); func_80832440(play, this); this->floorSfxOffset = this->prevFloorSfxOffset; if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_LEAVE) && !(this->stateFlags1 & PLAYER_STATE1_27) && - (D_80853604 != FLOOR_PROPERTY_6) && (D_80853604 != FLOOR_PROPERTY_9) && (D_80853600 > 20.0f) && - (this->meleeWeaponState == 0) && (ABS(sp5C) < 0x2000) && (this->speedXZ > 3.0f)) { + (sPrevFloorProperty != FLOOR_PROPERTY_6) && (sPrevFloorProperty != FLOOR_PROPERTY_9) && + (sYDistToFloor > 20.0f) && (this->meleeWeaponState == 0) && (ABS(sp5C) < 0x2000) && + (this->speedXZ > 3.0f)) { - if ((D_80853604 == FLOOR_PROPERTY_11) && !(this->stateFlags1 & PLAYER_STATE1_11)) { + if ((sPrevFloorProperty == FLOOR_PROPERTY_11) && !(this->stateFlags1 & PLAYER_STATE1_11)) { sp40 = func_808396F4(play, this, &D_8085451C, &sp44, &sp58, &sp54); sp3C = this->actor.world.pos.y; @@ -5088,7 +5175,7 @@ void func_8083AA10(Player* this, PlayState* play) { if (WaterBox_GetSurface1(play, &play->colCtx, sp44.x, sp44.z, &sp3C, &sp50) && ((sp3C - sp40) > 50.0f)) { func_808389E8(this, &gPlayerAnim_link_normal_run_jump_water_fall, 6.0f, play); - func_80835C58(play, this, func_80844A44, 0); + Player_SetupAction(play, this, Player_Action_80844A44, 0); return; } } @@ -5096,10 +5183,9 @@ void func_8083AA10(Player* this, PlayState* play) { func_8083A4A8(this, play); return; } - - if ((D_80853604 == FLOOR_PROPERTY_9) || (D_80853600 <= this->ageProperties->unk_34) || + if ((sPrevFloorProperty == FLOOR_PROPERTY_9) || (sYDistToFloor <= this->ageProperties->unk_34) || !func_8083A6AC(this, play)) { - func_80832284(play, this, &gPlayerAnim_link_normal_landing_wait); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_normal_landing_wait); return; } } @@ -5131,7 +5217,7 @@ s32 func_8083AD4C(PlayState* play, Player* this) { s32 func_8083ADD4(PlayState* play, Player* this) { if (this->unk_6AD == 3) { - func_80835C58(play, this, func_80852E14, 0); + Player_SetupAction(play, this, Player_Action_80852E14, 0); if (this->doorBgCamIndex != 0) { this->stateFlags1 |= PLAYER_STATE1_29; } @@ -5160,9 +5246,17 @@ void func_8083AE40(Player* this, s16 objectId) { } void func_8083AF44(PlayState* play, Player* this, s32 magicSpell) { - func_80835DE4(play, this, func_808507F4, 0); + func_80835DE4(play, this, Player_Action_808507F4, 0); - this->unk_84F = magicSpell - 3; + this->actionVar1 = magicSpell - 3; + + //! @bug `MAGIC_CONSUME_WAIT_PREVIEW` is not guaranteed to succeed. + //! Ideally, the return value of `Magic_RequestChange` should be checked before allowing the process of + //! using a spell to continue. If the magic state change request fails, `gSaveContext.magicTarget` will + //! never be set correctly. + //! When `MAGIC_STATE_CONSUME_SETUP` is set in `Player_Action_808507F4`, magic will eventually be + //! consumed to a stale target value. If that stale target value is higher than the current + //! magic value, it will be consumed to zero. Magic_RequestChange(play, sMagicSpellCosts[magicSpell], MAGIC_CONSUME_WAIT_PREVIEW); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, &gPlayerAnim_link_magic_tame, 0.83f); @@ -5235,9 +5329,9 @@ s32 func_8083B040(Player* this, PlayState* play) { if ((sp2C != 3) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { func_8083AF44(play, this, sp2C); } else { - func_80835C58(play, this, func_8085063C, 1); + Player_SetupAction(play, this, Player_Action_8085063C, 1); this->stateFlags1 |= PLAYER_STATE1_28 | PLAYER_STATE1_29; - func_80832264(play, this, func_80833338(this)); + Player_AnimPlayOnce(play, this, func_80833338(this)); func_80835EA4(play, 4); } @@ -5255,7 +5349,7 @@ s32 func_8083B040(Player* this, PlayState* play) { (this->exchangeItemId == EXCH_ITEM_BOTTLE_BLUE_FIRE))))))) { if ((play->actorCtx.titleCtx.delayTimer == 0) && (play->actorCtx.titleCtx.alpha == 0)) { - func_80835DE4(play, this, func_8084F104, 0); + func_80835DE4(play, this, Player_Action_8084F104, 0); if (sp2C >= 0) { giEntry = &sGetItemTable[D_80854528[sp2C] - 1]; @@ -5282,19 +5376,19 @@ s32 func_8083B040(Player* this, PlayState* play) { (this->itemAction == PLAYER_IA_MAGIC_BEAN))) { if (this->exchangeItemId == EXCH_ITEM_MAGIC_BEAN) { Inventory_ChangeAmmo(ITEM_MAGIC_BEAN, -1); - func_80835DE4(play, this, func_8084279C, 0); + func_80835DE4(play, this, Player_Action_8084279C, 0); this->stateFlags1 |= PLAYER_STATE1_29; - this->unk_850 = 0x50; - this->unk_84F = -1; + this->actionVar2 = 0x50; + this->actionVar1 = -1; } targetActor->flags |= ACTOR_FLAG_8; this->unk_664 = this->targetActor; } else if (sp2C == EXCH_ITEM_BOTTLE_RUTOS_LETTER) { - this->unk_84F = 1; + this->actionVar1 = 1; this->actor.textId = 0x4005; func_80835EA4(play, 1); } else { - this->unk_84F = 2; + this->actionVar1 = 2; this->actor.textId = 0xCF; func_80835EA4(play, 4); } @@ -5302,10 +5396,11 @@ s32 func_8083B040(Player* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_8; this->exchangeItemId = sp2C; - if (this->unk_84F < 0) { - func_80832B0C(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_check, this->modelAnimType)); + if (this->actionVar1 < 0) { + Player_AnimChangeOnceMorph(play, this, + GET_PLAYER_ANIM(PLAYER_ANIMGROUP_check, this->modelAnimType)); } else { - func_80832264(play, this, D_80854548[this->unk_84F]); + Player_AnimPlayOnce(play, this, D_80854548[this->actionVar1]); } func_80832224(this); @@ -5316,21 +5411,21 @@ s32 func_8083B040(Player* this, PlayState* play) { sp2C = Player_ActionToBottle(this, this->itemAction); if (sp2C >= 0) { if (sp2C == 0xC) { - func_80835DE4(play, this, func_8084EED8, 0); - func_808322D0(play, this, &gPlayerAnim_link_bottle_bug_out); + func_80835DE4(play, this, Player_Action_8084EED8, 0); + Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_bottle_bug_out); func_80835EA4(play, 3); } else if ((sp2C > 0) && (sp2C < 4)) { - func_80835DE4(play, this, func_8084EFC0, 0); - func_808322D0(play, this, &gPlayerAnim_link_bottle_fish_out); + func_80835DE4(play, this, Player_Action_8084EFC0, 0); + Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_bottle_fish_out); func_80835EA4(play, (sp2C == 1) ? 1 : 5); } else { - func_80835DE4(play, this, func_8084EAC0, 0); - func_80832B78(play, this, &gPlayerAnim_link_bottle_drink_demo_start); + func_80835DE4(play, this, Player_Action_8084EAC0, 0); + Player_AnimChangeOnceMorphAdjusted(play, this, &gPlayerAnim_link_bottle_drink_demo_start); func_80835EA4(play, 2); } } else { - func_80835DE4(play, this, func_8084E3C4, 0); - func_808322D0(play, this, &gPlayerAnim_link_normal_okarina_start); + func_80835DE4(play, this, Player_Action_8084E3C4, 0); + Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_normal_okarina_start); this->stateFlags2 |= PLAYER_STATE2_27; func_80835EA4(play, (this->unk_6A8 != NULL) ? 0x5B : 0x5A); if (this->unk_6A8 != NULL) { @@ -5340,8 +5435,8 @@ s32 func_8083B040(Player* this, PlayState* play) { } } else if (func_8083AD4C(play, this)) { if (!(this->stateFlags1 & PLAYER_STATE1_23)) { - func_80835C58(play, this, func_8084B1D8, 1); - this->unk_850 = 13; + Player_SetupAction(play, this, Player_Action_8084B1D8, 1); + this->actionVar2 = 13; func_8083B010(this); } this->stateFlags1 |= PLAYER_STATE1_20; @@ -5469,7 +5564,7 @@ s32 func_8083B998(Player* this, PlayState* play) { void func_8083BA90(PlayState* play, Player* this, s32 arg2, f32 xzSpeed, f32 yVelocity) { func_80837948(play, this, arg2); - func_80835C58(play, this, func_80844AF4, 0); + Player_SetupAction(play, this, Player_Action_80844AF4, 0); this->stateFlags3 |= PLAYER_STATE3_1; @@ -5486,7 +5581,7 @@ void func_8083BA90(PlayState* play, Player* this, s32 arg2, f32 xzSpeed, f32 yVe s32 func_8083BB20(Player* this) { if (!(this->stateFlags1 & PLAYER_STATE1_22) && (Player_GetMeleeWeaponHeld(this) != 0)) { - if (D_80853614 || + if (sUseHeldItem || ((this->actor.category != ACTORCAT_PLAYER) && CHECK_BTN_ALL(sControlInput->press.button, BTN_B))) { return 1; } @@ -5496,7 +5591,7 @@ s32 func_8083BB20(Player* this) { } s32 func_8083BBA0(Player* this, PlayState* play) { - if (func_8083BB20(this) && (D_808535E4 != FLOOR_TYPE_7)) { + if (func_8083BB20(this) && (sFloorType != FLOOR_TYPE_7)) { func_8083BA90(play, this, PLAYER_MWA_JUMPSLASH_START, 3.0f, 4.5f); return 1; } @@ -5505,14 +5600,14 @@ s32 func_8083BBA0(Player* this, PlayState* play) { } void func_8083BC04(Player* this, PlayState* play) { - func_80835C58(play, this, func_80844708, 0); + Player_SetupAction(play, this, Player_Action_80844708, 0); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_landing_roll, this->modelAnimType), 1.25f * D_808535E8); } s32 func_8083BC7C(Player* this, PlayState* play) { - if ((this->unk_84B[this->unk_846] == 0) && (D_808535E4 != FLOOR_TYPE_7)) { + if ((this->unk_84B[this->unk_846] == 0) && (sFloorType != FLOOR_TYPE_7)) { func_8083BC04(this, play); return 1; } @@ -5525,8 +5620,8 @@ void func_8083BCD0(Player* this, PlayState* play, s32 arg2) { if (arg2) {} - this->unk_850 = 1; - this->unk_84F = arg2; + this->actionVar2 = 1; + this->actionVar1 = arg2; this->yaw = this->actor.shape.rot.y + (arg2 << 0xE); this->speedXZ = !(arg2 & 1) ? 6.0f : 8.5f; @@ -5540,7 +5635,7 @@ s32 func_8083BDBC(Player* this, PlayState* play) { s32 sp2C; if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && - (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (D_808535E4 != FLOOR_TYPE_7) && + (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (sFloorType != FLOOR_TYPE_7) && (SurfaceType_GetFloorEffect(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) != FLOOR_EFFECT_1)) { sp2C = this->unk_84B[this->unk_846]; @@ -5553,7 +5648,7 @@ s32 func_8083BDBC(Player* this, PlayState* play) { func_8083BC04(this, play); } } else { - if ((Player_GetMeleeWeaponHeld(this) != 0) && func_808365C8(this)) { + if ((Player_GetMeleeWeaponHeld(this) != 0) && Player_CanUpdateItems(this)) { func_8083BA90(play, this, PLAYER_MWA_JUMPSLASH_START, 5.0f, 5.0f); } else { func_8083BC04(this, play); @@ -5606,8 +5701,8 @@ void func_8083C0B8(Player* this, PlayState* play) { } void func_8083C0E8(Player* this, PlayState* play) { - func_80835C58(play, this, func_80840BC8, 1); - func_80832264(play, this, func_80833338(this)); + Player_SetupAction(play, this, Player_Action_80840BC8, 1); + Player_AnimPlayOnce(play, this, func_80833338(this)); this->yaw = this->actor.shape.rot.y; } @@ -5634,7 +5729,7 @@ s32 func_8083C1DC(Player* this, PlayState* play) { return 1; } if ((this->unk_837 == 0) && (this->heldItemAction >= PLAYER_IA_SWORD_MASTER)) { - func_80835F44(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); } else { this->stateFlags2 ^= PLAYER_STATE2_20; } @@ -5652,9 +5747,9 @@ s32 func_8083C2B0(Player* this, PlayState* play) { (Player_IsChildWithHylianShield(this) || (!func_80833B2C(this) && (this->unk_664 == NULL)))) { func_80832318(this); - func_808323B4(play, this); + Player_DetachHeldActor(play, this); - if (func_80835C58(play, this, func_80843188, 0)) { + if (Player_SetupAction(play, this, Player_Action_80843188, 0)) { this->stateFlags1 |= PLAYER_STATE1_22; if (!Player_IsChildWithHylianShield(this)) { @@ -5678,7 +5773,7 @@ s32 func_8083C2B0(Player* this, PlayState* play) { LinkAnimation_Change(play, &this->skelAnime, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); if (Player_IsChildWithHylianShield(this)) { - func_80832F54(play, this, ANIM_FLAG_PLAYER_2); + Player_AnimReplaceApplyFlags(play, this, ANIM_FLAG_PLAYER_2); } Player_PlaySfx(this, NA_SE_IT_SHIELD_POSTURE); @@ -5731,8 +5826,8 @@ s32 func_8083C544(Player* this, PlayState* play) { s32 func_8083C61C(PlayState* play, Player* this) { if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (AMMO(ITEM_DEKU_NUT) != 0)) { - func_80835C58(play, this, func_8084E604, 0); - func_80832264(play, this, &gPlayerAnim_link_normal_light_bom); + Player_SetupAction(play, this, Player_Action_8084E604, 0); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_light_bom); this->unk_6AD = 0; return 1; } @@ -5748,15 +5843,15 @@ static struct_80854554 D_80854554[] = { s32 func_8083C6B8(PlayState* play, Player* this) { Vec3f sp24; - if (D_80853614) { + if (sUseHeldItem) { if (Player_GetBottleHeld(this) >= 0) { - func_80835C58(play, this, func_8084ECA4, 0); + Player_SetupAction(play, this, Player_Action_8084ECA4, 0); if (this->actor.yDistToWater > 12.0f) { - this->unk_850 = 1; + this->actionVar2 = 1; } - func_808322D0(play, this, D_80854554[this->unk_850].unk_00); + Player_AnimPlayOnceAdjusted(play, this, D_80854554[this->actionVar2].unk_00); Player_PlaySfx(this, NA_SE_IT_SWORD_SWING); func_80832698(this, NA_SE_VO_LI_AUTO_JUMP); @@ -5773,10 +5868,10 @@ s32 func_8083C6B8(PlayState* play, Player* this) { return 0; } - func_80835C58(play, this, func_80850C68, 0); + Player_SetupAction(play, this, Player_Action_80850C68, 0); this->unk_860 = 1; Player_ZeroSpeedXZ(this); - func_80832264(play, this, &gPlayerAnim_link_fishing_throw); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_fishing_throw); return 1; } else { return 0; @@ -5787,16 +5882,16 @@ s32 func_8083C6B8(PlayState* play, Player* this) { } void func_8083C858(Player* this, PlayState* play) { - PlayerFunc674 func; + PlayerActionFunc actionFunc; if (func_80833BCC(this)) { - func = func_8084227C; + actionFunc = Player_Action_8084227C; } else { - func = func_80842180; + actionFunc = Player_Action_80842180; } - func_80835C58(play, this, func, 1); - func_80832BE8(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_run, this->modelAnimType)); + Player_SetupAction(play, this, actionFunc, 1); + Player_AnimChangeLoopMorph(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_run, this->modelAnimType)); this->unk_89C = 0; this->unk_864 = this->unk_868 = 0.0f; @@ -5816,10 +5911,10 @@ s32 func_8083C910(PlayState* play, Player* this, f32 arg2) { 0) { sp28 -= this->actor.world.pos.y; if (this->ageProperties->unk_24 <= sp28) { - func_80835C58(play, this, func_8084D7C4, 0); - func_80832C6C(play, this, &gPlayerAnim_link_swimer_swim); + Player_SetupAction(play, this, Player_Action_8084D7C4, 0); + Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim); this->stateFlags1 |= PLAYER_STATE1_27 | PLAYER_STATE1_29; - this->unk_850 = 20; + this->actionVar2 = 20; this->speedXZ = 2.0f; Player_SetBootData(play, this); return 0; @@ -5833,7 +5928,7 @@ s32 func_8083C910(PlayState* play, Player* this, f32 arg2) { void func_8083CA20(PlayState* play, Player* this) { if (func_8083C910(play, this, 180.0f)) { - this->unk_850 = -20; + this->actionVar2 = -20; } } @@ -5841,7 +5936,7 @@ void func_8083CA54(PlayState* play, Player* this) { this->speedXZ = 2.0f; gSaveContext.entranceSpeed = 2.0f; if (func_8083C910(play, this, 120.0f)) { - this->unk_850 = -15; + this->actionVar2 = -15; } } @@ -5853,27 +5948,27 @@ void func_8083CA9C(PlayState* play, Player* this) { this->speedXZ = gSaveContext.entranceSpeed; if (func_8083C910(play, this, 800.0f)) { - this->unk_850 = -80 / this->speedXZ; - if (this->unk_850 < -20) { - this->unk_850 = -20; + this->actionVar2 = -80 / this->speedXZ; + if (this->actionVar2 < -20) { + this->actionVar2 = -20; } } } void func_8083CB2C(Player* this, s16 yaw, PlayState* play) { - func_80835C58(play, this, func_808414F8, 1); + Player_SetupAction(play, this, Player_Action_808414F8, 1); LinkAnimation_CopyJointToMorph(play, &this->skelAnime); this->unk_864 = this->unk_868 = 0.0f; this->yaw = yaw; } void func_8083CB94(Player* this, PlayState* play) { - func_80835C58(play, this, func_80840DE4, 1); - func_80832BE8(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_walk, this->modelAnimType)); + Player_SetupAction(play, this, Player_Action_80840DE4, 1); + Player_AnimChangeLoopMorph(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_walk, this->modelAnimType)); } void func_8083CBF0(Player* this, s16 yaw, PlayState* play) { - func_80835C58(play, this, func_808423EC, 1); + Player_SetupAction(play, this, Player_Action_808423EC, 1); LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_anchor_back_walk, 2.2f, 0.0f, Animation_GetLastFrame(&gPlayerAnim_link_anchor_back_walk), ANIMMODE_ONCE, -6.0f); this->speedXZ = 8.0f; @@ -5881,19 +5976,19 @@ void func_8083CBF0(Player* this, s16 yaw, PlayState* play) { } void func_8083CC9C(Player* this, PlayState* play) { - func_80835C58(play, this, func_8084193C, 1); - func_80832BE8(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_side_walkR, this->modelAnimType)); + Player_SetupAction(play, this, Player_Action_8084193C, 1); + Player_AnimChangeLoopMorph(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_side_walkR, this->modelAnimType)); this->unk_868 = 0.0f; } void func_8083CD00(Player* this, PlayState* play) { - func_80835C58(play, this, func_8084251C, 1); + Player_SetupAction(play, this, Player_Action_8084251C, 1); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, &gPlayerAnim_link_anchor_back_brake, 2.0f); } void func_8083CD54(PlayState* play, Player* this, s16 yaw) { this->yaw = yaw; - func_80835C58(play, this, func_80841BA8, 1); + Player_SetupAction(play, this, Player_Action_80841BA8, 1); this->unk_87E = 1200; this->unk_87E *= D_808535E8; LinkAnimation_Change(play, &this->skelAnime, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_45_turn, this->modelAnimType), 1.0f, @@ -5903,22 +5998,22 @@ void func_8083CD54(PlayState* play, Player* this, s16 yaw) { void func_8083CE0C(Player* this, PlayState* play) { LinkAnimationHeader* anim; - func_80835C58(play, this, func_80840BC8, 1); + Player_SetupAction(play, this, Player_Action_80840BC8, 1); if (this->unk_870 < 0.5f) { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_waitR2wait, this->modelAnimType); } else { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_waitL2wait, this->modelAnimType); } - func_80832264(play, this, anim); + Player_AnimPlayOnce(play, this, anim); this->yaw = this->actor.shape.rot.y; } void func_8083CEAC(Player* this, PlayState* play) { - func_80835C58(play, this, func_80840450, 1); - func_80832B0C(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait2waitR, this->modelAnimType)); - this->unk_850 = 1; + Player_SetupAction(play, this, Player_Action_80840450, 1); + Player_AnimChangeOnceMorph(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait2waitR, this->modelAnimType)); + this->actionVar2 = 1; } void func_8083CF10(Player* this, PlayState* play) { @@ -5978,8 +6073,8 @@ s32 func_8083D12C(PlayState* play, Player* this, Input* arg2) { if ((arg2 == NULL) || (CHECK_BTN_ALL(arg2->press.button, BTN_A) && (ABS(this->unk_6C2) < 12000) && (this->currentBoots != PLAYER_BOOTS_IRON))) { - func_80835C58(play, this, func_8084DC48, 0); - func_80832264(play, this, &gPlayerAnim_link_swimer_swim_deep_start); + Player_SetupAction(play, this, Player_Action_8084DC48, 0); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_swimer_swim_deep_start); this->unk_6C2 = 0; this->stateFlags2 |= PLAYER_STATE2_10; @@ -6001,19 +6096,20 @@ s32 func_8083D12C(PlayState* play, Player* this, Input* arg2) { this->stateFlags2 &= ~PLAYER_STATE2_10; if (arg2 != NULL) { - func_80835C58(play, this, func_8084E1EC, 1); + Player_SetupAction(play, this, Player_Action_8084E1EC, 1); if (this->stateFlags1 & PLAYER_STATE1_10) { this->stateFlags1 |= PLAYER_STATE1_10 | PLAYER_STATE1_11 | PLAYER_STATE1_29; } - this->unk_850 = 2; + this->actionVar2 = 2; } func_80832340(play, this); - func_80832B0C(play, this, - (this->stateFlags1 & PLAYER_STATE1_11) ? &gPlayerAnim_link_swimer_swim_get - : &gPlayerAnim_link_swimer_swim_deep_end); + Player_AnimChangeOnceMorph(play, this, + (this->stateFlags1 & PLAYER_STATE1_11) + ? &gPlayerAnim_link_swimer_swim_get + : &gPlayerAnim_link_swimer_swim_deep_end); if (func_8083CFA8(play, this, this->actor.velocity.y, 500)) { Player_PlaySfx(this, NA_SE_PL_FACE_UP); @@ -6028,9 +6124,9 @@ s32 func_8083D12C(PlayState* play, Player* this, Input* arg2) { } void func_8083D330(PlayState* play, Player* this) { - func_80832284(play, this, &gPlayerAnim_link_swimer_swim); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_swimer_swim); this->unk_6C2 = 16000; - this->unk_850 = 1; + this->actionVar2 = 1; } void func_8083D36C(PlayState* play, Player* this) { @@ -6040,15 +6136,16 @@ void func_8083D36C(PlayState* play, Player* this) { if ((this->currentBoots != PLAYER_BOOTS_IRON) && (this->stateFlags2 & PLAYER_STATE2_10)) { this->stateFlags2 &= ~PLAYER_STATE2_10; func_8083D12C(play, this, NULL); - this->unk_84F = 1; - } else if (func_80844A44 == this->func_674) { - func_80835C58(play, this, func_8084DC48, 0); + this->actionVar1 = 1; + } else if (Player_Action_80844A44 == this->actionFunc) { + Player_SetupAction(play, this, Player_Action_8084DC48, 0); func_8083D330(play, this); } else { - func_80835C58(play, this, func_8084D610, 1); - func_80832B0C(play, this, - (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) ? &gPlayerAnim_link_swimer_wait2swim_wait - : &gPlayerAnim_link_swimer_land2swim_wait); + Player_SetupAction(play, this, Player_Action_8084D610, 1); + Player_AnimChangeOnceMorph(play, this, + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) + ? &gPlayerAnim_link_swimer_wait2swim_wait + : &gPlayerAnim_link_swimer_land2swim_wait); } } @@ -6081,14 +6178,14 @@ void func_8083D53C(PlayState* play, Player* this) { } } - if ((func_80845668 != this->func_674) && (func_8084BDFC != this->func_674)) { + if ((Player_Action_80845668 != this->actionFunc) && (Player_Action_8084BDFC != this->actionFunc)) { if (this->ageProperties->unk_2C < this->actor.yDistToWater) { if (!(this->stateFlags1 & PLAYER_STATE1_27) || (!((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) && - (func_8084E30C != this->func_674) && (func_8084E368 != this->func_674) && - (func_8084D610 != this->func_674) && (func_8084D84C != this->func_674) && - (func_8084DAB4 != this->func_674) && (func_8084DC48 != this->func_674) && - (func_8084E1EC != this->func_674) && (func_8084D7C4 != this->func_674))) { + (Player_Action_8084E30C != this->actionFunc) && (Player_Action_8084E368 != this->actionFunc) && + (Player_Action_8084D610 != this->actionFunc) && (Player_Action_8084D84C != this->actionFunc) && + (Player_Action_8084DAB4 != this->actionFunc) && (Player_Action_8084DC48 != this->actionFunc) && + (Player_Action_8084E1EC != this->actionFunc) && (Player_Action_8084D7C4 != this->actionFunc))) { func_8083D36C(play, this); return; } @@ -6111,11 +6208,11 @@ void func_8083D6EC(PlayState* play, Player* this) { this->actor.minVelocityY = -20.0f; this->actor.gravity = REG(68) / 100.0f; - if (func_8083816C(D_808535E4)) { + if (func_8083816C(sFloorType)) { temp1 = fabsf(this->speedXZ) * 20.0f; temp3 = 0.0f; - if (D_808535E4 == FLOOR_TYPE_4) { + if (sFloorType == FLOOR_TYPE_4) { if (this->unk_6C4 > 1300.0f) { temp2 = this->unk_6C4; } else { @@ -6130,7 +6227,7 @@ void func_8083D6EC(PlayState* play, Player* this) { temp2 = 20000.0f; if (this->currentBoots != PLAYER_BOOTS_HOVER) { temp1 += temp1; - } else if ((D_808535E4 == FLOOR_TYPE_7) || (this->currentBoots == PLAYER_BOOTS_IRON)) { + } else if ((sFloorType == FLOOR_TYPE_7) || (this->currentBoots == PLAYER_BOOTS_IRON)) { temp1 = 0; } } @@ -6232,7 +6329,7 @@ void func_8083DC54(Player* this, PlayState* play) { return; } - if (D_808535E4 == FLOOR_TYPE_11) { + if (sFloorType == FLOOR_TYPE_11) { Math_SmoothStepToS(&this->actor.focus.rot.x, -20000, 10, 4000, 800); } else { sp46 = 0; @@ -6328,10 +6425,10 @@ s32 func_8083E0FC(Player* this, PlayState* play) { this->yaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y; Actor_MountHorse(play, this, &rideActor->actor); - func_80832264(play, this, D_80854578[temp].anim); - func_80832F54(play, this, - ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | - ANIM_FLAG_PLAYER_7); + Player_AnimPlayOnce(play, this, D_80854578[temp].anim); + Player_AnimReplaceApplyFlags(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); this->actor.parent = this->rideActor; func_80832224(this); Actor_DisableLens(play); @@ -6349,12 +6446,11 @@ void Player_GetSlopeDirection(CollisionPoly* floorPoly, Vec3f* slopeNormal, s16* *downwardSlopeYaw = Math_Atan2S(slopeNormal->z, slopeNormal->x); } -static LinkAnimationHeader* D_80854590[] = { - &gPlayerAnim_link_normal_down_slope_slip, - &gPlayerAnim_link_normal_up_slope_slip, -}; - -s32 func_8083E318(PlayState* play, Player* this, CollisionPoly* floorPoly) { +s32 Player_HandleSlopes(PlayState* play, Player* this, CollisionPoly* floorPoly) { + static LinkAnimationHeader* sSlopeSlipAnims[] = { + &gPlayerAnim_link_normal_down_slope_slip, + &gPlayerAnim_link_normal_up_slope_slip, + }; s32 pad; s16 playerVelYaw; Vec3f slopeNormal; @@ -6363,9 +6459,8 @@ s32 func_8083E318(PlayState* play, Player* this, CollisionPoly* floorPoly) { f32 slopeSlowdownSpeedStep; s16 velYawToDownwardSlope; - if (!Player_InBlockingCsMode(play, this) && (func_8084F390 != this->func_674) && + if (!Player_InBlockingCsMode(play, this) && (Player_Action_8084F390 != this->actionFunc) && (SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) == FLOOR_EFFECT_1)) { - // Get direction of movement relative to the downward direction of the slope playerVelYaw = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); Player_GetSlopeDirection(floorPoly, &slopeNormal, &downwardSlopeYaw); @@ -6375,6 +6470,7 @@ s32 func_8083E318(PlayState* play, Player* this, CollisionPoly* floorPoly) { // moving parallel or upwards on the slope, player does not slip but does slow down slopeSlowdownSpeed = (1.0f - slopeNormal.y) * 40.0f; slopeSlowdownSpeedStep = SQ(slopeSlowdownSpeed) * 0.015f; + if (slopeSlowdownSpeedStep < 1.2f) { slopeSlowdownSpeedStep = 1.2f; } @@ -6384,12 +6480,13 @@ s32 func_8083E318(PlayState* play, Player* this, CollisionPoly* floorPoly) { Math_StepToF(&this->pushedSpeed, slopeSlowdownSpeed, slopeSlowdownSpeedStep); } else { // moving downward on the slope, causing player to slip - func_80835C58(play, this, func_8084F390, 0); + Player_SetupAction(play, this, Player_Action_8084F390, 0); func_80832564(play, this); - if (D_80853610 >= 0) { - this->unk_84F = 1; + + if (sFloorShapePitch >= 0) { + this->actionVar1 = 1; } - func_80832BE8(play, this, D_80854590[this->unk_84F]); + Player_AnimChangeLoopMorph(play, this, sSlopeSlipAnims[this->actionVar1]); this->speedXZ = sqrtf(SQ(this->actor.velocity.x) + SQ(this->actor.velocity.z)); this->yaw = playerVelYaw; return true; @@ -6442,12 +6539,12 @@ s32 func_8083E5A8(Player* this, PlayState* play) { if ((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) || (play->sceneId == SCENE_BOMBCHU_BOWLING_ALLEY)) { - func_808323B4(play, this); + Player_DetachHeldActor(play, this); func_8083AE40(this, giEntry->objectId); if (!(this->stateFlags2 & PLAYER_STATE2_10) || (this->currentBoots == PLAYER_BOOTS_IRON)) { func_80836898(play, this, func_8083A434); - func_808322D0(play, this, &gPlayerAnim_link_demo_get_itemB); + Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_demo_get_itemB); func_80835EA4(play, 9); } @@ -6485,14 +6582,15 @@ s32 func_8083E5A8(Player* this, PlayState* play) { if ((giEntry->itemId != ITEM_NONE) && (giEntry->gi >= 0) && (Item_CheckObtainability(giEntry->itemId) == ITEM_NONE)) { - func_808322D0(play, this, this->ageProperties->unk_98); - func_80832F54(play, this, - FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | - ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); + Player_AnimPlayOnceAdjusted(play, this, this->ageProperties->unk_98); + Player_AnimReplaceApplyFlags(play, this, + ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | + ANIM_FLAG_PLAYER_7); chest->unk_1F4 = 1; Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_SLOW_CHEST_CS); } else { - func_80832264(play, this, &gPlayerAnim_link_normal_box_kick); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_box_kick); chest->unk_1F4 = -1; } @@ -6510,9 +6608,9 @@ s32 func_8083E5A8(Player* this, PlayState* play) { if (sp24 == PLAYER_IA_SWORD_MASTER) { this->nextModelGroup = Player_ActionToModelGroup(this, PLAYER_IA_LAST_USED); - func_8083399C(play, this, PLAYER_IA_LAST_USED); + Player_InitItemAction(play, this, PLAYER_IA_LAST_USED); } else { - func_80835F44(play, this, ITEM_LAST_USED); + Player_UseItem(play, this, ITEM_LAST_USED); } } else { s32 strength = Player_GetStrength(); @@ -6536,8 +6634,8 @@ s32 func_8083E5A8(Player* this, PlayState* play) { } void func_8083EA94(Player* this, PlayState* play) { - func_80835C58(play, this, func_80846578, 1); - func_80832264(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_throw, this->modelAnimType)); + Player_SetupAction(play, this, Player_Action_80846578, 1); + Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_throw, this->modelAnimType)); } s32 func_8083EAF0(Player* this, Actor* actor) { @@ -6554,8 +6652,8 @@ s32 func_8083EB44(Player* this, PlayState* play) { CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { if (!func_80835644(play, this, this->heldActor)) { if (!func_8083EAF0(this, this->heldActor)) { - func_80835C58(play, this, func_808464B0, 1); - func_80832264(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_put, this->modelAnimType)); + Player_SetupAction(play, this, Player_Action_808464B0, 1); + Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_put, this->modelAnimType)); } else { func_8083EA94(this, play); } @@ -6566,13 +6664,13 @@ s32 func_8083EB44(Player* this, PlayState* play) { return 0; } -s32 func_8083EC18(Player* this, PlayState* play, u32 interactWallFlags) { - if (this->wallHeight >= 79.0f) { +s32 func_8083EC18(Player* this, PlayState* play, u32 wallFlags) { + if (this->yDistToLedge >= 79.0f) { if (!(this->stateFlags1 & PLAYER_STATE1_27) || (this->currentBoots == PLAYER_BOOTS_IRON) || (this->actor.yDistToWater < this->ageProperties->unk_2C)) { - s32 sp8C = (interactWallFlags & WALL_FLAG_3) ? 2 : 0; + s32 sp8C = (wallFlags & WALL_FLAG_3) ? 2 : 0; - if ((sp8C != 0) || (interactWallFlags & WALL_FLAG_1) || + if ((sp8C != 0) || (wallFlags & WALL_FLAG_1) || SurfaceType_CheckWallFlag2(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) { f32 phi_f20; CollisionPoly* wallPoly = this->actor.wallPoly; @@ -6631,31 +6729,31 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 interactWallFlags) { if (phi_f12 < 8.0f) { f32 wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); - f32 sp34 = this->wallDistance; - LinkAnimationHeader* sp30; + f32 sp34 = this->distToInteractWall; + LinkAnimationHeader* anim; func_80836898(play, this, func_8083A3B0); this->stateFlags1 |= PLAYER_STATE1_21; this->stateFlags1 &= ~PLAYER_STATE1_27; - if ((sp8C != 0) || (interactWallFlags & WALL_FLAG_1)) { - if ((this->unk_84F = sp8C) != 0) { + if ((sp8C != 0) || (wallFlags & WALL_FLAG_1)) { + if ((this->actionVar1 = sp8C) != 0) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - sp30 = &gPlayerAnim_link_normal_Fclimb_startA; + anim = &gPlayerAnim_link_normal_Fclimb_startA; } else { - sp30 = &gPlayerAnim_link_normal_Fclimb_hold2upL; + anim = &gPlayerAnim_link_normal_Fclimb_hold2upL; } - sp34 = (this->ageProperties->unk_38 - 1.0f) - sp34; + sp34 = (this->ageProperties->wallCheckRadius - 1.0f) - sp34; } else { - sp30 = this->ageProperties->unk_A4; + anim = this->ageProperties->unk_A4; sp34 = sp34 - 1.0f; } - this->unk_850 = -2; + this->actionVar2 = -2; this->actor.world.pos.y += phi_f20; this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000; } else { - sp30 = this->ageProperties->unk_A8; - this->unk_850 = -4; + anim = this->ageProperties->unk_A8; + this->actionVar2 = -4; this->actor.shape.rot.y = this->yaw = this->actor.wallYaw; } @@ -6663,10 +6761,10 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 interactWallFlags) { this->actor.world.pos.z = (sp34 * wallPolyNormalZ) + sp7C; func_80832224(this); Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); - func_80832264(play, this, sp30); - func_80832F54(play, this, - ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | - ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_AnimPlayOnce(play, this, anim); + Player_AnimReplaceApplyFlags(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); return true; } @@ -6678,7 +6776,7 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 interactWallFlags) { } void func_8083F070(Player* this, LinkAnimationHeader* anim, PlayState* play) { - func_80835DAC(play, this, func_8084C5F8, 0); + func_80835DAC(play, this, Player_Action_8084C5F8, 0); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, (4.0f / 3.0f)); } @@ -6735,19 +6833,19 @@ s32 Player_TryEnteringCrawlspace(Player* this, PlayState* play, u32 interactWall // Enter Crawlspace f32 wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); - f32 wallDistance = this->wallDistance; + f32 distToInteractWall = this->distToInteractWall; func_80836898(play, this, func_8083A40C); this->stateFlags2 |= PLAYER_STATE2_CRAWLING; this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000; - this->actor.world.pos.x = xVertex1 + (wallDistance * wallPolyNormalX); - this->actor.world.pos.z = zVertex1 + (wallDistance * wallPolyNormalZ); + this->actor.world.pos.x = xVertex1 + (distToInteractWall * wallPolyNormalX); + this->actor.world.pos.z = zVertex1 + (distToInteractWall * wallPolyNormalZ); func_80832224(this); this->actor.prevPos = this->actor.world.pos; - func_80832264(play, this, &gPlayerAnim_link_child_tunnel_start); - func_80832F54(play, this, - ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | - ANIM_FLAG_PLAYER_7); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_start); + Player_AnimReplaceApplyFlags(play, this, + ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | + ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); return true; } @@ -6785,7 +6883,7 @@ s32 func_8083F360(PlayState* play, Player* this, f32 arg1, f32 arg2, f32 arg3, f this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_WALL_INTERACT; this->actor.wallBgId = wallBgId; - sInteractWallFlags = SurfaceType_GetWallFlags(&play->colCtx, wallPoly, wallBgId); + sTouchedWallFlags = SurfaceType_GetWallFlags(&play->colCtx, wallPoly, wallBgId); wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); @@ -6805,7 +6903,7 @@ s32 func_8083F360(PlayState* play, Player* this, f32 arg1, f32 arg2, f32 arg3, f } s32 func_8083F524(PlayState* play, Player* this) { - return func_8083F360(play, this, 26.0f, this->ageProperties->unk_38 + 5.0f, 30.0f, 0.0f); + return func_8083F360(play, this, 26.0f, this->ageProperties->wallCheckRadius + 5.0f, 30.0f, 0.0f); } /** @@ -6818,7 +6916,7 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { s16 yawToWall; if ((this->speedXZ != 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && - (sInteractWallFlags & WALL_FLAG_CRAWLSPACE)) { + (sTouchedWallFlags & WALL_FLAG_CRAWLSPACE)) { // The exit wallYaws will always point inward on the crawlline // Interacting with the exit wall in front will have a yaw diff of 0x8000 @@ -6829,15 +6927,15 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { } if (ABS(yawToWall) > 0x4000) { - func_80835C58(play, this, func_8084C81C, 0); + Player_SetupAction(play, this, Player_Action_8084C81C, 0); if (this->speedXZ > 0.0f) { // Leaving a crawlspace forwards this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; - func_80832264(play, this, &gPlayerAnim_link_child_tunnel_end); - func_80832F54(play, this, - ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | - ANIM_FLAG_PLAYER_7); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_end); + Player_AnimReplaceApplyFlags(play, this, + ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | + ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); OnePointCutscene_Init(play, 9601, 999, NULL, CAM_ID_MAIN); } else { // Leaving a crawlspace backwards @@ -6845,9 +6943,9 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_child_tunnel_start, -1.0f, Animation_GetLastFrame(&gPlayerAnim_link_child_tunnel_start), 0.0f, ANIMMODE_ONCE, 0.0f); - func_80832F54(play, this, - ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | - ANIM_FLAG_PLAYER_7); + Player_AnimReplaceApplyFlags(play, this, + ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | + ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); OnePointCutscene_Init(play, 9602, 999, NULL, CAM_ID_MAIN); } @@ -6863,10 +6961,10 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { void func_8083F72C(Player* this, LinkAnimationHeader* anim, PlayState* play) { if (!func_80836898(play, this, func_8083A388)) { - func_80835C58(play, this, func_8084B78C, 0); + Player_SetupAction(play, this, Player_Action_8084B78C, 0); } - func_80832264(play, this, anim); + Player_AnimPlayOnce(play, this, anim); func_80832224(this); this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000; @@ -6876,16 +6974,16 @@ s32 func_8083F7BC(Player* this, PlayState* play) { DynaPolyActor* wallPolyActor; if (!(this->stateFlags1 & PLAYER_STATE1_11) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && - (D_80853608 < 0x3000)) { + (sShapeYawToTouchedWall < 0x3000)) { - if (((this->speedXZ > 0.0f) && func_8083EC18(this, play, sInteractWallFlags)) || - Player_TryEnteringCrawlspace(this, play, sInteractWallFlags)) { + if (((this->speedXZ > 0.0f) && func_8083EC18(this, play, sTouchedWallFlags)) || + Player_TryEnteringCrawlspace(this, play, sTouchedWallFlags)) { return 1; } if (!func_808332B8(this) && ((this->speedXZ == 0.0f) || !(this->stateFlags2 & PLAYER_STATE2_2)) && - (sInteractWallFlags & WALL_FLAG_6) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && - (this->wallHeight >= 39.0f)) { + (sTouchedWallFlags & WALL_FLAG_6) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (this->yDistToLedge >= 39.0f)) { this->stateFlags2 |= PLAYER_STATE2_0; @@ -6943,21 +7041,21 @@ s32 func_8083F9D0(PlayState* play, Player* this) { } func_80839FFC(this, play); - func_80832264(play, this, &gPlayerAnim_link_normal_push_wait_end); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_push_wait_end); this->stateFlags2 &= ~PLAYER_STATE2_4; return 1; } void func_8083FAB8(Player* this, PlayState* play) { - func_80835C58(play, this, func_8084B898, 0); + Player_SetupAction(play, this, Player_Action_8084B898, 0); this->stateFlags2 |= PLAYER_STATE2_4; - func_80832264(play, this, &gPlayerAnim_link_normal_push_start); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_push_start); } void func_8083FB14(Player* this, PlayState* play) { - func_80835C58(play, this, func_8084B9E4, 0); + Player_SetupAction(play, this, Player_Action_8084B9E4, 0); this->stateFlags2 |= PLAYER_STATE2_4; - func_80832264(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_pull_start, this->modelAnimType)); + Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_pull_start, this->modelAnimType)); } void func_8083FB7C(Player* this, PlayState* play) { @@ -6969,7 +7067,7 @@ void func_8083FB7C(Player* this, PlayState* play) { s32 func_8083FBC0(Player* this, PlayState* play) { if (!CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && - ((sInteractWallFlags & WALL_FLAG_3) || (sInteractWallFlags & WALL_FLAG_1) || + ((sTouchedWallFlags & WALL_FLAG_3) || (sTouchedWallFlags & WALL_FLAG_1) || SurfaceType_CheckWallFlag2(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId))) { return false; } @@ -7134,7 +7232,7 @@ void func_8084029C(Player* this, f32 arg1) { } } -void func_80840450(Player* this, PlayState* play) { +void Player_Action_80840450(Player* this, PlayState* play) { f32 sp44; s16 sp42; s32 temp1; @@ -7150,11 +7248,11 @@ void func_80840450(Player* this, PlayState* play) { } } - if (this->unk_850 != 0) { + if (this->actionVar2 != 0) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_80832DBC(this); - func_80832284(play, this, func_808334E4(this)); - this->unk_850 = 0; + Player_AnimPlayLoop(play, this, func_808334E4(this)); + this->actionVar2 = 0; this->stateFlags3 &= ~PLAYER_STATE3_3; } func_80833C3C(this); @@ -7165,7 +7263,7 @@ void func_80840450(Player* this, PlayState* play) { func_8083721C(this); if (!func_80837348(play, this, D_808543E0, 1)) { - if (!func_80833B54(this) && (!func_80833B2C(this) || (func_80834B5C != this->func_82C))) { + if (!func_80833B54(this) && (!func_80833B2C(this) || (func_80834B5C != this->itemActionFunc))) { func_8083CF10(this, play); return; } @@ -7216,7 +7314,7 @@ void func_80840450(Player* this, PlayState* play) { } } -void func_808407CC(Player* this, PlayState* play) { +void Player_Action_808407CC(Player* this, PlayState* play) { f32 sp3C; s16 sp3A; s32 temp1; @@ -7225,7 +7323,7 @@ void func_808407CC(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_80832DBC(this); - func_80832264(play, this, func_80833338(this)); + Player_AnimPlayOnce(play, this, func_80833338(this)); } func_8083721C(this); @@ -7237,12 +7335,12 @@ void func_808407CC(Player* this, PlayState* play) { } if (!func_80833B2C(this)) { - func_80835DAC(play, this, func_80840BC8, 1); + func_80835DAC(play, this, Player_Action_80840BC8, 1); this->yaw = this->actor.shape.rot.y; return; } - if (func_80834B5C == this->func_82C) { + if (func_80834B5C == this->itemActionFunc) { func_8083CEAC(this, play); return; } @@ -7328,7 +7426,7 @@ void func_808409CC(PlayState* play, Player* this) { ANIMMODE_ONCE, -6.0f); } -void func_80840BC8(Player* this, PlayState* play) { +void Player_Action_80840BC8(Player* this, PlayState* play) { s32 sp44; s32 sp40; f32 sp3C; @@ -7343,11 +7441,12 @@ void func_80840BC8(Player* this, PlayState* play) { } if (sp40 != 0) { - if (this->unk_850 != 0) { - if (DECR(this->unk_850) == 0) { + if (this->actionVar2 != 0) { + if (DECR(this->actionVar2) == 0) { this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; } - this->skelAnime.jointTable[0].y = (this->skelAnime.jointTable[0].y + ((this->unk_850 & 1) * 0x50)) - 0x28; + this->skelAnime.jointTable[0].y = + (this->skelAnime.jointTable[0].y + ((this->actionVar2 & 1) * 0x50)) - 0x28; } else { func_80832DBC(this); func_808409CC(play, this); @@ -7356,7 +7455,7 @@ void func_80840BC8(Player* this, PlayState* play) { func_8083721C(this); - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { if (!func_80837348(play, this, D_80854418, 1)) { if (func_80833B54(this)) { func_8083CEAC(this, play); @@ -7390,7 +7489,7 @@ void func_80840BC8(Player* this, PlayState* play) { } } -void func_80840DE4(Player* this, PlayState* play) { +void Player_Action_80840DE4(Player* this, PlayState* play) { f32 frames; f32 coeff; f32 sp44; @@ -7522,8 +7621,8 @@ void func_80841138(Player* this, PlayState* play) { } void func_8084140C(Player* this, PlayState* play) { - func_80835C58(play, this, func_8084170C, 1); - func_80832B0C(play, this, &gPlayerAnim_link_normal_back_brake); + Player_SetupAction(play, this, Player_Action_8084170C, 1); + Player_AnimChangeOnceMorph(play, this, &gPlayerAnim_link_normal_back_brake); } s32 func_80841458(Player* this, f32* arg1, s16* arg2, PlayState* play) { @@ -7544,7 +7643,7 @@ s32 func_80841458(Player* this, f32* arg1, s16* arg2, PlayState* play) { return 0; } -void func_808414F8(Player* this, PlayState* play) { +void Player_Action_808414F8(Player* this, PlayState* play) { f32 sp34; s16 sp32; s32 sp2C; @@ -7585,11 +7684,11 @@ void func_808414F8(Player* this, PlayState* play) { } void func_808416C0(Player* this, PlayState* play) { - func_80835C58(play, this, func_808417FC, 1); - func_80832264(play, this, &gPlayerAnim_link_normal_back_brake_end); + Player_SetupAction(play, this, Player_Action_808417FC, 1); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_back_brake_end); } -void func_8084170C(Player* this, PlayState* play) { +void Player_Action_8084170C(Player* this, PlayState* play) { s32 sp34; f32 sp30; s16 sp2E; @@ -7612,7 +7711,7 @@ void func_8084170C(Player* this, PlayState* play) { } } -void func_808417FC(Player* this, PlayState* play) { +void Player_Action_808417FC(Player* this, PlayState* play) { s32 sp1C; sp1C = LinkAnimation_Update(play, &this->skelAnime); @@ -7637,7 +7736,7 @@ void func_80841860(PlayState* play, Player* this) { LinkAnimation_BlendToJoint(play, &this->skelAnime, sp34, frame, sp38, frame, this->unk_870, this->blendTable); } -void func_8084193C(Player* this, PlayState* play) { +void Player_Action_8084193C(Player* this, PlayState* play) { f32 sp3C; s16 sp3A; s32 temp1; @@ -7701,7 +7800,7 @@ void func_8084193C(Player* this, PlayState* play) { } } -void func_80841BA8(Player* this, PlayState* play) { +void Player_Action_80841BA8(Player* this, PlayState* play) { f32 sp34; s16 sp32; @@ -7711,7 +7810,7 @@ void func_80841BA8(Player* this, PlayState* play) { AnimationContext_SetLoadFrame(play, func_80833338(this), 0, this->skelAnime.limbCount, this->skelAnime.morphTable); AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime.morphTable, D_80853410); + this->skelAnime.morphTable, sUpperBodyLimbCopyMap); } func_80837268(this, &sp34, &sp32, 0.018f, play); @@ -7733,10 +7832,10 @@ void func_80841CC4(Player* this, s32 arg1, PlayState* play) { s16 target; f32 rate; - if (ABS(D_80853610) < 3640) { + if (ABS(sFloorShapePitch) < 3640) { target = 0; } else { - target = CLAMP(D_80853610, -10922, 10922); + target = CLAMP(sFloorShapePitch, -10922, 10922); } Math_ScaledStepToS(&this->unk_89C, target, 400); @@ -7825,7 +7924,7 @@ void func_80841EE4(Player* this, PlayState* play) { } } -void func_80842180(Player* this, PlayState* play) { +void Player_Action_80842180(Player* this, PlayState* play) { f32 sp2C; s16 sp2A; @@ -7857,7 +7956,7 @@ void func_80842180(Player* this, PlayState* play) { } } -void func_8084227C(Player* this, PlayState* play) { +void Player_Action_8084227C(Player* this, PlayState* play) { f32 sp2C; s16 sp2A; @@ -7889,7 +7988,7 @@ void func_8084227C(Player* this, PlayState* play) { } } -void func_808423EC(Player* this, PlayState* play) { +void Player_Action_808423EC(Player* this, PlayState* play) { s32 sp34; f32 sp30; s16 sp2E; @@ -7919,7 +8018,7 @@ void func_808423EC(Player* this, PlayState* play) { } } -void func_8084251C(Player* this, PlayState* play) { +void Player_Action_8084251C(Player* this, PlayState* play) { s32 sp34; f32 sp30; s16 sp2E; @@ -7971,10 +8070,10 @@ s32 func_8084269C(PlayState* play, Player* this) { return 0; } -void func_8084279C(Player* this, PlayState* play) { +void Player_Action_8084279C(Player* this, PlayState* play) { func_80832CB0(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_check_wait, this->modelAnimType)); - if (DECR(this->unk_850) == 0) { + if (DECR(this->actionVar2) == 0) { if (!func_8083B040(this, play)) { func_8083A098(this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_check_end, this->modelAnimType), play); } @@ -7995,9 +8094,9 @@ s32 func_8084285C(Player* this, f32 arg1, f32 arg2, f32 arg3) { } s32 func_808428D8(Player* this, PlayState* play) { - if (!Player_IsChildWithHylianShield(this) && (Player_GetMeleeWeaponHeld(this) != 0) && D_80853614) { - func_80832264(play, this, &gPlayerAnim_link_normal_defense_kiru); - this->unk_84F = 1; + if (!Player_IsChildWithHylianShield(this) && (Player_GetMeleeWeaponHeld(this) != 0) && sUseHeldItem) { + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_defense_kiru); + this->actionVar1 = 1; this->meleeWeaponAnimation = PLAYER_MWA_STAB_1H; this->yaw = this->actor.shape.rot.y + this->unk_6BE; return 1; @@ -8027,7 +8126,7 @@ void func_80842A28(PlayState* play, Player* this) { void func_80842A88(PlayState* play, Player* this) { Inventory_ChangeAmmo(ITEM_DEKU_STICK, -1); - func_80835F44(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); } s32 func_80842AC4(PlayState* play, Player* this) { @@ -8078,9 +8177,9 @@ void func_80842D20(PlayState* play, Player* this) { s32 pad; s32 sp28; - if (func_80843188 != this->func_674) { + if (Player_Action_80843188 != this->actionFunc) { func_80832440(play, this); - func_80835C58(play, this, func_808505DC, 0); + Player_SetupAction(play, this, Player_Action_808505DC, 0); if (func_8008E9C4(this)) { sp28 = 2; @@ -8088,7 +8187,7 @@ void func_80842D20(PlayState* play, Player* this) { sp28 = 0; } - func_808322D0(play, this, D_808545CC[Player_HoldsTwoHandedWeapon(this) + sp28]); + Player_AnimPlayOnceAdjusted(play, this, D_808545CC[Player_HoldsTwoHandedWeapon(this) + sp28]); } Player_RequestRumble(this, 180, 20, 100, 0); @@ -8188,7 +8287,7 @@ s32 func_80842DF4(PlayState* play, Player* this) { return 0; } -void func_80843188(Player* this, PlayState* play) { +void Player_Action_80843188(Player* this, PlayState* play) { f32 sp54; f32 sp50; s16 sp4E; @@ -8200,21 +8299,21 @@ void func_80843188(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { if (!Player_IsChildWithHylianShield(this)) { - func_80832284(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_defense_wait, this->modelAnimType)); + Player_AnimPlayLoop(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_defense_wait, this->modelAnimType)); } - this->unk_850 = 1; - this->unk_84F = 0; + this->actionVar2 = 1; + this->actionVar1 = 0; } if (!Player_IsChildWithHylianShield(this)) { this->stateFlags1 |= PLAYER_STATE1_22; - func_80836670(this, play); + Player_UpdateUpperBody(this, play); this->stateFlags1 &= ~PLAYER_STATE1_22; } func_8083721C(this); - if (this->unk_850 != 0) { + if (this->actionVar2 != 0) { sp54 = sControlInput->rel.stick_y * 100; sp50 = sControlInput->rel.stick_x * -120; sp4E = this->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); @@ -8242,14 +8341,14 @@ void func_80843188(Player* this, PlayState* play) { this->unk_6BC = this->actor.focus.rot.x; Math_ScaledStepToS(&this->unk_6BE, sp4A, sp46); - if (this->unk_84F != 0) { + if (this->actionVar1 != 0) { if (!func_80842DF4(play, this)) { if (this->skelAnime.curFrame < 2.0f) { func_80833A20(this, 1); } } else { - this->unk_850 = 1; - this->unk_84F = 0; + this->actionVar2 = 1; + this->actionVar1 = 0; } } else if (!func_80842964(this, play)) { if (func_8083C2B0(this, play)) { @@ -8263,7 +8362,7 @@ void func_80843188(Player* this, PlayState* play) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_clink_normal_defense_ALL, 1.0f, Animation_GetLastFrame(&gPlayerAnim_clink_normal_defense_ALL), 0.0f, ANIMMODE_ONCE, 0.0f); - func_80832F54(play, this, ANIM_FLAG_PLAYER_2); + Player_AnimReplaceApplyFlags(play, this, ANIM_FLAG_PLAYER_2); } else { if (this->itemAction < 0) { func_8008EC70(this); @@ -8285,22 +8384,22 @@ void func_80843188(Player* this, PlayState* play) { this->unk_6AE |= 0xC1; } -void func_808435C4(Player* this, PlayState* play) { +void Player_Action_808435C4(Player* this, PlayState* play) { s32 temp; LinkAnimationHeader* anim; f32 frames; func_8083721C(this); - if (this->unk_84F == 0) { - D_808535E0 = func_80836670(this, play); - if ((func_80834B5C == this->func_82C) || (func_808374A0(play, this, &this->skelAnime2, 4.0f) > 0)) { - func_80835C58(play, this, func_80840450, 1); + if (this->actionVar1 == 0) { + D_808535E0 = Player_UpdateUpperBody(this, play); + if ((func_80834B5C == this->itemActionFunc) || (func_808374A0(play, this, &this->skelAnimeUpper, 4.0f) > 0)) { + Player_SetupAction(play, this, Player_Action_80840450, 1); } } else { temp = func_808374A0(play, this, &this->skelAnime, 4.0f); if ((temp != 0) && ((temp > 0) || LinkAnimation_Update(play, &this->skelAnime))) { - func_80835C58(play, this, func_80843188, 1); + Player_SetupAction(play, this, Player_Action_80843188, 1); this->stateFlags1 |= PLAYER_STATE1_22; Player_SetModelsForHoldingShield(this); anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_defense, this->modelAnimType); @@ -8310,7 +8409,7 @@ void func_808435C4(Player* this, PlayState* play) { } } -void func_8084370C(Player* this, PlayState* play) { +void Player_Action_8084370C(Player* this, PlayState* play) { s32 sp1C; func_8083721C(this); @@ -8321,12 +8420,12 @@ void func_8084370C(Player* this, PlayState* play) { } } -void func_8084377C(Player* this, PlayState* play) { +void Player_Action_8084377C(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_5 | PLAYER_STATE2_6; func_808382BC(this); - if (!(this->stateFlags1 & PLAYER_STATE1_29) && (this->unk_850 == 0) && (this->unk_8A1 != 0)) { + if (!(this->stateFlags1 & PLAYER_STATE1_29) && (this->actionVar2 == 0) && (this->unk_8A1 != 0)) { s16 temp = this->actor.shape.rot.y - this->unk_8A2; this->yaw = this->actor.shape.rot.y = this->unk_8A2; @@ -8343,23 +8442,23 @@ void func_8084377C(Player* this, PlayState* play) { } if (LinkAnimation_Update(play, &this->skelAnime) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { - if (this->unk_850 != 0) { - this->unk_850--; - if (this->unk_850 == 0) { + if (this->actionVar2 != 0) { + this->actionVar2--; + if (this->actionVar2 == 0) { func_80853080(this, play); } } else if ((this->stateFlags1 & PLAYER_STATE1_29) || (!(this->cylinder.base.acFlags & AC_HIT) && (this->unk_8A1 == 0))) { if (this->stateFlags1 & PLAYER_STATE1_29) { - this->unk_850++; + this->actionVar2++; } else { - func_80835C58(play, this, func_80843954, 0); + Player_SetupAction(play, this, Player_Action_80843954, 0); this->stateFlags1 |= PLAYER_STATE1_26; } - func_80832264(play, this, - (this->yaw != this->actor.shape.rot.y) ? &gPlayerAnim_link_normal_front_downB - : &gPlayerAnim_link_normal_back_downB); + Player_AnimPlayOnce(play, this, + (this->yaw != this->actor.shape.rot.y) ? &gPlayerAnim_link_normal_front_downB + : &gPlayerAnim_link_normal_back_downB); func_80832698(this, NA_SE_VO_LI_FREEZE); } } @@ -8369,7 +8468,7 @@ void func_8084377C(Player* this, PlayState* play) { } } -void func_80843954(Player* this, PlayState* play) { +void Player_Action_80843954(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_5 | PLAYER_STATE2_6; func_808382BC(this); @@ -8377,15 +8476,15 @@ void func_80843954(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime) && (this->speedXZ == 0.0f)) { if (this->stateFlags1 & PLAYER_STATE1_29) { - this->unk_850++; + this->actionVar2++; } else { - func_80835C58(play, this, func_80843A38, 0); + Player_SetupAction(play, this, Player_Action_80843A38, 0); this->stateFlags1 |= PLAYER_STATE1_26; } - func_808322D0(play, this, - (this->yaw != this->actor.shape.rot.y) ? &gPlayerAnim_link_normal_front_down_wake - : &gPlayerAnim_link_normal_back_down_wake); + Player_AnimPlayOnceAdjusted(play, this, + (this->yaw != this->actor.shape.rot.y) ? &gPlayerAnim_link_normal_front_down_wake + : &gPlayerAnim_link_normal_back_down_wake); this->yaw = this->actor.shape.rot.y; } } @@ -8395,7 +8494,7 @@ static struct_80832924 D_808545DC[] = { { 0, -0x401E }, }; -void func_80843A38(Player* this, PlayState* play) { +void Player_Action_80843A38(Player* this, PlayState* play) { s32 sp24; this->stateFlags2 |= PLAYER_STATE2_5; @@ -8416,10 +8515,10 @@ void func_80843A38(Player* this, PlayState* play) { static Vec3f D_808545E4 = { 0.0f, 0.0f, 5.0f }; void func_80843AE8(PlayState* play, Player* this) { - if (this->unk_850 != 0) { - if (this->unk_850 > 0) { - this->unk_850--; - if (this->unk_850 == 0) { + if (this->actionVar2 != 0) { + if (this->actionVar2 > 0) { + this->actionVar2--; + if (this->actionVar2 == 0) { if (this->stateFlags1 & PLAYER_STATE1_27) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_swimer_swim_wait, 1.0f, 0.0f, Animation_GetLastFrame(&gPlayerAnim_link_swimer_swim_wait), ANIMMODE_ONCE, @@ -8429,7 +8528,7 @@ void func_80843AE8(PlayState* play, Player* this) { Animation_GetLastFrame(&gPlayerAnim_link_derth_rebirth), ANIMMODE_ONCE, 0.0f); } gSaveContext.healthAccumulator = 0x140; - this->unk_850 = -1; + this->actionVar2 = -1; } } else if (gSaveContext.healthAccumulator == 0) { this->stateFlags1 &= ~PLAYER_STATE1_7; @@ -8442,8 +8541,8 @@ void func_80843AE8(PlayState* play, Player* this) { func_80837AFC(this, -20); Audio_SetBgmVolumeOnDuringFanfare(); } - } else if (this->unk_84F != 0) { - this->unk_850 = 60; + } else if (this->actionVar1 != 0) { + this->actionVar2 = 60; Player_SpawnFairy(play, this, &this->actor.world.pos, &D_808545E4, FAIRY_REVIVE_DEATH); Player_PlaySfx(this, NA_SE_EV_FIATY_HEAL - SFX_FLAG); OnePointCutscene_Init(play, 9908, 125, &this->actor, CAM_ID_MAIN); @@ -8459,10 +8558,10 @@ static struct_80832924 D_808545F0[] = { { 0, -0x40AA }, }; -void func_80843CEC(Player* this, PlayState* play) { +void Player_Action_80843CEC(Player* this, PlayState* play) { if (this->currentTunic != PLAYER_TUNIC_GORON) { - if ((play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) || (D_808535E4 == FLOOR_TYPE_9) || - ((func_80838144(D_808535E4) >= 0) && + if ((play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) || (sFloorType == FLOOR_TYPE_9) || + ((func_80838144(sFloorType) >= 0) && !func_80042108(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { func_8083821C(this); } @@ -8502,7 +8601,7 @@ static FallImpactInfo D_80854600[] = { s32 func_80843E64(PlayState* play, Player* this) { s32 sp34; - if ((D_808535E4 == FLOOR_TYPE_6) || (D_808535E4 == FLOOR_TYPE_9)) { + if ((sFloorType == FLOOR_TYPE_6) || (sFloorType == FLOOR_TYPE_9)) { sp34 = 0; } else { sp34 = this->fallDistance; @@ -8547,7 +8646,7 @@ s32 func_80843E64(PlayState* play, Player* this) { Player_RequestRumble(this, (u8)sp34, (u8)(sp34 * 0.1f), (u8)sp34, 0); - if (D_808535E4 == FLOOR_TYPE_6) { + if (sFloorType == FLOOR_TYPE_6) { func_80832698(this, NA_SE_VO_LI_CLIMB_END); } } @@ -8570,7 +8669,7 @@ void func_8084409C(PlayState* play, Player* this, f32 speedXZ, f32 velocityY) { } } -void func_8084411C(Player* this, PlayState* play) { +void Player_Action_8084411C(Player* this, PlayState* play) { f32 sp4C; s16 sp4A; @@ -8598,35 +8697,35 @@ void func_8084411C(Player* this, PlayState* play) { func_8083DFE0(this, &sp4C, &sp4A); } - func_80836670(this, play); + Player_UpdateUpperBody(this, play); - if (((this->stateFlags2 & PLAYER_STATE2_19) && (this->unk_84F == 2)) || !func_8083BBA0(this, play)) { + if (((this->stateFlags2 & PLAYER_STATE2_19) && (this->actionVar1 == 2)) || !func_8083BBA0(this, play)) { if (this->actor.velocity.y < 0.0f) { - if (this->unk_850 >= 0) { - if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->unk_850 == 0) || + if (this->actionVar2 >= 0) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->actionVar2 == 0) || (this->fallDistance > 0)) { - if ((D_80853600 > 800.0f) || (this->stateFlags1 & PLAYER_STATE1_2)) { + if ((sYDistToFloor > 800.0f) || (this->stateFlags1 & PLAYER_STATE1_2)) { func_80843E14(this, NA_SE_VO_LI_FALL_S); this->stateFlags1 &= ~PLAYER_STATE1_2; } LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_normal_landing, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f); - this->unk_850 = -1; + this->actionVar2 = -1; } } else { - if ((this->unk_850 == -1) && (this->fallDistance > 120.0f) && (D_80853600 > 280.0f)) { - this->unk_850 = -2; + if ((this->actionVar2 == -1) && (this->fallDistance > 120.0f) && (sYDistToFloor > 280.0f)) { + this->actionVar2 = -2; func_80843E14(this, NA_SE_VO_LI_FALL_L); } if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && !(this->stateFlags2 & PLAYER_STATE2_19) && !(this->stateFlags1 & (PLAYER_STATE1_11 | PLAYER_STATE1_27)) && (this->speedXZ > 0.0f)) { - if ((this->wallHeight >= 150.0f) && (this->unk_84B[this->unk_846] == 0)) { - func_8083EC18(this, play, sInteractWallFlags); - } else if ((this->unk_88C >= 2) && (this->wallHeight < 150.0f) && - (((this->actor.world.pos.y - this->actor.floorHeight) + this->wallHeight) > + if ((this->yDistToLedge >= 150.0f) && (this->unk_84B[this->unk_846] == 0)) { + func_8083EC18(this, play, sTouchedWallFlags); + } else if ((this->ledgeClimbType >= PLAYER_LEDGE_CLIMB_2) && (this->yDistToLedge < 150.0f) && + (((this->actor.world.pos.y - this->actor.floorHeight) + this->yDistToLedge) > (70.0f * this->ageProperties->unk_08))) { AnimationContext_DisableQueue(play); if (this->stateFlags1 & PLAYER_STATE1_2) { @@ -8634,8 +8733,8 @@ void func_8084411C(Player* this, PlayState* play) { } else { func_80832698(this, NA_SE_VO_LI_HANG); } - this->actor.world.pos.y += this->wallHeight; - func_8083A5C4(play, this, this->actor.wallPoly, this->wallDistance, + this->actor.world.pos.y += this->yDistToLedge; + func_8083A5C4(play, this, this->actor.wallPoly, this->distToInteractWall, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_jump_climb_hold, this->modelAnimType)); this->actor.shape.rot.y = this->yaw += 0x8000; this->stateFlags1 |= PLAYER_STATE1_13; @@ -8650,9 +8749,9 @@ void func_8084411C(Player* this, PlayState* play) { if (this->stateFlags2 & PLAYER_STATE2_19) { if (func_8008E9C4(this)) { - anim = D_80853D4C[this->unk_84F][2]; + anim = D_80853D4C[this->actionVar1][2]; } else { - anim = D_80853D4C[this->unk_84F][1]; + anim = D_80853D4C[this->actionVar1][1]; } } else if (this->skelAnime.animation == &gPlayerAnim_link_normal_run_jump) { anim = &gPlayerAnim_link_normal_run_jump_end; @@ -8673,9 +8772,9 @@ void func_8084411C(Player* this, PlayState* play) { func_8083A098(this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_landing, this->modelAnimType), play); this->skelAnime.endFrame = 8.0f; if (sp3C == 1) { - this->unk_850 = 10; + this->actionVar2 = 10; } else { - this->unk_850 = 20; + this->actionVar2 = 20; } } else if (sp3C == 0) { func_8083A098(this, anim, play); @@ -8690,7 +8789,7 @@ static struct_80832924 D_8085460C[] = { { 0, -0x2812 }, }; -void func_80844708(Player* this, PlayState* play) { +void Player_Action_80844708(Player* this, PlayState* play) { Actor* cylinderOc; s32 temp; s32 sp44; @@ -8709,7 +8808,7 @@ void func_80844708(Player* this, PlayState* play) { } if (func_80842964(this, play) == 0) { - if (this->unk_850 != 0) { + if (this->actionVar2 != 0) { Math_StepToF(&this->speedXZ, 0.0f, 2.0f); temp = func_808374A0(play, this, &this->skelAnime, 5.0f); @@ -8718,7 +8817,8 @@ void func_80844708(Player* this, PlayState* play) { } } else { if (this->speedXZ >= 7.0f) { - if (((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (D_8085360C < 0x2000)) || + if (((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && + (sWorldYawToTouchedWall < 0x2000)) || ((this->cylinder.base.ocFlags1 & OC1_HIT) && (cylinderOc = this->cylinder.base.oc, ((cylinderOc->id == ACTOR_EN_WOOD02) && @@ -8733,13 +8833,13 @@ void func_80844708(Player* this, PlayState* play) { } } - func_80832264(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_hip_down, this->modelAnimType)); + Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_hip_down, this->modelAnimType)); this->speedXZ = -this->speedXZ; Player_RequestQuake(play, 33267, 3, 12); Player_RequestRumble(this, 255, 20, 150, 0); Player_PlaySfx(this, NA_SE_PL_BODY_HIT); func_80832698(this, NA_SE_VO_LI_CLIMB_END); - this->unk_850 = 1; + this->actionVar2 = 1; return; } } @@ -8769,11 +8869,11 @@ void func_80844708(Player* this, PlayState* play) { } } -void func_80844A44(Player* this, PlayState* play) { +void Player_Action_80844A44(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_5; if (LinkAnimation_Update(play, &this->skelAnime)) { - func_80832284(play, this, &gPlayerAnim_link_normal_run_jump_water_fall_wait); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_normal_run_jump_water_fall_wait); } Math_StepToF(&this->speedXZ, 0.0f, 0.05f); @@ -8784,7 +8884,7 @@ void func_80844A44(Player* this, PlayState* play) { } } -void func_80844AF4(Player* this, PlayState* play) { +void Player_Action_80844AF4(Player* this, PlayState* play) { f32 sp2C; s16 sp2A; @@ -8840,32 +8940,32 @@ s32 func_80844BE4(Player* this, PlayState* play) { } void func_80844CF8(Player* this, PlayState* play) { - func_80835C58(play, this, func_80845000, 1); + Player_SetupAction(play, this, Player_Action_80845000, 1); } void func_80844D30(Player* this, PlayState* play) { - func_80835C58(play, this, func_80845308, 1); + Player_SetupAction(play, this, Player_Action_80845308, 1); } void func_80844D68(Player* this, PlayState* play) { func_80839FFC(this, play); func_80832318(this); - func_80832B0C(play, this, D_80854368[Player_HoldsTwoHandedWeapon(this)]); + Player_AnimChangeOnceMorph(play, this, D_80854368[Player_HoldsTwoHandedWeapon(this)]); this->yaw = this->actor.shape.rot.y; } void func_80844DC8(Player* this, PlayState* play) { - func_80835C58(play, this, func_80844E68, 1); + Player_SetupAction(play, this, Player_Action_80844E68, 1); this->unk_868 = 0.0f; - func_80832284(play, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]); - this->unk_850 = 1; + Player_AnimPlayLoop(play, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]); + this->actionVar2 = 1; } void func_80844E3C(Player* this) { Math_StepToF(&this->unk_858, 1.0f, 0.02f); } -void func_80844E68(Player* this, PlayState* play) { +void Player_Action_80844E68(Player* this, PlayState* play) { f32 sp34; s16 sp32; s32 temp; @@ -8876,19 +8976,19 @@ void func_80844E68(Player* this, PlayState* play) { func_80832DBC(this); func_808355DC(this); this->stateFlags1 &= ~PLAYER_STATE1_17; - func_80832284(play, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]); - this->unk_850 = -1; + Player_AnimPlayLoop(play, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]); + this->actionVar2 = -1; } func_8083721C(this); - if (!func_80842964(this, play) && (this->unk_850 != 0)) { + if (!func_80842964(this, play) && (this->actionVar2 != 0)) { func_80844E3C(this); - if (this->unk_850 < 0) { + if (this->actionVar2 < 0) { if (this->unk_858 >= 0.1f) { this->unk_845 = 0; - this->unk_850 = 1; + this->actionVar2 = 1; } else if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { func_80844D68(this, play); } @@ -8905,7 +9005,7 @@ void func_80844E68(Player* this, PlayState* play) { } } -void func_80845000(Player* this, PlayState* play) { +void Player_Action_80845000(Player* this, PlayState* play) { s16 temp1; s32 temp2; f32 sp5C; @@ -8973,7 +9073,7 @@ void func_80845000(Player* this, PlayState* play) { } } -void func_80845308(Player* this, PlayState* play) { +void Player_Action_80845308(Player* this, PlayState* play) { f32 sp5C; f32 sp58; f32 sp54; @@ -9041,7 +9141,7 @@ void func_80845308(Player* this, PlayState* play) { } } -void func_80845668(Player* this, PlayState* play) { +void Player_Action_80845668(Player* this, PlayState* play) { s32 sp3C; f32 temp1; s32 temp2; @@ -9054,7 +9154,7 @@ void func_80845668(Player* this, PlayState* play) { this->speedXZ = 1.0f; if (LinkAnimation_OnFrame(&this->skelAnime, 8.0f)) { - temp1 = this->wallHeight; + temp1 = this->yDistToLedge; if (temp1 > this->ageProperties->unk_0C) { temp1 = this->ageProperties->unk_0C; @@ -9071,7 +9171,7 @@ void func_80845668(Player* this, PlayState* play) { } func_80838940(this, NULL, temp1, play, NA_SE_VO_LI_AUTO_JUMP); - this->unk_850 = -1; + this->actionVar2 = -1; return; } } else { @@ -9107,21 +9207,21 @@ void func_80845668(Player* this, PlayState* play) { } if ((this->skelAnime.animation == &gPlayerAnim_link_normal_100step_up) || (this->skelAnime.curFrame > 5.0f)) { - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { func_80832854(this); - this->unk_850 = 1; + this->actionVar2 = 1; } Math_StepToF(&this->actor.shape.yOffset, 0.0f, 150.0f); } } } -void func_808458D0(Player* this, PlayState* play) { +void Player_Action_808458D0(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_5 | PLAYER_STATE2_6; LinkAnimation_Update(play, &this->skelAnime); if (((this->stateFlags1 & PLAYER_STATE1_11) && (this->heldActor != NULL) && (this->getItemId == GI_NONE)) || - !func_80836670(this, play)) { + !Player_UpdateUpperBody(this, play)) { this->func_A74(play, this); } } @@ -9193,7 +9293,7 @@ s32 func_80845C68(PlayState* play, s32 arg1) { return arg1; } -void func_80845CA4(Player* this, PlayState* play) { +void Player_Action_80845CA4(Player* this, PlayState* play) { f32 sp3C; s32 temp; f32 sp34; @@ -9201,18 +9301,18 @@ void func_80845CA4(Player* this, PlayState* play) { s32 pad; if (!func_8083B040(this, play)) { - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { LinkAnimation_Update(play, &this->skelAnime); if (DECR(this->doorTimer) == 0) { this->speedXZ = 0.1f; - this->unk_850 = 1; + this->actionVar2 = 1; } - } else if (this->unk_84F == 0) { + } else if (this->actionVar1 == 0) { sp3C = 5.0f * D_808535E8; if (func_80845BA0(play, this, &sp3C, -1) < 30) { - this->unk_84F = 1; + this->actionVar1 = 1; this->stateFlags1 |= PLAYER_STATE1_29; this->unk_450.x = this->unk_45C.x; @@ -9225,12 +9325,12 @@ void func_80845CA4(Player* this, PlayState* play) { if (this->stateFlags1 & PLAYER_STATE1_0) { sp34 = gSaveContext.entranceSpeed; - if (sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { + if (sConveyorSpeed != CONVEYOR_SPEED_DISABLED) { this->unk_450.x = (Math_SinS(sConveyorYaw) * 400.0f) + this->actor.world.pos.x; this->unk_450.z = (Math_CosS(sConveyorYaw) * 400.0f) + this->actor.world.pos.z; } - } else if (this->unk_850 < 0) { - this->unk_850++; + } else if (this->actionVar2 < 0) { + this->actionVar2++; sp34 = gSaveContext.entranceSpeed; sp30 = -1; @@ -9238,8 +9338,8 @@ void func_80845CA4(Player* this, PlayState* play) { temp = func_80845BA0(play, this, &sp34, sp30); - if ((this->unk_850 == 0) || ((temp == 0) && (this->speedXZ == 0.0f) && - (Play_GetCamera(play, CAM_ID_MAIN)->stateFlags & CAM_STATE_4))) { + if ((this->actionVar2 == 0) || ((temp == 0) && (this->speedXZ == 0.0f) && + (Play_GetCamera(play, CAM_ID_MAIN)->stateFlags & CAM_STATE_4))) { func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); func_80845C68(play, gSaveContext.respawn[RESPAWN_MODE_DOWN].data); @@ -9252,22 +9352,22 @@ void func_80845CA4(Player* this, PlayState* play) { } if (this->stateFlags1 & PLAYER_STATE1_11) { - func_80836670(this, play); + Player_UpdateUpperBody(this, play); } } -void func_80845EF8(Player* this, PlayState* play) { +void Player_Action_80845EF8(Player* this, PlayState* play) { s32 sp2C; this->stateFlags2 |= PLAYER_STATE2_5; sp2C = LinkAnimation_Update(play, &this->skelAnime); - func_80836670(this, play); + Player_UpdateUpperBody(this, play); if (sp2C) { - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { if (DECR(this->doorTimer) == 0) { - this->unk_850 = 1; + this->actionVar2 = 1; this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; } } else { @@ -9286,7 +9386,7 @@ void func_80845EF8(Player* this, PlayState* play) { } } -void func_80846050(Player* this, PlayState* play) { +void Player_Action_80846050(Player* this, PlayState* play) { func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -9318,8 +9418,8 @@ static struct_80832924 D_8085461C[] = { { NA_SE_VO_LI_SWORD_N, -0x20E6 }, }; -void func_80846120(Player* this, PlayState* play) { - if (LinkAnimation_Update(play, &this->skelAnime) && (this->unk_850++ > 20)) { +void Player_Action_80846120(Player* this, PlayState* play) { + if (LinkAnimation_Update(play, &this->skelAnime) && (this->actionVar2++ > 20)) { if (!func_8083B040(this, play)) { func_8083A098(this, &gPlayerAnim_link_normal_heavy_carry_end, play); } @@ -9343,23 +9443,23 @@ void func_80846120(Player* this, PlayState* play) { heldActor->velocity.y = Math_CosS(heldActor->shape.rot.x) * 40.0f; heldActor->gravity = -2.0f; heldActor->minVelocityY = -30.0f; - func_808323B4(play, this); + Player_DetachHeldActor(play, this); return; } func_80832924(this, D_8085461C); } -void func_80846260(Player* this, PlayState* play) { +void Player_Action_80846260(Player* this, PlayState* play) { func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { - func_80832284(play, this, &gPlayerAnim_link_silver_wait); - this->unk_850 = 1; + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_silver_wait); + this->actionVar2 = 1; return; } - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { if (LinkAnimation_OnFrame(&this->skelAnime, 27.0f)) { Actor* interactRangeActor = this->interactRangeActor; @@ -9375,12 +9475,12 @@ void func_80846260(Player* this, PlayState* play) { } } else if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { - func_80835C58(play, this, func_80846358, 1); - func_80832264(play, this, &gPlayerAnim_link_silver_throw); + Player_SetupAction(play, this, Player_Action_80846358, 1); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_silver_throw); } } -void func_80846358(Player* this, PlayState* play) { +void Player_Action_80846358(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_80839F90(this, play); return; @@ -9398,16 +9498,16 @@ void func_80846358(Player* this, PlayState* play) { } } -void func_80846408(Player* this, PlayState* play) { +void Player_Action_80846408(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_80832284(play, this, &gPlayerAnim_link_normal_nocarry_free_wait); - this->unk_850 = 15; + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_normal_nocarry_free_wait); + this->actionVar2 = 15; return; } - if (this->unk_850 != 0) { - this->unk_850--; - if (this->unk_850 == 0) { + if (this->actionVar2 != 0) { + this->actionVar2--; + if (this->actionVar2 == 0) { func_8083A098(this, &gPlayerAnim_link_normal_nocarry_free_end, play); this->stateFlags1 &= ~PLAYER_STATE1_11; func_80832698(this, NA_SE_VO_LI_DAMAGE_S); @@ -9415,7 +9515,7 @@ void func_80846408(Player* this, PlayState* play) { } } -void func_808464B0(Player* this, PlayState* play) { +void Player_Action_808464B0(Player* this, PlayState* play) { func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -9437,7 +9537,7 @@ void func_808464B0(Player* this, PlayState* play) { } } -void func_80846578(Player* this, PlayState* play) { +void Player_Action_80846578(Player* this, PlayState* play) { f32 sp34; s16 sp32; @@ -9523,9 +9623,9 @@ void func_80846648(PlayState* play, Player* this) { } void func_80846660(PlayState* play, Player* this) { - func_80835C58(play, this, func_8084F710, 0); + Player_SetupAction(play, this, Player_Action_8084F710, 0); if ((play->sceneId == SCENE_LAKE_HYLIA) && IS_CUTSCENE_LAYER) { - this->unk_84F = 1; + this->actionVar1 = 1; } this->stateFlags1 |= PLAYER_STATE1_29; LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_okarina_warp_goal, 2.0f / 3.0f, 0.0f, 24.0f, @@ -9539,13 +9639,13 @@ void func_80846720(PlayState* play, Player* this, s32 arg2) { s32 item = D_808546F0[(void)0, gSaveContext.save.linkAge]; s32 itemAction = sItemActions[item]; - func_80835EFC(this); - func_808323B4(play, this); + Player_DestroyHookshot(this); + Player_DetachHeldActor(play, this); this->heldItemId = item; this->nextModelGroup = Player_ActionToModelGroup(this, itemAction); - func_8083399C(play, this, itemAction); + Player_InitItemAction(play, this, itemAction); func_80834644(play, this); if (arg2 != 0) { @@ -9556,30 +9656,31 @@ 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) { - func_80835C58(play, this, func_8084E9AC, 0); + Player_SetupAction(play, this, Player_Action_8084E9AC, 0); this->stateFlags1 |= PLAYER_STATE1_29; Math_Vec3f_Copy(&this->actor.world.pos, &D_808546F4); this->yaw = this->actor.shape.rot.y = -0x8000; LinkAnimation_Change(play, &this->skelAnime, this->ageProperties->unk_A0, 2.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); - func_80832F54(play, this, - FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | - ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplaceApplyFlags(play, this, + ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); if (LINK_IS_ADULT) { func_80846720(play, this, 0); } - this->unk_850 = 20; + this->actionVar2 = 20; } void func_808468A8(PlayState* play, Player* this) { - func_80835C58(play, this, func_8084F9A0, 0); - func_80832F54(play, this, - ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_SetupAction(play, this, Player_Action_8084F9A0, 0); + Player_AnimReplaceApplyFlags(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); } void func_808468E8(PlayState* play, Player* this) { func_808389E8(this, &gPlayerAnim_link_normal_jump, 12.0f, play); - func_80835C58(play, this, func_8084F9C0, 0); + Player_SetupAction(play, this, Player_Action_8084F9C0, 0); this->stateFlags1 |= PLAYER_STATE1_29; this->fallStartHeight = this->actor.world.pos.y; OnePointCutscene_Init(play, 5110, 40, &this->actor, CAM_ID_MAIN); @@ -9590,7 +9691,7 @@ void func_80846978(PlayState* play, Player* this) { } void func_808469BC(PlayState* play, Player* this) { - func_80835C58(play, this, func_8084F698, 0); + Player_SetupAction(play, this, Player_Action_8084F698, 0); this->actor.draw = NULL; this->stateFlags1 |= PLAYER_STATE1_29; } @@ -9604,7 +9705,7 @@ Actor* func_80846A00(PlayState* play, Player* this, s32 arg2) { void func_80846A68(PlayState* play, Player* this) { this->actor.draw = NULL; - func_80835C58(play, this, func_8085076C, 0); + Player_SetupAction(play, this, Player_Action_8085076C, 0); this->stateFlags1 |= PLAYER_STATE1_29; } @@ -9617,7 +9718,7 @@ static EffectBlureInit2 D_8085470C = { 0, 2, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, }; -static Vec3s D_80854730 = { -57, 3377, 0 }; +static Vec3s sSkeletonBaseTransl = { -57, 3377, 0 }; void Player_InitCommon(Player* this, PlayState* play, FlexSkeletonHeader* skelHeader) { this->ageProperties = &sAgeProperties[gSaveContext.save.linkAge]; @@ -9628,10 +9729,10 @@ void Player_InitCommon(Player* this, PlayState* play, FlexSkeletonHeader* skelHe SkelAnime_InitLink(play, &this->skelAnime, skelHeader, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType), 9, this->jointTable, this->morphTable, PLAYER_LIMB_MAX); - this->skelAnime.baseTransl = D_80854730; - SkelAnime_InitLink(play, &this->skelAnime2, skelHeader, func_80833338(this), 9, this->jointTable2, - this->morphTable2, PLAYER_LIMB_MAX); - this->skelAnime2.baseTransl = D_80854730; + this->skelAnime.baseTransl = sSkeletonBaseTransl; + SkelAnime_InitLink(play, &this->skelAnimeUpper, skelHeader, func_80833338(this), 9, this->jointTableUpper, + this->morphTableUpper, PLAYER_LIMB_MAX); + this->skelAnimeUpper.baseTransl = sSkeletonBaseTransl; Effect_Add(play, &this->meleeWeaponEffectIndex, EFFECT_BLURE2, 0, 0, &D_8085470C); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFeet, this->ageProperties->unk_04); @@ -9716,7 +9817,7 @@ void Player_Init(Actor* thisx, PlayState* play2) { this->itemAction = this->heldItemAction = -1; this->heldItemId = ITEM_NONE; - func_80835F44(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); Player_SetEquipmentData(play, this); this->prevBoots = this->currentBoots; Player_InitCommon(this, play, gPlayerSkelHeaders[((void)0, gSaveContext.save.linkAge)]); @@ -9892,7 +9993,7 @@ void func_808473D4(PlayState* play, Player* this) { if (this->unk_860 == 2) { doAction = DO_ACTION_REEL; } - } else if ((func_8084E3C4 != this->func_674) && !(this->stateFlags2 & PLAYER_STATE2_CRAWLING)) { + } else if ((Player_Action_8084E3C4 != this->actionFunc) && !(this->stateFlags2 & PLAYER_STATE2_CRAWLING)) { if ((this->doorType != PLAYER_DOORTYPE_NONE) && (!(this->stateFlags1 & PLAYER_STATE1_11) || ((heldActor != NULL) && (heldActor->id == ACTOR_EN_RU1)))) { @@ -9914,7 +10015,7 @@ void func_808473D4(PlayState* play, Player* this) { (!(this->stateFlags1 & PLAYER_STATE1_23) && (this->rideActor != NULL))) { doAction = DO_ACTION_CLIMB; } else if ((this->stateFlags1 & PLAYER_STATE1_23) && !EN_HORSE_CHECK_4((EnHorse*)this->rideActor) && - (func_8084D3E4 != this->func_674)) { + (Player_Action_8084D3E4 != this->actionFunc)) { if ((this->stateFlags2 & PLAYER_STATE2_1) && (this->targetActor != NULL)) { if (this->targetActor->category == ACTORCAT_NPC) { doAction = DO_ACTION_SPEAK; @@ -9957,7 +10058,7 @@ void func_808473D4(PlayState* play, Player* this) { !Player_IsChildWithHylianShield(this))) { if ((!(this->stateFlags1 & PLAYER_STATE1_14) && (sp20 <= 0) && (func_8008E9C4(this) || - ((D_808535E4 != FLOOR_TYPE_7) && + ((sFloorType != FLOOR_TYPE_7) && (func_80833B2C(this) || ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && !(this->stateFlags1 & PLAYER_STATE1_22) && (sp20 == 0))))))) { doAction = DO_ACTION_ATTACK; @@ -9995,8 +10096,18 @@ void func_808473D4(PlayState* play, Player* this) { } } -s32 func_80847A78(Player* this) { - s32 cond; +/** + * Updates state related to the Hover Boots. + * Handles a special case where the Hover Boots are able to activate when standing on certain floor types even if the + * player is standing on the ground. + * + * If the player is not on the ground, regardless of the usage of the Hover Boots, various floor related variables are + * reset. + * + * @return true if not on the ground, false otherwise. Note this is independent of the Hover Boots state. + */ +s32 Player_UpdateHoverBoots(Player* this) { + s32 canHoverOnGround; if ((this->currentBoots == PLAYER_BOOTS_HOVER) && (this->hoverBootsTimer != 0)) { this->hoverBootsTimer--; @@ -10004,90 +10115,108 @@ s32 func_80847A78(Player* this) { this->hoverBootsTimer = 0; } - cond = (this->currentBoots == PLAYER_BOOTS_HOVER) && - ((this->actor.yDistToWater >= 0.0f) || (func_80838144(D_808535E4) >= 0) || func_8083816C(D_808535E4)); + canHoverOnGround = + (this->currentBoots == PLAYER_BOOTS_HOVER) && + ((this->actor.yDistToWater >= 0.0f) || (func_80838144(sFloorType) >= 0) || func_8083816C(sFloorType)); - if (cond && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->hoverBootsTimer != 0)) { + if (canHoverOnGround && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->hoverBootsTimer != 0)) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - if (!cond) { + if (!canHoverOnGround) { this->hoverBootsTimer = 19; } + return false; + } else { + sFloorType = FLOOR_TYPE_0; + this->floorPitch = this->floorPitchAlt = sFloorShapePitch = 0; + + return true; } - - D_808535E4 = FLOOR_TYPE_0; - this->unk_898 = this->unk_89A = D_80853610 = 0; - - return true; } -static Vec3f D_80854798 = { 0.0f, 18.0f, 0.0f }; - -void func_80847BA0(PlayState* play, Player* this) { - u8 spC7 = 0; +/** + * Peforms various tasks related to scene collision. + * + * This includes: + * - Update BgCheckInfo, parameters adjusted due to various state flags + * - Update floor type, floor property and floor sfx offset + * - Update conveyor, reverb and light settings according to the current floor poly + * - Handle exits and voids + * - Update information relating to the "interact wall" + * - Update information for ledge climbing + * - Update hover boots + * - Calculate floor poly angles + * + */ +void Player_ProcessSceneCollision(PlayState* play, Player* this) { + static Vec3f sInteractWallCheckOffset = { 0.0f, 18.0f, 0.0f }; + u8 nextLedgeClimbType = PLAYER_LEDGE_CLIMB_NONE; CollisionPoly* floorPoly; - Vec3f spB4; - f32 spB0; - f32 spAC; - f32 spA8; - u32 spA4; + Vec3f unusedWorldPos; + f32 float0; // multi-purpose variable, see define names (fake match?) + f32 float1; // multi-purpose variable, see define names (fake match?) + f32 ceilingCheckHeight; + u32 flags; - D_80853604 = this->unk_A7A; + sPrevFloorProperty = this->floorProperty; + +#define vWallCheckRadius float0 +#define vWallCheckHeight float1 if (this->stateFlags2 & PLAYER_STATE2_CRAWLING) { - spB0 = 10.0f; - spAC = 15.0f; - spA8 = 30.0f; + vWallCheckRadius = 10.0f; + vWallCheckHeight = 15.0f; + ceilingCheckHeight = 30.0f; } else { - spB0 = this->ageProperties->unk_38; - spAC = 26.0f; - spA8 = this->ageProperties->unk_00; + vWallCheckRadius = this->ageProperties->wallCheckRadius; + vWallCheckHeight = 26.0f; + ceilingCheckHeight = this->ageProperties->ceilingCheckHeight; } if (this->stateFlags1 & (PLAYER_STATE1_29 | PLAYER_STATE1_31)) { if (this->stateFlags1 & PLAYER_STATE1_31) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; - spA4 = UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } else if ((this->stateFlags1 & PLAYER_STATE1_0) && ((this->unk_A84 - (s32)this->actor.world.pos.y) >= 100)) { - spA4 = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } else if (!(this->stateFlags1 & PLAYER_STATE1_0) && - ((func_80845EF8 == this->func_674) || (func_80845CA4 == this->func_674))) { + ((Player_Action_80845EF8 == this->actionFunc) || (Player_Action_80845CA4 == this->actionFunc))) { this->actor.bgCheckFlags &= ~(BGCHECKFLAG_WALL | BGCHECKFLAG_PLAYER_WALL_INTERACT); - spA4 = UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } else { - spA4 = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | - UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } } else { - spA4 = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | - UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } if (this->stateFlags3 & PLAYER_STATE3_0) { - spA4 &= ~(UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2); + flags &= ~(UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2); } - if (spA4 & UPDBGCHECKINFO_FLAG_2) { + if (flags & UPDBGCHECKINFO_FLAG_2) { this->stateFlags3 |= PLAYER_STATE3_4; } - Math_Vec3f_Copy(&spB4, &this->actor.world.pos); - Actor_UpdateBgCheckInfo(play, &this->actor, spAC, spB0, spA8, spA4); + Math_Vec3f_Copy(&unusedWorldPos, &this->actor.world.pos); + + Actor_UpdateBgCheckInfo(play, &this->actor, vWallCheckHeight, vWallCheckRadius, ceilingCheckHeight, flags); if (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) { this->actor.velocity.y = 0.0f; } - D_80853600 = this->actor.world.pos.y - this->actor.floorHeight; - sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; - + sYDistToFloor = this->actor.world.pos.y - this->actor.floorHeight; + sConveyorSpeed = CONVEYOR_SPEED_DISABLED; floorPoly = this->actor.floorPoly; if (floorPoly != NULL) { - this->unk_A7A = SurfaceType_GetFloorProperty(&play->colCtx, floorPoly, this->actor.floorBgId); + this->floorProperty = SurfaceType_GetFloorProperty(&play->colCtx, floorPoly, this->actor.floorBgId); this->prevFloorSfxOffset = this->floorSfxOffset; if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { @@ -10097,7 +10226,7 @@ void func_80847BA0(PlayState* play, Player* this) { this->floorSfxOffset = SURFACE_SFX_OFFSET_WATER_DEEP; } } else { - if (this->stateFlags2 & PLAYER_STATE2_9) { + if (this->stateFlags2 & PLAYER_STATE2_FORCE_SAND_FLOOR_SOUND) { this->floorSfxOffset = SURFACE_SFX_OFFSET_SAND; } else { this->floorSfxOffset = SurfaceType_GetSfxOffset(&play->colCtx, floorPoly, this->actor.floorBgId); @@ -10115,37 +10244,40 @@ void func_80847BA0(PlayState* play, Player* this) { } } - // This block extracts the conveyor properties from the floor poly - sConveyorSpeedIndex = SurfaceType_GetConveyorSpeed(&play->colCtx, floorPoly, this->actor.floorBgId); - if (sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { + sConveyorSpeed = SurfaceType_GetConveyorSpeed(&play->colCtx, floorPoly, this->actor.floorBgId); + + if (sConveyorSpeed != CONVEYOR_SPEED_DISABLED) { sIsFloorConveyor = SurfaceType_IsFloorConveyor(&play->colCtx, floorPoly, this->actor.floorBgId); + if ((!sIsFloorConveyor && (this->actor.yDistToWater > 20.0f) && (this->currentBoots != PLAYER_BOOTS_IRON)) || (sIsFloorConveyor && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { sConveyorYaw = CONVEYOR_DIRECTION_TO_BINANG( SurfaceType_GetConveyorDirection(&play->colCtx, floorPoly, this->actor.floorBgId)); } else { - sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; + sConveyorSpeed = CONVEYOR_SPEED_DISABLED; } } } - func_80839034(play, this, floorPoly, this->actor.floorBgId); + Player_HandleExitsAndVoids(play, this, floorPoly, this->actor.floorBgId); this->actor.bgCheckFlags &= ~BGCHECKFLAG_PLAYER_WALL_INTERACT; if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { CollisionPoly* wallPoly; s32 wallBgId; - s16 sp9A; + s16 yawDiff; s32 pad; - D_80854798.y = 18.0f; - D_80854798.z = this->ageProperties->unk_38 + 10.0f; + sInteractWallCheckOffset.y = 18.0f; + sInteractWallCheckOffset.z = this->ageProperties->wallCheckRadius + 10.0f; if (!(this->stateFlags2 & PLAYER_STATE2_CRAWLING) && - func_80839768(play, this, &D_80854798, &wallPoly, &wallBgId, &D_80858AA8)) { + Player_PosVsWallLineTest(play, this, &sInteractWallCheckOffset, &wallPoly, &wallBgId, + &sInteractWallCheckResult)) { this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_WALL_INTERACT; + if (this->actor.wallPoly != wallPoly) { this->actor.wallPoly = wallPoly; this->actor.wallBgId = wallBgId; @@ -10153,80 +10285,87 @@ void func_80847BA0(PlayState* play, Player* this) { } } - sp9A = this->actor.shape.rot.y - (s16)(this->actor.wallYaw + 0x8000); + yawDiff = this->actor.shape.rot.y - (s16)(this->actor.wallYaw + 0x8000); + sTouchedWallFlags = SurfaceType_GetWallFlags(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId); + sShapeYawToTouchedWall = ABS(yawDiff); - sInteractWallFlags = SurfaceType_GetWallFlags(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId); + yawDiff = this->yaw - (s16)(this->actor.wallYaw + 0x8000); + sWorldYawToTouchedWall = ABS(yawDiff); - D_80853608 = ABS(sp9A); +#define vSpeedScale float0 +#define vSpeedLimit float1 - sp9A = this->yaw - (s16)(this->actor.wallYaw + 0x8000); + vSpeedScale = sWorldYawToTouchedWall * 0.00008f; - D_8085360C = ABS(sp9A); - - spB0 = D_8085360C * 0.00008f; - if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || spB0 >= 1.0f) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || vSpeedScale >= 1.0f) { this->unk_880 = R_RUN_SPEED_LIMIT / 100.0f; } else { - spAC = (R_RUN_SPEED_LIMIT / 100.0f * spB0); - this->unk_880 = spAC; - if (spAC < 0.1f) { + vSpeedLimit = (R_RUN_SPEED_LIMIT / 100.0f * vSpeedScale); + this->unk_880 = vSpeedLimit; + + if (vSpeedLimit < 0.1f) { this->unk_880 = 0.1f; } } - if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (D_80853608 < 0x3000)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (sShapeYawToTouchedWall < 0x3000)) { CollisionPoly* wallPoly = this->actor.wallPoly; if (ABS(wallPoly->normal.y) < 600) { f32 wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); f32 wallPolyNormalY = COLPOLY_GET_NORMAL(wallPoly->normal.y); f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); - f32 wallHeight; - CollisionPoly* groundPoly; - CollisionPoly* sp78; - s32 sp74; - Vec3f sp68; - f32 sp64; - f32 sp60; - s32 temp3; + f32 yDistToLedge; + CollisionPoly* ledgeFloorPoly; + CollisionPoly* poly; + s32 bgId; + Vec3f ledgeCheckPos; + f32 ledgePosY; + f32 ceillingPosY; + s32 wallYawDiff; - this->wallDistance = Math3D_UDistPlaneToPos(wallPolyNormalX, wallPolyNormalY, wallPolyNormalZ, - wallPoly->dist, &this->actor.world.pos); + this->distToInteractWall = Math3D_UDistPlaneToPos(wallPolyNormalX, wallPolyNormalY, wallPolyNormalZ, + wallPoly->dist, &this->actor.world.pos); - spB0 = this->wallDistance + 10.0f; - sp68.x = this->actor.world.pos.x - (spB0 * wallPolyNormalX); - sp68.z = this->actor.world.pos.z - (spB0 * wallPolyNormalZ); - sp68.y = this->actor.world.pos.y + this->ageProperties->unk_0C; +#define vLedgeCheckOffsetXZ float0 - sp64 = BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &sp68); - wallHeight = sp64 - this->actor.world.pos.y; - this->wallHeight = wallHeight; + vLedgeCheckOffsetXZ = this->distToInteractWall + 10.0f; - if ((this->wallHeight < 18.0f) || - BgCheck_EntityCheckCeiling(&play->colCtx, &sp60, &this->actor.world.pos, - (sp64 - this->actor.world.pos.y) + 20.0f, &sp78, &sp74, &this->actor)) { - this->wallHeight = 399.96002f; + ledgeCheckPos.x = this->actor.world.pos.x - (vLedgeCheckOffsetXZ * wallPolyNormalX); + ledgeCheckPos.z = this->actor.world.pos.z - (vLedgeCheckOffsetXZ * wallPolyNormalZ); + ledgeCheckPos.y = this->actor.world.pos.y + this->ageProperties->unk_0C; + + ledgePosY = BgCheck_EntityRaycastDown1(&play->colCtx, &ledgeFloorPoly, &ledgeCheckPos); + yDistToLedge = ledgePosY - this->actor.world.pos.y; + this->yDistToLedge = yDistToLedge; + + if ((this->yDistToLedge < 18.0f) || + BgCheck_EntityCheckCeiling(&play->colCtx, &ceillingPosY, &this->actor.world.pos, + (ledgePosY - this->actor.world.pos.y) + 20.0f, &poly, &bgId, + &this->actor)) { + this->yDistToLedge = LEDGE_DIST_MAX; } else { - D_80854798.y = (sp64 + 5.0f) - this->actor.world.pos.y; + sInteractWallCheckOffset.y = (ledgePosY + 5.0f) - this->actor.world.pos.y; - if (func_80839768(play, this, &D_80854798, &sp78, &sp74, &D_80858AA8) && - (temp3 = this->actor.wallYaw - Math_Atan2S(sp78->normal.z, sp78->normal.x), - ABS(temp3) < 0x4000) && - !SurfaceType_CheckWallFlag1(&play->colCtx, sp78, sp74)) { - this->wallHeight = 399.96002f; + if (Player_PosVsWallLineTest(play, this, &sInteractWallCheckOffset, &poly, &bgId, + &sInteractWallCheckResult) && + (wallYawDiff = this->actor.wallYaw - Math_Atan2S(poly->normal.z, poly->normal.x), + ABS(wallYawDiff) < 0x4000) && + !SurfaceType_CheckWallFlag1(&play->colCtx, poly, bgId)) { + this->yDistToLedge = LEDGE_DIST_MAX; } else if (SurfaceType_CheckWallFlag0(&play->colCtx, wallPoly, this->actor.wallBgId) == 0) { - if (this->ageProperties->unk_1C <= this->wallHeight) { - if (ABS(groundPoly->normal.y) > 28000) { - if (this->ageProperties->unk_14 <= this->wallHeight) { - spC7 = 4; - } else if (this->ageProperties->unk_18 <= this->wallHeight) { - spC7 = 3; + if (this->ageProperties->unk_1C <= this->yDistToLedge) { + if (ABS(ledgeFloorPoly->normal.y) > 0x6D60) { + if (this->ageProperties->unk_14 <= this->yDistToLedge) { + nextLedgeClimbType = PLAYER_LEDGE_CLIMB_4; + } else if (this->ageProperties->unk_18 <= this->yDistToLedge) { + nextLedgeClimbType = PLAYER_LEDGE_CLIMB_3; } else { - spC7 = 2; + nextLedgeClimbType = PLAYER_LEDGE_CLIMB_2; } } } else { - spC7 = 1; + nextLedgeClimbType = PLAYER_LEDGE_CLIMB_1; } } } @@ -10234,29 +10373,29 @@ void func_80847BA0(PlayState* play, Player* this) { } } else { this->unk_880 = R_RUN_SPEED_LIMIT / 100.0f; - this->unk_88D = 0; - this->wallHeight = 0.0f; + this->ledgeClimbDelayTimer = 0; + this->yDistToLedge = 0.0f; } - if (spC7 == this->unk_88C) { - if ((this->speedXZ != 0.0f) && (this->unk_88D < 100)) { - this->unk_88D++; + if (nextLedgeClimbType == this->ledgeClimbType) { + if ((this->speedXZ != 0.0f) && (this->ledgeClimbDelayTimer < 100)) { + this->ledgeClimbDelayTimer++; } } else { - this->unk_88C = spC7; - this->unk_88D = 0; + this->ledgeClimbType = nextLedgeClimbType; + this->ledgeClimbDelayTimer = 0; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - D_808535E4 = SurfaceType_GetFloorType(&play->colCtx, floorPoly, this->actor.floorBgId); + sFloorType = SurfaceType_GetFloorType(&play->colCtx, floorPoly, this->actor.floorBgId); - if (!func_80847A78(this)) { + if (!Player_UpdateHoverBoots(this)) { f32 floorPolyNormalX; f32 invFloorPolyNormalY; f32 floorPolyNormalZ; - f32 sp4C; + f32 sin; s32 pad2; - f32 sp44; + f32 cos; s32 pad3; if (this->actor.floorBgId != BGCHECK_SCENE) { @@ -10267,31 +10406,31 @@ void func_80847BA0(PlayState* play, Player* this) { invFloorPolyNormalY = 1.0f / COLPOLY_GET_NORMAL(floorPoly->normal.y); floorPolyNormalZ = COLPOLY_GET_NORMAL(floorPoly->normal.z); - sp4C = Math_SinS(this->yaw); - sp44 = Math_CosS(this->yaw); + sin = Math_SinS(this->yaw); + cos = Math_CosS(this->yaw); - this->unk_898 = - Math_Atan2S(1.0f, (-(floorPolyNormalX * sp4C) - (floorPolyNormalZ * sp44)) * invFloorPolyNormalY); - this->unk_89A = - Math_Atan2S(1.0f, (-(floorPolyNormalX * sp44) - (floorPolyNormalZ * sp4C)) * invFloorPolyNormalY); + this->floorPitch = + Math_Atan2S(1.0f, (-(floorPolyNormalX * sin) - (floorPolyNormalZ * cos)) * invFloorPolyNormalY); + this->floorPitchAlt = + Math_Atan2S(1.0f, (-(floorPolyNormalX * cos) - (floorPolyNormalZ * sin)) * invFloorPolyNormalY); - sp4C = Math_SinS(this->actor.shape.rot.y); - sp44 = Math_CosS(this->actor.shape.rot.y); + sin = Math_SinS(this->actor.shape.rot.y); + cos = Math_CosS(this->actor.shape.rot.y); - D_80853610 = - Math_Atan2S(1.0f, (-(floorPolyNormalX * sp4C) - (floorPolyNormalZ * sp44)) * invFloorPolyNormalY); + sFloorShapePitch = + Math_Atan2S(1.0f, (-(floorPolyNormalX * sin) - (floorPolyNormalZ * cos)) * invFloorPolyNormalY); - func_8083E318(play, this, floorPoly); + Player_HandleSlopes(play, this, floorPoly); } } else { - func_80847A78(this); + Player_UpdateHoverBoots(this); } - if (this->unk_A7B == D_808535E4) { - this->unk_A79++; + if (this->prevFloorType == sFloorType) { + this->floorTypeTimer++; } else { - this->unk_A7B = D_808535E4; - this->unk_A79 = 0; + this->prevFloorType = sFloorType; + this->floorTypeTimer = 0; } } @@ -10310,7 +10449,7 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { if ((this->actor.parent != NULL) && (this->stateFlags3 & PLAYER_STATE3_7)) { camMode = CAM_MODE_HOOKSHOT_FLY; Camera_SetViewParam(Play_GetCamera(play, CAM_ID_MAIN), CAM_VIEW_TARGET, this->actor.parent); - } else if (func_8084377C == this->func_674) { + } else if (Player_Action_8084377C == this->actionFunc) { camMode = CAM_MODE_STILL; } else if (this->stateFlags2 & PLAYER_STATE2_8) { camMode = CAM_MODE_PUSH_PULL; @@ -10347,7 +10486,7 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { camMode = CAM_MODE_Z_PARALLEL; } } else if (this->stateFlags1 & (PLAYER_STATE1_18 | PLAYER_STATE1_21)) { - if ((func_80845668 == this->func_674) || (this->stateFlags1 & PLAYER_STATE1_21)) { + if ((Player_Action_80845668 == this->actionFunc) || (this->stateFlags1 & PLAYER_STATE1_21)) { camMode = CAM_MODE_WALL_CLIMB; } else { camMode = CAM_MODE_JUMP; @@ -10393,7 +10532,7 @@ void func_80848A04(PlayState* play, Player* this) { f32 temp; if (this->unk_85C == 0.0f) { - func_80835F44(play, this, 0xFF); + Player_UseItem(play, this, 0xFF); return; } @@ -10619,7 +10758,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { Actor_MoveXZGravity(&this->actor); } - func_80847BA0(play, this); + Player_ProcessSceneCollision(play, this); } else { f32 temp_f0; f32 phi_f12; @@ -10648,11 +10787,11 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { this->actor.parent = this->rideActor; func_8083A360(play, this); this->stateFlags1 |= PLAYER_STATE1_23; - func_80832264(play, this, &gPlayerAnim_link_uma_wait_1); - func_80832F54(play, this, - ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | - ANIM_FLAG_PLAYER_7); - this->unk_850 = 99; + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_uma_wait_1); + Player_AnimReplaceApplyFlags(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | + ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + this->actionVar2 = 99; } if (this->unk_844 == 0) { @@ -10677,7 +10816,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } if (!(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_7)) { - if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (D_808535E4 == FLOOR_TYPE_5) && + if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (sFloorType == FLOOR_TYPE_5) && (this->currentBoots != PLAYER_BOOTS_IRON)) || ((this->currentBoots == PLAYER_BOOTS_HOVER) && !(this->stateFlags1 & (PLAYER_STATE1_27 | PLAYER_STATE1_29)))) { @@ -10716,16 +10855,16 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { if ((this->pushedSpeed != 0.0f) && !Player_InCsMode(play) && !(this->stateFlags1 & (PLAYER_STATE1_13 | PLAYER_STATE1_14 | PLAYER_STATE1_21)) && - (func_80845668 != this->func_674) && (func_808507F4 != this->func_674)) { + (Player_Action_80845668 != this->actionFunc) && (Player_Action_808507F4 != this->actionFunc)) { this->actor.velocity.x += this->pushedSpeed * Math_SinS(this->pushedYaw); this->actor.velocity.z += this->pushedSpeed * Math_CosS(this->pushedYaw); } Actor_UpdatePos(&this->actor); - func_80847BA0(play, this); + Player_ProcessSceneCollision(play, this); } else { - D_808535E4 = FLOOR_TYPE_0; - this->unk_A7A = FLOOR_PROPERTY_0; + sFloorType = FLOOR_TYPE_0; + this->floorProperty = FLOOR_PROPERTY_0; if (!(this->stateFlags1 & PLAYER_STATE1_0) && (this->stateFlags1 & PLAYER_STATE1_23)) { EnHorse* rideActor = (EnHorse*)this->rideActor; @@ -10740,7 +10879,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { sp58 = rideActor->actor.floorBgId; } - if ((sp5C != NULL) && func_80839034(play, this, sp5C, sp58)) { + if ((sp5C != NULL) && Player_HandleExitsAndVoids(play, this, sp5C, sp58)) { if (DREG(25) != 0) { DREG(25) = 0; } else { @@ -10749,25 +10888,25 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } } - sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; + sConveyorSpeed = CONVEYOR_SPEED_DISABLED; this->pushedSpeed = 0.0f; } // This block applies the bg conveyor to pushedSpeed - if ((sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) && (this->currentBoots != PLAYER_BOOTS_IRON)) { + if ((sConveyorSpeed != CONVEYOR_SPEED_DISABLED) && (this->currentBoots != PLAYER_BOOTS_IRON)) { f32 conveyorSpeed; // converts 1-index to 0-index - sConveyorSpeedIndex--; + sConveyorSpeed--; if (!sIsFloorConveyor) { - conveyorSpeed = sWaterConveyorSpeeds[sConveyorSpeedIndex]; + conveyorSpeed = sWaterConveyorSpeeds[sConveyorSpeed]; if (!(this->stateFlags1 & PLAYER_STATE1_27)) { conveyorSpeed *= 0.25f; } } else { - conveyorSpeed = sFloorConveyorSpeeds[sConveyorSpeedIndex]; + conveyorSpeed = sFloorConveyorSpeeds[sConveyorSpeed]; } Math_StepToF(&this->pushedSpeed, conveyorSpeed, conveyorSpeed * 0.1f); @@ -10821,7 +10960,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { if ((this->csMode != PLAYER_CSMODE_7) || !(this->stateFlags1 & (PLAYER_STATE1_13 | PLAYER_STATE1_14 | PLAYER_STATE1_21 | PLAYER_STATE1_26))) { this->unk_6AD = 3; - } else if (func_80852E14 != this->func_674) { + } else if (Player_Action_80852E14 != this->actionFunc) { func_80852944(play, this, NULL); } } else { @@ -10836,8 +10975,8 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { this->stateFlags1 &= ~(PLAYER_STATE1_SWINGING_BOTTLE | PLAYER_STATE1_9 | PLAYER_STATE1_12 | PLAYER_STATE1_22); this->stateFlags2 &= ~(PLAYER_STATE2_0 | PLAYER_STATE2_2 | PLAYER_STATE2_3 | PLAYER_STATE2_5 | PLAYER_STATE2_6 | - PLAYER_STATE2_8 | PLAYER_STATE2_9 | PLAYER_STATE2_12 | PLAYER_STATE2_14 | - PLAYER_STATE2_DO_ACTION_ENTER | PLAYER_STATE2_22 | PLAYER_STATE2_26); + PLAYER_STATE2_8 | PLAYER_STATE2_FORCE_SAND_FLOOR_SOUND | PLAYER_STATE2_12 | + PLAYER_STATE2_14 | PLAYER_STATE2_DO_ACTION_ENTER | PLAYER_STATE2_22 | PLAYER_STATE2_26); this->stateFlags3 &= ~PLAYER_STATE3_4; func_80847298(this); @@ -10850,11 +10989,11 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } D_808535EC = 1.0f / D_808535E8; - D_80853614 = D_80853618 = 0; + sUseHeldItem = sHeldItemButtonIsHeldDown = 0; D_80858AA4 = this->currentMask; if (!(this->stateFlags3 & PLAYER_STATE3_2)) { - this->func_674(this, play); + this->actionFunc(this, play); } Player_UpdateCamAndSeqModes(play, this); @@ -10970,11 +11109,11 @@ void Player_Update(Actor* thisx, PlayState* play) { if (func_8084FCAC(this, play)) { #endif if (gSaveContext.dogParams < 0) { - if (Object_GetIndex(&play->objectCtx, OBJECT_DOG) < 0) { + if (Object_GetSlot(&play->objectCtx, OBJECT_DOG) < 0) { gSaveContext.dogParams = 0; } else { gSaveContext.dogParams &= 0x7FFF; - func_808395DC(this, &this->actor.world.pos, &D_80854838, &sDogSpawnPos); + Player_GetRelativePosition(this, &this->actor.world.pos, &D_80854838, &sDogSpawnPos); dogParams = gSaveContext.dogParams; dog = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_DOG, sDogSpawnPos.x, sDogSpawnPos.y, sDogSpawnPos.z, @@ -10990,7 +11129,7 @@ void Player_Update(Actor* thisx, PlayState* play) { } if ((this->heldActor != NULL) && (this->heldActor->update == NULL)) { - func_808323B4(play, this); + Player_DetachHeldActor(play, this); } if (this->stateFlags1 & (PLAYER_STATE1_5 | PLAYER_STATE1_29)) { @@ -11183,7 +11322,7 @@ void Player_Draw(Actor* thisx, PlayState* play2) { } if (this->stateFlags2 & PLAYER_STATE2_14) { - f32 scale = (this->unk_84F >> 1) * 22.0f; + f32 scale = (this->actionVar1 >> 1) * 22.0f; gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, (0 - play->gameplayFrames) % 128, 32, @@ -11340,7 +11479,7 @@ void func_8084B158(PlayState* play, Player* this, Input* input, f32 arg3) { LinkAnimation_Update(play, &this->skelAnime); } -void func_8084B1D8(Player* this, PlayState* play) { +void Player_Action_8084B1D8(Player* this, PlayState* play) { if (this->stateFlags1 & PLAYER_STATE1_27) { func_8084B000(this); func_8084AEEC(this, &this->speedXZ, 0, this->actor.shape.rot.y); @@ -11349,7 +11488,7 @@ void func_8084B1D8(Player* this, PlayState* play) { } if ((this->unk_6AD == 2) && (func_8002DD6C(this) || func_808332E4(this))) { - func_80836670(this, play); + Player_UpdateUpperBody(this, play); } if ((this->csMode != PLAYER_CSMODE_NONE) || (this->unk_6AD == 0) || (this->unk_6AD >= 4) || func_80833B54(this) || @@ -11361,7 +11500,7 @@ void func_8084B1D8(Player* this, PlayState* play) { BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)))) { func_8083C148(this, play); Sfx_PlaySfxCentered(NA_SE_SY_CAMERA_ZOOM_UP); - } else if ((DECR(this->unk_850) == 0) || (this->unk_6AD != 2)) { + } else if ((DECR(this->actionVar2) == 0) || (this->unk_6AD != 2)) { if (func_8008F128(this)) { this->unk_6AE |= 0x43; } else { @@ -11375,14 +11514,14 @@ void func_8084B1D8(Player* this, PlayState* play) { s32 func_8084B3CC(PlayState* play, Player* this) { if (play->shootingGalleryStatus != 0) { func_80832564(play, this); - func_80835C58(play, this, func_8084FA54, 0); + Player_SetupAction(play, this, Player_Action_8084FA54, 0); if (!func_8002DD6C(this) || Player_HoldsHookshot(this)) { - func_80835F44(play, this, 3); + Player_UseItem(play, this, 3); } this->stateFlags1 |= PLAYER_STATE1_20; - func_80832264(play, this, func_80833338(this)); + Player_AnimPlayOnce(play, this, func_80833338(this)); Player_ZeroSpeedXZ(this); func_8083B010(this); return 1; @@ -11408,9 +11547,9 @@ s32 func_8084B4D4(PlayState* play, Player* this) { return 0; } -void func_8084B530(Player* this, PlayState* play) { +void Player_Action_8084B530(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_5; - func_80836670(this, play); + Player_UpdateUpperBody(this, play); if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->actor.flags &= ~ACTOR_FLAG_8; @@ -11424,9 +11563,9 @@ void func_8084B530(Player* this, PlayState* play) { if (!func_8084B4D4(play, this) && !func_8084B3CC(play, this) && !func_8083ADD4(play, this)) { if ((this->targetActor != this->interactRangeActor) || !func_8083E5A8(this, play)) { if (this->stateFlags1 & PLAYER_STATE1_23) { - s32 sp24 = this->unk_850; + s32 sp24 = this->actionVar2; func_8083A360(play, this); - this->unk_850 = sp24; + this->actionVar2 = sp24; } else if (func_808332B8(this)) { func_80838F18(play, this); } else { @@ -11440,19 +11579,19 @@ void func_8084B530(Player* this, PlayState* play) { } if (this->stateFlags1 & PLAYER_STATE1_23) { - func_8084CC98(this, play); + Player_Action_8084CC98(this, play); } else if (func_808332B8(this)) { - func_8084D610(this, play); + Player_Action_8084D610(this, play); } else if (!func_8008E9C4(this) && LinkAnimation_Update(play, &this->skelAnime)) { if (this->skelAnime.moveFlags != 0) { func_80832DBC(this); if ((this->targetActor->category == ACTORCAT_NPC) && (this->heldItemAction != PLAYER_IA_FISHING_POLE)) { - func_808322D0(play, this, &gPlayerAnim_link_normal_talk_free); + Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_normal_talk_free); } else { - func_80832284(play, this, func_80833338(this)); + Player_AnimPlayLoop(play, this, func_80833338(this)); } } else { - func_808322A4(play, this, &gPlayerAnim_link_normal_talk_free_wait); + Player_AnimPlayLoopAdjusted(play, this, &gPlayerAnim_link_normal_talk_free_wait); } } @@ -11461,7 +11600,7 @@ void func_8084B530(Player* this, PlayState* play) { } } -void func_8084B78C(Player* this, PlayState* play) { +void Player_Action_8084B78C(Player* this, PlayState* play) { f32 sp34; s16 sp32; s32 temp; @@ -11497,7 +11636,7 @@ static struct_80832924 D_80854870[] = { { NA_SE_PL_SLIP, -0x1015 }, }; -void func_8084B898(Player* this, PlayState* play) { +void Player_Action_8084B898(Player* this, PlayState* play) { f32 sp34; s16 sp32; s32 temp; @@ -11505,8 +11644,8 @@ void func_8084B898(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_0 | PLAYER_STATE2_6 | PLAYER_STATE2_8; if (func_80832CB0(play, this, &gPlayerAnim_link_normal_pushing)) { - this->unk_850 = 1; - } else if (this->unk_850 == 0) { + this->actionVar2 = 1; + } else if (this->actionVar2 == 0) { if (LinkAnimation_OnFrame(&this->skelAnime, 11.0f)) { func_80832698(this, NA_SE_VO_LI_PUSH); } @@ -11540,7 +11679,7 @@ static struct_80832924 D_80854878[] = { static Vec3f D_80854880 = { 0.0f, 26.0f, -40.0f }; -void func_8084B9E4(Player* this, PlayState* play) { +void Player_Action_8084B9E4(Player* this, PlayState* play) { LinkAnimationHeader* anim; f32 sp70; s16 sp6E; @@ -11556,9 +11695,9 @@ void func_8084B9E4(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_0 | PLAYER_STATE2_6 | PLAYER_STATE2_8; if (func_80832CB0(play, this, anim)) { - this->unk_850 = 1; + this->actionVar2 = 1; } else { - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { if (LinkAnimation_OnFrame(&this->skelAnime, 11.0f)) { func_80832698(this, NA_SE_VO_LI_PUSH); } @@ -11596,7 +11735,7 @@ void func_8084B9E4(Player* this, PlayState* play) { } } -void func_8084BBE4(Player* this, PlayState* play) { +void Player_Action_8084BBE4(Player* this, PlayState* play) { f32 sp3C; s16 sp3A; LinkAnimationHeader* anim; @@ -11606,9 +11745,9 @@ void func_8084BBE4(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { // clang-format off - anim = (this->unk_84F > 0) ? &gPlayerAnim_link_normal_fall_wait : GET_PLAYER_ANIM(PLAYER_ANIMGROUP_jump_climb_wait, this->modelAnimType); func_80832284(play, this, anim); + anim = (this->actionVar1 > 0) ? &gPlayerAnim_link_normal_fall_wait : GET_PLAYER_ANIM(PLAYER_ANIMGROUP_jump_climb_wait, this->modelAnimType); Player_AnimPlayLoop(play, this, anim); // clang-format on - } else if (this->unk_84F == 0) { + } else if (this->actionVar1 == 0) { if (this->skelAnime.animation == &gPlayerAnim_link_normal_fall) { temp = 11.0f; } else { @@ -11618,19 +11757,19 @@ void func_8084BBE4(Player* this, PlayState* play) { if (LinkAnimation_OnFrame(&this->skelAnime, temp)) { func_80832770(this, NA_SE_PL_WALK_GROUND); if (this->skelAnime.animation == &gPlayerAnim_link_normal_fall) { - this->unk_84F = 1; + this->actionVar1 = 1; } else { - this->unk_84F = -1; + this->actionVar1 = -1; } } } Math_ScaledStepToS(&this->actor.shape.rot.y, this->yaw, 0x800); - if (this->unk_84F != 0) { + if (this->actionVar1 != 0) { func_80837268(this, &sp3C, &sp3A, 0.0f, play); if (this->unk_847[this->unk_846] >= 0) { - if (this->unk_84F > 0) { + if (this->actionVar1 > 0) { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_fall_up, this->modelAnimType); } else { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_jump_climb_up, this->modelAnimType); @@ -11641,7 +11780,7 @@ void func_8084BBE4(Player* this, PlayState* play) { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) || (this->actor.shape.feetFloorFlag != 0)) { func_80837B60(this); - if (this->unk_84F < 0) { + if (this->actionVar1 < 0) { this->speedXZ = -0.8f; } else { this->speedXZ = 0.8f; @@ -11652,7 +11791,7 @@ void func_8084BBE4(Player* this, PlayState* play) { } } -void func_8084BDFC(Player* this, PlayState* play) { +void Player_Action_8084BDFC(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_6; if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -11671,11 +11810,11 @@ void func_8084BDFC(Player* this, PlayState* play) { } void func_8084BEE4(Player* this) { - Player_PlaySfx(this, (this->unk_84F != 0) ? NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_VINE - : NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_WOOD); + Player_PlaySfx(this, (this->actionVar1 != 0) ? NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_VINE + : NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_WOOD); } -void func_8084BF1C(Player* this, PlayState* play) { +void Player_Action_8084BF1C(Player* this, PlayState* play) { static Vec3f D_8085488C = { 0.0f, 0.0f, 26.0f }; s32 sp84; s32 sp80; @@ -11694,7 +11833,7 @@ void func_8084BF1C(Player* this, PlayState* play) { this->fallStartHeight = this->actor.world.pos.y; this->stateFlags2 |= PLAYER_STATE2_6; - if ((this->unk_84F != 0) && (ABS(sp84) < ABS(sp80))) { + if ((this->actionVar1 != 0) && (ABS(sp84) < ABS(sp80))) { phi_f0 = ABS(sp80) * 0.0325f; sp84 = 0; } else { @@ -11716,7 +11855,7 @@ void func_8084BF1C(Player* this, PlayState* play) { this->skelAnime.playSpeed = phi_f2 * phi_f0; - if (this->unk_850 >= 0) { + if (this->actionVar2 >= 0) { if ((this->actor.wallPoly != NULL) && (this->actor.wallBgId != BGCHECK_SCENE)) { DynaPolyActor* wallPolyActor = DynaPoly_GetActor(&play->colCtx, this->actor.wallBgId); if (wallPolyActor != NULL) { @@ -11725,27 +11864,27 @@ void func_8084BF1C(Player* this, PlayState* play) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 6.0f, this->ageProperties->unk_00, + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 6.0f, this->ageProperties->ceilingCheckHeight, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2); func_8083F360(play, this, 26.0f, this->ageProperties->unk_3C, 50.0f, -20.0f); } - if ((this->unk_850 < 0) || !func_8083FBC0(this, play)) { + if ((this->actionVar2 < 0) || !func_8083FBC0(this, play)) { if (LinkAnimation_Update(play, &this->skelAnime) != 0) { - if (this->unk_850 < 0) { - this->unk_850 = ABS(this->unk_850) & 1; + if (this->actionVar2 < 0) { + this->actionVar2 = ABS(this->actionVar2) & 1; return; } if (sp84 != 0) { - sp68 = this->unk_84F + this->unk_850; + sp68 = this->actionVar1 + this->actionVar2; if (sp84 > 0) { D_8085488C.y = this->ageProperties->unk_40; temp_f0 = func_8083973C(play, this, &D_8085488C, &sp5C); if (this->actor.world.pos.y < temp_f0) { - if (this->unk_84F != 0) { + if (this->actionVar1 != 0) { this->actor.world.pos.y = temp_f0; this->stateFlags1 &= ~PLAYER_STATE1_21; func_8083A5C4(play, this, this->actor.wallPoly, this->ageProperties->unk_3C, @@ -11755,22 +11894,22 @@ void func_8084BF1C(Player* this, PlayState* play) { func_8083A9B8(this, &gPlayerAnim_link_normal_jump_climb_up_free, play); this->stateFlags1 |= PLAYER_STATE1_14; } else { - func_8083F070(this, this->ageProperties->unk_CC[this->unk_850], play); + func_8083F070(this, this->ageProperties->unk_CC[this->actionVar2], play); } } else { this->skelAnime.prevTransl = this->ageProperties->unk_4A[sp68]; - func_80832264(play, this, this->ageProperties->unk_AC[sp68]); + Player_AnimPlayOnce(play, this, this->ageProperties->unk_AC[sp68]); } } else { if ((this->actor.world.pos.y - this->actor.floorHeight) < 15.0f) { - if (this->unk_84F != 0) { + if (this->actionVar1 != 0) { func_8083FB7C(this, play); } else { - if (this->unk_850 != 0) { + if (this->actionVar2 != 0) { this->skelAnime.prevTransl = this->ageProperties->unk_44; } - func_8083F070(this, this->ageProperties->unk_C4[this->unk_850], play); - this->unk_850 = 1; + func_8083F070(this, this->ageProperties->unk_C4[this->actionVar2], play); + this->actionVar2 = 1; } } else { sp68 ^= 1; @@ -11780,16 +11919,16 @@ void func_8084BF1C(Player* this, PlayState* play) { ANIMMODE_ONCE, 0.0f); } } - this->unk_850 ^= 1; + this->actionVar2 ^= 1; } else { - if ((this->unk_84F != 0) && (sp80 != 0)) { - anim2 = this->ageProperties->unk_BC[this->unk_850]; + if ((this->actionVar1 != 0) && (sp80 != 0)) { + anim2 = this->ageProperties->unk_BC[this->actionVar2]; if (sp80 > 0) { - this->skelAnime.prevTransl = this->ageProperties->unk_7A[this->unk_850]; - func_80832264(play, this, anim2); + this->skelAnime.prevTransl = this->ageProperties->unk_7A[this->actionVar2]; + Player_AnimPlayOnce(play, this, anim2); } else { - this->skelAnime.prevTransl = this->ageProperties->unk_86[this->unk_850]; + this->skelAnime.prevTransl = this->ageProperties->unk_86[this->actionVar2]; LinkAnimation_Change(play, &this->skelAnime, anim2, -1.0f, Animation_GetLastFrame(anim2), 0.0f, ANIMMODE_ONCE, 0.0f); } @@ -11802,10 +11941,10 @@ void func_8084BF1C(Player* this, PlayState* play) { } } - if (this->unk_850 < 0) { - if (((this->unk_850 == -2) && + if (this->actionVar2 < 0) { + if (((this->actionVar2 == -2) && (LinkAnimation_OnFrame(&this->skelAnime, 14.0f) || LinkAnimation_OnFrame(&this->skelAnime, 29.0f))) || - ((this->unk_850 == -4) && + ((this->actionVar2 == -4) && (LinkAnimation_OnFrame(&this->skelAnime, 22.0f) || LinkAnimation_OnFrame(&this->skelAnime, 35.0f) || LinkAnimation_OnFrame(&this->skelAnime, 49.0f) || LinkAnimation_OnFrame(&this->skelAnime, 55.0f)))) { func_8084BEE4(this); @@ -11827,7 +11966,7 @@ static struct_80832924 D_808548A8[] = { { NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_WOOD, -0x81E }, }; -void func_8084C5F8(Player* this, PlayState* play) { +void Player_Action_8084C5F8(Player* this, PlayState* play) { s32 temp; f32* sp38; CollisionPoly* groundPoly; @@ -11851,7 +11990,7 @@ void func_8084C5F8(Player* this, PlayState* play) { sp38 = D_80854898; - if (this->unk_850 != 0) { + if (this->actionVar2 != 0) { func_80832924(this, D_808548A8); sp38 = D_808548A0; } @@ -11879,7 +12018,7 @@ static struct_80832924 D_808548B4[] = { * Update player's animation while entering the crawlspace. * Once inside, stop all player animations and update player's movement. */ -void func_8084C760(Player* this, PlayState* play) { +void Player_Action_8084C760(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_6; if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -11910,7 +12049,7 @@ static struct_80832924 D_808548D8[] = { /** * Update player's animation while leaving the crawlspace. */ -void func_8084C81C(Player* this, PlayState* play) { +void Player_Action_8084C81C(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_6; if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -11953,8 +12092,9 @@ s32 func_8084C89C(PlayState* play, Player* this, s32 arg2, f32* arg3) { *arg3 = func_8083973C(play, this, &D_808548FC[arg2], &sp40); - return (sp4C < *arg3) && (*arg3 < sp50) && !func_80839768(play, this, &D_80854914[arg2], &sp30, &sp2C, &sp34) && - !func_80839768(play, this, &D_8085492C[arg2], &sp30, &sp2C, &sp34); + return (sp4C < *arg3) && (*arg3 < sp50) && + !Player_PosVsWallLineTest(play, this, &D_80854914[arg2], &sp30, &sp2C, &sp34) && + !Player_PosVsWallLineTest(play, this, &D_8085492C[arg2], &sp30, &sp2C, &sp34); } s32 func_8084C9BC(Player* this, PlayState* play) { @@ -11962,8 +12102,8 @@ s32 func_8084C9BC(Player* this, PlayState* play) { s32 sp38; f32 sp34; - if (this->unk_850 < 0) { - this->unk_850 = 99; + if (this->actionVar2 < 0) { + this->actionVar2 = 99; } else { sp38 = (this->mountSide < 0) ? 0 : 1; if (!func_8084C89C(play, this, sp38, &sp34)) { @@ -11982,11 +12122,11 @@ s32 func_8084C9BC(Player* this, PlayState* play) { if (EN_HORSE_CHECK_1(rideActor) || (EN_HORSE_CHECK_4(rideActor) && CHECK_BTN_ALL(sControlInput->press.button, BTN_A))) { rideActor->actor.child = NULL; - func_80835DAC(play, this, func_8084D3E4, 0); + func_80835DAC(play, this, Player_Action_8084D3E4, 0); this->unk_878 = sp34 - rideActor->actor.world.pos.y; - func_80832264(play, this, - (this->mountSide < 0) ? &gPlayerAnim_link_uma_left_down - : &gPlayerAnim_link_uma_right_down); + Player_AnimPlayOnce(play, this, + (this->mountSide < 0) ? &gPlayerAnim_link_uma_left_down + : &gPlayerAnim_link_uma_right_down); return 1; } } @@ -12058,7 +12198,7 @@ static struct_80832924 D_808549A4[] = { { NA_SE_PL_CALM_PAT, 0x884 }, { NA_SE_PL_CALM_PAT, -0x888 }, }; -void func_8084CC98(Player* this, PlayState* play) { +void Player_Action_8084CC98(Player* this, PlayState* play) { EnHorse* rideActor = (EnHorse*)this->rideActor; u8* arr; @@ -12066,10 +12206,10 @@ void func_8084CC98(Player* this, PlayState* play) { func_8084CBF4(this, 1.0f, 10.0f); - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { if (LinkAnimation_Update(play, &this->skelAnime)) { this->skelAnime.animation = &gPlayerAnim_link_uma_wait_1; - this->unk_850 = 99; + this->actionVar2 = 99; return; } @@ -12092,34 +12232,34 @@ void func_8084CC98(Player* this, PlayState* play) { func_8002DE74(play, this); this->skelAnime.prevTransl = D_8085499C; - if ((rideActor->animationIdx != this->unk_850) && ((rideActor->animationIdx >= 2) || (this->unk_850 >= 2))) { - if ((this->unk_850 = rideActor->animationIdx) < 2) { + if ((rideActor->animationIdx != this->actionVar2) && ((rideActor->animationIdx >= 2) || (this->actionVar2 >= 2))) { + if ((this->actionVar2 = rideActor->animationIdx) < 2) { f32 rand = Rand_ZeroOne(); s32 temp = 0; - this->unk_850 = 1; + this->actionVar2 = 1; if (rand < 0.1f) { temp = 2; } else if (rand < 0.2f) { temp = 1; } - func_80832264(play, this, D_8085498C[temp]); + Player_AnimPlayOnce(play, this, D_8085498C[temp]); } else { - this->skelAnime.animation = D_80854944[this->unk_850 - 2]; + this->skelAnime.animation = D_80854944[this->actionVar2 - 2]; Animation_SetMorph(play, &this->skelAnime, 8.0f); - if (this->unk_850 < 4) { + if (this->actionVar2 < 4) { func_80834644(play, this); - this->unk_84F = 0; + this->actionVar1 = 0; } } } - if (this->unk_850 == 1) { + if (this->actionVar2 == 1) { if ((D_808535E0 != 0) || func_8083224C(play)) { - func_80832264(play, this, &gPlayerAnim_link_uma_wait_3); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_uma_wait_3); } else if (LinkAnimation_Update(play, &this->skelAnime)) { - this->unk_850 = 99; + this->actionVar2 = 99; } else if (this->skelAnime.animation == &gPlayerAnim_link_uma_wait_1) { func_80832924(this, D_808549A4); } @@ -12136,11 +12276,11 @@ void func_8084CC98(Player* this, PlayState* play) { this->csMode = PLAYER_CSMODE_NONE; } this->unk_6AD = 0; - this->unk_84F = 0; - } else if ((this->unk_850 < 2) || (this->unk_850 >= 4)) { - D_808535E0 = func_80836670(this, play); + this->actionVar1 = 0; + } else if ((this->actionVar2 < 2) || (this->actionVar2 >= 4)) { + D_808535E0 = Player_UpdateUpperBody(this, play); if (D_808535E0 != 0) { - this->unk_84F = 0; + this->actionVar1 = 0; } } @@ -12154,28 +12294,28 @@ void func_8084CC98(Player* this, PlayState* play) { (!func_8083224C(play) && ((rideActor->actor.speed != 0.0f) || !func_8083B644(this, play)) && !func_8083C1DC(this, play))) { if (D_808535E0 == 0) { - if (this->unk_84F != 0) { - if (LinkAnimation_Update(play, &this->skelAnime2)) { + if (this->actionVar1 != 0) { + if (LinkAnimation_Update(play, &this->skelAnimeUpper)) { rideActor->stateFlags &= ~ENHORSE_FLAG_8; - this->unk_84F = 0; + this->actionVar1 = 0; } - if (this->skelAnime2.animation == &gPlayerAnim_link_uma_stop_muti) { - if (LinkAnimation_OnFrame(&this->skelAnime2, 23.0f)) { + if (this->skelAnimeUpper.animation == &gPlayerAnim_link_uma_stop_muti) { + if (LinkAnimation_OnFrame(&this->skelAnimeUpper, 23.0f)) { Player_PlaySfx(this, NA_SE_IT_LASH); func_80832698(this, NA_SE_VO_LI_LASH); } AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable); + this->skelAnimeUpper.jointTable); } else { - if (LinkAnimation_OnFrame(&this->skelAnime2, 10.0f)) { + if (LinkAnimation_OnFrame(&this->skelAnimeUpper, 10.0f)) { Player_PlaySfx(this, NA_SE_IT_LASH); func_80832698(this, NA_SE_VO_LI_LASH); } AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable, D_80853410); + this->skelAnimeUpper.jointTable, sUpperBodyLimbCopyMap); } } else { LinkAnimationHeader* anim = NULL; @@ -12183,14 +12323,14 @@ void func_8084CC98(Player* this, PlayState* play) { if (EN_HORSE_CHECK_3(rideActor)) { anim = &gPlayerAnim_link_uma_stop_muti; } else if (EN_HORSE_CHECK_2(rideActor)) { - if ((this->unk_850 >= 2) && (this->unk_850 != 99)) { - anim = D_80854968[this->unk_850 - 2]; + if ((this->actionVar2 >= 2) && (this->actionVar2 != 99)) { + anim = D_80854968[this->actionVar2 - 2]; } } if (anim != NULL) { - LinkAnimation_PlayOnce(play, &this->skelAnime2, anim); - this->unk_84F = 1; + LinkAnimation_PlayOnce(play, &this->skelAnimeUpper, anim); + this->actionVar1 = 1; } } } @@ -12236,7 +12376,7 @@ static struct_80832924 D_808549C4[] = { { NA_SE_PL_SLIPDOWN, -0x819 }, }; -void func_8084D3E4(Player* this, PlayState* play) { +void Player_Action_8084D3E4(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_6; func_8084CBF4(this, 1.0f, 10.0f); @@ -12276,17 +12416,17 @@ void func_8084D530(Player* this, f32* arg1, f32 arg2, s16 arg3) { } void func_8084D574(PlayState* play, Player* this, s16 arg2) { - func_80835C58(play, this, func_8084D84C, 0); + Player_SetupAction(play, this, Player_Action_8084D84C, 0); this->actor.shape.rot.y = this->yaw = arg2; - func_80832C6C(play, this, &gPlayerAnim_link_swimer_swim); + Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim); } void func_8084D5CC(PlayState* play, Player* this) { - func_80835C58(play, this, func_8084DAB4, 0); - func_80832C6C(play, this, &gPlayerAnim_link_swimer_swim); + Player_SetupAction(play, this, Player_Action_8084DAB4, 0); + Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim); } -void func_8084D610(Player* this, PlayState* play) { +void Player_Action_8084D610(Player* this, PlayState* play) { f32 sp34; s16 sp32; @@ -12329,20 +12469,20 @@ void func_8084D610(Player* this, PlayState* play) { } } -void func_8084D7C4(Player* this, PlayState* play) { +void Player_Action_8084D7C4(Player* this, PlayState* play) { if (!func_8083B040(this, play)) { this->stateFlags2 |= PLAYER_STATE2_5; func_8084B158(play, this, NULL, this->speedXZ); func_8084B000(this); - if (DECR(this->unk_850) == 0) { + if (DECR(this->actionVar2) == 0) { func_80838F18(play, this); } } } -void func_8084D84C(Player* this, PlayState* play) { +void Player_Action_8084D84C(Player* this, PlayState* play) { f32 sp34; s16 sp32; s16 temp; @@ -12397,14 +12537,14 @@ s32 func_8084D980(PlayState* play, Player* this, f32* arg2, s16* arg3) { } if (anim != this->skelAnime.animation) { - func_80832C6C(play, this, anim); + Player_AnimChangeLoopSlowMorph(play, this, anim); return 1; } return 0; } -void func_8084DAB4(Player* this, PlayState* play) { +void Player_Action_8084DAB4(Player* this, PlayState* play) { f32 sp2C; s16 sp2A; @@ -12435,12 +12575,12 @@ void func_8084DBC4(PlayState* play, Player* this, f32 arg2) { func_8084AEEC(this, &this->actor.velocity.y, arg2, this->yaw); } -void func_8084DC48(Player* this, PlayState* play) { +void Player_Action_8084DC48(Player* this, PlayState* play) { f32 sp2C; this->stateFlags2 |= PLAYER_STATE2_5; this->actor.gravity = 0.0f; - func_80836670(this, play); + Player_UpdateUpperBody(this, play); if (!func_8083B040(this, play)) { if (this->currentBoots == PLAYER_BOOTS_IRON) { @@ -12448,8 +12588,8 @@ void func_8084DC48(Player* this, PlayState* play) { return; } - if (this->unk_84F == 0) { - if (this->unk_850 == 0) { + if (this->actionVar1 == 0) { + if (this->actionVar2 == 0) { if (LinkAnimation_Update(play, &this->skelAnime) || ((this->skelAnime.curFrame >= 22.0f) && !CHECK_BTN_ALL(sControlInput->cur.button, BTN_A))) { func_8083D330(play, this); @@ -12469,20 +12609,20 @@ void func_8084DC48(Player* this, PlayState* play) { (this->actor.yDistToWater < D_80854784[CUR_UPG_VALUE(UPG_SCALE)])) { func_8084DBC4(play, this, -2.0f); } else { - this->unk_84F++; - func_80832C6C(play, this, &gPlayerAnim_link_swimer_swim_wait); + this->actionVar1++; + Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim_wait); } - } else if (this->unk_84F == 1) { + } else if (this->actionVar1 == 1) { LinkAnimation_Update(play, &this->skelAnime); func_8084B000(this); if (this->unk_6C2 < 10000) { - this->unk_84F++; - this->unk_850 = this->actor.yDistToWater; - func_80832C6C(play, this, &gPlayerAnim_link_swimer_swim); + this->actionVar1++; + this->actionVar2 = this->actor.yDistToWater; + Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim); } } else if (!func_8083D12C(play, this, sControlInput)) { - sp2C = (this->unk_850 * 0.018f) + 4.0f; + sp2C = (this->actionVar2 * 0.018f) + 4.0f; if (this->stateFlags1 & PLAYER_STATE1_11) { sControlInput = NULL; @@ -12523,9 +12663,9 @@ s32 func_8084DFF4(PlayState* play, Player* this) { return 1; } - if (this->unk_84F == 0) { + if (this->actionVar1 == 0) { giEntry = &sGetItemTable[this->getItemId - 1]; - this->unk_84F = 1; + this->actionVar1 = 1; Message_StartTextbox(play, giEntry->textId, &this->actor); Item_Give(play, giEntry->itemId); @@ -12563,7 +12703,7 @@ s32 func_8084DFF4(PlayState* play, Player* this) { return 0; } -void func_8084E1EC(Player* this, PlayState* play) { +void Player_Action_8084E1EC(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_5; if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -12586,7 +12726,7 @@ void func_8084E1EC(Player* this, PlayState* play) { func_8084AEEC(this, &this->speedXZ, 0.0f, this->actor.shape.rot.y); } -void func_8084E30C(Player* this, PlayState* play) { +void Player_Action_8084E30C(Player* this, PlayState* play) { func_8084B000(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -12596,7 +12736,7 @@ void func_8084E30C(Player* this, PlayState* play) { func_8084AEEC(this, &this->speedXZ, 0.0f, this->actor.shape.rot.y); } -void func_8084E368(Player* this, PlayState* play) { +void Player_Action_8084E368(Player* this, PlayState* play) { func_8084B000(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -12615,10 +12755,10 @@ static s16 sWarpSongEntrances[] = { ENTR_TEMPLE_OF_TIME_7, }; -void func_8084E3C4(Player* this, PlayState* play) { +void Player_Action_8084E3C4(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_808322A4(play, this, &gPlayerAnim_link_normal_okarina_swing); - this->unk_850 = 1; + Player_AnimPlayLoopAdjusted(play, this, &gPlayerAnim_link_normal_okarina_swing); + this->actionVar2 = 1; if (this->stateFlags2 & (PLAYER_STATE2_23 | PLAYER_STATE2_25)) { this->stateFlags2 |= PLAYER_STATE2_24; } else { @@ -12627,7 +12767,7 @@ void func_8084E3C4(Player* this, PlayState* play) { return; } - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { return; } @@ -12670,7 +12810,7 @@ void func_8084E3C4(Player* this, PlayState* play) { } } -void func_8084E604(Player* this, PlayState* play) { +void Player_Action_8084E604(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_8083A098(this, &gPlayerAnim_link_normal_light_bom_end, play); } else if (LinkAnimation_OnFrame(&this->skelAnime, 3.0f)) { @@ -12691,16 +12831,16 @@ static struct_80832924 D_808549E0[] = { { 0, -0x287B }, }; -void func_8084E6D4(Player* this, PlayState* play) { +void Player_Action_8084E6D4(Player* this, PlayState* play) { s32 cond; if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_850 != 0) { - if (this->unk_850 >= 2) { - this->unk_850--; + if (this->actionVar2 != 0) { + if (this->actionVar2 >= 2) { + this->actionVar2--; } - if (func_8084DFF4(play, this) && (this->unk_850 == 1)) { + if (func_8084DFF4(play, this) && (this->actionVar2 == 1)) { cond = ((this->targetActor != NULL) && (this->exchangeItemId < 0)) || (this->stateFlags3 & PLAYER_STATE3_5); @@ -12735,16 +12875,16 @@ void func_8084E6D4(Player* this, PlayState* play) { } if (this->skelAnime.animation == &gPlayerAnim_link_normal_box_kick) { - func_808322D0(play, this, &gPlayerAnim_link_demo_get_itemB); + Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_demo_get_itemB); } else { - func_808322D0(play, this, &gPlayerAnim_link_demo_get_itemA); + Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_demo_get_itemA); } - this->unk_850 = 2; + this->actionVar2 = 2; func_80835EA4(play, 9); } } else { - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { if (!LINK_IS_ADULT) { func_80832924(this, D_808549E0); } @@ -12774,11 +12914,11 @@ static struct_80832924 D_808549F4[] = { { 0, -0x280F }, }; -void func_8084E9AC(Player* this, PlayState* play) { +void Player_Action_8084E9AC(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_84F == 0) { - if (DECR(this->unk_850) == 0) { - this->unk_84F = 1; + if (this->actionVar1 == 0) { + if (DECR(this->actionVar2) == 0) { + this->actionVar1 = 1; this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; } } else { @@ -12802,9 +12942,9 @@ static u8 D_808549FC[] = { 0x01, 0x03, 0x02, 0x04, 0x04, }; -void func_8084EAC0(Player* this, PlayState* play) { +void Player_Action_8084EAC0(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { if (this->itemAction == PLAYER_IA_BOTTLE_POE) { s32 rand = Rand_S16Offset(-1, 3); @@ -12837,21 +12977,21 @@ void func_8084EAC0(Player* this, PlayState* play) { } } - func_808322A4(play, this, &gPlayerAnim_link_bottle_drink_demo_wait); - this->unk_850 = 1; + Player_AnimPlayLoopAdjusted(play, this, &gPlayerAnim_link_bottle_drink_demo_wait); + this->actionVar2 = 1; return; } func_8083C0E8(this, play); func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); - } else if (this->unk_850 == 1) { + } else if (this->actionVar2 == 1) { if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { - func_80832B78(play, this, &gPlayerAnim_link_bottle_drink_demo_end); - this->unk_850 = 2; + Player_AnimChangeOnceMorphAdjusted(play, this, &gPlayerAnim_link_bottle_drink_demo_end); + this->actionVar2 = 2; Player_UpdateBottleHeld(play, this, ITEM_BOTTLE_EMPTY, PLAYER_IA_BOTTLE); } func_80832698(this, NA_SE_VO_LI_DRINK - SFX_FLAG); - } else if ((this->unk_850 == 2) && LinkAnimation_OnFrame(&this->skelAnime, 29.0f)) { + } else if ((this->actionVar2 == 2) && LinkAnimation_OnFrame(&this->skelAnime, 29.0f)) { func_80832698(this, NA_SE_VO_LI_BREATH_DRINK); } } @@ -12863,35 +13003,35 @@ static BottleCatchInfo sBottleCatchInfos[] = { { ACTOR_EN_INSECT, ITEM_BOTTLE_BUG, PLAYER_IA_BOTTLE_BUG, 0x7A }, }; -void func_8084ECA4(Player* this, PlayState* play) { +void Player_Action_8084ECA4(Player* this, PlayState* play) { struct_80854554* sp24; BottleCatchInfo* catchInfo; s32 temp; s32 i; - sp24 = &D_80854554[this->unk_850]; + sp24 = &D_80854554[this->actionVar2]; func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_84F != 0) { - if (this->unk_850 == 0) { - Message_StartTextbox(play, sBottleCatchInfos[this->unk_84F - 1].textId, &this->actor); + if (this->actionVar1 != 0) { + if (this->actionVar2 == 0) { + Message_StartTextbox(play, sBottleCatchInfos[this->actionVar1 - 1].textId, &this->actor); Audio_PlayFanfare(NA_BGM_ITEM_GET | 0x900); - this->unk_850 = 1; + this->actionVar2 = 1; } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { - this->unk_84F = 0; + this->actionVar1 = 0; func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); } } else { func_8083C0E8(this, play); } } else { - if (this->unk_84F == 0) { + if (this->actionVar1 == 0) { temp = this->skelAnime.curFrame - sp24->unk_08; if (temp >= 0) { if (sp24->unk_09 >= temp) { - if (this->unk_850 != 0) { + if (this->actionVar2 != 0) { if (temp == 0) { Player_PlaySfx(this, NA_SE_IT_SCOOP_UP_WATER); } @@ -12906,12 +13046,12 @@ void func_8084ECA4(Player* this, PlayState* play) { } if (i < ARRAY_COUNT(sBottleCatchInfos)) { - this->unk_84F = i + 1; - this->unk_850 = 0; + this->actionVar1 = i + 1; + this->actionVar2 = 0; this->stateFlags1 |= PLAYER_STATE1_28 | PLAYER_STATE1_29; this->interactRangeActor->parent = &this->actor; Player_UpdateBottleHeld(play, this, catchInfo->itemId, ABS(catchInfo->itemAction)); - func_808322D0(play, this, sp24->unk_04); + Player_AnimPlayOnceAdjusted(play, this, sp24->unk_04); func_80835EA4(play, 4); } } @@ -12920,9 +13060,9 @@ void func_8084ECA4(Player* this, PlayState* play) { } } - //! @bug If the animation is changed at any point above (such as by func_8083C0E8() or func_808322D0()), it will - //! change the curFrame to 0. This causes this flag to be set for one frame, at a time when it does not look like - //! Player is swinging the bottle. + //! @bug If the animation is changed at any point above (such as by func_8083C0E8() or + //! Player_AnimPlayOnceAdjusted()), it will change the curFrame to 0. This causes this flag to be set for one frame, + //! at a time when it does not look like Player is swinging the bottle. if (this->skelAnime.curFrame <= 7.0f) { this->stateFlags1 |= PLAYER_STATE1_SWINGING_BOTTLE; } @@ -12930,7 +13070,7 @@ void func_8084ECA4(Player* this, PlayState* play) { static Vec3f D_80854A1C = { 0.0f, 0.0f, 5.0f }; -void func_8084EED8(Player* this, PlayState* play) { +void Player_Action_8084EED8(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_8083C0E8(this, play); func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); @@ -12958,7 +13098,7 @@ static struct_80832924 D_80854A34[] = { { NA_SE_EV_BOTTLE_CAP_OPEN, -0x828 }, }; -void func_8084EFC0(Player* this, PlayState* play) { +void Player_Action_8084EFC0(Player* this, PlayState* play) { func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -12986,11 +13126,11 @@ static struct_80832924 D_80854A3C[] = { { NA_SE_PL_PUT_OUT_ITEM, -0x81E }, }; -void func_8084F104(Player* this, PlayState* play) { +void Player_Action_8084F104(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_5; if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_850 < 0) { + if (this->actionVar2 < 0) { func_8083C0E8(this, play); } else if (this->exchangeItemId == EXCH_ITEM_NONE) { Actor* targetActor = this->targetActor; @@ -13008,21 +13148,21 @@ void func_8084F104(Player* this, PlayState* play) { this->unk_862 = ABS(giEntry->gi); } - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { Message_StartTextbox(play, this->actor.textId, &this->actor); if ((this->itemAction == PLAYER_IA_CHICKEN) || (this->itemAction == PLAYER_IA_POCKET_CUCCO)) { Player_PlaySfx(this, NA_SE_EV_CHICKEN_CRY_M); } - this->unk_850 = 1; + this->actionVar2 = 1; } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->actor.flags &= ~ACTOR_FLAG_8; this->unk_862 = 0; - if (this->unk_84F == 1) { - func_80832264(play, this, &gPlayerAnim_link_bottle_read_end); - this->unk_850 = -1; + if (this->actionVar1 == 1) { + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_bottle_read_end); + this->actionVar2 = -1; } else { func_8083C0E8(this, play); } @@ -13030,20 +13170,20 @@ void func_8084F104(Player* this, PlayState* play) { func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); } } - } else if (this->unk_850 >= 0) { + } else if (this->actionVar2 >= 0) { func_80832924(this, D_80854A3C); } - if ((this->unk_84F == 0) && (this->unk_664 != NULL)) { + if ((this->actionVar1 == 0) && (this->unk_664 != NULL)) { this->yaw = this->actor.shape.rot.y = func_8083DB98(this, 0); } } -void func_8084F308(Player* this, PlayState* play) { +void Player_Action_8084F308(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_5 | PLAYER_STATE2_6; if (LinkAnimation_Update(play, &this->skelAnime)) { - func_80832284(play, this, &gPlayerAnim_link_normal_re_dead_attack_wait); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_normal_re_dead_attack_wait); } if (func_80832594(this, 0, 100)) { @@ -13052,7 +13192,7 @@ void func_8084F308(Player* this, PlayState* play) { } } -void func_8084F390(Player* this, PlayState* play) { +void Player_Action_8084F390(Player* this, PlayState* play) { CollisionPoly* floorPoly; f32 sp50; f32 sp4C; @@ -13077,7 +13217,7 @@ void func_8084F390(Player* this, PlayState* play) { Player_GetSlopeDirection(floorPoly, &slopeNormal, &downwardSlopeYaw); sp44 = downwardSlopeYaw; - if (this->unk_84F != 0) { + if (this->actionVar1 != 0) { sp44 = downwardSlopeYaw + 0x8000; } @@ -13102,7 +13242,7 @@ void func_8084F390(Player* this, PlayState* play) { if (Math_AsymStepToF(&this->speedXZ, sp50, sp4C, sp48) && (sp50 == 0)) { LinkAnimationHeader* anim; - if (this->unk_84F == 0) { + if (this->actionVar1 == 0) { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_down_slope_slip_end, this->modelAnimType); } else { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_up_slope_slip_end, this->modelAnimType); @@ -13115,33 +13255,33 @@ void func_8084F390(Player* this, PlayState* play) { } } -void func_8084F608(Player* this, PlayState* play) { - if ((DECR(this->unk_850) == 0) && func_8083ADD4(play, this)) { +void Player_Action_8084F608(Player* this, PlayState* play) { + if ((DECR(this->actionVar2) == 0) && func_8083ADD4(play, this)) { func_80852280(play, this, NULL); - func_80835C58(play, this, func_80852E14, 0); - func_80852E14(this, play); + Player_SetupAction(play, this, Player_Action_80852E14, 0); + Player_Action_80852E14(this, play); } } -void func_8084F698(Player* this, PlayState* play) { - func_80835C58(play, this, func_8084F608, 0); - this->unk_850 = 40; +void Player_Action_8084F698(Player* this, PlayState* play) { + Player_SetupAction(play, this, Player_Action_8084F608, 0); + this->actionVar2 = 40; Actor_Spawn(&play->actorCtx, play, ACTOR_DEMO_KANKYO, 0.0f, 0.0f, 0.0f, 0, 0, 0, DEMOKANKYO_WARP_IN); } -void func_8084F710(Player* this, PlayState* play) { +void Player_Action_8084F710(Player* this, PlayState* play) { s32 pad; - if ((this->unk_84F != 0) && (play->csCtx.curFrame < 305)) { + if ((this->actionVar1 != 0) && (play->csCtx.curFrame < 305)) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; - } else if (D_80853600 < 150.0f) { + } else if (sYDistToFloor < 150.0f) { if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; func_808328A0(this); - this->unk_850 = 1; + this->actionVar2 = 1; } } else { if ((play->sceneId == SCENE_KOKIRI_FOREST) && func_8083ADD4(play, this)) { @@ -13164,16 +13304,16 @@ void func_8084F710(Player* this, PlayState* play) { } } -void func_8084F88C(Player* this, PlayState* play) { +void Player_Action_8084F88C(Player* this, PlayState* play) { LinkAnimation_Update(play, &this->skelAnime); - if ((this->unk_850++ > 8) && (play->transitionTrigger == TRANS_TRIGGER_OFF)) { + if ((this->actionVar2++ > 8) && (play->transitionTrigger == TRANS_TRIGGER_OFF)) { - if (this->unk_84F != 0) { + if (this->actionVar1 != 0) { if (play->sceneId == SCENE_ICE_CAVERN) { Play_TriggerRespawn(play); play->nextEntranceIndex = ENTR_ICE_CAVERN_0; - } else if (this->unk_84F < 0) { + } else if (this->actionVar1 < 0) { Play_TriggerRespawn(play); } else { Play_TriggerVoidOut(play); @@ -13192,11 +13332,11 @@ void func_8084F88C(Player* this, PlayState* play) { } } -void func_8084F9A0(Player* this, PlayState* play) { +void Player_Action_8084F9A0(Player* this, PlayState* play) { func_80839800(this, play); } -void func_8084F9C0(Player* this, PlayState* play) { +void Player_Action_8084F9C0(Player* this, PlayState* play) { this->actor.gravity = -1.0f; LinkAnimation_Update(play, &this->skelAnime); @@ -13208,12 +13348,12 @@ void func_8084F9C0(Player* this, PlayState* play) { } } -void func_8084FA54(Player* this, PlayState* play) { +void Player_Action_8084FA54(Player* this, PlayState* play) { this->unk_6AD = 2; func_8083AD4C(play, this); LinkAnimation_Update(play, &this->skelAnime); - func_80836670(this, play); + Player_UpdateUpperBody(this, play); this->unk_6BE = func_8084ABD8(play, this, 1, 0) - this->actor.shape.rot.y; this->unk_6AE |= 0x80; @@ -13226,14 +13366,14 @@ void func_8084FA54(Player* this, PlayState* play) { } } -void func_8084FB10(Player* this, PlayState* play) { - if (this->unk_84F >= 0) { - if (this->unk_84F < 6) { - this->unk_84F++; +void Player_Action_8084FB10(Player* this, PlayState* play) { + if (this->actionVar1 >= 0) { + if (this->actionVar1 < 6) { + this->actionVar1++; } if (func_80832594(this, 1, 100)) { - this->unk_84F = -1; + this->actionVar1 = -1; EffectSsIcePiece_SpawnBurst(play, &this->actor.world.pos, this->actor.scale.x); Player_PlaySfx(this, NA_SE_PL_ICE_BROKEN); } else { @@ -13251,12 +13391,12 @@ void func_8084FB10(Player* this, PlayState* play) { } } -void func_8084FBF4(Player* this, PlayState* play) { +void Player_Action_8084FBF4(Player* this, PlayState* play) { LinkAnimation_Update(play, &this->skelAnime); func_808382BC(this); - if (((this->unk_850 % 25) != 0) || func_80837B18(play, this, -1)) { - if (DECR(this->unk_850) == 0) { + if (((this->actionVar2 % 25) != 0) || func_80837B18(play, this, -1)) { + if (DECR(this->actionVar2) == 0) { func_80839F90(this, play); } } @@ -13423,7 +13563,7 @@ s32 func_80850224(Player* this, PlayState* play) { static Vec3f D_80854A40 = { 0.0f, 40.0f, 45.0f }; -void func_808502D0(Player* this, PlayState* play) { +void Player_Action_808502D0(Player* this, PlayState* play) { struct_80854190* sp44 = &D_80854190[this->meleeWeaponAnimation]; this->stateFlags2 |= PLAYER_STATE2_5; @@ -13494,7 +13634,7 @@ void func_808502D0(Player* this, PlayState* play) { } } -void func_808505DC(Player* this, PlayState* play) { +void Player_Action_808505DC(Player* this, PlayState* play) { LinkAnimation_Update(play, &this->skelAnime); func_8083721C(this); @@ -13503,15 +13643,15 @@ void func_808505DC(Player* this, PlayState* play) { } } -void func_8085063C(Player* this, PlayState* play) { +void Player_Action_8085063C(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_5; LinkAnimation_Update(play, &this->skelAnime); - func_80836670(this, play); + Player_UpdateUpperBody(this, play); - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { Message_StartTextbox(play, 0x3B, &this->actor); - this->unk_850 = 1; + this->actionVar2 = 1; return; } @@ -13538,17 +13678,17 @@ void func_8085063C(Player* this, PlayState* play) { } } -void func_8085076C(Player* this, PlayState* play) { +void Player_Action_8085076C(Player* this, PlayState* play) { s32 respawnData = gSaveContext.respawn[RESPAWN_MODE_TOP].data; - if (this->unk_850 > 20) { + if (this->actionVar2 > 20) { this->actor.draw = Player_Draw; this->actor.world.pos.y += 60.0f; func_80837B9C(this, play); return; } - if (this->unk_850++ == 20) { + if (this->actionVar2++ == 20) { gSaveContext.respawn[RESPAWN_MODE_TOP].data = respawnData + 1; Sfx_PlaySfxAtPos(&gSaveContext.respawn[RESPAWN_MODE_TOP].pos, NA_SE_PL_MAGIC_WIND_WARP); } @@ -13595,40 +13735,40 @@ static struct_80832924 D_80854A8C[][2] = { }, }; -void func_808507F4(Player* this, PlayState* play) { +void Player_Action_808507F4(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_84F < 0) { + if (this->actionVar1 < 0) { if ((this->itemAction == PLAYER_IA_NAYRUS_LOVE) || (gSaveContext.magicState == MAGIC_STATE_IDLE)) { func_80839FFC(this, play); func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); } } else { - if (this->unk_850 == 0) { - LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, D_80854A58[this->unk_84F], 0.83f); + if (this->actionVar2 == 0) { + LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, D_80854A58[this->actionVar1], 0.83f); - if (func_80846A00(play, this, this->unk_84F) != NULL) { + if (func_80846A00(play, this, this->actionVar1) != NULL) { this->stateFlags1 |= PLAYER_STATE1_28 | PLAYER_STATE1_29; - if ((this->unk_84F != 0) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { + if ((this->actionVar1 != 0) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; } } else { Magic_Reset(play); } } else { - LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, D_80854A64[this->unk_84F], 0.83f); + LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, D_80854A64[this->actionVar1], 0.83f); - if (this->unk_84F == 0) { - this->unk_850 = -10; + if (this->actionVar1 == 0) { + this->actionVar2 = -10; } } - this->unk_850++; + this->actionVar2++; } } else { - if (this->unk_850 < 0) { - this->unk_850++; + if (this->actionVar2 < 0) { + this->actionVar2++; - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { gSaveContext.respawn[RESPAWN_MODE_TOP].data = 1; Play_SetupRespawnPoint(play, RESPAWN_MODE_TOP, 0x6FF); gSaveContext.save.info.fwMain.set = 1; @@ -13641,20 +13781,20 @@ void func_808507F4(Player* this, PlayState* play) { gSaveContext.save.info.fwMain.roomIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].roomIndex; gSaveContext.save.info.fwMain.tempSwchFlags = gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwchFlags; gSaveContext.save.info.fwMain.tempCollectFlags = gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags; - this->unk_850 = 2; + this->actionVar2 = 2; } - } else if (this->unk_84F >= 0) { - if (this->unk_850 == 0) { + } else if (this->actionVar1 >= 0) { + if (this->actionVar2 == 0) { func_80832924(this, D_80854A80); - } else if (this->unk_850 == 1) { - func_80832924(this, D_80854A8C[this->unk_84F]); - if ((this->unk_84F == 2) && LinkAnimation_OnFrame(&this->skelAnime, 30.0f)) { + } else if (this->actionVar2 == 1) { + func_80832924(this, D_80854A8C[this->actionVar1]); + if ((this->actionVar1 == 2) && LinkAnimation_OnFrame(&this->skelAnime, 30.0f)) { this->stateFlags1 &= ~(PLAYER_STATE1_28 | PLAYER_STATE1_29); } - } else if (D_80854A7C[this->unk_84F] < this->unk_850++) { - LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, D_80854A70[this->unk_84F], 0.83f); + } else if (D_80854A7C[this->actionVar1] < this->actionVar2++) { + LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, D_80854A70[this->actionVar1], 0.83f); this->yaw = this->actor.shape.rot.y; - this->unk_84F = -1; + this->actionVar1 = -1; } } } @@ -13662,20 +13802,20 @@ void func_808507F4(Player* this, PlayState* play) { func_8083721C(this); } -void func_80850AEC(Player* this, PlayState* play) { +void Player_Action_80850AEC(Player* this, PlayState* play) { f32 temp; this->stateFlags2 |= PLAYER_STATE2_5; if (LinkAnimation_Update(play, &this->skelAnime)) { - func_80832284(play, this, &gPlayerAnim_link_hook_fly_wait); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_hook_fly_wait); } Math_Vec3f_Sum(&this->actor.world.pos, &this->actor.velocity, &this->actor.world.pos); if (func_80834FBC(this)) { Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); - func_80847BA0(play, this); + Player_ProcessSceneCollision(play, this); temp = this->actor.world.pos.y - this->actor.floorHeight; if (temp > 20.0f) { @@ -13700,8 +13840,8 @@ void func_80850AEC(Player* this, PlayState* play) { } } -void func_80850C68(Player* this, PlayState* play) { - if ((this->unk_850 != 0) && ((this->unk_858 != 0.0f) || (this->unk_85C != 0.0f))) { +void Player_Action_80850C68(Player* this, PlayState* play) { + if ((this->actionVar2 != 0) && ((this->unk_858 != 0.0f) || (this->unk_85C != 0.0f))) { f32 updateScale = R_UPDATE_RATE * 0.5f; this->skelAnime.curFrame += this->skelAnime.playSpeed * updateScale; @@ -13720,8 +13860,8 @@ void func_80850C68(Player* this, PlayState* play) { LinkAnimation_InterpJointMorph(play, &this->skelAnime, 0.5f); } else if (LinkAnimation_Update(play, &this->skelAnime)) { this->unk_860 = 2; - func_80832284(play, this, &gPlayerAnim_link_fishing_wait); - this->unk_850 = 1; + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_fishing_wait); + this->actionVar2 = 1; } func_8083721C(this); @@ -13729,12 +13869,12 @@ void func_80850C68(Player* this, PlayState* play) { if (this->unk_860 == 0) { func_80853080(this, play); } else if (this->unk_860 == 3) { - func_80835C58(play, this, func_80850E84, 0); - func_80832B0C(play, this, &gPlayerAnim_link_fishing_fish_catch); + Player_SetupAction(play, this, Player_Action_80850E84, 0); + Player_AnimChangeOnceMorph(play, this, &gPlayerAnim_link_fishing_fish_catch); } } -void func_80850E84(Player* this, PlayState* play) { +void Player_Action_80850E84(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime) && (this->unk_860 == 0)) { func_8083A098(this, &gPlayerAnim_link_fishing_fish_catch_end, play); } @@ -13973,22 +14113,22 @@ static struct_80854B18 D_80854E50[PLAYER_CSMODE_MAX] = { { 12, &gPlayerAnim_demo_link_nwait }, // PLAYER_CSMODE_102 }; -void func_80850ED8(PlayState* play, Player* this, LinkAnimationHeader* anim) { - func_80832DB0(this); - func_80832B0C(play, this, anim); +void Player_AnimChangeOnceMorphZeroRootYawSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim) { + Player_ZeroRootLimbYaw(this); + Player_AnimChangeOnceMorph(play, this, anim); Player_ZeroSpeedXZ(this); } -void func_80850F1C(PlayState* play, Player* this, LinkAnimationHeader* anim) { - func_80832DB0(this); - LinkAnimation_Change(play, &this->skelAnime, anim, (2.0f / 3.0f), 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, - -8.0f); +void Player_AnimChangeOnceMorphAdjustedZeroRootYawSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim) { + Player_ZeroRootLimbYaw(this); + LinkAnimation_Change(play, &this->skelAnime, anim, PLAYER_ANIM_ADJUSTED_SPEED, 0.0f, Animation_GetLastFrame(anim), + ANIMMODE_ONCE, -8.0f); Player_ZeroSpeedXZ(this); } -void func_80850F9C(PlayState* play, Player* this, LinkAnimationHeader* anim) { - func_80832DB0(this); - LinkAnimation_Change(play, &this->skelAnime, anim, (2.0f / 3.0f), 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f); +void Player_AnimChangeLoopMorphAdjustedZeroRootYawSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim) { + Player_ZeroRootLimbYaw(this); + LinkAnimation_Change(play, &this->skelAnime, anim, PLAYER_ANIM_ADJUSTED_SPEED, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f); Player_ZeroSpeedXZ(this); } @@ -13997,55 +14137,55 @@ void func_80851008(PlayState* play, Player* this, void* anim) { } void func_80851030(PlayState* play, Player* this, void* anim) { - func_80850ED8(play, this, anim); + Player_AnimChangeOnceMorphZeroRootYawSpeed(play, this, anim); } void func_80851050(PlayState* play, Player* this, void* anim) { - func_80832DB0(this); - func_80832C2C(play, this, anim); + Player_ZeroRootLimbYaw(this); + Player_AnimChangeFreeze(play, this, anim); Player_ZeroSpeedXZ(this); } void func_80851094(PlayState* play, Player* this, void* anim) { - func_80850F1C(play, this, anim); + Player_AnimChangeOnceMorphAdjustedZeroRootYawSpeed(play, this, anim); } void func_808510B4(PlayState* play, Player* this, void* anim) { - func_80850F9C(play, this, anim); + Player_AnimChangeLoopMorphAdjustedZeroRootYawSpeed(play, this, anim); } void func_808510D4(PlayState* play, Player* this, void* anim) { - func_8083308C(play, this, anim); + Player_AnimReplaceNormalPlayOnceAdjusted(play, this, anim); } void func_808510F4(PlayState* play, Player* this, void* anim) { - func_8083303C(play, this, anim, - ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplacePlayOnce(play, this, anim, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } void func_80851114(PlayState* play, Player* this, void* anim) { - func_8083313C(play, this, anim); + Player_AnimReplaceNormalPlayLoopAdjusted(play, this, anim); } void func_80851134(PlayState* play, Player* this, void* anim) { - func_808330EC(play, this, anim, - ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplacePlayLoop(play, this, anim, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } void func_80851154(PlayState* play, Player* this, void* anim) { - func_80832264(play, this, anim); + Player_AnimPlayOnce(play, this, anim); } void func_80851174(PlayState* play, Player* this, void* anim) { - func_80832284(play, this, anim); + Player_AnimPlayLoop(play, this, anim); } void func_80851194(PlayState* play, Player* this, void* anim) { - func_808322D0(play, this, anim); + Player_AnimPlayOnceAdjusted(play, this, anim); } void func_808511B4(PlayState* play, Player* this, void* anim) { - func_808322A4(play, this, anim); + Player_AnimPlayLoopAdjusted(play, this, anim); } void func_808511D4(PlayState* play, Player* this, void* anim) { @@ -14054,22 +14194,22 @@ void func_808511D4(PlayState* play, Player* this, void* anim) { void func_808511FC(PlayState* play, Player* this, void* anim) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_80850F9C(play, this, anim); - this->unk_850 = 1; + Player_AnimChangeLoopMorphAdjustedZeroRootYawSpeed(play, this, anim); + this->actionVar2 = 1; } } void func_80851248(PlayState* play, Player* this, void* anim) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_80832DBC(this); - func_808322A4(play, this, anim); + Player_AnimPlayLoopAdjusted(play, this, anim); } } void func_80851294(PlayState* play, Player* this, void* anim) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_8083313C(play, this, anim); - this->unk_850 = 1; + Player_AnimReplaceNormalPlayLoopAdjusted(play, this, anim); + this->actionVar2 = 1; } } @@ -14095,15 +14235,15 @@ void func_80851368(PlayState* play, Player* this, CsCmdActorCue* cue) { this->stateFlags2 |= PLAYER_STATE2_10; this->stateFlags1 &= ~(PLAYER_STATE1_18 | PLAYER_STATE1_19); - func_80832284(play, this, &gPlayerAnim_link_swimer_swim); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_swimer_swim); } void func_808513BC(PlayState* play, Player* this, CsCmdActorCue* cue) { this->actor.gravity = 0.0f; - if (this->unk_84F == 0) { + if (this->actionVar1 == 0) { if (func_8083D12C(play, this, NULL)) { - this->unk_84F = 1; + this->actionVar1 = 1; } else { func_8084B158(play, this, NULL, fabsf(this->actor.velocity.y)); Math_ScaledStepToS(&this->unk_6C2, -10000, 800); @@ -14113,10 +14253,10 @@ void func_808513BC(PlayState* play, Player* this, CsCmdActorCue* cue) { } if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_84F == 1) { - func_80832C6C(play, this, &gPlayerAnim_link_swimer_swim_wait); + if (this->actionVar1 == 1) { + Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim_wait); } else { - func_80832284(play, this, &gPlayerAnim_link_swimer_swim_wait); + Player_AnimPlayLoop(play, this, &gPlayerAnim_link_swimer_swim_wait); } } @@ -14135,7 +14275,7 @@ void func_808514C0(PlayState* play, Player* this, CsCmdActorCue* cue) { LinkAnimation_Update(play, &this->skelAnime); if (func_8008F128(this) || (this->stateFlags1 & PLAYER_STATE1_11)) { - func_80836670(this, play); + Player_UpdateUpperBody(this, play); return; } @@ -14159,9 +14299,9 @@ void func_808515A4(PlayState* play, Player* this, CsCmdActorCue* cue) { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_nwait, this->modelAnimType); if ((this->cueId == 6) || (this->cueId == 0x2E)) { - func_80832264(play, this, anim); + Player_AnimPlayOnce(play, this, anim); } else { - func_80832DB0(this); + Player_ZeroRootLimbYaw(this); LinkAnimation_Change(play, &this->skelAnime, anim, (2.0f / 3.0f), 0.0f, Animation_GetLastFrame(anim), ANIMMODE_LOOP, -4.0f); } @@ -14184,7 +14324,7 @@ void func_80851688(PlayState* play, Player* this, CsCmdActorCue* cue) { LinkAnimation_Update(play, &this->skelAnime); if (func_8008F128(this) || (this->stateFlags1 & PLAYER_STATE1_11)) { - func_80836670(this, play); + Player_UpdateUpperBody(this, play); } } } @@ -14218,7 +14358,7 @@ void func_80851828(PlayState* play, Player* this, CsCmdActorCue* cue) { func_80845BA0(play, this, &sp1C, 10); if (play->sceneId == SCENE_JABU_JABU_BOSS) { - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { return; } @@ -14229,8 +14369,8 @@ void func_80851828(PlayState* play, Player* this, CsCmdActorCue* cue) { } } - this->unk_850++; - if (this->unk_850 > 20) { + this->actionVar2++; + if (this->actionVar2 > 20) { this->csMode = PLAYER_CSMODE_11; } } @@ -14242,10 +14382,10 @@ void func_808518DC(PlayState* play, Player* this, CsCmdActorCue* cue) { void func_8085190C(PlayState* play, Player* this, CsCmdActorCue* cue) { func_80851314(this); - if (this->unk_850 != 0) { + if (this->actionVar2 != 0) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_80832284(play, this, func_808334E4(this)); - this->unk_850 = 0; + Player_AnimPlayLoop(play, this, func_808334E4(this)); + this->actionVar2 = 0; } func_80833C3C(this); @@ -14273,10 +14413,10 @@ static Vec3f D_80855198 = { -1.0f, 70.0f, 20.0f }; void func_808519EC(PlayState* play, Player* this, CsCmdActorCue* cue) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80855198); this->actor.shape.rot.y = -0x8000; - func_808322D0(play, this, this->ageProperties->unk_9C); - func_80832F54(play, this, - FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | - ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); + Player_AnimPlayOnceAdjusted(play, this, this->ageProperties->unk_9C); + Player_AnimReplaceApplyFlags(play, this, + ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); } static struct_808551A4 D_808551A4[] = { @@ -14332,10 +14472,10 @@ static struct_80832924 D_808551B4[] = { void func_80851BE8(PlayState* play, Player* this, CsCmdActorCue* cue) { LinkAnimation_Update(play, &this->skelAnime); - this->unk_850++; + this->actionVar2++; - if (this->unk_850 >= 180) { - if (this->unk_850 == 180) { + if (this->actionVar2 >= 180) { + if (this->actionVar2 == 180) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_okarina_warp_goal, (2.0f / 3.0f), 10.0f, Animation_GetLastFrame(&gPlayerAnim_link_okarina_warp_goal), ANIMMODE_ONCE, -8.0f); } @@ -14344,19 +14484,19 @@ void func_80851BE8(PlayState* play, Player* this, CsCmdActorCue* cue) { } void func_80851CA4(PlayState* play, Player* this, CsCmdActorCue* cue) { - if (LinkAnimation_Update(play, &this->skelAnime) && (this->unk_850 == 0) && + if (LinkAnimation_Update(play, &this->skelAnime) && (this->actionVar2 == 0) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { - func_80832264(play, this, &gPlayerAnim_link_normal_back_downB); - this->unk_850 = 1; + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_back_downB); + this->actionVar2 = 1; } - if (this->unk_850 != 0) { + if (this->actionVar2 != 0) { func_8083721C(this); } } void func_80851D2C(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_80850F1C(play, this, &gPlayerAnim_link_normal_okarina_start); + Player_AnimChangeOnceMorphAdjustedZeroRootYawSpeed(play, this, &gPlayerAnim_link_normal_okarina_start); func_8084B498(this); Player_SetModels(this, Player_ActionToModelGroup(this, this->itemAction)); } @@ -14386,28 +14526,29 @@ void func_80851E28(PlayState* play, Player* this, CsCmdActorCue* cue) { } void func_80851E64(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_80833064(play, this, &gPlayerAnim_link_swimer_swim_get, - ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplacePlayOnceAdjusted(play, this, &gPlayerAnim_link_swimer_swim_get, + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } void func_80851E90(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_8083303C(play, this, &gPlayerAnim_clink_op3_negaeri, - ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplacePlayOnce(play, this, &gPlayerAnim_clink_op3_negaeri, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); func_80832698(this, NA_SE_VO_LI_GROAN); } void func_80851ECC(PlayState* play, Player* this, CsCmdActorCue* cue) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_808330EC(play, this, &gPlayerAnim_clink_op3_wait2, - ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplacePlayLoop(play, this, &gPlayerAnim_clink_op3_wait2, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); } } void func_80851F14(PlayState* play, Player* this, LinkAnimationHeader* anim, struct_80832924* arg3) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_808322A4(play, this, anim); - this->unk_850 = 1; - } else if (this->unk_850 == 0) { + Player_AnimPlayLoopAdjusted(play, this, anim); + this->actionVar2 = 1; + } else if (this->actionVar2 == 0) { func_80832924(this, arg3); } } @@ -14425,10 +14566,11 @@ static struct_80832924 D_808551BC[] = { void func_80851FB0(PlayState* play, Player* this, CsCmdActorCue* cue) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_808330EC(play, this, &gPlayerAnim_clink_op3_wait3, - ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); - this->unk_850 = 1; - } else if (this->unk_850 == 0) { + Player_AnimReplacePlayLoop(play, this, &gPlayerAnim_clink_op3_wait3, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); + this->actionVar2 = 1; + } else if (this->actionVar2 == 0) { func_80832924(this, D_808551BC); if (LinkAnimation_OnFrame(&this->skelAnime, 240.0f)) { this->actor.shape.shadowDraw = ActorShadow_DrawFeet; @@ -14449,8 +14591,9 @@ void func_80852048(PlayState* play, Player* this, CsCmdActorCue* cue) { } void func_80852080(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_80833064(play, this, &gPlayerAnim_clink_demo_futtobi, - ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplacePlayOnceAdjusted(play, this, &gPlayerAnim_clink_demo_futtobi, + ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); func_80832698(this, NA_SE_VO_LI_FALL_L); } @@ -14489,7 +14632,7 @@ void func_808521B8(PlayState* play, Player* this, CsCmdActorCue* cue) { } void func_808521F4(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_80832B0C(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_nwait, this->modelAnimType)); + Player_AnimChangeOnceMorph(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_nwait, this->modelAnimType)); Player_ZeroSpeedXZ(this); } @@ -14498,7 +14641,7 @@ void func_80852234(PlayState* play, Player* this, CsCmdActorCue* cue) { } void func_8085225C(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_80832F54(play, this, ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); + Player_AnimReplaceApplyFlags(play, this, ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } void func_80852280(PlayState* play, Player* this, CsCmdActorCue* cue) { @@ -14507,9 +14650,9 @@ void func_80852280(PlayState* play, Player* this, CsCmdActorCue* cue) { void func_80852298(PlayState* play, Player* this, CsCmdActorCue* cue) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_8083313C(play, this, &gPlayerAnim_clink_demo_koutai_wait); - this->unk_850 = 1; - } else if (this->unk_850 == 0) { + Player_AnimReplaceNormalPlayLoopAdjusted(play, this, &gPlayerAnim_clink_demo_koutai_wait); + this->actionVar2 = 1; + } else if (this->actionVar2 == 0) { if (LinkAnimation_OnFrame(&this->skelAnime, 10.0f)) { func_80846720(play, this, 1); } @@ -14536,11 +14679,11 @@ void func_80852358(PlayState* play, Player* this, CsCmdActorCue* cue) { void func_80852388(PlayState* play, Player* this, CsCmdActorCue* cue) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_808322A4(play, this, &gPlayerAnim_demo_link_twait); - this->unk_850 = 1; + Player_AnimPlayLoopAdjusted(play, this, &gPlayerAnim_demo_link_twait); + this->actionVar2 = 1; } - if ((this->unk_850 != 0) && (play->csCtx.curFrame >= 900)) { + if ((this->actionVar2 != 0) && (play->csCtx.curFrame >= 900)) { this->rightHandType = PLAYER_MODELTYPE_LH_OPEN; } else { this->rightHandType = PLAYER_MODELTYPE_RH_FF; @@ -14549,7 +14692,7 @@ void func_80852388(PlayState* play, Player* this, CsCmdActorCue* cue) { void func_80852414(PlayState* play, Player* this, LinkAnimationHeader* anim, struct_80832924* arg3) { func_80851294(play, this, anim); - if (this->unk_850 == 0) { + if (this->actionVar2 == 0) { func_80832924(this, arg3); } } @@ -14578,11 +14721,11 @@ void func_808524B0(PlayState* play, Player* this, CsCmdActorCue* cue) { void func_808524D0(PlayState* play, Player* this, CsCmdActorCue* cue) { sControlInput->press.button |= BTN_B; - func_80844E68(this, play); + Player_Action_80844E68(this, play); } void func_80852514(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_80844E68(this, play); + Player_Action_80844E68(this, play); } void func_80852544(PlayState* play, Player* this, CsCmdActorCue* cue) { @@ -14596,23 +14739,23 @@ void func_80852564(PlayState* play, Player* this, CsCmdActorCue* cue) { this->speedXZ = 2.0f; this->actor.velocity.y = -1.0f; - func_80832264(play, this, &gPlayerAnim_link_normal_back_downA); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_back_downA); func_80832698(this, NA_SE_VO_LI_FALL_L); } static void (*D_808551FC[])(Player* this, PlayState* play) = { - func_8084377C, - func_80843954, - func_80843A38, + Player_Action_8084377C, + Player_Action_80843954, + Player_Action_80843A38, }; void func_808525C0(PlayState* play, Player* this, CsCmdActorCue* cue) { - D_808551FC[this->unk_850](this, play); + D_808551FC[this->actionVar2](this, play); } void func_80852608(PlayState* play, Player* this, CsCmdActorCue* cue) { func_80846720(play, this, 0); - func_808322D0(play, this, &gPlayerAnim_link_demo_return_to_past); + Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_demo_return_to_past); } void func_80852648(PlayState* play, Player* this, CsCmdActorCue* cue) { @@ -14669,7 +14812,7 @@ void func_808526EC(PlayState* play, Player* this, CsCmdActorCue* cue) { void func_8085283C(PlayState* play, Player* this, CsCmdActorCue* cue) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_80852944(play, this, cue); - } else if (this->unk_850 == 0) { + } else if (this->actionVar2 == 0) { Item_Give(play, ITEM_SWORD_MASTER); func_80846720(play, this, 0); } else { @@ -14726,7 +14869,7 @@ void func_80852A54(PlayState* play, Player* this, CsCmdActorCue* cue) { } this->skelAnime.moveFlags = 0; - func_80832DB0(this); + Player_ZeroRootLimbYaw(this); } void func_80852B4C(PlayState* play, Player* this, CsCmdActorCue* cue, struct_80854B18* arg3) { @@ -14745,7 +14888,7 @@ void func_80852B4C(PlayState* play, Player* this, CsCmdActorCue* cue, struct_808 void func_80852C0C(PlayState* play, Player* this, s32 csMode) { if ((csMode != PLAYER_CSMODE_1) && (csMode != PLAYER_CSMODE_8) && (csMode != PLAYER_CSMODE_49) && (csMode != PLAYER_CSMODE_7)) { - func_808323B4(play, this); + Player_DetachHeldActor(play, this); } } @@ -14784,8 +14927,8 @@ void func_80852C50(PlayState* play, Player* this, CsCmdActorCue* cueUnused) { func_80852C0C(play, this, ABS(csMode)); func_80852B4C(play, this, cue, &D_80854B18[ABS(csMode)]); - this->unk_850 = 0; - this->unk_84F = 0; + this->actionVar2 = 0; + this->actionVar1 = 0; this->cueId = cue->id; } @@ -14793,7 +14936,7 @@ void func_80852C50(PlayState* play, Player* this, CsCmdActorCue* cueUnused) { func_80852B4C(play, this, cue, &D_80854E50[ABS(csMode)]); } -void func_80852E14(Player* this, PlayState* play) { +void Player_Action_80852E14(Player* this, PlayState* play) { if (this->csMode != this->prevCsMode) { D_80858AA0 = this->skelAnime.moveFlags; @@ -14810,14 +14953,14 @@ void func_80852E14(Player* this, PlayState* play) { s32 Player_IsDroppingFish(PlayState* play) { Player* this = GET_PLAYER(play); - return (func_8084EFC0 == this->func_674) && (this->itemAction == PLAYER_IA_BOTTLE_FISH); + return (Player_Action_8084EFC0 == this->actionFunc) && (this->itemAction == PLAYER_IA_BOTTLE_FISH); } s32 Player_StartFishing(PlayState* play) { Player* this = GET_PLAYER(play); func_80832564(play, this); - func_80835F44(play, this, ITEM_FISHING_POLE); + Player_UseItem(play, this, ITEM_FISHING_POLE); return 1; } @@ -14825,8 +14968,8 @@ s32 func_80852F38(PlayState* play, Player* this) { if (!Player_InBlockingCsMode(play, this) && (this->invincibilityTimer >= 0) && !func_8008F128(this) && !(this->stateFlags3 & PLAYER_STATE3_7)) { func_80832564(play, this); - func_80835C58(play, this, func_8084F308, 0); - func_80832264(play, this, &gPlayerAnim_link_normal_re_dead_attack); + Player_SetupAction(play, this, Player_Action_8084F308, 0); + Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_re_dead_attack); this->stateFlags2 |= PLAYER_STATE2_7; func_80832224(this); func_80832698(this, NA_SE_VO_LI_HELD); @@ -14842,7 +14985,7 @@ s32 func_80852FFC(PlayState* play, Actor* actor, s32 csMode) { if (!Player_InBlockingCsMode(play, this)) { func_80832564(play, this); - func_80835C58(play, this, func_80852E14, 0); + Player_SetupAction(play, this, Player_Action_80852E14, 0); this->csMode = csMode; this->unk_448 = actor; func_80832224(this); @@ -14853,8 +14996,8 @@ s32 func_80852FFC(PlayState* play, Actor* actor, s32 csMode) { } void func_80853080(Player* this, PlayState* play) { - func_80835C58(play, this, func_80840BC8, 1); - func_80832B0C(play, this, func_80833338(this)); + Player_SetupAction(play, this, Player_Action_80840BC8, 1); + Player_AnimChangeOnceMorph(play, this, func_80833338(this)); this->yaw = this->actor.shape.rot.y; } @@ -14895,35 +15038,35 @@ void func_80853148(PlayState* play, Actor* actor) { } if (this->stateFlags1 & PLAYER_STATE1_23) { - s32 sp24 = this->unk_850; + s32 sp24 = this->actionVar2; func_80832528(play, this); func_8083A2F8(play, this); - this->unk_850 = sp24; + this->actionVar2 = sp24; } else { if (func_808332B8(this)) { func_80836898(play, this, func_8083A2F8); - func_80832C6C(play, this, &gPlayerAnim_link_swimer_swim_wait); + Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim_wait); } else if ((actor->category != ACTORCAT_NPC) || (this->heldItemAction == PLAYER_IA_FISHING_POLE)) { func_8083A2F8(play, this); if (!func_8008E9C4(this)) { if ((actor != this->naviActor) && (actor->xzDistToPlayer < 40.0f)) { - func_808322D0(play, this, &gPlayerAnim_link_normal_backspace); + Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_normal_backspace); } else { - func_80832284(play, this, func_80833338(this)); + Player_AnimPlayLoop(play, this, func_80833338(this)); } } } else { func_80836898(play, this, func_8083A2F8); - func_808322D0(play, this, - (actor->xzDistToPlayer < 40.0f) ? &gPlayerAnim_link_normal_backspace - : &gPlayerAnim_link_normal_talk_free); + Player_AnimPlayOnceAdjusted(play, this, + (actor->xzDistToPlayer < 40.0f) ? &gPlayerAnim_link_normal_backspace + : &gPlayerAnim_link_normal_talk_free); } if (this->skelAnime.animation == &gPlayerAnim_link_normal_backspace) { - func_80832F54(play, this, ANIM_FLAG_0 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE); + Player_AnimReplaceApplyFlags(play, this, ANIM_FLAG_0 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE); } func_80832224(this); diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c index f2c02b3d8..7d3246837 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c @@ -15,7 +15,7 @@ #define rPrimColorA regs[5] #define rFadeDelay regs[6] #define rScaleStep regs[9] -#define rObjBankIdx regs[10] +#define rObjectSlot regs[10] #define rYAccelStep regs[11] // has no effect due to how it's implemented u32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); @@ -29,9 +29,9 @@ EffectSsInit Effect_Ss_D_Fire_InitVars = { u32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsDFireInitParams* initParams = (EffectSsDFireInitParams*)initParamsx; - s32 objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_DODONGO); + s32 objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_DODONGO); - if (objBankIndex >= 0) { + if (objectSlot >= 0) { this->pos = initParams->pos; this->velocity = initParams->velocity; this->accel = initParams->accel; @@ -45,7 +45,7 @@ u32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initPar this->rScale = initParams->scale; this->rScaleStep = initParams->scaleStep; this->rYAccelStep = 0; - this->rObjBankIdx = objBankIndex; + this->rObjectSlot = objectSlot; this->draw = EffectSsDFire_Draw; this->update = EffectSsDFire_Update; this->rTexIndex = ((s16)(play->state.frames % 4) ^ 3); @@ -70,17 +70,17 @@ void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this) { MtxF mfResult; MtxF mfTransBillboard; s32 pad; - void* object; + void* objectPtr; Mtx* mtx; f32 scale; - object = play->objectCtx.status[this->rObjBankIdx].segment; + objectPtr = play->objectCtx.slots[this->rObjectSlot].segment; OPEN_DISPS(gfxCtx); - if (Object_GetIndex(&play->objectCtx, OBJECT_DODONGO) > -1) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); - gSPSegment(POLY_XLU_DISP++, 0x06, object); + if (Object_GetSlot(&play->objectCtx, OBJECT_DODONGO) >= 0) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(objectPtr); + gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr); scale = this->rScale / 100.0f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); @@ -95,7 +95,7 @@ void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); + gSegments[6] = VIRTUAL_TO_PHYSICAL(objectPtr); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[this->rTexIndex])); gSPDisplayList(POLY_XLU_DISP++, this->gfx); } diff --git a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c index c43cc7280..1e37d04e8 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c +++ b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c @@ -7,7 +7,7 @@ #include "z_eff_ss_extra.h" #include "assets/objects/object_yabusame_point/object_yabusame_point.h" -#define rObjBankIdx regs[0] +#define rObjectSlot regs[0] #define rTimer regs[1] #define rScoreIdx regs[2] #define rScale regs[3] @@ -26,14 +26,14 @@ EffectSsInit Effect_Ss_Extra_InitVars = { u32 EffectSsExtra_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsExtraInitParams* initParams = (EffectSsExtraInitParams*)initParamsx; s32 pad; - s32 objBankIndex; + s32 objectSlot; uintptr_t oldSeg6; - objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_YABUSAME_POINT); + objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_YABUSAME_POINT); - if ((objBankIndex >= 0) && Object_IsLoaded(&play->objectCtx, objBankIndex)) { + if ((objectSlot >= 0) && Object_IsLoaded(&play->objectCtx, objectSlot)) { oldSeg6 = gSegments[6]; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); this->pos = initParams->pos; this->velocity = initParams->velocity; this->accel = initParams->accel; @@ -43,7 +43,7 @@ u32 EffectSsExtra_Init(PlayState* play, u32 index, EffectSs* this, void* initPar this->rScoreIdx = initParams->scoreIdx; this->rScale = initParams->scale; this->rTimer = 5; - this->rObjBankIdx = objBankIndex; + this->rObjectSlot = objectSlot; gSegments[6] = oldSeg6; return 1; @@ -61,12 +61,12 @@ static void* sTextures[] = { void EffectSsExtra_Draw(PlayState* play, u32 index, EffectSs* this) { s32 pad; f32 scale = this->rScale / 100.0f; - void* object = play->objectCtx.status[this->rObjBankIdx].segment; + void* objectPtr = play->objectCtx.slots[this->rObjectSlot].segment; OPEN_DISPS(play->state.gfxCtx); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); - gSPSegment(POLY_XLU_DISP++, 0x06, object); + gSegments[6] = VIRTUAL_TO_PHYSICAL(objectPtr); + gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr); Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Gfx_SetupDL_25Xlu(play->state.gfxCtx); diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c index 4e76ae3a0..a430aa59c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c @@ -9,7 +9,7 @@ #include "assets/objects/object_fhg/object_fhg.h" #define rAlpha regs[0] -#define rObjBankIdx regs[2] +#define rObjectSlot regs[2] #define rXZRot regs[3] #define rParam regs[4] #define rScale regs[8] @@ -32,18 +32,18 @@ static Gfx sShockDL[15]; u32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsFhgFlashInitParams* initParams = (EffectSsFhgFlashInitParams*)initParamsx; s32 pad; - s32 objBankIdx; + s32 objectSlot; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f farAwayVec = { 0.0f, -1000.0f, 0.0f }; - uintptr_t oldSeg6; + uintptr_t prevSeg6; if (initParams->type == FHGFLASH_LIGHTBALL) { - objBankIdx = Object_GetIndex(&play->objectCtx, OBJECT_FHG); + objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_FHG); - if ((objBankIdx > -1) && Object_IsLoaded(&play->objectCtx, objBankIdx)) { - oldSeg6 = gSegments[6]; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objBankIdx].segment); - this->rObjBankIdx = objBankIdx; + if ((objectSlot >= 0) && Object_IsLoaded(&play->objectCtx, objectSlot)) { + prevSeg6 = gSegments[6]; + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); + this->rObjectSlot = objectSlot; this->pos = initParams->pos; this->velocity = initParams->velocity; this->accel = initParams->accel; @@ -54,7 +54,7 @@ u32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* init this->draw = EffectSsFhgFlash_DrawLightBall; this->update = EffectSsFhgFlash_UpdateLightBall; this->gfx = SEGMENTED_TO_VIRTUAL(gPhantomEnergyBallDL); - gSegments[6] = oldSeg6; + gSegments[6] = prevSeg6; } else { osSyncPrintf("Effect_Ss_Fhg_Flash_ct():pffd->modeエラー\n"); return 0; @@ -89,17 +89,17 @@ void EffectSsFhgFlash_DrawLightBall(PlayState* play, u32 index, EffectSs* this) GraphicsContext* gfxCtx = play->state.gfxCtx; s32 pad; f32 scale; - void* object; + void* objectPtr; scale = this->rScale / 100.0f; - object = play->objectCtx.status[this->rObjBankIdx].segment; + objectPtr = play->objectCtx.slots[this->rObjectSlot].segment; OPEN_DISPS(gfxCtx); Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); - gSPSegment(POLY_XLU_DISP++, 0x06, object); + gSegments[6] = VIRTUAL_TO_PHYSICAL(objectPtr); + gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr); Gfx_SetupDL_25Xlu(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->rAlpha); gDPSetEnvColor(POLY_XLU_DISP++, sLightBallColors[this->rParam].r, sLightBallColors[this->rParam].g, diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c b/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c index b58667cdd..439e90102 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c @@ -17,7 +17,7 @@ #define rTimer regs[7] #define rUpdateRate regs[8] #define rDrawMode regs[9] -#define rObjBankIdx regs[10] +#define rObjectSlot regs[10] #define rScale regs[11] u32 EffectSsGMagma2_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); @@ -38,15 +38,15 @@ EffectSsInit Effect_Ss_G_Magma2_InitVars = { }; u32 EffectSsGMagma2_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { - s32 objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_KINGDODONGO); + s32 objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_KINGDODONGO); s32 pad; - if ((objBankIndex >= 0) && Object_IsLoaded(&play->objectCtx, objBankIndex)) { + if ((objectSlot >= 0) && Object_IsLoaded(&play->objectCtx, objectSlot)) { Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; EffectSsGMagma2InitParams* initParams = (EffectSsGMagma2InitParams*)initParamsx; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objBankIndex].segment); - this->rObjBankIdx = objBankIndex; + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); + this->rObjectSlot = objectSlot; this->pos = initParams->pos; this->velocity = zeroVec; this->accel = zeroVec; @@ -75,17 +75,17 @@ void EffectSsGMagma2_Draw(PlayState* play, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = play->state.gfxCtx; s32 pad; f32 scale; - void* object; + void* objectPtr; scale = this->rScale / 100.0f; - object = play->objectCtx.status[this->rObjBankIdx].segment; + objectPtr = play->objectCtx.slots[this->rObjectSlot].segment; OPEN_DISPS(gfxCtx); Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); - gSPSegment(POLY_XLU_DISP++, 0x06, object); + gSegments[6] = VIRTUAL_TO_PHYSICAL(objectPtr); + gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_g_magma2.c", 282), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c index 3315b5c0a..fe65984f5 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c @@ -7,7 +7,7 @@ #include "z_eff_ss_g_splash.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" -//! @bug the reuse of regs[11] means that EffectSs_DrawGEffect will treat the type as an object bank index +//! @bug the reuse of regs[11] means that EffectSs_DrawGEffect will treat the type as an object slot (`rgObjectSlot`) // this ends up having no effect because the texture provided does not use segment 6 #define rType regs[11] diff --git a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c index 143e2eb2f..38a9da474 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c +++ b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c @@ -12,7 +12,7 @@ #define rUnused regs[2] #define rScale regs[3] #define rObjId regs[4] -#define rObjBankIdx regs[5] +#define rObjectSlot regs[5] #define rMinLife regs[6] u32 EffectSsHahen_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); @@ -26,8 +26,8 @@ EffectSsInit Effect_Ss_Hahen_InitVars = { }; void EffectSsHahen_CheckForObject(EffectSs* this, PlayState* play) { - if (((this->rObjBankIdx = Object_GetIndex(&play->objectCtx, this->rObjId)) < 0) || - !Object_IsLoaded(&play->objectCtx, this->rObjBankIdx)) { + if (((this->rObjectSlot = Object_GetSlot(&play->objectCtx, this->rObjId)) < 0) || + !Object_IsLoaded(&play->objectCtx, this->rObjectSlot)) { this->life = -1; this->draw = NULL; } @@ -74,7 +74,7 @@ void EffectSsHahen_Draw(PlayState* play, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); if (this->rObjId != -1) { - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->rObjBankIdx].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->rObjectSlot].segment); } Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); @@ -98,7 +98,7 @@ void EffectSsHahen_DrawGray(PlayState* play, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); if (this->rObjId != -1) { - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->rObjBankIdx].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->rObjectSlot].segment); } Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c index d5d6b1981..adb173f89 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c @@ -7,7 +7,7 @@ #include "z_eff_ss_ice_smoke.h" #include "assets/objects/object_fz/object_fz.h" -#define rObjBankIdx regs[0] +#define rObjectSlot regs[0] #define rAlpha regs[1] #define rScale regs[2] @@ -23,24 +23,24 @@ EffectSsInit Effect_Ss_Ice_Smoke_InitVars = { u32 EffectSsIceSmoke_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsIceSmokeInitParams* initParams = (EffectSsIceSmokeInitParams*)initParamsx; s32 pad; - s32 objBankIdx; - uintptr_t oldSeg6; + s32 objectSlot; + uintptr_t prevSeg6; - objBankIdx = Object_GetIndex(&play->objectCtx, OBJECT_FZ); + objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_FZ); - if ((objBankIdx > -1) && Object_IsLoaded(&play->objectCtx, objBankIdx)) { - oldSeg6 = gSegments[6]; - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objBankIdx].segment); + if ((objectSlot >= 0) && Object_IsLoaded(&play->objectCtx, objectSlot)) { + prevSeg6 = gSegments[6]; + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[objectSlot].segment); Math_Vec3f_Copy(&this->pos, &initParams->pos); Math_Vec3f_Copy(&this->velocity, &initParams->velocity); Math_Vec3f_Copy(&this->accel, &initParams->accel); - this->rObjBankIdx = objBankIdx; + this->rObjectSlot = objectSlot; this->rAlpha = 0; this->rScale = initParams->scale; this->life = 50; this->draw = EffectSsIceSmoke_Draw; this->update = EffectSsIceSmoke_Update; - gSegments[6] = oldSeg6; + gSegments[6] = prevSeg6; return 1; } @@ -52,22 +52,22 @@ u32 EffectSsIceSmoke_Init(PlayState* play, u32 index, EffectSs* this, void* init void EffectSsIceSmoke_Draw(PlayState* play, u32 index, EffectSs* this) { s32 pad; - void* object; + void* objectPtr; Mtx* mtx; f32 scale; - s32 objBankIdx; + s32 objectSlot; - object = play->objectCtx.status[this->rObjBankIdx].segment; + objectPtr = play->objectCtx.slots[this->rObjectSlot].segment; OPEN_DISPS(play->state.gfxCtx); - objBankIdx = Object_GetIndex(&play->objectCtx, OBJECT_FZ); + objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_FZ); - if ((objBankIdx > -1) && Object_IsLoaded(&play->objectCtx, objBankIdx)) { + if ((objectSlot >= 0) && Object_IsLoaded(&play->objectCtx, objectSlot)) { gDPPipeSync(POLY_XLU_DISP++); Gfx_SetupDL_25Xlu(play->state.gfxCtx); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); - gSPSegment(POLY_XLU_DISP++, 0x06, object); + gSegments[6] = VIRTUAL_TO_PHYSICAL(objectPtr); + gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamStartDL)); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 235, 235, this->rAlpha); @@ -93,11 +93,11 @@ void EffectSsIceSmoke_Draw(PlayState* play, u32 index, EffectSs* this) { } void EffectSsIceSmoke_Update(PlayState* play, u32 index, EffectSs* this) { - s32 objBankIdx; + s32 objectSlot; - objBankIdx = Object_GetIndex(&play->objectCtx, OBJECT_FZ); + objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_FZ); - if ((objBankIdx > -1) && Object_IsLoaded(&play->objectCtx, objBankIdx)) { + if ((objectSlot >= 0) && Object_IsLoaded(&play->objectCtx, objectSlot)) { if (this->rAlpha < 100) { this->rAlpha += 10; } diff --git a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c index b1f13ebe6..eb8b3e9c2 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c @@ -17,7 +17,7 @@ #define rReg8 regs[8] #define rReg9 regs[9] #define rObjId regs[10] -#define rObjBankIdx regs[11] +#define rObjectSlot regs[11] #define rColorIdx regs[12] u32 EffectSsKakera_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); @@ -100,9 +100,9 @@ void EffectSsKakera_Draw(PlayState* play, u32 index, EffectSs* this) { if (this->rObjId != KAKERA_OBJECT_DEFAULT) { if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { - gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[this->rObjBankIdx].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.slots[this->rObjectSlot].segment); } else { - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->rObjBankIdx].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->rObjectSlot].segment); } } @@ -137,9 +137,9 @@ void EffectSsKakera_Draw(PlayState* play, u32 index, EffectSs* this) { } void func_809A9BA8(EffectSs* this, PlayState* play) { - this->rObjBankIdx = Object_GetIndex(&play->objectCtx, this->rObjId); + this->rObjectSlot = Object_GetSlot(&play->objectCtx, this->rObjId); - if ((this->rObjBankIdx < 0) || !Object_IsLoaded(&play->objectCtx, this->rObjBankIdx)) { + if ((this->rObjectSlot < 0) || !Object_IsLoaded(&play->objectCtx, this->rObjectSlot)) { this->life = 0; this->draw = NULL; } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c index 718c5bc7c..043c6b3bb 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c @@ -8,7 +8,7 @@ #include "assets/objects/object_link_boy/object_link_boy.h" #include "assets/objects/object_link_child/object_link_child.h" -#define rObjBankIdx regs[0] +#define rObjectSlot regs[0] #define rYaw regs[1] u32 EffectSsStick_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); @@ -21,7 +21,7 @@ EffectSsInit Effect_Ss_Stick_InitVars = { }; typedef struct { - /* 0x00 */ s16 objectID; + /* 0x00 */ s16 objectId; /* 0x04 */ Gfx* displayList; } StickDrawInfo; @@ -33,7 +33,7 @@ u32 EffectSsStick_Init(PlayState* play, u32 index, EffectSs* this, void* initPar StickDrawInfo* ageInfoEntry = gSaveContext.save.linkAge + drawInfo; EffectSsStickInitParams* initParams = (EffectSsStickInitParams*)initParamsx; - this->rObjBankIdx = Object_GetIndex(&play->objectCtx, ageInfoEntry->objectID); + this->rObjectSlot = Object_GetSlot(&play->objectCtx, ageInfoEntry->objectId); this->gfx = ageInfoEntry->displayList; this->vec = this->pos = initParams->pos; this->rYaw = initParams->yaw; @@ -67,7 +67,7 @@ void EffectSsStick_Draw(PlayState* play, u32 index, EffectSs* this) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_stick.c", 176), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); Gfx_SetupDL_25Opa(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->rObjBankIdx].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[this->rObjectSlot].segment); gSPSegment(POLY_OPA_DISP++, 0x0C, gCullBackDList); gSPDisplayList(POLY_OPA_DISP++, this->gfx); diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index ce679dc2c..67716bcb4 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -11,15 +11,15 @@ #include "config.h" #ifndef RELEASE_ROM -void ConsoleLogo_PrintBuildInfo(Gfx** gfxp) { - Gfx* g; +void ConsoleLogo_PrintBuildInfo(Gfx** gfxP) { + Gfx* gfx; GfxPrint* printer; - g = *gfxp; - g = Gfx_SetupDL_28(g); + gfx = *gfxP; + gfx = Gfx_SetupDL_28(gfx); printer = alloca(sizeof(GfxPrint)); GfxPrint_Init(printer); - GfxPrint_Open(printer, g); + GfxPrint_Open(printer, gfx); GfxPrint_SetColor(printer, 255, 255, 255, 255); @@ -35,9 +35,9 @@ void ConsoleLogo_PrintBuildInfo(Gfx** gfxp) { GfxPrint_SetPos(printer, WIDE_MULT(7, WIDE_GET_16_9), 25); GfxPrint_Printf(printer, "[Build Option:%s]", gBuildMakeOption); - g = GfxPrint_Close(printer); + gfx = GfxPrint_Close(printer); GfxPrint_Destroy(printer); - *gfxp = g; + *gfxP = gfx; } #endif diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c index 4e4de7d08..4971d893e 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c @@ -88,7 +88,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { if (pauseCtx->cursorSpecialPos == 0) { pauseCtx->nameColorSet = 0; - if ((pauseCtx->state != 6) || ((pauseCtx->stickAdjX == 0) && (pauseCtx->stickAdjY == 0))) { + if ((pauseCtx->state != PAUSE_STATE_6) || ((pauseCtx->stickAdjX == 0) && (pauseCtx->stickAdjY == 0))) { sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; } else { phi_s3 = pauseCtx->cursorPoint[PAUSE_QUEST]; @@ -180,7 +180,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx); - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->cursorSpecialPos == 0)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->cursorSpecialPos == 0)) { if ((sp216 >= QUEST_SONG_MINUET) && (sp216 < QUEST_KOKIRI_EMERALD)) { if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; @@ -446,7 +446,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - if ((pauseCtx->state == 4) || (pauseCtx->state == 0x12)) { + if ((pauseCtx->state == PAUSE_STATE_OPENING_1) || (pauseCtx->state == PAUSE_STATE_CLOSING)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_8082A070[0][0], D_8082A070[0][1], D_8082A070[0][2], pauseCtx->alpha); } else { @@ -464,7 +464,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { 48, 48, 0); } - if (pauseCtx->state == 6) { + if (pauseCtx->state == PAUSE_STATE_6) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c index ebc19c23b..56435f56b 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c @@ -38,12 +38,12 @@ static s16 sSlotItems[] = { ITEM_BOOMERANG, ITEM_LENS_OF_TRUTH, ITEM_MAGIC_BEAN, ITEM_HAMMER, ITEM_ARROW_LIGHT, ITEM_NAYRUS_LOVE, }; -void KaleidoScope_DrawDebugEditorText(Gfx** gfxp) { +void KaleidoScope_DrawDebugEditorText(Gfx** gfxP) { GfxPrint printer; s32 pad[2]; GfxPrint_Init(&printer); - GfxPrint_Open(&printer, *gfxp); + GfxPrint_Open(&printer, *gfxP); GfxPrint_SetPos(&printer, 3, 2); GfxPrint_SetColor(&printer, 255, 60, 0, 255); @@ -79,7 +79,7 @@ void KaleidoScope_DrawDebugEditorText(Gfx** gfxp) { GfxPrint_SetPos(&printer, 28, 24); GfxPrint_Printf(&printer, "%s", "/4"); - *gfxp = GfxPrint_Close(&printer); + *gfxP = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); } diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 9e486c9d9..6673a6fa3 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -152,7 +152,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { } } - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_EQUIP)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_EQUIP)) { oldCursorPoint = pauseCtx->cursorPoint[PAUSE_EQUIP]; pauseCtx->cursorColorSet = 0; @@ -469,9 +469,9 @@ void KaleidoScope_DrawEquipment(PlayState* play) { KaleidoScope_SetCursorVtx(pauseCtx, cursorSlot * 4, pauseCtx->equipVtx); - if ((pauseCtx->cursorSpecialPos == 0) && (cursorItem != PAUSE_ITEM_NONE) && (pauseCtx->state == 6) && - (pauseCtx->unk_1E4 == 0) && CHECK_BTN_ALL(input->press.button, BTN_A) && - (pauseCtx->cursorX[PAUSE_EQUIP] != 0)) { + if ((pauseCtx->cursorSpecialPos == 0) && (cursorItem != PAUSE_ITEM_NONE) && + (pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && + CHECK_BTN_ALL(input->press.button, BTN_A) && (pauseCtx->cursorX[PAUSE_EQUIP] != 0)) { if ((gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == 9) || (gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index 6f8d7d47a..ea6f8dc94 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -103,7 +103,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorColorSet = 0; pauseCtx->nameColorSet = 0; - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM)) { moveCursorResult = 0; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; @@ -350,9 +350,9 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { KaleidoScope_SetCursorVtx(pauseCtx, index, pauseCtx->itemVtx); #if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) - if ((pauseCtx->debugState == 0) && (pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->debugState == 0) && (pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0)) { #else - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0)) { #endif if (CHECK_BTN_ANY(input->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { if (((gSlotAgeReqs[cursorSlot] == 9) || diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c index d2256ed11..71674bc61 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c @@ -46,7 +46,7 @@ void KaleidoScope_DrawDungeonMap(PlayState* play, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { pauseCtx->cursorColorSet = 0; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MAP]; @@ -410,7 +410,7 @@ void KaleidoScope_DrawWorldMap(PlayState* play, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { pauseCtx->cursorColorSet = 0; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c index 0fd3310bd..ca2017e33 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c @@ -8,7 +8,8 @@ void KaleidoScope_UpdatePrompt(PlayState* play) { s8 stickAdjX = input->rel.stick_x; s16 step; - if (((pauseCtx->state == 7) && (pauseCtx->unk_1EC == 1)) || (pauseCtx->state == 0xE) || (pauseCtx->state == 0x10)) { + if (((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) && (pauseCtx->unk_1EC == 1)) || + (pauseCtx->state == PAUSE_STATE_14) || (pauseCtx->state == PAUSE_STATE_16)) { if ((pauseCtx->promptChoice == 0) && (stickAdjX >= 30)) { Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 6a58715c0..f97a3e7c7 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -444,7 +444,7 @@ void KaleidoScope_DrawCursor(PlayState* play, u16 pageIndex) { temp = pauseCtx->unk_1E4; - if ((((pauseCtx->unk_1E4 == 0) || (temp == 8)) && (pauseCtx->state == 6)) || + if ((((pauseCtx->unk_1E4 == 0) || (temp == 8)) && (pauseCtx->state == PAUSE_STATE_6)) || ((pauseCtx->pageIndex == PAUSE_QUEST) && ((temp < 3) || (temp == 5) || (temp == 8)))) { if (pauseCtx->pageIndex == pageIndex) { @@ -534,8 +534,8 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); - if ((pauseCtx->state < 8) || (pauseCtx->state > 0x11)) { - if (pauseCtx->state != 7) { + if (!IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { + if (pauseCtx->state != PAUSE_STATE_SAVE_PROMPT) { stepR = ABS(D_8082AB8C - D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][0]) / D_8082AD3C; stepG = ABS(D_8082AB90 - D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][1]) / D_8082AD3C; stepB = ABS(D_8082AB94 - D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][2]) / D_8082AD3C; @@ -800,7 +800,7 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { Gfx_SetupDL_42Opa(gfxCtx); - if ((pauseCtx->state == 7) || ((pauseCtx->state >= 8) && (pauseCtx->state < 0x12))) { + if ((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) || IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { KaleidoScope_UpdatePrompt(play); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); @@ -837,16 +837,17 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1424), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if ((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11)) { + if (IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->saveVtx, sGameOverTexs); - } else { + } else { // PAUSE_STATE_SAVE_PROMPT POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->saveVtx, sSaveTexs[gSaveContext.language]); } gSPVertex(POLY_OPA_DISP++, &pauseCtx->saveVtx[60], 32, 0); - if (((pauseCtx->state == 7) && (pauseCtx->unk_1EC < 4)) || (pauseCtx->state == 0xE)) { + if (((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) && (pauseCtx->unk_1EC < 4)) || + (pauseCtx->state == PAUSE_STATE_14)) { POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sSavePromptTexs[gSaveContext.language], 152, 16, 0); @@ -873,8 +874,9 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sPromptChoiceTexs[gSaveContext.language][1], 48, 16, 16); - } else if ((pauseCtx->state != 7) || (pauseCtx->unk_1EC < 4)) { - if ((pauseCtx->state != 0xF) && ((pauseCtx->state == 0x10) || (pauseCtx->state == 0x11))) { + } else if ((pauseCtx->state != PAUSE_STATE_SAVE_PROMPT) || (pauseCtx->unk_1EC < 4)) { + if ((pauseCtx->state != PAUSE_STATE_15) && + ((pauseCtx->state == PAUSE_STATE_16) || (pauseCtx->state == PAUSE_STATE_17))) { POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sContinuePromptTexs[gSaveContext.language], 152, 16, 0); @@ -908,7 +910,7 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - if ((pauseCtx->state != 0x10) && (pauseCtx->state != 0x11)) { + if ((pauseCtx->state != PAUSE_STATE_16) && (pauseCtx->state != PAUSE_STATE_17)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, pauseCtx->alpha); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); } @@ -1142,7 +1144,8 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); gDPSetEnvColor(POLY_OPA_DISP++, 20, 30, 40, 0); - if ((pauseCtx->state == 6) && (pauseCtx->namedItem != PAUSE_ITEM_NONE) && (pauseCtx->nameDisplayTimer < WREG(89)) && + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->namedItem != PAUSE_ITEM_NONE) && + (pauseCtx->nameDisplayTimer < WREG(89)) && (((u32)pauseCtx->unk_1E4 == 0) || (pauseCtx->unk_1E4 == 2) || ((pauseCtx->unk_1E4 >= 4) && (pauseCtx->unk_1E4 <= 7)) || (pauseCtx->unk_1E4 == 8)) && (pauseCtx->cursorSpecialPos == 0)) { @@ -1221,7 +1224,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { gSPVertex(POLY_OPA_DISP++, &pauseCtx->infoPanelVtx[16], 8, 0); - if (pauseCtx->state == 7) { + if (pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) { pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = WREG(61 + gSaveContext.language); pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = @@ -1246,7 +1249,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, D_8082AD60[gSaveContext.language], D_8082ADE0[gSaveContext.language], 16, 4); } else if (pauseCtx->cursorSpecialPos != 0) { - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0)) { pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = -63; pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = @@ -1678,7 +1681,7 @@ s16 func_80823A0C(PlayState* play, Vtx* vtx, s16 arg2, s16 arg3) { vtx[phi_t1 + 1].v.ob[0] = vtx[phi_t1 + 3].v.ob[0] = vtx[phi_t1 + 0].v.ob[0] + ptr2[phi_t3]; - if (!((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11))) { + if (!IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { vtx[phi_t1 + 0].v.ob[1] = vtx[phi_t1 + 1].v.ob[1] = ptr3[phi_t3] + pauseCtx->offsetY; } else { vtx[phi_t1 + 0].v.ob[1] = vtx[phi_t1 + 1].v.ob[1] = YREG(60 + phi_t3) + pauseCtx->offsetY; @@ -1809,9 +1812,9 @@ void KaleidoScope_InitVertices(PlayState* play, GraphicsContext* gfxCtx) { pauseCtx->offsetY = 0; - if ((pauseCtx->state == 4) || (pauseCtx->state >= 0x12) || - ((pauseCtx->state == 7) && ((pauseCtx->unk_1EC == 2) || (pauseCtx->unk_1EC == 5))) || - ((pauseCtx->state >= 8) && (pauseCtx->state <= 0xD))) { + if ((pauseCtx->state == PAUSE_STATE_OPENING_1) || (pauseCtx->state >= PAUSE_STATE_CLOSING) || + ((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) && ((pauseCtx->unk_1EC == 2) || (pauseCtx->unk_1EC == 5))) || + ((pauseCtx->state >= PAUSE_STATE_8) && (pauseCtx->state <= PAUSE_STATE_13))) { pauseCtx->offsetY = 80; } @@ -2321,14 +2324,14 @@ void KaleidoScope_Draw(PlayState* play) { KaleidoScope_SetView(pauseCtx, 0.0f, 0.0f, 64.0f); - if (!((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11))) { + if (!IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { KaleidoScope_DrawInfoPanel(play); } #if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) } #endif - if ((pauseCtx->state >= 0xB) && (pauseCtx->state <= 0x11)) { + if ((pauseCtx->state >= PAUSE_STATE_11) && (pauseCtx->state <= PAUSE_STATE_17)) { KaleidoScope_DrawGameOver(play); } @@ -2362,7 +2365,7 @@ void KaleidoScope_GrayOutTextureRGBA32(u32* texture, u16 pixelCount) { } } -void func_808265BC(PlayState* play) { +void KaleidoScope_UpdateOpening(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; pauseCtx->eye.x += D_8082ABAC[pauseCtx->mode] * ZREG(46); @@ -2370,6 +2373,8 @@ void func_808265BC(PlayState* play) { pauseCtx->unk_1EA += 4 * ZREG(46); if (pauseCtx->unk_1EA == (64 * ZREG(47))) { + // Finished opening + func_80084BF4(play, 1); gSaveContext.buttonStatus[0] = D_8082AB6C[pauseCtx->pageIndex][0]; gSaveContext.buttonStatus[1] = D_8082AB6C[pauseCtx->pageIndex][1]; @@ -2378,10 +2383,11 @@ void func_808265BC(PlayState* play) { gSaveContext.buttonStatus[4] = D_8082AB6C[pauseCtx->pageIndex][4]; pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; pauseCtx->unk_1E4 = 0; - pauseCtx->state++; + pauseCtx->state++; // PAUSE_STATE_6 pauseCtx->alpha = 255; Interface_LoadActionLabelB(play, DO_ACTION_SAVE); } else if (pauseCtx->unk_1EA == 64) { + // `ZREG(47)` is always 1 so this normally never happens pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; pauseCtx->mode = (u16)(pauseCtx->pageIndex * 2) + 1; } @@ -2530,10 +2536,10 @@ void KaleidoScope_Update(PlayState* play) { s32 pad; if ((R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_READY) && - (((pauseCtx->state >= 4) && (pauseCtx->state <= 7)) || - ((pauseCtx->state >= 0xA) && (pauseCtx->state <= 0x12)))) { + (((pauseCtx->state >= PAUSE_STATE_OPENING_1) && (pauseCtx->state <= PAUSE_STATE_SAVE_PROMPT)) || + ((pauseCtx->state >= PAUSE_STATE_10) && (pauseCtx->state <= PAUSE_STATE_CLOSING)))) { - if ((((u32)pauseCtx->unk_1E4 == 0) || (pauseCtx->unk_1E4 == 8)) && (pauseCtx->state == 6)) { + if ((((u32)pauseCtx->unk_1E4 == 0) || (pauseCtx->unk_1E4 == 8)) && (pauseCtx->state == PAUSE_STATE_6)) { pauseCtx->stickAdjX = input->rel.stick_x; pauseCtx->stickAdjY = input->rel.stick_y; KaleidoScope_UpdateCursorSize(play); @@ -2542,13 +2548,13 @@ void KaleidoScope_Update(PlayState* play) { KaleidoScope_UpdateCursorSize(play); } - if (pauseCtx->state == 6) { + if (pauseCtx->state == PAUSE_STATE_6) { KaleidoScope_UpdateNamePanel(play); } } switch (pauseCtx->state) { - case 3: + case PAUSE_STATE_INIT: D_808321A8[0] = gSaveContext.buttonStatus[0]; D_808321A8[1] = gSaveContext.buttonStatus[1]; D_808321A8[2] = gSaveContext.buttonStatus[2]; @@ -2567,7 +2573,7 @@ void KaleidoScope_Update(PlayState* play) { //! @bug messed up alignment, should match `ALIGN64` pauseCtx->playerSegment = (void*)(((uintptr_t)play->objectCtx.spaceStart + 0x30) & ~0x3F); - size1 = func_80091738(play, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime); + size1 = Player_InitPauseDrawData(play, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime); osSyncPrintf("プレイヤー size1=%x\n", size1); pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)pauseCtx->playerSegment + size1); @@ -2917,11 +2923,13 @@ void KaleidoScope_Update(PlayState* play) { } } - pauseCtx->state = 4; + pauseCtx->state = PAUSE_STATE_OPENING_1; break; - case 4: + case PAUSE_STATE_OPENING_1: if (pauseCtx->unk_1F4 == 160.0f) { + // First frame in this state + KaleidoScope_SetDefaultCursor(play); KaleidoScope_ProcessPlayerPreRender(); } @@ -2937,26 +2945,27 @@ void KaleidoScope_Update(PlayState* play) { if (pauseCtx->unk_1F4 == 0) { interfaceCtx->startAlpha = 255; WREG(2) = 0; - pauseCtx->state = 5; + pauseCtx->state = PAUSE_STATE_OPENING_2; } - func_808265BC(play); + KaleidoScope_UpdateOpening(play); break; - case 5: + case PAUSE_STATE_OPENING_2: pauseCtx->alpha += (u16)(255 / (WREG(6) + WREG(4))); - func_808265BC(play); - if (pauseCtx->state == 6) { + KaleidoScope_UpdateOpening(play); + + if (pauseCtx->state == PAUSE_STATE_6) { KaleidoScope_UpdateNamePanel(play); } break; - case 6: + case PAUSE_STATE_6: switch (pauseCtx->unk_1E4) { case 0: if (CHECK_BTN_ALL(input->press.button, BTN_START)) { Interface_SetDoAction(play, DO_ACTION_NONE); - pauseCtx->state = 0x12; + pauseCtx->state = PAUSE_STATE_CLOSING; WREG(2) = -6240; func_800F64E0(0); } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { @@ -2970,7 +2979,7 @@ void KaleidoScope_Update(PlayState* play) { gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL); pauseCtx->unk_1EC = 0; - pauseCtx->state = 7; + pauseCtx->state = PAUSE_STATE_SAVE_PROMPT; } break; @@ -2999,7 +3008,7 @@ void KaleidoScope_Update(PlayState* play) { if (CHECK_BTN_ALL(input->press.button, BTN_START)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); Interface_SetDoAction(play, DO_ACTION_NONE); - pauseCtx->state = 0x12; + pauseCtx->state = PAUSE_STATE_CLOSING; WREG(2) = -6240; func_800F64E0(0); pauseCtx->unk_1E4 = 0; @@ -3017,7 +3026,7 @@ void KaleidoScope_Update(PlayState* play) { gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL); pauseCtx->unk_1EC = 0; - pauseCtx->state = 7; + pauseCtx->state = PAUSE_STATE_SAVE_PROMPT; } else if (pauseCtx->ocarinaStaff->state == pauseCtx->ocarinaSongIdx) { Audio_PlaySfxGeneral(NA_SE_SY_TRE_BOX_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -3050,7 +3059,7 @@ void KaleidoScope_Update(PlayState* play) { if (CHECK_BTN_ALL(input->press.button, BTN_START)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); Interface_SetDoAction(play, DO_ACTION_NONE); - pauseCtx->state = 0x12; + pauseCtx->state = PAUSE_STATE_CLOSING; WREG(2) = -6240; func_800F64E0(0); pauseCtx->unk_1E4 = 0; @@ -3067,7 +3076,7 @@ void KaleidoScope_Update(PlayState* play) { gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL); pauseCtx->unk_1EC = 0; - pauseCtx->state = 7; + pauseCtx->state = PAUSE_STATE_SAVE_PROMPT; } break; @@ -3080,7 +3089,7 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 7: + case PAUSE_STATE_SAVE_PROMPT: switch (pauseCtx->unk_1EC) { case 0: pauseCtx->unk_204 -= 314.0f / WREG(6); @@ -3149,7 +3158,7 @@ void KaleidoScope_Update(PlayState* play) { WREG(16) += WREG(25) / WREG(6); WREG(17) += WREG(26) / WREG(6); if (pauseCtx->unk_204 >= -314.0f) { - pauseCtx->state = 6; + pauseCtx->state = PAUSE_STATE_6; pauseCtx->unk_1EC = 0; pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 0.0f; pauseCtx->unk_204 = -314.0f; @@ -3174,7 +3183,7 @@ void KaleidoScope_Update(PlayState* play) { #if (defined ENABLE_INV_EDITOR || defined ENABLE_EVENT_EDITOR) pauseCtx->debugState = 0; #endif - pauseCtx->state = 0x13; + pauseCtx->state = PAUSE_STATE_RESUME_GAMEPLAY; pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 160.0f; pauseCtx->namedItem = PAUSE_ITEM_NONE; pauseCtx->unk_1E4 = 0; @@ -3184,7 +3193,7 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 0xA: + case PAUSE_STATE_10: pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot = VREG(30) + 3; WREG(16) = -175; @@ -3241,10 +3250,10 @@ void KaleidoScope_Update(PlayState* play) { D_8082B260 = 30; VREG(88) = 98; pauseCtx->promptChoice = 0; - pauseCtx->state++; + pauseCtx->state++; // PAUSE_STATE_11 break; - case 0xB: + case PAUSE_STATE_11: stepR = ABS(D_8082AB8C - 30) / D_8082B260; stepG = ABS(D_8082AB90) / D_8082B260; stepB = ABS(D_8082AB94) / D_8082B260; @@ -3300,19 +3309,19 @@ void KaleidoScope_Update(PlayState* play) { D_8082ABA0 = 130; D_8082ABA4 = 0; - pauseCtx->state++; + pauseCtx->state++; // PAUSE_STATE_12 D_8082B260 = 40; } break; - case 0xC: + case PAUSE_STATE_12: D_8082B260--; if (D_8082B260 == 0) { - pauseCtx->state = 0xD; + pauseCtx->state = PAUSE_STATE_13; } break; - case 0xD: + case PAUSE_STATE_13: pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = pauseCtx->unk_204 -= 160.0f / WREG(6); pauseCtx->infoPanelOffsetY += 40 / WREG(6); @@ -3328,7 +3337,7 @@ void KaleidoScope_Update(PlayState* play) { VREG(88) = 66; WREG(2) = 0; pauseCtx->alpha = 255; - pauseCtx->state = 0xE; + pauseCtx->state = PAUSE_STATE_14; gSaveContext.save.info.playerData.deaths++; if (gSaveContext.save.info.playerData.deaths > 999) { gSaveContext.save.info.playerData.deaths = 999; @@ -3337,13 +3346,13 @@ void KaleidoScope_Update(PlayState* play) { osSyncPrintf("kscope->angle_s = %f\n", pauseCtx->unk_204); break; - case 0xE: + case PAUSE_STATE_14: if (CHECK_BTN_ALL(input->press.button, BTN_A)) { if (pauseCtx->promptChoice != 0) { pauseCtx->promptChoice = 0; Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - pauseCtx->state = 0x10; + pauseCtx->state = PAUSE_STATE_16; gameOverCtx->state++; } else { Audio_PlaySfxGeneral(NA_SE_SY_PIECE_OF_HEART, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -3352,26 +3361,26 @@ void KaleidoScope_Update(PlayState* play) { Play_SaveSceneFlags(play); gSaveContext.save.info.playerData.savedSceneId = play->sceneId; Sram_WriteSave(&play->sramCtx); - pauseCtx->state = 0xF; + pauseCtx->state = PAUSE_STATE_15; D_8082B25C = 3; } } break; - case 0xF: + case PAUSE_STATE_15: D_8082B25C--; if (D_8082B25C == 0) { - pauseCtx->state = 0x10; + pauseCtx->state = PAUSE_STATE_16; gameOverCtx->state++; } else if ((D_8082B25C <= 80) && (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_START))) { - pauseCtx->state = 0x10; + pauseCtx->state = PAUSE_STATE_16; gameOverCtx->state++; func_800F64E0(0); } break; - case 0x10: + case PAUSE_STATE_16: if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_START)) { if (pauseCtx->promptChoice == 0) { Audio_PlaySfxGeneral(NA_SE_SY_PIECE_OF_HEART, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -3437,16 +3446,16 @@ void KaleidoScope_Update(PlayState* play) { &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - pauseCtx->state = 0x11; + pauseCtx->state = PAUSE_STATE_17; } break; - case 0x11: + case PAUSE_STATE_17: if (interfaceCtx->unk_244 != 255) { interfaceCtx->unk_244 += 10; if (interfaceCtx->unk_244 >= 255) { interfaceCtx->unk_244 = 255; - pauseCtx->state = 0; + pauseCtx->state = PAUSE_STATE_OFF; R_UPDATE_RATE = 3; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF; func_800981B8(&play->objectCtx); @@ -3480,7 +3489,7 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 0x12: + case PAUSE_STATE_CLOSING: if (pauseCtx->unk_1F4 != 160.0f) { pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 += 160.0f / WREG(6); pauseCtx->infoPanelOffsetY -= 40 / WREG(6); @@ -3496,7 +3505,7 @@ void KaleidoScope_Update(PlayState* play) { #ifdef ENABLE_INV_EDITOR pauseCtx->debugState = 0; #endif - pauseCtx->state = 0x13; + pauseCtx->state = PAUSE_STATE_RESUME_GAMEPLAY; pauseCtx->unk_200 = 160.0f; pauseCtx->unk_1FC = 160.0f; pauseCtx->unk_1F8 = 160.0f; @@ -3506,10 +3515,11 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 0x13: - pauseCtx->state = 0; + case PAUSE_STATE_RESUME_GAMEPLAY: + pauseCtx->state = PAUSE_STATE_OFF; R_UPDATE_RATE = 3; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF; + func_800981B8(&play->objectCtx); func_800418D0(&play->colCtx, play); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c b/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c index cb23a1f4a..cf6daf7aa 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c @@ -80,7 +80,7 @@ void PauseMapMark_DrawForDungeon(PlayState* play) { Matrix_Push(); - if ((play->pauseCtx.state == 4) || (play->pauseCtx.state >= 0x12)) { + if ((play->pauseCtx.state == PAUSE_STATE_OPENING_1) || (play->pauseCtx.state >= PAUSE_STATE_CLOSING)) { Matrix_Translate(-36.0f, 101.0f, 0.0f, MTXMODE_APPLY); } else { Matrix_Translate(-36.0f, 21.0f, 0.0f, MTXMODE_APPLY);