z_kankyo Decompiled (3 non-matching) (#1451)

* z_Kankyo progress

* build OK

* progress

* more progress

* Kankyo WIP

* Add docs

* func_800FEAF4

* more docs

* func_800FEAF4

* improve Init

* Small cleanup

* kankyo data

* data cleanup

* Environment_DrawLensFlare

* Match Environment_UpdateSkybox

* Match Environment_DrawRainImpl

* Start on Environment_UpdateLights

* Match Environment_DrawSandstorm

* gRainDropDL

* Some light renamings

* Fix merge

* cleanup

* improve non-equivalents

* cleanup

* PR Review

* match Environment_UpdatePostmanEvents

* PR Review

* small improvement to Environment_UpdatePostmanEvents from anon

* more cleanup

* void

* bits

* fix comment

* improve Environment_UpdateLights

* Skybox Stars Docs

* PR Review

* fix merge

* macros

* Add comments

* PR Review

* gRandFloat

* bug

---------

Co-authored-by: Rozelette <Uberpanzermensch@gmail.com>
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
This commit is contained in:
engineer124
2023-10-31 14:50:11 +11:00
committed by GitHub
parent 0492c8e89a
commit 83ceaf3717
26 changed files with 2702 additions and 120 deletions
+9 -9
View File
@@ -5,7 +5,7 @@ static u32 sRandInt = 1;
//! Space to store a value to be re-interpreted as a float.
//! This can't be static because it is used in z_kankyo.
u32 sRandFloat;
u32 gRandFloat;
//! These values are recommended by the algorithms book *Numerical Recipes in C. The Art of Scientific Computing*, 2nd
//! Edition, 1992, ISBN 0-521-43108-5. (p. 284):
@@ -37,8 +37,8 @@ void Rand_Seed(u32 seed) {
*/
f32 Rand_ZeroOne(void) {
sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT;
sRandFloat = ((sRandInt >> 9) | 0x3F800000);
return *((f32*)&sRandFloat) - 1.0f;
gRandFloat = ((sRandInt >> 9) | 0x3F800000);
return *((f32*)&gRandFloat) - 1.0f;
}
/**
@@ -46,8 +46,8 @@ f32 Rand_ZeroOne(void) {
*/
f32 Rand_Centered(void) {
sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT;
sRandFloat = ((sRandInt >> 9) | 0x3F800000);
return *((f32*)&sRandFloat) - 1.5f;
gRandFloat = ((sRandInt >> 9) | 0x3F800000);
return *((f32*)&gRandFloat) - 1.5f;
}
//! All functions below are unused variants of the above four, that use a provided random number variable instead of the
@@ -79,8 +79,8 @@ u32 Rand_Next_Variable(u32* rndNum) {
f32 Rand_ZeroOne_Variable(u32* rndNum) {
u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT;
sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000;
return *((f32*)&sRandFloat) - 1.0f;
gRandFloat = ((*rndNum = next) >> 9) | 0x3F800000;
return *((f32*)&gRandFloat) - 1.0f;
}
/**
@@ -91,6 +91,6 @@ f32 Rand_ZeroOne_Variable(u32* rndNum) {
f32 Rand_Centered_Variable(u32* rndNum) {
u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT;
sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000;
return *((f32*)&sRandFloat) - 1.5f;
gRandFloat = ((*rndNum = next) >> 9) | 0x3F800000;
return *((f32*)&gRandFloat) - 1.5f;
}
+2620 -55
View File
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -663,15 +663,15 @@ void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 rotAngle, Vec3f* src,
dst->z = translation->z + (src->z * cos - src->x * sin);
}
void Color_RGB8_Lerp(Color_RGB8* a, Color_RGB8* b, f32 t, Color_RGB8* dst) {
void Color_RGB8_Lerp(Color_RGB8* from, Color_RGB8* to, f32 lerp, Color_RGB8* dst) {
f32 aF;
aF = a->r;
dst->r = aF + (b->r - aF) * t;
aF = a->g;
dst->g = aF + (b->g - aF) * t;
aF = a->b;
dst->b = aF + (b->b - aF) * t;
aF = from->r;
dst->r = aF + (to->r - aF) * lerp;
aF = from->g;
dst->g = aF + (to->g - aF) * lerp;
aF = from->b;
dst->b = aF + (to->b - aF) * lerp;
}
f32 Math_Vec3f_StepTo(Vec3f* start, Vec3f* target, f32 speed) {
+6 -5
View File
@@ -385,7 +385,7 @@ void Play_Destroy(GameState* thisx) {
BombersNotebook_Destroy(&sBombersNotebook);
this->state.gfxCtx->callback = NULL;
this->state.gfxCtx->callbackArg = 0;
this->state.gfxCtx->callbackArg = NULL;
Play_DestroyMotionBlur();
if (R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_OFF) {
@@ -1332,7 +1332,7 @@ void Play_DrawMain(PlayState* this) {
}
if (1) {
Environment_FillScreen(gfxCtx, 0, 0, 0, this->bgCoverAlpha, 1);
Environment_FillScreen(gfxCtx, 0, 0, 0, this->bgCoverAlpha, FILL_SCREEN_OPA);
}
if (1) {
@@ -1353,13 +1353,14 @@ void Play_DrawMain(PlayState* this) {
if (1) {
if (R_PLAY_FILL_SCREEN_ON) {
Environment_FillScreen(gfxCtx, R_PLAY_FILL_SCREEN_R, R_PLAY_FILL_SCREEN_G, R_PLAY_FILL_SCREEN_B,
R_PLAY_FILL_SCREEN_ALPHA, 3);
R_PLAY_FILL_SCREEN_ALPHA, FILL_SCREEN_OPA | FILL_SCREEN_XLU);
}
switch (this->envCtx.fillScreen) {
case 1:
Environment_FillScreen(gfxCtx, this->envCtx.screenFillColor[0], this->envCtx.screenFillColor[1],
this->envCtx.screenFillColor[2], this->envCtx.screenFillColor[3], 3);
this->envCtx.screenFillColor[2], this->envCtx.screenFillColor[3],
FILL_SCREEN_OPA | FILL_SCREEN_XLU);
break;
default:
@@ -1374,7 +1375,7 @@ void Play_DrawMain(PlayState* this) {
}
if (this->worldCoverAlpha != 0) {
Environment_FillScreen(gfxCtx, 0, 0, 0, this->worldCoverAlpha, 3);
Environment_FillScreen(gfxCtx, 0, 0, 0, this->worldCoverAlpha, FILL_SCREEN_OPA | FILL_SCREEN_XLU);
}
if (1) {
@@ -159,7 +159,7 @@ void EnEncount3_Update(Actor* thisx, PlayState* play2) {
Math_ApproachZeroF(&this->unk170, 0.3f, 10.0f);
Math_ApproachZeroF(&this->unk160, 0.3f, 5.0f);
if (this->unk160 < 1.0f) {
play->unk_18880 = 0;
play->unk_18880 = false;
}
} else if (this->unk148 != 0) {
Math_ApproachF(&this->unk170, 255.0f, 0.4f, 10.0f);
@@ -750,7 +750,8 @@ void EnInvadepohDemo_Ufo_Draw(EnInvadepohDemo* this, PlayState* play) {
CLOSE_DISPS(play->state.gfxCtx);
if (EnInvadepohDemo_Ufo_ShouldDrawLensFlare(play, &flashPos)) {
Environment_DrawLensFlare(play, &play->envCtx, &play->view, play->state.gfxCtx, flashPos, 20.0f, 9.0f, 0, 0);
Environment_DrawLensFlare(play, &play->envCtx, &play->view, play->state.gfxCtx, flashPos, 20.0f, 9.0f, 0,
false);
}
}
+1 -1
View File
@@ -553,7 +553,7 @@ void EnJso_HandleIntroCutscene(EnJso* this, PlayState* play) {
if (parent->actor.update != NULL) {
parent->unk148 = 1;
play->unk_18880 = 1;
play->unk_18880 = true;
}
}
@@ -48,7 +48,7 @@ void EnOkarinaEffect_Init(Actor* thisx, PlayState* play) {
}
void func_8096B104(EnOkarinaEffect* this, PlayState* play) {
this->unk144 = 0x50;
this->timer = 80;
play->envCtx.precipitation[PRECIP_SOS_MAX] = 60;
gLightningStrike.delayTimer = 501.0f;
play->envCtx.lightningState = LIGHTNING_LAST;
@@ -57,9 +57,9 @@ void func_8096B104(EnOkarinaEffect* this, PlayState* play) {
}
void func_8096B174(EnOkarinaEffect* this, PlayState* play) {
DECR(this->unk144);
DECR(this->timer);
if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) &&
(play->msgCtx.msgLength == 0) && !FrameAdvance_IsEnabled(&play->state) && (this->unk144 == 0)) {
(play->msgCtx.msgLength == 0) && !FrameAdvance_IsEnabled(&play->state) && (this->timer == 0)) {
EnOkarinaEffect_SetupAction(this, func_8096B1FC);
}
}
@@ -9,8 +9,7 @@ typedef void (*EnOkarinaEffectActionFunc)(struct EnOkarinaEffect*, PlayState*);
typedef struct EnOkarinaEffect {
/* 0x000 */ Actor actor;
/* 0x144 */ u16 unk144;
/* 0x146 */ u16 unk146;
/* 0x144 */ u16 timer;
/* 0x148 */ EnOkarinaEffectActionFunc actionFunc;
} EnOkarinaEffect; // size = 0x14C
@@ -431,7 +431,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) {
this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE;
}
} else if ((new_var * bellDiff) <= 0) {
Audio_PlaySfx_BigBells(&this->actor.projectedPos, (this->actor.params >> 5) & 0xF);
Audio_PlaySfx_BigBells(&this->actor.projectedPos, TEST4_GET_BIG_BELLS_SFX_VOLUME_INDEX(&this->actor));
this->lastBellTime = gSaveContext.save.time;
if (CURRENT_DAY == 3) {
@@ -553,11 +553,11 @@ void func_80A431C8(EnTest4* this, PlayState* play) {
}
}
void func_80A4323C(EnTest4* this, PlayState* play) {
s32 temp_v0 = (this->actor.params >> 0xA) * 0x64;
void EnTest4_SetSkyboxNumStars(EnTest4* this, PlayState* play) {
s32 numStars = TEST4_GET_SKYBOX_NUM_STARS(&this->actor);
if (temp_v0 > 0) {
gSkyboxNumStars = temp_v0;
if (numStars > 0) {
gSkyboxNumStars = numStars;
}
}
@@ -578,6 +578,6 @@ void EnTest4_Update(Actor* thisx, PlayState* play) {
break;
}
}
func_80A4323C(this, play);
EnTest4_SetSkyboxNumStars(this, play);
}
}
@@ -5,6 +5,9 @@
struct EnTest4;
#define TEST4_GET_SKYBOX_NUM_STARS(thisx) (((thisx)->params >> 10) * 100)
#define TEST4_GET_BIG_BELLS_SFX_VOLUME_INDEX(thisx) (((thisx)->params >> 5) & 0xF)
typedef void (*EnTest4ActionFunc)(struct EnTest4*, PlayState*);
typedef struct EnTest4 {
@@ -988,6 +988,6 @@ void EnTest7_Draw(Actor* thisx, PlayState* play) {
if (this->unk_144 & 4) {
Environment_DrawLensFlare(play, &play->envCtx, &play->view, play->state.gfxCtx, this->actor.world.pos, 70.0f,
5.0f, 0, 0);
5.0f, 0, false);
}
}
@@ -86,7 +86,7 @@ void EnWeatherTag_Init(Actor* thisx, PlayState* play) {
EnWeatherTag_SetupAction(this, func_80966EF0);
break;
case WEATHERTAG_TYPE_UNK4:
case WEATHERTAG_TYPE_SKYBOX_STARS:
EnWeatherTag_SetupAction(this, func_80966FEC);
break;
@@ -352,14 +352,11 @@ void func_80966F74(EnWeatherTag* this, PlayState* play) {
}
}
// WEATHERTAG_TYPE_UNK4: no visible effect, what does it doooo??
// used in south clock town??? romani ranch, clock tower rooftop woodfall..? stt
// all of them have shorter distances though, like 0xA and 0x6, so their locations are important
void func_80966FEC(EnWeatherTag* this, PlayState* play) {
// weirdly, not the same as the other param lookup used in the rest of the file, which is float
s32 distance = WEATHER_TAG_RANGE100INT(&this->actor);
if (distance > 0) {
gSkyboxNumStars = distance;
s32 numStars = WEATHER_TAG_GET_SKYBOX_NUM_STARS(&this->actor);
if (numStars > 0) {
gSkyboxNumStars = numStars;
}
if ((play->sceneId == SCENE_KAIZOKU) && (play->actorCtx.flags & ACTORCTX_FLAG_1)) {
@@ -22,14 +22,14 @@ typedef struct EnWeatherTag {
#define WEATHER_TAG_TYPE(thisx) ((thisx)->params & 0xF)
#define WEATHER_TAG_PATHID(thisx) (((thisx)->params >> 4) & 0xF)
#define WEATHER_TAG_RANGE100(thisx) ((u8)(((thisx)->params >> 8) & 0xFF) * 100.0f)
#define WEATHER_TAG_RANGE100INT(thisx) ((u8)(((thisx)->params >> 8) & 0xFF) * 100)
#define WEATHER_TAG_GET_SKYBOX_NUM_STARS(thisx) ((u8)(((thisx)->params >> 8) & 0xFF) * 100)
typedef enum {
/* 0 */ WEATHERTAG_TYPE_UNK0,
/* 1 */ WEATHERTAG_TYPE_UNK1,
/* 2 */ WEATHERTAG_TYPE_WINTERFOG,
/* 3 */ WEATHERTAG_TYPE_UNK3,
/* 4 */ WEATHERTAG_TYPE_UNK4,
/* 4 */ WEATHERTAG_TYPE_SKYBOX_STARS,
/* 5 */ WEATHERTAG_TYPE_UNK5,
/* 6 */ WEATHERTAG_TYPE_WATERMURK,
/* 7 */ WEATHERTAG_TYPE_LOCALDAY2RAIN
@@ -511,7 +511,8 @@ void func_808DD3C8(Actor* thisx, PlayState* play2) {
f32 temp_f2;
f32 tempf;
if ((play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_UNDERWATER) || ((u8)play->envCtx.stormState == 0)) {
if ((play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_UNDERWATER) ||
((u8)play->envCtx.stormState == STORM_STATE_OFF)) {
return;
}
@@ -687,7 +688,7 @@ void func_808DDE9C(Actor* thisx, PlayState* play2) {
}
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0706E0);
gSPDisplayList(POLY_XLU_DISP++, gFallingRainDropDL);
}
}
+1 -1
View File
@@ -112,7 +112,7 @@ void ConsoleLogo_Draw(GameState* thisx) {
1 << 10, 1 << 10);
}
Environment_FillScreen(this->state.gfxCtx, 0, 0, 0, this->coverAlpha, 2);
Environment_FillScreen(this->state.gfxCtx, 0, 0, 0, this->coverAlpha, FILL_SCREEN_XLU);
sTitleRotation += 300;