From 7ccb0a641e4d3b5d3e8cdcb1785ff38abdcde2fc Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Wed, 25 Sep 2024 19:45:06 +0200 Subject: [PATCH] [headers] Create letterbox.h, move more protos from functions.h (#2225) * [headers] Create z64shrink_window.h, move more protos from functions.h * format * include * bss * letterbox.h --- include/functions.h | 87 +-------------------- include/letterbox.h | 14 ++++ include/z64.h | 1 + include/z64camera.h | 33 ++++++++ include/z64cutscene.h | 11 +++ include/z64environment.h | 45 +++++++++++ src/boot/z_std_dma.c | 2 +- src/code/main.c | 4 +- src/code/z_bgcheck.c | 2 +- src/code/z_camera.c | 2 +- src/code/z_common_data.c | 2 +- src/code/z_demo.c | 4 +- src/code/z_kankyo.c | 6 +- src/overlays/actors/ovl_Fishing/z_fishing.c | 2 +- 14 files changed, 119 insertions(+), 96 deletions(-) create mode 100644 include/letterbox.h diff --git a/include/functions.h b/include/functions.h index 4d7a70ab61..1cc6278cab 100644 --- a/include/functions.h +++ b/include/functions.h @@ -422,35 +422,6 @@ s32 DynaPolyActor_IsPlayerOnTop(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsPlayerAbove(DynaPolyActor* dynaActor); s32 func_800435B4(DynaPolyActor* dynaActor); s32 func_800435D8(PlayState* play, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4); -void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState* play); -void Camera_InitDataUsingPlayer(Camera* camera, Player* player); -s16 Camera_ChangeStatus(Camera* camera, s16 status); -Vec3s Camera_Update(Camera* camera); -void Camera_Finish(Camera* camera); -s32 Camera_RequestMode(Camera* camera, s16 mode); -s32 Camera_CheckValidMode(Camera* camera, s16 mode); -s32 Camera_RequestSetting(Camera* camera, s16 setting); -s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex); -s16 Camera_GetInputDirYaw(Camera* camera); -Vec3s Camera_GetCamDir(Camera* camera); -s16 Camera_GetCamDirPitch(Camera* camera); -s16 Camera_GetCamDirYaw(Camera* camera); -s32 Camera_RequestQuake(Camera* camera, s32 unused, s16 y, s32 duration); -s32 Camera_SetViewParam(Camera* camera, s32 viewFlag, void* param); -s32 Camera_OverwriteStateFlags(Camera* camera, s16 stateFlags); -s16 Camera_SetStateFlag(Camera* camera, s16 stateFlag); -s16 Camera_UnsetStateFlag(Camera* camera, s16 stateFlag); -s32 Camera_ResetAnim(Camera* camera); -s32 Camera_SetCSParams(Camera* camera, CutsceneCameraPoint* atPoints, CutsceneCameraPoint* eyePoints, Player* player, - s16 relativeToPlayer); -s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 arg3, s16 timer1, s16 timer2, - s16 timer3); -s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera); -Vec3f Camera_GetQuakeOffset(Camera* camera); -void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, - UNK_TYPE arg6); -s32 func_8005B198(void); -s16 Camera_SetFinishedFlag(Camera* camera); void SaveContext_Init(void); s32 func_800635D0(s32); @@ -466,14 +437,7 @@ DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); void DebugDisplay_DrawObjects(PlayState* play); -void Cutscene_InitContext(PlayState* play, CutsceneContext* csCtx); -void Cutscene_StartManual(PlayState* play, CutsceneContext* csCtx); -void Cutscene_StopManual(PlayState* play, CutsceneContext* csCtx); -void Cutscene_UpdateManual(PlayState* play, CutsceneContext* csCtx); -void Cutscene_UpdateScripted(PlayState* play, CutsceneContext* csCtx); -void Cutscene_HandleEntranceTriggers(PlayState* play); -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); @@ -497,46 +461,7 @@ void Font_LoadCharWide(Font* font, u16 character, u16 codePointIndex); void Font_LoadChar(Font* font, u8 character, u16 codePointIndex); void Font_LoadMessageBoxIcon(Font* font, u16 icon); void Font_LoadOrderedFont(Font* font); -s32 Environment_ZBufValToFixedPoint(s32 zBufferVal); -u16 Environment_GetPixelDepth(s32 x, s32 y); -void Environment_GraphCallback(GraphicsContext* gfxCtx, void* param); -void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused); -u8 Environment_SmoothStepToU8(u8* pvalue, u8 target, u8 scale, u8 step, u8 minStep); -u8 Environment_SmoothStepToS8(s8* pvalue, s8 target, u8 scale, u8 step, u8 minStep); -f32 Environment_LerpWeight(u16 max, u16 min, u16 val); -f32 Environment_LerpWeightAccelDecel(u16 endFrame, u16 startFrame, u16 curFrame, u16 accelDuration, u16 decelDuration); -void Environment_EnableUnderwaterLights(PlayState* play, s32 waterLightsIndex); -void Environment_DisableUnderwaterLights(PlayState* play); -void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx, - PauseContext* pauseCtx, MessageContext* msgCtx, GameOverContext* gameOverCtx, - GraphicsContext* gfxCtx); -void Environment_DrawSunAndMoon(PlayState* play); -void Environment_DrawSunLensFlare(PlayState* play, EnvironmentContext* envCtx, View* view, - GraphicsContext* gfxCtx, Vec3f pos, s32 unused); -void Environment_DrawLensFlare(PlayState* play, EnvironmentContext* envCtx, View* view, - GraphicsContext* gfxCtx, Vec3f pos, s32 unused, s16 scale, f32 colorIntensity, - s16 glareStrength, u8 isSun); -void Environment_DrawRain(PlayState* play, View* view, GraphicsContext* gfxCtx); -void Environment_ChangeLightSetting(PlayState* play, u32 lightSetting); -void Environment_UpdateLightningStrike(PlayState* play); -void Environment_AddLightningBolts(PlayState* play, u8 num); -void Environment_DrawLightning(PlayState* play, s32 unused); -void Environment_PlaySceneSequence(PlayState* play); -void Environment_DrawCustomLensFlare(PlayState* play); -void Environment_InitGameOverLights(PlayState* play); -void Environment_FadeInGameOverLights(PlayState* play); -void Environment_FadeOutGameOverLights(PlayState* play); -void Environment_FillScreen(GraphicsContext* gfxCtx, u8 red, u8 green, u8 blue, u8 alpha, u8 drawFlags); -void Environment_DrawSandstorm(PlayState* play, u8 sandstormState); -void Environment_AdjustLights(PlayState* play, f32 arg1, f32 arg2, f32 arg3, f32 arg4); -s32 Environment_GetBgsDayCount(void); -void Environment_ClearBgsDayCount(void); -s32 Environment_GetTotalDays(void); -void Environment_ForcePlaySequence(u16 seqId); -s32 Environment_IsForcedSequenceDisabled(void); -void Environment_PlayStormNatureAmbience(PlayState* play); -void Environment_StopStormNatureAmbience(PlayState* play); -void Environment_WarpSongLeave(PlayState* play); + void Health_InitMeter(PlayState* play); void Health_UpdateMeter(PlayState* play); void Health_DrawMeter(PlayState* play); @@ -794,13 +719,7 @@ void TransitionFade_Draw(void* thisx, Gfx** gfxP); s32 TransitionFade_IsDone(void* thisx); void TransitionFade_SetColor(void* thisx, u32 color); void TransitionFade_SetType(void* thisx, s32 type); -void Letterbox_SetSizeTarget(s32 target); -u32 Letterbox_GetSizeTarget(void); -void Letterbox_SetSize(s32 size); -u32 Letterbox_GetSize(void); -void Letterbox_Init(void); -void Letterbox_Destroy(void); -void Letterbox_Update(s32 updateRate); + void DebugCamera_Init(DebugCam* debugCam, Camera* cameraPtr); void DebugCamera_Enable(DebugCam* debugCam, Camera* cam); void DebugCamera_Update(DebugCam* debugCam, Camera* cam); diff --git a/include/letterbox.h b/include/letterbox.h new file mode 100644 index 0000000000..48d6ea7c13 --- /dev/null +++ b/include/letterbox.h @@ -0,0 +1,14 @@ +#ifndef LETTERBOX_H +#define LETTERBOX_H + +#include "ultra64.h" + +void Letterbox_SetSizeTarget(s32 target); +u32 Letterbox_GetSizeTarget(void); +void Letterbox_SetSize(s32 size); +u32 Letterbox_GetSize(void); +void Letterbox_Init(void); +void Letterbox_Destroy(void); +void Letterbox_Update(s32 updateRate); + +#endif diff --git a/include/z64.h b/include/z64.h index 25b470ad71..0271864e90 100644 --- a/include/z64.h +++ b/include/z64.h @@ -28,6 +28,7 @@ #include "z64animation.h" #include "z64animation_legacy.h" #include "z64dma.h" +#include "letterbox.h" #include "z64math.h" #include "z64map_mark.h" #include "z64message.h" diff --git a/include/z64camera.h b/include/z64camera.h index ee28d87f1c..a985eca4db 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -6,6 +6,9 @@ #include "z64math.h" #include "z64save.h" +struct CollisionContext; +struct View; + #define CAM_STAT_CUT 0 #define CAM_STAT_WAIT 1 #define CAM_STAT_UNK3 3 @@ -1696,4 +1699,34 @@ typedef enum DebugCamTextColor { /* 7 */ DEBUG_CAM_TEXT_GREEN } DebugCamTextColor; +void Camera_Init(Camera* camera, struct View* view, struct CollisionContext* colCtx, struct PlayState* play); +void Camera_InitDataUsingPlayer(Camera* camera, struct Player* player); +s16 Camera_ChangeStatus(Camera* camera, s16 status); +Vec3s Camera_Update(Camera* camera); +void Camera_Finish(Camera* camera); +s32 Camera_RequestMode(Camera* camera, s16 mode); +s32 Camera_CheckValidMode(Camera* camera, s16 mode); +s32 Camera_RequestSetting(Camera* camera, s16 setting); +s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex); +s16 Camera_GetInputDirYaw(Camera* camera); +Vec3s Camera_GetCamDir(Camera* camera); +s16 Camera_GetCamDirPitch(Camera* camera); +s16 Camera_GetCamDirYaw(Camera* camera); +s32 Camera_RequestQuake(Camera* camera, s32 unused, s16 y, s32 duration); +s32 Camera_SetViewParam(Camera* camera, s32 viewFlag, void* param); +s32 Camera_OverwriteStateFlags(Camera* camera, s16 stateFlags); +s16 Camera_SetStateFlag(Camera* camera, s16 stateFlag); +s16 Camera_UnsetStateFlag(Camera* camera, s16 stateFlag); +s32 Camera_ResetAnim(Camera* camera); +s32 Camera_SetCSParams(Camera* camera, CutsceneCameraPoint* atPoints, CutsceneCameraPoint* eyePoints, + struct Player* player, s16 relativeToPlayer); +s32 Camera_ChangeDoorCam(Camera* camera, struct Actor* doorActor, s16 bgCamIndex, f32 arg3, s16 timer1, s16 timer2, + s16 timer3); +s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera); +Vec3f Camera_GetQuakeOffset(Camera* camera); +void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, + UNK_TYPE arg6); +s32 func_8005B198(void); +s16 Camera_SetFinishedFlag(Camera* camera); + #endif diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 627da47e51..d73cb6a47a 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -4,6 +4,8 @@ #include "ultra64.h" #include "z64math.h" +struct PlayState; + typedef union CutsceneData { s32 i; f32 f; @@ -513,4 +515,13 @@ typedef struct CutsceneContext { /* 0x28 */ CsCmdActorCue* actorCues[10]; // "npcdemopnt" } CutsceneContext; // size = 0x50 +void Cutscene_InitContext(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_StartManual(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_StopManual(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_UpdateManual(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_UpdateScripted(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_HandleEntranceTriggers(struct PlayState* play); +void Cutscene_HandleConditionalTriggers(struct PlayState* play); +void Cutscene_SetScript(struct PlayState* play, void* script); + #endif diff --git a/include/z64environment.h b/include/z64environment.h index 79d34bbff5..598c4655a9 100644 --- a/include/z64environment.h +++ b/include/z64environment.h @@ -5,8 +5,12 @@ #include "z64light.h" #include "z64dma.h" +struct GameOverContext; +struct MessageContext; +struct PauseContext; struct PlayState; struct SkyboxContext; +struct View; #define FILL_SCREEN_OPA (1 << 0) #define FILL_SCREEN_XLU (1 << 1) @@ -241,4 +245,45 @@ extern u16 gTimeSpeed; void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, struct SkyboxContext* skyboxCtx); void Environment_DrawSkyboxFilters(struct PlayState* play); +s32 Environment_ZBufValToFixedPoint(s32 zBufferVal); +u16 Environment_GetPixelDepth(s32 x, s32 y); +void Environment_GraphCallback(struct GraphicsContext* gfxCtx, void* param); +void Environment_Init(struct PlayState* play2, EnvironmentContext* envCtx, s32 unused); +u8 Environment_SmoothStepToU8(u8* pvalue, u8 target, u8 scale, u8 step, u8 minStep); +u8 Environment_SmoothStepToS8(s8* pvalue, s8 target, u8 scale, u8 step, u8 minStep); +f32 Environment_LerpWeight(u16 max, u16 min, u16 val); +f32 Environment_LerpWeightAccelDecel(u16 endFrame, u16 startFrame, u16 curFrame, u16 accelDuration, u16 decelDuration); +void Environment_EnableUnderwaterLights(struct PlayState* play, s32 waterLightsIndex); +void Environment_DisableUnderwaterLights(struct PlayState* play); +void Environment_Update(struct PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx, + struct PauseContext* pauseCtx, struct MessageContext* msgCtx, + struct GameOverContext* gameOverCtx, struct GraphicsContext* gfxCtx); +void Environment_DrawSunAndMoon(struct PlayState* play); +void Environment_DrawSunLensFlare(struct PlayState* play, EnvironmentContext* envCtx, struct View* view, + struct GraphicsContext* gfxCtx, Vec3f pos, s32 unused); +void Environment_DrawLensFlare(struct PlayState* play, EnvironmentContext* envCtx, struct View* view, + struct GraphicsContext* gfxCtx, Vec3f pos, s32 unused, s16 scale, f32 colorIntensity, + s16 glareStrength, u8 isSun); +void Environment_DrawRain(struct PlayState* play, struct View* view, struct GraphicsContext* gfxCtx); +void Environment_ChangeLightSetting(struct PlayState* play, u32 lightSetting); +void Environment_UpdateLightningStrike(struct PlayState* play); +void Environment_AddLightningBolts(struct PlayState* play, u8 num); +void Environment_DrawLightning(struct PlayState* play, s32 unused); +void Environment_PlaySceneSequence(struct PlayState* play); +void Environment_DrawCustomLensFlare(struct PlayState* play); +void Environment_InitGameOverLights(struct PlayState* play); +void Environment_FadeInGameOverLights(struct PlayState* play); +void Environment_FadeOutGameOverLights(struct PlayState* play); +void Environment_FillScreen(struct GraphicsContext* gfxCtx, u8 red, u8 green, u8 blue, u8 alpha, u8 drawFlags); +void Environment_DrawSandstorm(struct PlayState* play, u8 sandstormState); +void Environment_AdjustLights(struct PlayState* play, f32 arg1, f32 arg2, f32 arg3, f32 arg4); +s32 Environment_GetBgsDayCount(void); +void Environment_ClearBgsDayCount(void); +s32 Environment_GetTotalDays(void); +void Environment_ForcePlaySequence(u16 seqId); +s32 Environment_IsForcedSequenceDisabled(void); +void Environment_PlayStormNatureAmbience(struct PlayState* play); +void Environment_StopStormNatureAmbience(struct PlayState* play); +void Environment_WarpSongLeave(struct PlayState* play); + #endif diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index 5491e4ca92..55e04ca848 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -27,7 +27,7 @@ #endif #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:106" + "ntsc-1.2:100" StackEntry sDmaMgrStackInfo; OSMesgQueue sDmaMgrMsgQueue; diff --git a/src/code/main.c b/src/code/main.c index ba53239c8f..310ff63cf5 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -22,8 +22,8 @@ extern struct IrqMgr gIrqMgr; #include "n64dd.h" #endif -#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ - "ntsc-1.2:163" +#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ + "ntsc-1.2:158" extern u8 _buffersSegmentEnd[]; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index dcc2a0df33..7a5a8dc63d 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,7 +1,7 @@ #include "global.h" #include "terminal.h" -#pragma increment_block_number "ntsc-1.2:152" +#pragma increment_block_number "ntsc-1.2:144" u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList); void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 346e334504..5a4c486976 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -3638,7 +3638,7 @@ s32 Camera_KeepOn3(Camera* camera) { } #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:107" + "ntsc-1.2:102" s32 Camera_KeepOn4(Camera* camera) { static Vec3f D_8015BD50; diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 1c70bfb0f4..dcd0ee4d2e 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -3,7 +3,7 @@ #include "versions.h" #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:224" + "ntsc-1.2:192" ALIGNED(16) SaveContext gSaveContext; u32 D_8015FA88; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index e691c67980..527bd02bcf 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -124,8 +124,8 @@ u16 gCamAtSplinePointsAppliedFrame; u16 gCamEyePointAppliedFrame; u16 gCamAtPointAppliedFrame; -#pragma increment_block_number "gc-eu:192 gc-eu-mq:176 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ - "ntsc-1.2:96" +#pragma increment_block_number "gc-eu:192 gc-eu-mq:176 gc-jp:192 gc-jp-ce:192 gc-jp-mq:176 gc-us:192 gc-us-mq:176" \ + "ntsc-1.2:80" // Cam ID to return to when a scripted cutscene is finished s16 sReturnToCamId; diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 402840aca1..ab69972d29 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -7,7 +7,7 @@ #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "assets/objects/gameplay_field_keep/gameplay_field_keep.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:0" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:0" typedef enum LightningBoltState { /* 0x00 */ LIGHTNING_BOLT_START, @@ -212,8 +212,8 @@ s16 sLightningFlashAlpha; s16 sSunDepthTestX; s16 sSunDepthTestY; -#pragma increment_block_number "gc-eu:112 gc-eu-mq:112 gc-jp:216 gc-jp-ce:216 gc-jp-mq:216 gc-us:216 gc-us-mq:216" \ - "ntsc-1.2:224" +#pragma increment_block_number "gc-eu:239 gc-eu-mq:239 gc-jp:216 gc-jp-ce:216 gc-jp-mq:216 gc-us:216 gc-us-mq:216" \ + "ntsc-1.2:216" LightNode* sNGameOverLightNode; LightInfo sNGameOverLightInfo; diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index da24becbc8..253e3ee232 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -16,7 +16,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:130 gc-jp-ce:130 gc-jp-mq:130 gc-us:130 gc-us-mq:130" +#pragma increment_block_number "gc-eu:123 gc-eu-mq:123 gc-jp:125 gc-jp-ce:125 gc-jp-mq:125 gc-us:125 gc-us-mq:125" #define FLAGS ACTOR_FLAG_4