mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-25 22:26:12 +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:
parent
63f0033fe5
commit
488b0e7783
1 changed files with 252 additions and 243 deletions
|
@ -252,7 +252,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
|
|||
|
||||
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.nightFlag = 1);
|
||||
} else {
|
||||
|
@ -335,12 +336,17 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
|
|||
envCtx->lightSettingOverride = LIGHT_SETTING_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;
|
||||
|
||||
if (CREG(3) != 0) {
|
||||
gSaveContext.chamberCutsceneNum = CREG(3) - 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
play->envCtx.precipitation[PRECIP_RAIN_MAX] = 0;
|
||||
play->envCtx.precipitation[PRECIP_RAIN_CUR] = 0;
|
||||
|
@ -405,6 +411,7 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
|
|||
gSkyboxIsChanging = false;
|
||||
gSaveContext.retainWeatherMode = false;
|
||||
|
||||
#if OOT_DEBUG
|
||||
R_ENV_LIGHT1_DIR(0) = 80;
|
||||
R_ENV_LIGHT1_DIR(1) = 80;
|
||||
R_ENV_LIGHT1_DIR(2) = 80;
|
||||
|
@ -419,6 +426,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
|
|||
cREG(12) = 0;
|
||||
cREG(13) = 0;
|
||||
cREG(14) = 0;
|
||||
#endif
|
||||
|
||||
gUseCutsceneCam = true;
|
||||
|
||||
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 diff = max - min;
|
||||
f32 ret;
|
||||
|
||||
if (diff != 0.0f) {
|
||||
ret = 1.0f - (max - val) / diff;
|
||||
f32 ret = 1.0f - (max - val) / diff;
|
||||
|
||||
if (!(ret >= 1.0f)) {
|
||||
return ret;
|
||||
|
@ -700,10 +708,12 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon
|
|||
}
|
||||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
if (newSkybox1Index == 0xFF) {
|
||||
// "Environment VR data acquisition failed! Report to Sasaki!"
|
||||
PRINTF(VT_COL(RED, WHITE) "\n環境VRデータ取得失敗! ささきまでご報告を!" VT_RST);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((envCtx->skybox1Index != newSkybox1Index) && (envCtx->skyboxDmaState == SKYBOX_DMA_INACTIVE)) {
|
||||
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) {
|
||||
GfxPrint printer;
|
||||
s32 pad[2];
|
||||
|
@ -869,6 +880,7 @@ void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) {
|
|||
*gfx = GfxPrint_Close(&printer);
|
||||
GfxPrint_Destroy(&printer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Environment_PlayTimeBasedSequence(PlayState* play);
|
||||
void Environment_UpdateRain(PlayState* play);
|
||||
|
@ -881,7 +893,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
u16 j;
|
||||
u16 time;
|
||||
EnvLightSettings* lightSettingsList = play->envCtx.lightSettingsList;
|
||||
s32 adjustment;
|
||||
u8 blendRate;
|
||||
|
||||
if ((((void)0, gSaveContext.gameMode) != GAMEMODE_NORMAL) &&
|
||||
(((void)0, gSaveContext.gameMode) != GAMEMODE_END_CREDITS)) {
|
||||
|
@ -951,6 +963,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
gSaveContext.save.nightFlag = 0;
|
||||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
if (R_ENABLE_ARENA_DBG != 0 || CREG(2) != 0) {
|
||||
Gfx* displayList;
|
||||
Gfx* prevDisplayList;
|
||||
|
@ -967,249 +980,247 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
if (1) {}
|
||||
CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1690);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE) &&
|
||||
(envCtx->lightBlendOverride != LIGHT_BLEND_OVERRIDE_FULL_CONTROL) &&
|
||||
(envCtx->lightSetting != envCtx->lightSettingOverride) && (envCtx->lightBlend >= 1.0f) &&
|
||||
(envCtx->lightSettingOverride <= LIGHT_SETTING_MAX)) {
|
||||
|
||||
envCtx->lightBlend = 0.0f;
|
||||
envCtx->prevLightSetting = envCtx->lightSetting;
|
||||
envCtx->lightSetting = envCtx->lightSettingOverride;
|
||||
envCtx->lightBlend = 0.0f;
|
||||
}
|
||||
|
||||
if (envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_FULL_CONTROL) {
|
||||
if ((envCtx->lightMode == LIGHT_MODE_TIME) &&
|
||||
(envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) {
|
||||
for (i = 0; i < ARRAY_COUNT(sTimeBasedLightConfigs[envCtx->lightConfig]); i++) {
|
||||
if ((gSaveContext.skyboxTime >= sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime) &&
|
||||
((gSaveContext.skyboxTime < sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime) ||
|
||||
sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime == 0xFFFF)) {
|
||||
u8 blend8[2];
|
||||
s16 blend16[2];
|
||||
if (envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_FULL_CONTROL) {
|
||||
// Do nothing; Skip updating lights based on time or light settings
|
||||
} else if ((envCtx->lightMode == LIGHT_MODE_TIME) &&
|
||||
(envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) {
|
||||
for (i = 0; i < ARRAY_COUNT(sTimeBasedLightConfigs[envCtx->lightConfig]); i++) {
|
||||
if ((gSaveContext.skyboxTime >= sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime) &&
|
||||
((gSaveContext.skyboxTime < sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime) ||
|
||||
sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime == 0xFFFF)) {
|
||||
u8 blend8[2];
|
||||
s16 blend16[2];
|
||||
|
||||
timeChangeBlend =
|
||||
Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime,
|
||||
sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime,
|
||||
((void)0, gSaveContext.skyboxTime));
|
||||
timeChangeBlend = Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime,
|
||||
sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime,
|
||||
((void)0, gSaveContext.skyboxTime));
|
||||
|
||||
sSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting & 3;
|
||||
sNextSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting & 3;
|
||||
sSandstormLerpScale = timeChangeBlend;
|
||||
sSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting & 3;
|
||||
sNextSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting & 3;
|
||||
sSandstormLerpScale = timeChangeBlend;
|
||||
|
||||
if (envCtx->changeLightEnabled) {
|
||||
configChangeBlend =
|
||||
((f32)envCtx->changeDuration - envCtx->changeLightTimer) / envCtx->changeDuration;
|
||||
envCtx->changeLightTimer--;
|
||||
if (envCtx->changeLightEnabled) {
|
||||
configChangeBlend =
|
||||
((f32)envCtx->changeDuration - envCtx->changeLightTimer) / envCtx->changeDuration;
|
||||
envCtx->changeLightTimer--;
|
||||
|
||||
if (envCtx->changeLightTimer <= 0) {
|
||||
envCtx->changeLightEnabled = false;
|
||||
envCtx->lightConfig = envCtx->changeLightNextConfig;
|
||||
}
|
||||
if (envCtx->changeLightTimer <= 0) {
|
||||
envCtx->changeLightEnabled = false;
|
||||
envCtx->lightConfig = envCtx->changeLightNextConfig;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < 3; j++) {
|
||||
// blend ambient color
|
||||
blend8[0] =
|
||||
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.ambientColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.ambientColor[j],
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.ambientColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.ambientColor[j],
|
||||
timeChangeBlend);
|
||||
*(envCtx->lightSettings.ambientColor + j) = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
}
|
||||
|
||||
// set light1 direction for the sun
|
||||
envCtx->lightSettings.light1Dir[0] =
|
||||
-(Math_SinS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f);
|
||||
envCtx->lightSettings.light1Dir[1] =
|
||||
Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f;
|
||||
envCtx->lightSettings.light1Dir[2] =
|
||||
Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 20.0f;
|
||||
|
||||
// set light2 direction for the moon
|
||||
envCtx->lightSettings.light2Dir[0] = -envCtx->lightSettings.light1Dir[0];
|
||||
envCtx->lightSettings.light2Dir[1] = -envCtx->lightSettings.light1Dir[1];
|
||||
envCtx->lightSettings.light2Dir[2] = -envCtx->lightSettings.light1Dir[2];
|
||||
|
||||
for (j = 0; j < 3; j++) {
|
||||
// blend light1Color
|
||||
blend8[0] =
|
||||
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.light1Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.light1Color[j],
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.light1Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.light1Color[j],
|
||||
timeChangeBlend);
|
||||
*(envCtx->lightSettings.light1Color + j) = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
|
||||
// blend light2Color
|
||||
blend8[0] =
|
||||
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.light2Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.light2Color[j],
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.light2Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.light2Color[j],
|
||||
timeChangeBlend);
|
||||
*(envCtx->lightSettings.light2Color + j) = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
}
|
||||
|
||||
// blend fogColor
|
||||
for (j = 0; j < 3; j++) {
|
||||
blend8[0] =
|
||||
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.fogColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.fogColor[j],
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.fogColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.fogColor[j],
|
||||
timeChangeBlend);
|
||||
*(envCtx->lightSettings.fogColor + j) = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
}
|
||||
|
||||
blend16[0] = LERP16(
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.blendRateAndFogNear),
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.blendRateAndFogNear),
|
||||
timeChangeBlend);
|
||||
blend16[1] = LERP16(
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.blendRateAndFogNear),
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.blendRateAndFogNear),
|
||||
timeChangeBlend);
|
||||
|
||||
envCtx->lightSettings.fogNear = LERP16(blend16[0], blend16[1], configChangeBlend);
|
||||
|
||||
blend16[0] = LERP16(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].zFar,
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].zFar,
|
||||
timeChangeBlend);
|
||||
blend16[1] = LERP16(
|
||||
for (j = 0; j < 3; j++) {
|
||||
// blend ambient color
|
||||
blend8[0] =
|
||||
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.ambientColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.ambientColor[j],
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.zFar,
|
||||
.ambientColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
|
||||
.zFar,
|
||||
.ambientColor[j],
|
||||
timeChangeBlend);
|
||||
|
||||
envCtx->lightSettings.zFar = LERP16(blend16[0], blend16[1], configChangeBlend);
|
||||
|
||||
if (sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting >=
|
||||
envCtx->numLightSettings) {
|
||||
// "The color palette setting seems to be wrong!"
|
||||
PRINTF(VT_COL(RED, WHITE) "\nカラーパレットの設定がおかしいようです!" VT_RST);
|
||||
|
||||
// "Palette setting = [] Last palette number = []"
|
||||
PRINTF(VT_COL(RED, WHITE) "\n設定パレット=[%d] 最後パレット番号=[%d]\n" VT_RST,
|
||||
sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting,
|
||||
envCtx->numLightSettings - 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!envCtx->lightBlendEnabled) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
envCtx->lightSettings.ambientColor[i] = lightSettingsList[envCtx->lightSetting].ambientColor[i];
|
||||
envCtx->lightSettings.light1Dir[i] = lightSettingsList[envCtx->lightSetting].light1Dir[i];
|
||||
envCtx->lightSettings.light1Color[i] = lightSettingsList[envCtx->lightSetting].light1Color[i];
|
||||
envCtx->lightSettings.light2Dir[i] = lightSettingsList[envCtx->lightSetting].light2Dir[i];
|
||||
envCtx->lightSettings.light2Color[i] = lightSettingsList[envCtx->lightSetting].light2Color[i];
|
||||
envCtx->lightSettings.fogColor[i] = lightSettingsList[envCtx->lightSetting].fogColor[i];
|
||||
envCtx->lightSettings.ambientColor[j] = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
}
|
||||
|
||||
envCtx->lightSettings.fogNear =
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear);
|
||||
envCtx->lightSettings.zFar = lightSettingsList[envCtx->lightSetting].zFar;
|
||||
envCtx->lightBlend = 1.0f;
|
||||
} else {
|
||||
u8 blendRate =
|
||||
ENV_LIGHT_SETTINGS_BLEND_RATE_U8(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear);
|
||||
// set light1 direction for the sun
|
||||
envCtx->lightSettings.light1Dir[0] =
|
||||
-(Math_SinS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f);
|
||||
envCtx->lightSettings.light1Dir[1] =
|
||||
Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f;
|
||||
envCtx->lightSettings.light1Dir[2] =
|
||||
Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 20.0f;
|
||||
|
||||
if (blendRate == 0) {
|
||||
blendRate++;
|
||||
// set light2 direction for the moon
|
||||
envCtx->lightSettings.light2Dir[0] = -envCtx->lightSettings.light1Dir[0];
|
||||
envCtx->lightSettings.light2Dir[1] = -envCtx->lightSettings.light1Dir[1];
|
||||
envCtx->lightSettings.light2Dir[2] = -envCtx->lightSettings.light1Dir[2];
|
||||
|
||||
for (j = 0; j < 3; j++) {
|
||||
// blend light1Color
|
||||
blend8[0] =
|
||||
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.light1Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.light1Color[j],
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.light1Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
|
||||
.light1Color[j],
|
||||
timeChangeBlend);
|
||||
envCtx->lightSettings.light1Color[j] = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
|
||||
// blend light2Color
|
||||
blend8[0] =
|
||||
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.light2Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.light2Color[j],
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.light2Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
|
||||
.light2Color[j],
|
||||
timeChangeBlend);
|
||||
envCtx->lightSettings.light2Color[j] = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
}
|
||||
|
||||
if (envCtx->lightBlendRateOverride != LIGHT_BLENDRATE_OVERRIDE_NONE) {
|
||||
blendRate = envCtx->lightBlendRateOverride;
|
||||
// blend fogColor
|
||||
for (j = 0; j < 3; j++) {
|
||||
blend8[0] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].fogColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.fogColor[j],
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.fogColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
|
||||
.fogColor[j],
|
||||
timeChangeBlend);
|
||||
envCtx->lightSettings.fogColor[j] = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
}
|
||||
|
||||
if (envCtx->lightBlendOverride == LIGHT_BLEND_OVERRIDE_NONE) {
|
||||
envCtx->lightBlend += blendRate / 255.0f;
|
||||
blend16[0] =
|
||||
LERP16(ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.blendRateAndFogNear),
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.blendRateAndFogNear),
|
||||
timeChangeBlend);
|
||||
blend16[1] = LERP16(
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.blendRateAndFogNear),
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
|
||||
.blendRateAndFogNear),
|
||||
timeChangeBlend);
|
||||
|
||||
envCtx->lightSettings.fogNear = LERP16(blend16[0], blend16[1], configChangeBlend);
|
||||
|
||||
blend16[0] =
|
||||
LERP16(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].zFar,
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].zFar,
|
||||
timeChangeBlend);
|
||||
blend16[1] = LERP16(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting].zFar,
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
|
||||
.zFar,
|
||||
timeChangeBlend);
|
||||
|
||||
envCtx->lightSettings.zFar = LERP16(blend16[0], blend16[1], configChangeBlend);
|
||||
|
||||
#if OOT_DEBUG
|
||||
if (sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting >=
|
||||
envCtx->numLightSettings) {
|
||||
// "The color palette setting seems to be wrong!"
|
||||
PRINTF(VT_COL(RED, WHITE) "\nカラーパレットの設定がおかしいようです!" VT_RST);
|
||||
|
||||
// "Palette setting = [] Last palette number = []"
|
||||
PRINTF(VT_COL(RED, WHITE) "\n設定パレット=[%d] 最後パレット番号=[%d]\n" VT_RST,
|
||||
sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting,
|
||||
envCtx->numLightSettings - 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (envCtx->lightBlend > 1.0f) {
|
||||
envCtx->lightBlend = 1.0f;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
envCtx->lightSettings.ambientColor[i] =
|
||||
LERP(lightSettingsList[envCtx->prevLightSetting].ambientColor[i],
|
||||
lightSettingsList[envCtx->lightSetting].ambientColor[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.light1Dir[i] =
|
||||
LERP16(lightSettingsList[envCtx->prevLightSetting].light1Dir[i],
|
||||
lightSettingsList[envCtx->lightSetting].light1Dir[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.light1Color[i] =
|
||||
LERP(lightSettingsList[envCtx->prevLightSetting].light1Color[i],
|
||||
lightSettingsList[envCtx->lightSetting].light1Color[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.light2Dir[i] =
|
||||
LERP16(lightSettingsList[envCtx->prevLightSetting].light2Dir[i],
|
||||
lightSettingsList[envCtx->lightSetting].light2Dir[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.light2Color[i] =
|
||||
LERP(lightSettingsList[envCtx->prevLightSetting].light2Color[i],
|
||||
lightSettingsList[envCtx->lightSetting].light2Color[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.fogColor[i] =
|
||||
LERP(lightSettingsList[envCtx->prevLightSetting].fogColor[i],
|
||||
lightSettingsList[envCtx->lightSetting].fogColor[i], envCtx->lightBlend);
|
||||
}
|
||||
envCtx->lightSettings.fogNear = LERP16(
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->prevLightSetting].blendRateAndFogNear),
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear),
|
||||
envCtx->lightBlend);
|
||||
envCtx->lightSettings.zFar =
|
||||
LERP16(lightSettingsList[envCtx->prevLightSetting].zFar,
|
||||
lightSettingsList[envCtx->lightSetting].zFar, envCtx->lightBlend);
|
||||
}
|
||||
|
||||
if (envCtx->lightSetting >= envCtx->numLightSettings) {
|
||||
// "The color palette seems to be wrong!"
|
||||
PRINTF("\n" VT_FGCOL(RED) "カラーパレットがおかしいようです!");
|
||||
|
||||
// "Palette setting = [] Last palette number = []"
|
||||
PRINTF("\n" VT_FGCOL(YELLOW) "設定パレット=[%d] パレット数=[%d]\n" VT_RST, envCtx->lightSetting,
|
||||
envCtx->numLightSettings);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!envCtx->lightBlendEnabled) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
envCtx->lightSettings.ambientColor[i] = lightSettingsList[envCtx->lightSetting].ambientColor[i];
|
||||
envCtx->lightSettings.light1Dir[i] = lightSettingsList[envCtx->lightSetting].light1Dir[i];
|
||||
envCtx->lightSettings.light1Color[i] = lightSettingsList[envCtx->lightSetting].light1Color[i];
|
||||
envCtx->lightSettings.light2Dir[i] = lightSettingsList[envCtx->lightSetting].light2Dir[i];
|
||||
envCtx->lightSettings.light2Color[i] = lightSettingsList[envCtx->lightSetting].light2Color[i];
|
||||
envCtx->lightSettings.fogColor[i] = lightSettingsList[envCtx->lightSetting].fogColor[i];
|
||||
}
|
||||
|
||||
envCtx->lightSettings.fogNear =
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear);
|
||||
envCtx->lightSettings.zFar = lightSettingsList[envCtx->lightSetting].zFar;
|
||||
envCtx->lightBlend = 1.0f;
|
||||
} else {
|
||||
blendRate =
|
||||
ENV_LIGHT_SETTINGS_BLEND_RATE_U8(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear);
|
||||
|
||||
if (blendRate == 0) {
|
||||
blendRate++;
|
||||
}
|
||||
|
||||
if (envCtx->lightBlendRateOverride != LIGHT_BLENDRATE_OVERRIDE_NONE) {
|
||||
blendRate = envCtx->lightBlendRateOverride;
|
||||
}
|
||||
|
||||
if (envCtx->lightBlendOverride == LIGHT_BLEND_OVERRIDE_NONE) {
|
||||
envCtx->lightBlend += blendRate / 255.0f;
|
||||
}
|
||||
|
||||
if (envCtx->lightBlend > 1.0f) {
|
||||
envCtx->lightBlend = 1.0f;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
envCtx->lightSettings.ambientColor[i] =
|
||||
LERP(lightSettingsList[envCtx->prevLightSetting].ambientColor[i],
|
||||
lightSettingsList[envCtx->lightSetting].ambientColor[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.light1Dir[i] =
|
||||
LERP16(lightSettingsList[envCtx->prevLightSetting].light1Dir[i],
|
||||
lightSettingsList[envCtx->lightSetting].light1Dir[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.light1Color[i] =
|
||||
LERP(lightSettingsList[envCtx->prevLightSetting].light1Color[i],
|
||||
lightSettingsList[envCtx->lightSetting].light1Color[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.light2Dir[i] =
|
||||
LERP16(lightSettingsList[envCtx->prevLightSetting].light2Dir[i],
|
||||
lightSettingsList[envCtx->lightSetting].light2Dir[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.light2Color[i] =
|
||||
LERP(lightSettingsList[envCtx->prevLightSetting].light2Color[i],
|
||||
lightSettingsList[envCtx->lightSetting].light2Color[i], envCtx->lightBlend);
|
||||
envCtx->lightSettings.fogColor[i] =
|
||||
LERP(lightSettingsList[envCtx->prevLightSetting].fogColor[i],
|
||||
lightSettingsList[envCtx->lightSetting].fogColor[i], envCtx->lightBlend);
|
||||
}
|
||||
|
||||
envCtx->lightSettings.fogNear =
|
||||
LERP16(ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->prevLightSetting].blendRateAndFogNear),
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear),
|
||||
envCtx->lightBlend);
|
||||
envCtx->lightSettings.zFar = LERP16(lightSettingsList[envCtx->prevLightSetting].zFar,
|
||||
lightSettingsList[envCtx->lightSetting].zFar, envCtx->lightBlend);
|
||||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
if (envCtx->lightSetting >= envCtx->numLightSettings) {
|
||||
// "The color palette seems to be wrong!"
|
||||
PRINTF("\n" VT_FGCOL(RED) "カラーパレットがおかしいようです!");
|
||||
|
||||
// "Palette setting = [] Last palette number = []"
|
||||
PRINTF("\n" VT_FGCOL(YELLOW) "設定パレット=[%d] パレット数=[%d]\n" VT_RST, envCtx->lightSetting,
|
||||
envCtx->numLightSettings);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
envCtx->lightBlendEnabled = true;
|
||||
|
@ -1261,22 +1272,20 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
envCtx->dirLight2.params.dir.z = envCtx->lightSettings.light2Dir[2];
|
||||
|
||||
// Adjust fog near and far if necessary
|
||||
adjustment = envCtx->lightSettings.fogNear + envCtx->adjFogNear;
|
||||
|
||||
if (adjustment <= ENV_FOGNEAR_MAX) {
|
||||
lightCtx->fogNear = adjustment;
|
||||
if ((envCtx->lightSettings.fogNear + envCtx->adjFogNear) <= ENV_FOGNEAR_MAX) {
|
||||
lightCtx->fogNear = envCtx->lightSettings.fogNear + envCtx->adjFogNear;
|
||||
} else {
|
||||
lightCtx->fogNear = ENV_FOGNEAR_MAX;
|
||||
}
|
||||
|
||||
adjustment = envCtx->lightSettings.zFar + envCtx->adjZFar;
|
||||
|
||||
if (adjustment <= ENV_ZFAR_MAX) {
|
||||
lightCtx->zFar = adjustment;
|
||||
if ((envCtx->lightSettings.zFar + envCtx->adjZFar) <= ENV_ZFAR_MAX) {
|
||||
lightCtx->zFar = envCtx->lightSettings.zFar + envCtx->adjZFar;
|
||||
} else {
|
||||
lightCtx->zFar = ENV_ZFAR_MAX;
|
||||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
// When environment debug is enabled, various environment related variables can be configured via the reg editor
|
||||
if (R_ENV_DISABLE_DBG) {
|
||||
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->windSpeed = R_ENV_WIND_SPEED;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((envCtx->dirLight1.params.dir.x == 0) && (envCtx->dirLight1.params.dir.y == 0) &&
|
||||
(envCtx->dirLight1.params.dir.z == 0)) {
|
||||
|
@ -2366,9 +2376,6 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) {
|
|||
Color_RGBA8 envColor;
|
||||
s32 pad;
|
||||
f32 sp98;
|
||||
u16 sp96;
|
||||
u16 sp94;
|
||||
u16 sp92;
|
||||
|
||||
switch (sandstormState) {
|
||||
case SANDSTORM_ACTIVE:
|
||||
|
@ -2475,25 +2482,27 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) {
|
|||
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);
|
||||
|
||||
sp96 = (s32)(sSandstormScroll * (11.0f / 6.0f));
|
||||
sp94 = (s32)(sSandstormScroll * (9.0f / 6.0f));
|
||||
sp92 = (s32)(sSandstormScroll * (6.0f / 6.0f));
|
||||
{
|
||||
u16 sp96 = (s32)(sSandstormScroll * (11.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);
|
||||
|
||||
POLY_XLU_DISP = Gfx_SetupDL_64(POLY_XLU_DISP);
|
||||
POLY_XLU_DISP = Gfx_SetupDL_64(POLY_XLU_DISP);
|
||||
|
||||
gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE);
|
||||
gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE);
|
||||
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);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x08,
|
||||
Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (u32)sp96 % 4096, 0, 512, 32, 1, (u32)sp94 % 4096,
|
||||
4095 - ((u32)sp92 % 4096), 256, 64));
|
||||
gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE);
|
||||
gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL);
|
||||
gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE);
|
||||
gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE);
|
||||
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);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x08,
|
||||
Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (u32)sp96 % 4096, 0, 512, 32, 1,
|
||||
(u32)sp94 % 4096, 4095 - ((u32)sp92 % 4096), 256, 64));
|
||||
gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE);
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue