diff options
Diffstat (limited to 'soh/src/code')
| -rw-r--r-- | soh/src/code/z_actor.c | 79 | ||||
| -rw-r--r-- | soh/src/code/z_camera.c | 202 | ||||
| -rw-r--r-- | soh/src/code/z_kankyo.c | 8 | ||||
| -rw-r--r-- | soh/src/code/z_parameter.c | 15 | ||||
| -rw-r--r-- | soh/src/code/z_play.c | 4 | ||||
| -rw-r--r-- | soh/src/code/z_player_lib.c | 4 | ||||
| -rw-r--r-- | soh/src/code/z_rcp.c | 2 | ||||
| -rw-r--r-- | soh/src/code/z_room.c | 14 | ||||
| -rw-r--r-- | soh/src/code/z_scene.c | 123 | ||||
| -rw-r--r-- | soh/src/code/z_scene_table.c | 14 | ||||
| -rw-r--r-- | soh/src/code/z_view.c | 126 |
11 files changed, 318 insertions, 273 deletions
diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index d624fc42d..caff63c8e 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -651,7 +651,7 @@ void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag) { } /** - * Tests if current scene unknown flag is set. + * Tests if unknown flag is set. */ s32 Flags_GetUnknown(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { @@ -662,7 +662,7 @@ s32 Flags_GetUnknown(GlobalContext* globalCtx, s32 flag) { } /** - * Sets current scene unknown flag. + * Sets unknown flag. */ void Flags_SetUnknown(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { @@ -673,7 +673,7 @@ void Flags_SetUnknown(GlobalContext* globalCtx, s32 flag) { } /** - * Unsets current scene unknown flag. + * Unsets unknown flag. */ void Flags_UnsetUnknown(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { @@ -1395,7 +1395,7 @@ void func_8002DE04(GlobalContext* globalCtx, Actor* actorA, Actor* actorB) { } void func_8002DE74(GlobalContext* globalCtx, Player* player) { - if ((globalCtx->roomCtx.curRoom.unk_03 != 4) && func_800C0CB8(globalCtx)) { + if ((globalCtx->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_4) && func_800C0CB8(globalCtx)) { Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, MAIN_CAM), CAM_SET_HORSE); } } @@ -2348,9 +2348,9 @@ void func_80030488(GlobalContext* globalCtx) { LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, D_8015BC10); } -void func_800304B0(GlobalContext* globalCtx) { - if (globalCtx->actorCtx.unk_03 != 0) { - globalCtx->actorCtx.unk_03 = 0; +void Actor_DisableLens(GlobalContext* globalCtx) { + if (globalCtx->actorCtx.lensActive) { + globalCtx->actorCtx.lensActive = false; func_800876C8(globalCtx); } } @@ -2390,7 +2390,7 @@ void func_800304DC(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* func_8002FA60(globalCtx); } -u32 D_80116068[] = { +u32 D_80116068[ACTORCAT_MAX] = { 0x100000C0, 0x100000C0, 0x00000000, 0x100004C0, 0x00000080, 0x300000C0, 0x10000080, 0x00000000, 0x300000C0, 0x100004C0, 0x00000000, 0x100000C0, }; @@ -2643,26 +2643,35 @@ void func_80030ED8(Actor* actor) { } } -void func_80030FA8(GraphicsContext* gfxCtx) { +#define LENS_MASK_WIDTH 64 +#define LENS_MASK_HEIGHT 64 +// 26 and 6 are for padding between the mask texture and the screen borders +#define LENS_MASK_OFFSET_S ((SCREEN_WIDTH / 2 - LENS_MASK_WIDTH) - 26) +#define LENS_MASK_OFFSET_T ((SCREEN_HEIGHT / 2 - LENS_MASK_HEIGHT) - 6) + +void Actor_DrawLensOverlay(GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); - gDPLoadTextureBlock(POLY_XLU_DISP++, gLensOfTruthMaskTex, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, - G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(POLY_XLU_DISP++, gLensOfTruthMaskTex, G_IM_FMT_I, G_IM_SIZ_8b, LENS_MASK_WIDTH, + LENS_MASK_HEIGHT, 0, G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, + G_TX_NOLOD); s32 x = OTRGetRectDimensionFromLeftEdge(0) << 2; s32 w = OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) << 2; - float ratio = OTRGetAspectRatio(); - - gDPSetTileSize(POLY_XLU_DISP++, G_TX_RENDERTILE, 384, 224, 892, 732); - // TODO: Do correct math to fix it - gSPWideTextureRectangle(POLY_XLU_DISP++, x, 0, x + abs(x), 960, G_TX_RENDERTILE, 0, 0, 0, 0); - gSPWideTextureRectangle(POLY_XLU_DISP++, 0, 0, w, 960, G_TX_RENDERTILE, 2240, 1600, 576, 597); + gDPSetTileSize(POLY_XLU_DISP++, G_TX_RENDERTILE, (SCREEN_WIDTH / 2 - LENS_MASK_WIDTH) << 2, + (SCREEN_HEIGHT / 2 - LENS_MASK_HEIGHT) << 2, (SCREEN_WIDTH / 2 + LENS_MASK_WIDTH - 1) << 2, + (SCREEN_HEIGHT / 2 + LENS_MASK_HEIGHT - 1) << 2); + gSPWideTextureRectangle(POLY_XLU_DISP++, x, 0, x + abs(x), SCREEN_HEIGHT << 2, G_TX_RENDERTILE, 0, 0, 0, 0); + gSPWideTextureRectangle(POLY_XLU_DISP++, 0, 0, w, SCREEN_HEIGHT << 2, G_TX_RENDERTILE, + LENS_MASK_OFFSET_S << 5, LENS_MASK_OFFSET_T << 5, + (1 << 10) * (SCREEN_WIDTH - 2 * LENS_MASK_OFFSET_S) / SCREEN_WIDTH, + (1 << 10) * (SCREEN_HEIGHT - 2 * LENS_MASK_OFFSET_T) / SCREEN_HEIGHT); gDPPipeSync(POLY_XLU_DISP++); CLOSE_DISPS(gfxCtx); } -void func_8003115C(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** invisibleActors) { +void Actor_DrawLensActors(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** invisibleActors) { Actor** invisibleActor; GraphicsContext* gfxCtx; s32 i; @@ -2675,28 +2684,41 @@ void func_8003115C(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** inv gDPPipeSync(POLY_XLU_DISP++); - if (globalCtx->roomCtx.curRoom.showInvisActors == 0) { + if (globalCtx->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) { + // Update both the color frame buffer and the z-buffer gDPSetOtherMode(POLY_XLU_DISP++, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | G_RM_CLD_SURF | G_RM_CLD_SURF2); + gDPSetCombineMode(POLY_XLU_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 0, 0, 255); + + // the z-buffer will later only allow drawing inside the lens circle } else { + // Update the z-buffer but not the color frame buffer gDPSetOtherMode(POLY_XLU_DISP++, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | GBL_c1(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA) | GBL_c2(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA)); + + // inverts the mask image, which initially is 0 inner and 74 outer, + // by setting the combiner to draw 74 - image instead of the image gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 74, 74, 74, 74); + + // the z-buffer will later only allow drawing outside the lens circle } + // Together with the depth source set above, this sets the depth to the closest. + // For a pixel with such a depth value, the z-buffer will reject drawing to that pixel. gDPSetPrimDepth(POLY_XLU_DISP++, 0, 0); - func_80030FA8(gfxCtx); + // The z-buffer will be updated where the mask is not fully transparent. + Actor_DrawLensOverlay(gfxCtx); // "Magic lens invisible Actor display START" gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ 見えないActor表示 START", numInvisibleActors); @@ -2711,7 +2733,9 @@ void func_8003115C(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** inv // "Magic lens invisible Actor display END" gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ 見えないActor表示 END", numInvisibleActors); - if (globalCtx->roomCtx.curRoom.showInvisActors != 0) { + if (globalCtx->roomCtx.curRoom.lensMode != LENS_MODE_HIDE_ACTORS) { + // Draw the lens overlay to the color frame buffer + gDPNoOpString(POLY_OPA_DISP++, "青い眼鏡(外側)", 0); // "Blue spectacles (exterior)" gDPPipeSync(POLY_XLU_DISP++); @@ -2723,7 +2747,7 @@ void func_8003115C(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** inv gDPSetCombineMode(POLY_XLU_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 0, 0, 255); - func_80030FA8(gfxCtx); + Actor_DrawLensOverlay(gfxCtx); gDPNoOpString(POLY_OPA_DISP++, "青い眼鏡(外側)", 1); // "Blue spectacles (exterior)" } @@ -2808,8 +2832,8 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(71) == 0)) { if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & (ACTOR_FLAG_5 | ACTOR_FLAG_6))) { if ((actor->flags & ACTOR_FLAG_7) && - ((globalCtx->roomCtx.curRoom.showInvisActors == 0) || (globalCtx->actorCtx.unk_03 != 0) || - (actor->room != globalCtx->roomCtx.curRoom.num))) { + ((globalCtx->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) || + globalCtx->actorCtx.lensActive || (actor->room != globalCtx->roomCtx.curRoom.num))) { ASSERT(invisibleActorCounter < INVISIBLE_ACTOR_MAX); invisibleActors[invisibleActorCounter] = actor; invisibleActorCounter++; @@ -2835,10 +2859,10 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { } if ((HREG(64) != 1) || (HREG(72) != 0)) { - if (globalCtx->actorCtx.unk_03 != 0) { - func_8003115C(globalCtx, invisibleActorCounter, invisibleActors); + if (globalCtx->actorCtx.lensActive) { + Actor_DrawLensActors(globalCtx, invisibleActorCounter, invisibleActors); if ((globalCtx->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(globalCtx)) { - func_800304B0(globalCtx); + Actor_DisableLens(globalCtx); } } } @@ -3195,6 +3219,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s16 params) { Actor* spawnedActor = Actor_Spawn(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params); + if (spawnedActor == NULL) { return NULL; } diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index c0b70a904..ea37cab1a 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -11,7 +11,7 @@ s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags); s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 flags); s32 Camera_QRegInit(void); -s32 Camera_CheckWater(Camera* camera); +s32 Camera_UpdateWater(Camera* camera); #define RELOAD_PARAMS \ (camera->animState == 0 || camera->animState == 0xA || camera->animState == 0x14 || R_RELOAD_CAM_PARAMS) @@ -28,6 +28,12 @@ s32 Camera_CheckWater(Camera* camera); #define FLG_ADJSLOPE (1 << 0) #define FLG_OFFGROUND (1 << 7) +#define DISTORTION_HOT_ROOM (1 << 0) +#define DISTORTION_UNDERWATER_WEAK (1 << 1) +#define DISTORTION_UNDERWATER_MEDIUM (1 << 2) +#define DISTORTION_UNDERWATER_STRONG (1 << 3) +#define DISTORTION_UNDERWATER_FISHING (1 << 4) + #include "z_camera_data.inc" /*===============================================================*/ @@ -972,7 +978,7 @@ s32 func_80045B08(Camera* camera, VecSph* eyeAtDir, f32 yExtra, s16 arg3) { f32 phi_f2; Vec3f posOffsetTarget; Vec3f atTarget; - f32 sp38; // unused + f32 pad; f32 temp_ret; PosRot* playerPosRot = &camera->playerPosRot; @@ -7004,19 +7010,20 @@ void func_80057FC4(Camera* camera) { if (camera != &camera->globalCtx->mainCamera) { camera->prevSetting = camera->setting = CAM_SET_FREE0; camera->unk_14C &= ~0x4; - } else if (camera->globalCtx->roomCtx.curRoom.mesh->polygon.type != 1) { - switch (camera->globalCtx->roomCtx.curRoom.unk_03) { - case 1: + } else if (camera->globalCtx->roomCtx.curRoom.meshHeader->base.type != 1) { + switch (camera->globalCtx->roomCtx.curRoom.behaviorType1) { + case ROOM_BEHAVIOR_TYPE1_1: Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10); camera->prevSetting = camera->setting = CAM_SET_DUNGEON0; break; - case 0: + case ROOM_BEHAVIOR_TYPE1_0: osSyncPrintf("camera: room type: default set field\n"); Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10); camera->prevSetting = camera->setting = CAM_SET_NORMAL0; break; default: - osSyncPrintf("camera: room type: default set etc (%d)\n", camera->globalCtx->roomCtx.curRoom.unk_03); + osSyncPrintf("camera: room type: default set etc (%d)\n", + camera->globalCtx->roomCtx.curRoom.behaviorType1); Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10); camera->prevSetting = camera->setting = CAM_SET_NORMAL0; camera->unk_14C |= 4; @@ -7095,7 +7102,7 @@ void Camera_InitPlayerSettings(Camera* camera, Player* player) { osSyncPrintf(VT_FGCOL(BLUE) "camera: personalize ---" VT_RST "\n"); if (camera->thisIdx == MAIN_CAM) { - Camera_CheckWater(camera); + Camera_UpdateWater(camera); } } @@ -7203,7 +7210,7 @@ void Camera_PrintSettings(Camera* camera) { } } -s32 Camera_CheckWater(Camera* camera) { +s32 Camera_UpdateWater(Camera* camera) { f32 waterY; s16 newQuakeId; s32 waterLightsIndex; @@ -7280,7 +7287,7 @@ s32 Camera_CheckWater(Camera* camera) { camera->unk_14C |= 0x100; osSyncPrintf("kankyo changed water, sound on\n"); Environment_EnableUnderwaterLights(camera->globalCtx, waterLightsIndex); - camera->unk_150 = 0x50; + camera->waterDistortionTimer = 80; } Audio_SetExtraFilter(0x20); @@ -7299,13 +7306,13 @@ s32 Camera_CheckWater(Camera* camera) { } } - if (camera->unk_150 > 0) { - camera->unk_150--; - camera->unk_152 |= 8; - } else if (camera->globalCtx->sceneNum == 0x49) { - camera->unk_152 |= 0x10; + if (camera->waterDistortionTimer > 0) { + camera->waterDistortionTimer--; + camera->distortionFlags |= DISTORTION_UNDERWATER_STRONG; + } else if (camera->globalCtx->sceneNum == SCENE_TURIBORI) { + camera->distortionFlags |= DISTORTION_UNDERWATER_FISHING; } else { - camera->unk_152 |= 2; + camera->distortionFlags |= DISTORTION_UNDERWATER_WEAK; } } else { if (camera->unk_14C & 0x100) { @@ -7315,21 +7322,18 @@ s32 Camera_CheckWater(Camera* camera) { if (*quakeId != 0) { Quake_RemoveFromIdx(*quakeId); } - camera->unk_150 = 0; - camera->unk_152 = 0; + camera->waterDistortionTimer = 0; + camera->distortionFlags = 0; } Audio_SetExtraFilter(0); } //! @bug: doesn't always return a value, but sometimes does. } -/** - * Sets the room to be hot camera quake flag - */ -s32 Camera_SetRoomHotFlag(Camera* camera) { - camera->unk_152 &= ~1; - if (camera->globalCtx->roomCtx.curRoom.unk_02 == 3) { - camera->unk_152 |= 1; +s32 Camera_UpdateHotRoom(Camera* camera) { + camera->distortionFlags &= ~DISTORTION_HOT_ROOM; + if (camera->globalCtx->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) { + camera->distortionFlags |= DISTORTION_HOT_ROOM; } return 1; @@ -7364,80 +7368,87 @@ s32 Camera_DbgChangeMode(Camera* camera) { return true; } -s16 D_8011DB08 = 0x3F0; -s16 D_8011DB0C = 0x156; -void func_80058E8C(Camera* camera) { - s32 pad3; - f32 sp60; - s32 pad; - s32 pad1; - s32 pad4; - f32 phi_f2; - s32 pad2; - f32 phi_f0; - f32 phi_f20; - f32 sp40; - f32 sp3C; - f32 sp38; - f32 sp34; - - if (camera->unk_152 != 0) { - if (camera->unk_152 & 4) { - phi_f0 = 0.0f; - phi_f2 = 170.0f; - sp3C = 0.01f; - sp40 = -0.01f; - sp38 = 0.0f; - sp34 = 0.6f; - phi_f20 = camera->unk_150 / 60.0f; - sp60 = 1.0f; - } else if (camera->unk_152 & 8) { - phi_f0 = 248.0f; - phi_f2 = -90.0f; - sp38 = 0.2f; - sp34 = 0.2f; - sp40 = -0.3f; - sp3C = 0.3f; - phi_f20 = camera->unk_150 / 80.0f; - sp60 = 1.0f; - } else if (camera->unk_152 & 2) { - phi_f0 = 359.2f; - phi_f2 = -18.5f; - sp40 = 0.09f; - sp38 = 0.01f; - sp3C = 0.09f; - sp34 = 0.08f; - phi_f20 = +s16 depthPhase = 0x3F0; +s16 screenPlanePhase = 0x156; +void Camera_UpdateDistortion(Camera* camera) { + f32 scaleFactor; + f32 speedFactor; + f32 depthPhaseStep; + f32 screenPlanePhaseStep; + s32 pad[5]; + f32 xScale; + f32 yScale; + f32 zScale; + f32 speed; + + if (camera->distortionFlags != 0) { + if (camera->distortionFlags & DISTORTION_UNDERWATER_MEDIUM) { + depthPhaseStep = 0.0f; + screenPlanePhaseStep = 170.0f; + + xScale = -0.01f; + yScale = 0.01f; + zScale = 0.0f; + + speed = 0.6f; + scaleFactor = camera->waterDistortionTimer / 60.0f; + speedFactor = 1.0f; + } else if (camera->distortionFlags & DISTORTION_UNDERWATER_STRONG) { + depthPhaseStep = 248.0f; + screenPlanePhaseStep = -90.0f; + + xScale = -0.3f; + yScale = 0.3f; + zScale = 0.2f; + + speed = 0.2f; + scaleFactor = camera->waterDistortionTimer / 80.0f; + speedFactor = 1.0f; + } else if (camera->distortionFlags & DISTORTION_UNDERWATER_WEAK) { + depthPhaseStep = 359.2f; + screenPlanePhaseStep = -18.5f; + + xScale = 0.09f; + yScale = 0.09f; + zScale = 0.01f; + + speed = 0.08f; + scaleFactor = (((camera->waterYPos - camera->eye.y) > 150.0f ? 1.0f : (camera->waterYPos - camera->eye.y) / 150.0f) * 0.45f) + (camera->speedRatio * 0.45f); - sp60 = phi_f20; - } else if (camera->unk_152 & 1) { - // hot room flag - phi_f2 = 150.0f; - phi_f0 = 0.0f; - sp3C = 0.01f; - sp38 = 0.01f; - sp40 = -0.01f; - sp34 = 0.6f; - sp60 = 1.0f; - phi_f20 = 1.0f; - + speedFactor = scaleFactor; + } else if (camera->distortionFlags & DISTORTION_HOT_ROOM) { + // Gives the hot-room a small mirage-like appearance + depthPhaseStep = 0.0f; + screenPlanePhaseStep = 150.0f; + + xScale = -0.01f; + yScale = 0.01f; + zScale = 0.01f; + + speed = 0.6f; + speedFactor = 1.0f; + scaleFactor = 1.0f; } else { + // DISTORTION_UNDERWATER_FISHING return; } - D_8011DB08 += DEGF_TO_BINANG(phi_f0); - D_8011DB0C += DEGF_TO_BINANG(phi_f2); - Math_CosS(D_8011DB08); - Math_SinS(D_8011DB08); - Math_SinS(D_8011DB0C); - func_800AA76C(&camera->globalCtx->view, 0.0f, 0.0f, 0.0f); - func_800AA78C(&camera->globalCtx->view, Math_SinS(D_8011DB0C) * (sp40 * phi_f20) + 1.0f, - Math_CosS(D_8011DB0C) * (sp3C * phi_f20) + 1.0f, Math_CosS(D_8011DB08) * (sp38 * phi_f20) + 1.0f); - func_800AA7AC(&camera->globalCtx->view, sp34 * sp60); + + depthPhase += DEGF_TO_BINANG(depthPhaseStep); + screenPlanePhase += DEGF_TO_BINANG(screenPlanePhaseStep); + + View_SetDistortionOrientation(&camera->globalCtx->view, Math_CosS(depthPhase) * 0.0f, Math_SinS(depthPhase) * 0.0f, + Math_SinS(screenPlanePhase) * 0.0f); + View_SetDistortionScale(&camera->globalCtx->view, Math_SinS(screenPlanePhase) * (xScale * scaleFactor) + 1.0f, + Math_CosS(screenPlanePhase) * (yScale * scaleFactor) + 1.0f, + Math_CosS(depthPhase) * (zScale * scaleFactor) + 1.0f); + View_SetDistortionSpeed(&camera->globalCtx->view, speed * speedFactor); + camera->unk_14C |= 0x40; + } else if (camera->unk_14C & 0x40) { - func_800AA814(&camera->globalCtx->view); + View_ClearDistortion(&camera->globalCtx->view); camera->unk_14C &= ~0x40; } } @@ -7506,8 +7517,8 @@ Vec3s Camera_Update(Camera* camera) { if (sOOBTimer < 200) { if (camera->status == CAM_STAT_ACTIVE) { - Camera_CheckWater(camera); - Camera_SetRoomHotFlag(camera); + Camera_UpdateWater(camera); + Camera_UpdateHotRoom(camera); } if (!(camera->unk_14C & 4)) { @@ -7647,7 +7658,8 @@ Vec3s Camera_Update(Camera* camera) { camera->skyboxOffset = quake.eyeOffset; - func_80058E8C(camera); + Camera_UpdateDistortion(camera); + if ((camera->globalCtx->sceneNum == SCENE_SPOT00) && (camera->fov < 59.0f)) { View_SetScale(&camera->globalCtx->view, 0.79f); } else { @@ -7844,7 +7856,7 @@ s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 flags) { func_80078884(0); break; case 2: - if (camera->globalCtx->roomCtx.curRoom.unk_03 == 1) { + if (camera->globalCtx->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) { func_80078884(NA_SE_SY_ATTENTION_URGENCY); } else { func_80078884(NA_SE_SY_ATTENTION_ON); diff --git a/soh/src/code/z_kankyo.c b/soh/src/code/z_kankyo.c index 7fd9a7480..a8bc385f8 100644 --- a/soh/src/code/z_kankyo.c +++ b/soh/src/code/z_kankyo.c @@ -36,8 +36,8 @@ typedef struct { } LightningBolt; // size = 0x20 typedef struct { - /* 0x00 */ s32 unk0; - /* 0x04 */ s32 unk1; + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; } Struct_8011FAF0; // size = 0x8 Struct_8011FAF0 D_8011FAF0[] = { @@ -215,7 +215,7 @@ u8 sGameOverLightsIntensity; u16 D_8015FDB0; s32 func_8006F0A0(s32 a0) { - s32 ret = ((a0 >> 4 & 0x7FF) << D_8011FAF0[a0 >> 15 & 7].unk0) + D_8011FAF0[a0 >> 15 & 7].unk1; + s32 ret = ((a0 >> 4 & 0x7FF) << D_8011FAF0[a0 >> 15 & 7].unk_00) + D_8011FAF0[a0 >> 15 & 7].unk_04; return ret; } @@ -2454,7 +2454,7 @@ void Environment_AdjustLights(GlobalContext* globalCtx, f32 arg1, f32 arg2, f32 f32 temp; s32 i; - if (globalCtx->roomCtx.curRoom.unk_03 != 5 && func_800C0CB8(globalCtx)) { + if (globalCtx->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_5 && func_800C0CB8(globalCtx)) { arg1 = CLAMP_MIN(arg1, 0.0f); arg1 = CLAMP_MAX(arg1, 1.0f); diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 24211c590..ba589f56c 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -817,7 +817,7 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { break; } - if ((globalCtx->roomCtx.curRoom.unk_03 == 1) && (interfaceCtx->minimapAlpha >= 0xFF)) { + if ((globalCtx->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) && (interfaceCtx->minimapAlpha >= 255)) { interfaceCtx->minimapAlpha = 255; } } @@ -2781,7 +2781,7 @@ s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2) { case 2: if ((gSaveContext.unk_13F0 == 0) || (gSaveContext.unk_13F0 == 7)) { if (gSaveContext.unk_13F0 == 7) { - globalCtx->actorCtx.unk_03 = 0; + globalCtx->actorCtx.lensActive = false; } gSaveContext.unk_13F8 = gSaveContext.magic - arg1; gSaveContext.unk_13F0 = 1; @@ -2793,7 +2793,7 @@ s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2) { case 1: if ((gSaveContext.unk_13F0 == 0) || (gSaveContext.unk_13F0 == 7)) { if (gSaveContext.unk_13F0 == 7) { - globalCtx->actorCtx.unk_03 = 0; + globalCtx->actorCtx.lensActive = false; } gSaveContext.unk_13F8 = gSaveContext.magic - arg1; gSaveContext.unk_13F0 = 6; @@ -2821,7 +2821,7 @@ s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2) { case 4: if ((gSaveContext.unk_13F0 == 0) || (gSaveContext.unk_13F0 == 7)) { if (gSaveContext.unk_13F0 == 7) { - globalCtx->actorCtx.unk_03 = 0; + globalCtx->actorCtx.lensActive = false; } gSaveContext.unk_13F8 = gSaveContext.magic - arg1; gSaveContext.unk_13F0 = 4; @@ -3010,8 +3010,8 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { } if ((gSaveContext.magic == 0) || ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) || !hasLens || - (globalCtx->actorCtx.unk_03 == 0)) { - globalCtx->actorCtx.unk_03 = 0; + !globalCtx->actorCtx.lensActive) { + globalCtx->actorCtx.lensActive = false; Audio_PlaySoundGeneral(NA_SE_SY_GLASSMODE_OFF, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); gSaveContext.unk_13F0 = 0; @@ -5884,7 +5884,8 @@ void Interface_Update(GlobalContext* globalCtx) { gTimeIncrement = sPrevTimeIncrement; globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; } - } else if ((globalCtx->roomCtx.curRoom.unk_03 != 1) && (interfaceCtx->restrictions.sunsSong != 3)) { + } else if ((globalCtx->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_1) && + (interfaceCtx->restrictions.sunsSong != 3)) { if ((gSaveContext.dayTime >= 0x4555) && (gSaveContext.dayTime < 0xC001)) { gSaveContext.nextDayTime = 0; globalCtx->fadeTransition = 4; diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 104b7f1e4..622a64a94 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -306,7 +306,7 @@ void Gameplay_Init(GameState* thisx) { Audio_SetExtraFilter(0); Quake_Init(); - for (i = 0; i < 4; i++) { + for (i = 0; i < ARRAY_COUNT(globalCtx->cameraPtrs); i++) { globalCtx->cameraPtrs[i] = NULL; } @@ -1932,7 +1932,7 @@ void Gameplay_TriggerRespawn(GlobalContext* globalCtx) { } s32 func_800C0CB8(GlobalContext* globalCtx) { - return (globalCtx->roomCtx.curRoom.mesh->polygon.type != 1) && (YREG(15) != 0x20) && (YREG(15) != 0x30) && + return (globalCtx->roomCtx.curRoom.meshHeader->base.type != 1) && (YREG(15) != 0x20) && (YREG(15) != 0x30) && (YREG(15) != 0x40) && (globalCtx->sceneNum != SCENE_HAIRAL_NIWA); } diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 2db533821..99425bd8d 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -322,7 +322,7 @@ void Player_SetBootData(GlobalContext* globalCtx, Player* this) { IREG(69) = bootRegs[15]; MREG(95) = bootRegs[16]; - if (globalCtx->roomCtx.curRoom.unk_03 == 2) { + if (globalCtx->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_2) { REG(45) = 500; } } @@ -615,7 +615,7 @@ s32 func_8008F2F8(GlobalContext* globalCtx) { TextTriggerEntry* triggerEntry; s32 var; - if (globalCtx->roomCtx.curRoom.unk_02 == 3) { // Room is hot + if (globalCtx->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) { // Room is hot var = 0; } else if ((this->unk_840 > 80) && ((this->currentBoots == PLAYER_BOOTS_IRON) || (this->unk_840 >= 300))) { // Deep underwater diff --git a/soh/src/code/z_rcp.c b/soh/src/code/z_rcp.c index 7050973e1..c6a50cf94 100644 --- a/soh/src/code/z_rcp.c +++ b/soh/src/code/z_rcp.c @@ -1012,7 +1012,7 @@ void func_80093C80(GlobalContext* globalCtx) { func_80093D18(gfxCtx); - if (globalCtx->roomCtx.curRoom.unk_03 == 3) { + if (globalCtx->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_3) { OPEN_DISPS(gfxCtx); gDPSetColorDither(POLY_OPA_DISP++, G_CD_DISABLE); diff --git a/soh/src/code/z_room.c b/soh/src/code/z_room.c index d73533ff8..593406d69 100644 --- a/soh/src/code/z_room.c +++ b/soh/src/code/z_room.c @@ -53,7 +53,7 @@ void func_80095AB4(GlobalContext* globalCtx, Room* room, u32 flags) { gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); } - polygon0 = &room->mesh->polygon0; + polygon0 = &room->meshHeader->polygon0; polygonDlist = SEGMENTED_TO_VIRTUAL(polygon0->start); for (i = 0; i < polygon0->num; i++) { if ((flags & 1) && (polygonDlist->opa != NULL)) { @@ -113,7 +113,7 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); } - polygon2 = &room->mesh->polygon2; + polygon2 = &room->meshHeader->polygon2; polygonDlist = SEGMENTED_TO_VIRTUAL(polygon2->start); spA4 = spB8; @@ -346,7 +346,7 @@ void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) { camera = GET_ACTIVE_CAM(globalCtx); sp9C = (camera->setting == CAM_SET_PREREND_FIXED); - polygon1 = &room->mesh->polygon1; + polygon1 = &room->meshHeader->polygon1; polygonDlist = SEGMENTED_TO_VIRTUAL(polygon1->dlist); sp98 = (flags & 1) && sp9C && polygon1->single.source && !(SREG(25) & 1); sp94 = (flags & 1) && polygonDlist->opa && !(SREG(25) & 2); @@ -447,7 +447,7 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { camera = GET_ACTIVE_CAM(globalCtx); sp98 = (camera->setting == CAM_SET_PREREND_FIXED); - polygon1 = &room->mesh->polygon1; + polygon1 = &room->meshHeader->polygon1; polygonDlist = SEGMENTED_TO_VIRTUAL(polygon1->dlist); bgImage = func_80096A74(polygon1, globalCtx); sp94 = (flags & 1) && sp98 && bgImage->source && !(SREG(25) & 1); @@ -494,7 +494,7 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { // Room Draw Polygon Type 1 void func_80096F6C(GlobalContext* globalCtx, Room* room, u32 flags) { - PolygonType1* polygon1 = &room->mesh->polygon1; + PolygonType1* polygon1 = &room->meshHeader->polygon1; if (polygon1->format == 1) { func_80096680(globalCtx, room, flags); @@ -626,8 +626,8 @@ void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags) { if (room->segment != NULL) { gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment); - ASSERT(room->mesh->polygon.type < ARRAY_COUNTU(sRoomDrawHandlers)); - sRoomDrawHandlers[room->mesh->polygon.type](globalCtx, room, flags); + ASSERT(room->meshHeader->base.type < ARRAY_COUNTU(sRoomDrawHandlers)); + sRoomDrawHandlers[room->meshHeader->base.type](globalCtx, room, flags); } } diff --git a/soh/src/code/z_scene.c b/soh/src/code/z_scene.c index a80fa62ea..145d039a1 100644 --- a/soh/src/code/z_scene.c +++ b/soh/src/code/z_scene.c @@ -168,11 +168,11 @@ s32 Scene_ExecuteCommands(GlobalContext* globalCtx, SceneCmd* sceneCmd) { osSyncPrintf("*** Scene_Word = { code=%d, data1=%02x, data2=%04x } ***\n", cmdCode, sceneCmd->base.data1, sceneCmd->base.data2); - if (cmdCode == 0x14) { + if (cmdCode == SCENE_CMD_ID_END) { break; } - if (cmdCode <= 0x19) { + if (cmdCode < ARRAY_COUNT(gSceneCmdHandlers)) { gSceneCmdHandlers[cmdCode](globalCtx, sceneCmd); } else { osSyncPrintf(VT_FGCOL(RED)); @@ -184,7 +184,7 @@ s32 Scene_ExecuteCommands(GlobalContext* globalCtx, SceneCmd* sceneCmd) { return 0; } -void func_80098508(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { ActorEntry* linkEntry = globalCtx->linkActorEntry = (ActorEntry*)SEGMENTED_TO_VIRTUAL(cmd->spawnList.segment) + globalCtx->setupEntranceList[globalCtx->curSpawn].spawn; s16 linkObjectId; @@ -197,19 +197,16 @@ void func_80098508(GlobalContext* globalCtx, SceneCmd* cmd) { Object_Spawn(&globalCtx->objectCtx, linkObjectId); } -// Scene Command 0x01: Actor List -void func_800985DC(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandActorList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->numSetupActors = cmd->actorList.num; globalCtx->setupActorList = SEGMENTED_TO_VIRTUAL(cmd->actorList.segment); } -// Scene Command 0x02: Unused 02 -void func_80098630(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandUnused2(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment); } -// Scene Command 0x03: Collision Header -void func_80098674(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandCollisionHeader(GlobalContext* globalCtx, SceneCmd* cmd) { CollisionHeader* colHeader = SEGMENTED_TO_VIRTUAL(cmd->colHeader.segment); colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList); @@ -221,19 +218,16 @@ void func_80098674(GlobalContext* globalCtx, SceneCmd* cmd) { BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader); } -// Scene Command 0x04: Room List -void func_800987A4(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandRoomList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->numRooms = cmd->roomList.num; globalCtx->roomList = SEGMENTED_TO_VIRTUAL(cmd->roomList.segment); } -// Scene Command 0x06: Entrance List -void func_800987F8(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandEntranceList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->setupEntranceList = SEGMENTED_TO_VIRTUAL(cmd->entranceList.segment); } -// Scene Command 0x07: Special Files -void func_8009883C(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandSpecialFiles(GlobalContext* globalCtx, SceneCmd* cmd) { if (cmd->specialFiles.keepObjectId != OBJECT_INVALID) { globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.keepObjectId); gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); @@ -244,21 +238,18 @@ void func_8009883C(GlobalContext* globalCtx, SceneCmd* cmd) { } } -// Scene Command 0x08: Room Behavior -void func_80098904(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.curRoom.unk_03 = cmd->roomBehavior.gpFlag1; - globalCtx->roomCtx.curRoom.unk_02 = cmd->roomBehavior.gpFlag2 & 0xFF; - globalCtx->roomCtx.curRoom.showInvisActors = (cmd->roomBehavior.gpFlag2 >> 8) & 1; +void Scene_CommandRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd) { + globalCtx->roomCtx.curRoom.behaviorType1 = cmd->roomBehavior.gpFlag1; + globalCtx->roomCtx.curRoom.behaviorType2 = cmd->roomBehavior.gpFlag2 & 0xFF; + globalCtx->roomCtx.curRoom.lensMode = (cmd->roomBehavior.gpFlag2 >> 8) & 1; globalCtx->msgCtx.disableWarpSongs = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1; } -// Scene Command 0x0A: Mesh Header -void func_80098958(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.curRoom.mesh = SEGMENTED_TO_VIRTUAL(cmd->mesh.segment); +void Scene_CommandMeshHeader(GlobalContext* globalCtx, SceneCmd* cmd) { + globalCtx->roomCtx.curRoom.meshHeader = SEGMENTED_TO_VIRTUAL(cmd->mesh.segment); } -// Scene Command 0x0B: Object List -void func_8009899C(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { s32 i; s32 j; s32 k; @@ -307,8 +298,7 @@ void func_8009899C(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->objectCtx.num = i; } -// Scene Command 0x0C: Light List -void func_80098B74(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandLightList(GlobalContext* globalCtx, SceneCmd* cmd) { s32 i; LightInfo* lightInfo = SEGMENTED_TO_VIRTUAL(cmd->lightList.segment); @@ -318,13 +308,11 @@ void func_80098B74(GlobalContext* globalCtx, SceneCmd* cmd) { } } -// Scene Command 0x0D: Path List -void func_80098C24(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandPathList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->setupPathList = SEGMENTED_TO_VIRTUAL(cmd->pathList.segment); } -// Scene Command 0x0E: Transition Actor List -void func_80098C68(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandTransitionActorList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->transiActorCtx.numActors = cmd->transiActorList.num; globalCtx->transiActorCtx.list = SEGMENTED_TO_VIRTUAL(cmd->transiActorList.segment); } @@ -333,27 +321,23 @@ void TransitionActor_InitContext(GameState* state, TransitionActorContext* trans transiActorCtx->numActors = 0; } -// Scene Command 0x0F: Light Setting List -void func_80098CC8(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandLightSettingsList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->envCtx.numLightSettings = cmd->lightSettingList.num; globalCtx->envCtx.lightSettingsList = SEGMENTED_TO_VIRTUAL(cmd->lightSettingList.segment); } -// Scene Command 0x11: Skybox Settings -void func_80098D1C(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->skyboxId = cmd->skyboxSettings.skyboxId; globalCtx->envCtx.unk_17 = globalCtx->envCtx.unk_18 = cmd->skyboxSettings.unk_05; globalCtx->envCtx.indoors = cmd->skyboxSettings.unk_06; } -// Scene Command 0x12: Skybox Disables -void func_80098D5C(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->envCtx.skyboxDisabled = cmd->skyboxDisables.unk_04; globalCtx->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk_05; } -// Scene Command 0x10: Time Settings -void func_80098D80(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { if ((cmd->timeSettings.hour != 0xFF) && (cmd->timeSettings.min != 0xFF)) { gSaveContext.skyboxTime = gSaveContext.dayTime = ((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / ((f32)(24 * 60) / 0x10000); @@ -388,8 +372,7 @@ void func_80098D80(GlobalContext* globalCtx, SceneCmd* cmd) { } } -// Scene Command 0x05: Wind Settings -void func_80099090(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandWindSettings(GlobalContext* globalCtx, SceneCmd* cmd) { s8 x = cmd->windSettings.x; s8 y = cmd->windSettings.y; s8 z = cmd->windSettings.z; @@ -401,17 +384,14 @@ void func_80099090(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->envCtx.windSpeed = cmd->windSettings.unk_07; } -// Scene Command 0x13: Exit List -void func_800990F0(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandExitList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->setupExitList = SEGMENTED_TO_VIRTUAL(cmd->exitList.segment); } -// Scene Command 0x09: Undefined -void func_80099134(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandUndefined9(GlobalContext* globalCtx, SceneCmd* cmd) { } -// Scene Command 0x15: Sound Settings -void func_80099140(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->sequenceCtx.seqId = cmd->soundSettings.seqId; globalCtx->sequenceCtx.natureAmbienceId = cmd->soundSettings.natureAmbienceId; @@ -420,13 +400,11 @@ void func_80099140(GlobalContext* globalCtx, SceneCmd* cmd) { } } -// Scene Command 0x16: Echo Setting -void func_8009918C(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandEchoSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->roomCtx.curRoom.echo = cmd->echoSettings.echo; } -// Scene Command 0x18: Alternate Headers -void func_800991A0(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandAlternateHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { s32 pad; SceneCmd* altHeader; @@ -439,7 +417,7 @@ void func_800991A0(GlobalContext* globalCtx, SceneCmd* cmd) { if (altHeader != NULL) { Scene_ExecuteCommands(globalCtx, SEGMENTED_TO_VIRTUAL(altHeader)); - (cmd + 1)->base.code = 0x14; + (cmd + 1)->base.code = SCENE_CMD_ID_END; } else { // "Coughh! There is no specified dataaaaa!" osSyncPrintf("\nげぼはっ! 指定されたデータがないでええっす!"); @@ -453,21 +431,20 @@ void func_800991A0(GlobalContext* globalCtx, SceneCmd* cmd) { if (altHeader != NULL) { Scene_ExecuteCommands(globalCtx, SEGMENTED_TO_VIRTUAL(altHeader)); - (cmd + 1)->base.code = 0x14; + (cmd + 1)->base.code = SCENE_CMD_ID_END; } } } } } -// Scene Command 0x17: Cutscene Data -void func_8009934C(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandCutsceneData(GlobalContext* globalCtx, SceneCmd* cmd) { osSyncPrintf("\ngame_play->demo_play.data=[%x]", globalCtx->csCtx.segment); globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(cmd->cutsceneData.segment); } -// Scene Command 0x19: Misc. Settings (Camera & World Map Area) -void func_800993C0(GlobalContext* globalCtx, SceneCmd* cmd) { +// Camera & World Map Area +void Scene_CommandMiscSettings(GlobalContext* globalCtx, SceneCmd* cmd) { YREG(15) = cmd->miscSettings.cameraMovement; gSaveContext.worldMapArea = cmd->miscSettings.area; @@ -487,11 +464,33 @@ void func_800993C0(GlobalContext* globalCtx, SceneCmd* cmd) { } } -void (*gSceneCmdHandlers[])(GlobalContext*, SceneCmd*) = { - func_80098508, func_800985DC, func_80098630, func_80098674, func_800987A4, func_80099090, func_800987F8, - func_8009883C, func_80098904, func_80099134, func_80098958, func_8009899C, func_80098B74, func_80098C24, - func_80098C68, func_80098CC8, func_80098D80, func_80098D1C, func_80098D5C, func_800990F0, NULL, - func_80099140, func_8009918C, func_8009934C, func_800991A0, func_800993C0, +void (*gSceneCmdHandlers[SCENE_CMD_ID_MAX])(GlobalContext*, SceneCmd*) = { + Scene_CommandSpawnList, // SCENE_CMD_ID_SPAWN_LIST + Scene_CommandActorList, // SCENE_CMD_ID_ACTOR_LIST + Scene_CommandUnused2, // SCENE_CMD_ID_UNUSED_2 + Scene_CommandCollisionHeader, // SCENE_CMD_ID_COLLISION_HEADER + Scene_CommandRoomList, // SCENE_CMD_ID_ROOM_LIST + Scene_CommandWindSettings, // SCENE_CMD_ID_WIND_SETTINGS + Scene_CommandEntranceList, // SCENE_CMD_ID_ENTRANCE_LIST + Scene_CommandSpecialFiles, // SCENE_CMD_ID_SPECIAL_FILES + Scene_CommandRoomBehavior, // SCENE_CMD_ID_ROOM_BEHAVIOR + Scene_CommandUndefined9, // SCENE_CMD_ID_UNDEFINED_9 + Scene_CommandMeshHeader, // SCENE_CMD_ID_MESH_HEADER + Scene_CommandObjectList, // SCENE_CMD_ID_OBJECT_LIST + Scene_CommandLightList, // SCENE_CMD_ID_LIGHT_LIST + Scene_CommandPathList, // SCENE_CMD_ID_PATH_LIST + Scene_CommandTransitionActorList, // SCENE_CMD_ID_TRANSITION_ACTOR_LIST + Scene_CommandLightSettingsList, // SCENE_CMD_ID_LIGHT_SETTINGS_LIST + Scene_CommandTimeSettings, // SCENE_CMD_ID_TIME_SETTINGS + Scene_CommandSkyboxSettings, // SCENE_CMD_ID_SKYBOX_SETTINGS + Scene_CommandSkyboxDisables, // SCENE_CMD_ID_SKYBOX_DISABLES + Scene_CommandExitList, // SCENE_CMD_ID_EXIT_LIST + NULL, // SCENE_CMD_ID_END + Scene_CommandSoundSettings, // SCENE_CMD_ID_SOUND_SETTINGS + Scene_CommandEchoSettings, // SCENE_CMD_ID_ECHO_SETTINGS + Scene_CommandCutsceneData, // SCENE_CMD_ID_CUTSCENE_DATA + Scene_CommandAlternateHeaderList, // SCENE_CMD_ID_ALTERNATE_HEADER_LIST + Scene_CommandMiscSettings, // SCENE_CMD_ID_MISC_SETTINGS }; RomFile sNaviMsgFiles[] = { diff --git a/soh/src/code/z_scene_table.c b/soh/src/code/z_scene_table.c index ea1f45863..4987cba2f 100644 --- a/soh/src/code/z_scene_table.c +++ b/soh/src/code/z_scene_table.c @@ -2401,12 +2401,14 @@ void func_8009FE58(GlobalContext* globalCtx) { temp = 0.020000001f; if (globalCtx->pauseCtx.state == 0) { - func_800AA76C(&globalCtx->view, ((360.00018f / 65535.0f) * (M_PI / 180.0f)) * temp * Math_CosS(D_8012A39C), - ((360.00018f / 65535.0f) * (M_PI / 180.0f)) * temp * Math_SinS(D_8012A39C), - ((360.00018f / 65535.0f) * (M_PI / 180.0f)) * temp * Math_SinS(D_8012A3A0)); - func_800AA78C(&globalCtx->view, 1.f + (0.79999995f * temp * Math_SinS(D_8012A3A0)), - 1.f + (0.39999998f * temp * Math_CosS(D_8012A3A0)), 1.f + (1 * temp * Math_CosS(D_8012A39C))); - func_800AA7AC(&globalCtx->view, 0.95f); + View_SetDistortionOrientation(&globalCtx->view, + ((360.00018f / 65535.0f) * (M_PI / 180.0f)) * temp * Math_CosS(D_8012A39C), + ((360.00018f / 65535.0f) * (M_PI / 180.0f)) * temp * Math_SinS(D_8012A39C), + ((360.00018f / 65535.0f) * (M_PI / 180.0f)) * temp * Math_SinS(D_8012A3A0)); + View_SetDistortionScale(&globalCtx->view, 1.f + (0.79999995f * temp * Math_SinS(D_8012A3A0)), + 1.f + (0.39999998f * temp * Math_CosS(D_8012A3A0)), + 1.f + (1 * temp * Math_CosS(D_8012A39C))); + View_SetDistortionSpeed(&globalCtx->view, 0.95f); } switch (globalCtx->roomCtx.unk_74[0]) { diff --git a/soh/src/code/z_view.c b/soh/src/code/z_view.c index 6b70bfac0..c84634a6b 100644 --- a/soh/src/code/z_view.c +++ b/soh/src/code/z_view.c @@ -64,7 +64,7 @@ void View_Init(View* view, GraphicsContext* gfxCtx) { view->unk_124 = 0; view->flags = 1 | 2 | 4; - func_800AA7B8(view); + View_InitDistortion(view); } void View_GetParams(View* view, Vec3f* eye, Vec3f* lookAt, Vec3f* up) { @@ -193,81 +193,87 @@ void func_800AA550(View* view) { CLOSE_DISPS(gfxCtx); } -void func_800AA76C(View* view, f32 x, f32 y, f32 z) { - view->unk_E8.x = x; - view->unk_E8.y = y; - view->unk_E8.z = z; +void View_SetDistortionOrientation(View* view, f32 rotX, f32 rotY, f32 rotZ) { + view->distortionOrientation.x = rotX; + view->distortionOrientation.y = rotY; + view->distortionOrientation.z = rotZ; } -void func_800AA78C(View* view, f32 x, f32 y, f32 z) { - view->unk_F4.x = x; - view->unk_F4.y = y; - view->unk_F4.z = z; +void View_SetDistortionScale(View* view, f32 scaleX, f32 scaleY, f32 scaleZ) { + view->distortionScale.x = scaleX; + view->distortionScale.y = scaleY; + view->distortionScale.z = scaleZ; } -s32 func_800AA7AC(View* view, f32 arg1) { - view->unk_100 = arg1; +s32 View_SetDistortionSpeed(View* view, f32 speed) { + view->distortionSpeed = speed; } -void func_800AA7B8(View* view) { - view->unk_E8.x = 0.0f; - view->unk_E8.y = 0.0f; - view->unk_E8.z = 0.0f; - view->unk_F4.x = 1.0f; - view->unk_F4.y = 1.0f; - view->unk_F4.z = 1.0f; - view->unk_104 = view->unk_E8; - view->unk_110 = view->unk_F4; - view->unk_100 = 0.0f; +void View_InitDistortion(View* view) { + view->distortionOrientation.x = 0.0f; + view->distortionOrientation.y = 0.0f; + view->distortionOrientation.z = 0.0f; + view->distortionScale.x = 1.0f; + view->distortionScale.y = 1.0f; + view->distortionScale.z = 1.0f; + view->curDistortionOrientation = view->distortionOrientation; + view->curDistortionScale = view->distortionScale; + view->distortionSpeed = 0.0f; } -void func_800AA814(View* view) { - view->unk_E8.x = 0.0f; - view->unk_E8.y = 0.0f; - view->unk_E8.z = 0.0f; - view->unk_F4.x = 1.0f; - view->unk_F4.y = 1.0f; - view->unk_F4.z = 1.0f; - view->unk_100 = 1.0f; +void View_ClearDistortion(View* view) { + view->distortionOrientation.x = 0.0f; + view->distortionOrientation.y = 0.0f; + view->distortionOrientation.z = 0.0f; + view->distortionScale.x = 1.0f; + view->distortionScale.y = 1.0f; + view->distortionScale.z = 1.0f; + view->distortionSpeed = 1.0f; } -void func_800AA840(View* view, Vec3f vec1, Vec3f vec2, f32 arg3) { - view->unk_E8 = vec1; - view->unk_F4 = vec2; - view->unk_100 = arg3; +void View_SetDistortion(View* view, Vec3f orientation, Vec3f scale, f32 speed) { + view->distortionOrientation = orientation; + view->distortionScale = scale; + view->distortionSpeed = speed; } -s32 func_800AA890(View* view, Mtx* mtx) { - MtxF mf; +s32 View_StepDistortion(View* view, Mtx* projectionMtx) { + MtxF projectionMtxF; - if (view->unk_100 == 0.0f) { - return 0; - } else if (view->unk_100 == 1.0f) { - view->unk_104 = view->unk_E8; - view->unk_110 = view->unk_F4; - view->unk_100 = 0.0f; + if (view->distortionSpeed == 0.0f) { + return false; + } else if (view->distortionSpeed == 1.0f) { + view->curDistortionOrientation = view->distortionOrientation; + view->curDistortionScale = view->distortionScale; + view->distortionSpeed = 0.0f; } else { - view->unk_104.x += ((view->unk_E8.x - view->unk_104.x) * view->unk_100); - view->unk_104.y += ((view->unk_E8.y - view->unk_104.y) * view->unk_100); - view->unk_104.z += ((view->unk_E8.z - view->unk_104.z) * view->unk_100); - - view->unk_110.x += ((view->unk_F4.x - view->unk_110.x) * view->unk_100); - view->unk_110.y += ((view->unk_F4.y - view->unk_110.y) * view->unk_100); - view->unk_110.z += ((view->unk_F4.z - view->unk_110.z) * view->unk_100); + view->curDistortionOrientation.x = + F32_LERPIMP(view->curDistortionOrientation.x, view->distortionOrientation.x, view->distortionSpeed); + view->curDistortionOrientation.y = + F32_LERPIMP(view->curDistortionOrientation.y, view->distortionOrientation.y, view->distortionSpeed); + view->curDistortionOrientation.z = + F32_LERPIMP(view->curDistortionOrientation.z, view->distortionOrientation.z, view->distortionSpeed); + + view->curDistortionScale.x = + F32_LERPIMP(view->curDistortionScale.x, view->distortionScale.x, view->distortionSpeed); + view->curDistortionScale.y = + F32_LERPIMP(view->curDistortionScale.y, view->distortionScale.y, view->distortionSpeed); + view->curDistortionScale.z = + F32_LERPIMP(view->curDistortionScale.z, view->distortionScale.z, view->distortionSpeed); } - Matrix_MtxToMtxF(mtx, &mf); - Matrix_Put(&mf); - Matrix_RotateX(view->unk_104.x, MTXMODE_APPLY); - Matrix_RotateY(view->unk_104.y, MTXMODE_APPLY); - Matrix_RotateZ(view->unk_104.z, MTXMODE_APPLY); - Matrix_Scale(view->unk_110.x, view->unk_110.y, view->unk_110.z, MTXMODE_APPLY); - Matrix_RotateZ(-view->unk_104.z, MTXMODE_APPLY); - Matrix_RotateY(-view->unk_104.y, MTXMODE_APPLY); - Matrix_RotateX(-view->unk_104.x, MTXMODE_APPLY); - MATRIX_TOMTX(mtx); + Matrix_MtxToMtxF(projectionMtx, &projectionMtxF); + Matrix_Put(&projectionMtxF); + Matrix_RotateX(view->curDistortionOrientation.x, MTXMODE_APPLY); + Matrix_RotateY(view->curDistortionOrientation.y, MTXMODE_APPLY); + Matrix_RotateZ(view->curDistortionOrientation.z, MTXMODE_APPLY); + Matrix_Scale(view->curDistortionScale.x, view->curDistortionScale.y, view->curDistortionScale.z, MTXMODE_APPLY); + Matrix_RotateZ(-view->curDistortionOrientation.z, MTXMODE_APPLY); + Matrix_RotateY(-view->curDistortionOrientation.y, MTXMODE_APPLY); + Matrix_RotateX(-view->curDistortionOrientation.x, MTXMODE_APPLY); + Matrix_ToMtx(projectionMtx, "../z_view.c", 566); - return 1; + return true; } void func_800AAA50(View* view, s32 arg1) { @@ -424,7 +430,7 @@ s32 func_800AAA9C(View* view) { view->projection = *projection; - func_800AA890(view, projection); + View_StepDistortion(view, projection); gSPPerspNormalize(POLY_OPA_DISP++, view->normal); gSPMatrix(POLY_OPA_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); |
