From 12bd420f7b6c3f3472f96cd0328298f136394ee4 Mon Sep 17 00:00:00 2001 From: rylieb <31797144+rylieb@users.noreply.github.com> Date: Sun, 8 Aug 2021 07:33:59 -0600 Subject: [PATCH] Obj_Warpstone - Tiny PR to address final suggestions from previous PR's code review. (#251) * EnBji01_Init OK and Partially Documented. * EnBji01_Destroy OK and Fully Documented. * func_809CCE98 OK and partially documented. * Removed goto in func_809CCE98(). * func_809CD6C0 matching and partly documented. * Pasted raw mips_to_c into EnBji01_Update(). * EnBji01_Update() matching and partially documented. * EnBji01_Update() matching and partially documented. * func_809CDA4C() matching and partially documented. * func_809CDA4C actually matching this time, and partially documented. * func_809CDB04() matching and partially documented. * func_809CD028() matching and mostly documented. * func_809CD6B0() matching. * func_809CD328() matching and partially documented. * func_809CCDE0() matching and partially documented, func_8013E950() prototyped. * func_809CD634() and func_809CD70C() matching and partially documented. func_801A5BD0() prototyped. * func_809CD77C() matching and mostly documented. All functions now matching. * Imported data from ovl_En_Bji_01_data.asm to z_en_bji_01.c. Updated object_script.txt and code_script.txt. Ran format.sh. Builds OK. * Documented all of the unks in Shikashi's struct. Build still OK. * Fixed new warning in Bg_Haka_Tomb resulting from my new prototype of func_8013E3B8(). * Renamed remaining instances of unk160 to cutscenes. * Update src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h Remove unnecessary comment about compiler padding. Co-authored-by: Anghelo Carvajal * Update src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c Correct stack declaration spacing. Co-authored-by: Anghelo Carvajal * Update src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.h Remove unnecessary comment about compiler alignment padding. Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c Remove unnecessary padding comment. Co-authored-by: Anghelo Carvajal * Apply suggestions from code review Co-authored-by: Anghelo Carvajal Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Batch commit for comments during code review. * Apply suggestions from code review (trailing Us) Co-authored-by: Derek Hensley * Deleted exteraneous space at the bottom of En_Bji_01 struct in the header file. * Used params enum for switch cases. * Update src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h Co-authored-by: Parker Burnett * Apply suggestions from code review replacing magic numbers with limb enums Co-authored-by: Anghelo Carvajal * Renamed func_809CD328 to EnBji01_DialogueHandler per code review. * ObjWarpstone_Init() matching and mostly documented. * ObjWarpstone_Destroy() matching and fully documented. * ObjWarpstone_Update() matching and partially documented. * ObjWarpstone_Draw() matching and partially documented. * func_80B92B10() matching and partially documented. * func_80B92C00() matching and mostly documented. * func_80B92C48() matching and mostly documented. * func_80B92CD0() matching and partially documented. * func_80B92DC4() matching and fully documented. * Obj_Warpstone OK. * Obj_Warpstone OK and mostly documented. * Changed "actionFunc" return values from 0/1 to false/true. * Apply suggestions from code review Change colors to decimal, and use matrix defines/enums instead of magic numbers. Co-authored-by: kyleburnette * Convert more colors to decimal and replace more magic nums with mtx defines/enums. * Ran format.sh after adding (wordy) mtx defines. * Ran format.sh which updated ginko_man. * Update src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c Switch to line comments. Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Changed floating point constants in ObjWarpstone_Draw to hex per code review. * Rename timer and timer enums. * Address a few last comments on my PR. Mainly regarding variable/macro naming, and also using generated reloc instead of extracted. * Added C file descriptors to both of my merged actors. * Changed macro name from "_HIT" to "_ACTIVATED" to be more accurate. Co-authored-by: Anghelo Carvajal Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Derek Hensley Co-authored-by: Parker Burnett Co-authored-by: kyleburnette Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- include/z64save.h | 62 +++++++++---------- spec | 2 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 6 ++ .../ovl_Obj_Warpstone/z_obj_warpstone.c | 12 +++- .../ovl_Obj_Warpstone/z_obj_warpstone.h | 4 +- 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index b59381d329..20efff7b8f 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -42,40 +42,40 @@ typedef struct { } RespawnData; // size = 0x20 typedef struct { - /* 0x0000 */ u32 entranceIndex; // "scene_no" - /* 0x0004 */ u8 equippedMask; // "player_mask" - /* 0x0005 */ u8 unk_05; // "opening_flag" + /* 0x0000 */ u32 entranceIndex; // "scene_no" + /* 0x0004 */ u8 equippedMask; // "player_mask" + /* 0x0005 */ u8 unk_05; // "opening_flag" /* 0x0006 */ u8 unk_06; - /* 0x0007 */ u8 linkAge; // "link_age" - /* 0x0008 */ s32 cutscene; // "day_time" - /* 0x000C */ u16 time; // "zelda_time" + /* 0x0007 */ u8 linkAge; // "link_age" + /* 0x0008 */ s32 cutscene; // "day_time" + /* 0x000C */ u16 time; // "zelda_time" /* 0x000E */ u16 owlSaveLocation; - /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ u32 unk_14; // "change_zelda_time" - /* 0x0018 */ s32 day; // "totalday" - /* 0x001C */ u32 daysElapsed; // "eventday" - /* 0x0020 */ u8 playerForm; // "player_character" - /* 0x0021 */ u8 snowheadCleared; // "spring_flag" - /* 0x0022 */ u8 hasTatl; // "bell_flag" + /* 0x0010 */ s32 isNight; // "asahiru_fg" + /* 0x0014 */ u32 unk_14; // "change_zelda_time" + /* 0x0018 */ s32 day; // "totalday" + /* 0x001C */ u32 daysElapsed; // "eventday" + /* 0x0020 */ u8 playerForm; // "player_character" + /* 0x0021 */ u8 snowheadCleared; // "spring_flag" + /* 0x0022 */ u8 hasTatl; // "bell_flag" /* 0x0023 */ u8 isOwlSave; - /* 0x0024 */ char newf[6]; // Will always be "ZELDA3" for a valid save - /* 0x002B */ u16 deaths; // "savect" - /* 0x002C */ char playerName[8]; // "player_name" - /* 0x0034 */ s16 healthCapacity; // "max_life" - /* 0x0036 */ s16 health; // "now_life" - /* 0x0038 */ s8 magicLevel; // "magic_max" - /* 0x0039 */ s8 magic; // "magic_now" - /* 0x003A */ s16 rupees; // "lupy_count" - /* 0x003C */ u16 swordHealth; // "long_sword_hp" - /* 0x003E */ u16 naviTimer; // "navi_timer" - /* 0x0040 */ u8 magicAcquired; // "magic_mode" - /* 0x0041 */ u8 doubleMagic; // "magic_ability" - /* 0x0042 */ u8 doubleDefense; // "life_ability" - /* 0x0043 */ u8 unk_43; // "ocarina_round" - /* 0x0044 */ u8 unk_44; // "first_memory" - /* 0x0046 */ u16 owlsHit; // "memory_warp_point" - /* 0x0048 */ u8 unk_48; // "last_warp_pt" - /* 0x004A */ s16 savedSceneNum; // "scene_data_ID" + /* 0x0024 */ char newf[6]; // Will always be "ZELDA3" for a valid save + /* 0x002B */ u16 deaths; // "savect" + /* 0x002C */ char playerName[8]; // "player_name" + /* 0x0034 */ s16 healthCapacity; // "max_life" + /* 0x0036 */ s16 health; // "now_life" + /* 0x0038 */ s8 magicLevel; // "magic_max" + /* 0x0039 */ s8 magic; // "magic_now" + /* 0x003A */ s16 rupees; // "lupy_count" + /* 0x003C */ u16 swordHealth; // "long_sword_hp" + /* 0x003E */ u16 naviTimer; // "navi_timer" + /* 0x0040 */ u8 magicAcquired; // "magic_mode" + /* 0x0041 */ u8 doubleMagic; // "magic_ability" + /* 0x0042 */ u8 doubleDefense; // "life_ability" + /* 0x0043 */ u8 unk_43; // "ocarina_round" + /* 0x0044 */ u8 unk_44; // "first_memory" + /* 0x0046 */ u16 owlActivationFlags; // "memory_warp_point" + /* 0x0048 */ u8 unk_48; // "last_warp_pt" + /* 0x004A */ s16 savedSceneNum; // "scene_data_ID" /* 0x004C */ ItemEquips equips; /* 0x0070 */ Inventory inventory; /* 0x00F8 */ u32 roomInf[128][7]; diff --git a/spec b/spec index 11dedd0471..8577c25161 100644 --- a/spec +++ b/spec @@ -4488,7 +4488,7 @@ beginseg name "ovl_Obj_Warpstone" compress include "build/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.o" - include "build/data/ovl_Obj_Warpstone/ovl_Obj_Warpstone.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Warpstone/ovl_Obj_Warpstone_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index ceac98bef3..5879c5cb9a 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -1,3 +1,9 @@ +/* + * File: z_en_bji_01.c + * Overlay: ovl_En_Bji_01 + * Description: Professor Shikashi (Astral Observatory Proprietor) + */ + #include "z_en_bji_01.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index 712addcaf3..8d9511df83 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_warpstone.c + * Overlay: ovl_Obj_Warpstone + * Description: Owl Statue + */ + #include "z_obj_warpstone.h" #define FLAGS 0x00000009 @@ -67,7 +73,7 @@ void ObjWarpstone_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Actor_SetHeight(&this->dyna.actor, 40.0f); - if (!IS_OWL_HIT(GET_OWL_ID(this))) { + if (!OBJ_WARPSTONE_IS_ACTIVATED(OBJ_WARPSTONE_GET_ID(this))) { ObjWarpstone_SetupAction(this, ObjWarpstone_ClosedIdle); } else { ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); @@ -106,7 +112,7 @@ s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalC s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCtx) { if (this->openingCSTimer++ >= OBJ_WARPSTONE_TIMER_ACTIVATE_THRESHOLD) { ActorCutscene_Stop(this->dyna.actor.cutscene); - func_80143A10(GET_OWL_ID(this)); + func_80143A10(OBJ_WARPSTONE_GET_ID(this)); ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); } else if (this->openingCSTimer < OBJ_WARPSTONE_TIMER_OPEN_THRESHOLD) { Math_StepToF(&this->dyna.actor.velocity.x, 0.01f, 0.001f); @@ -140,7 +146,7 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { globalCtx->msgCtx.unk11F22 = 0x4D; globalCtx->msgCtx.unk120D6 = 0; globalCtx->msgCtx.unk120D4 = 0; - gSaveContext.owlSaveLocation = GET_OWL_ID(this); + gSaveContext.owlSaveLocation = OBJ_WARPSTONE_GET_ID(this); } else { func_801477B4(globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h index e2c3937b20..47163ec2c9 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h @@ -28,7 +28,7 @@ typedef struct ObjWarpstone { extern const ActorInit Obj_Warpstone_InitVars; -#define GET_OWL_ID(this) ((u16)(this->dyna.actor.params & 0xF)) -#define IS_OWL_HIT(owlId) (((void)0,gSaveContext.owlsHit) & (u16)gBitFlags[owlId]) +#define OBJ_WARPSTONE_GET_ID(this) ((u16)(this->dyna.actor.params & 0xF)) +#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0,gSaveContext.owlActivationFlags) & (u16)gBitFlags[owlId]) #endif // Z_OBJ_WARPSTONE_H