1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-10 19:20:13 +00:00

Retail kankyo OK (#1735)

* only Environment_Update plus 1 fake match

* more WIP

* remove fake matches

* Environment_Update OK

* void

* add fake comment

* better match for update

* cleanup

* fix fake match

* more fixes

* add comment
This commit is contained in:
engineer124 2024-02-09 00:57:06 +11:00 committed by GitHub
parent 63f0033fe5
commit 488b0e7783
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -252,7 +252,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
gSaveContext.sunsSongState = SUNSSONG_INACTIVE; gSaveContext.sunsSongState = SUNSSONG_INACTIVE;
if (((void)0, gSaveContext.save.dayTime) > CLOCK_TIME(18, 0) || //! FAKE: (void)0 on CLOCK_TIME(18, 0)
if (((void)0, gSaveContext.save.dayTime) > ((void)0, CLOCK_TIME(18, 0)) ||
((void)0, gSaveContext.save.dayTime) < CLOCK_TIME(6, 30)) { ((void)0, gSaveContext.save.dayTime) < CLOCK_TIME(6, 30)) {
((void)0, gSaveContext.save.nightFlag = 1); ((void)0, gSaveContext.save.nightFlag = 1);
} else { } else {
@ -335,12 +336,17 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
envCtx->lightSettingOverride = LIGHT_SETTING_OVERRIDE_NONE; envCtx->lightSettingOverride = LIGHT_SETTING_OVERRIDE_NONE;
envCtx->lightBlendRateOverride = LIGHT_BLENDRATE_OVERRIDE_NONE; envCtx->lightBlendRateOverride = LIGHT_BLENDRATE_OVERRIDE_NONE;
R_ENV_TIME_SPEED_OLD = gTimeSpeed = envCtx->sceneTimeSpeed = 0; envCtx->sceneTimeSpeed = 0;
gTimeSpeed = envCtx->sceneTimeSpeed;
#if OOT_DEBUG
R_ENV_TIME_SPEED_OLD = gTimeSpeed;
R_ENV_DISABLE_DBG = true; R_ENV_DISABLE_DBG = true;
if (CREG(3) != 0) { if (CREG(3) != 0) {
gSaveContext.chamberCutsceneNum = CREG(3) - 1; gSaveContext.chamberCutsceneNum = CREG(3) - 1;
} }
#endif
play->envCtx.precipitation[PRECIP_RAIN_MAX] = 0; play->envCtx.precipitation[PRECIP_RAIN_MAX] = 0;
play->envCtx.precipitation[PRECIP_RAIN_CUR] = 0; play->envCtx.precipitation[PRECIP_RAIN_CUR] = 0;
@ -405,6 +411,7 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
gSkyboxIsChanging = false; gSkyboxIsChanging = false;
gSaveContext.retainWeatherMode = false; gSaveContext.retainWeatherMode = false;
#if OOT_DEBUG
R_ENV_LIGHT1_DIR(0) = 80; R_ENV_LIGHT1_DIR(0) = 80;
R_ENV_LIGHT1_DIR(1) = 80; R_ENV_LIGHT1_DIR(1) = 80;
R_ENV_LIGHT1_DIR(2) = 80; R_ENV_LIGHT1_DIR(2) = 80;
@ -419,6 +426,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
cREG(12) = 0; cREG(12) = 0;
cREG(13) = 0; cREG(13) = 0;
cREG(14) = 0; cREG(14) = 0;
#endif
gUseCutsceneCam = true; gUseCutsceneCam = true;
for (i = 0; i < ARRAY_COUNT(sLightningBolts); i++) { for (i = 0; i < ARRAY_COUNT(sLightningBolts); i++) {
@ -512,10 +521,9 @@ u8 Environment_SmoothStepToS8(s8* pvalue, s8 target, u8 scale, u8 step, u8 minSt
f32 Environment_LerpWeight(u16 max, u16 min, u16 val) { f32 Environment_LerpWeight(u16 max, u16 min, u16 val) {
f32 diff = max - min; f32 diff = max - min;
f32 ret;
if (diff != 0.0f) { if (diff != 0.0f) {
ret = 1.0f - (max - val) / diff; f32 ret = 1.0f - (max - val) / diff;
if (!(ret >= 1.0f)) { if (!(ret >= 1.0f)) {
return ret; return ret;
@ -700,10 +708,12 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon
} }
} }
#if OOT_DEBUG
if (newSkybox1Index == 0xFF) { if (newSkybox1Index == 0xFF) {
// "Environment VR data acquisition failed! Report to Sasaki!" // "Environment VR data acquisition failed! Report to Sasaki!"
PRINTF(VT_COL(RED, WHITE) "\n環境VRデータ取得失敗! ささきまでご報告を!" VT_RST); PRINTF(VT_COL(RED, WHITE) "\n環境VRデータ取得失敗! ささきまでご報告を!" VT_RST);
} }
#endif
if ((envCtx->skybox1Index != newSkybox1Index) && (envCtx->skyboxDmaState == SKYBOX_DMA_INACTIVE)) { if ((envCtx->skybox1Index != newSkybox1Index) && (envCtx->skyboxDmaState == SKYBOX_DMA_INACTIVE)) {
envCtx->skyboxDmaState = SKYBOX_DMA_TEXTURE1_START; envCtx->skyboxDmaState = SKYBOX_DMA_TEXTURE1_START;
@ -815,6 +825,7 @@ void Environment_DisableUnderwaterLights(PlayState* play) {
} }
} }
#if OOT_DEBUG
void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) { void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) {
GfxPrint printer; GfxPrint printer;
s32 pad[2]; s32 pad[2];
@ -869,6 +880,7 @@ void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) {
*gfx = GfxPrint_Close(&printer); *gfx = GfxPrint_Close(&printer);
GfxPrint_Destroy(&printer); GfxPrint_Destroy(&printer);
} }
#endif
void Environment_PlayTimeBasedSequence(PlayState* play); void Environment_PlayTimeBasedSequence(PlayState* play);
void Environment_UpdateRain(PlayState* play); void Environment_UpdateRain(PlayState* play);
@ -881,7 +893,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
u16 j; u16 j;
u16 time; u16 time;
EnvLightSettings* lightSettingsList = play->envCtx.lightSettingsList; EnvLightSettings* lightSettingsList = play->envCtx.lightSettingsList;
s32 adjustment; u8 blendRate;
if ((((void)0, gSaveContext.gameMode) != GAMEMODE_NORMAL) && if ((((void)0, gSaveContext.gameMode) != GAMEMODE_NORMAL) &&
(((void)0, gSaveContext.gameMode) != GAMEMODE_END_CREDITS)) { (((void)0, gSaveContext.gameMode) != GAMEMODE_END_CREDITS)) {
@ -951,6 +963,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
gSaveContext.save.nightFlag = 0; gSaveContext.save.nightFlag = 0;
} }
#if OOT_DEBUG
if (R_ENABLE_ARENA_DBG != 0 || CREG(2) != 0) { if (R_ENABLE_ARENA_DBG != 0 || CREG(2) != 0) {
Gfx* displayList; Gfx* displayList;
Gfx* prevDisplayList; Gfx* prevDisplayList;
@ -967,19 +980,21 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
if (1) {} if (1) {}
CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1690); CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1690);
} }
#endif
if ((envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE) && if ((envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE) &&
(envCtx->lightBlendOverride != LIGHT_BLEND_OVERRIDE_FULL_CONTROL) && (envCtx->lightBlendOverride != LIGHT_BLEND_OVERRIDE_FULL_CONTROL) &&
(envCtx->lightSetting != envCtx->lightSettingOverride) && (envCtx->lightBlend >= 1.0f) && (envCtx->lightSetting != envCtx->lightSettingOverride) && (envCtx->lightBlend >= 1.0f) &&
(envCtx->lightSettingOverride <= LIGHT_SETTING_MAX)) { (envCtx->lightSettingOverride <= LIGHT_SETTING_MAX)) {
envCtx->lightBlend = 0.0f;
envCtx->prevLightSetting = envCtx->lightSetting; envCtx->prevLightSetting = envCtx->lightSetting;
envCtx->lightSetting = envCtx->lightSettingOverride; envCtx->lightSetting = envCtx->lightSettingOverride;
envCtx->lightBlend = 0.0f;
} }
if (envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_FULL_CONTROL) { if (envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_FULL_CONTROL) {
if ((envCtx->lightMode == LIGHT_MODE_TIME) && // Do nothing; Skip updating lights based on time or light settings
} else if ((envCtx->lightMode == LIGHT_MODE_TIME) &&
(envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) { (envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) {
for (i = 0; i < ARRAY_COUNT(sTimeBasedLightConfigs[envCtx->lightConfig]); i++) { for (i = 0; i < ARRAY_COUNT(sTimeBasedLightConfigs[envCtx->lightConfig]); i++) {
if ((gSaveContext.skyboxTime >= sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime) && if ((gSaveContext.skyboxTime >= sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime) &&
@ -988,8 +1003,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
u8 blend8[2]; u8 blend8[2];
s16 blend16[2]; s16 blend16[2];
timeChangeBlend = timeChangeBlend = Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime,
Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime,
sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime, sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime,
((void)0, gSaveContext.skyboxTime)); ((void)0, gSaveContext.skyboxTime));
@ -1019,11 +1033,10 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
blend8[1] = LERP( blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.ambientColor[j], .ambientColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.nextLightSetting]
.ambientColor[j], .ambientColor[j],
timeChangeBlend); timeChangeBlend);
*(envCtx->lightSettings.ambientColor + j) = LERP(blend8[0], blend8[1], configChangeBlend); envCtx->lightSettings.ambientColor[j] = LERP(blend8[0], blend8[1], configChangeBlend);
} }
// set light1 direction for the sun // set light1 direction for the sun
@ -1050,11 +1063,10 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
blend8[1] = LERP( blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.light1Color[j], .light1Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.nextLightSetting]
.light1Color[j], .light1Color[j],
timeChangeBlend); timeChangeBlend);
*(envCtx->lightSettings.light1Color + j) = LERP(blend8[0], blend8[1], configChangeBlend); envCtx->lightSettings.light1Color[j] = LERP(blend8[0], blend8[1], configChangeBlend);
// blend light2Color // blend light2Color
blend8[0] = blend8[0] =
@ -1066,33 +1078,30 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
blend8[1] = LERP( blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.light2Color[j], .light2Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.nextLightSetting]
.light2Color[j], .light2Color[j],
timeChangeBlend); timeChangeBlend);
*(envCtx->lightSettings.light2Color + j) = LERP(blend8[0], blend8[1], configChangeBlend); envCtx->lightSettings.light2Color[j] = LERP(blend8[0], blend8[1], configChangeBlend);
} }
// blend fogColor // blend fogColor
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
blend8[0] = blend8[0] = LERP(
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].fogColor[j],
.fogColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
.fogColor[j], .fogColor[j],
timeChangeBlend); timeChangeBlend);
blend8[1] = LERP( blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.fogColor[j], .fogColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.nextLightSetting]
.fogColor[j], .fogColor[j],
timeChangeBlend); timeChangeBlend);
*(envCtx->lightSettings.fogColor + j) = LERP(blend8[0], blend8[1], configChangeBlend); envCtx->lightSettings.fogColor[j] = LERP(blend8[0], blend8[1], configChangeBlend);
} }
blend16[0] = LERP16( blend16[0] =
ENV_LIGHT_SETTINGS_FOG_NEAR( LERP16(ENV_LIGHT_SETTINGS_FOG_NEAR(
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
.blendRateAndFogNear), .blendRateAndFogNear),
ENV_LIGHT_SETTINGS_FOG_NEAR( ENV_LIGHT_SETTINGS_FOG_NEAR(
@ -1104,26 +1113,25 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.blendRateAndFogNear), .blendRateAndFogNear),
ENV_LIGHT_SETTINGS_FOG_NEAR( ENV_LIGHT_SETTINGS_FOG_NEAR(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.nextLightSetting]
.blendRateAndFogNear), .blendRateAndFogNear),
timeChangeBlend); timeChangeBlend);
envCtx->lightSettings.fogNear = LERP16(blend16[0], blend16[1], configChangeBlend); envCtx->lightSettings.fogNear = LERP16(blend16[0], blend16[1], configChangeBlend);
blend16[0] = LERP16( blend16[0] =
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].zFar, LERP16(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].zFar,
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].zFar, lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].zFar,
timeChangeBlend); timeChangeBlend);
blend16[1] = LERP16( blend16[1] = LERP16(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting].zFar,
.zFar,
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.zFar, .zFar,
timeChangeBlend); timeChangeBlend);
envCtx->lightSettings.zFar = LERP16(blend16[0], blend16[1], configChangeBlend); envCtx->lightSettings.zFar = LERP16(blend16[0], blend16[1], configChangeBlend);
#if OOT_DEBUG
if (sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting >= if (sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting >=
envCtx->numLightSettings) { envCtx->numLightSettings) {
// "The color palette setting seems to be wrong!" // "The color palette setting seems to be wrong!"
@ -1134,6 +1142,8 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting, sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting,
envCtx->numLightSettings - 1); envCtx->numLightSettings - 1);
} }
#endif
break; break;
} }
} }
@ -1153,7 +1163,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
envCtx->lightSettings.zFar = lightSettingsList[envCtx->lightSetting].zFar; envCtx->lightSettings.zFar = lightSettingsList[envCtx->lightSetting].zFar;
envCtx->lightBlend = 1.0f; envCtx->lightBlend = 1.0f;
} else { } else {
u8 blendRate = blendRate =
ENV_LIGHT_SETTINGS_BLEND_RATE_U8(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear); ENV_LIGHT_SETTINGS_BLEND_RATE_U8(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear);
if (blendRate == 0) { if (blendRate == 0) {
@ -1192,15 +1202,16 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
LERP(lightSettingsList[envCtx->prevLightSetting].fogColor[i], LERP(lightSettingsList[envCtx->prevLightSetting].fogColor[i],
lightSettingsList[envCtx->lightSetting].fogColor[i], envCtx->lightBlend); lightSettingsList[envCtx->lightSetting].fogColor[i], envCtx->lightBlend);
} }
envCtx->lightSettings.fogNear = LERP16(
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->prevLightSetting].blendRateAndFogNear), envCtx->lightSettings.fogNear =
LERP16(ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->prevLightSetting].blendRateAndFogNear),
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear), ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear),
envCtx->lightBlend); envCtx->lightBlend);
envCtx->lightSettings.zFar = envCtx->lightSettings.zFar = LERP16(lightSettingsList[envCtx->prevLightSetting].zFar,
LERP16(lightSettingsList[envCtx->prevLightSetting].zFar,
lightSettingsList[envCtx->lightSetting].zFar, envCtx->lightBlend); lightSettingsList[envCtx->lightSetting].zFar, envCtx->lightBlend);
} }
#if OOT_DEBUG
if (envCtx->lightSetting >= envCtx->numLightSettings) { if (envCtx->lightSetting >= envCtx->numLightSettings) {
// "The color palette seems to be wrong!" // "The color palette seems to be wrong!"
PRINTF("\n" VT_FGCOL(RED) "カラーパレットがおかしいようです!"); PRINTF("\n" VT_FGCOL(RED) "カラーパレットがおかしいようです!");
@ -1209,7 +1220,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
PRINTF("\n" VT_FGCOL(YELLOW) "設定パレット=[%d] パレット数=[%d]\n" VT_RST, envCtx->lightSetting, PRINTF("\n" VT_FGCOL(YELLOW) "設定パレット=[%d] パレット数=[%d]\n" VT_RST, envCtx->lightSetting,
envCtx->numLightSettings); envCtx->numLightSettings);
} }
} #endif
} }
envCtx->lightBlendEnabled = true; envCtx->lightBlendEnabled = true;
@ -1261,22 +1272,20 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
envCtx->dirLight2.params.dir.z = envCtx->lightSettings.light2Dir[2]; envCtx->dirLight2.params.dir.z = envCtx->lightSettings.light2Dir[2];
// Adjust fog near and far if necessary // Adjust fog near and far if necessary
adjustment = envCtx->lightSettings.fogNear + envCtx->adjFogNear;
if (adjustment <= ENV_FOGNEAR_MAX) { if ((envCtx->lightSettings.fogNear + envCtx->adjFogNear) <= ENV_FOGNEAR_MAX) {
lightCtx->fogNear = adjustment; lightCtx->fogNear = envCtx->lightSettings.fogNear + envCtx->adjFogNear;
} else { } else {
lightCtx->fogNear = ENV_FOGNEAR_MAX; lightCtx->fogNear = ENV_FOGNEAR_MAX;
} }
adjustment = envCtx->lightSettings.zFar + envCtx->adjZFar; if ((envCtx->lightSettings.zFar + envCtx->adjZFar) <= ENV_ZFAR_MAX) {
lightCtx->zFar = envCtx->lightSettings.zFar + envCtx->adjZFar;
if (adjustment <= ENV_ZFAR_MAX) {
lightCtx->zFar = adjustment;
} else { } else {
lightCtx->zFar = ENV_ZFAR_MAX; lightCtx->zFar = ENV_ZFAR_MAX;
} }
#if OOT_DEBUG
// When environment debug is enabled, various environment related variables can be configured via the reg editor // When environment debug is enabled, various environment related variables can be configured via the reg editor
if (R_ENV_DISABLE_DBG) { if (R_ENV_DISABLE_DBG) {
R_ENV_AMBIENT_COLOR(0) = lightCtx->ambientColor[0]; R_ENV_AMBIENT_COLOR(0) = lightCtx->ambientColor[0];
@ -1357,6 +1366,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
envCtx->windDirection.z = R_ENV_WIND_DIR(2); envCtx->windDirection.z = R_ENV_WIND_DIR(2);
envCtx->windSpeed = R_ENV_WIND_SPEED; envCtx->windSpeed = R_ENV_WIND_SPEED;
} }
#endif
if ((envCtx->dirLight1.params.dir.x == 0) && (envCtx->dirLight1.params.dir.y == 0) && if ((envCtx->dirLight1.params.dir.x == 0) && (envCtx->dirLight1.params.dir.y == 0) &&
(envCtx->dirLight1.params.dir.z == 0)) { (envCtx->dirLight1.params.dir.z == 0)) {
@ -2366,9 +2376,6 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) {
Color_RGBA8 envColor; Color_RGBA8 envColor;
s32 pad; s32 pad;
f32 sp98; f32 sp98;
u16 sp96;
u16 sp94;
u16 sp92;
switch (sandstormState) { switch (sandstormState) {
case SANDSTORM_ACTIVE: case SANDSTORM_ACTIVE:
@ -2475,9 +2482,10 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) {
envColor.g = ((envColor.g * sp98) + ((6.0f - sp98) * primColor.g)) * (1.0f / 6.0f); envColor.g = ((envColor.g * sp98) + ((6.0f - sp98) * primColor.g)) * (1.0f / 6.0f);
envColor.b = ((envColor.b * sp98) + ((6.0f - sp98) * primColor.b)) * (1.0f / 6.0f); envColor.b = ((envColor.b * sp98) + ((6.0f - sp98) * primColor.b)) * (1.0f / 6.0f);
sp96 = (s32)(sSandstormScroll * (11.0f / 6.0f)); {
sp94 = (s32)(sSandstormScroll * (9.0f / 6.0f)); u16 sp96 = (s32)(sSandstormScroll * (11.0f / 6.0f));
sp92 = (s32)(sSandstormScroll * (6.0f / 6.0f)); u16 sp94 = (s32)(sSandstormScroll * (9.0f / 6.0f));
u16 sp92 = (s32)(sSandstormScroll * (6.0f / 6.0f));
OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4044); OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4044);
@ -2488,12 +2496,13 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) {
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, play->envCtx.sandstormPrimA); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, play->envCtx.sandstormPrimA);
gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, play->envCtx.sandstormEnvA); gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, play->envCtx.sandstormEnvA);
gSPSegment(POLY_XLU_DISP++, 0x08, gSPSegment(POLY_XLU_DISP++, 0x08,
Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (u32)sp96 % 4096, 0, 512, 32, 1, (u32)sp94 % 4096, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (u32)sp96 % 4096, 0, 512, 32, 1,
4095 - ((u32)sp92 % 4096), 256, 64)); (u32)sp94 % 4096, 4095 - ((u32)sp92 % 4096), 256, 64));
gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE);
gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL); gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL);
CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4068); CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4068);
}
sSandstormScroll += (s32)sp98; sSandstormScroll += (s32)sp98;
} }