Add `ENV_LIGHT_SETTINGS_BLEND_RATE_AND_FOG_NEAR_PACK`, fix extracted negative `blendRate` (#2653)

* Add ENV_LIGHT_SETTINGS_BLEND_RATE_AND_FOG_NEAR_PACK, fix extracted negative blendRate

* -> BLEND_RATE_AND_FOG_NEAR
This commit is contained in:
Dragorn421 2025-07-15 06:52:22 +01:00 committed by GitHub
parent 7158775cea
commit 4c2a451b9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -155,8 +155,10 @@ typedef struct CurrentEnvLightSettings {
// The blendRate determines how fast the current light settings fade to the next one
// (under LIGHT_MODE_SETTINGS, otherwise unused).
#define BLEND_RATE_AND_FOG_NEAR(blendRate, fogNear) (s16)((((blendRate) / 4) << 10) | (fogNear))
// Get blend rate from `EnvLightSettings.blendRateAndFogNear` in 0-255 range
#define ENV_LIGHT_SETTINGS_BLEND_RATE_U8(blendRateAndFogNear) (((blendRateAndFogNear) >> 10) * 4)
#define ENV_LIGHT_SETTINGS_BLEND_RATE_U8(blendRateAndFogNear) (u8)(((blendRateAndFogNear) >> 10) * 4)
#define ENV_LIGHT_SETTINGS_FOG_NEAR(blendRateAndFogNear) ((blendRateAndFogNear) & 0x3FF)
typedef struct EnvLightSettings {

View File

@ -293,8 +293,10 @@ class EnvLightSettingsListResource(CDataArrayNamedLengthResource):
def write_blendRateAndFogNear(v):
blendRate = (v >> 10) * 4
if blendRate < 0:
blendRate += 0x100
fogNear = v & 0x3FF
return f"(({blendRate} / 4) << 10) | {fogNear}"
return f"BLEND_RATE_AND_FOG_NEAR({blendRate}, {fogNear})"
elem_cdata_ext = CDataExt_Struct(
(