1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 09:45:02 +00:00

Add skybox .h and cleanup, SkyboxDraw_ -> Skybox_ (#1435)

* Add skybox .h and cleanup

* move forward declared structs to top of file

* `SkyboxDraw_` -> `Skybox_`

* format

* move more forward declared structs to top of file
This commit is contained in:
Dragorn421 2022-11-26 23:53:41 +01:00 committed by GitHub
parent 186ecc72b5
commit 92f081d7f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 92 additions and 70 deletions

View file

@ -814,7 +814,6 @@ u8 Environment_SmoothStepToU8(u8* pvalue, u8 target, u8 scale, u8 step, u8 minSt
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_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxContext* skyboxCtx);
void Environment_EnableUnderwaterLights(PlayState* play, s32 waterLightsIndex);
void Environment_DisableUnderwaterLights(PlayState* play);
void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx,
@ -828,7 +827,6 @@ void Environment_DrawLensFlare(PlayState* play, EnvironmentContext* envCtx, View
s16 glareStrength, u8 isSun);
void Environment_DrawRain(PlayState* play, View* view, GraphicsContext* gfxCtx);
void Environment_ChangeLightSetting(PlayState* play, u32 lightSetting);
void Environment_DrawSkyboxFilters(PlayState* play);
void Environment_UpdateLightningStrike(PlayState* play);
void Environment_AddLightningBolts(PlayState* play, u8 num);
void Environment_DrawLightning(PlayState* play, s32 unused);
@ -1295,10 +1293,6 @@ void VisMono_Draw(VisMono* this, Gfx** gfxp);
void func_800AD920(struct_80166500* this);
void func_800AD950(struct_80166500* this);
void func_800AD958(struct_80166500* this, Gfx** gfxp);
void Skybox_Init(GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId);
Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z);
void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z);
void SkyboxDraw_Update(SkyboxContext* skyboxCtx);
void PlayerCall_InitFuncPtrs(void);
void TransitionUnk_InitGraphics(TransitionUnk* this);
void TransitionUnk_InitData(TransitionUnk* this);

View file

@ -60,10 +60,7 @@ extern GameStateOverlay gGameStateOverlayTable[6];
extern u8 gWeatherMode;
extern u8 gLightConfigAfterUnderwater;
extern u8 gInterruptSongOfStorms;
extern u8 gSkyboxIsChanging;
extern u16 gTimeSpeed;
extern TimeBasedSkyboxEntry gTimeBasedSkyboxConfigs[][9];
extern SkyboxFile gNormalSkyFiles[];
extern s32 gZeldaArenaLogSeverity;
extern MapData gMapDataTable;
extern s16 gSpoilingItems[3];

View file

@ -26,6 +26,7 @@
#include "z64skin.h"
#include "z64transition.h"
#include "z64interface.h"
#include "z64skybox.h"
#include "alignment.h"
#include "seqcmd.h"
#include "sequence.h"
@ -361,49 +362,6 @@ typedef struct {
/* 0x10 */ Vec3f projectedPos;
} SfxSource; // size = 0x1C
typedef enum {
/* 0x00 */ SKYBOX_NONE,
/* 0x01 */ SKYBOX_NORMAL_SKY,
/* 0x02 */ SKYBOX_BAZAAR,
/* 0x03 */ SKYBOX_OVERCAST_SUNSET,
/* 0x04 */ SKYBOX_MARKET_ADULT,
/* 0x05 */ SKYBOX_CUTSCENE_MAP,
/* 0x07 */ SKYBOX_HOUSE_LINK = 7,
/* 0x09 */ SKYBOX_MARKET_CHILD_DAY = 9,
/* 0x0A */ SKYBOX_MARKET_CHILD_NIGHT,
/* 0x0B */ SKYBOX_HAPPY_MASK_SHOP,
/* 0x0C */ SKYBOX_HOUSE_KNOW_IT_ALL_BROTHERS,
/* 0x0E */ SKYBOX_HOUSE_OF_TWINS = 14,
/* 0x0F */ SKYBOX_STABLES,
/* 0x10 */ SKYBOX_HOUSE_KAKARIKO,
/* 0x11 */ SKYBOX_KOKIRI_SHOP,
/* 0x13 */ SKYBOX_GORON_SHOP = 19,
/* 0x14 */ SKYBOX_ZORA_SHOP,
/* 0x16 */ SKYBOX_POTION_SHOP_KAKARIKO = 22,
/* 0x17 */ SKYBOX_POTION_SHOP_MARKET,
/* 0x18 */ SKYBOX_BOMBCHU_SHOP,
/* 0x1A */ SKYBOX_HOUSE_RICHARD = 26,
/* 0x1B */ SKYBOX_HOUSE_IMPA,
/* 0x1C */ SKYBOX_TENT,
/* 0x1D */ SKYBOX_UNSET_1D,
/* 0x20 */ SKYBOX_HOUSE_MIDO = 32,
/* 0x21 */ SKYBOX_HOUSE_SARIA,
/* 0x22 */ SKYBOX_HOUSE_ALLEY,
/* 0x27 */ SKYBOX_UNSET_27 = 39
} SkyboxId;
typedef struct {
/* 0x000 */ char unk_00[0x128];
/* 0x128 */ void* staticSegments[2];
/* 0x130 */ u16 (*palettes)[256];
/* 0x134 */ Gfx (*dListBuf)[150];
/* 0x138 */ Gfx* unk_138;
/* 0x13C */ Vtx* roomVtx;
/* 0x140 */ s16 unk_140;
/* 0x144 */ Vec3f rot;
/* 0x150 */ char unk_150[0x10];
} SkyboxContext; // size = 0x160
typedef enum {
TEXTBOX_ICON_TRIANGLE,
TEXTBOX_ICON_SQUARE,
@ -1838,11 +1796,6 @@ typedef struct {
/* 0x04 */ const char* name;
} FlagSetEntry; // size = 0x08
typedef struct {
/* 0x00 */ RomFile file;
/* 0x08 */ RomFile palette;
} SkyboxFile; // size = 0x10
#define ROM_FILE(name) \
{ (uintptr_t)_##name##SegmentRomStart, (uintptr_t)_##name##SegmentRomEnd }
#define ROM_FILE_EMPTY(name) \

View file

@ -5,6 +5,9 @@
#include "z64light.h"
#include "z64dma.h"
struct PlayState;
struct SkyboxContext;
#define FILL_SCREEN_OPA (1 << 0)
#define FILL_SCREEN_XLU (1 << 1)
@ -231,4 +234,10 @@ typedef struct {
/* 0xF3 */ char unk_F3[0x09];
} EnvironmentContext; // size = 0xFC
extern u8 gSkyboxIsChanging;
extern TimeBasedSkyboxEntry gTimeBasedSkyboxConfigs[][9];
void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, struct SkyboxContext* skyboxCtx);
void Environment_DrawSkyboxFilters(struct PlayState* play);
#endif

69
include/z64skybox.h Normal file
View file

@ -0,0 +1,69 @@
#ifndef Z64_SKYBOX_H
#define Z64_SKYBOX_H
#include "ultra64/ultratypes.h"
#include "ultra64/gbi.h"
#include "z64math.h"
#include "z64scene.h" // for RomFile
struct GameState;
struct GraphicsContext;
typedef enum {
/* 0x00 */ SKYBOX_NONE,
/* 0x01 */ SKYBOX_NORMAL_SKY,
/* 0x02 */ SKYBOX_BAZAAR,
/* 0x03 */ SKYBOX_OVERCAST_SUNSET,
/* 0x04 */ SKYBOX_MARKET_ADULT,
/* 0x05 */ SKYBOX_CUTSCENE_MAP,
/* 0x07 */ SKYBOX_HOUSE_LINK = 7,
/* 0x09 */ SKYBOX_MARKET_CHILD_DAY = 9,
/* 0x0A */ SKYBOX_MARKET_CHILD_NIGHT,
/* 0x0B */ SKYBOX_HAPPY_MASK_SHOP,
/* 0x0C */ SKYBOX_HOUSE_KNOW_IT_ALL_BROTHERS,
/* 0x0E */ SKYBOX_HOUSE_OF_TWINS = 14,
/* 0x0F */ SKYBOX_STABLES,
/* 0x10 */ SKYBOX_HOUSE_KAKARIKO,
/* 0x11 */ SKYBOX_KOKIRI_SHOP,
/* 0x13 */ SKYBOX_GORON_SHOP = 19,
/* 0x14 */ SKYBOX_ZORA_SHOP,
/* 0x16 */ SKYBOX_POTION_SHOP_KAKARIKO = 22,
/* 0x17 */ SKYBOX_POTION_SHOP_MARKET,
/* 0x18 */ SKYBOX_BOMBCHU_SHOP,
/* 0x1A */ SKYBOX_HOUSE_RICHARD = 26,
/* 0x1B */ SKYBOX_HOUSE_IMPA,
/* 0x1C */ SKYBOX_TENT,
/* 0x1D */ SKYBOX_UNSET_1D,
/* 0x20 */ SKYBOX_HOUSE_MIDO = 32,
/* 0x21 */ SKYBOX_HOUSE_SARIA,
/* 0x22 */ SKYBOX_HOUSE_ALLEY,
/* 0x27 */ SKYBOX_UNSET_27 = 39
} SkyboxId;
typedef struct SkyboxContext {
/* 0x000 */ char unk_00[0x128];
/* 0x128 */ void* staticSegments[2];
/* 0x130 */ u16 (*palettes)[256];
/* 0x134 */ Gfx (*dListBuf)[150];
/* 0x138 */ Gfx* unk_138;
/* 0x13C */ Vtx* roomVtx;
/* 0x140 */ s16 unk_140;
/* 0x144 */ Vec3f rot;
/* 0x150 */ char unk_150[0x10];
} SkyboxContext; // size = 0x160
typedef struct {
/* 0x00 */ RomFile file;
/* 0x08 */ RomFile palette;
} SkyboxFile; // size = 0x10
extern SkyboxFile gNormalSkyFiles[];
void Skybox_Init(struct GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId);
Mtx* Skybox_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z);
void Skybox_Draw(SkyboxContext* skyboxCtx, struct GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y,
f32 z);
void Skybox_Update(SkyboxContext* skyboxCtx);
#endif

View file

@ -939,7 +939,7 @@ void Play_Update(PlayState* this) {
}
PLAY_LOG(3708);
SkyboxDraw_Update(&this->skyboxCtx);
Skybox_Update(&this->skyboxCtx);
PLAY_LOG(3716);
@ -1135,11 +1135,11 @@ void Play_Draw(PlayState* this) {
if (this->skyboxId && (this->skyboxId != SKYBOX_UNSET_1D) && !this->envCtx.skyboxDisabled) {
if ((this->skyboxId == SKYBOX_NORMAL_SKY) || (this->skyboxId == SKYBOX_CUTSCENE_MAP)) {
Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx);
SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.skyboxBlend,
this->view.eye.x, this->view.eye.y, this->view.eye.z);
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.skyboxBlend,
this->view.eye.x, this->view.eye.y, this->view.eye.z);
} else if (this->skyboxCtx.unk_140 == 0) {
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);
}
}
}
@ -1183,8 +1183,8 @@ void Play_Draw(PlayState* this) {
Vec3f quakeOffset;
Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(this));
SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + quakeOffset.x,
this->view.eye.y + quakeOffset.y, this->view.eye.z + quakeOffset.z);
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + quakeOffset.x,
this->view.eye.y + quakeOffset.y, this->view.eye.z + quakeOffset.z);
}
}
@ -1268,7 +1268,7 @@ void Play_Draw(PlayState* this) {
View_UpdateViewingMatrix(&this->view);
this->view.unk_124 = 0;
if (this->skyboxId && (this->skyboxId != SKYBOX_UNSET_1D) && !this->envCtx.skyboxDisabled) {
SkyboxDraw_UpdateMatrix(&this->skyboxCtx, this->view.eye.x, this->view.eye.y, this->view.eye.z);
Skybox_UpdateMatrix(&this->skyboxCtx, this->view.eye.x, this->view.eye.y, this->view.eye.z);
}
}

View file

@ -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_RotateX(skyboxCtx->rot.x, MTXMODE_APPLY);
@ -11,7 +11,7 @@ Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) {
return Matrix_ToMtx(sSkyboxDrawMatrix, "../z_vr_box_draw.c", 42);
}
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, "../z_vr_box_draw.c", 52);
Gfx_SetupDL_40Opa(gfxCtx);
@ -80,5 +80,5 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb
CLOSE_DISPS(gfxCtx, "../z_vr_box_draw.c", 125);
}
void SkyboxDraw_Update(SkyboxContext* skyboxCtx) {
void Skybox_Update(SkyboxContext* skyboxCtx) {
}

View file

@ -1126,7 +1126,7 @@ void FileSelect_ConfigModeDraw(GameState* thisx) {
eyeZ = 1000.0f * Math_SinS(ZREG(11)) + 1000.0f * Math_CosS(ZREG(11));
FileSelect_SetView(this, eyeX, eyeY, eyeZ);
SkyboxDraw_Draw(&this->skyboxCtx, this->state.gfxCtx, 1, this->envCtx.skyboxBlend, eyeX, eyeY, eyeZ);
Skybox_Draw(&this->skyboxCtx, this->state.gfxCtx, 1, this->envCtx.skyboxBlend, eyeX, eyeY, eyeZ);
gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE);
ZREG(11) += ZREG(10);
Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &this->envCtx, &this->skyboxCtx);
@ -1539,7 +1539,7 @@ void FileSelect_SelectModeDraw(GameState* thisx) {
eyeZ = 1000.0f * Math_SinS(ZREG(11)) + 1000.0f * Math_CosS(ZREG(11));
FileSelect_SetView(this, eyeX, eyeY, eyeZ);
SkyboxDraw_Draw(&this->skyboxCtx, this->state.gfxCtx, 1, this->envCtx.skyboxBlend, eyeX, eyeY, eyeZ);
Skybox_Draw(&this->skyboxCtx, this->state.gfxCtx, 1, this->envCtx.skyboxBlend, eyeX, eyeY, eyeZ);
gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE);
ZREG(11) += ZREG(10);
Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &this->envCtx, &this->skyboxCtx);