From 9675051377c95b95119c6f15c65b648c2f01726a Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 15 Oct 2022 02:16:37 -0400 Subject: [PATCH] Quake Documentation Pass (#1402) * begin quake docs * continue cleanup * quake offset * many more docs * cleanup * more cleanup * cleanup headers * move quake value to internal * update, still need to test shake zoom/yaw * more docs * better docs * add file descriptions * fix comment * explain random index * cleanup comments * better type 6 docs * expand orientation comment * fix old names, add comment * remove comment, twas a mistake * easy PR feedback * duration in dec * rm offset, clear up roll * oops * merge shakeInfo and QuakeCamData * match order that always appears in code * more PR suggestions * adjust comment * zeroVec * rm extra space * roman PR suggestions --- include/functions.h | 32 +- include/quake.h | 44 ++ include/z64.h | 40 -- include/z64actor.h | 2 +- include/z64camera.h | 6 +- src/code/z_actor.c | 36 +- src/code/z_camera.c | 89 +-- src/code/z_demo.c | 9 +- src/code/z_onepointdemo.c | 115 ++-- src/code/z_play.c | 9 +- src/code/z_quake.c | 615 ++++++++++-------- src/code/z_room.c | 4 +- src/code/z_scene_table.c | 19 +- .../ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c | 11 +- .../actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c | 7 +- .../actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c | 2 +- .../ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c | 2 +- .../actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c | 7 +- .../ovl_Bg_Heavy_Block/z_bg_heavy_block.c | 37 +- .../ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.c | 13 +- .../ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c | 12 +- .../ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c | 12 +- .../z_bg_mori_rakkatenjo.c | 12 +- .../actors/ovl_Bg_Po_Event/z_bg_po_event.c | 2 +- .../ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c | 13 +- .../actors/ovl_Boss_Dodongo/z_boss_dodongo.c | 12 +- src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c | 8 +- src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c | 2 +- .../actors/ovl_Boss_Ganon/z_boss_ganon.c | 2 +- .../actors/ovl_Boss_Ganon2/z_boss_ganon2.c | 4 +- .../actors/ovl_Boss_Goma/z_boss_goma.c | 8 +- src/overlays/actors/ovl_Boss_Va/z_boss_va.c | 2 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 25 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 2 +- src/overlays/actors/ovl_En_Bili/z_en_bili.c | 2 +- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 2 +- src/overlays/actors/ovl_En_Bombf/z_en_bombf.c | 2 +- src/overlays/actors/ovl_En_Crow/z_en_crow.c | 2 +- src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c | 4 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 9 +- .../actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c | 2 +- .../actors/ovl_En_Fire_Rock/z_en_fire_rock.c | 2 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 2 +- src/overlays/actors/ovl_En_Go2/z_en_go2.c | 11 +- src/overlays/actors/ovl_En_Goma/z_en_goma.c | 2 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 11 +- src/overlays/actors/ovl_En_Ik/z_en_ik.c | 2 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 12 +- src/overlays/actors/ovl_En_Mb/z_en_mb.c | 6 +- .../actors/ovl_En_Po_Desert/z_en_po_desert.c | 2 +- .../actors/ovl_En_Po_Field/z_en_po_field.c | 2 +- .../actors/ovl_En_Po_Relay/z_en_po_relay.c | 2 +- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 2 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 2 +- src/overlays/actors/ovl_En_Vali/z_en_vali.c | 2 +- .../actors/ovl_En_Vb_Ball/z_en_vb_ball.c | 2 +- .../actors/ovl_En_Wall_Tubo/z_en_wall_tubo.c | 7 +- .../actors/ovl_En_Yukabyun/z_en_yukabyun.c | 2 +- src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c | 7 +- .../actors/ovl_Oceff_Wipe/z_oceff_wipe.c | 6 +- .../actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c | 6 +- .../actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c | 6 +- .../actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c | 6 +- .../actors/ovl_player_actor/z_player.c | 17 +- 64 files changed, 737 insertions(+), 620 deletions(-) create mode 100644 include/quake.h diff --git a/include/functions.h b/include/functions.h index b415ae6d14..318cc59559 100644 --- a/include/functions.h +++ b/include/functions.h @@ -488,9 +488,9 @@ s32 Actor_IsTargeted(PlayState* play, Actor* actor); s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor); f32 func_80033AEC(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5); void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play); -void func_80033DB8(PlayState* play, s16 arg1, s16 arg2); -void func_80033E1C(PlayState* play, s16 arg1, s16 arg2, s16 arg3); -void func_80033E88(Actor* actor, PlayState* play, s16 arg2, s16 arg3); +void Actor_RequestQuake(PlayState* play, s16 y, s16 duration); +void Actor_RequestQuakeWithSpeed(PlayState* play, s16 y, s16 duration, s16 speed); +void Actor_RequestQuakeAndRumble(Actor* actor, PlayState* play, s16 quakeY, s16 quakeDuration); f32 Rand_ZeroFloat(f32 f); f32 Rand_CenteredFloat(f32 f); void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type); @@ -666,7 +666,7 @@ s16 Camera_GetInputDirYaw(Camera* camera); Vec3s* Camera_GetCamDir(Vec3s* dst, Camera* camera); s16 Camera_GetCamDirPitch(Camera* camera); s16 Camera_GetCamDirYaw(Camera* camera); -s32 Camera_AddQuake(Camera* camera, s32 arg1, s16 y, s32 countdown); +s32 Camera_RequestQuake(Camera* camera, s32 unused, s16 y, s32 duration); s32 Camera_SetParam(Camera* camera, s32 param, void* value); s32 func_8005AC48(Camera* camera, s16 arg1); s16 func_8005ACFC(Camera* camera, s16 arg1); @@ -677,7 +677,7 @@ s32 Camera_SetCSParams(Camera* camera, CutsceneCameraPoint* atPoints, CutsceneCa s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 arg3, s16 timer1, s16 timer2, s16 timer3); s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera); -Vec3f* Camera_GetSkyboxOffset(Vec3f* dst, Camera* camera); +Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera); void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, UNK_TYPE arg6); s32 func_8005B198(void); @@ -1059,28 +1059,6 @@ u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime); void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots); void PreNMI_Init(GameState* thisx); -Vec3f* Quake_AddVec(Vec3f* dst, Vec3f* arg1, VecSph* arg2); -void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x); -s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_GetFreeIndex(void); -QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx); -void Quake_Remove(QuakeRequest* req); -QuakeRequest* Quake_GetRequest(s16 idx); -QuakeRequest* Quake_SetValue(s16 idx, s16 valueType, s16 value); -u32 Quake_SetSpeed(s16 idx, s16 value); -u32 Quake_SetCountdown(s16 idx, s16 value); -s16 Quake_GetCountdown(s16 idx); -u32 Quake_SetQuakeValues(s16 idx, s16 y, s16 x, s16 zoom, s16 rotZ); -u32 Quake_SetUnkValues(s16 idx, s16 arg1, SubQuakeRequest14 arg2); -void Quake_Init(void); -s16 Quake_Add(Camera* camera, u32 callbackIdx); -u32 Quake_RemoveFromIdx(s16 idx); -s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData); Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); Gfx* Gfx_SetFogWithSync(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); Gfx* Gfx_SetFog2(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); diff --git a/include/quake.h b/include/quake.h new file mode 100644 index 0000000000..a9a33b5288 --- /dev/null +++ b/include/quake.h @@ -0,0 +1,44 @@ +#ifndef QUAKE_H +#define QUAKE_H + +#include "z64camera.h" +#include "z64math.h" + +typedef struct { + /* 0x00 */ Vec3f atOffset; + /* 0x0C */ Vec3f eyeOffset; + /* 0x18 */ s16 upPitchOffset; // gives a "roll" effect by offsetting the Up vector + /* 0x1A */ s16 upYawOffset; // gives a "roll" effect by offsetting the Up vector + /* 0x1C */ s16 fovOffset; // binary angle + /* 0x20 */ f32 maxOffset; +} ShakeInfo; // size = 0x24 + +typedef enum { + /* 0 */ QUAKE_TYPE_NONE, + /* 1 */ QUAKE_TYPE_1, // Periodic, sustaining, random X perturbations + /* 2 */ QUAKE_TYPE_2, // Aperiodic, sustaining, random X perturbations + /* 3 */ QUAKE_TYPE_3, // Periodic, decaying + /* 4 */ QUAKE_TYPE_4, // Aperiodic, decaying, random X perturbations + /* 5 */ QUAKE_TYPE_5, // Periodic, sustaining + /* 6 */ QUAKE_TYPE_6 // See below +} QuakeType; + +// Quake type 6 is Jump-Periodic, sustaining, random X perturbations, +// resets period every 16 frames (jumps, similar to sawtooth), +// continues indefinitely i.e. does not terminate when the timer reaches 0 +// must be manually removed + +s16 Quake_Request(Camera* camera, u32 type); + +u32 Quake_SetSpeed(s16 index, s16 speed); +u32 Quake_SetPerturbations(s16 index, s16 y, s16 x, s16 fov, s16 roll); +u32 Quake_SetDuration(s16 index, s16 duration); +u32 Quake_SetOrientation(s16 index, s16 isRelativeToScreen, Vec3s orientation); + +s16 Quake_GetTimeLeft(s16 index); +u32 Quake_RemoveRequest(s16 index); + +void Quake_Init(void); +s16 Quake_Update(Camera* camera, ShakeInfo* camShake); + +#endif diff --git a/include/z64.h b/include/z64.h index a90b246551..d351794d1b 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1617,46 +1617,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } PreNmiBuff; // size = 0x18 (actually osAppNMIBuffer is 0x40 bytes large but the rest is unused) -typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; - /* 0x04 */ s16 unk_04; -} SubQuakeRequest14; - -typedef struct { - /* 0x00 */ s16 randIdx; - /* 0x02 */ s16 countdownMax; - /* 0x04 */ Camera* cam; - /* 0x08 */ u32 callbackIdx; - /* 0x0C */ s16 y; - /* 0x0E */ s16 x; - /* 0x10 */ s16 zoom; - /* 0x12 */ s16 rotZ; - /* 0x14 */ SubQuakeRequest14 unk_14; - /* 0x1A */ s16 speed; - /* 0x1C */ s16 unk_1C; - /* 0x1E */ s16 countdown; - /* 0x20 */ s16 camPtrIdx; -} QuakeRequest; // size = 0x24 - -typedef struct { - /* 0x00 */ Vec3f vec1; - /* 0x0C */ Vec3f vec2; - /* 0x18 */ s16 rotZ; - /* 0x1A */ s16 unk_1A; - /* 0x1C */ s16 zoom; -} ShakeInfo; // size = 0x1E - -typedef struct { - /* 0x00 */ Vec3f atOffset; - /* 0x0C */ Vec3f eyeOffset; - /* 0x18 */ s16 rotZ; - /* 0x1A */ s16 unk_1A; - /* 0x1C */ s16 zoom; - /* 0x20 */ f32 unk_20; -} QuakeCamCalc; // size = 0x24 - - #define UCODE_NULL 0 #define UCODE_F3DZEX 1 #define UCODE_UNK 2 diff --git a/include/z64actor.h b/include/z64actor.h index e717fdfa10..7088919f44 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -151,7 +151,7 @@ typedef struct { #define ACTOR_FLAG_9 (1 << 9) #define ACTOR_FLAG_10 (1 << 10) #define ACTOR_FLAG_ENKUSA_CUT (1 << 11) -#define ACTOR_FLAG_12 (1 << 12) +#define ACTOR_FLAG_IGNORE_QUAKE (1 << 12) // actor will not shake when a quake occurs #define ACTOR_FLAG_13 (1 << 13) #define ACTOR_FLAG_14 (1 << 14) #define ACTOR_FLAG_15 (1 << 15) diff --git a/include/z64camera.h b/include/z64camera.h index a5402d2245..aa8e01c4a2 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -1348,13 +1348,13 @@ typedef struct { /* 0x24 */ s32 bgId; } CamColChk; // size = 0x28 -typedef struct { +typedef struct Camera { /* 0x000 */ CamParamData paramData; /* 0x050 */ Vec3f at; /* 0x05C */ Vec3f eye; /* 0x068 */ Vec3f up; /* 0x074 */ Vec3f eyeNext; - /* 0x080 */ Vec3f skyboxOffset; + /* 0x080 */ Vec3f quakeOffset; /* 0x08C */ struct PlayState* play; /* 0x090 */ struct Player* player; /* 0x094 */ PosRot playerPosRot; @@ -1378,7 +1378,7 @@ typedef struct { /* 0x114 */ f32 waterYPos; /* 0x118 */ s32 bgCamIndexBeforeUnderwater; /* 0x11C */ s32 waterCamSetting; - /* 0x120 */ s32 waterQuakeId; + /* 0x120 */ s32 waterQuakeIndex; /* 0x124 */ void* data0; /* 0x128 */ void* data1; /* 0x12C */ s16 data2; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index d026eff6d7..b14f32a84d 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1,4 +1,5 @@ #include "global.h" +#include "quake.h" #include "vt.h" #include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h" @@ -2179,11 +2180,11 @@ void Actor_Draw(PlayState* play, Actor* actor) { Lights_BindAll(lights, play->lightCtx.listHead, (actor->flags & ACTOR_FLAG_22) ? NULL : &actor->world.pos); Lights_Draw(lights, play->state.gfxCtx); - if (actor->flags & ACTOR_FLAG_12) { - Matrix_SetTranslateRotateYXZ(actor->world.pos.x + play->mainCamera.skyboxOffset.x, + if (actor->flags & ACTOR_FLAG_IGNORE_QUAKE) { + Matrix_SetTranslateRotateYXZ(actor->world.pos.x + play->mainCamera.quakeOffset.x, actor->world.pos.y + - ((actor->shape.yOffset * actor->scale.y) + play->mainCamera.skyboxOffset.y), - actor->world.pos.z + play->mainCamera.skyboxOffset.z, &actor->shape.rot); + ((actor->shape.yOffset * actor->scale.y) + play->mainCamera.quakeOffset.y), + actor->world.pos.z + play->mainCamera.quakeOffset.z, &actor->shape.rot); } else { Matrix_SetTranslateRotateYXZ(actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), actor->world.pos.z, &actor->shape.rot); @@ -3505,30 +3506,29 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 8155); } -void func_80033DB8(PlayState* play, s16 arg1, s16 arg2) { - s16 var = Quake_Add(&play->mainCamera, 3); +void Actor_RequestQuake(PlayState* play, s16 y, s16 duration) { + s16 quakeIndex = Quake_Request(&play->mainCamera, QUAKE_TYPE_3); - Quake_SetSpeed(var, 20000); - Quake_SetQuakeValues(var, arg1, 0, 0, 0); - Quake_SetCountdown(var, arg2); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetPerturbations(quakeIndex, y, 0, 0, 0); + Quake_SetDuration(quakeIndex, duration); } -void func_80033E1C(PlayState* play, s16 arg1, s16 arg2, s16 arg3) { - s16 var = Quake_Add(&play->mainCamera, 3); +void Actor_RequestQuakeWithSpeed(PlayState* play, s16 y, s16 duration, s16 speed) { + s16 quakeIndex = Quake_Request(&play->mainCamera, QUAKE_TYPE_3); - Quake_SetSpeed(var, arg3); - Quake_SetQuakeValues(var, arg1, 0, 0, 0); - Quake_SetCountdown(var, arg2); + Quake_SetSpeed(quakeIndex, speed); + Quake_SetPerturbations(quakeIndex, y, 0, 0, 0); + Quake_SetDuration(quakeIndex, duration); } -void func_80033E88(Actor* actor, PlayState* play, s16 arg2, s16 arg3) { - if (arg2 >= 5) { +void Actor_RequestQuakeAndRumble(Actor* actor, PlayState* play, s16 quakeY, s16 quakeDuration) { + if (quakeY >= 5) { Rumble_Request(actor->xyzDistToPlayerSq, 255, 20, 150); } else { Rumble_Request(actor->xyzDistToPlayerSq, 180, 20, 100); } - - func_80033DB8(play, arg2, arg3); + Actor_RequestQuake(play, quakeY, quakeDuration); } f32 Rand_ZeroFloat(f32 f) { diff --git a/src/code/z_camera.c b/src/code/z_camera.c index c9477d147b..815be7475a 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -1,5 +1,6 @@ #include "ultra64.h" #include "global.h" +#include "quake.h" #include "vt.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" @@ -6972,7 +6973,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState camera->up.y = 1.0f; camera->up.z = camera->up.x = 0.0f; - camera->skyboxOffset.x = camera->skyboxOffset.y = camera->skyboxOffset.z = 0; + camera->quakeOffset.x = camera->quakeOffset.y = camera->quakeOffset.z = 0; camera->atLERPStepScale = 1; sCameraInterfaceFlags = 0xFF00; sDbgModeIdx = -1; @@ -7185,11 +7186,11 @@ void Camera_PrintSettings(Camera* camera) { s32 Camera_UpdateWater(Camera* camera) { f32 waterY; - s16 newQuakeId; + s16 quakeIndex; s32 waterLightsIndex; s32* waterCamSetting = &camera->waterCamSetting; s16 waterBgCamIndex; - s16* quakeId = (s16*)&camera->waterQuakeId; + s16* waterQuakeIndex = (s16*)&camera->waterQuakeIndex; Player* player = camera->player; s16 prevBgId; @@ -7213,7 +7214,7 @@ s32 Camera_UpdateWater(Camera* camera) { camera->unk_14C |= 0x200; camera->waterYPos = waterY; camera->bgCamIndexBeforeUnderwater = camera->bgCamIndex; - *quakeId = -1; + *waterQuakeIndex = -1; } if (camera->playerGroundY != camera->playerPosRot.pos.y) { prevBgId = camera->bgId; @@ -7229,7 +7230,7 @@ s32 Camera_UpdateWater(Camera* camera) { camera->unk_14C |= 0x200; camera->waterYPos = waterY; camera->bgCamIndexBeforeUnderwater = camera->bgCamIndex; - *quakeId = -1; + *waterQuakeIndex = -1; } if (camera->playerGroundY != camera->playerPosRot.pos.y) { prevBgId = camera->bgId; @@ -7266,16 +7267,19 @@ s32 Camera_UpdateWater(Camera* camera) { Audio_SetExtraFilter(0x20); if (PREG(81)) { - Quake_RemoveFromIdx(*quakeId); - *quakeId = -1; + Quake_RemoveRequest(*waterQuakeIndex); + *waterQuakeIndex = -1; PREG(81) = 0; } - if ((*quakeId == -1) || (Quake_GetCountdown(*quakeId) == 0xA)) { - if (*quakeId = newQuakeId = Quake_Add(camera, 5U), newQuakeId != 0) { - Quake_SetSpeed(*quakeId, 550); - Quake_SetQuakeValues(*quakeId, 1, 1, 180, 0); - Quake_SetCountdown(*quakeId, 1000); + if ((*waterQuakeIndex == -1) || (Quake_GetTimeLeft(*waterQuakeIndex) == 10)) { + quakeIndex = Quake_Request(camera, QUAKE_TYPE_5); + + *waterQuakeIndex = quakeIndex; + if (quakeIndex != 0) { + Quake_SetSpeed(*waterQuakeIndex, 550); + Quake_SetPerturbations(*waterQuakeIndex, 1, 1, 180, 0); + Quake_SetDuration(*waterQuakeIndex, 1000); } } @@ -7292,8 +7296,8 @@ s32 Camera_UpdateWater(Camera* camera) { camera->unk_14C &= ~0x100; osSyncPrintf("kankyo changed water off, sound off\n"); Environment_DisableUnderwaterLights(camera->play); - if (*quakeId != 0) { - Quake_RemoveFromIdx(*quakeId); + if (*waterQuakeIndex != 0) { + Quake_RemoveRequest(*waterQuakeIndex); } camera->waterDistortionTimer = 0; camera->distortionFlags = 0; @@ -7438,8 +7442,9 @@ Vec3s Camera_Update(Camera* camera) { f32 playerXZSpeed; VecSph eyeAtAngle; s16 bgCamIndex; + s16 numQuakesApplied; PosRot curPlayerPosRot; - QuakeCamCalc quake; + ShakeInfo camShake; Player* player; player = camera->play->cameraPtrs[CAM_ID_MAIN]->player; @@ -7602,19 +7607,23 @@ Vec3s Camera_Update(Camera* camera) { return camera->inputDir; } - // setting bgId to the ret of Quake_Calc, and checking that - // is required, it doesn't make too much sense though. - if ((bgId = Quake_Calc(camera, &quake), bgId != 0) && (camera->setting != CAM_SET_TURN_AROUND)) { - viewAt.x = camera->at.x + quake.atOffset.x; - viewAt.y = camera->at.y + quake.atOffset.y; - viewAt.z = camera->at.z + quake.atOffset.z; - viewEye.x = camera->eye.x + quake.eyeOffset.x; - viewEye.y = camera->eye.y + quake.eyeOffset.y; - viewEye.z = camera->eye.z + quake.eyeOffset.z; + numQuakesApplied = Quake_Update(camera, &camShake); + + bgId = numQuakesApplied; // required to match + + if ((numQuakesApplied != 0) && (camera->setting != CAM_SET_TURN_AROUND)) { + viewAt.x = camera->at.x + camShake.atOffset.x; + viewAt.y = camera->at.y + camShake.atOffset.y; + viewAt.z = camera->at.z + camShake.atOffset.z; + + viewEye.x = camera->eye.x + camShake.eyeOffset.x; + viewEye.y = camera->eye.y + camShake.eyeOffset.y; + viewEye.z = camera->eye.z + camShake.eyeOffset.z; + OLib_Vec3fDiffToVecSphGeo(&eyeAtAngle, &viewEye, &viewAt); - Camera_CalcUpFromPitchYawRoll(&viewUp, eyeAtAngle.pitch + quake.rotZ, eyeAtAngle.yaw + quake.unk_1A, - camera->roll); - viewFov = camera->fov + CAM_BINANG_TO_DEG(quake.zoom); + Camera_CalcUpFromPitchYawRoll(&viewUp, eyeAtAngle.pitch + camShake.upPitchOffset, + eyeAtAngle.yaw + camShake.upYawOffset, camera->roll); + viewFov = camera->fov + CAM_BINANG_TO_DEG(camShake.fovOffset); } else { viewAt = camera->at; viewEye = camera->eye; @@ -7630,7 +7639,7 @@ Vec3s Camera_Update(Camera* camera) { camera->up = viewUp; } - camera->skyboxOffset = quake.eyeOffset; + camera->quakeOffset = camShake.eyeOffset; Camera_UpdateDistortion(camera); @@ -8010,17 +8019,17 @@ s16 Camera_GetCamDirYaw(Camera* camera) { return camDir.y; } -s32 Camera_AddQuake(Camera* camera, s32 arg1, s16 y, s32 countdown) { - s16 quakeIdx; +s32 Camera_RequestQuake(Camera* camera, s32 unused, s16 y, s32 duration) { + s16 quakeIndex; - quakeIdx = Quake_Add(camera, 3); - if (quakeIdx == 0) { - return 0; + quakeIndex = Quake_Request(camera, QUAKE_TYPE_3); + if (quakeIndex == 0) { + return false; } - Quake_SetSpeed(quakeIdx, 0x61A8); - Quake_SetQuakeValues(quakeIdx, y, 0, 0, 0); - Quake_SetCountdown(quakeIdx, countdown); - return 1; + Quake_SetSpeed(quakeIndex, 0x61A8); + Quake_SetPerturbations(quakeIndex, y, 0, 0, 0); + Quake_SetDuration(quakeIndex, duration); + return true; } s32 Camera_SetParam(Camera* camera, s32 param, void* value) { @@ -8187,9 +8196,9 @@ s32 Camera_GetDbgCamEnabled(void) { return gDbgCamEnabled; } -Vec3f* Camera_GetSkyboxOffset(Vec3f* dst, Camera* camera) { - *dst = camera->skyboxOffset; - return dst; +Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera) { + *quakeOffset = camera->quakeOffset; + return quakeOffset; } void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 9af0c6f930..b7c178ee6f 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,4 +1,5 @@ #include "global.h" +#include "quake.h" #include "z64camera.h" #include "assets/scenes/indoors/tokinoma/tokinoma_scene.h" @@ -311,15 +312,15 @@ void func_80064824(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { break; case 16: if (sp3F != 0) { - sQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); + sQuakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sQuakeIndex, 0x7FFF); - Quake_SetQuakeValues(sQuakeIndex, 4, 0, 1000, 0); - Quake_SetCountdown(sQuakeIndex, 800); + Quake_SetPerturbations(sQuakeIndex, 4, 0, 1000, 0); + Quake_SetDuration(sQuakeIndex, 800); } break; case 17: if (sp3F != 0) { - Quake_RemoveFromIdx(sQuakeIndex); + Quake_RemoveRequest(sQuakeIndex); } break; case 18: diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index e28448f3b3..9d62b8910f 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -1,4 +1,5 @@ #include "global.h" +#include "quake.h" #include "vt.h" #include "overlays/actors/ovl_En_Sw/z_en_sw.h" @@ -156,10 +157,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act ((mainCam->play->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 5); + i = Quake_Request(subCam, QUAKE_TYPE_5); Quake_SetSpeed(i, 400); - Quake_SetQuakeValues(i, 4, 5, 40, 0x3C); - Quake_SetCountdown(i, 1600); + Quake_SetPerturbations(i, 4, 5, 40, 0x3C); + Quake_SetDuration(i, 1600); break; case 2280: csInfo->keyFrames = D_80120D4C; @@ -177,10 +178,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act ((mainCam->play->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 5); + i = Quake_Request(subCam, QUAKE_TYPE_5); Quake_SetSpeed(i, 400); - Quake_SetQuakeValues(i, 2, 3, 200, 0x32); - Quake_SetCountdown(i, 9999); + Quake_SetPerturbations(i, 2, 3, 200, 0x32); + Quake_SetDuration(i, 9999); break; case 2220: csInfo->keyFrames = D_80120E64; @@ -188,10 +189,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 5); + i = Quake_Request(subCam, QUAKE_TYPE_5); Quake_SetSpeed(i, 400); - Quake_SetQuakeValues(i, 2, 2, 50, 0); - Quake_SetCountdown(i, 280); + Quake_SetPerturbations(i, 2, 2, 50, 0); + Quake_SetDuration(i, 280); break; case 2230: if (player->actor.world.pos.z < 1000.0f) { @@ -210,10 +211,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 5); + i = Quake_Request(subCam, QUAKE_TYPE_5); Quake_SetSpeed(i, 400); - Quake_SetQuakeValues(i, 2, 2, 50, 0); - Quake_SetCountdown(i, 60); + Quake_SetPerturbations(i, 2, 2, 50, 0); + Quake_SetDuration(i, 60); break; case 2350: csInfo->keyFrames = D_8012110C; @@ -397,10 +398,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 3); + i = Quake_Request(subCam, QUAKE_TYPE_3); Quake_SetSpeed(i, 22000); - Quake_SetQuakeValues(i, 2, 0, 200, 0); - Quake_SetCountdown(i, 10); + Quake_SetPerturbations(i, 2, 0, 200, 0); + Quake_SetDuration(i, 10); break; case 3080: csInfo->keyFrames = D_80121774; @@ -435,10 +436,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_8002DF54(play, NULL, 8); func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 1); + i = Quake_Request(subCam, QUAKE_TYPE_1); Quake_SetSpeed(i, 24000); - Quake_SetQuakeValues(i, 2, 0, 0, 0); - Quake_SetCountdown(i, 160); + Quake_SetPerturbations(i, 2, 0, 0, 0); + Quake_SetDuration(i, 160); break; case 3060: csInfo->keyFrames = D_80121904; @@ -467,10 +468,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act D_8012021C[D_801202FC - 3].pos.z += (D_8012021C[D_801202FC - 2].pos.z - D_8012021C[D_801202FC - 3].pos.z) / 2; - i = Quake_Add(mainCam, 3); + i = Quake_Request(mainCam, QUAKE_TYPE_3); Quake_SetSpeed(i, 30000); - Quake_SetQuakeValues(i, 2, 1, 1, 0); - Quake_SetCountdown(i, 200); + Quake_SetPerturbations(i, 2, 1, 1, 0); + Quake_SetDuration(i, 200); break; case 3120: csInfo->keyFrames = D_80121954[-(timer + 101)]; @@ -583,10 +584,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); Play_CameraSetAtEye(play, CAM_ID_MAIN, &spC0, &spB4); - i = Quake_Add(subCam, 3); + i = Quake_Request(subCam, QUAKE_TYPE_3); Quake_SetSpeed(i, 22000); - Quake_SetQuakeValues(i, 1, 0, 0, 0); - Quake_SetCountdown(i, 90); + Quake_SetPerturbations(i, 1, 0, 0, 0); + Quake_SetDuration(i, 90); break; case 6010: Actor_GetWorld(&spA0, actor); @@ -637,10 +638,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act OnePointCutscene_SetCsCamPoints(subCam, D_801208E8, D_801208E4, D_801206A0, D_80120760); } - i = Quake_Add(subCam, 1); + i = Quake_Request(subCam, QUAKE_TYPE_1); Quake_SetSpeed(i, 32000); - Quake_SetQuakeValues(i, 0, 0, 20, 0); - Quake_SetCountdown(i, D_801208E4 - 10); + Quake_SetPerturbations(i, 0, 0, 20, 0); + Quake_SetDuration(i, D_801208E4 - 10); break; case 3400: Play_CameraChangeSetting(play, subCamId, CAM_SET_CS_3); @@ -649,10 +650,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act OnePointCutscene_Vec3sToVec3f(&mainCam->eye, &D_801205B4[D_80120694 - 2].pos); OnePointCutscene_Vec3sToVec3f(&mainCam->at, &D_801204D4[D_80120694 - 2].pos); - i = Quake_Add(subCam, 1); + i = Quake_Request(subCam, QUAKE_TYPE_1); Quake_SetSpeed(i, 0x4E20); - Quake_SetQuakeValues(i, 1, 0, 50, 0); - Quake_SetCountdown(i, D_80120698 - 20); + Quake_SetPerturbations(i, 1, 0, 50, 0); + Quake_SetDuration(i, D_80120698 - 20); break; case 3390: player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = -0x3FD9; @@ -668,10 +669,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_8002DF54(play, NULL, 8); Play_CopyCamera(play, subCamId, CAM_ID_MAIN); - i = Quake_Add(subCam, 1); + i = Quake_Request(subCam, QUAKE_TYPE_1); Quake_SetSpeed(i, 32000); - Quake_SetQuakeValues(i, 2, 0, 0, 0); - Quake_SetCountdown(i, timer); + Quake_SetPerturbations(i, 2, 0, 0, 0); + Quake_SetDuration(i, timer); break; case 3290: D_80121F1C[0].atTargetInit = play->view.at; @@ -685,10 +686,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 3); + i = Quake_Request(subCam, QUAKE_TYPE_3); Quake_SetSpeed(i, 12000); - Quake_SetQuakeValues(i, 0, 0, 1000, 0); - Quake_SetCountdown(i, 5); + Quake_SetPerturbations(i, 0, 0, 1000, 0); + Quake_SetDuration(i, 5); break; case 3340: D_80121FBC[0].atTargetInit = play->view.at; @@ -701,10 +702,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_8002DF54(play, NULL, 8); func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 3); + i = Quake_Request(subCam, QUAKE_TYPE_3); Quake_SetSpeed(i, 12000); - Quake_SetQuakeValues(i, 0, 0, 1000, 0); - Quake_SetCountdown(i, 5); + Quake_SetPerturbations(i, 0, 0, 1000, 0); + Quake_SetDuration(i, 5); break; case 3360: csInfo->keyFrames = D_8012205C; @@ -746,10 +747,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_8002DF54(play, NULL, 8); func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 1); + i = Quake_Request(subCam, QUAKE_TYPE_1); Quake_SetSpeed(i, 32000); - Quake_SetQuakeValues(i, 4, 0, 0, 0); - Quake_SetCountdown(i, 20); + Quake_SetPerturbations(i, 4, 0, 0, 0); + Quake_SetDuration(i, 20); break; case 3450: csInfo->keyFrames = D_8012237C; @@ -758,10 +759,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_8002DF38(play, &player->actor, 8); func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 1); + i = Quake_Request(subCam, QUAKE_TYPE_1); Quake_SetSpeed(i, 32000); - Quake_SetQuakeValues(i, 2, 0, 0, 0); - Quake_SetCountdown(i, 10); + Quake_SetPerturbations(i, 2, 0, 0, 0); + Quake_SetDuration(i, 10); break; case 3440: csInfo->keyFrames = D_801223CC; @@ -772,10 +773,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act player->stateFlags1 |= PLAYER_STATE1_29; player->actor.freezeTimer = 90; - i = Quake_Add(subCam, 1); + i = Quake_Request(subCam, QUAKE_TYPE_1); Quake_SetSpeed(i, 32000); - Quake_SetQuakeValues(i, 2, 0, 0, 0); - Quake_SetCountdown(i, 10); + Quake_SetPerturbations(i, 2, 0, 0, 0); + Quake_SetDuration(i, 10); break; case 3430: csInfo->keyFrames = D_801224BC; @@ -784,10 +785,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_8002DF54(play, NULL, 8); func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 1); + i = Quake_Request(subCam, QUAKE_TYPE_1); Quake_SetSpeed(i, 32000); - Quake_SetQuakeValues(i, 1, 0, 10, 0); - Quake_SetCountdown(i, 20); + Quake_SetPerturbations(i, 1, 0, 10, 0); + Quake_SetDuration(i, 20); break; case 4100: csInfo->keyFrames = D_801225D4; @@ -867,10 +868,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_800C0808(play, subCamId, player, CAM_SET_CS_C); - i = Quake_Add(subCam, 3); + i = Quake_Request(subCam, QUAKE_TYPE_3); Quake_SetSpeed(i, 12000); - Quake_SetQuakeValues(i, 0, 1, 100, 0); - Quake_SetCountdown(i, timer - 80); + Quake_SetPerturbations(i, 0, 1, 100, 0); + Quake_SetDuration(i, timer - 80); break; case 4220: csInfo->keyFrames = (player->actor.world.pos.z < -15.0f) ? D_80122C3C : D_80122C64; @@ -879,10 +880,10 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act func_800C0808(play, subCamId, player, CAM_SET_CS_C); func_8002DF38(play, &player->actor, 1); - i = Quake_Add(subCam, 3); + i = Quake_Request(subCam, QUAKE_TYPE_3); Quake_SetSpeed(i, 12000); - Quake_SetQuakeValues(i, 0, 1, 10, 0); - Quake_SetCountdown(i, timer - 10); + Quake_SetPerturbations(i, 0, 1, 10, 0); + Quake_SetDuration(i, timer - 10); break; case 4221: csInfo->keyFrames = D_80122C8C; diff --git a/src/code/z_play.c b/src/code/z_play.c index 7d0fee621f..16948ad770 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1,4 +1,5 @@ #include "global.h" +#include "quake.h" #include "vt.h" void* D_8012D1F0 = NULL; @@ -1176,11 +1177,11 @@ void Play_Draw(PlayState* this) { if ((HREG(80) != 10) || (HREG(83) != 0)) { if ((this->skyboxCtx.unk_140 != 0) && (GET_ACTIVE_CAM(this)->setting != CAM_SET_PREREND_FIXED)) { - Vec3f sp74; + Vec3f quakeOffset; - Camera_GetSkyboxOffset(&sp74, GET_ACTIVE_CAM(this)); - SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + sp74.x, - this->view.eye.y + sp74.y, this->view.eye.z + sp74.z); + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(this)); + SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + quakeOffset.x, + this->view.eye.y + quakeOffset.y, this->view.eye.z + quakeOffset.z); } } diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 02fb8e63d4..d2538b5ddd 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -1,280 +1,362 @@ #include "global.h" +#include "quake.h" #include "vt.h" -QuakeRequest sQuakeRequest[4]; -s16 D_80126250 = 1; +typedef struct { + /* 0x00 */ s16 index; + /* 0x02 */ s16 duration; + /* 0x04 */ Camera* cam; + /* 0x08 */ u32 type; + /* 0x0C */ s16 y; + /* 0x0E */ s16 x; + /* 0x10 */ s16 fov; + /* 0x12 */ s16 upPitchOffset; + /* 0x14 */ Vec3s orientation; // alters the orientation of the xy perturbation. Only x (pitch) and y (yaw) are used + /* 0x1A */ s16 speed; + /* 0x1C */ s16 isRelativeToScreen; // is the quake relative to the screen or on world coordinates + /* 0x1E */ s16 timer; + /* 0x20 */ s16 camId; +} QuakeRequest; // size = 0x24 + +QuakeRequest sQuakeRequests[4]; +s16 sQuakeUnused = 1; s16 sQuakeRequestCount = 0; -s16 (*sQuakeCallbacks[])(QuakeRequest*, ShakeInfo*) = { - NULL, Quake_Callback1, Quake_Callback2, Quake_Callback3, Quake_Callback4, Quake_Callback5, Quake_Callback6, -}; +Vec3f* Quake_VecSphGeoAddToVec3f(Vec3f* dst, Vec3f* a, VecSph* sph) { + Vec3f vec; + Vec3f b; -Vec3f* Quake_AddVec(Vec3f* dst, Vec3f* arg1, VecSph* arg2) { - Vec3f vec1; - Vec3f vec2; + OLib_VecSphGeoToVec3f(&b, sph); + vec.x = a->x + b.x; + vec.y = a->y + b.y; + vec.z = a->z + b.z; + + *dst = vec; - OLib_VecSphGeoToVec3f(&vec2, arg2); - vec1.x = arg1->x + vec2.x; - vec1.y = arg1->y + vec2.y; - vec1.z = arg1->z + vec2.z; - *dst = vec1; return dst; } void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x) { - Vec3f* unk50 = &req->cam->at; - Vec3f* unk5C = &req->cam->eye; + Vec3f* at = &req->cam->at; + Vec3f* eye = &req->cam->eye; + Vec3f offset; + VecSph sph; + VecSph eyeToAtSph; - Vec3f vec; - VecSph struc2; - VecSph struc1; - Vec3f vec2; + if (req->isRelativeToScreen) { + offset.x = 0; + offset.y = 0; + offset.z = 0; + OLib_Vec3fDiffToVecSphGeo(&eyeToAtSph, eye, at); - if (req->unk_1C) { - vec.x = 0; - vec.y = 0; - vec.z = 0; - OLib_Vec3fDiffToVecSphGeo(&struc1, unk5C, unk50); - struc2.r = req->y * y; - struc2.pitch = struc1.pitch + req->unk_14.unk_00 + 0x4000; - struc2.yaw = struc1.yaw + req->unk_14.unk_02; - Quake_AddVec(&vec, &vec, &struc2); - struc2.r = req->x * x; - struc2.pitch = struc1.pitch + req->unk_14.unk_00; - struc2.yaw = struc1.yaw + req->unk_14.unk_02 + 0x4000; - Quake_AddVec(&vec, &vec, &struc2); + // y shake + sph.r = req->y * y; + // point unit vector up, then add on `req->orientation` + sph.pitch = eyeToAtSph.pitch + req->orientation.x + 0x4000; + sph.yaw = eyeToAtSph.yaw + req->orientation.y; + // apply y shake + Quake_VecSphGeoAddToVec3f(&offset, &offset, &sph); + + // x shake + sph.r = req->x * x; + // point unit vector left, then add on `req->orientation` + sph.pitch = eyeToAtSph.pitch + req->orientation.x; + sph.yaw = eyeToAtSph.yaw + req->orientation.y + 0x4000; + // apply x shake + Quake_VecSphGeoAddToVec3f(&offset, &offset, &sph); } else { - vec.x = 0; - vec.y = req->y * y; - vec.z = 0; - struc2.r = req->x * x; - struc2.pitch = req->unk_14.unk_00; - struc2.yaw = req->unk_14.unk_02; - Quake_AddVec(&vec, &vec, &struc2); + offset.x = 0; + offset.y = req->y * y; + offset.z = 0; + sph.r = req->x * x; + sph.pitch = req->orientation.x; + sph.yaw = req->orientation.y; + Quake_VecSphGeoAddToVec3f(&offset, &offset, &sph); } - vec2 = vec; - shake->vec2 = vec2; - shake->vec1 = vec2; - shake->unk_1A = (f32)0x8000 * y; - shake->rotZ = req->rotZ * y; - shake->zoom = req->zoom * y; + shake->atOffset = shake->eyeOffset = offset; + shake->upYawOffset = 0x8000 * y; + shake->upPitchOffset = req->upPitchOffset * y; + shake->fovOffset = req->fov * y; } -s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType1(QuakeRequest* req, ShakeInfo* shake) { s32 pad; - if (req->countdown > 0) { - f32 a = Math_SinS(req->speed * req->countdown); + if (req->timer > 0) { + f32 xyOffset = Math_SinS(req->speed * req->timer); - Quake_UpdateShakeInfo(req, shake, a, Rand_ZeroOne() * a); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } -s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) { - if (req->countdown > 0) { - f32 a = Math_SinS(req->speed * req->countdown); +s16 Quake_CallbackType5(QuakeRequest* req, ShakeInfo* shake) { + if (req->timer > 0) { + f32 xyOffset = Math_SinS(req->speed * req->timer); - Quake_UpdateShakeInfo(req, shake, a, a); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } -s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType6(QuakeRequest* req, ShakeInfo* shake) { s32 pad; - f32 a; + f32 xyOffset; - req->countdown--; - a = Math_SinS(req->speed * ((req->countdown & 0xF) + 500)); - Quake_UpdateShakeInfo(req, shake, a, Rand_ZeroOne() * a); + req->timer--; + xyOffset = Math_SinS(req->speed * ((req->timer & 0xF) + 500)); + Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset); + + // Not returning the timer ensures quake type 6 continues indefinitely until manually removed return 1; } -s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) { - if (req->countdown > 0) { - f32 a = Math_SinS(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax); +s16 Quake_CallbackType3(QuakeRequest* req, ShakeInfo* shake) { + if (req->timer > 0) { + f32 xyOffset = Math_SinS(req->speed * req->timer) * ((f32)req->timer / req->duration); - Quake_UpdateShakeInfo(req, shake, a, a); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } -s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) { - if (req->countdown > 0) { - f32 a = Rand_ZeroOne(); +s16 Quake_CallbackType2(QuakeRequest* req, ShakeInfo* shake) { + if (req->timer > 0) { + f32 xyOffset = Rand_ZeroOne(); - Quake_UpdateShakeInfo(req, shake, a, Rand_ZeroOne() * a); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } -s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake) { - if (req->countdown > 0) { - f32 a = Rand_ZeroOne() * ((f32)req->countdown / (f32)req->countdownMax); +s16 Quake_CallbackType4(QuakeRequest* req, ShakeInfo* shake) { + if (req->timer > 0) { + f32 xyOffset = Rand_ZeroOne() * ((f32)req->timer / req->duration); - Quake_UpdateShakeInfo(req, shake, a, Rand_ZeroOne() * a); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } s16 Quake_GetFreeIndex(void) { s32 i; - s32 ret; - s32 min = 0x10000; + s32 index; + s32 timerMin = 0x10000; // UINT16_MAX + 1 - for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - if (sQuakeRequest[i].callbackIdx == 0) { - ret = i; - min = 0x20000; + for (i = 0; i < ARRAY_COUNT(sQuakeRequests); i++) { + if (sQuakeRequests[i].type == QUAKE_TYPE_NONE) { + index = i; + timerMin = 0x20000; // Magic Number to indicate there was an unused quake index break; } - if (sQuakeRequest[i].countdown < min) { - min = sQuakeRequest[i].countdown; - ret = i; + if (timerMin > sQuakeRequests[i].timer) { + timerMin = sQuakeRequests[i].timer; + index = i; } } - if (min != 0x20000) { - osSyncPrintf(VT_COL(YELLOW, BLACK) "quake: too many request %d is changed new one !!\n" VT_RST, ret); + if (timerMin != 0x20000) { + osSyncPrintf(VT_COL(YELLOW, BLACK) "quake: too many request %d is changed new one !!\n" VT_RST, index); } - return ret; + return index; } -QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx) { - s16 idx = Quake_GetFreeIndex(); - QuakeRequest* req = &sQuakeRequest[idx]; +QuakeRequest* Quake_RequestImpl(Camera* camera, u32 type) { + s16 index = Quake_GetFreeIndex(); + QuakeRequest* req = &sQuakeRequests[index]; __osMemset(req, 0, sizeof(QuakeRequest)); + req->cam = camera; - req->camPtrIdx = camera->camId; - req->callbackIdx = callbackIdx; - req->unk_1C = 1; - req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx; + req->camId = camera->camId; + req->type = type; + req->isRelativeToScreen = true; + + // Add a unique random identifier to the upper bits of the index + // The `~3` assumes there are only 4 requests + req->index = index + ((s16)(Rand_ZeroOne() * 0x10000) & ~3); + sQuakeRequestCount++; return req; } void Quake_Remove(QuakeRequest* req) { - req->callbackIdx = 0; - req->countdown = -1; + req->type = QUAKE_TYPE_NONE; + req->timer = -1; sQuakeRequestCount--; } -QuakeRequest* Quake_GetRequest(s16 idx) { - QuakeRequest* req = &sQuakeRequest[idx & 3]; +QuakeRequest* Quake_GetRequest(s16 index) { + QuakeRequest* req = &sQuakeRequests[index & 3]; - if (req->callbackIdx == 0) { + if (req->type == QUAKE_TYPE_NONE) { return NULL; } - if (idx != req->randIdx) { + if (index != req->index) { return NULL; } return req; } -QuakeRequest* Quake_SetValue(s16 idx, s16 valueType, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +#define QUAKE_SPEED (1 << 0) +#define QUAKE_Y_OFFSET (1 << 1) +#define QUAKE_X_OFFSET (1 << 2) +#define QUAKE_FOV (1 << 3) +#define QUAKE_ROLL (1 << 4) +#define QUAKE_ORIENTATION_PITCH (1 << 5) +#define QUAKE_ORIENTATION_YAW (1 << 6) +#define QUAKE_ORIENTATION_ROLL (1 << 7) +#define QUAKE_DURATION (1 << 8) +#define QUAKE_IS_RELATIVE_TO_SCREEN (1 << 9) + +QuakeRequest* Quake_SetValue(s16 index, s16 valueType, s16 value) { + QuakeRequest* req = Quake_GetRequest(index); if (req == NULL) { return NULL; - } else { - switch (valueType) { - case 1: - req->speed = value; - break; - case 2: - req->y = value; - break; - case 4: - req->x = value; - break; - case 8: - req->zoom = value; - break; - case 0x10: - req->rotZ = value; - break; - case 0x20: - req->unk_14.unk_00 = value; - break; - case 0x40: - req->unk_14.unk_02 = value; - break; - case 0x80: - req->unk_14.unk_04 = value; - break; - case 0x100: - req->countdown = value; - req->countdownMax = req->countdown; - break; - case 0x200: - req->unk_1C = value; - break; - } } + + switch (valueType) { + case QUAKE_SPEED: + req->speed = value; + break; + + case QUAKE_Y_OFFSET: + req->y = value; + break; + + case QUAKE_X_OFFSET: + req->x = value; + break; + + case QUAKE_FOV: + req->fov = value; + break; + + case QUAKE_ROLL: + req->upPitchOffset = value; + break; + + case QUAKE_ORIENTATION_PITCH: + req->orientation.x = value; + break; + + case QUAKE_ORIENTATION_YAW: + req->orientation.y = value; + break; + + case QUAKE_ORIENTATION_ROLL: + req->orientation.z = value; + break; + + case QUAKE_DURATION: + req->timer = value; + req->duration = req->timer; + break; + + case QUAKE_IS_RELATIVE_TO_SCREEN: + req->isRelativeToScreen = value; + break; + + default: + break; + } + + //! @bug UB: missing return. "req" is in v0 at this point, but doing an + //! explicit return uses an additional register. +#ifdef AVOID_UB + return req; +#endif } -u32 Quake_SetSpeed(s16 idx, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +/** + * @param index + * @param speed For periodic types only, the angular frequency of the sine wave (binang / frame) + * @return true if successfully applied, false if the request does not exist + */ +u32 Quake_SetSpeed(s16 index, s16 speed) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - req->speed = value; + req->speed = speed; return true; } return false; } -u32 Quake_SetCountdown(s16 idx, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +/** + * @param index quake request index to apply + * @param duration Number of frames to apply the quake + * @return true if successfully applied, false if the request does not exist + */ +u32 Quake_SetDuration(s16 index, s16 duration) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - req->countdown = value; - req->countdownMax = req->countdown; + req->duration = req->timer = duration; return true; } return false; } -s16 Quake_GetCountdown(s16 idx) { - QuakeRequest* req = Quake_GetRequest(idx); +/** + * @param index quake request index to get + * @return Number of frames until the quake is finished + */ +s16 Quake_GetTimeLeft(s16 index) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - return req->countdown; + return req->timer; } return 0; } -u32 Quake_SetQuakeValues(s16 idx, s16 y, s16 x, s16 zoom, s16 rotZ) { - QuakeRequest* req = Quake_GetRequest(idx); +/** + * @param index quake request index to apply + * @param y Apply up/down shake + * @param x Apply left/right shake + * @param fov Apply zooming in/out shake (binang) + * @param roll Apply rolling shake (binang) + * @return true if successfully applied, false if the request does not exist + */ +u32 Quake_SetPerturbations(s16 index, s16 y, s16 x, s16 fov, s16 roll) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { req->y = y; req->x = x; - req->zoom = zoom; - req->rotZ = rotZ; + req->fov = fov; + // Visual roll is indirectly achieved by offsetting the pitch in calculating the camera "Up" vector + req->upPitchOffset = roll; return true; } return false; } -u32 Quake_SetUnkValues(s16 idx, s16 arg1, SubQuakeRequest14 arg2) { - QuakeRequest* req = Quake_GetRequest(idx); +/** + * @param index quake request index to apply + * @param isRelativeToScreen Is the quake applied relative to the screen or in absolute world coordinates + * @param orientation orient the x/y shake to a different direction + * @return true if successfully applied, false if the request does not exist + */ +u32 Quake_SetOrientation(s16 index, s16 isRelativeToScreen, Vec3s orientation) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - req->unk_1C = arg1; - - req->unk_14 = arg2; + req->isRelativeToScreen = isRelativeToScreen; + req->orientation = orientation; return true; } return false; @@ -283,20 +365,20 @@ u32 Quake_SetUnkValues(s16 idx, s16 arg1, SubQuakeRequest14 arg2) { void Quake_Init(void) { s16 i; - for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - sQuakeRequest[i].callbackIdx = 0; - sQuakeRequest[i].countdown = 0; + for (i = 0; i < ARRAY_COUNT(sQuakeRequests); i++) { + sQuakeRequests[i].type = QUAKE_TYPE_NONE; + sQuakeRequests[i].timer = 0; } - D_80126250 = 1; + sQuakeUnused = 1; sQuakeRequestCount = 0; } -s16 Quake_Add(Camera* camera, u32 callbackIdx) { - return Quake_AddImpl(camera, callbackIdx)->randIdx; +s16 Quake_Request(Camera* camera, u32 type) { + return Quake_RequestImpl(camera, type)->index; } -u32 Quake_RemoveFromIdx(s16 idx) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_RemoveRequest(s16 index) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { Quake_Remove(req); @@ -305,101 +387,120 @@ u32 Quake_RemoveFromIdx(s16 idx) { return false; } -s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { - f32 max; - f32 max2; - QuakeRequest* req; - ShakeInfo shake; - f32 absSpeedDiv; - s16* temp; - u32 pad2; - s32 idx; - s32 ret; - u32 eq; - Vec3f vec; - PlayState* play; +s16 (*sQuakeCallbacks[])(QuakeRequest*, ShakeInfo*) = { + NULL, // QUAKE_TYPE_NONE + Quake_CallbackType1, // QUAKE_TYPE_1 + Quake_CallbackType2, // QUAKE_TYPE_2 + Quake_CallbackType3, // QUAKE_TYPE_3 + Quake_CallbackType4, // QUAKE_TYPE_4 + Quake_CallbackType5, // QUAKE_TYPE_5 + Quake_CallbackType6, // QUAKE_TYPE_6 +}; - play = camera->play; - vec.x = 0.0f; - vec.y = 0.0f; - vec.z = 0.0f; - camData->rotZ = 0; - camData->unk_1A = 0; - camData->zoom = 0; - camData->atOffset.x = 0.0f; - camData->atOffset.y = 0.0f; - camData->atOffset.z = 0.0f; - camData->eyeOffset.x = 0.0f; - camData->eyeOffset.y = 0.0f; - camData->eyeOffset.z = 0.0f; - camData->unk_20 = 0.0f; +s16 Quake_Update(Camera* camera, ShakeInfo* camShake) { + f32 maxCurr; + f32 maxNext; + ShakeInfo shake; + QuakeRequest* req; + f32 absSpeedDiv; + s16* camId; + s32 index; + s32 numQuakesApplied; + u32 isDifferentCamId; + Vec3f zeroVec; + PlayState* play = camera->play; + + zeroVec.x = 0.0f; + zeroVec.y = 0.0f; + zeroVec.z = 0.0f; + + camShake->upPitchOffset = 0; + camShake->upYawOffset = 0; + camShake->fovOffset = 0; + + camShake->atOffset.x = 0.0f; + camShake->atOffset.y = 0.0f; + camShake->atOffset.z = 0.0f; + + camShake->eyeOffset.x = 0.0f; + camShake->eyeOffset.y = 0.0f; + camShake->eyeOffset.z = 0.0f; + + camShake->maxOffset = 0.0f; if (sQuakeRequestCount == 0) { return 0; } - ret = 0; - for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) { - req = &sQuakeRequest[idx]; - if (req->callbackIdx != 0) { - if (play->cameraPtrs[req->camPtrIdx] == NULL) { - osSyncPrintf(VT_COL(YELLOW, BLACK) "quake: stopped! 'coz camera [%d] killed!!\n" VT_RST, - req->camPtrIdx); - Quake_Remove(req); - } else { - temp = &camera->camId; - eq = req->cam->camId != *temp; - absSpeedDiv = ABS(req->speed) / (f32)0x8000; - if (sQuakeCallbacks[req->callbackIdx](req, &shake) == 0) { - Quake_Remove(req); - } else if (eq == 0) { - if (fabsf(camData->atOffset.x) < fabsf(shake.vec1.x)) { - camData->atOffset.x = shake.vec1.x; - } - if (fabsf(camData->atOffset.y) < fabsf(shake.vec1.y)) { - camData->atOffset.y = shake.vec1.y; - } - if (fabsf(camData->atOffset.z) < fabsf(shake.vec1.z)) { - camData->atOffset.z = shake.vec1.z; - } - if (fabsf(camData->eyeOffset.x) < fabsf(shake.vec2.x)) { - camData->eyeOffset.x = shake.vec2.x; - } - if (fabsf(camData->eyeOffset.y) < fabsf(shake.vec2.y)) { - camData->eyeOffset.y = shake.vec2.y; - } - if (fabsf(camData->eyeOffset.z) < fabsf(shake.vec2.z)) { - camData->eyeOffset.z = shake.vec2.z; - } - if (camData->rotZ < shake.rotZ) { - camData->rotZ = shake.rotZ; - camData->unk_1A = shake.unk_1A; - } - if (camData->zoom < shake.zoom) { - camData->zoom = shake.zoom; - } - - max = OLib_Vec3fDist(&shake.vec1, &vec) * absSpeedDiv; - max2 = OLib_Vec3fDist(&shake.vec2, &vec) * absSpeedDiv; - if (max < max2) { - max = max2; - } - max2 = (camData->rotZ * 0.005f) * absSpeedDiv; - if (max < max2) { - max = max2; - } - max2 = (camData->zoom * 0.005f) * absSpeedDiv; - if (max < max2) { - max = max2; - } - if (camData->unk_20 < max) { - camData->unk_20 = max; - } - - ret++; - } - } + numQuakesApplied = 0; + for (index = 0; index < ARRAY_COUNT(sQuakeRequests); index++) { + req = &sQuakeRequests[index]; + if (req->type == QUAKE_TYPE_NONE) { + continue; } + + if (play->cameraPtrs[req->camId] == NULL) { + osSyncPrintf(VT_COL(YELLOW, BLACK) "quake: stopped! 'coz camera [%d] killed!!\n" VT_RST, req->camId); + Quake_Remove(req); + continue; + } + + camId = &camera->camId; + isDifferentCamId = req->cam->camId != *camId; + absSpeedDiv = (f32)ABS(req->speed) / 0x8000; + + if (sQuakeCallbacks[req->type](req, &shake) == 0) { + // Quake has reached the end of its timer. + Quake_Remove(req); + continue; + } + + if (isDifferentCamId) { + // Quake is attached to a different camId + continue; + } + + if (fabsf(camShake->atOffset.x) < fabsf(shake.atOffset.x)) { + camShake->atOffset.x = shake.atOffset.x; + } + if (fabsf(camShake->atOffset.y) < fabsf(shake.atOffset.y)) { + camShake->atOffset.y = shake.atOffset.y; + } + if (fabsf(camShake->atOffset.z) < fabsf(shake.atOffset.z)) { + camShake->atOffset.z = shake.atOffset.z; + } + if (fabsf(camShake->eyeOffset.x) < fabsf(shake.eyeOffset.x)) { + camShake->eyeOffset.x = shake.eyeOffset.x; + } + if (fabsf(camShake->eyeOffset.y) < fabsf(shake.eyeOffset.y)) { + camShake->eyeOffset.y = shake.eyeOffset.y; + } + if (fabsf(camShake->eyeOffset.z) < fabsf(shake.eyeOffset.z)) { + camShake->eyeOffset.z = shake.eyeOffset.z; + } + if (camShake->upPitchOffset < shake.upPitchOffset) { + camShake->upPitchOffset = shake.upPitchOffset; + camShake->upYawOffset = shake.upYawOffset; + } + if (camShake->fovOffset < shake.fovOffset) { + camShake->fovOffset = shake.fovOffset; + } + + maxCurr = OLib_Vec3fDist(&shake.atOffset, &zeroVec) * absSpeedDiv; + maxNext = OLib_Vec3fDist(&shake.eyeOffset, &zeroVec) * absSpeedDiv; + maxCurr = CLAMP_MIN(maxCurr, maxNext); + + maxNext = camShake->upPitchOffset * (1.0f / 200.0f) * absSpeedDiv; + maxCurr = CLAMP_MIN(maxCurr, maxNext); + + maxNext = camShake->fovOffset * (1.0f / 200.0f) * absSpeedDiv; + maxCurr = CLAMP_MIN(maxCurr, maxNext); + + if (camShake->maxOffset < maxCurr) { + camShake->maxOffset = maxCurr; + } + + numQuakesApplied++; } - return ret; + return numQuakesApplied; } diff --git a/src/code/z_room.c b/src/code/z_room.c index add5101380..953739f2a7 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -389,7 +389,7 @@ void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) { Vec3f quakeOffset; gfx = POLY_OPA_DISP; - Camera_GetSkyboxOffset(&quakeOffset, activeCam); + Camera_GetQuakeOffset(&quakeOffset, activeCam); Room_DrawBackground2D(&gfx, roomShape->source, roomShape->tlut, roomShape->width, roomShape->height, roomShape->fmt, roomShape->siz, roomShape->tlutMode, roomShape->tlutCount, (quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f, @@ -487,7 +487,7 @@ void Room_DrawImageMulti(PlayState* play, Room* room, u32 flags) { Vec3f quakeOffset; gfx = POLY_OPA_DISP; - Camera_GetSkyboxOffset(&quakeOffset, activeCam); + Camera_GetQuakeOffset(&quakeOffset, activeCam); Room_DrawBackground2D(&gfx, bgEntry->source, bgEntry->tlut, bgEntry->width, bgEntry->height, bgEntry->fmt, bgEntry->siz, bgEntry->tlutMode, bgEntry->tlutCount, (quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f, diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index 67d071ece8..a951314200 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -1,4 +1,5 @@ #include "global.h" +#include "quake.h" #include "assets/scenes/overworld/spot00/spot00_scene.h" #include "assets/scenes/overworld/spot00/spot00_room_0.h" @@ -585,20 +586,20 @@ void Scene_DrawConfigGanonCastleExterior(PlayState* play) { // Screen Shake for Ganon's Tower Collapse void func_8009BEEC(PlayState* play) { - s32 var; + s32 quakeIndex; if (play->gameplayFrames % 128 == 13) { - var = Quake_Add(GET_ACTIVE_CAM(play), 2); - Quake_SetSpeed(var, 10000); - Quake_SetQuakeValues(var, 4, 0, 0, 0); - Quake_SetCountdown(var, 127); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_2); + Quake_SetSpeed(quakeIndex, 10000); + Quake_SetPerturbations(quakeIndex, 4, 0, 0, 0); + Quake_SetDuration(quakeIndex, 127); } if ((play->gameplayFrames % 64 == 0) && (Rand_ZeroOne() > 0.6f)) { - var = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(var, 32000.0f + (Rand_ZeroOne() * 3000.0f)); - Quake_SetQuakeValues(var, 10.0f - (Rand_ZeroOne() * 9.0f), 0, 0, 0); - Quake_SetCountdown(var, 48.0f - (Rand_ZeroOne() * 15.0f)); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 32000.0f + (Rand_ZeroOne() * 3000.0f)); + Quake_SetPerturbations(quakeIndex, 10.0f - (Rand_ZeroOne() * 9.0f), 0, 0, 0); + Quake_SetDuration(quakeIndex, 48.0f - (Rand_ZeroOne() * 15.0f)); } } diff --git a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c index 798a717e0c..12bbb3a36b 100644 --- a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c +++ b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c @@ -5,6 +5,7 @@ */ #include "z_bg_bdan_objects.h" +#include "quake.h" #include "assets/objects/object_bdan_objects/object_bdan_objects.h" #define FLAGS ACTOR_FLAG_4 @@ -221,15 +222,15 @@ void func_8086C1A0(BgBdanObjects* this, PlayState* play) { } void func_8086C29C(BgBdanObjects* this, PlayState* play) { - s32 temp; + s32 quakeIndex; if (this->timer != 0) { this->timer--; if (this->timer == 0) { - temp = Quake_Add(GET_ACTIVE_CAM(play), 1); - Quake_SetSpeed(temp, 0x3A98); - Quake_SetQuakeValues(temp, 0, 1, 0xFA, 1); - Quake_SetCountdown(temp, 0xA); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); + Quake_SetSpeed(quakeIndex, 0x3A98); + Quake_SetPerturbations(quakeIndex, 0, 1, 250, 1); + Quake_SetDuration(quakeIndex, 10); } } diff --git a/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c b/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c index 122359fb68..a27997bda0 100644 --- a/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c +++ b/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c @@ -8,6 +8,7 @@ #include "overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "assets/objects/object_bowl/object_bowl.h" +#include "quake.h" #include "vt.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -151,10 +152,10 @@ void BgBowlWall_FallDoEffects(BgBowlWall* this, PlayState* play) { EffectSsHahen_SpawnBurst(play, &effectPos, 10.0f, 0, 50, 15, 3, HAHEN_OBJECT_DEFAULT, 10, NULL); Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); } - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 1); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); Quake_SetSpeed(quakeIndex, 0x7FFF); - Quake_SetQuakeValues(quakeIndex, 300, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 30); + Quake_SetPerturbations(quakeIndex, 300, 0, 0, 0); + Quake_SetDuration(quakeIndex, 30); this->timer = 20; this->actionFunc = BgBowlWall_FinishFall; } diff --git a/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c b/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c index 6241a90f01..f9407b73c3 100644 --- a/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c +++ b/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c @@ -169,7 +169,7 @@ void BgDdanKd_LowerStairs(BgDdanKd* this, PlayState* play) { func_80033480(play, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1); func_8003555C(play, &pos1, &velocity, &accel); } - Camera_AddQuake(&play->mainCamera, 0, effectStrength * 0.6f, 3); + Camera_RequestQuake(&play->mainCamera, 0, effectStrength * 0.6f, 3); Audio_PlaySfxGeneral(NA_SE_EV_PILLAR_SINK - SFX_FLAG, &this->dyna.actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } diff --git a/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c b/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c index 8c9338b6c0..6a9af76455 100644 --- a/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c +++ b/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c @@ -211,7 +211,7 @@ void BgGanonOtyuka_Fall(BgGanonOtyuka* this, PlayState* play) { (s16)Rand_ZeroFloat(100.0f) + 250, 5, (s16)Rand_ZeroFloat(5.0f) + 15); } - func_80033DB8(play, 10, 15); + Actor_RequestQuake(play, 10, 15); SfxSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 40, NA_SE_EV_BOX_BREAK); } Actor_Kill(&this->dyna.actor); diff --git a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c index 598ef2c117..8af91598fe 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c +++ b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c @@ -7,6 +7,7 @@ #include "z_bg_haka_huta.h" #include "assets/objects/object_hakach_objects/object_hakach_objects.h" #include "overlays/actors/ovl_En_Rd/z_en_rd.h" +#include "quake.h" #define FLAGS ACTOR_FLAG_4 @@ -179,10 +180,10 @@ void func_8087D720(BgHakaHuta* this, PlayState* play) { this->counter++; if (this->counter == 6) { this->actionFunc = BgHakaHuta_DoNothing; - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 0x7530); - Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 2); + Quake_SetPerturbations(quakeIndex, 4, 0, 0, 0); + Quake_SetDuration(quakeIndex, 2); } else if (this->counter == 0) { this->counter = 6; this->actionFunc = BgHakaHuta_DoNothing; diff --git a/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c b/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c index 269e99dc6c..bed22e6ab4 100644 --- a/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c +++ b/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c @@ -6,6 +6,7 @@ #include "z_bg_heavy_block.h" #include "assets/objects/object_heavy_object/object_heavy_object.h" +#include "quake.h" #include "vt.h" #define FLAGS 0 @@ -331,10 +332,10 @@ void BgHeavyBlock_Wait(BgHeavyBlock* this, PlayState* play) { break; } - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 25000); - Quake_SetQuakeValues(quakeIndex, 1, 1, 5, 0); - Quake_SetCountdown(quakeIndex, 10); + Quake_SetPerturbations(quakeIndex, 1, 1, 5, 0); + Quake_SetDuration(quakeIndex, 10); this->actionFunc = BgHeavyBlock_LiftedUp; } } @@ -398,25 +399,25 @@ void BgHeavyBlock_Fly(BgHeavyBlock* this, PlayState* play) { Flags_SetSwitch(play, (this->dyna.actor.params >> 8) & 0x3F); Actor_Kill(&this->dyna.actor); - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 28000); - Quake_SetQuakeValues(quakeIndex, 14, 2, 100, 0); - Quake_SetCountdown(quakeIndex, 30); + Quake_SetPerturbations(quakeIndex, 14, 2, 100, 0); + Quake_SetDuration(quakeIndex, 30); - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 2); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_2); Quake_SetSpeed(quakeIndex, 12000); - Quake_SetQuakeValues(quakeIndex, 5, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 999); + Quake_SetPerturbations(quakeIndex, 5, 0, 0, 0); + Quake_SetDuration(quakeIndex, 999); SfxSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 30, NA_SE_EV_ELECTRIC_EXPLOSION); return; case HEAVYBLOCK_UNBREAKABLE_OUTSIDE_CASTLE: Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 28000); - Quake_SetQuakeValues(quakeIndex, 16, 2, 120, 0); - Quake_SetCountdown(quakeIndex, 40); + Quake_SetPerturbations(quakeIndex, 16, 2, 120, 0); + Quake_SetDuration(quakeIndex, 40); this->actionFunc = BgHeavyBlock_Land; Flags_SetSwitch(play, (this->dyna.actor.params >> 8) & 0x3F); @@ -424,18 +425,18 @@ void BgHeavyBlock_Fly(BgHeavyBlock* this, PlayState* play) { case HEAVYBLOCK_UNBREAKABLE: Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_U); - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 28000); - Quake_SetQuakeValues(quakeIndex, 14, 2, 100, 0); - Quake_SetCountdown(quakeIndex, 40); + Quake_SetPerturbations(quakeIndex, 14, 2, 100, 0); + Quake_SetDuration(quakeIndex, 40); this->actionFunc = BgHeavyBlock_Land; break; default: - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 28000); - Quake_SetQuakeValues(quakeIndex, 14, 2, 100, 0); - Quake_SetCountdown(quakeIndex, 40); + Quake_SetPerturbations(quakeIndex, 14, 2, 100, 0); + Quake_SetDuration(quakeIndex, 40); this->actionFunc = BgHeavyBlock_Land; } diff --git a/src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.c b/src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.c index d3a0bf9edb..87a845e664 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.c @@ -6,6 +6,7 @@ #include "z_bg_hidan_hamstep.h" #include "assets/objects/object_hidan_objects/object_hidan_objects.h" +#include "quake.h" #define FLAGS 0 @@ -308,10 +309,10 @@ void func_80888860(BgHidanHamstep* this, PlayState* play) { if (1) {} if (this->unk_244 == 1) { - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, -15536); - Quake_SetQuakeValues(quakeIndex, 0, 0, 500, 0); - Quake_SetCountdown(quakeIndex, 20); + Quake_SetPerturbations(quakeIndex, 0, 0, 500, 0); + Quake_SetDuration(quakeIndex, 20); Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 255, 20, 150); func_80888638(this, play); @@ -367,10 +368,10 @@ void func_80888A58(BgHidanHamstep* this, PlayState* play) { if (1) {} if (this->unk_244 == 1) { - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, -15536); - Quake_SetQuakeValues(quakeIndex, 20, 1, 0, 0); - Quake_SetCountdown(quakeIndex, 7); + Quake_SetPerturbations(quakeIndex, 20, 1, 0, 0); + Quake_SetDuration(quakeIndex, 7); Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); Rumble_Request(SQ(100.0f), 255, 20, 150); diff --git a/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c b/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c index 44b4d7428f..6c4ac3dbac 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c +++ b/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c @@ -6,6 +6,7 @@ #include "z_bg_jya_kanaami.h" #include "assets/objects/object_jya_obj/object_jya_obj.h" +#include "quake.h" #define FLAGS 0 @@ -96,16 +97,17 @@ void func_8089993C(BgJyaKanaami* this) { void func_80899950(BgJyaKanaami* this, PlayState* play) { s32 pad[2]; - s32 quakeId; + s32 quakeIndex; this->unk_168 += 0x20; if (Math_ScaledStepToS(&this->dyna.actor.world.rot.x, 0x4000, this->unk_168)) { func_80899A08(this); Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_TRAP_BOUND); - quakeId = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quakeId, 25000); - Quake_SetQuakeValues(quakeId, 2, 0, 0, 0); - Quake_SetCountdown(quakeId, 16); + + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 25000); + Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0); + Quake_SetDuration(quakeIndex, 16); } } diff --git a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c index f332ea8c5b..0f66fbe4b6 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c +++ b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c @@ -6,6 +6,7 @@ #include "z_bg_mori_bigst.h" #include "assets/objects/object_mori_objects/object_mori_objects.h" +#include "quake.h" #define FLAGS ACTOR_FLAG_4 @@ -169,14 +170,15 @@ void BgMoriBigst_Fall(BgMoriBigst* this, PlayState* play) { void BgMoriBigst_SetupLanding(BgMoriBigst* this, PlayState* play) { s32 pad; - s32 quake; + s32 quakeIndex; BgMoriBigst_SetupAction(this, BgMoriBigst_Landing); this->waitTimer = 18; - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quake, 25000); - Quake_SetQuakeValues(quake, 5, 0, 0, 0); - Quake_SetCountdown(quake, 16); + + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 25000); + Quake_SetPerturbations(quakeIndex, 5, 0, 0, 0); + Quake_SetDuration(quakeIndex, 16); } void BgMoriBigst_Landing(BgMoriBigst* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c index 8d8494d1bd..ce4b68a8d5 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c +++ b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c @@ -6,6 +6,7 @@ #include "z_bg_mori_rakkatenjo.h" #include "assets/objects/object_mori_objects/object_mori_objects.h" +#include "quake.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -146,7 +147,7 @@ void BgMoriRakkatenjo_Fall(BgMoriRakkatenjo* this, PlayState* play) { static f32 bounceVel[] = { 4.0f, 1.5f, 0.4f, 0.1f }; s32 pad; Actor* thisx = &this->dyna.actor; - s32 quake; + s32 quakeIndex; Actor_MoveForward(thisx); if ((thisx->velocity.y < 0.0f) && (thisx->world.pos.y <= 403.0f)) { @@ -162,10 +163,11 @@ void BgMoriRakkatenjo_Fall(BgMoriRakkatenjo* this, PlayState* play) { 403.0f - (thisx->world.pos.y - 403.0f) * bounceVel[this->bounceCount] / fabsf(thisx->velocity.y); thisx->velocity.y = bounceVel[this->bounceCount]; this->bounceCount++; - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quake, 50000); - Quake_SetQuakeValues(quake, 5, 0, 0, 0); - Quake_SetCountdown(quake, 5); + + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 50000); + Quake_SetPerturbations(quakeIndex, 5, 0, 0, 0); + Quake_SetDuration(quakeIndex, 5); } } } diff --git a/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c b/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c index 9d2184349a..2e2ce1f359 100644 --- a/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c +++ b/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c @@ -315,7 +315,7 @@ void BgPoEvent_BlockFall(BgPoEvent* this, PlayState* play) { BgPoEvent_CheckBlock(this); } else { Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); - func_80033E88(&this->dyna.actor, play, 5, 5); + Actor_RequestQuakeAndRumble(&this->dyna.actor, play, 5, 5); func_80088B34(this->timer); if (firstFall == 0) { firstFall = 1; diff --git a/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c b/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c index dbe09013cd..e56ed7e0c2 100644 --- a/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c +++ b/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c @@ -6,6 +6,7 @@ #include "z_bg_spot12_gate.h" #include "assets/objects/object_spot12_obj/object_spot12_obj.h" +#include "quake.h" #define FLAGS 0 @@ -104,16 +105,18 @@ void func_808B317C(BgSpot12Gate* this) { void func_808B318C(BgSpot12Gate* this, PlayState* play) { s32 pad; - s32 var; + s32 quakeIndex; Math_StepToF(&this->dyna.actor.velocity.y, 1.6f, 0.03f); if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, this->dyna.actor.velocity.y)) { func_808B3274(this); - var = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(var, -0x3CB0); - Quake_SetQuakeValues(var, 3, 0, 0, 0); - Quake_SetCountdown(var, 0xC); + + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -0x3CB0); + Quake_SetPerturbations(quakeIndex, 3, 0, 0, 0); + Quake_SetDuration(quakeIndex, 12); + Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); } else { func_8002F974(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index ace123bcfd..3dccccfbc0 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -552,7 +552,7 @@ void BossDodongo_Explode(BossDodongo* this, PlayState* play) { this->actionFunc = BossDodongo_LayDown; Audio_PlayActorSfx2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_DODO_K_DAMAGE); - func_80033E88(&this->actor, play, 4, 10); + Actor_RequestQuakeAndRumble(&this->actor, play, 4, 10); this->health -= 2; // make sure not to die from the bomb explosion @@ -677,7 +677,7 @@ void BossDodongo_Walk(BossDodongo* this, PlayState* play) { } if (this->subCamId == SUB_CAM_ID_DONE) { - func_80033E88(&this->actor, play, 4, 10); + Actor_RequestQuakeAndRumble(&this->actor, play, 4, 10); } else { this->unk_1B6 = 10; Rumble_Override(0.0f, 180, 20, 100); @@ -758,7 +758,7 @@ void BossDodongo_Roll(BossDodongo* this, PlayState* play) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_DODO_K_ROLL - SFX_FLAG); if ((this->unk_19E & 7) == 0) { - Camera_AddQuake(&play->mainCamera, 2, 1, 8); + Camera_RequestQuake(&play->mainCamera, 2, 1, 8); } if (!(this->unk_19E & 1)) { @@ -787,12 +787,12 @@ void BossDodongo_Roll(BossDodongo* this, PlayState* play) { this->unk_228 = 9200.0f; this->actor.velocity.y = 20.0f; Audio_PlayActorSfx2(&this->actor, NA_SE_EN_DODO_K_COLI); - Camera_AddQuake(&play->mainCamera, 2, 6, 8); + Camera_RequestQuake(&play->mainCamera, 2, 6, 8); sp50.x = this->actor.world.pos.x; sp50.y = this->actor.world.pos.y + 60.0f; sp50.z = this->actor.world.pos.z; func_80033480(play, &sp50, 250.0f, 40, 800, 10, 0); - func_80033E88(&this->actor, play, 6, 15); + Actor_RequestQuakeAndRumble(&this->actor, play, 6, 15); } else { this->actor.velocity.y = 15.0f; Audio_PlayActorSfx2(&this->actor, NA_SE_EN_DODO_K_COLI2); @@ -1395,7 +1395,7 @@ void BossDodongo_DeathCutscene(BossDodongo* this, PlayState* play) { Math_SmoothStepToF(&this->actor.world.pos.z, cornerPos->z + sp184.z, 1.0f, this->unk_1E4, 0.0f); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_DODO_K_ROLL - SFX_FLAG); if ((this->unk_19E & 7) == 0) { - Camera_AddQuake(&play->mainCamera, 2, 1, 8); + Camera_RequestQuake(&play->mainCamera, 2, 1, 8); } if (!(this->unk_19E & 1)) { Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 40.0f, 3, 8.0f, 500, 10, diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index 477b3a2186..da3722c2fd 100644 --- a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -629,7 +629,7 @@ void BossFd_Fly(BossFd* this, PlayState* play) { this->holePosition.x = this->targetPosition.x; this->holePosition.z = this->targetPosition.z; - func_80033E1C(play, 1, 0x50, 0x5000); + Actor_RequestQuakeWithSpeed(play, 1, 80, 0x5000); if (this->introState != BFD_CS_NONE) { this->timers[0] = 50; } else { @@ -673,7 +673,7 @@ void BossFd_Fly(BossFd* this, PlayState* play) { this->timers[1] = 10; Audio_PlaySfxGeneral(NA_SE_EV_EXPLOSION, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - func_80033E1C(play, 3, 0xA, 0x7530); + Actor_RequestQuakeWithSpeed(play, 3, 10, 0x7530); this->work[BFD_ROCK_TIMER] = 300; } } else { @@ -979,14 +979,14 @@ void BossFd_Fly(BossFd* this, PlayState* play) { if (this->work[BFD_ACTION_STATE] < BOSSFD_SKULL_FALL) { if ((this->actor.prevPos.y < 90.0f) && (90.0f <= this->actor.world.pos.y)) { this->timers[4] = 80; - func_80033E1C(play, 1, 80, 0x5000); + Actor_RequestQuakeWithSpeed(play, 1, 80, 0x5000); this->work[BFD_ROAR_TIMER] = 40; this->work[BFD_MANE_EMBERS_TIMER] = 30; this->work[BFD_SPLASH_TIMER] = 10; } if ((this->actor.prevPos.y > 90.0f) && (90.0f >= this->actor.world.pos.y)) { this->timers[4] = 80; - func_80033E1C(play, 1, 80, 0x5000); + Actor_RequestQuakeWithSpeed(play, 1, 80, 0x5000); this->work[BFD_MANE_EMBERS_TIMER] = 30; this->work[BFD_SPLASH_TIMER] = 10; } diff --git a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c index 43afbefc9b..a4cd5f56ea 100644 --- a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c +++ b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c @@ -243,7 +243,7 @@ void BossFd2_Emerge(BossFd2* this, PlayState* play) { bossFd->faceExposed = 0; bossFd->holePosition.x = this->actor.world.pos.x; bossFd->holePosition.z = this->actor.world.pos.z; - func_80033E1C(play, 1, 0x32, 0x5000); + Actor_RequestQuakeWithSpeed(play, 1, 50, 0x5000); this->work[FD2_ACTION_STATE] = 1; this->work[FD2_HOLE_COUNTER]++; this->actor.world.pos.y = -200.0f; diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index b44e7191b2..79e1999f3a 100644 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -1897,7 +1897,7 @@ void BossGanon_PoundFloor(BossGanon* this, PlayState* play) { this->actor.world.pos.y = 60.0f; this->unk_1C2 = 2; this->timers[0] = 10; - func_80033E88(&this->actor, play, 0xA, 0x14); // rumble + Actor_RequestQuakeAndRumble(&this->actor, play, 10, 20); this->unk_19C = 35; this->unk_19E = 0; Audio_PlayActorSfx2(&this->actor, NA_SE_EN_GANON_HIT_GND_IMP); diff --git a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index cce407735a..06ce4c4f73 100644 --- a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -170,7 +170,7 @@ void func_808FD4D4(BossGanon2* this, PlayState* play, s16 arg2, s16 arg3) { } Audio_PlayActorSfx2(&this->actor, NA_SE_EN_MGANON_WALK); - func_80033E88(&this->actor, play, 2, 0xA); + Actor_RequestQuakeAndRumble(&this->actor, play, 2, 10); } void func_808FD5C4(BossGanon2* this, PlayState* play) { @@ -2004,7 +2004,7 @@ void BossGanon2_Update(Actor* thisx, PlayState* play) { UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2); if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->actor.velocity.y < -5.0f) { - func_80033E88(&this->actor, play, 5, 20); + Actor_RequestQuakeAndRumble(&this->actor, play, 5, 20); func_80078884(NA_SE_IT_BOMB_EXPLOSION); } this->actor.velocity.y = 0.0f; diff --git a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c index e2c6bd4d06..ae4b8e1cd3 100644 --- a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c @@ -1309,7 +1309,7 @@ void BossGoma_FloorAttack(BossGoma* this, PlayState* play) { if (Animation_OnFrame(&this->skelanime, 10.0f)) { BossGoma_PlayEffectsAndSfx(this, play, 3, 5); - func_80033E88(&this->actor, play, 5, 15); + Actor_RequestQuakeAndRumble(&this->actor, play, 5, 15); } if (Animation_OnFrame(&this->skelanime, Animation_GetLastFrame(&gGohmaAttackAnim))) { @@ -1434,7 +1434,7 @@ void BossGoma_FallJump(BossGoma* this, PlayState* play) { BossGoma_SetupFloorLand(this); this->actor.velocity.y = 0.0f; BossGoma_PlayEffectsAndSfx(this, play, 0, 8); - func_80033E88(&this->actor, play, 5, 0xF); + Actor_RequestQuakeAndRumble(&this->actor, play, 5, 15); } } @@ -1451,7 +1451,7 @@ void BossGoma_FallStruckDown(BossGoma* this, PlayState* play) { BossGoma_SetupFloorLandStruckDown(this); this->actor.velocity.y = 0.0f; BossGoma_PlayEffectsAndSfx(this, play, 0, 8); - func_80033E88(&this->actor, play, 0xA, 0xF); + Actor_RequestQuakeAndRumble(&this->actor, play, 10, 15); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_GOMA_DAM1); } } @@ -1847,7 +1847,7 @@ void BossGoma_UpdateHit(BossGoma* this, PlayState* play) { } this->timer = 4; - func_80033E88(&this->actor, play, 4, 0xC); + Actor_RequestQuakeAndRumble(&this->actor, play, 4, 12); } } } diff --git a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index 5426855675..267b6cc1cb 100644 --- a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -1758,7 +1758,7 @@ void BossVa_SetupSupportCut(BossVa* this, PlayState* play) { sFightPhase++; Actor_Spawn(&play->actorCtx, play, ACTOR_BOSS_VA, this->armTip.x, this->armTip.y + 20.0f, this->armTip.z, 0, this->actor.shape.rot.y, 0, stumpParams); - Camera_AddQuake(&play->mainCamera, 2, 11, 8); + Camera_RequestQuake(&play->mainCamera, 2, 11, 8); this->burst = false; this->timer2 = 0; BossVa_SetupAction(this, BossVa_SupportCut); diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index a4a0488b49..e65ca80d88 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -6,6 +6,7 @@ #include "z_door_shutter.h" #include "overlays/actors/ovl_Boss_Goma/z_boss_goma.h" +#include "quake.h" #include "assets/objects/object_gnd/object_gnd.h" #include "assets/objects/object_goma/object_goma.h" @@ -31,7 +32,7 @@ void DoorShutter_Destroy(Actor* thisx, PlayState* play); void DoorShutter_Update(Actor* thisx, PlayState* play); void DoorShutter_Draw(Actor* thisx, PlayState* play); -void func_8099803C(PlayState* play, s16 y, s16 countdown, s16 camId); +void DoorShutter_RequestQuakeAndRumble(PlayState* play, s16 quakeY, s16 quakeDuration, s16 camId); void DoorShutter_SetupType(DoorShutter* this, PlayState* play); void func_80996A54(DoorShutter* this, PlayState* play); void func_80996B00(DoorShutter* this, PlayState* play); @@ -560,7 +561,7 @@ void func_80997220(DoorShutter* this, PlayState* play) { } void func_809973E8(DoorShutter* this, PlayState* play) { - s32 quakeId; + s32 quakeIndex; if (this->dyna.actor.velocity.y < 20.0f) { Math_StepToF(&this->dyna.actor.velocity.y, 20.0f, 8.0f); @@ -572,10 +573,10 @@ void func_809973E8(DoorShutter* this, PlayState* play) { false); } Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); - quakeId = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); - Quake_SetSpeed(quakeId, -32536); - Quake_SetQuakeValues(quakeId, 2, 0, 0, 0); - Quake_SetCountdown(quakeId, 10); + quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), 3); + Quake_SetSpeed(quakeIndex, -32536); + Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0); + Quake_SetDuration(quakeIndex, 10); Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); func_80997220(this, play); } @@ -604,7 +605,7 @@ void func_809975C0(DoorShutter* this, PlayState* play) { this->unk_164 = 10; Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); - func_8099803C(play, 2, 10, parent->subCamId); + DoorShutter_RequestQuakeAndRumble(play, 2, 10, parent->subCamId); Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 70.0f, 20, 8.0f, 500, 10, true); } @@ -766,11 +767,11 @@ void DoorShutter_Draw(Actor* thisx, PlayState* play) { } } -void func_8099803C(PlayState* play, s16 y, s16 countdown, s16 camId) { - s16 quakeId = Quake_Add(Play_GetCamera(play, camId), 3); +void DoorShutter_RequestQuakeAndRumble(PlayState* play, s16 quakeY, s16 quakeDuration, s16 camId) { + s16 quakeIndex = Quake_Request(Play_GetCamera(play, camId), QUAKE_TYPE_3); Rumble_Override(0.0f, 180, 20, 100); - Quake_SetSpeed(quakeId, 20000); - Quake_SetQuakeValues(quakeId, y, 0, 0, 0); - Quake_SetCountdown(quakeId, countdown); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetPerturbations(quakeIndex, quakeY, 0, 0, 0); + Quake_SetDuration(quakeIndex, quakeDuration); } diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 9c2f3dc7a5..201276fd4c 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -262,7 +262,7 @@ void func_809BD1C8(EnBigokuta* this, PlayState* play) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_DAIOCTA_LAND_WATER); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_GOLON_LAND_BIG); - func_80033E88(&this->actor, play, 0xA, 8); + Actor_RequestQuakeAndRumble(&this->actor, play, 10, 8); } void func_809BD2E4(EnBigokuta* this) { diff --git a/src/overlays/actors/ovl_En_Bili/z_en_bili.c b/src/overlays/actors/ovl_En_Bili/z_en_bili.c index 6c49419a9c..baed701b84 100644 --- a/src/overlays/actors/ovl_En_Bili/z_en_bili.c +++ b/src/overlays/actors/ovl_En_Bili/z_en_bili.c @@ -7,7 +7,7 @@ #include "z_en_bili.h" #include "assets/objects/object_bl/object_bl.h" -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12 | ACTOR_FLAG_14) +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_14) void EnBili_Init(Actor* thisx, PlayState* play); void EnBili_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 9e91b70aa7..f844b3892a 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -319,7 +319,7 @@ void EnBom_Update(Actor* thisx, PlayState* play2) { play->envCtx.adjAmbientColor[0] = play->envCtx.adjAmbientColor[1] = play->envCtx.adjAmbientColor[2] = 250; - Camera_AddQuake(&play->mainCamera, 2, 0xB, 8); + Camera_RequestQuake(&play->mainCamera, 2, 11, 8); thisx->params = BOMB_EXPLOSION; this->timer = 10; thisx->flags |= ACTOR_FLAG_5; diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 4fc3a9f19e..c72c4f6e99 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -428,7 +428,7 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { play->envCtx.adjLight1Color[0] = play->envCtx.adjLight1Color[1] = play->envCtx.adjLight1Color[2] = 250; play->envCtx.adjAmbientColor[0] = play->envCtx.adjAmbientColor[1] = play->envCtx.adjAmbientColor[2] = 250; - Camera_AddQuake(&play->mainCamera, 2, 0xB, 8); + Camera_RequestQuake(&play->mainCamera, 2, 11, 8); thisx->params = BOMBFLOWER_EXPLOSION; this->timer = 10; thisx->flags |= ACTOR_FLAG_5; diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index ab67053149..44630e6909 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -1,7 +1,7 @@ #include "z_en_crow.h" #include "assets/objects/object_crow/object_crow.h" -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12 | ACTOR_FLAG_14) +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_14) void EnCrow_Init(Actor* thisx, PlayState* play); void EnCrow_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c b/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c index d1c4ee79f5..5a43ab49ec 100644 --- a/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c +++ b/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c @@ -200,7 +200,7 @@ void EnEiyer_SetupAppearFromGround(EnEiyer* this) { this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_12); + this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_IGNORE_QUAKE); this->actor.shape.shadowScale = 0.0f; this->actor.shape.yOffset = 0.0f; this->actionFunc = EnEiyer_AppearFromGround; @@ -231,7 +231,7 @@ void EnEiyer_SetupAmbush(EnEiyer* this, PlayState* play) { this->collider.info.bumper.dmgFlags = DMG_DEFAULT; this->basePos = this->actor.world.pos; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.flags |= ACTOR_FLAG_12; + this->actor.flags |= ACTOR_FLAG_IGNORE_QUAKE; this->collider.base.acFlags &= ~AC_ON; this->actor.shape.shadowScale = 65.0f; this->actor.shape.yOffset = 600.0f; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index 0cb0eb0df0..38e0e84530 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -1,5 +1,6 @@ #include "z_en_encount2.h" #include "overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.h" +#include "quake.h" #include "vt.h" #include "assets/objects/object_efc_star_field/object_efc_star_field.h" @@ -91,11 +92,11 @@ void EnEncount2_Wait(EnEncount2* this, PlayState* play) { } break; case ENCOUNT2_ACTIVE_DEATH_MOUNTAIN: - if ((this->deathMountainSpawnerTimer == 1) || (!this->isQuaking)) { - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 1); + if ((this->deathMountainSpawnerTimer == 1) || !this->isQuaking) { + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); Quake_SetSpeed(quakeIndex, 0x7FFF); - Quake_SetQuakeValues(quakeIndex, 50, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 300); + Quake_SetPerturbations(quakeIndex, 50, 0, 0, 0); + Quake_SetDuration(quakeIndex, 300); this->isQuaking = true; } FALLTHROUGH; diff --git a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c index d9fb15c80f..8d17373f66 100644 --- a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c +++ b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c @@ -212,7 +212,7 @@ void EnFhgFire_LightningStrike(EnFhgFire* this, PlayState* play) { (s16)(Rand_ZeroOne() * 100.0f) + 240, FHGFLASH_LIGHTBALL_GREEN); } } - func_80033E88(&this->actor, play, 4, 10); + Actor_RequestQuakeAndRumble(&this->actor, play, 4, 10); } break; diff --git a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c index 232aeb9fc9..e22128e519 100644 --- a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c +++ b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c @@ -198,7 +198,7 @@ void EnFireRock_Fall(EnFireRock* this, PlayState* play) { switch (this->type) { case FIRE_ROCK_SPAWNED_FALLING1: case FIRE_ROCK_SPAWNED_FALLING2: - func_80033E88(&this->actor, play, 5, 2); + Actor_RequestQuakeAndRumble(&this->actor, play, 5, 2); FALLTHROUGH; case FIRE_ROCK_BROKEN_PIECE1: Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index 6c93d2052b..d88e8bc63e 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -8,7 +8,7 @@ #include "assets/objects/object_firefly/object_firefly.h" #include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h" -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12 | ACTOR_FLAG_14) +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_14) void EnFirefly_Init(Actor* thisx, PlayState* play); void EnFirefly_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/src/overlays/actors/ovl_En_Go2/z_en_go2.c index de374fa169..c7736ba151 100644 --- a/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -2,6 +2,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "assets/objects/object_oF1d_map/object_oF1d_map.h" +#include "quake.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -1628,14 +1629,14 @@ void EnGo2_Destroy(Actor* thisx, PlayState* play) { void EnGo2_CurledUp(EnGo2* this, PlayState* play) { u8 index = this->actor.params & 0x1F; s16 height; - s32 quake; + s32 quakeIndex; if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quake, -0x3CB0); - Quake_SetQuakeValues(quake, 8, 0, 0, 0); - Quake_SetCountdown(quake, 16); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -0x3CB0); + Quake_SetPerturbations(quakeIndex, 8, 0, 0, 0); + Quake_SetDuration(quakeIndex, 16); } else { EnGo2_GetDustData(this, 1); } diff --git a/src/overlays/actors/ovl_En_Goma/z_en_goma.c b/src/overlays/actors/ovl_En_Goma/z_en_goma.c index 13eb480d56..e2c7c297b3 100644 --- a/src/overlays/actors/ovl_En_Goma/z_en_goma.c +++ b/src/overlays/actors/ovl_En_Goma/z_en_goma.c @@ -791,7 +791,7 @@ void EnGoma_Draw(Actor* thisx, PlayState* play) { this->actor.naviEnemyId = NAVI_ENEMY_GOHMA_LARVA; Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + - ((this->actor.shape.yOffset * this->actor.scale.y) + play->mainCamera.skyboxOffset.y), + ((this->actor.shape.yOffset * this->actor.scale.y) + play->mainCamera.quakeOffset.y), this->actor.world.pos.z, MTXMODE_NEW); Matrix_RotateX(BINANG_TO_RAD_ALT(this->slopePitch), MTXMODE_APPLY); Matrix_RotateZ(BINANG_TO_RAD_ALT(this->slopeRoll), MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index 0f931ea560..e71402cbe5 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -8,6 +8,7 @@ #include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "assets/objects/object_goroiwa/object_goroiwa.h" +#include "quake.h" #include "vt.h" #define FLAGS ACTOR_FLAG_4 @@ -358,7 +359,7 @@ s32 EnGoroiwa_MoveDownToNextWaypoint(EnGoroiwa* this, PlayState* play) { f32 nextPointY; f32 thisY; f32 yDistToFloor; - s32 quakeIdx; + s32 quakeIndex; CollisionPoly* floorPoly; Vec3f checkPos; f32 floorY; @@ -379,10 +380,10 @@ s32 EnGoroiwa_MoveDownToNextWaypoint(EnGoroiwa* this, PlayState* play) { if (this->actor.velocity.y < 0.0f && this->actor.world.pos.y <= nextPointY) { if (this->bounceCount == 0) { if (this->actor.xzDistToPlayer < 600.0f) { - quakeIdx = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quakeIdx, -0x3CB0); - Quake_SetQuakeValues(quakeIdx, 3, 0, 0, 0); - Quake_SetCountdown(quakeIdx, 7); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -0x3CB0); + Quake_SetPerturbations(quakeIndex, 3, 0, 0, 0); + Quake_SetDuration(quakeIndex, 7); } this->rollRotSpeed = 0.0f; if (!(this->stateFlags & ENGOROIWA_IN_WATER)) { diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index 31b3acf0ce..bbeb6c4de0 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -427,7 +427,7 @@ void func_80A74EBC(EnIk* this, PlayState* play) { sp2C.z = this->actor.world.pos.z + Math_CosS(this->actor.shape.rot.y + 0x6A4) * 70.0f; sp2C.y = this->actor.world.pos.y; Audio_PlayActorSfx2(&this->actor, NA_SE_EN_IRONNACK_HIT_GND); - Camera_AddQuake(&play->mainCamera, 2, 0x19, 5); + Camera_RequestQuake(&play->mainCamera, 2, 25, 5); Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); CollisionCheck_SpawnShieldParticles(play, &sp2C); } diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 6fda0facc8..4c361c8c5b 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Insect/z_en_insect.h" #include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" #include "assets/objects/gameplay_field_keep/gameplay_field_keep.h" - +#include "quake.h" #include "vt.h" #define FLAGS ACTOR_FLAG_23 @@ -420,7 +420,7 @@ void EnIshi_Fly(EnIshi* this, PlayState* play) { s32 pad; s16 type = this->actor.params & 1; s32 pad2; - s32 quakeIdx; + s32 quakeIndex; Vec3f contactPos; if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_WALL)) { @@ -432,10 +432,10 @@ void EnIshi_Fly(EnIshi* this, PlayState* play) { sDustSpawnFuncs[type](this, play); } if (type == ROCK_LARGE) { - quakeIdx = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quakeIdx, -0x3CB0); - Quake_SetQuakeValues(quakeIdx, 3, 0, 0, 0); - Quake_SetCountdown(quakeIdx, 7); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -0x3CB0); + Quake_SetPerturbations(quakeIndex, 3, 0, 0, 0); + Quake_SetDuration(quakeIndex, 7); Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } Actor_Kill(&this->actor); diff --git a/src/overlays/actors/ovl_En_Mb/z_en_mb.c b/src/overlays/actors/ovl_En_Mb/z_en_mb.c index 195ed29bd2..c103703efc 100644 --- a/src/overlays/actors/ovl_En_Mb/z_en_mb.c +++ b/src/overlays/actors/ovl_En_Mb/z_en_mb.c @@ -862,7 +862,7 @@ void EnMb_ClubAttack(EnMb* this, PlayState* play) { EffectSsBlast_SpawnWhiteShockwave(play, &effSpawnPos, &effWhiteShockwaveDynamics, &effWhiteShockwaveDynamics); func_80033480(play, &effSpawnPos, 2.0f, 3, 0x12C, 0xB4, 1); - Camera_AddQuake(&play->mainCamera, 2, 0x19, 5); + Camera_RequestQuake(&play->mainCamera, 2, 25, 5); func_800358DC(&this->actor, &effSpawnPos, &this->actor.world.rot, flamesParams, 20, flamesUnused, play, -1, NULL); EnMb_SetupClubWaitAfterAttack(this); @@ -1044,7 +1044,7 @@ void EnMb_ClubDamaged(EnMb* this, PlayState* play) { Animation_PlayOnce(&this->skelAnime, &gEnMbClubStandUpAnim); this->timer3 = 0; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); - Camera_AddQuake(&play->mainCamera, 2, 25, 5); + Camera_RequestQuake(&play->mainCamera, 2, 25, 5); } else { EnMb_SetupClubWaitPlayerNear(this); } @@ -1105,7 +1105,7 @@ void EnMb_ClubDead(EnMb* this, PlayState* play) { Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); Actor_SpawnFloorDustRing(play, &this->actor, &effPos, 50.0f, 10, 3.0f, 400, 60, false); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_RIZA_DOWN); - Camera_AddQuake(&play->mainCamera, 2, 25, 5); + Camera_RequestQuake(&play->mainCamera, 2, 25, 5); } } diff --git a/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c b/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c index 4dae5a2910..3f650fb36b 100644 --- a/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c +++ b/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c @@ -7,7 +7,7 @@ #include "z_en_po_desert.h" #include "assets/objects/object_po_field/object_po_field.h" -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_7 | ACTOR_FLAG_12) +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_7 | ACTOR_FLAG_IGNORE_QUAKE) void EnPoDesert_Init(Actor* thisx, PlayState* play); void EnPoDesert_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c b/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c index cd803523d4..b1fc21258c 100644 --- a/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c +++ b/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c @@ -8,7 +8,7 @@ #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "assets/objects/object_po_field/object_po_field.h" -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_12) +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_IGNORE_QUAKE) void EnPoField_Init(Actor* thisx, PlayState* play); void EnPoField_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.c b/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.c index 737399be6b..d51900d708 100644 --- a/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.c +++ b/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Honotrap/z_en_honotrap.h" #include "assets/objects/object_tk/object_tk.h" -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_12 | ACTOR_FLAG_16) +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_16) void EnPoRelay_Init(Actor* thisx, PlayState* play); void EnPoRelay_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 1ea543a43d..99d7f0ed36 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -8,7 +8,7 @@ #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "assets/objects/object_po_sisters/object_po_sisters.h" -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_9 | ACTOR_FLAG_12 | ACTOR_FLAG_14) +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_9 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_14) void EnPoSisters_Init(Actor* thisx, PlayState* play); void EnPoSisters_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index 93e7a7857e..d3ed737cc8 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -8,7 +8,7 @@ #include "assets/objects/object_poh/object_poh.h" #include "assets/objects/object_po_composer/object_po_composer.h" -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_12) +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE) void EnPoh_Init(Actor* thisx, PlayState* play); void EnPoh_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Vali/z_en_vali.c b/src/overlays/actors/ovl_En_Vali/z_en_vali.c index 697b31d86c..60e54f99d1 100644 --- a/src/overlays/actors/ovl_En_Vali/z_en_vali.c +++ b/src/overlays/actors/ovl_En_Vali/z_en_vali.c @@ -7,7 +7,7 @@ #include "z_en_vali.h" #include "assets/objects/object_vali/object_vali.h" -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_12) +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE) void EnVali_Init(Actor* thisx, PlayState* play); void EnVali_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c b/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c index 88f4976e31..cd444c9132 100644 --- a/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c +++ b/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c @@ -191,7 +191,7 @@ void EnVbBall_Update(Actor* thisx, PlayState* play2) { if ((this->actor.params == 100) || (this->actor.params == 101)) { Actor_Kill(&this->actor); if (this->actor.params == 100) { - func_80033E88(&this->actor, play, 5, 0xA); + Actor_RequestQuakeAndRumble(&this->actor, play, 5, 10); } if (this->actor.params == 100) { spawnNum = 2; diff --git a/src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.c b/src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.c index feb1141a72..cf97c6ca7d 100644 --- a/src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.c +++ b/src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.c @@ -5,6 +5,7 @@ */ #include "z_en_wall_tubo.h" +#include "quake.h" #include "vt.h" #include "overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h" #include "overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.h" @@ -91,10 +92,10 @@ void EnWallTubo_DetectChu(EnWallTubo* this, PlayState* play) { func_80078884(NA_SE_SY_TRE_BOX_APPEAR); this->timer = 60; EffectSsBomb2_SpawnLayered(play, &this->explosionCenter, &effVelocity, &effAccel, 200, 40); - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 1); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); Quake_SetSpeed(quakeIndex, 0x7FFF); - Quake_SetQuakeValues(quakeIndex, 100, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 100); + Quake_SetPerturbations(quakeIndex, 100, 0, 0, 0); + Quake_SetDuration(quakeIndex, 100); this->actionFunc = EnWallTubo_SetWallFall; break; } diff --git a/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.c b/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.c index 97d85a32fa..cb8bc106e8 100644 --- a/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.c +++ b/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.c @@ -80,7 +80,7 @@ void func_80B43A94(EnYukabyun* this, PlayState* play) { this->unk_150--; } if (this->unk_150 == 0) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12; + this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_IGNORE_QUAKE; this->actionfunc = func_80B43AD4; } } diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c index 2ac90b1cb1..c7da7d11bf 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -7,6 +7,7 @@ #include "z_obj_lift.h" #include "assets/objects/object_d_lift/object_d_lift.h" #include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" +#include "quake.h" #define FLAGS ACTOR_FLAG_4 @@ -142,10 +143,10 @@ void func_80B96560(ObjLift* this, PlayState* play) { if (((this->dyna.actor.params >> 8) & 7) == 7) { func_80B967C0(this); } else { - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 1); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); Quake_SetSpeed(quakeIndex, 10000); - Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 20); + Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0); + Quake_SetDuration(quakeIndex, 20); func_80B9664C(this); } } diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index 06ce3449fe..145d13f358 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -72,10 +72,10 @@ void OceffWipe_Draw(Actor* thisx, PlayState* play) { s32 i; Vec3f eye; Vtx* vtxPtr; - Vec3f vec; + Vec3f quakeOffset; eye = GET_ACTIVE_CAM(play)->eye; - Camera_GetSkyboxOffset(&vec, GET_ACTIVE_CAM(play)); + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); OPEN_DISPS(play->state.gfxCtx, "../z_oceff_wipe.c", 346); @@ -103,7 +103,7 @@ void OceffWipe_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Xlu(play->state.gfxCtx); - Matrix_Translate(eye.x + vec.x, eye.y + vec.y, eye.z + vec.z, MTXMODE_NEW); + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.z + quakeOffset.z, MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index 2bb9247696..dd32aa46c3 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -66,10 +66,10 @@ void OceffWipe2_Draw(Actor* thisx, PlayState* play) { s32 pad[2]; Vec3f eye; Vtx* vtxPtr; - Vec3f vec; + Vec3f quakeOffset; eye = GET_ACTIVE_CAM(play)->eye; - Camera_GetSkyboxOffset(&vec, GET_ACTIVE_CAM(play)); + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); if (this->timer < 32) { z = Math_SinS(this->timer << 9) * 1330; } else { @@ -91,7 +91,7 @@ void OceffWipe2_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Xlu(play->state.gfxCtx); - Matrix_Translate(eye.x + vec.x, eye.y + vec.y, eye.z + vec.z, MTXMODE_NEW); + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.z + quakeOffset.z, MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index 3a05b14d07..db7f545cae 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -67,10 +67,10 @@ void OceffWipe3_Draw(Actor* thisx, PlayState* play) { s32 pad[2]; Vec3f eye; Vtx* vtxPtr; - Vec3f vec; + Vec3f quakeOffset; eye = GET_ACTIVE_CAM(play)->eye; - Camera_GetSkyboxOffset(&vec, GET_ACTIVE_CAM(play)); + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); if (this->counter < 32) { z = Math_SinS(this->counter << 9) * 1330; } else { @@ -92,7 +92,7 @@ void OceffWipe3_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Xlu(play->state.gfxCtx); - Matrix_Translate(eye.x + vec.x, eye.y + vec.y, eye.z + vec.z, MTXMODE_NEW); + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.z + quakeOffset.z, MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index 69e79ad1a4..bfdbac149e 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -65,10 +65,10 @@ void OceffWipe4_Draw(Actor* thisx, PlayState* play) { s32 pad[2]; Vec3f eye; Vtx* vtxPtr; - Vec3f vec; + Vec3f quakeOffset; eye = GET_ACTIVE_CAM(play)->eye; - Camera_GetSkyboxOffset(&vec, GET_ACTIVE_CAM(play)); + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); if (this->timer < 16) { z = Math_SinS(this->timer * 1024) * 1330.0f; } else { @@ -90,7 +90,7 @@ void OceffWipe4_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Xlu(play->state.gfxCtx); - Matrix_Translate(eye.x + vec.x, eye.y + vec.y, eye.z + vec.z, MTXMODE_NEW); + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.z + quakeOffset.z, MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 5905d18a17..7b3c4a0d55 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -6,6 +6,7 @@ #include "ultra64.h" #include "global.h" +#include "quake.h" #include "overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.h" #include "overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h" @@ -7690,16 +7691,16 @@ s32 func_80842964(Player* this, PlayState* play) { return func_8083B040(this, play) || func_8083B644(this, play) || func_8083E5A8(this, play); } -void func_808429B4(PlayState* play, s32 speed, s32 y, s32 countdown) { - s32 quakeIdx = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); +void Player_RequestQuake(PlayState* play, s32 speed, s32 y, s32 duration) { + s32 quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); - Quake_SetSpeed(quakeIdx, speed); - Quake_SetQuakeValues(quakeIdx, y, 0, 0, 0); - Quake_SetCountdown(quakeIdx, countdown); + Quake_SetSpeed(quakeIndex, speed); + Quake_SetPerturbations(quakeIndex, y, 0, 0, 0); + Quake_SetDuration(quakeIndex, duration); } void func_80842A28(PlayState* play, Player* this) { - func_808429B4(play, 27767, 7, 20); + Player_RequestQuake(play, 27767, 7, 20); play->actorCtx.unk_02 = 4; Player_RequestRumble(this, 255, 20, 150, 0); func_8002F7DC(&this->actor, NA_SE_IT_HAMMER_HIT); @@ -8209,7 +8210,7 @@ s32 func_80843E64(PlayState* play, Player* this) { } func_80837AE0(this, 40); - func_808429B4(play, 32967, 2, 30); + Player_RequestQuake(play, 32967, 2, 30); Player_RequestRumble(this, impactInfo->rumbleStrength, impactInfo->rumbleDuration, impactInfo->rumbleDecreaseRate, 0); func_8002F7DC(&this->actor, NA_SE_PL_BODY_HIT); @@ -8415,7 +8416,7 @@ void func_80844708(Player* this, PlayState* play) { func_80832264(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_17, this->modelAnimType)); this->linearVelocity = -this->linearVelocity; - func_808429B4(play, 33267, 3, 12); + Player_RequestQuake(play, 33267, 3, 12); Player_RequestRumble(this, 255, 20, 150, 0); func_8002F7DC(&this->actor, NA_SE_PL_BODY_HIT); func_80832698(this, NA_SE_VO_LI_CLIMB_END);