Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera docs: KeepOn4 #1456

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
3 changes: 1 addition & 2 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,7 @@ s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 a
s16 timer3);
s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera);
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);
void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, s32 data4);
s32 func_8005B198(void);
s16 func_8005B1A4(Camera* camera);
DamageTable* DamageTable_Get(s32 index);
Expand Down
82 changes: 52 additions & 30 deletions include/z64camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
#define CAM_VIEW_FOV (1 << 5) // camera->fov
#define CAM_VIEW_ROLL (1 << 6) // camera->roll

#define CAM_SET_CAMERA_DATA_0 (1 << 0)
#define CAM_SET_CAMERA_DATA_1 (1 << 1)
#define CAM_SET_CAMERA_DATA_2 (1 << 2)
#define CAM_SET_CAMERA_DATA_3 (1 << 3)
#define CAM_SET_CAMERA_DATA_4 (1 << 4)

// All scenes using `SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT` or `SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT` are expected
// to have their first two bgCamInfo entries be the following:
#define BGCAM_INDEX_TOGGLE_LOCKED 0
Expand Down Expand Up @@ -824,7 +830,7 @@ typedef struct {
#define KEEPON3_FLAG_5 (1 << 5)
#define KEEPON3_FLAG_7 (1 << 7)

#define CAM_FUNCDATA_KEEP3(yOffset, eyeDist, eyeDistNext, swingYawInit, swingYawFinal, swingPitchInit, swingPitchFinal, swingPitchAdj, fov, atLerpStepScale, yawUpdateRateTarget, interfaceField) \
#define CAM_FUNCDATA_KEEP3(yOffset, eyeDist, eyeDistNext, swingYawInit, swingYawFinal, swingPitchInit, swingPitchFinal, swingPitchAdj, fov, atLerpStepScale, initTimer, interfaceField) \
{ yOffset, CAM_DATA_Y_OFFSET }, \
{ eyeDist, CAM_DATA_EYE_DIST }, \
{ eyeDistNext, CAM_DATA_EYE_DIST_NEXT }, \
Expand All @@ -835,56 +841,72 @@ typedef struct {
{ swingPitchAdj, CAM_DATA_SWING_PITCH_ADJ }, \
{ fov, CAM_DATA_FOV }, \
{ atLerpStepScale, CAM_DATA_AT_LERP_STEP_SCALE }, \
{ yawUpdateRateTarget, CAM_DATA_YAW_UPDATE_RATE_TARGET }, \
{ initTimer, CAM_DATA_YAW_UPDATE_RATE_TARGET }, \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the second value (CAM_DATA_YAW_UPDATE_RATE_TARGET) also need to be updated?

{ interfaceField, CAM_DATA_INTERFACE_FIELD }

typedef struct {
/* 0x00 */ f32 unk_00;
/* 0x04 */ f32 unk_04;
/* 0x08 */ f32 unk_08;
/* 0x0C */ f32 unk_0C;
/* 0x10 */ f32 unk_10;
/* 0x14 */ f32 unk_14;
/* 0x18 */ f32 unk_18;
/* 0x00 */ f32 yOffset;
/* 0x04 */ f32 eyeDist;
/* 0x08 */ f32 pitchTarget; // degrees, usage varies with KEEPON4_FLAG_EYE_
/* 0x0C */ f32 yawTarget; // degrees, usage varies with KEEPON4_FLAG_EYE_
/* 0x10 */ f32 atOffsetPlayerForwards; // distance to offset at by in the player's forwards direction
Comment on lines +851 to +852
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"distance to offset at by, in the player's forwards direction"
will help alot with the word soup here. i think putting at and eye in backticks in general helps the reader quickly know its referring to the camera component, and not the regular word

/* 0x14 */ f32 unk_14; // scale for stepping yaw and pitch of "at to eye" to target
/* 0x18 */ f32 fovTarget;
/* 0x1C */ s16 interfaceField;
/* 0x1E */ s16 unk_1E;
/* 0x1E */ s16 initTimer;
} KeepOn4ReadOnlyData; // size = 0x20

typedef struct {
/* 0x00 */ f32 unk_00;
/* 0x04 */ f32 unk_04;
/* 0x08 */ f32 unk_08;
/* 0x0C */ s16 unk_0C;
/* 0x0E */ s16 unk_0E;
/* 0x10 */ s16 unk_10;
/* 0x12 */ s16 unk_12;
/* 0x14 */ s16 unk_14;
typedef enum {
/* 1 */ CAM_ITEM_TYPE_1=1, // drop fish from bottle and something with ruto's letter
Comment on lines +859 to +860
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id space out all the value assignments here, = 1 etc

/* 2 */ CAM_ITEM_TYPE_2, // drink from bottle?
/* 3 */ CAM_ITEM_TYPE_3, // use bottled fairy
/* 4 */ CAM_ITEM_TYPE_4, // something with farore's wind, something with exchange items, catching things into bottles
/* 5 */ CAM_ITEM_TYPE_5, // drop bugs and blue fire from bottle
/* 8 */ CAM_ITEM_TYPE_8=8, // ??? get item after underwater?
/* 9 */ CAM_ITEM_TYPE_9, // get item
/* 10 */ CAM_ITEM_TYPE_10, // used farore's wind or nayru's love
/* 11 */ CAM_ITEM_TYPE_11, // talking to navi?
/* 12 */ CAM_ITEM_TYPE_ONEPOINTDEMO9806,
/* 81 */ CAM_ITEM_TYPE_HORSE=81,
/* 90 */ CAM_ITEM_TYPE_90=90, // play ocarina (on its own)?
/* 91 */ CAM_ITEM_TYPE_91 // play ocarina for an actor?
} CameraItemType;

typedef struct {
/* 0x00 */ f32 atToEyeTargetStepYaw;
/* 0x04 */ f32 atToEyeTargetStepPitch;
/* 0x08 */ f32 unk_08; // unused
/* 0x0C */ s16 atToEyeTargetYaw;
/* 0x0E */ s16 atToEyeTargetPitch;
/* 0x10 */ s16 animTimer;
/* 0x12 */ s16 unk_12; // unused
/* 0x14 */ s16 itemType;
} KeepOn4ReadWriteData; // size = 0x18

typedef struct {
/* 0x00 */ KeepOn4ReadOnlyData roData;
/* 0x20 */ KeepOn4ReadWriteData rwData;
} KeepOn4; // size = 0x38

#define KEEPON4_FLAG_0 (1 << 0)
#define KEEPON4_FLAG_1 (1 << 1)
#define KEEPON4_FLAG_2 (1 << 2)
#define KEEPON4_FLAG_3 (1 << 3)
#define KEEPON4_FLAG_4 (1 << 4)
#define KEEPON4_FLAG_5 (1 << 5)
#define KEEPON4_FLAG_6 (1 << 6)
#define KEEPON4_FLAG_7 (1 << 7)
#define KEEPON4_FLAG_NO_CHECK_COL (1 << 0) // If set, disables checking for colliders and collision to place the camera eye. Never set
#define KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER (1 << 1) // pitch: provided, yaw: offset from behind player
#define KEEPON4_FLAG_EYE_ABS (1 << 2) // pitch: provided, yaw: provided. Unused
#define KEEPON4_FLAG_EYE_FROM_TARGET (1 << 3) // pitch and yaw: depends on x/y rotations of the camera `target`, plus offsets
#define KEEPON4_FLAG_ONEPOINTDEMO9806 (1 << 4) // Camera timer ticks down, and other things (TODO). Only set for CAM_ITEM_TYPE_ONEPOINTDEMO9806
#define KEEPON4_FLAG_NOOP (1 << 5) // No effect. Only set for CAM_ITEM_TYPE_11
#define KEEPON4_FLAG_EYE_KEEP_YAW (1 << 6) // pitch: provided, yaw: retain current yaw
#define KEEPON4_FLAG_HORSE (1 << 7) // (partly a KEEPON4_FLAG_EYE_) pitch: provided, yaw: offset from the side opposite to the camera `target` compared to player

#define CAM_FUNCDATA_KEEP4(yOffset, eyeDist, pitchTarget, yawTarget, atOffsetZ, fov, interfaceField, yawUpdateRateTarget, unk_22) \
#define CAM_FUNCDATA_KEEP4(yOffset, eyeDist, pitchTarget, yawTarget, atOffsetPlayerForwards, fov, interfaceField, yawUpdateRateTarget, initTimer) \
{ yOffset, CAM_DATA_Y_OFFSET }, \
{ eyeDist, CAM_DATA_EYE_DIST }, \
{ pitchTarget, CAM_DATA_PITCH_TARGET }, \
{ yawTarget, CAM_DATA_YAW_TARGET }, \
{ atOffsetZ, CAM_DATA_AT_OFFSET_Z }, \
{ atOffsetPlayerForwards, CAM_DATA_AT_OFFSET_Z }, \
{ fov, CAM_DATA_FOV }, \
{ interfaceField, CAM_DATA_INTERFACE_FIELD }, \
{ yawUpdateRateTarget, CAM_DATA_YAW_UPDATE_RATE_TARGET }, \
{ unk_22, CAM_DATA_UNK_22 }
{ initTimer, CAM_DATA_UNK_22 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps UNK_22 was suppose to be the init timer, and the one above is wrong?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump


typedef struct {
/* 0x00 */ f32 fovScale;
Expand Down
6 changes: 6 additions & 0 deletions include/z64player.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ typedef enum {
/* 0x43 */ PLAYER_IA_MAX
} PlayerItemAction;

#define PLAYER_MAGIC_SPELL(playerItemActionMagicSpell) ((playerItemActionMagicSpell) - PLAYER_IA_MAGIC_SPELL_15)
#define PLAYER_MAGIC_SPELL_MAX (1 + PLAYER_MAGIC_SPELL(PLAYER_IA_DINS_FIRE))

#define PLAYER_BOTTLE(playerItemActionBottle) ((playerItemActionBottle) - PLAYER_IA_BOTTLE)
#define PLAYER_BOTTLE_MAX (1 + PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FAIRY))
Comment on lines +143 to +147
Copy link
Collaborator

@fig02 fig02 Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can prob afford _IA_ in the middle to make it clear its dealing with item actions


typedef enum {
/* 0x00 */ PLAYER_LIMB_NONE,
/* 0x01 */ PLAYER_LIMB_ROOT,
Expand Down
Loading