Actor Cutscene system from Majora's Mask (#161)

* animated materials

* fix build errors with CI

* tests

* fix issues

* renamed cs halt state flag

* format

* remove test scene from spec

* remove test code from z_play.c

* forgot to reset the boot entrance

* fixed issues

* format

* update safeguards

* cleanup and fixes
This commit is contained in:
Yanis
2025-01-06 12:40:41 +01:00
committed by GitHub
parent 3f156f32df
commit a449ef23bf
40 changed files with 3202 additions and 148 deletions

View File

@@ -2,6 +2,9 @@
#define ANIMATED_MATERIALS_H
#include "ultra64.h"
#include "config.h"
#if ENABLE_ANIMATED_MATERIALS
typedef enum AnimatedMatType {
/* 0 */ ANIM_MAT_TYPE_TEX_SCROLL,
@@ -82,3 +85,5 @@ void AnimatedMat_DrawAlphaStepOpa(struct PlayState* play, AnimatedMaterial* matA
void AnimatedMat_DrawAlphaStepXlu(struct PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step);
#endif
#endif

View File

@@ -74,4 +74,16 @@
*/
#define ENABLE_ANIMATED_MATERIALS true
/**
* Enable New Letterbox (from Majora's Mask)
*/
#define ENABLE_NEW_LETTERBOX true
/**
* Enable Cutscene Improvements (from Majora's Mask)
*
* This includes actor cutscenes
*/
#define ENABLE_CUTSCENE_IMPROVEMENTS true
#endif

View File

@@ -137,6 +137,14 @@
#define USE_WIDESCREEN (ENABLE_WIDESCREEN && gSaveContext.save.useWidescreen == true)
#endif
#if ENABLE_CUTSCENE_IMPROVEMENTS && !ENABLE_NEW_LETTERBOX
#undef ENABLE_NEW_LETTERBOX
#define ENABLE_NEW_LETTERBOX true
#endif
/*****************
* config_graphics.h
*/
//! TODO: implement better Wii VC compatibility
#ifdef CONSOLE_WIIVC
#undef ENABLE_F3DEX3

View File

@@ -11,4 +11,25 @@ void Letterbox_Init(void);
void Letterbox_Destroy(void);
void Letterbox_Update(s32 updateRate);
#if ENABLE_NEW_LETTERBOX
struct GraphicsContext;
void ShrinkWindow_Letterbox_SetSizeTarget(s32 target);
s32 ShrinkWindow_Letterbox_GetSizeTarget(void);
void ShrinkWindow_Letterbox_SetSize(s32 size);
s32 ShrinkWindow_Letterbox_GetSize(void);
void ShrinkWindow_Pillarbox_SetSizeTarget(s32 target);
s32 ShrinkWindow_Pillarbox_GetSizeTarget(void);
void ShrinkWindow_Pillarbox_SetSize(s32 size);
s32 ShrinkWindow_Pillarbox_GetSize(void);
void ShrinkWindow_Init(void);
void ShrinkWindow_Destroy(void);
void ShrinkWindow_Update(s32 framerateDivisor);
void ShrinkWindow_Draw(struct GraphicsContext* gfxCtx);
#endif
#endif

View File

@@ -124,5 +124,9 @@
#endif
#if CAN_INCLUDE_EXAMPLE_SCENE
#if ENABLE_ANIMATED_MATERIALS
/* 0x6C */ DEFINE_SCENE(example_scene, none, SCENE_EXAMPLE, SDC_MAT_ANIM, 0, 0)
#else
/* 0x6C */ DEFINE_SCENE(example_scene, none, SCENE_EXAMPLE, SDC_HAUNTED_WASTELAND, 0, 0)
#endif
#endif

View File

@@ -220,6 +220,13 @@ typedef struct ActorShape {
// Flag controlling the use of `Actor.sfx`. Do not use directly. See Actor_PlaySfx_FlaggedTimer
#define ACTOR_FLAG_SFX_TIMER (1 << 28)
// Actor can update even if Player is currently in one of the `sCategoryFreezeMasks` states.
// Typically an actor will halt while the player is in one of the `sCategoryFreezeMasks` states (depending on category).
// This flag allows a given actor to be an exception.
//
// Note: Not implemented yet.
#define ACTOR_FLAG_FREEZE_EXCEPTION (1 << 29)
#define COLORFILTER_GET_COLORINTENSITY(colorFilterParams) (((colorFilterParams) & 0x1F00) >> 5)
#define COLORFILTER_GET_DURATION(colorFilterParams) ((colorFilterParams) & 0xFF)

View File

@@ -205,7 +205,10 @@ typedef enum CameraSettingType {
/* 0x3F */ CAM_SET_DIRECTED_YAW, // Does not auto-update yaw, tends to keep the camera pointed at a certain yaw (used by biggoron and final spirit lowering platform) "TEPPEN"
/* 0x40 */ CAM_SET_PIVOT_FROM_SIDE, // Fixed side view, allows rotation of camera (eg. Potion Shop, Meadow at fairy grotto) "CIRCLE7"
/* 0x41 */ CAM_SET_NORMAL4,
/* 0x42 */ CAM_SET_MAX
#if ENABLE_CUTSCENE_IMPROVEMENTS
/* 0x42 */ CAM_SET_FIXED1,
#endif
/* 0x43 */ CAM_SET_MAX
} CameraSettingType;
typedef enum CameraModeType {
@@ -305,7 +308,10 @@ typedef enum CameraFuncType {
/* 0x44 */ CAM_FUNC_SPEC7,
/* 0x45 */ CAM_FUNC_SPEC8,
/* 0x46 */ CAM_FUNC_SPEC9,
/* 0x47 */ CAM_FUNC_MAX
#if ENABLE_CUTSCENE_IMPROVEMENTS
/* 0x47 */ CAM_FUNC_FIXED1,
#endif
/* 0x48 */ CAM_FUNC_MAX
} CameraFuncType;
typedef enum CameraDataType {
@@ -1733,4 +1739,13 @@ void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* d
s32 func_8005B198(void);
s16 Camera_SetFinishedFlag(Camera* camera);
s16 Camera_GetBgCamOrActorCsCamSetting(Camera* camera, u32 camDataId);
Vec3s* Camera_GetBgCamOrActorCsCamFuncData(Camera* camera, u32 camDataId);
#if ENABLE_CUTSCENE_IMPROVEMENTS
s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags);
s32 Camera_ChangeSetting(Camera* camera, s16 setting);
s32 Camera_ChangeActorCsCamIndex(Camera* camera, s32 bgCamIndex);
void Camera_800E0348(Camera* camera);
#endif
#endif

View File

@@ -11,7 +11,7 @@ typedef union CutsceneData {
s32 i;
f32 f;
s16 s[2];
s8 b[4];
s8 b[4];
} CutsceneData;
typedef enum CutsceneState {
@@ -198,7 +198,7 @@ typedef enum CutsceneTextType {
/* 0x00 */ CS_TEXT_NORMAL,
/* 0x01 */ CS_TEXT_CHOICE,
/* 0x02 */ CS_TEXT_OCARINA_ACTION,
/* 0x03 */ CS_TEXT_GORON_RUBY, // use `altTextId1` in the ruby cutscene if sapphire is already obtained
/* 0x03 */ CS_TEXT_GORON_RUBY, // use `altTextId1` in the ruby cutscene if sapphire is already obtained
/* 0x04 */ CS_TEXT_ZORA_SAPPHIRE // use `altTextId1` in the sapphire cutscene if ruby is already obtained
} CutsceneTextType;
@@ -240,7 +240,7 @@ typedef enum CutsceneDestination {
/* 0x0D */ CS_DEST_ZORAS_FOUNTAIN_FROM_ZORAS_SAPPHIRE,
/* 0x0E */ CS_DEST_KOKIRI_FOREST_FROM_KOKIRI_EMERALD,
/* 0x0F */ CS_DEST_TEMPLE_OF_TIME_KOKIRI_EMERALD_RESTORED, // unused
/* 0x10 */ CS_DEST_TEMPLE_OF_TIME_GORON_RUBY_RESTORED, // unused
/* 0x10 */ CS_DEST_TEMPLE_OF_TIME_GORON_RUBY_RESTORED, // unused
/* 0x11 */ CS_DEST_TEMPLE_OF_TIME_ZORAS_SAPPHIRE_RESTORED, // unused
/* 0x12 */ CS_DEST_TEMPLE_OF_TIME_AFTER_LIGHT_MEDALLION,
/* 0x13 */ CS_DEST_DEATH_MOUNTAIN_TRAIL, // unused
@@ -251,7 +251,7 @@ typedef enum CutsceneDestination {
/* 0x18 */ CS_DEST_JABU_JABU,
/* 0x19 */ CS_DEST_CHAMBER_OF_SAGES_LIGHT_MEDALLION,
/* 0x1A */ CS_DEST_TEMPLE_OF_TIME_KOKIRI_EMERALD_RESTORED_2, // unused
/* 0x1B */ CS_DEST_TEMPLE_OF_TIME_GORON_RUBY_RESTORED_2, // unused
/* 0x1B */ CS_DEST_TEMPLE_OF_TIME_GORON_RUBY_RESTORED_2, // unused
/* 0x1C */ CS_DEST_TEMPLE_OF_TIME_ZORAS_SAPPHIRE_RESTORED_2, // unused
/* 0x1D */ CS_DEST_CHAMBER_OF_SAGES_FOREST_MEDALLION,
/* 0x1E */ CS_DEST_CHAMBER_OF_SAGES_FIRE_MEDALLION,
@@ -303,15 +303,15 @@ typedef enum CutsceneDestination {
/* 0x4C */ CS_DEST_LON_LON_RANCH_CREDITS_PART_4,
/* 0x4D */ CS_DEST_LON_LON_RANCH_CREDITS_PART_5,
/* 0x4E */ CS_DEST_LON_LON_RANCH_CREDITS_PART_6,
/* 0x4F */ CS_DEST_LON_LON_RANCH_1, // unused
/* 0x50 */ CS_DEST_LON_LON_RANCH_2, // unused
/* 0x51 */ CS_DEST_LON_LON_RANCH_3, // unused
/* 0x52 */ CS_DEST_LON_LON_RANCH_4, // unused
/* 0x53 */ CS_DEST_LON_LON_RANCH_5, // unused
/* 0x54 */ CS_DEST_LON_LON_RANCH_6, // unused
/* 0x55 */ CS_DEST_LON_LON_RANCH_7, // unused
/* 0x56 */ CS_DEST_LON_LON_RANCH_8, // unused
/* 0x57 */ CS_DEST_LON_LON_RANCH_9, // unused
/* 0x4F */ CS_DEST_LON_LON_RANCH_1, // unused
/* 0x50 */ CS_DEST_LON_LON_RANCH_2, // unused
/* 0x51 */ CS_DEST_LON_LON_RANCH_3, // unused
/* 0x52 */ CS_DEST_LON_LON_RANCH_4, // unused
/* 0x53 */ CS_DEST_LON_LON_RANCH_5, // unused
/* 0x54 */ CS_DEST_LON_LON_RANCH_6, // unused
/* 0x55 */ CS_DEST_LON_LON_RANCH_7, // unused
/* 0x56 */ CS_DEST_LON_LON_RANCH_8, // unused
/* 0x57 */ CS_DEST_LON_LON_RANCH_9, // unused
/* 0x58 */ CS_DEST_LON_LON_RANCH_10, // unused
/* 0x59 */ CS_DEST_LON_LON_RANCH_11, // unused
/* 0x5A */ CS_DEST_LON_LON_RANCH_12, // unused
@@ -355,7 +355,6 @@ typedef union CsCmdCam {
s32 _words[2];
} CsCmdCam; // size = 0x8
typedef union CsCmdMisc {
struct {
/* 0x00 */ u16 type;
@@ -421,8 +420,8 @@ typedef union CsCmdTime {
/* 0x00 */ u16 unused0;
/* 0x02 */ u16 startFrame;
/* 0x04 */ u16 endFrame; // unused
/* 0x06 */ u8 hour;
/* 0x07 */ u8 minute;
/* 0x06 */ u8 hour;
/* 0x07 */ u8 minute;
};
s32 _words[3];
} CsCmdTime; // size = 0xC
@@ -500,22 +499,240 @@ typedef struct CutsceneCameraMove {
/* 0x8 */ s16 relativeToPlayer;
} CutsceneCameraMove; // size = 0xC
typedef struct CutsceneScriptEntry {
/* 0x0 */ CutsceneData* script;
/* 0x4 */ s16 nextEntrance;
/* 0x6 */ u8 spawn;
/* 0x7 */ u8 spawnFlags; // See `CS_SPAWN_FLAG_`
} CutsceneScriptEntry; // size = 0x8
typedef struct CutsceneEntry {
/* 0x0 */ s16 priority; // Lower means higher priority. -1 means it ignores priority
/* 0x2 */ s16 length;
/* 0x4 */ s16 csCamId; // Index of CsCameraEntry to use. Negative indices use sGlobalCamDataSettings. Indices 0 and
// above use CsCameraEntry from a sceneLayer
/* 0x6 */ s16 scriptIndex;
/* 0x8 */ s16 additionalCsId;
/* 0xA */ u8 endSfx;
/* 0xB */ u8 customValue; // 0 - 99: actor-specific custom value. 100+: spawn. 255: none
/* 0xC */ s16 hudVisibility;
/* 0xE */ u8 endCam;
/* 0xF */ u8 letterboxSize;
} CutsceneEntry; // size = 0x10
#define CS_SCRIPT_ID_NONE -1
typedef enum CutsceneCamId {
// global (see sGlobalCamDataSettings)
/* -66 */ CS_CAM_ID_GLOBAL_NORMAL4 = -67, // CAM_SET_NORMAL4 (set to -CAM_SET_MAX)
/* -65 */ CS_CAM_ID_GLOBAL_PIVOT_FROM_SIDE, // CAM_SET_PIVOT_FROM_SIDE
/* -64 */ CS_CAM_ID_GLOBAL_DIRECTED_YAW, // CAM_SET_DIRECTED_YAW
/* -63 */ CS_CAM_ID_GLOBAL_DUNGEON2, // CAM_SET_DUNGEON2
/* -62 */ CS_CAM_ID_GLOBAL_JABU_TENTACLE, // CAM_SET_JABU_TENTACLE
/* -61 */ CS_CAM_ID_GLOBAL_CS_C, // CAM_SET_CS_C
/* -60 */ CS_CAM_ID_GLOBAL_FISHING, // CAM_SET_FISHING
/* -59 */ CS_CAM_ID_GLOBAL_NORMAL2, // CAM_SET_NORMAL2
/* -58 */ CS_CAM_ID_GLOBAL_PIVOT_VERTICAL, // CAM_SET_PIVOT_VERTICAL
/* -57 */ CS_CAM_ID_GLOBAL_TURN_AROUND, // CAM_SET_TURN_AROUND
/* -56 */ CS_CAM_ID_GLOBAL_FIRE_BIRDS_EYE, // CAM_SET_FIRE_BIRDS_EYE
/* -55 */ CS_CAM_ID_GLOBAL_MEADOW_UNUSED, // CAM_SET_MEADOW_UNUSED
/* -54 */ CS_CAM_ID_GLOBAL_MEADOW_BIRDS_EYE, // CAM_SET_MEADOW_BIRDS_EYE
/* -53 */ CS_CAM_ID_GLOBAL_BIG_OCTO, // CAM_SET_BIG_OCTO
/* -52 */ CS_CAM_ID_GLOBAL_FOREST_DEFEAT_POE, // CAM_SET_FOREST_DEFEAT_POE
/* -51 */ CS_CAM_ID_GLOBAL_FOREST_UNUSED, // CAM_SET_FOREST_UNUSED
/* -50 */ CS_CAM_ID_GLOBAL_FIRE_STAIRCASE, // CAM_SET_FIRE_STAIRCASE
/* -49 */ CS_CAM_ID_GLOBAL_ELEVATOR_PLATFORM, // CAM_SET_ELEVATOR_PLATFORM
/* -48 */ CS_CAM_ID_GLOBAL_SCENE_TRANSITION, // CAM_SET_SCENE_TRANSITION
/* -47 */ CS_CAM_ID_GLOBAL_SCENE_UNUSED, // CAM_SET_SCENE_UNUSED
/* -46 */ CS_CAM_ID_GLOBAL_BEAN_LOST_WOODS, // CAM_SET_BEAN_LOST_WOODS
/* -45 */ CS_CAM_ID_GLOBAL_BEAN_GENERIC, // CAM_SET_BEAN_GENERIC
/* -44 */ CS_CAM_ID_GLOBAL_CS_ATTENTION, // CAM_SET_CS_ATTENTION
/* -43 */ CS_CAM_ID_GLOBAL_CS_3, // CAM_SET_CS_3
/* -42 */ CS_CAM_ID_GLOBAL_ITEM_UNUSED, // CAM_SET_ITEM_UNUSED
/* -41 */ CS_CAM_ID_GLOBAL_SLOW_CHEST_CS, // CAM_SET_SLOW_CHEST_CS
/* -40 */ CS_CAM_ID_GLOBAL_FOREST_BIRDS_EYE, // CAM_SET_FOREST_BIRDS_EYE
/* -39 */ CS_CAM_ID_GLOBAL_CS_TWISTED_HALLWAY, // CAM_SET_CS_TWISTED_HALLWAY
/* -38 */ CS_CAM_ID_GLOBAL_CS_0, // CAM_SET_CS_0
/* -37 */ CS_CAM_ID_GLOBAL_PIVOT_WATER_SURFACE, // CAM_SET_PIVOT_WATER_SURFACE
/* -36 */ CS_CAM_ID_GLOBAL_PIVOT_CORNER, // CAM_SET_PIVOT_CORNER
/* -35 */ CS_CAM_ID_GLOBAL_FREE2, // CAM_SET_FREE2
/* -34 */ CS_CAM_ID_GLOBAL_FREE0, // CAM_SET_FREE0
/* -33 */ CS_CAM_ID_GLOBAL_START1, // CAM_SET_START1
/* -32 */ CS_CAM_ID_GLOBAL_START0, // CAM_SET_START0
/* -31 */ CS_CAM_ID_GLOBAL_CRAWLSPACE, // CAM_SET_CRAWLSPACE
/* -30 */ CS_CAM_ID_GLOBAL_DOORC, // CAM_SET_DOORC
/* -29 */ CS_CAM_ID_GLOBAL_DOOR0, // CAM_SET_DOOR0
/* -28 */ CS_CAM_ID_GLOBAL_PREREND_SIDE_SCROLL, // CAM_SET_PREREND_SIDE_SCROLL
/* -27 */ CS_CAM_ID_GLOBAL_PREREND_PIVOT, // CAM_SET_PREREND_PIVOT
/* -26 */ CS_CAM_ID_GLOBAL_PREREND_FIXED, // CAM_SET_PREREND_FIXED
/* -25 */ CS_CAM_ID_GLOBAL_PIVOT_IN_FRONT, // CAM_SET_PIVOT_IN_FRONT
/* -24 */ CS_CAM_ID_GLOBAL_PIVOT_SHOP_BROWSING, // CAM_SET_PIVOT_SHOP_BROWSING
/* -23 */ CS_CAM_ID_GLOBAL_PIVOT_CRAWLSPACE, // CAM_SET_PIVOT_CRAWLSPACE
/* -22 */ CS_CAM_ID_GLOBAL_CHU_BOWLING, // CAM_SET_CHU_BOWLING
/* -21 */ CS_CAM_ID_GLOBAL_MARKET_BALCONY, // CAM_SET_MARKET_BALCONY
/* -20 */ CS_CAM_ID_GLOBAL_TOWER_UNUSED, // CAM_SET_TOWER_UNUSED
/* -19 */ CS_CAM_ID_GLOBAL_TOWER_CLIMB, // CAM_SET_TOWER_CLIMB
/* -18 */ CS_CAM_ID_GLOBAL_BOSS_GANON, // CAM_SET_BOSS_GANON
/* -17 */ CS_CAM_ID_GLOBAL_BOSS_GANONDORF, // CAM_SET_BOSS_GANONDORF
/* -16 */ CS_CAM_ID_GLOBAL_BOSS_TWINROVA_FLOOR, // CAM_SET_BOSS_TWINROVA_FLOOR
/* -15 */ CS_CAM_ID_GLOBAL_BOSS_TWINROVA_PLATFORM, // CAM_SET_BOSS_TWINROVA_PLATFORM
/* -14 */ CS_CAM_ID_GLOBAL_BOSS_MORPHA, // CAM_SET_BOSS_MORPHA
/* -13 */ CS_CAM_ID_GLOBAL_BOSS_BONGO, // CAM_SET_BOSS_BONGO
/* -12 */ CS_CAM_ID_GLOBAL_BOSS_VOLVAGIA, // CAM_SET_BOSS_VOLVAGIA
/* -11 */ CS_CAM_ID_GLOBAL_BOSS_PHANTOM_GANON, // CAM_SET_BOSS_PHANTOM_GANON
/* -10 */ CS_CAM_ID_GLOBAL_BOSS_BARINADE, // CAM_SET_BOSS_BARINADE
/* -9 */ CS_CAM_ID_GLOBAL_BOSS_DODONGO, // CAM_SET_BOSS_DODONGO
/* -8 */ CS_CAM_ID_GLOBAL_BOSS_GOHMA, // CAM_SET_BOSS_GOHMA
/* -7 */ CS_CAM_ID_GLOBAL_HORSE, // CAM_SET_HORSE
/* -6 */ CS_CAM_ID_GLOBAL_NORMAL3, // CAM_SET_NORMAL3
/* -5 */ CS_CAM_ID_GLOBAL_DUNGEON1, // CAM_SET_DUNGEON1
/* -4 */ CS_CAM_ID_GLOBAL_DUNGEON0, // CAM_SET_DUNGEON0
/* -3 */ CS_CAM_ID_GLOBAL_NORMAL1, // CAM_SET_NORMAL1
/* -2 */ CS_CAM_ID_GLOBAL_NORMAL0, // CAM_SET_NORMAL0
/* -1 */ CS_CAM_ID_NONE,
// CamCsId's 0+ are sceneLayer-specific and index `ActorCsCamInfo`
} CutsceneCamId;
typedef enum CutsceneHudVisibility {
/* -1 */ CS_HUD_VISIBILITY_ALL_ALT = -1,
/* 0 */ CS_HUD_VISIBILITY_NONE,
/* 1 */ CS_HUD_VISIBILITY_ALL,
/* 2 */ CS_HUD_VISIBILITY_A_HEARTS_MAGIC,
/* 3 */ CS_HUD_VISIBILITY_C_HEARTS_MAGIC,
/* 4 */ CS_HUD_VISIBILITY_ALL_NO_MINIMAP,
/* 5 */ CS_HUD_VISIBILITY_A_B_C,
/* 6 */ CS_HUD_VISIBILITY_B_MINIMAP,
/* 7 */ CS_HUD_VISIBILITY_A
} CutsceneHudVisibility;
typedef enum CutsceneEndSfx {
/* 0 */ CS_END_SFX_NONE,
/* 1 */ CS_END_SFX_TRE_BOX_APPEAR,
/* 2 */ CS_END_SFX_CORRECT_CHIME,
/* 255 */ CS_END_SFX_NONE_ALT = 0xFF
} CutsceneEndSfx;
typedef enum CutsceneEndCam {
/* 0 */ CS_END_CAM_0,
/* 1 */ CS_END_CAM_1,
/* 2 */ CS_END_CAM_SMOOTH
} CutsceneEndCam;
typedef enum CutsceneId {
/* -1 */ CS_ID_NONE = -1,
// CsId's 0 - 119 are sceneLayer-specific and index `CutsceneEntry`
/* 0x78 */ CS_ID_GLOBAL_78 = 120,
/* 0x79 */ CS_ID_GLOBAL_79,
/* 0x7A */ CS_ID_GLOBAL_7A,
/* 0x7C */ CS_ID_GLOBAL_TALK,
/* 0x7D */ CS_ID_GLOBAL_DOOR,
/* 0x7F */ CS_ID_GLOBAL_END = 0x7F
} CutsceneId;
typedef struct {
/* 0x0 */ s16 numEntries;
/* 0x2 */ s16 unk_02; // unused
/* 0x4 */ s16 unk_04; // unused
/* 0x6 */ s16 duration; // total duration
} CsCmdCamSpline; // size = 0x8
// Both camAt and camEye
typedef struct {
/* 0x0 */ u8 interpType; // see `CutsceneCamInterpType`
/* 0x1 */ u8 weight; // for certain types of interpTypes, shifts the weight to certain points. Default is 100.
/* 0x2 */ s16 duration; // duration of current point
/* 0x4 */ Vec3s pos;
/* 0xA */ s16 relativeTo; // see `CutsceneCamRelativeTo`
} CsCmdCamPoint; // size = 0xC
typedef enum CutsceneCamInterpType {
/* 0 */ CS_CAM_INTERP_NONE, // values do not change.
// values 1-3 only uses a single point from the cmd
/* 1 */ CS_CAM_INTERP_SET, // values immediately set to cmd values.
/* 2 */ CS_CAM_INTERP_LINEAR, // Lerp to the target position
/* 3 */ CS_CAM_INTERP_SCALE, // Step to the target position in increments scaled by the remaining distance
// values 4-5 uses multiple points from the cmd
/* 4 */ CS_CAM_INTERP_MP_CUBIC, // cubic multi-point (identical to SM64/OoT)
/* 5 */ CS_CAM_INTERP_MP_QUAD, // quadratic multi-point
// value 6 only uses a single point from the cmd
/* 6 */ CS_CAM_INTERP_GEO, // does VecGeo calculations using fov
/* 7 */ CS_CAM_INTERP_OFF // interpolation is not processed.
} CutsceneCamInterpType;
typedef enum CutsceneCamRelativeTo {
/* 0 */ CS_CAM_REL_0,
/* 1 */ CS_CAM_REL_1,
/* 2 */ CS_CAM_REL_2,
/* 3 */ CS_CAM_REL_3,
/* 4 */ CS_CAM_REL_4,
/* 5 */ CS_CAM_REL_5
} CutsceneCamRelativeTo;
// Roll and Fov Data
typedef struct CsCmdCamMisc {
/* 0x0 */ s16 unused0; // used only in the unused interp function
/* 0x2 */ s16 roll;
/* 0x4 */ s16 fov;
/* 0x6 */ s16 unused1; // unused
} CsCmdCamMisc; // size = 0x8
typedef struct CutsceneCameraInterp {
/* 0x00 */ Vec3f curPos;
/* 0x0C */ Vec3f initPos;
/* 0x18 */ f32 initFov;
/* 0x1C */ f32 initRoll;
/* 0x2A */ f32 unk_20; // position adjustment based on fov?
/* 0x24 */ s16 curFrame;
/* 0x26 */ s16 waypoint;
/* 0x28 */ s16 duration;
/* 0x2A */ s16 numEntries;
/* 0x1E */ u8 curPoint;
/* 0x2D */ u8 type; // See `CutsceneCamInterpType`
} CutsceneCameraInterp; // size = 0x30
typedef struct CutsceneCamera {
/* 0x00 */ s16 splineIndex;
/* 0x02 */ s16 cmdIndex;
/* 0x04 */ s16 splineNeedsInit;
/* 0x06 */ s16 state;
/* 0x08 */ s16 nextSplineTimer;
/* 0x0A */ s16 updateSplineTimer;
/* 0x0C */ s16 duration; // Duration of the current spline
/* 0x10 */ CutsceneCameraInterp eyeInterp;
/* 0x40 */ CutsceneCameraInterp atInterp;
/* 0x70 */ CsCmdCamPoint* atCmd;
/* 0x74 */ CsCmdCamPoint* eyeCmd;
/* 0x78 */ CsCmdCamMisc* miscCmd;
/* 0x7C */ struct Camera* camera;
} CutsceneCamera; // size = 0x80
typedef enum {
/* 0 */ CS_CAM_STATE_UPDATE_ALL, // Update spline and next spline timer
/* 1 */ CS_CAM_STATE_UPDATE_SPLINE, // Update spline, do not advance next spline timer
/* 2 */ CS_CAM_STATE_PAUSE, // No updates
/* 3 */ CS_CAM_STATE_DONE_SPLINE, // Finished the current spline, ready for the next one
/* 999 */ CS_CAM_STATE_DONE = 999 // Finished all the splines.
} CutsceneCameraState;
typedef struct CutsceneContext {
/* 0x00 */ char unk_00[0x4];
/* 0x00 */ u8 scriptListCount;
/* 0x04 */ void* script;
/* 0x08 */ u8 state;
/* 0x0C */ f32 timer;
/* 0x10 */ u16 curFrame; // current frame of the script that is running
/* 0x12 */ u16 unk_12; // set but never used
/* 0x12 */ u16 scriptIndex;
/* 0x14 */ s32 subCamId;
/* 0x18 */ u16 camEyeSplinePointsAppliedFrame; // stores the frame the cam eye spline points data was last applied on
/* 0x1A */ u8 camAtReady; // cam `at` data is ready to be applied
/* 0x1B */ u8 camEyeReady; // cam `eye` data is ready to be applied
/* 0x1A */ u8 camAtReady; // cam `at` data is ready to be applied
/* 0x1B */ u8 camEyeReady; // cam `eye` data is ready to be applied
/* 0x1C */ CutsceneCameraPoint* camAtPoints;
/* 0x20 */ CutsceneCameraPoint* camEyePoints;
/* 0x24 */ CsCmdActorCue* playerCue;
/* 0x28 */ CsCmdActorCue* actorCues[10]; // "npcdemopnt"
/* 0x38 */ u16 originalBlurAlpha;
#if ENABLE_CUTSCENE_IMPROVEMENTS
CutsceneScriptEntry* scriptList;
#endif
} CutsceneContext; // size = 0x50
typedef union {
@@ -541,5 +758,38 @@ void Cutscene_UpdateScripted(struct PlayState* play, CutsceneContext* csCtx);
void Cutscene_HandleEntranceTriggers(struct PlayState* play);
void Cutscene_HandleConditionalTriggers(struct PlayState* play);
void Cutscene_SetScript(struct PlayState* play, void* script);
void Cutscene_StartScripted(struct PlayState* play, u8 scriptIndex);
#if ENABLE_CUTSCENE_IMPROVEMENTS
struct Camera;
struct Actor;
void CutsceneManager_Init(struct PlayState* play, CutsceneEntry* cutsceneList, s16 numEntries);
void CutsceneManager_StoreCamera(struct Camera* camera);
void CutsceneManager_ClearWaiting(void);
s16 CutsceneManager_Update(void);
void CutsceneManager_Queue(s16 csId);
s16 CutsceneManager_IsNext(s16 csId);
s16 CutsceneManager_StartWithPlayerCs(s16 csId, struct Actor* actor);
s16 CutsceneManager_StartWithPlayerCsAndSetFlag(s16 csId, struct Actor* actor);
s16 CutsceneManager_Start(s16 csId, struct Actor* actor);
s16 CutsceneManager_Stop(s16 csId);
s16 CutsceneManager_GetCurrentCsId(void);
CutsceneEntry* CutsceneManager_GetCutsceneEntry(s16 csId);
s16 CutsceneManager_GetAdditionalCsId(s16 csId);
s16 CutsceneManager_GetLength(s16 csId);
s16 CutsceneManager_GetCutsceneScriptIndex(s16 csId);
s16 CutsceneManager_GetCutsceneCustomValue(s16 csId);
s16 CutsceneManager_GetCurrentSubCamId(s16 csId);
s16 CutsceneManager_FindEntranceCsId(void);
s32 CutsceneManager_800F22C4(s16 csId, struct Actor* actor);
void CutsceneManager_SetReturnCamera(s16 camId);
s16 CutsceneManager_MarkNextCutscenes(void);
s32 CutsceneCamera_Init(struct Camera* camera, CutsceneCamera* csCamera);
s32 CutsceneCamera_UpdateSplines(u8* script, CutsceneCamera* csCamera);
void CutsceneCamera_SetState(s16 state);
void CutsceneCamera_Reset(void);
#endif
#endif

View File

@@ -3,6 +3,19 @@
#include "z64math.h"
// To be used with OLib_Vec3fAdd()
typedef enum {
/* 0 */ OLIB_ADD_COPY, // Copy `b` to dest
/* 1 */ OLIB_ADD_OFFSET, // Add `a` and `b` to dest, and also add the yaw of `a` to the dest
/* 2 */ OLIB_ADD // Add `a` and `b` to dest
} OlibVec3fAdd;
typedef enum {
/* 0 */ OLIB_DIFF_COPY, // Copy `b` to dest
/* 1 */ OLIB_DIFF_OFFSET, // Sub `a` and `b` to dest, and also subs the yaw of `a` to the dest
/* 2 */ OLIB_DIFF // Sub `a` and `b` to dest
} OlibVec3fDiff;
f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b);
f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b);
f32 OLib_ClampMinDist(f32 val, f32 min);
@@ -14,4 +27,8 @@ VecGeo OLib_Vec3fToVecGeo(Vec3f* vec);
VecGeo OLib_Vec3fDiffToVecGeo(Vec3f* a, Vec3f* b);
Vec3f OLib_Vec3fDiffRad(Vec3f* a, Vec3f* b);
Vec3f OLib_AddVecGeoToVec3f(Vec3f* a, VecGeo* geo);
void OLib_Vec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode);
void OLib_Vec3fAdd(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode);
#endif

View File

@@ -113,6 +113,9 @@ typedef struct PlayState {
#if ENABLE_ANIMATED_MATERIALS
AnimatedMaterial* sceneMaterialAnims;
#endif
#if ENABLE_CUTSCENE_IMPROVEMENTS
ActorCsCamInfo* actorCsCamList;
#endif
} PlayState; // size = 0x12518
#define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamId])
@@ -149,6 +152,11 @@ void Play_TriggerVoidOut(PlayState* this);
void Play_TriggerRespawn(PlayState* this);
int Play_CamIsNotFixed(PlayState* this);
#if ENABLE_CUTSCENE_IMPROVEMENTS
u16 Play_GetActorCsCamSetting(PlayState* this, s32 csCamDataIndex);
Vec3s* Play_GetActorCsCamFuncData(PlayState* this, s32 csCamDataIndex);
#endif
#if DEBUG_FEATURES
extern void* gDebugCutsceneScript;
#endif

View File

@@ -4,6 +4,7 @@
#include "z64actor.h"
#include "alignment.h"
#include "face_change.h"
#include "config.h"
struct Player;
@@ -766,6 +767,12 @@ typedef struct WeaponInfo {
#define PLAYER_STATE3_RESTORE_NAYRUS_LOVE (1 << 6) // Set by ocarina effects actors when destroyed to signal Nayru's Love may be restored (see `ACTOROVL_ALLOC_ABSOLUTE`)
#define PLAYER_STATE3_FLYING_WITH_HOOKSHOT (1 << 7) // Flying in the air with the hookshot as it pulls Player toward its destination
#if ENABLE_CUTSCENE_IMPROVEMENTS
#define PLAYER_STATE3_CS_HALT (1 << 8) // Prevents updating the actor while a cutscene is playing
#else
#define PLAYER_STATE3_CS_HALT (0)
#endif
#define PLAYER_ALLOC_GI_MIN 0x2880 // title card maximum file size
typedef void (*PlayerActionFunc)(struct Player*, struct PlayState*);
@@ -862,7 +869,7 @@ typedef struct Player {
/* 0x0688 */ Actor* boomerangActor;
/* 0x068C */ Actor* naviActor;
/* 0x0690 */ s16 naviTextId;
/* 0x0692 */ u8 stateFlags3;
/* 0x0692 */ u32 stateFlags3;
/* 0x0693 */ s8 exchangeItemId;
/* 0x0694 */ Actor* talkActor; // Actor offering to talk, or currently talking to, depending on context
/* 0x0698 */ f32 talkActorDistance; // xz distance away from `talkActor`

View File

@@ -36,6 +36,15 @@ typedef enum HudVisibilityMode {
/* 11 */ HUD_VISIBILITY_HEARTS,
/* 12 */ HUD_VISIBILITY_A_B_MINIMAP,
/* 13 */ HUD_VISIBILITY_HEARTS_MAGIC_FORCE, // See above
/* 14 */ HUD_VISIBILITY_HEARTS_MAGIC_C,
/* 15 */ HUD_VISIBILITY_ALL_NO_MINIMAP,
/* 16 */ HUD_VISIBILITY_A_B_C,
/* 17 */ HUD_VISIBILITY_B_MINIMAP,
/* 18 */ HUD_VISIBILITY_HEARTS_MAGIC_MINIMAP,
/* 19 */ HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP,
/* 20 */ HUD_VISIBILITY_B_MAGIC,
/* 21 */ HUD_VISIBILITY_A_B,
/* 22 */ HUD_VISIBILITY_A_B_HEARTS_MAGIC_MINIMAP,
/* 50 */ HUD_VISIBILITY_ALL = 50, // Only raises button alphas if not disabled
/* 52 */ HUD_VISIBILITY_NOTHING_INSTANT = 52
} HudVisibilityMode;

View File

@@ -398,6 +398,26 @@ typedef struct {
} SCmdTextureAnimations; // size = 0x8
#endif
#if ENABLE_CUTSCENE_IMPROVEMENTS
typedef struct {
/* 0x0 */ u8 code;
/* 0x1 */ u8 data1;
/* 0x4 */ void* segment;
} SCmdCsCameraList; // size = 0x8
typedef struct {
/* 0x0 */ u8 code;
/* 0x1 */ u8 num;
/* 0x4 */ void* segment;
} SCmdCutsceneList; // size = 0x8
typedef struct {
/* 0x0 */ s16 setting; // camera setting described by CameraSettingType enum
/* 0x2 */ s16 count;
/* 0x4 */ Vec3s* actorCsCamFuncData; // s16 data grouped in threes
} ActorCsCamInfo; // size = 0x8
#endif
typedef union SceneCmd {
SCmdBase base;
SCmdPlayerEntryList playerEntryList;
@@ -431,6 +451,10 @@ typedef union SceneCmd {
#if ENABLE_ANIMATED_MATERIALS
SCmdTextureAnimations textureAnimations;
#endif
#if ENABLE_CUTSCENE_IMPROVEMENTS
SCmdCsCameraList actorCsCamList;
SCmdCutsceneList cutsceneList;
#endif
} SceneCmd; // size = 0x8
typedef BAD_RETURN(s32) (*SceneCmdHandlerFunc)(struct PlayState*, SceneCmd*);
@@ -556,8 +580,10 @@ typedef enum SceneDrawConfig {
/* 50 */ SDC_FISHING_POND,
/* 51 */ SDC_GANONS_TOWER_COLLAPSE_INTERIOR,
/* 52 */ SDC_INSIDE_GANONS_CASTLE_COLLAPSE,
#if ENABLE_ANIMATED_MATERIALS
/* 53 */ SDC_MAT_ANIM,
/* 54 */ SDC_MAT_ANIM_MANUAL_STEP,
#endif
/* 55 */ SDC_MAX
} SceneDrawConfig;
@@ -610,7 +636,13 @@ typedef enum SceneCommandTypeID {
#if ENABLE_F3DEX3
SCENE_CMD_ID_OCC_PLANE_CAND_LIST,
#endif
#if ENABLE_ANIMATED_MATERIALS
SCENE_CMD_ID_ANIMATED_MATERIAL_LIST,
#endif
#if ENABLE_CUTSCENE_IMPROVEMENTS
SCENE_CMD_ID_ACTOR_CUTSCENE_LIST,
SCENE_CMD_ID_ACTOR_CUTSCENE_CAM_LIST,
#endif
/* 0x1A */ SCENE_CMD_ID_MAX
} SceneCommandTypeID;
@@ -698,8 +730,18 @@ typedef enum SceneCommandTypeID {
{ SCENE_CMD_ID_OCC_PLANE_CAND_LIST, numPlanes, CMD_PTR(planeList) }
#endif
#if ENABLE_ANIMATED_MATERIALS
#define SCENE_CMD_ANIMATED_MATERIAL_LIST(matAnimList) \
{ SCENE_CMD_ID_ANIMATED_MATERIAL_LIST, 0, CMD_PTR(matAnimList) }
#endif
#if ENABLE_CUTSCENE_IMPROVEMENTS
#define SCENE_CMD_ACTOR_CUTSCENE_LIST(numEntries, actorCutsceneList) \
{ SCENE_CMD_ID_ACTOR_CUTSCENE_LIST, numEntries, CMD_PTR(actorCutsceneList) }
#define SCENE_CMD_ACTOR_CUTSCENE_CAM_LIST(numCams, camList) \
{ SCENE_CMD_ID_ACTOR_CUTSCENE_CAM_LIST, numCams, CMD_PTR(camList) }
#endif
s32 Scene_ExecuteCommands(struct PlayState* play, SceneCmd* sceneCmd);

View File

@@ -41,4 +41,8 @@ void Sfx_PlaySfxCentered(u16 sfxId);
void Sfx_PlaySfxCentered2(u16 sfxId);
void Sfx_PlaySfxAtPos(Vec3f* projectedPos, u16 sfxId);
s32 Math_StepToIImpl(s32 start, s32 target, s32 step);
void Math_StepToIGet(s32* pValue, s32 target, s32 step);
s32 Math_StepToI(s32* pValue, s32 target, s32 step);
#endif