z_quake OK and documented (#213)

* Create z_quake.c file

* Match all quake functions with OoT counterparts (quake2 left)

* z_quake OK

* Document first half of quake

* More docs

* more cleanup

* remember to format!

* PR Suggestions

* More PR Suggestions
This commit is contained in:
engineer124 2021-07-20 09:06:54 +10:00 committed by GitHub
parent 184e67c841
commit b5c931e432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 969 additions and 206 deletions

View File

@ -2116,7 +2116,7 @@ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec);
VecSph* OLib_Vec3fToVecSphGeo(VecSph* dest, Vec3f* vec);
VecSph* OLib_Vec3fDiffToVecSph(VecSph* dest, Vec3f* a, Vec3f* b);
VecSph* OLib_Vec3fDiffToVecSphGeo(VecSph* dest, Vec3f* a, Vec3f* b);
Vec3f* OLib_VecSphToVec3fSum(Vec3f* dest, Vec3f* a, VecSph* sph);
Vec3f* OLib_VecSphAddToVec3f(Vec3f* dest, Vec3f* a, VecSph* sph);
Vec3f* OLib_Vec3fDiffRad(Vec3f* dest, Vec3f* a, Vec3f* b);
Vec3f* OLib_Vec3fDiffDegF(Vec3f* dest, Vec3f* a, Vec3f* b);
Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b);
@ -2317,37 +2317,37 @@ void PreNMI_Draw(PreNMIContext* prenmiCtx);
void PreNMI_Main(PreNMIContext* prenmiCtx);
void PreNMI_Destroy(PreNMIContext* prenmiCtx);
void PreNMI_Init(PreNMIContext* prenmiCtx);
// f32 Quake_Random(void);
void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x);
f32 Quake_Random(void);
void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPertubation, f32 horizontalPertubation);
s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake);
s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake);
s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake);
s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake);
s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake);
s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake);
// s16 Quake_GetFreeIndex(void);
QuakeRequest* Quake_AddImpl(Camera* cam, u32 callbackIdx);
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_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);
// void Quake_Init(void);
s16 Quake_Add(Camera* cam, u32 callbackIdx);
u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset);
u32 Quake_SetQuakeValues2(s16 idx, s16 isShakePerpendicular, Vec3s shakePlaneOffset);
void Quake_Init(void);
s16 Quake_Add(Camera* camera, u32 callbackIdx);
u32 Quake_RemoveFromIdx(s16 idx);
s16 Quake_Calc(Camera* camera, UnkQuakeCalcStruct* camData);
s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData);
void Quake2_Init(GlobalContext* globalCtx);
void Quake2_SetCountdown(s16 countdown);
// s32 Quake2_GetCountdown(void);
// s16 Quake2_GetType(void);
void Quake2_SetType(s16 type);
void Quake2_ClearType(s16 type);
u32 Quake2_GetFloorQuake(Player* player);
// void Quake2_Update(void);
// void Quake_NumActiveQuakes(void);
s16 Quake2_GetCountdown(void);
s16 Quake2_GetType(void);
void Quake2_SetType(s32 type);
void Quake2_ClearType(s32 type);
s32 Quake2_GetFloorQuake(Player* player);
void Quake2_Update(void);
s32 Quake_NumActiveQuakes(void);
Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f);
Gfx* Gfx_SetFogWithSync(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f);
Gfx* Gfx_SetFog2(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f);
@ -2757,8 +2757,8 @@ void func_8013EDD0(void);
// void func_8013EE48(void);
void View_ViewportToVp(Vp* dest, Viewport* src);
void View_Init(View* view, GraphicsContext* gfxCtx);
void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* focalPoint, Vec3f* upDir);
void func_8013F050(View* view, Vec3f* eye, Vec3f* focalPoint, Vec3f* upDir);
void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up);
void func_8013F050(View* view, Vec3f* eye, Vec3f* at, Vec3f* up);
void View_SetScale(View* view, f32 scale);
void View_GetScale(View* view, f32* scale);
void func_8013F0D0(View* view, f32 fovy, f32 zNear, f32 zFar);
@ -3047,7 +3047,7 @@ void func_80169590(GlobalContext* globalCtx, s16 param_2, s16 param_3);
void func_80169600(GlobalContext* globalCtx, s16 param_2);
// void func_80169668(void);
Camera* Play_GetCamera(GlobalContext* globalCtx, s16 index);
s32 func_8016970C(GlobalContext* globalCtx, s16 camId, Vec3f* focalPoint, Vec3f* eye);
s32 func_8016970C(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye);
// void func_8016981C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
// void func_80169940(void);
// void func_80169988(void);

View File

@ -1386,12 +1386,6 @@ extern UNK_PTR D_801C0B0C;
// extern UNK_TYPE1 D_801C0EA0;
// extern UNK_TYPE1 D_801C0EAC;
// extern UNK_TYPE1 D_801C0EB8;
// extern UNK_TYPE2 D_801C0EC0;
extern s16 sQuakeRequestCount;
extern quake_callback_func sQuakeCallbacks[7];
extern s16 D_801C0EE4;
extern s16 D_801C0EE8;
extern s16 D_801C0EEC;
extern Gfx sSetupDL[438];
extern Gfx sFillSetupDL[12];
extern Gfx gEmptyDL[1];
@ -3377,8 +3371,8 @@ extern s32* gNMIBuffer;
// extern UNK_TYPE1 D_801F59F0;
// extern UNK_TYPE1 D_801F59F4;
// extern UNK_TYPE1 D_801F59F8;
extern QuakeRequest sQuakeRequest[4];
extern Quake2Context sQuake2Context;
// extern QuakeRequest sQuakeRequest[4];
// extern Quake2Context sQuake2Context;
extern s32 sMatAnimStep;
extern u32 sMatAnimFlags;
extern f32 sMatAnimAlphaRatio;

View File

@ -323,12 +323,6 @@ typedef struct {
/* 0x10 */ u32 nRelocations;
} OverlayRelocationSection; // size = 0x14
typedef struct {
/* 0x0 */ s16 unk0;
/* 0x2 */ s16 unk2;
/* 0x4 */ s16 unk4;
} QuakeRequest14; // size = 0x6
typedef struct {
/* 0x00 */ s16 intPart[16];
/* 0x20 */ u16 fracPart[16];
@ -587,23 +581,6 @@ typedef struct {
/* 0x12 */ OSContPad rel; // X/Y store adjusted
} Input; // size = 0x18
typedef struct {
/* 0x00 */ Vec3f focalPointChange;
/* 0x0C */ Vec3f eyeChange;
/* 0x18 */ s16 rotZ;
/* 0x1A */ s16 zoom;
/* 0x1C */ UNK_TYPE1 pad1C[0x2];
} ShakeInfo; // size = 0x1E
typedef struct {
/* 0x00 */ Vec3f focalPointChange;
/* 0x0C */ Vec3f eyeChange;
/* 0x18 */ s16 unk18;
/* 0x1A */ s16 unk1A;
/* 0x1C */ f32 unk1C;
/* 0x20 */ f32 unk20;
} UnkQuakeCalcStruct; // size = 0x24
typedef struct {
/* 0x000 */ u32 magic;
/* 0x004 */ GraphicsContext* gfxCtx;
@ -613,8 +590,8 @@ typedef struct {
/* 0x020 */ f32 zFar;
/* 0x024 */ f32 scale;
/* 0x028 */ Vec3f eye;
/* 0x034 */ Vec3f focalPoint;
/* 0x040 */ Vec3f upDir;
/* 0x034 */ Vec3f at;
/* 0x040 */ Vec3f up;
/* 0x04C */ UNK_TYPE1 pad4C[0x4];
/* 0x050 */ Vp vp;
/* 0x060 */ Mtx projection;
@ -1253,13 +1230,6 @@ typedef void (*ColChkApplyFunc)(GlobalContext*, CollisionCheckContext*, Collider
typedef void (*ColChkVsFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Collider*);
typedef s32 (*ColChkLineFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*);
typedef struct {
/* 0x0 */ GlobalContext* globalCtx;
/* 0x4 */ s32 type; // bitfield, highest set bit determines type
/* 0x8 */ s16 countdown;
/* 0xA */ s16 state; // 0 - stopped, 1 - active, 2 - setup
} Quake2Context; // size = 0xC
typedef void(*cutscene_update_func)(GlobalContext* globalCtx, CutsceneContext* cCtxt);
typedef void(*draw_func)(GlobalContext* globalCtx, s16 index);
@ -1278,28 +1248,129 @@ typedef struct {
/* 0x20 */ u32 unk20;
} s801BB170; // size = 0x24
typedef struct Camera Camera;
typedef struct Camera {
/* 0x000 */ char paramData[0x50];
/* 0x050 */ Vec3f at;
/* 0x05C */ Vec3f eye;
/* 0x068 */ Vec3f up;
/* 0x074 */ Vec3f eyeNext;
/* 0x080 */ Vec3f skyboxOffset;
/* 0x08C */ struct GlobalContext* globalCtx;
/* 0x090 */ struct Player* player;
/* 0x094 */ PosRot playerPosRot;
/* 0x0A8 */ struct Actor* target;
/* 0x0AC */ PosRot targetPosRot;
/* 0x0C0 */ f32 rUpdateRateInv;
/* 0x0C4 */ f32 pitchUpdateRateInv;
/* 0x0C8 */ f32 yawUpdateRateInv;
/* 0x0CC */ f32 yOffsetUpdateRate;
/* 0x0D0 */ f32 xzOffsetUpdateRate;
/* 0x0D4 */ f32 fovUpdateRate;
/* 0x0D8 */ f32 xzSpeed;
/* 0x0DC */ f32 dist;
/* 0x0E0 */ f32 speedRatio;
/* 0x0E4 */ Vec3f posOffset;
/* 0x0F0 */ Vec3f playerPosDelta;
/* 0x0FC */ f32 fov;
/* 0x100 */ f32 atLERPStepScale;
/* 0x104 */ f32 playerGroundY;
/* 0x108 */ Vec3f floorNorm;
/* 0x114 */ f32 waterYPos;
/* 0x118 */ s32 waterPrevCamIdx;
/* 0x11C */ s32 waterPrevCamSetting;
/* 0x120 */ s16 waterQuakeId;
/* 0x122 */ s16 unk122;
/* 0x124 */ void* data0;
/* 0x128 */ void* data1;
/* 0x12C */ s16 data2;
/* 0x12E */ s16 data3;
/* 0x130 */ s16 uid;
/* 0x132 */ UNK_TYPE1 pad132[2];
/* 0x134 */ Vec3s inputDir;
/* 0x13A */ Vec3s camDir;
/* 0x140 */ s16 status;
/* 0x142 */ s16 setting;
/* 0x144 */ s16 mode;
/* 0x146 */ s16 bgCheckId;
/* 0x148 */ s16 camDataIdx;
/* 0x14A */ s16 flags1;
/* 0x14C */ s16 flags2;
/* 0x14E */ s16 childCamIdx;
/* 0x150 */ s16 unk150;
/* 0x152 */ s16 unk152;
/* 0x154 */ s16 prevSetting;
/* 0x156 */ s16 nextCamDataIdx;
/* 0x158 */ s16 nextBGCheckId;
/* 0x15A */ s16 roll;
/* 0x15C */ s16 paramFlags;
/* 0x15E */ s16 animState;
/* 0x160 */ s16 unk160;
/* 0x162 */ s16 timer;
/* 0x164 */ s16 thisIdx;
/* 0x166 */ s16 prevCamDataIdx;
/* 0x168 */ s16 unk168;
/* 0x16A */ s16 unk16A;
/* 0x16C */ Vec3f meshActorPos;
} Camera; // size = 0x178
typedef s32(*camera_update_func)(Camera* camera);
typedef struct {
/* 0x00 */ Vec3f atOffset;
/* 0x0C */ Vec3f eyeOffset;
/* 0x18 */ s16 rollOffset;
/* 0x1A */ s16 zoom;
} ShakeInfo; // size = 0x1C
typedef struct {
/* 0x00 */ s16 randIdx;
/* 0x02 */ s16 countdownMax;
/* 0x04 */ Camera* cam;
/* 0x04 */ Camera* camera;
/* 0x08 */ u32 callbackIdx;
/* 0x0C */ s16 y;
/* 0x0E */ s16 x;
/* 0x0C */ s16 verticalMag;
/* 0x0E */ s16 horizontalMag;
/* 0x10 */ s16 zoom;
/* 0x12 */ s16 rotZ;
/* 0x14 */ QuakeRequest14 unk14;
/* 0x12 */ s16 rollOffset;
/* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane
/* 0x1A */ s16 speed;
/* 0x1C */ s16 unk1C;
/* 0x1C */ s16 isShakePerpendicular;
/* 0x1E */ s16 countdown;
/* 0x20 */ s16 camPtrIdx;
/* 0x22 */ UNK_TYPE1 pad22[0x2];
/* 0x20 */ s16 cameraPtrsIdx;
} QuakeRequest; // size = 0x24
typedef s32(*camera_update_func)(Camera* camera);
typedef struct {
/* 0x00 */ Vec3f atOffset;
/* 0x0C */ Vec3f eyeOffset;
/* 0x18 */ s16 rollOffset;
/* 0x1A */ s16 zoom;
/* 0x1C */ f32 max; // Set to scaled max data of struct (mag for Vec3f), never used
} QuakeCamCalc; // size = 0x20
typedef s16(*quake_callback_func)(QuakeRequest* req, ShakeInfo* shake);
typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*);
#define QUAKE_SPEED (1 << 0)
#define QUAKE_VERTICAL_MAG (1 << 1)
#define QUAKE_HORIZONTAL_MAG (1 << 2)
#define QUAKE_ZOOM (1 << 3)
#define QUAKE_ROLL_OFFSET (1 << 4)
#define QUAKE_SHAKE_PLANE_OFFSET_X (1 << 5)
#define QUAKE_SHAKE_PLANE_OFFSET_Y (1 << 6)
#define QUAKE_SHAKE_PLANE_OFFSET_Z (1 << 7)
#define QUAKE_COUNTDOWN (1 << 8)
#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9)
typedef struct {
/* 0x0 */ GlobalContext* globalCtx;
/* 0x4 */ s32 type; // bitfield, highest set bit determines type
/* 0x8 */ s16 countdown;
/* 0xA */ s16 state;
} Quake2Context; // size = 0xC
typedef enum {
QUAKE2_INACTIVE,
QUAKE2_ACTIVE,
QUAKE2_SETUP,
} Quake2State;
typedef struct OSMesgQueueListNode_t {
/* 0x0 */ struct OSMesgQueueListNode_t* next;
@ -1413,70 +1484,6 @@ struct ActorListEntry {
/* 0x8 */ UNK_TYPE1 pad8[0x4];
}; // size = 0xC
struct Camera {
/* 0x000 */ UNK_TYPE1 pad0[0x4];
/* 0x004 */ Vec3f unk4;
/* 0x010 */ UNK_TYPE1 pad10[0x8];
/* 0x018 */ f32 unk18;
/* 0x01C */ s16 unk1C;
/* 0x01E */ s16 unk1E;
/* 0x020 */ Vec3f unk20;
/* 0x02C */ UNK_TYPE1 pad2C[0x2];
/* 0x02E */ s16 unk2E;
/* 0x030 */ UNK_TYPE1 pad30[0x10];
/* 0x040 */ s16 unk40;
/* 0x042 */ s16 unk42;
/* 0x044 */ UNK_TYPE1 pad44[0x8];
/* 0x04C */ s16 unk4C;
/* 0x04E */ UNK_TYPE1 pad4E[0x2];
/* 0x050 */ Vec3f focalPoint;
/* 0x05C */ Vec3f eye;
/* 0x068 */ Vec3f upDir;
/* 0x074 */ Vec3f unk74;
/* 0x080 */ f32 unk80;
/* 0x084 */ f32 unk84;
/* 0x088 */ f32 unk88;
/* 0x08C */ GlobalContext* globalCtx;
/* 0x090 */ Player* player;
/* 0x094 */ PosRot unk94;
/* 0x0A8 */ Actor* unkA8;
/* 0x0AC */ Vec3f unkAC;
/* 0x0B8 */ UNK_TYPE1 padB8[0x8];
/* 0x0C0 */ f32 unkC0;
/* 0x0C4 */ f32 unkC4;
/* 0x0C8 */ f32 unkC8;
/* 0x0CC */ f32 unkCC;
/* 0x0D0 */ f32 unkD0;
/* 0x0D4 */ f32 unkD4;
/* 0x0D8 */ UNK_TYPE1 padD8[0x4];
/* 0x0DC */ f32 unkDC;
/* 0x0E0 */ f32 unkE0;
/* 0x0E4 */ UNK_TYPE1 padE4[0x18];
/* 0x0FC */ f32 fov;
/* 0x100 */ f32 unk100;
/* 0x104 */ UNK_TYPE1 pad104[0x30];
/* 0x134 */ Vec3s unk134;
/* 0x13A */ UNK_TYPE1 pad13A[0x4];
/* 0x13E */ u16 unk13E;
/* 0x140 */ s16 unk140;
/* 0x142 */ s16 state;
/* 0x144 */ s16 mode;
/* 0x146 */ UNK_TYPE1 pad146[0x2];
/* 0x148 */ s16 unk148;
/* 0x14A */ s16 unk14A;
/* 0x14C */ s16 unk14C;
/* 0x14E */ UNK_TYPE1 pad14E[0x6];
/* 0x154 */ s16 unk154;
/* 0x156 */ UNK_TYPE1 pad156[0x4];
/* 0x15A */ s16 unk15A;
/* 0x15C */ s16 unk15C;
/* 0x15E */ s16 unk15E;
/* 0x160 */ UNK_TYPE1 pad160[0x4];
/* 0x164 */ s16 unk164;
/* 0x166 */ s16 unk166;
/* 0x168 */ UNK_TYPE1 pad168[0x10];
}; // size = 0x178
typedef struct {
/* 0x00 */ MtxF displayMatrix;
/* 0x40 */ Actor* actor;

View File

@ -404,7 +404,7 @@ SECTIONS
build/asm/code/code_0x80122660.o(.text)
build/asm/code/z_player_lib.o(.text)
build/src/code/z_prenmi.o(.text)
build/asm/code/code_0x8012A080.o(.text)
build/src/code/z_quake.o(.text)
build/src/code/z_rcp.o(.text)
. += 0x10;
build/src/code/z_room.o(.text)
@ -525,7 +525,7 @@ SECTIONS
build/asm/code/code_data_z_msgevent.o(.data)
build/asm/code/code_data_z_parameter.o(.data)
build/asm/code/code_data_z_player_lib.o(.data)
build/asm/code/code_data_0x8012A080.o(.data)
build/src/code/z_quake.o(.data)
build/src/code/z_rcp.o(.data)
build/asm/code/code_data_z_room.o(.data)
build/src/code/code_0x8012EC80.o(.data)
@ -600,7 +600,7 @@ SECTIONS
build/src/code/z_olib.o(.rodata)
build/asm/code/code_rodata_z_parameter.o(.rodata)
build/asm/code/code_rodata_z_player_lib.o(.rodata)
build/asm/code/code_rodata_0x8012A080.o(.rodata)
build/src/code/z_quake.o(.rodata)
build/asm/code/code_rodata_z_room.o(.rodata)
build/src/code/code_0x8012EC80.o(.rodata)
build/src/code/z_scene_proc.o(.rodata)
@ -675,7 +675,7 @@ SECTIONS
. += 0x10; /* code_0x8010C0C0 */
. += 0x60; /* z_parameter */
. += 0x150; /* z_player_lib */
. += 0xA0; /* code_0x8012A080 */
. += 0xA0; /* z_quake */
. += 0x10; /* z_scene_proc */
. += 0x10; /* z_skelanime */
. += 0xF10; /* z_skin */

View File

@ -180,8 +180,9 @@ VecSph* OLib_Vec3fDiffToVecSphGeo(VecSph* dest, Vec3f* a, Vec3f* b) {
/**
* Takes the sum of positions `a` (x,y,z coordinates) and `sph` (geographic coordinates), result is in x,y,z position
* Identical to Quake_AddVec from OoT
*/
Vec3f* OLib_VecSphToVec3fSum(Vec3f* dest, Vec3f* a, VecSph* sph) {
Vec3f* OLib_VecSphAddToVec3f(Vec3f* dest, Vec3f* a, VecSph* sph) {
Vec3f vec;
Vec3f b;
@ -279,7 +280,7 @@ void OLib_DbCameraVec3fSum(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode) {
case 1:
OLib_Vec3fToVecSphGeo(&sph, b);
sph.yaw += a->rot.y;
OLib_VecSphToVec3fSum(dest, &a->pos, &sph);
OLib_VecSphAddToVec3f(dest, &a->pos, &sph);
break;
case 2:
dest->x = a->pos.x + b->x;

759
src/code/z_quake.c Normal file
View File

@ -0,0 +1,759 @@
#include "global.h"
QuakeRequest sQuakeRequest[4];
Quake2Context sQuake2Context;
static s16 sIsQuakeInitialized = true;
static s16 sQuakeRequestCount = 0;
f32 Quake_Random(void) {
return 2.0f * (Rand_ZeroOne() - 0.5f);
}
void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPertubation, f32 horizontalPertubation) {
Vec3f* at = &req->camera->at;
Vec3f* eye = &req->camera->eye;
Vec3f atEyeOffset;
VecSph atEyeOffsetSph2;
VecSph eyeAtAngle;
// isShakePerpendicular is always set to 1 before reaching this conditional
// alternative is an unused fixed vertical shake
if (req->isShakePerpendicular) {
atEyeOffset.x = 0;
atEyeOffset.y = 0;
atEyeOffset.z = 0;
OLib_Vec3fDiffToVecSphGeo(&eyeAtAngle, eye, at);
atEyeOffsetSph2.r = req->verticalMag * verticalPertubation;
atEyeOffsetSph2.pitch = eyeAtAngle.pitch + req->shakePlaneOffset.x + 0x4000;
atEyeOffsetSph2.yaw = eyeAtAngle.yaw + req->shakePlaneOffset.y;
OLib_VecSphAddToVec3f(&atEyeOffset, &atEyeOffset, &atEyeOffsetSph2);
atEyeOffsetSph2.r = req->horizontalMag * horizontalPertubation;
atEyeOffsetSph2.pitch = eyeAtAngle.pitch + req->shakePlaneOffset.x;
atEyeOffsetSph2.yaw = eyeAtAngle.yaw + req->shakePlaneOffset.y + 0x4000;
OLib_VecSphAddToVec3f(&atEyeOffset, &atEyeOffset, &atEyeOffsetSph2);
} else {
atEyeOffset.x = 0;
atEyeOffset.y = req->verticalMag * verticalPertubation;
atEyeOffset.z = 0;
atEyeOffsetSph2.r = req->horizontalMag * horizontalPertubation;
atEyeOffsetSph2.pitch = req->shakePlaneOffset.x;
atEyeOffsetSph2.yaw = req->shakePlaneOffset.y;
OLib_VecSphAddToVec3f(&atEyeOffset, &atEyeOffset, &atEyeOffsetSph2);
}
shake->atOffset = shake->eyeOffset = atEyeOffset;
shake->rollOffset = req->rollOffset * verticalPertubation;
shake->zoom = req->zoom * verticalPertubation;
}
s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown);
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation);
req->countdown--;
}
return req->countdown;
}
s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown);
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, perpendicularPertubation);
req->countdown--;
}
return req->countdown;
}
s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) {
f32 perpendicularPertubation;
req->countdown--;
perpendicularPertubation = Math_SinS(req->speed * ((req->countdown & 0xF) + 500));
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation);
return 1;
}
s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation =
Math_SinS(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax);
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, perpendicularPertubation);
req->countdown--;
}
return req->countdown;
}
s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Quake_Random();
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation);
req->countdown--;
}
return req->countdown;
}
s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Quake_Random() * ((f32)req->countdown / (f32)req->countdownMax);
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation);
req->countdown--;
}
return req->countdown;
}
s16 Quake_GetFreeIndex(void) {
s32 i;
s32 ret = 0;
s32 min = 0x10000;
for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) {
if (sQuakeRequest[i].callbackIdx == 0) {
ret = i;
break;
}
if (sQuakeRequest[i].countdown < min) {
min = sQuakeRequest[i].countdown;
ret = i;
}
}
return ret;
}
QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx) {
s16 idx = Quake_GetFreeIndex();
QuakeRequest* req = &sQuakeRequest[idx];
func_80096880(req, 0, sizeof(QuakeRequest)); // memset
req->camera = camera;
req->cameraPtrsIdx = camera->thisIdx;
req->callbackIdx = callbackIdx;
req->isShakePerpendicular = true;
req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx;
sQuakeRequestCount++;
return req;
}
void Quake_Remove(QuakeRequest* req) {
req->callbackIdx = 0;
req->countdown = -1;
sQuakeRequestCount--;
}
QuakeRequest* Quake_GetRequest(s16 idx) {
QuakeRequest* req = &sQuakeRequest[idx & 3];
if (req->callbackIdx == 0) {
return NULL;
}
if (idx != req->randIdx) {
return NULL;
}
return req;
}
u32 Quake_SetValue(s16 idx, s16 valueType, s16 value) {
QuakeRequest* req = Quake_GetRequest(idx);
if (req == NULL) {
return false;
} else {
switch (valueType) {
case QUAKE_SPEED:
req->speed = value;
break;
case QUAKE_VERTICAL_MAG:
req->verticalMag = value;
break;
case QUAKE_HORIZONTAL_MAG:
req->horizontalMag = value;
break;
case QUAKE_ZOOM:
req->zoom = value;
break;
case QUAKE_ROLL_OFFSET:
req->rollOffset = value;
break;
case QUAKE_SHAKE_PLANE_OFFSET_X:
req->shakePlaneOffset.x = value;
break;
case QUAKE_SHAKE_PLANE_OFFSET_Y:
req->shakePlaneOffset.y = value;
break;
case QUAKE_SHAKE_PLANE_OFFSET_Z:
req->shakePlaneOffset.z = value;
break;
case QUAKE_COUNTDOWN:
req->countdown = value;
req->countdownMax = req->countdown;
break;
case QUAKE_IS_SHAKE_PERPENDICULAR:
req->isShakePerpendicular = value;
break;
}
return true;
}
}
u32 Quake_SetSpeed(s16 idx, s16 value) {
QuakeRequest* req = Quake_GetRequest(idx);
if (req != NULL) {
req->speed = value;
return true;
}
return false;
}
u32 Quake_SetCountdown(s16 idx, s16 value) {
QuakeRequest* req = Quake_GetRequest(idx);
if (req != NULL) {
req->countdown = value;
req->countdownMax = req->countdown;
return true;
}
return false;
}
s16 Quake_GetCountdown(s16 idx) {
QuakeRequest* req = Quake_GetRequest(idx);
if (req != NULL) {
return req->countdown;
}
return 0;
}
u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) {
QuakeRequest* req = Quake_GetRequest(idx);
if (req != NULL) {
req->verticalMag = verticalMag;
req->horizontalMag = horizontalMag;
req->zoom = zoom;
req->rollOffset = rollOffset;
return true;
}
return false;
}
u32 Quake_SetQuakeValues2(s16 idx, s16 isShakePerpendicular, Vec3s shakePlaneOffset) {
QuakeRequest* req = Quake_GetRequest(idx);
if (req != NULL) {
req->isShakePerpendicular = isShakePerpendicular;
req->shakePlaneOffset = shakePlaneOffset;
return true;
}
return false;
}
void Quake_Init(void) {
s16 i;
for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) {
sQuakeRequest[i].callbackIdx = 0;
sQuakeRequest[i].countdown = 0;
}
sIsQuakeInitialized = true;
sQuakeRequestCount = 0;
}
s16 Quake_Add(Camera* camera, u32 callbackIdx) {
return Quake_AddImpl(camera, callbackIdx)->randIdx;
}
u32 Quake_RemoveFromIdx(s16 idx) {
QuakeRequest* req = Quake_GetRequest(idx);
if (req != NULL) {
Quake_Remove(req);
return true;
}
return false;
}
static QuakeCallbackFunc sQuakeCallbacks[] = {
NULL, Quake_Callback1, Quake_Callback2, Quake_Callback3, Quake_Callback4, Quake_Callback5, Quake_Callback6,
};
s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
s32 pad;
QuakeRequest* req;
ShakeInfo shake;
f32 absSpeedDiv;
f32 maxCurr;
f32 maxNext;
s32 idx;
s32 ret;
u32 eq;
Vec3f originVec;
GlobalContext* globalCtx = camera->globalCtx;
originVec.x = 0.0f;
originVec.y = 0.0f;
originVec.z = 0.0f;
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->rollOffset = 0;
camData->zoom = 0;
camData->max = 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 (globalCtx->cameraPtrs[req->cameraPtrsIdx] == NULL) {
Quake_Remove(req);
} else {
eq = (camera->thisIdx != req->camera->thisIdx);
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.atOffset.x)) {
camData->atOffset.x = shake.atOffset.x;
}
if (fabsf(camData->atOffset.y) < fabsf(shake.atOffset.y)) {
camData->atOffset.y = shake.atOffset.y;
}
if (fabsf(camData->atOffset.z) < fabsf(shake.atOffset.z)) {
camData->atOffset.z = shake.atOffset.z;
}
if (fabsf(camData->eyeOffset.x) < fabsf(shake.eyeOffset.x)) {
camData->eyeOffset.x = shake.eyeOffset.x;
}
if (fabsf(camData->eyeOffset.y) < fabsf(shake.eyeOffset.y)) {
camData->eyeOffset.y = shake.eyeOffset.y;
}
if (fabsf(camData->eyeOffset.z) < fabsf(shake.eyeOffset.z)) {
camData->eyeOffset.z = shake.eyeOffset.z;
}
if (camData->rollOffset < shake.rollOffset) {
camData->rollOffset = shake.rollOffset;
}
if (camData->zoom < shake.zoom) {
camData->zoom = shake.zoom;
}
maxCurr = OLib_Vec3fDist(&shake.atOffset, &originVec) * absSpeedDiv;
maxNext = OLib_Vec3fDist(&shake.eyeOffset, &originVec) * absSpeedDiv;
maxCurr = CLAMP_MIN(maxCurr, maxNext);
maxNext = (camData->rollOffset * (7.0f / 2500.0f)) * absSpeedDiv;
maxCurr = CLAMP_MIN(maxCurr, maxNext);
maxNext = (camData->zoom * (7.0f / 2500.0f)) * absSpeedDiv;
maxCurr = CLAMP_MIN(maxCurr, maxNext);
if (camData->max < maxCurr) {
camData->max = maxCurr;
}
ret++;
}
}
}
}
return ret;
}
void Quake2_Init(GlobalContext* globalCtx) {
sQuake2Context.globalCtx = globalCtx;
View_ClearQuake(&globalCtx->view);
sQuake2Context.type = 0;
sQuake2Context.countdown = 0;
sQuake2Context.state = QUAKE2_INACTIVE;
}
void Quake2_SetCountdown(s16 countdown) {
sQuake2Context.countdown = countdown;
sQuake2Context.state = QUAKE2_SETUP;
}
s16 Quake2_GetCountdown(void) {
return sQuake2Context.countdown;
}
s16 Quake2_GetType(void) {
return sQuake2Context.type;
}
void Quake2_SetType(s32 type) {
if (sQuake2Context.type < type) {
sQuake2Context.type = type;
}
}
void Quake2_ClearType(s32 type) {
if (sQuake2Context.type == type) {
sQuake2Context.type = 0;
}
}
s32 Quake2_GetFloorQuake(Player* player) {
if (func_800C9D8C(&sQuake2Context.globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 0) {
return func_800C9E18(&sQuake2Context.globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId);
}
return 0;
}
void Quake2_Update(void) {
static s16 angle1 = 0x3F0;
static s16 angle2 = 0x156;
static s16 countdownMax = 1;
f32 xyScaleFactor;
f32 zScaleFactor;
f32 speedScaleFactor;
f32 countdownRatio;
f32 waterYScaleFactor;
f32 angle1Speed;
f32 angle2Speed;
f32 rotX;
f32 rotY;
f32 rotZ;
f32 xScale;
f32 yScale;
f32 zScale;
f32 speed;
Player* player;
GlobalContext* globalCtx = sQuake2Context.globalCtx;
PosRot playerPosRot;
Camera* camera = globalCtx->cameraPtrs[globalCtx->activeCamera];
f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f);
if (sQuake2Context.type != 0) {
if (sQuake2Context.type & 0x800) {
sQuake2Context.countdown = 2;
angle1 = 0x3F0;
angle2 = 0x156;
angle1Speed = 0.0f;
angle2Speed = 170.0f;
rotX = 0.0f;
rotY = 0.0f;
rotZ = 0.0f;
xScale = -0.01f;
yScale = 0.01f;
zScale = 0.0f;
speed = 0.6f;
xyScaleFactor = zScaleFactor = sQuake2Context.countdown / 60.0f;
speedScaleFactor = 1.0f;
} else if (sQuake2Context.type & 0x400) {
if (sQuake2Context.state == QUAKE2_SETUP) {
countdownMax = sQuake2Context.countdown;
angle1 = 0x3F0;
angle2 = 0x156;
}
angle1Speed = 0.0f;
angle2Speed = 50.0f / countdownMax;
rotX = 0.0f;
rotY = 0.0f;
rotZ = 0.0f;
xScale = 0.01f;
yScale = 100.0f;
zScale = 0.0f;
speed = 0.4f;
xyScaleFactor = zScaleFactor = ((f32)countdownMax - sQuake2Context.countdown) / (f32)countdownMax;
speedScaleFactor = 0.5f;
} else if (sQuake2Context.type & 0x200) {
if (sQuake2Context.state == QUAKE2_SETUP) {
countdownMax = sQuake2Context.countdown;
angle1 = 0x1FC;
angle2 = 0x156;
}
angle1Speed = -5.0f;
angle2Speed = 5.0f;
rotX = 0.0f;
rotY = 0.0f;
rotZ = 2.0f;
xScale = 0.3f;
yScale = 0.3f;
zScale = 0.0f;
speed = 0.1f;
xyScaleFactor = zScaleFactor = ((f32)countdownMax - sQuake2Context.countdown) / (f32)countdownMax;
speedScaleFactor = 1.0f;
} else if (sQuake2Context.type & 0x100) {
if (sQuake2Context.state == QUAKE2_SETUP) {
countdownMax = sQuake2Context.countdown;
angle1 = 0x2710;
angle2 = 0x3E8;
}
angle1Speed = 0.0f;
angle2Speed = 150.0f;
rotX = 0;
rotY = 0;
rotZ = 0.2f;
xScale = 0.025f;
yScale = 0.02f;
zScale = 0.01f;
speed = 1.5f;
if (sQuake2Context.countdown < 5) {
xyScaleFactor = zScaleFactor = ((f32)countdownMax - sQuake2Context.countdown) / (f32)countdownMax;
} else {
xyScaleFactor = zScaleFactor = 0.0f;
}
speedScaleFactor = 1.0f;
} else if (sQuake2Context.type & 0x80) {
if (sQuake2Context.state == QUAKE2_SETUP) {
countdownMax = sQuake2Context.countdown;
angle1 = 0x4B0;
angle2 = 0x7D0;
}
angle1Speed = 0.0f;
angle2Speed = 150.0f;
rotX = 0;
rotY = 0;
rotZ = 0;
xScale = 0.03f;
yScale = 0.02f;
zScale = 0.01f;
speed = 1.5f;
xyScaleFactor = zScaleFactor = sQuake2Context.countdown / (f32)countdownMax;
speedScaleFactor = 1.0f;
} else if (sQuake2Context.type & 0x40) {
if (sQuake2Context.state == QUAKE2_SETUP) {
countdownMax = sQuake2Context.countdown;
angle1 = 0x9C4;
angle2 = 0xBB8;
}
angle1Speed = 0.0f;
angle2Speed = 150.0f;
rotX = 0;
rotY = 0;
rotZ = 0;
xScale = 0.03f;
yScale = 0.03f;
zScale = 0.01f;
speed = 1.3f;
if (sQuake2Context.countdown < 4) {
xyScaleFactor = zScaleFactor = sQuake2Context.countdown / (f32)countdownMax;
} else {
xyScaleFactor = zScaleFactor = 0.0f;
}
speedScaleFactor = 1.0f;
} else if (sQuake2Context.type & 0x20) {
sQuake2Context.countdown = 2;
if (sQuake2Context.state == QUAKE2_SETUP) {
angle1 = 0x9C4;
angle2 = 0xBB8;
}
angle1 += 0xB1;
angle2 -= 0x2B;
angle1Speed = -107.0f;
angle2Speed = 158.0f;
rotX = 0.2f;
rotY = 1.7f;
rotZ = -2.9f;
xScale = -0.6f;
yScale = -0.7f;
zScale = 0.6f;
speed = 0.2f;
zScaleFactor = 1.0f;
xyScaleFactor = 1.0f;
speedScaleFactor = 1.0f;
} else if (sQuake2Context.type & 0x10) {
if (sQuake2Context.state == QUAKE2_SETUP) {
countdownMax = sQuake2Context.countdown;
angle1 = 0x760;
angle2 = 0x1BC;
}
angle1Speed = 248.0f;
angle2Speed = -90.0f;
rotX = 0.0f;
rotY = 0.0f;
rotZ = 0.0f;
xScale = -0.4f;
yScale = 0.4f;
zScale = 0.2f;
speed = 0.25f;
countdownRatio = sQuake2Context.countdown / (f32)countdownMax;
zScaleFactor = xyScaleFactor = countdownRatio;
speedScaleFactor = 1.0f;
} else if (sQuake2Context.type & 8) {
angle1 = 0x3F0;
angle2 = 0x156;
sQuake2Context.countdown = 2;
player = PLAYER;
if (&player->actor != NULL) {
func_800B8248(&playerPosRot, player);
}
angle1Speed = 359.2f;
angle2Speed = -18.5f;
rotX = 0.0f;
rotY = 0.0f;
rotZ = 0.3f;
switch (Quake2_GetFloorQuake(player)) {
case 3:
xScale = -0.06f;
yScale = 0.1f;
zScale = 0.03f;
speed = 0.33f;
break;
case 2:
xScale = -0.06f;
yScale = 0.1f;
zScale = 0.03f;
speed = 0.33f;
break;
case 1:
xScale = -0.06f;
yScale = 0.1f;
zScale = 0.03f;
speed = 0.33f;
break;
default:
xScale = -0.06f;
yScale = 0.1f;
zScale = 0.03f;
speed = 0.23f;
break;
}
if (player->unk_B88 < 0) {
xyScaleFactor = (player->unk_B88 - (f32)0x4000) / (f32)0xC000;
} else {
xyScaleFactor = (player->unk_B88 + (f32)0x4000) / (f32)0xC000;
}
zScaleFactor = -xyScaleFactor;
speedScaleFactor = 1.0f;
} else if (sQuake2Context.type & 4) {
angle1 = 0x3F0;
angle2 = 0x156;
sQuake2Context.countdown = 2;
player = PLAYER;
angle1Speed = 359.2f;
angle2Speed = -18.5f;
rotX = 0.0f;
rotY = 0.0f;
rotZ = 0.0f;
switch (Quake2_GetFloorQuake(player)) {
case 3:
xScale = 0.12f;
yScale = 0.12f;
zScale = 0.08f;
speed = 0.18f;
break;
case 2:
xScale = 0.12f;
yScale = 0.12f;
zScale = 0.08f;
speed = 0.12f;
break;
case 1:
xScale = 0.12f;
yScale = 0.12f;
zScale = 0.08f;
speed = 0.08f;
break;
default:
xScale = 0.12f;
yScale = 0.12f;
zScale = 0.08f;
speed = 0.05f;
break;
}
if ((camera->waterYPos - camera->eye.y) > 2000.0f) {
waterYScaleFactor = 1.0f;
} else {
waterYScaleFactor = (camera->waterYPos - camera->eye.y) / 2000.0f;
}
xyScaleFactor = speedScaleFactor = (waterYScaleFactor * 0.15f) + 0.35f + (speedRatio * 0.4f);
zScaleFactor = 0.9f - xyScaleFactor;
} else if (sQuake2Context.type & 1) {
angle1 = 0x3F0;
angle2 = 0x156;
sQuake2Context.countdown = 2;
angle1Speed = 0.0f;
angle2Speed = 150.0f;
rotX = 0.0f;
rotY = 0.0f;
rotZ = 0.0f;
xScale = -0.01f;
yScale = 0.01f;
zScale = 0.01f;
speed = 0.6f;
speedScaleFactor = 1.0f;
zScaleFactor = 1.0f;
xyScaleFactor = 1.0f;
} else {
return;
}
angle1 += DEGF_TO_BINANG(angle1Speed);
angle2 += DEGF_TO_BINANG(angle2Speed);
View_SetQuakeRotation(&sQuake2Context.globalCtx->view, Math_CosS(angle1) * (DEGF_TO_RADF(rotX) * xyScaleFactor),
Math_SinS(angle1) * (DEGF_TO_RADF(rotY) * xyScaleFactor),
Math_SinS(angle2) * (DEGF_TO_RADF(rotZ) * zScaleFactor));
View_SetQuakeScale(&sQuake2Context.globalCtx->view, (Math_SinS(angle2) * (xScale * xyScaleFactor)) + 1.0f,
(Math_CosS(angle2) * (yScale * xyScaleFactor)) + 1.0f,
(Math_CosS(angle1) * (zScale * zScaleFactor)) + 1.0f);
View_SetQuakeSpeed(&sQuake2Context.globalCtx->view, speed * speedScaleFactor);
sQuake2Context.state = QUAKE2_ACTIVE;
} else if (sQuake2Context.state != QUAKE2_INACTIVE) {
View_ClearQuake(&globalCtx->view);
sQuake2Context.state = QUAKE2_INACTIVE;
sQuake2Context.countdown = 0;
}
if (sQuake2Context.countdown != 0) {
sQuake2Context.countdown--;
if (sQuake2Context.countdown == 0) {
sQuake2Context.type = 0;
}
}
}
s32 Quake_NumActiveQuakes(void) {
QuakeRequest* req = sQuakeRequest;
s32 numActiveQuakes = 0;
if (req[0].callbackIdx != 0) {
numActiveQuakes++;
}
if (req[1].callbackIdx != 0) {
numActiveQuakes++;
}
if (req[2].callbackIdx != 0) {
numActiveQuakes++;
}
if (req[3].callbackIdx != 0) {
numActiveQuakes++;
}
return numActiveQuakes;
}

View File

@ -33,13 +33,13 @@ void View_Init(View* view, GraphicsContext* gfxCtx) {
}
view->scale = 1.0f;
view->upDir.y = 1.0f;
view->up.y = 1.0f;
view->fovy = 60.0f;
view->eye.x = 0.0f;
view->eye.y = 0.0f;
view->focalPoint.x = 0.0f;
view->upDir.x = 0.0f;
view->upDir.z = 0.0f;
view->at.x = 0.0f;
view->up.x = 0.0f;
view->up.z = 0.0f;
view->zNear = 10.0f;
view->zFar = 12800.0f;
view->eye.z = -1.0f;
@ -47,24 +47,24 @@ void View_Init(View* view, GraphicsContext* gfxCtx) {
View_InitCameraQuake(view);
}
void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* focalPoint, Vec3f* upDir) {
if (eye->x == focalPoint->x && eye->z == focalPoint->z) {
void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) {
if (eye->x == at->x && eye->z == at->z) {
eye->z += 0.1f;
upDir->z = 0.0f;
upDir->x = 0.0f;
upDir->y = 1.0f;
up->z = 0.0f;
up->x = 0.0f;
up->y = 1.0f;
}
view->eye = *eye;
view->focalPoint = *focalPoint;
view->upDir = *upDir;
view->at = *at;
view->up = *up;
view->flags |= 1;
}
void func_8013F050(View* view, Vec3f* eye, Vec3f* focalPoint, Vec3f* upDir) {
void func_8013F050(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) {
view->eye = *eye;
view->focalPoint = *focalPoint;
view->upDir = *upDir;
view->at = *at;
view->up = *up;
}
void View_SetScale(View* view, f32 scale) {
@ -321,12 +321,12 @@ s32 View_RenderToPerspectiveMatrix(View* view) {
viewing = GRAPH_ALLOC(gfxCtx, sizeof(*viewing));
view->viewingPtr = viewing;
if (view->eye.x == view->focalPoint.x && view->eye.y == view->focalPoint.y && view->eye.z == view->focalPoint.z) {
if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) {
view->eye.z += 2.0f;
}
guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->focalPoint.x, view->focalPoint.y, view->focalPoint.z,
view->upDir.x, view->upDir.y, view->upDir.z);
guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y,
view->up.z);
view->viewing = *viewing;
@ -455,12 +455,12 @@ s32 func_8013FD74(View* view) {
viewing = GRAPH_ALLOC(gfxCtx, sizeof(*viewing));
view->viewingPtr = viewing;
if (view->eye.x == view->focalPoint.x && view->eye.y == view->focalPoint.y && view->eye.z == view->focalPoint.z) {
if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) {
view->eye.z += 2.0f;
}
guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->focalPoint.x, view->focalPoint.y, view->focalPoint.z,
view->upDir.x, view->upDir.y, view->upDir.z);
guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y,
view->up.z);
view->viewing = *viewing;
@ -472,8 +472,8 @@ s32 func_8013FD74(View* view) {
}
s32 func_80140024(View* view) {
guLookAt(view->viewingPtr, view->eye.x, view->eye.y, view->eye.z, view->focalPoint.x, view->focalPoint.y,
view->focalPoint.z, view->upDir.x, view->upDir.y, view->upDir.z);
guLookAt(view->viewingPtr, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x,
view->up.y, view->up.z);
view->unkE0 = *view->viewingPtr;
view->viewingPtr = &view->unkE0;

View File

@ -64,12 +64,12 @@ void func_80C0A838(BgIkninSusceil* this, GlobalContext* globalCtx) {
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
}
void func_80C0A86C(BgIkninSusceil* this, GlobalContext* globalCtx, s16 y, s16 countdown, s32 arg4) {
void func_80C0A86C(BgIkninSusceil* this, GlobalContext* globalCtx, s16 verticalMag, s16 countdown, s32 arg4) {
s32 pad;
s16 quake = Quake_Add(ACTIVE_CAM, 3);
Quake_SetSpeed(quake, 0x7B30);
Quake_SetQuakeValues(quake, y, 0, 0, 0);
Quake_SetQuakeValues(quake, verticalMag, 0, 0, 0);
Quake_SetCountdown(quake, countdown);
if (arg4 == 1) {
func_8013ECE0(10000.0f, 255, 20, 150);
@ -191,7 +191,7 @@ void func_80C0AD64(BgIkninSusceil* this, GlobalContext* globalCtx) {
this->dyna.actor.velocity.y *= 0.98f;
if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 365.0f, 0.5f,
this->dyna.actor.velocity.y, 1.0f) < 0.1f) {
func_80C0A86C(this, globalCtx, 1, 0xE, 3);
func_80C0A86C(this, globalCtx, 1, 14, 3);
ActorCutscene_Stop(this->dyna.actor.cutscene);
func_80C0AB14(this);
} else {

View File

@ -47,7 +47,7 @@ const ActorInit En_Guruguru_InitVars = {
};
static u16 textIDs[] = { 0x292A, 0x292B, 0x292C, 0x292D, 0x292E, 0x292F, 0x2930, 0x2931,
0x2932, 0x2933, 0x2934, 0x2935, 0x2936, 0x294D, 0x294E };
0x2932, 0x2933, 0x2934, 0x2935, 0x2936, 0x294D, 0x294E };
static ColliderCylinderInit sCylinderInit = {
{
@ -80,8 +80,7 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) {
this->actor.colChkInfo.mass = MASS_IMMOVABLE;
ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 19.0f);
SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06006C90, &D_06000B04, this->jointTable, this->morphTable,
16);
SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06006C90, &D_06000B04, this->jointTable, this->morphTable, 16);
this->actor.targetMode = 0;
if (this->actor.params != 2) {
Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
@ -375,9 +374,10 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) {
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
}
s32 EnGuruguru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) {
s32 EnGuruguru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
Actor* thisx) {
EnGuruguru* this = THIS;
if (limbIndex == 14) {
rot->x += this->headXRot;
rot->z += this->headZRot;

View File

@ -269,9 +269,9 @@ void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) {
Actor* attackNiw;
if ((this->unkTimer252 == 0) && (this->unk290 < 7)) {
xView = globalCtx->view.focalPoint.x - globalCtx->view.eye.x;
yView = globalCtx->view.focalPoint.y - globalCtx->view.eye.y;
zView = globalCtx->view.focalPoint.z - globalCtx->view.eye.z;
xView = globalCtx->view.at.x - globalCtx->view.eye.x;
yView = globalCtx->view.at.y - globalCtx->view.eye.y;
zView = globalCtx->view.at.z - globalCtx->view.eye.z;
newNiwPos.x = ((Rand_ZeroOne() - 0.5f) * xView) + globalCtx->view.eye.x;
newNiwPos.y = randPlusMinusPoint5Scaled(0.3f) + (globalCtx->view.eye.y + 50.0f + (yView * 0.5f));
newNiwPos.z = ((Rand_ZeroOne() - 0.5f) * zView) + globalCtx->view.eye.z;
@ -835,9 +835,9 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) {
if ((this->actor.floorHeight <= BGCHECK_Y_MIN) || (this->actor.floorHeight >= 32000.0f)) {
// if cucco is off the map?
Vec3f camera;
camera.x = globalCtx->view.focalPoint.x - globalCtx->view.eye.x;
camera.y = globalCtx->view.focalPoint.y - globalCtx->view.eye.y;
camera.z = globalCtx->view.focalPoint.z - globalCtx->view.eye.z;
camera.x = globalCtx->view.at.x - globalCtx->view.eye.x;
camera.y = globalCtx->view.at.y - globalCtx->view.eye.y;
camera.z = globalCtx->view.at.z - globalCtx->view.eye.z;
camResult = camera.y / sqrtf(SQXYZ(camera));
this->actor.world.pos.x = this->actor.home.pos.x;

View File

@ -341,10 +341,10 @@ void EnPametfrog_ShakeCamera(EnPametfrog* this, GlobalContext* globalCtx, f32 ma
Vec3f eye;
y = BINANG_ROT180(func_800DFCDC(camera));
eye.x = (Math_SinS(y) * magShakeXZ) + camera->focalPoint.x;
eye.y = camera->focalPoint.y + magShakeY;
eye.z = (Math_CosS(y) * magShakeXZ) + camera->focalPoint.z;
func_8016970C(globalCtx, this->camId, &camera->focalPoint, &eye);
eye.x = (Math_SinS(y) * magShakeXZ) + camera->at.x;
eye.y = camera->at.y + magShakeY;
eye.z = (Math_CosS(y) * magShakeXZ) + camera->at.z;
func_8016970C(globalCtx, this->camId, &camera->at, &eye);
}
void EnPametfrog_StopCutscene(EnPametfrog* this, GlobalContext* globalCtx) {
@ -352,7 +352,7 @@ void EnPametfrog_StopCutscene(EnPametfrog* this, GlobalContext* globalCtx) {
if (this->camId != 0) {
camera = Play_GetCamera(globalCtx, this->camId);
func_8016970C(globalCtx, 0, &camera->focalPoint, &camera->eye);
func_8016970C(globalCtx, 0, &camera->at, &camera->eye);
this->camId = 0;
ActorCutscene_Stop(this->cutscene);
func_800B724C(globalCtx, &this->actor, 6);
@ -1176,7 +1176,7 @@ void func_8086CD04(EnPametfrog* this, GlobalContext* globalCtx) {
void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) {
Vec3f eye;
Vec3f focalPoint;
Vec3f at;
s16 yawDiff;
SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06001B08, 3.0f);
@ -1192,15 +1192,15 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) {
}
this->actor.shape.rot.y = this->actor.world.rot.y;
focalPoint.x = this->actor.world.pos.x;
focalPoint.z = this->actor.world.pos.z;
focalPoint.y = this->actor.world.pos.y + 45.0f;
eye.x = (Math_SinS(this->actor.shape.rot.y) * 90.0f) + focalPoint.x;
eye.z = (Math_CosS(this->actor.shape.rot.y) * 90.0f) + focalPoint.z;
eye.y = focalPoint.y + 4.0f;
at.x = this->actor.world.pos.x;
at.z = this->actor.world.pos.z;
at.y = this->actor.world.pos.y + 45.0f;
eye.x = (Math_SinS(this->actor.shape.rot.y) * 90.0f) + at.x;
eye.z = (Math_CosS(this->actor.shape.rot.y) * 90.0f) + at.z;
eye.y = at.y + 4.0f;
// Zooms in on Gekko
func_8016970C(globalCtx, this->camId, &focalPoint, &eye);
func_8016970C(globalCtx, this->camId, &at, &eye);
this->timer = 0;
this->actor.hintId = 0x5F;
this->actionFunc = EnPametfrog_CallSnapper;
@ -1213,26 +1213,26 @@ void EnPametfrog_CallSnapper(EnPametfrog* this, GlobalContext* globalCtx) {
}
void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx) {
Vec3f focalPoint;
Vec3f at;
Vec3f eye;
s16 yaw;
EnPametfrog_PlaceSnapper(this, globalCtx);
focalPoint.x = this->actor.child->world.pos.x;
focalPoint.z = this->actor.child->world.pos.z;
focalPoint.y = this->actor.child->floorHeight + 50.0f;
at.x = this->actor.child->world.pos.x;
at.z = this->actor.child->world.pos.z;
at.y = this->actor.child->floorHeight + 50.0f;
if ((s16)(Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y) > 0) {
yaw = this->actor.child->shape.rot.y - 0x1000;
} else {
yaw = this->actor.child->shape.rot.y + 0x1000;
}
eye.x = (Math_SinS(yaw) * 500.0f) + focalPoint.x;
eye.y = focalPoint.y + 55.0f;
eye.z = (Math_CosS(yaw) * 500.0f) + focalPoint.z;
eye.x = (Math_SinS(yaw) * 500.0f) + at.x;
eye.y = at.y + 55.0f;
eye.z = (Math_CosS(yaw) * 500.0f) + at.z;
// Zooms in on Snapper spawn point
func_8016970C(globalCtx, this->camId, &focalPoint, &eye);
func_8016970C(globalCtx, this->camId, &at, &eye);
this->quake = Quake_Add(ACTIVE_CAM, 6);
Quake_SetSpeed(this->quake, 18000);
Quake_SetQuakeValues(this->quake, 2, 0, 0, 0);
@ -1258,7 +1258,7 @@ void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, GlobalContext* g
Quake_RemoveFromIdx(this->quake);
this->quake = Quake_Add(ACTIVE_CAM, 3);
Quake_SetSpeed(this->quake, 20000);
Quake_SetQuakeValues(this->quake, 0x11, 0, 0, 0);
Quake_SetQuakeValues(this->quake, 17, 0, 0, 0);
Quake_SetCountdown(this->quake, 12);
func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150);
this->actionFunc = EnPametfrog_TransitionGekkoSnapper;

View File

@ -367,7 +367,8 @@ void ObjLightSwitch_DrawOpa(ObjLightswitch* this, GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx);
func_8012C28C(globalCtx->state.gfxCtx);
gDPSetEnvColor(POLY_OPA_DISP++, (u8)(this->colorR >> 6), (u8)(this->colorG >> 6), (0, (u8)(this->colorB >> 6)), (u8)(this->colorAlpha >> 6));
gDPSetEnvColor(POLY_OPA_DISP++, (u8)(this->colorR >> 6), (u8)(this->colorG >> 6), (0, (u8)(this->colorB >> 6)),
(u8)(this->colorAlpha >> 6));
gSPSegment(POLY_OPA_DISP++, 0x09, &D_801AEFA0);
tempPos.x = this->actor.world.pos.x;
@ -402,7 +403,8 @@ void ObjLightSwitch_DrawXlu(ObjLightswitch* this, GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx);
func_8012C2DC(globalCtx->state.gfxCtx);
gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->colorR >> 6), (u8)(this->colorG >> 6), (0, (u8)(this->colorB >> 6)), (u8)(this->colorAlpha >> 6));
gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->colorR >> 6), (u8)(this->colorG >> 6), (0, (u8)(this->colorB >> 6)),
(u8)(this->colorAlpha >> 6));
gSPSegment(POLY_XLU_DISP++, 0x09, &D_801AEF88);
tempPos.x = this->actor.world.pos.x;

View File

@ -2086,7 +2086,7 @@
0x8010C6C8:("OLib_Vec3fToVecSphGeo",),
0x8010C710:("OLib_Vec3fDiffToVecSph",),
0x8010C764:("OLib_Vec3fDiffToVecSphGeo",),
0x8010C7B8:("OLib_VecSphToVec3fSum",),
0x8010C7B8:("OLib_VecSphAddToVec3f",),
0x8010C838:("OLib_Vec3fDiffRad",),
0x8010C8C8:("OLib_Vec3fDiffDegF",),
0x8010C930:("OLib_Vec3fDiffBinAng",),
@ -2306,7 +2306,7 @@
0x8012A8F0:("Quake_SetCountdown",),
0x8012A940:("Quake_GetCountdown",),
0x8012A978:("Quake_SetQuakeValues",),
0x8012A9E0:("Quake_SetUnkValues",),
0x8012A9E0:("Quake_SetQuakeValues2",),
0x8012AA48:("Quake_Init",),
0x8012AA9C:("Quake_Add",),
0x8012AAC0:("Quake_RemoveFromIdx",),

View File

@ -309,7 +309,7 @@
0x80122660:"",
0x801226E0:"z_player_lib",
0x80129EF0:"z_prenmi",
0x8012A080:"", # probably z_quake
0x8012A080:"z_quake",
0x8012BC50:"z_rcp",
0x8012D510:"z_room",
0x8012EC80:"",

View File

@ -1387,7 +1387,7 @@
0x801C0EA0:("D_801C0EA0","UNK_TYPE1","",0x1),
0x801C0EAC:("D_801C0EAC","UNK_TYPE1","",0x1),
0x801C0EB8:("D_801C0EB8","UNK_TYPE1","",0x1),
0x801C0EC0:("D_801C0EC0","UNK_TYPE2","",0x2),
0x801C0EC0:("sIsQuakeInitialized","UNK_TYPE2","",0x2),
0x801C0EC4:("sQuakeRequestCount","s16","",0x2),
0x801C0EC8:("sQuakeCallbacks","quake_callback_func","[7]",0x1c),
0x801C0EE4:("D_801C0EE4","s16","",0x2),