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-19 19:06:54 -04:00
committed by GitHub
parent 184e67c841
commit b5c931e432
15 changed files with 969 additions and 206 deletions
+21 -21
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);
+2 -8
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;
+114 -107
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;