Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 60 additions & 16 deletions soh/soh/Enhancements/Graphics/Disable2DBackgrounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,59 @@ std::vector<SceneID> fogControlList = {
SCENE_GRAVEKEEPERS_HUT,
};

std::vector<SceneID> skyboxControlList = { SCENE_MARKET_ENTRANCE_DAY,
SCENE_MARKET_ENTRANCE_NIGHT,
SCENE_MARKET_ENTRANCE_RUINS,
SCENE_BACK_ALLEY_DAY,
SCENE_BACK_ALLEY_NIGHT,
SCENE_MARKET_DAY,
SCENE_MARKET_NIGHT,
SCENE_MARKET_RUINS,
SCENE_CASTLE_COURTYARD_ZELDA,
SCENE_TEMPLE_OF_TIME_EXTERIOR_DAY,
SCENE_TEMPLE_OF_TIME_EXTERIOR_NIGHT,
SCENE_TEMPLE_OF_TIME_EXTERIOR_RUINS,
SCENE_FOREST_TEMPLE };
std::vector<SceneID> skyboxSceneControlList = {
SCENE_MARKET_ENTRANCE_DAY,
SCENE_MARKET_ENTRANCE_NIGHT,
SCENE_MARKET_ENTRANCE_RUINS,
SCENE_BACK_ALLEY_DAY,
SCENE_BACK_ALLEY_NIGHT,
SCENE_MARKET_DAY,
SCENE_MARKET_NIGHT,
SCENE_MARKET_RUINS,
SCENE_CASTLE_COURTYARD_ZELDA,
SCENE_TEMPLE_OF_TIME_EXTERIOR_DAY,
SCENE_TEMPLE_OF_TIME_EXTERIOR_NIGHT,
SCENE_TEMPLE_OF_TIME_EXTERIOR_RUINS,
SCENE_FOREST_TEMPLE,
};

std::vector<SkyboxId> skyboxIdControlList = {
SKYBOX_BAZAAR,
SKYBOX_HOUSE_LINK,
SKYBOX_MARKET_ADULT,
SKYBOX_MARKET_CHILD_DAY,
SKYBOX_MARKET_CHILD_NIGHT,
SKYBOX_HAPPY_MASK_SHOP,
SKYBOX_HOUSE_KNOW_IT_ALL_BROTHERS,
SKYBOX_HOUSE_OF_TWINS,
SKYBOX_STABLES,
SKYBOX_HOUSE_KAKARIKO,
SKYBOX_KOKIRI_SHOP,
SKYBOX_GORON_SHOP,
SKYBOX_ZORA_SHOP,
SKYBOX_POTION_SHOP_KAKARIKO,
SKYBOX_POTION_SHOP_MARKET,
SKYBOX_HOUSE_RICHARD,
SKYBOX_HOUSE_IMPA,
SKYBOX_TENT,
SKYBOX_HOUSE_MIDO,
SKYBOX_HOUSE_SARIA,
SKYBOX_HOUSE_ALLEY,
};

void Register3DPreRenderedScenes() {
COND_HOOK(AfterSceneCommands, CVAR_VALUE, [](int16_t sceneNum) {
// Check if this scene is in the skyboxControlList
bool shouldControlSkybox = false;
for (const auto& scene : skyboxControlList) {
for (const auto& scene : skyboxSceneControlList) {
if (sceneNum == scene) {
shouldControlSkybox = true;
break;
}
}

if (shouldControlSkybox) {
// Add a skybox on scenes from skyboxControlList
// Add a skybox on scenes from skyboxSceneControlList
gPlayState->envCtx.skyboxDisabled = false;

// Replace skybox with normal sky
Expand All @@ -89,7 +115,7 @@ void Register3DPreRenderedScenes() {
if (!CVarGetInteger(CVAR_ENHANCEMENT("3DSceneRender"), 0)) {
return;
}
SPDLOG_INFO("Here");

for (auto& scene : fogControlList) {
if (scene == gPlayState->sceneNum) {
if ((HREG(80) != 10) || (HREG(82) != 0)) {
Expand All @@ -112,6 +138,24 @@ void Register3DPreRenderedScenes() {
return;
}
});

REGISTER_VB_SHOULD(VB_LOAD_SKYBOX, {
if (!gPlayState) {
return;
}

if (!CVAR_VALUE) {
return;
}

for (auto& skybox : skyboxIdControlList) {
if (gPlayState->skyboxCtx.skyboxId == skybox) {
gPlayState->skyboxCtx.unk_140 = 0;
*should = false;
return;
}
}
});
}

static RegisterShipInitFunc initFunc(Register3DPreRenderedScenes, { CVAR_NAME });
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,14 @@ typedef enum {
// #### `args`
// - None
VB_DRAW_2D_BACKGROUND,

// #### `result`
// ```c
// CVarGetInteger(CVAR_ENHANCEMENT("3DSceneRender"), 0)
// ```
// #### `args`
// - None
VB_LOAD_SKYBOX,
} GIVanillaBehavior;

#endif
17 changes: 13 additions & 4 deletions soh/src/code/z_vr_box.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
#include "assets/textures/skyboxes/vr_holy1_static.h"
#include "assets/textures/skyboxes/vr_holy1_pal_static.h"

#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"

u32 D_8012AC90[4] = {
0x00000000,
0x00010000,
Expand Down Expand Up @@ -449,17 +452,23 @@ void func_800AF178(SkyboxContext* skyboxCtx, s32 arg1) {

void LoadSkyboxTex(SkyboxContext* skyboxCtx, int segmentIndex, int imageIndex, char* tex, int width, int height,
int offsetW, int offsetH) {
skyboxCtx->textures[segmentIndex][imageIndex] = tex;
if (GameInteractor_Should(VB_LOAD_SKYBOX, true)) {
skyboxCtx->textures[segmentIndex][imageIndex] = tex;
}
}

void LoadSkyboxTexAtOffset(SkyboxContext* skyboxCtx, int segmentIndex, int imageIndex, char* tex, int width, int height,
int offset) {
skyboxCtx->textures[segmentIndex][imageIndex] = tex;
if (GameInteractor_Should(VB_LOAD_SKYBOX, true)) {
skyboxCtx->textures[segmentIndex][imageIndex] = tex;
}
}

void LoadSkyboxPalette(SkyboxContext* skyboxCtx, int paletteIndex, char* palTex, int width, int height) {
skyboxCtx->palettes[paletteIndex] = palTex;
skyboxCtx->palette_size = width * height;
if (GameInteractor_Should(VB_LOAD_SKYBOX, true)) {
skyboxCtx->palettes[paletteIndex] = palTex;
skyboxCtx->palette_size = width * height;
}
}

static const char* sSBVRFine0Tex[] = { gSunriseSkybox1Tex, gSunriseSkybox2Tex, gSunriseSkybox3Tex, gSunriseSkybox4Tex,
Expand Down
Loading