diff --git a/include/functions.h b/include/functions.h index 5d23991a51..110bb867a5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2164,16 +2164,6 @@ void func_801420C0(void* arg0); void func_801420F4(void* arg0); void func_80142100(void* arg0, Gfx** gfx, u32 arg2); -s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8); -void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); -void Skybox_Setup(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId); -void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId); -void Skybox_Init(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId); -Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); -void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); -void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); -void SkyboxDraw_Update(SkyboxContext* skyboxCtx); - // void func_80147520(void); void func_80147564(PlayState* play); s32 Message_ShouldAdvance(PlayState* play); diff --git a/include/z64.h b/include/z64.h index e996f4a5a7..e168bedbc8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -48,6 +48,7 @@ #include "z64scene.h" #include "z64schedule.h" #include "z64skin.h" +#include "z64skybox.h" #include "z64subs.h" #include "z64transition.h" #include "z64view.h" @@ -276,8 +277,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } NmiBuff; // size >= 0x18 -typedef void(*osCreateThread_func)(void*); - typedef enum { SLOWLY_CALLBACK_NO_ARGS, SLOWLY_CALLBACK_ONE_ARG, @@ -306,36 +305,6 @@ typedef struct { /* 0x14 */ OSMesgQueue unk14; } s80185D40; // size = 0x2C -typedef struct { - /* 0x00 */ u32 unk0; - /* 0x04 */ u8 unk4; - /* 0x05 */ u8 unk5; - /* 0x06 */ u8 unk6; - /* 0x07 */ UNK_TYPE1 pad7[0x2]; - /* 0x09 */ u8 unk9; - /* 0x0A */ UNK_TYPE1 padA[0x2]; - /* 0x0C */ u32 unkC; - /* 0x10 */ u16 unk10; - /* 0x12 */ u16 unk12; - /* 0x14 */ u16 unk14; - /* 0x16 */ UNK_TYPE1 pad16[0x2]; - /* 0x18 */ u32 unk18; - /* 0x1C */ u32 unk1C; - /* 0x20 */ u32 unk20; - /* 0x24 */ u32 unk24; - /* 0x28 */ u32 unk28; - /* 0x2C */ u32 unk2C; - /* 0x30 */ u32 unk30; - /* 0x34 */ u32 unk34; -} s8018CFAC; // size = 0x38 - -typedef struct { - /* 0x00 */ Vec3f unk0; - /* 0x0C */ Vec3f unkC; - /* 0x18 */ s16 unk18; - /* 0x1A */ s16 unk1A; -} s80874650; // size = 0x1C - typedef union { F3DVertexColor color; F3DVertexNormal normal; @@ -542,36 +511,6 @@ typedef struct { /* 0xFA */ u8 unk_FA[4]; } EnvironmentContext; // size = 0x100 -typedef struct { - /* 0x000 */ View view; - /* 0x168 */ void* staticSegments[4]; - /* 0x178 */ void* paletteStaticSegment; - /* 0x17C */ Gfx (*dListBuf)[150]; - /* 0x180 */ Gfx* roomDL; - /* 0x184 */ Vtx* roomVtx; - /* 0x188 */ DmaRequest unk188; - /* 0x1A8 */ DmaRequest unk1A8; - /* 0x1C8 */ DmaRequest unk1C8; - /* 0x1E8 */ OSMesgQueue loadQueue; - /* 0x200 */ OSMesg loadMsg; - /* 0x204 */ s16 skyboxShouldDraw; - /* 0x208 */ f32 rotX; - /* 0x20C */ f32 rotY; - /* 0x210 */ f32 rotZ; - /* 0x214 */ Vec3f eye; - /* 0x220 */ s16 angle; - /* 0x222 */ u8 primR; - /* 0x223 */ u8 primG; - /* 0x224 */ u8 primB; - /* 0x225 */ u8 envR; - /* 0x226 */ u8 envG; - /* 0x227 */ u8 envB; -} SkyboxContext; // size = 0x228 - -typedef enum { - /* 0x05 */ SKYBOX_CUTSCENE_MAP = 5 -} SkyboxId; - typedef struct ListAlloc { /* 0x0 */ struct ListAlloc* prev; /* 0x4 */ struct ListAlloc* next; @@ -698,13 +637,7 @@ typedef struct GameState { /* 0xA3 */ u8 unk_A3; } GameState; // size = 0xA4 -typedef struct { - /* 0x00 */ u32 resetting; - /* 0x04 */ u32 resetCount; - /* 0x08 */ OSTime duration; - /* 0x10 */ OSTime resetTime; -} PreNmiBuff; // size = 0x18 (actually osAppNmiBuffer is 0x40 bytes large but the rest is unused) - +struct PlayState; typedef s32 (*ColChkResetFunc)(struct PlayState*, Collider*); typedef void (*ColChkBloodFunc)(struct PlayState*, Collider*, Vec3f*); @@ -906,7 +839,7 @@ typedef struct PlayState { /* 0x18868 */ void* naviQuestHints; // leftover from OoT, system which processes this is removed /* 0x1886C */ AnimatedMaterial* sceneMaterialAnims; /* 0x18870 */ void* specialEffects; - /* 0x18874 */ u8 skyboxId; + /* 0x18874 */ u8 skyboxId; // @see SkyboxId enum /* 0x18875 */ s8 transitionTrigger; // "fade_direction" /* 0x18876 */ s16 worldCoverAlpha; /* 0x18878 */ s16 bgCoverAlpha; @@ -969,14 +902,6 @@ typedef struct { /* 0x10 */ Color_RGBA8_u32 envColor; } Struct_80140E80; // size = 0x14 -typedef struct { - /* 0x00 */ s32 unk0; - /* 0x04 */ s32 unk4; - /* 0x08 */ s32 unk8; - /* 0x0C */ s32 unkC; - /* 0x10 */ s32 unk10; -} struct_801C5F44; // size = 0x14 - // From OoT's struct_80034A14_arg1 typedef struct { /* 0x00 */ s16 unk_00; diff --git a/include/z64skybox.h b/include/z64skybox.h new file mode 100644 index 0000000000..1664b94b13 --- /dev/null +++ b/include/z64skybox.h @@ -0,0 +1,67 @@ +#ifndef Z64_SKYBOX_H +#define Z64_SKYBOX_H + +#include "PR/ultratypes.h" +#include "PR/gbi.h" + +#include "z64dma.h" +#include "z64math.h" +#include "z64view.h" + +struct GraphicsContext; +struct GameState; +struct PlayState; + +typedef enum SkyboxId { + /* 0 */ SKYBOX_NONE, + /* 1 */ SKYBOX_NORMAL_SKY, + /* 2 */ SKYBOX_2, + /* 3 */ SKYBOX_3, + /* 5 */ SKYBOX_CUTSCENE_MAP = 5 +} SkyboxId; + +typedef struct SkyboxContext { + /* 0x000 */ View view; + /* 0x168 */ void* staticSegments[4]; + /* 0x178 */ void* paletteStaticSegment; + /* 0x17C */ Gfx (*dListBuf)[150]; + /* 0x180 */ Gfx* roomDL; + /* 0x184 */ Vtx* roomVtx; + /* 0x188 */ DmaRequest unk188; + /* 0x1A8 */ DmaRequest unk1A8; + /* 0x1C8 */ DmaRequest unk1C8; + /* 0x1E8 */ OSMesgQueue loadQueue; + /* 0x200 */ OSMesg loadMsg; + /* 0x204 */ s16 skyboxShouldDraw; + /* 0x208 */ f32 rotX; + /* 0x20C */ f32 rotY; + /* 0x210 */ f32 rotZ; + /* 0x214 */ Vec3f eye; + /* 0x220 */ s16 angle; + /* 0x222 */ u8 primR; + /* 0x223 */ u8 primG; + /* 0x224 */ u8 primB; + /* 0x225 */ u8 envR; + /* 0x226 */ u8 envG; + /* 0x227 */ u8 envB; +} SkyboxContext; // size = 0x228 + +typedef struct struct_801C5F44 { + /* 0x00 */ s32 unk0; + /* 0x04 */ s32 unk4; + /* 0x08 */ s32 unk8; + /* 0x0C */ s32 unkC; + /* 0x10 */ s32 unk10; +} struct_801C5F44; // size = 0x14 + +s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8); +void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); +void Skybox_Setup(struct GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId); +void func_80143324(struct PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId); +void Skybox_Init(struct GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId); +Mtx* Skybox_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); +void Skybox_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); +void Skybox_Draw(SkyboxContext* skyboxCtx, struct GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); +void Skybox_Update(SkyboxContext* skyboxCtx); + +#endif diff --git a/src/boot_O2_g3/irqmgr.c b/src/boot_O2_g3/irqmgr.c index b100f209d5..152c69b89a 100644 --- a/src/boot_O2_g3/irqmgr.c +++ b/src/boot_O2_g3/irqmgr.c @@ -163,6 +163,6 @@ void IrqMgr_Init(IrqMgr* irqmgr, void* stack, OSPri pri, u8 retraceCount) { osSetEventMesg(0xE, &irqmgr->irqQueue, (OSMesg)0x29D); osViSetEvent(&irqmgr->irqQueue, (OSMesg)0x29A, retraceCount); - osCreateThread(&irqmgr->thread, Z_THREAD_ID_IRQMGR, (osCreateThread_func)IrqMgr_ThreadEntry, irqmgr, stack, pri); + osCreateThread(&irqmgr->thread, Z_THREAD_ID_IRQMGR, IrqMgr_ThreadEntry, irqmgr, stack, pri); osStartThread(&irqmgr->thread); } diff --git a/src/code/z_play.c b/src/code/z_play.c index 740f79d9e1..c6c3cc2735 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -991,7 +991,7 @@ void Play_UpdateMain(PlayState* this) { Room_nop8012D510(this, &this->roomCtx.curRoom, &input[1], 0); Room_nop8012D510(this, &this->roomCtx.prevRoom, &input[1], 1); - SkyboxDraw_Update(&this->skyboxCtx); + Skybox_Update(&this->skyboxCtx); if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { KaleidoScopeCall_Update(this); @@ -1264,14 +1264,14 @@ void Play_DrawMain(PlayState* this) { if (this->unk_18844 == 0) { if (1) { - if (this->skyboxId && !this->envCtx.skyboxDisabled) { - if ((this->skyboxId == 1) || (this->skyboxId == 3)) { + if ((this->skyboxId != SKYBOX_NONE) && !this->envCtx.skyboxDisabled) { + if ((this->skyboxId == SKYBOX_NORMAL_SKY) || (this->skyboxId == SKYBOX_3)) { Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx); - SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.unk_13, - this->view.eye.x, this->view.eye.y, this->view.eye.z); + Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.unk_13, this->view.eye.x, + this->view.eye.y, this->view.eye.z); } else if (!this->skyboxCtx.skyboxShouldDraw) { - SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, - this->view.eye.y, this->view.eye.z); + Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, this->view.eye.y, + this->view.eye.z); } } @@ -1302,8 +1302,8 @@ void Play_DrawMain(PlayState* this) { if (1) {} Camera_GetQuakeOffset(&sp78, GET_ACTIVE_CAM(this)); - SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + sp78.x, - this->view.eye.y + sp78.y, this->view.eye.z + sp78.z); + Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + sp78.x, + this->view.eye.y + sp78.y, this->view.eye.z + sp78.z); } // envCtx.precipitation[PRECIP_RAIN_CUR] @@ -1414,8 +1414,8 @@ void Play_DrawMain(PlayState* this) { Camera_Update(&sp4C, GET_ACTIVE_CAM(this)); View_UpdateViewingMatrix(&this->view); this->view.unk164 = 0; - if ((this->skyboxId != 0) && !this->envCtx.skyboxDisabled) { - SkyboxDraw_UpdateMatrix(&this->skyboxCtx, this->view.eye.x, this->view.eye.y, this->view.eye.z); + if ((this->skyboxId != SKYBOX_NONE) && !this->envCtx.skyboxDisabled) { + Skybox_UpdateMatrix(&this->skyboxCtx, this->view.eye.x, this->view.eye.y, this->view.eye.z); } } diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index f42e66a252..2797fee3cb 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -191,7 +191,7 @@ void Skybox_Setup(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId) skyboxCtx->rotZ = 0.0f; switch (skyboxId) { - case 1: + case SKYBOX_NORMAL_SKY: // Send a DMA request for the cloudy sky texture skyboxCtx->staticSegments[0] = &D_80025D00; size = SEGMENT_ROM_SIZE(d2_cloud_static); @@ -224,7 +224,7 @@ void Skybox_Setup(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId) } break; - case 2: + case SKYBOX_2: break; default: @@ -236,7 +236,7 @@ void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { size_t size; switch (skyboxId) { - case 1: + case SKYBOX_NORMAL_SKY: osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); if (play->envCtx.unk_10 == 0) { @@ -293,10 +293,10 @@ void Skybox_Init(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId) { Skybox_Setup(gameState, skyboxCtx, skyboxId); - if (skyboxId != 0) { + if (skyboxId != SKYBOX_NONE) { skyboxCtx->dListBuf = THA_AllocEndAlign16(&gameState->heap, 0x3840); - if (skyboxId == 5) { + if (skyboxId == SKYBOX_CUTSCENE_MAP) { // Allocate enough space for the vertices for a 6 sided skybox (cube) skyboxCtx->roomVtx = THA_AllocEndAlign16(&gameState->heap, sizeof(Vtx) * 32 * 6); func_80143148(skyboxCtx, 6); diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c index e0884e2707..2569f81fad 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.c @@ -2,7 +2,7 @@ Mtx* sSkyboxDrawMatrix; -Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) { +Mtx* Skybox_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) { Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); Matrix_RotateXFApply(skyboxCtx->rotX); @@ -11,7 +11,7 @@ Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) { return Matrix_ToMtx(sSkyboxDrawMatrix); } -void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { +void Skybox_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { skyboxCtx->primR = primR; skyboxCtx->primG = primG; skyboxCtx->primB = primB; @@ -20,7 +20,7 @@ void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB skyboxCtx->envB = envB; } -void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z) { +void Skybox_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z) { OPEN_DISPS(gfxCtx); func_8012C6AC(gfxCtx); @@ -63,5 +63,5 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb CLOSE_DISPS(gfxCtx); } -void SkyboxDraw_Update(SkyboxContext* skyboxCtx) { +void Skybox_Update(SkyboxContext* skyboxCtx) { } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index e5505e92a3..805d79170f 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1288,17 +1288,17 @@ void Boss02_Static_Update(Actor* thisx, PlayState* play) { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = 0; play->envCtx.lightSettingOverride = 1; - play->skyboxId = 1; + play->skyboxId = SKYBOX_NORMAL_SKY; } else if (!sIsInGiantMode) { this->unk_1D74 = 0.0f; D_801F4E30 = this->unk_1D7C; play->envCtx.lightSettingOverride = 0; - play->skyboxId = 2; + play->skyboxId = SKYBOX_2; } else { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = ((KREG(24) * 0.1f) + 1.0f) * this->unk_1D7C; play->envCtx.lightSettingOverride = 1; - play->skyboxId = 1; + play->skyboxId = SKYBOX_NORMAL_SKY; } Math_ApproachS(&this->unk_1D7C, this->unk_1D7E, 1, 3); diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index a25a339042..9e49ca0b17 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -30,7 +30,7 @@ typedef struct { /* 0x1A */ s16 rotX; } PowderKegFuseSegment; // size = 0x1C -static PowderKegFuseSegment sPowderKegFuseSegments[16]; +PowderKegFuseSegment sPowderKegFuseSegments[16]; ActorInit En_Bom_InitVars = { ACTOR_EN_BOM, diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 7ddd539e79..b4f63eb88c 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -94,7 +94,7 @@ void EnWeatherTag_Init(Actor* thisx, PlayState* play) { break; case WEATHERTAG_TYPE_UNK5: func_800BC154(play, &play->actorCtx, &this->actor, 7); - play->skyboxId = 3; + play->skyboxId = SKYBOX_3; play->envCtx.unk_1F = 5; play->envCtx.unk_20 = 5; D_801F4E74 = 1.0f; @@ -231,10 +231,10 @@ void EnWeatherTag_Die(EnWeatherTag* this, PlayState* play) { // this tag stops spawning after STT cleared? void func_80966B08(EnWeatherTag* this, PlayState* play) { if (func_80966608(this, play, 0, 0, play->envCtx.unk_1F, 5, 100, 2) || (gWeatherMode == 2)) { - play->skyboxId = 3; + play->skyboxId = SKYBOX_3; EnWeatherTag_SetupAction(this, func_80966D20); } else if (D_801F4E74 <= 0.01f) { - play->skyboxId = 1; + play->skyboxId = SKYBOX_NORMAL_SKY; } else { Math_SmoothStepToF(&D_801F4E74, 0.0f, 0.2f, 0.02f, 0.001f); } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 186d8a3ec1..822b19131e 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2783,10 +2783,10 @@ 0x801431E8:("Skybox_Setup",), 0x80143324:("func_80143324",), 0x801434E4:("Skybox_Init",), - 0x801435A0:("SkyboxDraw_UpdateMatrix",), - 0x80143624:("SkyboxDraw_SetColors",), - 0x80143668:("SkyboxDraw_Draw",), - 0x80143A04:("SkyboxDraw_Update",), + 0x801435A0:("Skybox_UpdateMatrix",), + 0x80143624:("Skybox_SetColors",), + 0x80143668:("Skybox_Draw",), + 0x80143A04:("Skybox_Update",), 0x80143A10:("Sram_ActivateOwl",), 0x80143A54:("Sram_ClearHighscores",), 0x80143AC4:("Sram_ClearFlagsAtDawnOfTheFirstDay",),