diff --git a/include/color.h b/include/color.h index 014e7accf2..723983f83a 100644 --- a/include/color.h +++ b/include/color.h @@ -10,7 +10,7 @@ typedef struct { } Color_RGBA8; // only use when necessary for alignment purposes -typedef union { +typedef union Color_RGBA8_u32 { struct { u8 r, g, b, a; }; diff --git a/include/functions.h b/include/functions.h index 54b57c8ea5..d9c29270a6 100644 --- a/include/functions.h +++ b/include/functions.h @@ -757,9 +757,7 @@ void Cutscene_HandleConditionalTriggers(PlayState* play); void Cutscene_SetScript(PlayState* play, void* script); void* MemCpy(void* dest, const void* src, s32 len); void GetItem_Draw(PlayState* play, s16 drawId); -void SfxSource_InitAll(PlayState* play); -void SfxSource_UpdateAll(PlayState* play); -void SfxSource_PlaySfxAtFixedWorldPos(PlayState* play, Vec3f* worldPos, s32 duration, u16 sfxId); + u16 QuestHint_GetSariaTextId(PlayState* play); u16 QuestHint_GetNaviTextId(PlayState* play); u16 MaskReaction_GetTextId(PlayState* play, u32 maskReactionSet); @@ -932,8 +930,7 @@ void Interface_Update(PlayState* play); Path* Path_GetByIndex(PlayState* play, s16 index, s16 max); f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); void Path_CopyLastPoint(Path* path, Vec3f* dest); -void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx); -s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input); + void Player_SetBootData(PlayState* play, Player* this); int Player_InBlockingCsMode(PlayState* play, Player* this); int Player_InCsMode(PlayState* play); @@ -1204,37 +1201,7 @@ void KaleidoScopeCall_Init(PlayState* play); void KaleidoScopeCall_Destroy(PlayState* play); void KaleidoScopeCall_Update(PlayState* play); void KaleidoScopeCall_Draw(PlayState* play); -void Play_SetViewpoint(PlayState* this, s16 viewpoint); -s32 Play_CheckViewpoint(PlayState* this, s16 viewpoint); -void Play_SetShopBrowsingViewpoint(PlayState* this); -Gfx* Play_SetFog(PlayState* this, Gfx* gfx); -void Play_Destroy(GameState* thisx); -void Play_Init(GameState* thisx); -void Play_Main(GameState* thisx); -int Play_InCsMode(PlayState* this); -f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* pos); -void* Play_LoadFile(PlayState* this, RomFile* file); -void Play_GetScreenPos(PlayState* this, Vec3f* src, Vec3f* dest); -s16 Play_CreateSubCamera(PlayState* this); -s16 Play_GetActiveCamId(PlayState* this); -s16 Play_ChangeCameraStatus(PlayState* this, s16 camId, s16 status); -void Play_ClearCamera(PlayState* this, s16 camId); -void Play_ClearAllSubCameras(PlayState* this); -Camera* Play_GetCamera(PlayState* this, s16 camId); -s32 Play_SetCameraAtEye(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye); -s32 Play_SetCameraAtEyeUp(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); -s32 Play_SetCameraFov(PlayState* this, s16 camId, f32 fov); -s32 Play_SetCameraRoll(PlayState* this, s16 camId, s16 roll); -void Play_CopyCamera(PlayState* this, s16 destCamId, s16 srcCamId); -s32 Play_InitCameraDataUsingPlayer(PlayState* this, s16 camId, Player* player, s16 setting); -s32 Play_RequestCameraSetting(PlayState* this, s16 camId, s16 setting); -void Play_ReturnToMainCam(PlayState* this, s16 camId, s16 duration); -void Play_SaveSceneFlags(PlayState* this); -void Play_SetupRespawnPoint(PlayState* this, s32 respawnMode, s32 playerParams); -void Play_TriggerVoidOut(PlayState* this); -void Play_TriggerRespawn(PlayState* this); -int Play_CamIsNotFixed(PlayState* this); -int FrameAdvance_IsEnabled(PlayState* this); + s32 func_800C0D34(PlayState* this, Actor* actor, s16* yaw); s32 func_800C0DB4(PlayState* this, Vec3f* pos); void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg); @@ -1777,9 +1744,7 @@ u8 Message_GetState(MessageContext* msgCtx); void Message_Draw(PlayState* play); void Message_Update(PlayState* play); void Message_SetTables(void); -void GameOver_Init(PlayState* play); -void GameOver_FadeInLights(PlayState* play); -void GameOver_Update(PlayState* play); + void Interface_Destroy(PlayState* play); void Interface_Init(PlayState* play); void Message_Init(PlayState* play); diff --git a/include/macros.h b/include/macros.h index 6315fbe94c..a42693b39a 100644 --- a/include/macros.h +++ b/include/macros.h @@ -30,10 +30,6 @@ #define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0)) -#define GET_PLAYER(play) ((Player*)(play)->actorCtx.actorLists[ACTORCAT_PLAYER].head) - -#define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamId]) - #define LINK_IS_ADULT (gSaveContext.save.linkAge == LINK_AGE_ADULT) #define LINK_IS_CHILD (gSaveContext.save.linkAge == LINK_AGE_CHILD) diff --git a/include/padmgr.h b/include/padmgr.h index ba86315c6f..fd58765c06 100644 --- a/include/padmgr.h +++ b/include/padmgr.h @@ -10,7 +10,7 @@ typedef enum { CONT_PAK_OTHER } ControllerPakType; -typedef struct { +typedef struct Input { /* 0x00 */ OSContPad cur; /* 0x06 */ OSContPad prev; /* 0x0C */ OSContPad press; // X/Y store delta from last frame diff --git a/include/variables.h b/include/variables.h index 0b3b260bf2..10f67329ff 100644 --- a/include/variables.h +++ b/include/variables.h @@ -98,7 +98,7 @@ extern u64 gMojiFontTex[]; // original name: "font_ff" extern KaleidoMgrOverlay gKaleidoMgrOverlayTable[KALEIDO_OVL_MAX]; extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; extern u8 gBossMarkState; -extern void* gDebugCutsceneScript; + extern s32 gScreenWidth; extern s32 gScreenHeight; extern Mtx gMtxClear; @@ -197,10 +197,7 @@ extern MapData* gMapData; extern f32 gBossMarkScale; extern u32 D_8016139C; extern PauseMapMarksData* gLoadedPauseMarkDataTable; -extern TransitionTile gTransitionTile; -extern s32 gTransitionTileState; -extern VisMono gPlayVisMono; -extern Color_RGBA8_u32 gVisMonoColor; + extern PreNmiBuff* gAppNmiBufferPtr; extern uintptr_t gSegments[NUM_SEGMENTS]; extern Scheduler gScheduler; diff --git a/include/z64.h b/include/z64.h index 2a556d3f9f..03ef633b7f 100644 --- a/include/z64.h +++ b/include/z64.h @@ -20,6 +20,7 @@ #include "z64curve.h" #include "z64scene.h" #include "z64effect.h" +#include "z64game_over.h" #include "z64item.h" #include "z64animation.h" #include "z64animation_legacy.h" @@ -28,11 +29,13 @@ #include "z64map_mark.h" #include "z64message.h" #include "z64pause.h" +#include "z64play.h" #include "z64skin.h" #include "z64game.h" #include "z64transition.h" #include "z64transition_instances.h" #include "z64interface.h" +#include "z64sfx_source.h" #include "z64skybox.h" #include "z64sram.h" #include "z64view.h" @@ -104,90 +107,6 @@ // NOTE: Once we start supporting other builds, this can be changed with an ifdef #define REGION_NATIVE REGION_EU -typedef struct { - /* 0x00 */ u8 seqId; - /* 0x01 */ u8 natureAmbienceId; -} SequenceContext; // size = 0x2 - -typedef struct { - /* 0x00 */ s32 enabled; - /* 0x04 */ s32 timer; -} FrameAdvanceContext; // size = 0x8 - -typedef struct { - /* 0x00 */ Vec3f pos; - /* 0x0C */ f32 unk_0C; // radius? - /* 0x10 */ Color_RGB8 color; -} TargetContextEntry; // size = 0x14 - -typedef struct { - /* 0x00 */ Vec3f naviRefPos; // possibly wrong - /* 0x0C */ Vec3f targetCenterPos; - /* 0x18 */ Color_RGBAf naviInner; - /* 0x28 */ Color_RGBAf naviOuter; - /* 0x38 */ Actor* arrowPointedActor; - /* 0x3C */ Actor* targetedActor; - /* 0x40 */ f32 unk_40; - /* 0x44 */ f32 unk_44; - /* 0x48 */ s16 unk_48; - /* 0x4A */ u8 activeCategory; - /* 0x4B */ u8 unk_4B; - /* 0x4C */ s8 unk_4C; - /* 0x4D */ char unk_4D[0x03]; - /* 0x50 */ TargetContextEntry arr_50[3]; - /* 0x8C */ Actor* unk_8C; - /* 0x90 */ Actor* bgmEnemy; // The nearest enemy to player with the right flags that will trigger NA_BGM_ENEMY - /* 0x94 */ Actor* unk_94; -} TargetContext; // size = 0x98 - -typedef struct { - /* 0x00 */ void* texture; - /* 0x04 */ s16 x; - /* 0x06 */ s16 y; - /* 0x08 */ u8 width; - /* 0x09 */ u8 height; - /* 0x0A */ u8 durationTimer; // how long the title card appears for before fading - /* 0x0B */ u8 delayTimer; // how long the title card waits to appear - /* 0x0C */ s16 alpha; - /* 0x0E */ s16 intensity; -} TitleCardContext; // size = 0x10 - -typedef struct { - /* 0x00 */ s32 length; // number of actors loaded of this category - /* 0x04 */ Actor* head; // pointer to head of the linked list of this category (most recent actor added) -} ActorListEntry; // size = 0x08 - -typedef struct { - /* 0x0000 */ u8 freezeFlashTimer; - /* 0x0001 */ char unk_01[0x01]; - /* 0x0002 */ u8 unk_02; - /* 0x0003 */ u8 lensActive; - /* 0x0004 */ char unk_04[0x04]; - /* 0x0008 */ u8 total; // total number of actors loaded - /* 0x000C */ ActorListEntry actorLists[ACTORCAT_MAX]; - /* 0x006C */ TargetContext targetCtx; - struct { - /* 0x0104 */ u32 swch; - /* 0x0108 */ u32 tempSwch; - /* 0x010C */ u32 unk0; - /* 0x0110 */ u32 unk1; - /* 0x0114 */ u32 chest; - /* 0x0118 */ u32 clear; - /* 0x011C */ u32 tempClear; - /* 0x0120 */ u32 collect; - /* 0x0124 */ u32 tempCollect; - } flags; - /* 0x0128 */ TitleCardContext titleCtx; - /* 0x0138 */ char unk_138[0x04]; - /* 0x013C */ void* absoluteSpace; // Space used to allocate actor overlays with alloc type ACTOROVL_ALLOC_ABSOLUTE -} ActorContext; // size = 0x140 - -typedef struct { - /* 0x00 */ u16 countdown; - /* 0x04 */ Vec3f worldPos; - /* 0x10 */ Vec3f projectedPos; -} SfxSource; // size = 0x1C - typedef struct { /* 0x00 */ void* loadedRamAddr; /* 0x04 */ RomFile file; @@ -203,86 +122,11 @@ typedef enum { /* 2 */ KALEIDO_OVL_MAX } KaleidoOverlayType; -typedef enum { - /* 00 */ GAMEOVER_INACTIVE, - /* 01 */ GAMEOVER_DEATH_START, - /* 02 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for link to fall and hit the ground - /* 03 */ GAMEOVER_DEATH_DELAY_MENU, // wait for 1 second before showing the game over menu - /* 04 */ GAMEOVER_DEATH_MENU, // do nothing while kaleidoscope handles the game over menu - /* 20 */ GAMEOVER_REVIVE_START = 20, - /* 21 */ GAMEOVER_REVIVE_RUMBLE, - /* 22 */ GAMEOVER_REVIVE_WAIT_GROUND, // wait for link to fall and hit the ground - /* 23 */ GAMEOVER_REVIVE_WAIT_FAIRY, // wait for the fairy to rise all the way up out of links body - /* 24 */ GAMEOVER_REVIVE_FADE_OUT // fade out the game over lights as link is revived and gets back up -} GameOverState; - -typedef struct { - /* 0x00 */ u16 state; -} GameOverContext; // size = 0x2 - typedef enum { /* 0 */ LENS_MODE_SHOW_ACTORS, // lens actors are invisible by default, and shown by using lens (for example, invisible enemies) /* 1 */ LENS_MODE_HIDE_ACTORS // lens actors are visible by default, and hidden by using lens (for example, fake walls) } LensMode; -typedef enum { - /* 0 */ ROOM_BEHAVIOR_TYPE1_0, - /* 1 */ ROOM_BEHAVIOR_TYPE1_1, - /* 2 */ ROOM_BEHAVIOR_TYPE1_2, - /* 3 */ ROOM_BEHAVIOR_TYPE1_3, // unused - /* 4 */ ROOM_BEHAVIOR_TYPE1_4, // unused - /* 5 */ ROOM_BEHAVIOR_TYPE1_5 -} RoomBehaviorType1; - -typedef enum { - /* 0 */ ROOM_BEHAVIOR_TYPE2_0, - /* 1 */ ROOM_BEHAVIOR_TYPE2_1, - /* 2 */ ROOM_BEHAVIOR_TYPE2_2, - /* 3 */ ROOM_BEHAVIOR_TYPE2_3, - /* 4 */ ROOM_BEHAVIOR_TYPE2_4, - /* 5 */ ROOM_BEHAVIOR_TYPE2_5, - /* 6 */ ROOM_BEHAVIOR_TYPE2_6 -} RoomBehaviorType2; - -typedef struct { - /* 0x00 */ s8 num; - /* 0x01 */ u8 unk_01; - /* 0x02 */ u8 behaviorType2; - /* 0x03 */ u8 behaviorType1; - /* 0x04 */ s8 echo; - /* 0x05 */ u8 lensMode; - /* 0x08 */ RoomShape* roomShape; // original name: "ground_shape" - /* 0x0C */ void* segment; - /* 0x10 */ char unk_10[0x4]; -} Room; // size = 0x14 - -typedef struct { - /* 0x00 */ Room curRoom; - /* 0x14 */ Room prevRoom; - /* 0x28 */ void* bufPtrs[2]; - /* 0x30 */ u8 unk_30; - /* 0x31 */ s8 status; - /* 0x34 */ void* unk_34; - /* 0x38 */ DmaRequest dmaRequest; - /* 0x58 */ OSMesgQueue loadQueue; - /* 0x70 */ OSMesg loadMsg; - /* 0x74 */ s16 unk_74[2]; // context-specific data used by the current scene draw config -} RoomContext; // size = 0x78 - -#define SAC_ENABLE (1 << 0) - -typedef struct { - /* 0x000 */ s16 colATCount; - /* 0x002 */ u16 sacFlags; - /* 0x004 */ Collider* colAT[COLLISION_CHECK_AT_MAX]; - /* 0x0CC */ s32 colACCount; - /* 0x0D0 */ Collider* colAC[COLLISION_CHECK_AC_MAX]; - /* 0x1C0 */ s32 colOCCount; - /* 0x1C4 */ Collider* colOC[COLLISION_CHECK_OC_MAX]; - /* 0x28C */ s32 colLineCount; - /* 0x290 */ OcLine* colLine[COLLISION_CHECK_OC_LINE_MAX]; -} CollisionCheckContext; // size = 0x29C - typedef struct { /* 0x00 */ GameState state; } SetupState; // size = 0xA4 @@ -339,18 +183,13 @@ typedef struct { /* 0x00A8 */ View view; } SampleState; // size = 0x1D0 -typedef struct { +typedef struct QuestHintCmd { /* 0x00 */ u8 byte0; /* 0x01 */ u8 byte1; /* 0x02 */ u8 byte2; /* 0x03 */ u8 byte3; } QuestHintCmd; // size = 0x4 -typedef struct { - /* 0x00 */ u8 numActors; - /* 0x04 */ TransitionActorEntry* list; -} TransitionActorContext; // size = 0x8 - typedef enum { /* 0 */ PAUSE_BG_PRERENDER_OFF, // Inactive, do nothing. /* 1 */ PAUSE_BG_PRERENDER_SETUP, // The current frame is only drawn for the purpose of serving as the pause background. @@ -366,87 +205,6 @@ typedef enum { /* 3 */ TRANS_TILE_READY // The transition is ready, so will update and draw each frame } TransitionTileState; -typedef struct PlayState { - /* 0x00000 */ GameState state; - /* 0x000A4 */ s16 sceneId; - /* 0x000A6 */ u8 sceneDrawConfig; - /* 0x000A7 */ char unk_A7[0x9]; - /* 0x000B0 */ void* sceneSegment; - /* 0x000B8 */ View view; - /* 0x001E0 */ Camera mainCamera; - /* 0x0034C */ Camera subCameras[NUM_CAMS - CAM_ID_SUB_FIRST]; - /* 0x00790 */ Camera* cameraPtrs[NUM_CAMS]; - /* 0x007A0 */ s16 activeCamId; - /* 0x007A2 */ s16 nextCamId; - /* 0x007A4 */ SequenceContext sequenceCtx; - /* 0x007A8 */ LightContext lightCtx; - /* 0x007B8 */ FrameAdvanceContext frameAdvCtx; - /* 0x007C0 */ CollisionContext colCtx; - /* 0x01C24 */ ActorContext actorCtx; - /* 0x01D64 */ CutsceneContext csCtx; // "demo_play" - /* 0x01DB4 */ SfxSource sfxSources[16]; - /* 0x01F74 */ SramContext sramCtx; - /* 0x01F78 */ SkyboxContext skyboxCtx; - /* 0x020D8 */ MessageContext msgCtx; // "message" - /* 0x104F0 */ InterfaceContext interfaceCtx; // "parameter" - /* 0x10760 */ PauseContext pauseCtx; - /* 0x10A20 */ GameOverContext gameOverCtx; - /* 0x10A24 */ EnvironmentContext envCtx; - /* 0x10B20 */ AnimTaskQueue animTaskQueue; - /* 0x117A4 */ ObjectContext objectCtx; - /* 0x11CBC */ RoomContext roomCtx; - /* 0x11D34 */ TransitionActorContext transiActorCtx; - /* 0x11D3C */ void (*playerInit)(Player* player, struct PlayState* play, FlexSkeletonHeader* skelHeader); - /* 0x11D40 */ void (*playerUpdate)(Player* player, struct PlayState* play, Input* input); - /* 0x11D44 */ int (*isPlayerDroppingFish)(struct PlayState* play); - /* 0x11D48 */ s32 (*startPlayerFishing)(struct PlayState* play); - /* 0x11D4C */ s32 (*grabPlayer)(struct PlayState* play, Player* player); - /* 0x11D50 */ s32 (*tryPlayerCsAction)(struct PlayState* play, Actor* actor, s32 csAction); - /* 0x11D54 */ void (*func_11D54)(Player* player, struct PlayState* play); - /* 0x11D58 */ s32 (*damagePlayer)(struct PlayState* play, s32 damage); - /* 0x11D5C */ void (*talkWithPlayer)(struct PlayState* play, Actor* actor); - /* 0x11D60 */ MtxF viewProjectionMtxF; - /* 0x11DA0 */ MtxF billboardMtxF; - /* 0x11DE0 */ Mtx* billboardMtx; - /* 0x11DE4 */ u32 gameplayFrames; - /* 0x11DE8 */ u8 linkAgeOnLoad; - /* 0x11DE9 */ u8 haltAllActors; - /* 0x11DEA */ u8 spawn; - /* 0x11DEB */ u8 numActorEntries; - /* 0x11DEC */ u8 numRooms; - /* 0x11DF0 */ RomFile* roomList; - /* 0x11DF4 */ ActorEntry* playerEntry; - /* 0x11DF8 */ ActorEntry* actorEntryList; - /* 0x11DFC */ void* unk_11DFC; - /* 0x11E00 */ Spawn* spawnList; - /* 0x11E04 */ s16* exitList; - /* 0x11E08 */ Path* pathList; - /* 0x11E0C */ QuestHintCmd* naviQuestHints; - /* 0x11E10 */ void* specialEffects; - /* 0x11E14 */ u8 skyboxId; - /* 0x11E15 */ s8 transitionTrigger; // "fade_direction" - /* 0x11E16 */ s16 unk_11E16; - /* 0x11E18 */ s16 bgCoverAlpha; - /* 0x11E1A */ s16 nextEntranceIndex; - /* 0x11E1C */ char unk_11E1C[0x40]; - /* 0x11E5C */ s8 shootingGalleryStatus; - /* 0x11E5D */ s8 bombchuBowlingStatus; // "bombchu_game_flag" - /* 0x11E5E */ u8 transitionType; - /* 0x11E60 */ CollisionCheckContext colChkCtx; - /* 0x120FC */ u16 cutsceneFlags[20]; - /* 0x12124 */ PreRender pauseBgPreRender; - /* 0x12174 */ char unk_12174[0x53]; - /* 0x121C7 */ s8 unk_121C7; - /* 0x121C8 */ TransitionContext transitionCtx; - /* 0x12418 */ char unk_12418[0x3]; - /* 0x1241B */ u8 transitionMode; // "fbdemo_wipe_modem" - /* 0x1241C */ TransitionFade transitionFadeFlash; // Transition fade instance which flashes screen, see R_TRANS_FADE_FLASH_ALPHA_STEP - /* 0x12428 */ char unk_12428[0x3]; - /* 0x1242B */ u8 viewpoint; // toggleable camera setting by shops or player. Is also equal to the bgCamIndex + 1 - /* 0x1242C */ SceneTableEntry* loadedScene; - /* 0x12430 */ char unk_12430[0xE8]; -} PlayState; // size = 0x12518 - typedef struct { /* 0x0000 */ GameState state; /* 0x00A8 */ View view; diff --git a/include/z64actor.h b/include/z64actor.h index 68991ca7d5..ecd6a29112 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -574,6 +574,76 @@ typedef enum { /* 0xFF */ NAVI_ENEMY_NONE = 0xFF } NaviEnemy; +typedef struct TargetContextEntry { + /* 0x00 */ Vec3f pos; + /* 0x0C */ f32 unk_0C; // radius? + /* 0x10 */ Color_RGB8 color; +} TargetContextEntry; // size = 0x14 + +typedef struct TargetContext { + /* 0x00 */ Vec3f naviRefPos; // possibly wrong + /* 0x0C */ Vec3f targetCenterPos; + /* 0x18 */ Color_RGBAf naviInner; + /* 0x28 */ Color_RGBAf naviOuter; + /* 0x38 */ Actor* arrowPointedActor; + /* 0x3C */ Actor* targetedActor; + /* 0x40 */ f32 unk_40; + /* 0x44 */ f32 unk_44; + /* 0x48 */ s16 unk_48; + /* 0x4A */ u8 activeCategory; + /* 0x4B */ u8 unk_4B; + /* 0x4C */ s8 unk_4C; + /* 0x4D */ char unk_4D[0x03]; + /* 0x50 */ TargetContextEntry arr_50[3]; + /* 0x8C */ Actor* unk_8C; + /* 0x90 */ Actor* bgmEnemy; // The nearest enemy to player with the right flags that will trigger NA_BGM_ENEMY + /* 0x94 */ Actor* unk_94; +} TargetContext; // size = 0x98 + +typedef struct TitleCardContext { + /* 0x00 */ void* texture; + /* 0x04 */ s16 x; + /* 0x06 */ s16 y; + /* 0x08 */ u8 width; + /* 0x09 */ u8 height; + /* 0x0A */ u8 durationTimer; // how long the title card appears for before fading + /* 0x0B */ u8 delayTimer; // how long the title card waits to appear + /* 0x0C */ s16 alpha; + /* 0x0E */ s16 intensity; +} TitleCardContext; // size = 0x10 + +typedef struct ActorListEntry { + /* 0x00 */ s32 length; // number of actors loaded of this category + /* 0x04 */ Actor* head; // pointer to head of the linked list of this category (most recent actor added) +} ActorListEntry; // size = 0x08 + +typedef struct ActorContextSceneFlags { + /* 0x00 */ u32 swch; + /* 0x04 */ u32 tempSwch; + /* 0x08 */ u32 unk0; + /* 0x0C */ u32 unk1; + /* 0x10 */ u32 chest; + /* 0x14 */ u32 clear; + /* 0x18 */ u32 tempClear; + /* 0x1C */ u32 collect; + /* 0x20 */ u32 tempCollect; +} ActorContextSceneFlags; // size = 0x24 + +typedef struct ActorContext { + /* 0x000 */ u8 freezeFlashTimer; + /* 0x001 */ char unk_01[0x01]; + /* 0x002 */ u8 unk_02; + /* 0x003 */ u8 lensActive; + /* 0x004 */ char unk_04[0x04]; + /* 0x008 */ u8 total; // total number of actors loaded + /* 0x00C */ ActorListEntry actorLists[ACTORCAT_MAX]; + /* 0x06C */ TargetContext targetCtx; + /* 0x104 */ ActorContextSceneFlags flags; + /* 0x128 */ TitleCardContext titleCtx; + /* 0x138 */ char unk_138[0x04]; + /* 0x13C */ void* absoluteSpace; // Space used to allocate actor overlays with alloc type ACTOROVL_ALLOC_ABSOLUTE +} ActorContext; // size = 0x140 + #define TRANSITION_ACTOR_PARAMS_INDEX_SHIFT 10 #define GET_TRANSITION_ACTOR_INDEX(actor) ((u16)(actor)->params >> TRANSITION_ACTOR_PARAMS_INDEX_SHIFT) diff --git a/include/z64collision_check.h b/include/z64collision_check.h index aa69dedb07..a9cff3a58e 100644 --- a/include/z64collision_check.h +++ b/include/z64collision_check.h @@ -306,6 +306,18 @@ typedef struct { /* 0x18 */ u16 ocFlags; } OcLine; // size = 0x1C +typedef struct CollisionCheckContext { + /* 0x000 */ s16 colATCount; + /* 0x002 */ u16 sacFlags; + /* 0x004 */ Collider* colAT[COLLISION_CHECK_AT_MAX]; + /* 0x0CC */ s32 colACCount; + /* 0x0D0 */ Collider* colAC[COLLISION_CHECK_AC_MAX]; + /* 0x1C0 */ s32 colOCCount; + /* 0x1C4 */ Collider* colOC[COLLISION_CHECK_OC_MAX]; + /* 0x28C */ s32 colLineCount; + /* 0x290 */ OcLine* colLine[COLLISION_CHECK_OC_LINE_MAX]; +} CollisionCheckContext; // size = 0x29C + /* * Collider properties, for all shapes */ diff --git a/include/z64frame_advance.h b/include/z64frame_advance.h new file mode 100644 index 0000000000..b8c77372d6 --- /dev/null +++ b/include/z64frame_advance.h @@ -0,0 +1,19 @@ +#ifndef Z64FRAME_ADVANCE_H +#define Z64FRAME_ADVANCE_H + +#include "ultra64.h" + +struct Input; +struct PlayState; + +typedef struct { + /* 0x0 */ s32 enabled; + /* 0x4 */ s32 timer; +} FrameAdvanceContext; // size = 0x8 + +void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx); +s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, struct Input* input); + +int FrameAdvance_IsEnabled(struct PlayState* this); + +#endif diff --git a/include/z64game_over.h b/include/z64game_over.h new file mode 100644 index 0000000000..03697c1f50 --- /dev/null +++ b/include/z64game_over.h @@ -0,0 +1,29 @@ +#ifndef Z64GAME_OVER_H +#define Z64GAME_OVER_H + +#include "ultra64.h" + +struct PlayState; + +typedef enum GameOverState { + /* 00 */ GAMEOVER_INACTIVE, + /* 01 */ GAMEOVER_DEATH_START, + /* 02 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for link to fall and hit the ground + /* 03 */ GAMEOVER_DEATH_DELAY_MENU, // wait for 1 second before showing the game over menu + /* 04 */ GAMEOVER_DEATH_MENU, // do nothing while kaleidoscope handles the game over menu + /* 20 */ GAMEOVER_REVIVE_START = 20, + /* 21 */ GAMEOVER_REVIVE_RUMBLE, + /* 22 */ GAMEOVER_REVIVE_WAIT_GROUND, // wait for link to fall and hit the ground + /* 23 */ GAMEOVER_REVIVE_WAIT_FAIRY, // wait for the fairy to rise all the way up out of links body + /* 24 */ GAMEOVER_REVIVE_FADE_OUT // fade out the game over lights as link is revived and gets back up +} GameOverState; + +typedef struct GameOverContext { + /* 0x00 */ u16 state; +} GameOverContext; // size = 0x2 + +void GameOver_Init(struct PlayState* play); +void GameOver_FadeInLights(struct PlayState* play); +void GameOver_Update(struct PlayState* play); + +#endif diff --git a/include/z64play.h b/include/z64play.h new file mode 100644 index 0000000000..bfea008834 --- /dev/null +++ b/include/z64play.h @@ -0,0 +1,161 @@ +#ifndef Z64PLAY_H +#define Z64PLAY_H + +#include "ultra64.h" + +#include "prerender.h" + +#include "z64actor.h" +#include "z64bgcheck.h" +#include "z64camera.h" +#include "z64cutscene.h" +#include "z64environment.h" +#include "z64frame_advance.h" +#include "z64game.h" +#include "z64game_over.h" +#include "z64interface.h" +#include "z64light.h" +#include "z64message.h" +#include "z64object.h" +#include "z64pause.h" +#include "z64scene.h" +#include "z64sfx_source.h" +#include "z64skybox.h" +#include "z64sram.h" +#include "z64transition.h" +#include "z64view.h" + +union Color_RGBA8_u32; +struct QuestHintCmd; +struct VisMono; + +typedef struct SceneSequences { + /* 0x00 */ u8 seqId; + /* 0x01 */ u8 natureAmbienceId; +} SceneSequences; // size = 0x2 + +typedef struct PlayState { + /* 0x00000 */ GameState state; + /* 0x000A4 */ s16 sceneId; + /* 0x000A6 */ u8 sceneDrawConfig; + /* 0x000A7 */ char unk_A7[0x9]; + /* 0x000B0 */ void* sceneSegment; + /* 0x000B8 */ View view; + /* 0x001E0 */ Camera mainCamera; + /* 0x0034C */ Camera subCameras[NUM_CAMS - CAM_ID_SUB_FIRST]; + /* 0x00790 */ Camera* cameraPtrs[NUM_CAMS]; + /* 0x007A0 */ s16 activeCamId; + /* 0x007A2 */ s16 nextCamId; + /* 0x007A4 */ SceneSequences sceneSequences; + /* 0x007A8 */ LightContext lightCtx; + /* 0x007B8 */ FrameAdvanceContext frameAdvCtx; + /* 0x007C0 */ CollisionContext colCtx; + /* 0x01C24 */ ActorContext actorCtx; + /* 0x01D64 */ CutsceneContext csCtx; // "demo_play" + /* 0x01DB4 */ SfxSource sfxSources[SFX_SOURCE_COUNT]; + /* 0x01F74 */ SramContext sramCtx; + /* 0x01F78 */ SkyboxContext skyboxCtx; + /* 0x020D8 */ MessageContext msgCtx; // "message" + /* 0x104F0 */ InterfaceContext interfaceCtx; // "parameter" + /* 0x10760 */ PauseContext pauseCtx; + /* 0x10A20 */ GameOverContext gameOverCtx; + /* 0x10A24 */ EnvironmentContext envCtx; + /* 0x10B20 */ AnimTaskQueue animTaskQueue; + /* 0x117A4 */ ObjectContext objectCtx; + /* 0x11CBC */ RoomContext roomCtx; + /* 0x11D34 */ TransitionActorContext transiActorCtx; + /* 0x11D3C */ void (*playerInit)(Player* player, struct PlayState* play, FlexSkeletonHeader* skelHeader); + /* 0x11D40 */ void (*playerUpdate)(Player* player, struct PlayState* play, Input* input); + /* 0x11D44 */ int (*isPlayerDroppingFish)(struct PlayState* play); + /* 0x11D48 */ s32 (*startPlayerFishing)(struct PlayState* play); + /* 0x11D4C */ s32 (*grabPlayer)(struct PlayState* play, Player* player); + /* 0x11D50 */ s32 (*tryPlayerCsAction)(struct PlayState* play, Actor* actor, s32 csAction); + /* 0x11D54 */ void (*func_11D54)(Player* player, struct PlayState* play); + /* 0x11D58 */ s32 (*damagePlayer)(struct PlayState* play, s32 damage); + /* 0x11D5C */ void (*talkWithPlayer)(struct PlayState* play, Actor* actor); + /* 0x11D60 */ MtxF viewProjectionMtxF; + /* 0x11DA0 */ MtxF billboardMtxF; + /* 0x11DE0 */ Mtx* billboardMtx; + /* 0x11DE4 */ u32 gameplayFrames; + /* 0x11DE8 */ u8 linkAgeOnLoad; + /* 0x11DE9 */ u8 haltAllActors; + /* 0x11DEA */ u8 spawn; + /* 0x11DEB */ u8 numActorEntries; + /* 0x11DEC */ u8 numRooms; + /* 0x11DF0 */ RomFile* roomList; + /* 0x11DF4 */ ActorEntry* playerEntry; + /* 0x11DF8 */ ActorEntry* actorEntryList; + /* 0x11DFC */ void* unk_11DFC; + /* 0x11E00 */ Spawn* spawnList; + /* 0x11E04 */ s16* exitList; + /* 0x11E08 */ Path* pathList; + /* 0x11E0C */ struct QuestHintCmd* naviQuestHints; + /* 0x11E10 */ void* specialEffects; + /* 0x11E14 */ u8 skyboxId; + /* 0x11E15 */ s8 transitionTrigger; // "fade_direction" + /* 0x11E16 */ s16 unk_11E16; + /* 0x11E18 */ s16 bgCoverAlpha; + /* 0x11E1A */ s16 nextEntranceIndex; + /* 0x11E1C */ char unk_11E1C[0x40]; + /* 0x11E5C */ s8 shootingGalleryStatus; + /* 0x11E5D */ s8 bombchuBowlingStatus; // "bombchu_game_flag" + /* 0x11E5E */ u8 transitionType; + /* 0x11E60 */ CollisionCheckContext colChkCtx; + /* 0x120FC */ u16 cutsceneFlags[20]; + /* 0x12124 */ PreRender pauseBgPreRender; + /* 0x12174 */ char unk_12174[0x53]; + /* 0x121C7 */ s8 unk_121C7; + /* 0x121C8 */ TransitionContext transitionCtx; + /* 0x12418 */ char unk_12418[0x3]; + /* 0x1241B */ u8 transitionMode; // "fbdemo_wipe_modem" + /* 0x1241C */ TransitionFade transitionFadeFlash; // Transition fade instance which flashes screen, see R_TRANS_FADE_FLASH_ALPHA_STEP + /* 0x12428 */ char unk_12428[0x3]; + /* 0x1242B */ u8 viewpoint; // toggleable camera setting by shops or player. Is also equal to the bgCamIndex + 1 + /* 0x1242C */ SceneTableEntry* loadedScene; + /* 0x12430 */ char unk_12430[0xE8]; +} PlayState; // size = 0x12518 + +#define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamId]) +#define GET_PLAYER(play) ((Player*)(play)->actorCtx.actorLists[ACTORCAT_PLAYER].head) + +void Play_SetViewpoint(PlayState* this, s16 viewpoint); +s32 Play_CheckViewpoint(PlayState* this, s16 viewpoint); +void Play_SetShopBrowsingViewpoint(PlayState* this); +Gfx* Play_SetFog(PlayState* this, Gfx* gfx); +void Play_Destroy(GameState* thisx); +void Play_Init(GameState* thisx); +void Play_Main(GameState* thisx); +int Play_InCsMode(PlayState* this); +f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* pos); +void* Play_LoadFile(PlayState* this, RomFile* file); +void Play_GetScreenPos(PlayState* this, Vec3f* src, Vec3f* dest); +s16 Play_CreateSubCamera(PlayState* this); +s16 Play_GetActiveCamId(PlayState* this); +s16 Play_ChangeCameraStatus(PlayState* this, s16 camId, s16 status); +void Play_ClearCamera(PlayState* this, s16 camId); +void Play_ClearAllSubCameras(PlayState* this); +Camera* Play_GetCamera(PlayState* this, s16 camId); +s32 Play_SetCameraAtEye(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye); +s32 Play_SetCameraAtEyeUp(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); +s32 Play_SetCameraFov(PlayState* this, s16 camId, f32 fov); +s32 Play_SetCameraRoll(PlayState* this, s16 camId, s16 roll); +void Play_CopyCamera(PlayState* this, s16 destCamId, s16 srcCamId); +s32 Play_InitCameraDataUsingPlayer(PlayState* this, s16 camId, Player* player, s16 setting); +s32 Play_RequestCameraSetting(PlayState* this, s16 camId, s16 setting); +void Play_ReturnToMainCam(PlayState* this, s16 camId, s16 duration); +void Play_SaveSceneFlags(PlayState* this); +void Play_SetupRespawnPoint(PlayState* this, s32 respawnMode, s32 playerParams); +void Play_TriggerVoidOut(PlayState* this); +void Play_TriggerRespawn(PlayState* this); +int Play_CamIsNotFixed(PlayState* this); + +#if OOT_DEBUG +extern void* gDebugCutsceneScript; +#endif + +extern TransitionTile gTransitionTile; +extern s32 gTransitionTileState; +extern struct VisMono gPlayVisMono; +extern union Color_RGBA8_u32 gVisMonoColor; + +#endif diff --git a/include/z64scene.h b/include/z64scene.h index c966913f15..f1a45af70b 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -33,6 +33,11 @@ typedef struct { /* 0x0E */ s16 params; } TransitionActorEntry; // size = 0x10 +typedef struct TransitionActorContext { + /* 0x00 */ u8 numActors; + /* 0x04 */ TransitionActorEntry* list; +} TransitionActorContext; // size = 0x8 + typedef struct { /* 0x00 */ u8 playerEntryIndex; /* 0x01 */ u8 room; @@ -139,6 +144,50 @@ typedef union { RoomShapeCullable cullable; } RoomShape; // "Ground Shape" +typedef enum RoomBehaviorType1 { + /* 0 */ ROOM_BEHAVIOR_TYPE1_0, + /* 1 */ ROOM_BEHAVIOR_TYPE1_1, + /* 2 */ ROOM_BEHAVIOR_TYPE1_2, + /* 3 */ ROOM_BEHAVIOR_TYPE1_3, // unused + /* 4 */ ROOM_BEHAVIOR_TYPE1_4, // unused + /* 5 */ ROOM_BEHAVIOR_TYPE1_5 +} RoomBehaviorType1; + +typedef enum RoomBehaviorType2 { + /* 0 */ ROOM_BEHAVIOR_TYPE2_0, + /* 1 */ ROOM_BEHAVIOR_TYPE2_1, + /* 2 */ ROOM_BEHAVIOR_TYPE2_2, + /* 3 */ ROOM_BEHAVIOR_TYPE2_3, + /* 4 */ ROOM_BEHAVIOR_TYPE2_4, + /* 5 */ ROOM_BEHAVIOR_TYPE2_5, + /* 6 */ ROOM_BEHAVIOR_TYPE2_6 +} RoomBehaviorType2; + +typedef struct Room { + /* 0x00 */ s8 num; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 behaviorType2; + /* 0x03 */ u8 behaviorType1; + /* 0x04 */ s8 echo; + /* 0x05 */ u8 lensMode; + /* 0x08 */ RoomShape* roomShape; // original name: "ground_shape" + /* 0x0C */ void* segment; + /* 0x10 */ char unk_10[0x4]; +} Room; // size = 0x14 + +typedef struct RoomContext { + /* 0x00 */ Room curRoom; + /* 0x14 */ Room prevRoom; + /* 0x28 */ void* bufPtrs[2]; + /* 0x30 */ u8 unk_30; + /* 0x31 */ s8 status; + /* 0x34 */ void* unk_34; + /* 0x38 */ DmaRequest dmaRequest; + /* 0x58 */ OSMesgQueue loadQueue; + /* 0x70 */ OSMesg loadMsg; + /* 0x74 */ s16 unk_74[2]; // context-specific data used by the current scene draw config +} RoomContext; // size = 0x78 + #define ROOM_DRAW_OPA (1 << 0) #define ROOM_DRAW_XLU (1 << 1) diff --git a/include/z64sfx_source.h b/include/z64sfx_source.h new file mode 100644 index 0000000000..0034bc90aa --- /dev/null +++ b/include/z64sfx_source.h @@ -0,0 +1,21 @@ +#ifndef Z64SFX_SOURCE_H +#define Z64SFX_SOURCE_H + +#include "ultra64.h" +#include "z64math.h" + +struct PlayState; + +typedef struct SfxSource { + /* 0x00 */ u16 countdown; + /* 0x04 */ Vec3f worldPos; + /* 0x10 */ Vec3f projectedPos; +} SfxSource; // size = 0x1C + +#define SFX_SOURCE_COUNT 16 + +void SfxSource_InitAll(struct PlayState* play); +void SfxSource_UpdateAll(struct PlayState* play); +void SfxSource_PlaySfxAtFixedWorldPos(struct PlayState* play, Vec3f* worldPos, s32 duration, u16 sfxId); + +#endif diff --git a/include/z64vis.h b/include/z64vis.h index c88d6de483..371b2346bd 100644 --- a/include/z64vis.h +++ b/include/z64vis.h @@ -55,7 +55,7 @@ void VisCvg_Draw(VisCvg* this, Gfx** gfxP); // Only one type -typedef struct { +typedef struct VisMono { /* 0x00 */ Vis vis; /* 0x10 */ u16* tlut; /* 0x14 */ Gfx* dList; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 4caafe18c9..681fa2d519 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -6,7 +6,7 @@ // For retail BSS ordering, the block number of D_8015BD7C // must be between 88 and 123 inclusive. -#pragma increment_block_number 30 +#pragma increment_block_number 26 s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags); s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange); diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index bebcac08d7..9b0e03131f 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,5 +1,8 @@ #include "global.h" #include "terminal.h" + +#include "z64frame_advance.h" + #include "overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.h" typedef s32 (*ColChkResetFunc)(PlayState*, Collider*); @@ -7,6 +10,8 @@ typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*); typedef void (*ColChkVsFunc)(PlayState*, CollisionCheckContext*, Collider*, Collider*); typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); +#define SAC_ENABLE (1 << 0) + // For retail BSS ordering, the block number of sparkInit in CollisionCheck_BlueBlood // must be between 183 and 255 inclusive. #pragma increment_block_number 50 @@ -2358,10 +2363,6 @@ void CollisionCheck_ATTrisVsACTris(PlayState* play, CollisionCheckContext* colCh } } -#if OOT_DEBUG -static s8 sBssDummy7; -#endif - void CollisionCheck_ATTrisVsACQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, Collider* acCol) { static Vec3f hitPos; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 8cea75bab8..4e516005c3 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -115,7 +115,7 @@ void* sUnusedEntranceCsList[] = { gDekuTreeIntroCs, gJabuJabuIntroCs, gDcOpeningCs, gMinuetCs, gIceCavernSerenadeCs, gTowerBarrierCs, }; -#pragma increment_block_number 254 +#pragma increment_block_number 248 // Stores the frame the relevant cam data was last applied on u16 gCamAtSplinePointsAppliedFrame; @@ -2229,11 +2229,15 @@ void CutsceneHandler_RunScript(PlayState* play, CutsceneContext* csCtx) { csCtx->curFrame++; - if (OOT_DEBUG && R_USE_DEBUG_CUTSCENE) { +#if OOT_DEBUG + if (R_USE_DEBUG_CUTSCENE) { Cutscene_ProcessScript(play, csCtx, gDebugCutsceneScript); } else { Cutscene_ProcessScript(play, csCtx, play->csCtx.script); } +#else + Cutscene_ProcessScript(play, csCtx, play->csCtx.script); +#endif } } diff --git a/src/code/z_effect.c b/src/code/z_effect.c index b4226e9de4..089387b17a 100644 --- a/src/code/z_effect.c +++ b/src/code/z_effect.c @@ -1,5 +1,7 @@ #include "global.h" +#include "z64frame_advance.h" + EffectContext sEffectContext; EffectInfo sEffectInfoTable[] = { diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 2fddd82707..20691e7162 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -1,6 +1,8 @@ #include "global.h" #include "terminal.h" +#include "z64frame_advance.h" + EffectSsInfo sEffectSsInfo = { 0 }; // "EffectSS2Info" void EffectSs_InitInfo(PlayState* play, s32 tableSize) { diff --git a/src/code/z_frame_advance.c b/src/code/z_frame_advance.c index 930db59b32..64404fb2f7 100644 --- a/src/code/z_frame_advance.c +++ b/src/code/z_frame_advance.c @@ -1,4 +1,9 @@ -#include "global.h" +#include "z64frame_advance.h" + +#include "stdbool.h" + +#include "padmgr.h" +#include "macros.h" void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx) { frameAdvCtx->timer = 0; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index b282fc9e74..ff2f2a57db 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -1,3 +1,5 @@ +#include "z64game_over.h" + #include "global.h" void GameOver_Init(PlayState* play) { diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 5a728aac78..ee1af2c1e2 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -1,13 +1,16 @@ #include "global.h" #include "ultra64.h" #include "terminal.h" + +#include "z64frame_advance.h" + #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "assets/objects/gameplay_field_keep/gameplay_field_keep.h" // For retail BSS ordering, the block number of sLensFlareUnused must be lower // than the extern variables declared in the header (e.g. gLightningStrike) // while the block number of sNGameOverLightNode must be higher. -#pragma increment_block_number 78 +#pragma increment_block_number 70 typedef enum { /* 0x00 */ LIGHTNING_BOLT_START, @@ -2069,30 +2072,30 @@ void Environment_PlaySceneSequence(PlayState* play) { SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, ((void)0, gSaveContext.forcedSeqId)); } gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; - } else if (play->sequenceCtx.seqId == NA_BGM_NO_MUSIC) { - if (play->sequenceCtx.natureAmbienceId == NATURE_ID_NONE) { + } else if (play->sceneSequences.seqId == NA_BGM_NO_MUSIC) { + if (play->sceneSequences.natureAmbienceId == NATURE_ID_NONE) { return; } - if (((void)0, gSaveContext.natureAmbienceId) != play->sequenceCtx.natureAmbienceId) { - Audio_PlayNatureAmbienceSequence(play->sequenceCtx.natureAmbienceId); + if (((void)0, gSaveContext.natureAmbienceId) != play->sceneSequences.natureAmbienceId) { + Audio_PlayNatureAmbienceSequence(play->sceneSequences.natureAmbienceId); } - } else if (play->sequenceCtx.natureAmbienceId == NATURE_ID_NONE) { + } else if (play->sceneSequences.natureAmbienceId == NATURE_ID_NONE) { // "BGM Configuration" - PRINTF("\n\n\nBGM設定game_play->sound_info.BGM=[%d] old_bgm=[%d]\n\n", play->sequenceCtx.seqId, + PRINTF("\n\n\nBGM設定game_play->sound_info.BGM=[%d] old_bgm=[%d]\n\n", play->sceneSequences.seqId, ((void)0, gSaveContext.seqId)); - if (((void)0, gSaveContext.seqId) != play->sequenceCtx.seqId) { - Audio_PlaySceneSequence(play->sequenceCtx.seqId); + if (((void)0, gSaveContext.seqId) != play->sceneSequences.seqId) { + Audio_PlaySceneSequence(play->sceneSequences.seqId); } } else if (((void)0, gSaveContext.save.dayTime) >= CLOCK_TIME(7, 0) && ((void)0, gSaveContext.save.dayTime) <= CLOCK_TIME(17, 10)) { - if (((void)0, gSaveContext.seqId) != play->sequenceCtx.seqId) { - Audio_PlaySceneSequence(play->sequenceCtx.seqId); + if (((void)0, gSaveContext.seqId) != play->sceneSequences.seqId) { + Audio_PlaySceneSequence(play->sceneSequences.seqId); } play->envCtx.timeSeqState = TIMESEQ_FADE_DAY_BGM; } else { - if (((void)0, gSaveContext.natureAmbienceId) != play->sequenceCtx.natureAmbienceId) { - Audio_PlayNatureAmbienceSequence(play->sequenceCtx.natureAmbienceId); + if (((void)0, gSaveContext.natureAmbienceId) != play->sceneSequences.natureAmbienceId) { + Audio_PlayNatureAmbienceSequence(play->sceneSequences.natureAmbienceId); } if (((void)0, gSaveContext.save.dayTime) > CLOCK_TIME(17, 10) && @@ -2108,8 +2111,8 @@ void Environment_PlaySceneSequence(PlayState* play) { PRINTF("\n-----------------\n", ((void)0, gSaveContext.forcedSeqId)); PRINTF("\n 強制BGM=[%d]", ((void)0, gSaveContext.forcedSeqId)); // "Forced BGM" - PRINTF("\n BGM=[%d]", play->sequenceCtx.seqId); - PRINTF("\n エンブ=[%d]", play->sequenceCtx.natureAmbienceId); + PRINTF("\n BGM=[%d]", play->sceneSequences.seqId); + PRINTF("\n エンブ=[%d]", play->sceneSequences.natureAmbienceId); PRINTF("\n status=[%d]", play->envCtx.timeSeqState); Audio_SetEnvReverb(play->roomCtx.curRoom.echo); @@ -2123,7 +2126,7 @@ void Environment_PlayTimeBasedSequence(PlayState* play) { if (play->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && play->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { PRINTF("\n\n\nNa_StartMorinigBgm\n\n"); - Audio_PlayMorningSceneSequence(play->sequenceCtx.seqId); + Audio_PlayMorningSceneSequence(play->sceneSequences.seqId); } play->envCtx.timeSeqState++; @@ -2149,7 +2152,7 @@ void Environment_PlayTimeBasedSequence(PlayState* play) { case TIMESEQ_EARLY_NIGHT_CRITTERS: if (play->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && play->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { - Audio_PlayNatureAmbienceSequence(play->sequenceCtx.natureAmbienceId); + Audio_PlayNatureAmbienceSequence(play->sceneSequences.natureAmbienceId); Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_1, 1); } @@ -2586,10 +2589,10 @@ s32 Environment_IsForcedSequenceDisabled(void) { } void Environment_PlayStormNatureAmbience(PlayState* play) { - if (play->sequenceCtx.natureAmbienceId == NATURE_ID_NONE) { + if (play->sceneSequences.natureAmbienceId == NATURE_ID_NONE) { Audio_PlayNatureAmbienceSequence(NATURE_ID_MARKET_NIGHT); } else { - Audio_PlayNatureAmbienceSequence(play->sequenceCtx.natureAmbienceId); + Audio_PlayNatureAmbienceSequence(play->sceneSequences.natureAmbienceId); } Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_1, 1); diff --git a/src/code/z_play.c b/src/code/z_play.c index 589ea596cb..e763cd9e05 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -2,6 +2,8 @@ #include "quake.h" #include "terminal.h" +#include "z64frame_advance.h" + #if OOT_DEBUG void* gDebugCutsceneScript = NULL; UNK_TYPE D_8012D1F4 = 0; // unused @@ -451,8 +453,8 @@ void Play_Init(GameState* thisx) { Interface_SetSceneRestrictions(this); Environment_PlaySceneSequence(this); - gSaveContext.seqId = this->sequenceCtx.seqId; - gSaveContext.natureAmbienceId = this->sequenceCtx.natureAmbienceId; + gSaveContext.seqId = this->sceneSequences.seqId; + gSaveContext.natureAmbienceId = this->sceneSequences.natureAmbienceId; func_8002DF18(this, GET_PLAYER(this)); AnimTaskQueue_Update(this, &this->animTaskQueue); gSaveContext.respawnFlag = 0; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 0375786e5b..849d936a41 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -409,8 +409,8 @@ BAD_RETURN(s32) Scene_CommandUndefined9(PlayState* play, SceneCmd* cmd) { } BAD_RETURN(s32) Scene_CommandSoundSettings(PlayState* play, SceneCmd* cmd) { - play->sequenceCtx.seqId = cmd->soundSettings.seqId; - play->sequenceCtx.natureAmbienceId = cmd->soundSettings.natureAmbienceId; + play->sceneSequences.seqId = cmd->soundSettings.seqId; + play->sceneSequences.natureAmbienceId = cmd->soundSettings.natureAmbienceId; if (gSaveContext.seqId == (u8)NA_BGM_DISABLED) { SEQCMD_RESET_AUDIO_HEAP(0, cmd->soundSettings.specId); diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index 4f4ac1143e..b38aa2c8e2 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -1,6 +1,8 @@ #include "global.h" #include "quake.h" +#include "z64frame_advance.h" + #include "assets/scenes/indoors/miharigoya/miharigoya_scene.h" #include "assets/scenes/indoors/souko/souko_scene.h" diff --git a/src/code/z_sfx_source.c b/src/code/z_sfx_source.c index c80e0c9b45..1dad386594 100644 --- a/src/code/z_sfx_source.c +++ b/src/code/z_sfx_source.c @@ -1,3 +1,5 @@ +#include "z64sfx_source.h" + #include "global.h" void SfxSource_InitAll(PlayState* play) { diff --git a/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c b/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c index c3ce4fa67a..6e3d236134 100644 --- a/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c +++ b/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c @@ -1,4 +1,7 @@ #include "z_demo_gt.h" + +#include "z64frame_advance.h" + #include "assets/objects/object_gt/object_gt.h" #include "assets/objects/object_geff/object_geff.h" #include "terminal.h" 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 8dd65a769b..4b755ca610 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 @@ -7,6 +7,8 @@ #include "z_en_okarina_effect.h" #include "terminal.h" +#include "z64frame_advance.h" + #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_25) void EnOkarinaEffect_Init(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.c b/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.c index 2ead519335..acf36140c2 100644 --- a/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.c +++ b/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.c @@ -53,6 +53,8 @@ ActorInit En_Wonder_Item_InitVars = { /**/ NULL, }; +#pragma increment_block_number 1 + static Vec3f sTagPointsFree[9]; static Vec3f sTagPointsOrdered[9]; 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 d518e4da43..e3b0c516bc 100644 --- a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c +++ b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c @@ -7,6 +7,8 @@ #include "z_en_zl2.h" #include "terminal.h" +#include "z64frame_advance.h" + #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "assets/objects/object_zl2/object_zl2.h" #include "assets/objects/object_zl2_anime1/object_zl2_anime1.h" 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 08620c6022..cdc701bdd5 100644 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -7,6 +7,9 @@ #include "z_en_zl3.h" #include "terminal.h" + +#include "z64frame_advance.h" + #include "overlays/actors/ovl_En_Encount2/z_en_encount2.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "assets/objects/object_zl2/object_zl2.h" diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index ef33cada43..6427395ae0 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -11,7 +11,7 @@ #include "terminal.h" // For retail BSS ordering, the block number of sStreamSfxProjectedPos must be 0. -#pragma increment_block_number 190 +#pragma increment_block_number 183 #define FLAGS ACTOR_FLAG_4