Skip to content

Commit

Permalink
Merge branch 'main' into pm-chaos-edition
Browse files Browse the repository at this point in the history
  • Loading branch information
JCog committed Oct 8, 2024
2 parents ceb6891 + 04d65cd commit ea644bb
Show file tree
Hide file tree
Showing 736 changed files with 13,457 additions and 9,689 deletions.
3 changes: 3 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CompileFlags:
Add: -Wno-unknown-warning-option
Remove: [-m*, -f*]
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ build/
*.crash

/tools/n64crc

# clangd
.cache/clangd/
# compile_commands.json requires hardcoded paths, so it can't be committed
compile_commands.json
20 changes: 11 additions & 9 deletions include/camera.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#ifndef _CAMERA_H_
#define _CAMERA_H_

extern f32 D_8009A5EC;

void update_camera_mode_0(Camera*);
void update_camera_mode_1(Camera*);
void update_camera_mode_2(Camera*);
void update_camera_mode_4(Camera*);
void update_camera_mode_5(Camera*);
void update_camera_mode_6(Camera*);
void create_camera_leadplayer_matrix(Camera*);
extern f32 CamLengthScale;

void update_camera_minimal(Camera*);
void update_camera_no_interp(Camera*);
void update_camera_interp_pos(Camera*);
void update_camera_zone_interp(Camera* camera);

void update_camera_unused_confined(Camera*);
void update_camera_unused_leading(Camera*);
void update_camera_unused_radial(Camera*);
void update_camera_unused_ahead(Camera*);

void create_camera_leadplayer_matrix(Camera*);
Camera* initialize_next_camera(CameraInitData* data);

#endif
150 changes: 75 additions & 75 deletions include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ typedef struct Matrix4s {
/* 0x20 */ s16 frac[4][4];
} Matrix4s; // size = 0x40

typedef struct CamConfiguration {
typedef struct CameraRig {
/* 0x00 */ f32 boomYaw;
/* 0x04 */ f32 boomLength;
/* 0x08 */ f32 boomPitch;
/* 0x0C */ f32 viewPitch;
/* 0x10 */ Vec3f targetPos;
} CamConfiguration; // size = 0x1C
} CameraRig; // size = 0x1C

typedef struct DmaTable {
/* 0x00 */ u8* start;
Expand Down Expand Up @@ -720,16 +720,6 @@ typedef struct CameraInitData {
/* 0x10 */ s16 vfov;
} CameraInitData; // size = 0x12;

typedef struct CameraUnk {
/* 0x00 */ s16 unk_00;
/* 0x02 */ s16 unk_02;
/* 0x04 */ char unk_04[0x8];
/* 0x0C */ s32 unk_0C;
/* 0x10 */ char unk_10[0x54];
/* 0x64 */ s32 unk_64;
/* 0x68 */ char unk_68[0x24];
} CameraUnk; // size = 0x8C

typedef struct CameraControlSettings {
/* 0x00 */ s32 type;
/* 0x04 */ f32 boomLength;
Expand All @@ -753,105 +743,115 @@ typedef struct CameraControlSettings {
} three;
} points;
/* 0x24 */ f32 viewPitch;
/* 0x28 */ s32 flag;
/* 0x28 */ b32 flag;
} CameraControlSettings; // size = 0x2C

typedef struct Camera {
/* 0x000 */ u16 flags;
/* 0x002 */ s16 moveFlags;
/* 0x004 */ s16 updateMode;
/* 0x006 */ s16 needsInit;
/* 0x008 */ b16 isChangingMap;
/* 0x006 */ b16 needsInit;
/* 0x008 */ b16 needsReinit; // used when loading from a save point or calling SetCamPerspective
/* 0x00A */ s16 viewportW;
/* 0x00C */ s16 viewportH;
/* 0x00E */ s16 viewportStartX;
/* 0x010 */ s16 viewportStartY;
/* 0x012 */ s16 nearClip;
/* 0x014 */ s16 farClip;
/* 0x016 */ char unk_16[2];
/* 0x018 */ f32 vfov;
/* 0x01C */ s16 auxPitch;
/* 0x01E */ s16 auxBoomLength;
/* 0x020 */ s16 lookAt_dist;
/* 0x022 */ s16 auxBoomPitch;
/* 0x024 */ s16 auxBoomYaw;
/* 0x026 */ s16 auxBoomZOffset;
/* 0x028 */ s16 unk_28;
/* 0x02A */ s16 zoomPercent;
union {
struct {
s16 zoomPercent;
} world;
struct {
s16 dist;
s16 offsetY;
s16 pitch;
s16 yaw;
s16 fovScale; // 100 --> vfov = 25, scales as 1/x so larger values mean smaller vfov
s16 zoomPercent;
b16 skipRecalc;
} basic;
struct {
s16 dist;
s16 offsetY;
s16 pitch;
s16 yaw;
} interp;
struct {
s16 dist;
s16 offsetY;
s16 pitch;
s16 minRadius;
} radial;
struct {
s16 dist;
s16 offsetY;
s16 xLimit;
s16 zLimit;
} confined;
} params;
/* 0x02C */ s16 bgColor[3];
/* 0x032 */ Vec3s targetScreenCoords;
/* 0x032 */ Vec3s targetScreenCoords; // screen coords corresponding to targetPos
/* 0x038 */ u16 perspNorm;
/* 0x03A */ char unk_3A[2];
/* 0x03C */ Vec3f lookAt_eye;
/* 0x048 */ Vec3f lookAt_obj;
/* 0x03C */ Vec3f lookAt_eye; // used to construct the view matrix
/* 0x048 */ Vec3f lookAt_obj; // used to construct the view matrix
/* 0x054 */ Vec3f lookAt_obj_target;
/* 0x060 */ Vec3f targetPos;
/* 0x060 */ Vec3f targetPos; // target for camera rig, often but not necessarily the player position
/* 0x06C */ f32 curYaw;
/* 0x070 */ f32 unk_70;
/* 0x074 */ f32 curBoomYaw;
/* 0x070 */ f32 interpYaw; // no camera mode actually uses this for interpolation
/* 0x078 */ f32 curBoomLength;
/* 0x07C */ f32 curYOffset;
/* 0x080 */ char unk_80[4];
/* 0x084 */ Vec3f trueRot;
/* 0x090 */ f32 curBlendedYawNegated;
/* 0x094 */ f32 curPitch;
/* 0x098 */ f32 unk_98;
/* 0x09C */ f32 unk_9C;
/* 0x074 */ f32 curBoomPitch;
/* 0x084 */ f32 curBoomYaw;
/* 0x07C */ f32 targetOffsetY;
/* 0x088 */ f32 targetBoomYaw; // only used by CAM_UPDATE_UNUSED_RADIAL
/* 0x090 */ f32 lookAt_yaw;
/* 0x094 */ f32 lookAt_pitch;
/* 0x0A0 */ Vp vp;
/* 0x0B0 */ Vp vpAlt;
/* 0x0C0 */ s32 unk_C0;
/* 0x0C4 */ f32 unk_C4;
/* 0x0C8 */ char unk_C8[0xC];
/* 0x0D4 */ Matrix4f perspectiveMatrix;
/* 0x114 */ Matrix4f viewMtxPlayer; /* centers on player */
/* 0x154 */ Matrix4f viewMtxLeading; /* leads player slightly */
/* 0x194 */ Matrix4f viewMtxShaking; /* used while ShakeCam is active */
/* 0x1D4 */ char unk_1D4[0x28];
/* 0x0D4 */ Matrix4f mtxPerspective;
/* 0x114 */ Matrix4f mtxViewPlayer; // centers on player
/* 0x154 */ Matrix4f mtxViewLeading; // leads player slightly
/* 0x194 */ Matrix4f mtxViewShaking; // used while ShakeCam is active
/* 0x1FC */ void (*fpDoPreRender)(struct Camera*);
/* 0x200 */ void (*fpDoPostRender)(struct Camera*);
/* 0x204 */ Mtx* unkMatrix;
/* 0x208 */ s32 unk_208;
/* 0x20C */ Matrix4s* unkEffectMatrix;
/* 0x210 */ char unk_210[0x2];
/* 0x212 */ s16 unk_212;
/* 0x214 */ CameraUnk unk_214[4];
/* 0x444 */ CameraControlSettings* prevController;
/* 0x448 */ CameraControlSettings* curController;
/* 0x44C */ CamConfiguration prevConfiguration;
/* 0x468 */ CamConfiguration goalConfiguration;
/* 0x204 */ Mtx* mtxBillboard; // rotation matrix created from -curBoomYaw
/* 0x444 */ CameraControlSettings* prevSettings;
/* 0x448 */ CameraControlSettings* curSettings;
/* 0x44C */ CameraRig prevRig;
/* 0x468 */ CameraRig nextRig;
/* 0x484 */ f32 interpAlpha;
/* 0x488 */ f32 linearInterp;
/* 0x48C */ f32 linearInterpScale; /* 3.0? */
/* 0x48C */ f32 linearInterpRate;
/* 0x490 */ f32 moveSpeed;
/* 0x494 */ f32 yinterpGoal;
/* 0x498 */ f32 yinterpAlpha;
/* 0x49C */ f32 yinterpRate; // smaller is faster; not valid for values less than 1.0, unstable below 0.5
/* 0x4A0 */ f32 yinterpCur;
/* 0x4A4 */ Vec3f prevTargetPos;
/* 0x4B0 */ Vec3f movePos;
/* 0x4BC */ Vec3f prevPrevMovePos;
/* 0x4C8 */ Vec3f prevMovePos;
/* 0x4D4 */ u16 prevPrevFollowPlayer;
/* 0x4D6 */ u16 prevFollowPlayer;
/* 0x4D8 */ CameraControlSettings controlSettings;
/* 0x504 */ u16 followPlayer;
/* 0x506 */ u16 panActive;
/* 0x508 */ f32 panPhase;
/* 0x4BC */ Vec3f prevPrevMovePos;
/* 0x4D8 */ CameraControlSettings overrideSettings;
/* 0x504 */ b16 useOverrideSettings;
/* 0x4D6 */ b16 prevUseOverride;
/* 0x4D4 */ b16 prevPrevUseOverride;
/* 0x506 */ b16 panActive;
/* 0x508 */ f32 interpEasingParameter; // controls whether easing for camera rig interpolation is more cosine-like (values near 0) or quadratic (values near 1)
/* 0x50C */ f32 leadAmount;
/* 0x510 */ f32 targetLeadAmount;
/* 0x514 */ f32 leadInterpAlpha;
/* 0x518 */ f32 accumulatedStickLead;
/* 0x51C */ s32 increasingLeadInterp;
/* 0x520 */ f32 leadAmtScale;
/* 0x524 */ f32 leadUnkX;
/* 0x528 */ f32 leadUnkZ;
/* 0x52C */ s32 unk_52C;
/* 0x530 */ s32 unk_530;
/* 0x534 */ CameraControlSettings* leadControlSettings;
/* 0x538 */ char unk_538[0x18];
/* 0x550 */ f32 unk_550;
/* 0x554 */ s16 unk_554;
/* 0x556 */ s16 unk_556;
/* 0x524 */ f32 prevLeadPosX;
/* 0x528 */ f32 prevLeadPosZ;
/* 0x52C */ s32 leadConstrainDir;
/* 0x530 */ b32 needsInitialConstrainDir;
/* 0x534 */ CameraControlSettings* prevLeadSettings;
/* 0x550 */ f32 unusedLeadAmt;
/* 0x554 */ s16 unusedLeadCounter;
/* 0x556 */ s16 unusedLeadDir;
} Camera; // size = 0x558

typedef struct BattleStatus {
Expand Down Expand Up @@ -1395,7 +1395,7 @@ typedef struct GameStatus {
/* 0x06A */ s8 demoStickX;
/* 0x06B */ s8 demoStickY;
/* 0x06C */ s32 mainScriptID;
/* 0x070 */ s8 isBattle;
/* 0x070 */ s8 context;
/* 0x071 */ s8 demoState; // see DemoState enum
/* 0x072 */ s8 nextDemoScene; /* which part of the demo to play next */
/* 0x073 */ u8 contBitPattern;
Expand Down Expand Up @@ -2008,7 +2008,7 @@ typedef struct PlayerStatus {
/* 0x06C */ f32 maxJumpSpeed;
/* 0x070 */ f32 gravityIntegrator[4]; // derivatives of y; 0 = velocity, 1 = accel, etc
/* 0x080 */ f32 targetYaw;
/* 0x084 */ f32 curYaw;
/* 0x084 */ f32 curYaw; // the direction of player input in world-space (not camera-relative)
/* 0x088 */ f32 overlapPushYaw;
/* 0x08C */ f32 pitch;
/* 0x090 */ f32 flipYaw[4];
Expand Down
2 changes: 1 addition & 1 deletion include/effect_shims.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void shim_draw_msg(s32, s32, s32, s32, s32, s32);
s32 shim_get_msg_width(s32, u16);
void shim_mdl_get_shroud_tint_params(u8* r, u8* g, u8* b, u8* a);
void shim_sfx_play_sound_at_position(s32 soundID, s32 value2, f32 posX, f32 posY, f32 posZ);
void shim_is_debug_panic(const char* message, const char* file, u32 line, const char* func);
void shim_is_debug_panic(const char* message);

#define guRotateF shim_guRotateF
#define guTranslateF shim_guTranslateF
Expand Down
31 changes: 17 additions & 14 deletions include/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -1259,24 +1259,27 @@ typedef struct SmallGoldSparkleFXData {
/* 0x20 */ s32 unk_20;
} SmallGoldSparkleFXData; // size = 0x24

typedef struct FlashingBoxShockwaveFXData {
/* 0x00 */ s32 unk_00;
enum ShockOverlayFXTypes {
FX_SHOCK_OVERLAY_SHOCK_HIT = 0,
FX_SHOCK_OVERLAY_LIGHTNING_WORLD = 1,
FX_SHOCK_OVERLAY_MEGA_SHOCK = 2,
FX_SHOCK_OVERLAY_LIGHTNING_BATTLE = 3,
};

typedef struct ShockOverlayFXData {
/* 0x00 */ s32 type;
/* 0x04 */ Vec3f pos;
/* 0x10 */ s32 unk_10;
/* 0x14 */ s32 unk_14;
/* 0x18 */ s32 unk_18;
/* 0x1C */ s32 unk_1C;
/* 0x20 */ s32 unk_20;
/* 0x1C */ s32 timeLeft;
/* 0x20 */ s32 lifetime;
/* 0x24 */ f32 unk_24;
/* 0x28 */ f32 unk_28;
/* 0x2C */ f32 unk_2C;
/* 0x30 */ s32 unk_30;
/* 0x34 */ s32 unk_34;
/* 0x38 */ s32 unk_38;
/* 0x3C */ s32 unk_3C;
/* 0x40 */ s32 unk_40;
/* 0x44 */ s32 unk_44;
} FlashingBoxShockwaveFXData; // size = 0x48
/* 0x28 */ f32 scaleX;
/* 0x2C */ f32 scaleY;
/* 0x30 */ Color3i primCol;
/* 0x3C */ Color3i envCol;
} ShockOverlayFXData; // size = 0x48

typedef struct BalloonFXData {
/* 0x00 */ s32 unk_00;
Expand Down Expand Up @@ -2532,7 +2535,7 @@ typedef union {
struct GatherMagicFXData* gatherMagic;
struct AttackResultTextFXData* attackResultText;
struct SmallGoldSparkleFXData* smallGoldSparkle;
struct FlashingBoxShockwaveFXData* flashingBoxShockwave;
struct ShockOverlayFXData* flashingBoxShockwave;
struct BalloonFXData* balloon;
struct FloatingRockFXData* floatingRock;
struct ChompDropFXData* chompDrop;
Expand Down
6 changes: 6 additions & 0 deletions include/effects_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

#include "effects.h"

// slimmed down assert so that all effects still fit under the TLB page size limit of 0x1000 bytes
#define ASSERT(condition) \
if (!(condition)) { \
IS_DEBUG_PANIC("ASSERT"); \
}

s32 effect_rand_int(s32);
s32 effect_simple_rand(s32, s32);

Expand Down
Loading

0 comments on commit ea644bb

Please sign in to comment.