From a5400fbde5c03c1f5eabd44ff8beceddde0b1c9f Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sun, 14 Jan 2024 10:34:50 -0500 Subject: [PATCH] Update ZAPD (#1533) * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "2b6f459b9" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "2b6f459b9" git-subrepo: version: "0.4.6" origin: "???" commit: "???" * Update ZAPD Co-authored-by: Yanis42 <35189056+Yanis42@users.noreply.github.com> * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "572b13236" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "572b13236" git-subrepo: version: "0.4.6" origin: "???" commit: "???" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "9601f2699" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "9601f2699" git-subrepo: version: "0.4.6" origin: "???" commit: "???" * fixes for new ZAPD * readd typedefs * remov enums * Reading is hard --------- Co-authored-by: Yanis42 <35189056+Yanis42@users.noreply.github.com> --- include/z64actor.h | 2 +- include/z64bgcheck.h | 2 - include/z64curve.h | 7 - include/z64cutscene.h | 15 +- include/z64cutscene_commands.h | 34 - include/z64scene.h | 12 - include/z64skin.h | 7 - src/code/PreRender.c | 1 + src/code/z_eventmgr.c | 16 +- src/code/z_play.c | 4 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 2 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 2 +- tools/ZAPD/.gitrepo | 4 +- tools/ZAPD/ExporterTest/RoomExporter.cpp | 2 +- tools/ZAPD/README.md | 2 +- tools/ZAPD/ZAPD/GameConfig.cpp | 93 +++ tools/ZAPD/ZAPD/GameConfig.h | 33 + .../ZAPD/OtherStructs/CutsceneMM_Commands.cpp | 557 ++++++++++++-- .../ZAPD/OtherStructs/CutsceneMM_Commands.h | 443 +++++++++-- .../OtherStructs/CutsceneOoT_Commands.cpp | 461 +++++++++++ .../ZAPD/OtherStructs/CutsceneOoT_Commands.h | 314 ++++++++ .../ZAPD/OtherStructs/Cutscene_Commands.cpp | 596 --------------- .../ZAPD/OtherStructs/Cutscene_Commands.h | 267 ------- .../ZAPD/OtherStructs/Cutscene_Common.cpp | 128 ++++ .../ZAPD/ZAPD/OtherStructs/Cutscene_Common.h | 72 ++ .../ZAPD/OtherStructs/SkinLimbStructs.cpp | 247 +++--- .../ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h | 66 +- tools/ZAPD/ZAPD/ZAPD.vcxproj | 10 +- tools/ZAPD/ZAPD/ZAPD.vcxproj.filters | 30 +- tools/ZAPD/ZAPD/ZAnimation.cpp | 45 +- tools/ZAPD/ZAPD/ZAnimation.h | 24 +- tools/ZAPD/ZAPD/ZCollision.cpp | 6 +- tools/ZAPD/ZAPD/ZCutscene.cpp | 390 +++++----- tools/ZAPD/ZAPD/ZCutscene.h | 3 +- tools/ZAPD/ZAPD/ZLimb.cpp | 6 +- tools/ZAPD/ZAPD/ZLimb.h | 6 +- .../ZAPD/ZRoom/Commands/SetCameraSettings.cpp | 9 +- .../ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp | 18 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.h | 6 +- ...sceneList.cpp => SetCutsceneEntryList.cpp} | 39 +- ...rCutsceneList.h => SetCutsceneEntryList.h} | 20 +- .../ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp | 25 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h | 8 +- .../ZAPD/ZRoom/Commands/SetEntranceList.cpp | 23 +- .../ZAPD/ZRoom/Commands/SetEntranceList.h | 6 +- .../ZRoom/Commands/SetLightingSettings.cpp | 22 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp | 85 ++- tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h | 23 +- .../ZAPD/ZRoom/Commands/SetSpecialObjects.cpp | 6 + .../ZRoom/Commands/SetWorldMapVisited.cpp | 6 +- tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp | 4 +- tools/ZAPD/ZAPD/ZSkeleton.cpp | 2 +- tools/ZAPD/ZAPDUtils/Utils/Directory.h | 15 +- tools/ZAPDConfigs/MM/Config.xml | 2 +- tools/ZAPDConfigs/MM/EnumData.xml | 718 ++++++++++++++++++ 55 files changed, 3310 insertions(+), 1636 deletions(-) create mode 100644 tools/ZAPD/ZAPD/OtherStructs/CutsceneOoT_Commands.cpp create mode 100644 tools/ZAPD/ZAPD/OtherStructs/CutsceneOoT_Commands.h delete mode 100644 tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp delete mode 100644 tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h create mode 100644 tools/ZAPD/ZAPD/OtherStructs/Cutscene_Common.cpp create mode 100644 tools/ZAPD/ZAPD/OtherStructs/Cutscene_Common.h rename tools/ZAPD/ZAPD/ZRoom/Commands/{SetActorCutsceneList.cpp => SetCutsceneEntryList.cpp} (53%) rename tools/ZAPD/ZAPD/ZRoom/Commands/{SetActorCutsceneList.h => SetCutsceneEntryList.h} (66%) create mode 100644 tools/ZAPDConfigs/MM/EnumData.xml diff --git a/include/z64actor.h b/include/z64actor.h index fcd80ca919..f87ad3ba9e 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -122,7 +122,7 @@ typedef struct Actor { /* 0x01F */ s8 targetMode; // Controls how far the actor can be targeted from and how far it can stay locked on /* 0x020 */ s16 halfDaysBits; // Bitmask indicating which half-days this actor is allowed to not be killed(?) (TODO: not sure how to word this). If the current halfDayBit is not part of this mask then the actor is killed when spawning the setup actors /* 0x024 */ PosRot world; // Position/rotation in the world - /* 0x038 */ s8 csId; // ActorCutscene index, see `CutsceneId` + /* 0x038 */ s8 csId; // CutsceneEntry index, see `CutsceneId` /* 0x039 */ u8 audioFlags; // Another set of flags? Seems related to sfx or bgm /* 0x03C */ PosRot focus; // Target reticle focuses on this position. For player this represents head pos and rot /* 0x050 */ u16 sfxId; // Id of sound effect to play. Plays when value is set, then is cleared the following update cycle diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 3f98de4571..4d75287068 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -84,8 +84,6 @@ typedef struct { /* 0x4 */ Vec3s* bgCamFuncData; // s16 data grouped in threes (ex. Vec3s), is usually of type `BgCamFuncData` } BgCamInfo; // size = 0x8 -typedef BgCamInfo CamData; // TODO: ZAPD compatibility - // The structure used for all instances of s16 data from `BgCamInfo`. typedef struct { /* 0x00 */ Vec3s pos; diff --git a/include/z64curve.h b/include/z64curve.h index ae3c3442ba..2ee1eae2ee 100644 --- a/include/z64curve.h +++ b/include/z64curve.h @@ -59,11 +59,4 @@ void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f3 s32 SkelCurve_Update(struct PlayState* play, SkelCurve* skelCurve); void SkelCurve_Draw(struct Actor* actor, struct PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, struct Actor* thisx); - -// ZAPD compatibility typedefs -// TODO: Remove when ZAPD adds support for them -typedef CurveInterpKnot TransformData; -typedef CurveAnimationHeader TransformUpdateIndex; -typedef CurveSkeletonHeader SkelCurveLimbList; - #endif // Z64_CURVE_H diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 52a6cf1bd3..82d2308902 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -599,10 +599,6 @@ typedef struct { /* 0x7 */ u8 spawnFlags; // See `CS_SPAWN_FLAG_` } CutsceneScriptEntry; // size = 0x8 -// ZAPD compatibility typedefs -// TODO: Remove when ZAPD adds support for them -typedef CutsceneScriptEntry CutsceneEntry; - typedef struct { /* 0x00 */ u8 scriptListCount; /* 0x04 */ CutsceneData* script; @@ -631,13 +627,11 @@ typedef struct { /* 0x0C */ s16 hudVisibility; /* 0x0E */ u8 endCam; /* 0x0F */ u8 letterboxSize; -} ActorCutscene; // size = 0x10 -// TODO: rename `ActorCutscene` to `CutsceneEntry` once ZAPD uses `CutsceneScriptEntry` -// typedef CutsceneEntry ActorCutscene; +} CutsceneEntry; // size = 0x10 typedef enum { /* -1 */ CS_ID_NONE = -1, - // CsId's 0 - 119 are sceneLayer-specific and index `ActorCutscene` + // 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, @@ -760,7 +754,6 @@ typedef enum CutsceneCamRelativeTo { /* 5 */ CS_CAM_REL_5 } CutsceneCamRelativeTo; - // Roll and Fov Data typedef struct CsCmdCamMisc { /* 0x0 */ s16 unused0; // used only in the unused interp function @@ -827,7 +820,7 @@ s32 Cutscene_GetCueChannel(struct PlayState* play, u16 cueType); s32 Cutscene_IsCueInChannel(struct PlayState* play, u16 cueType); u8 Cutscene_IsPlaying(struct PlayState* play); -void CutsceneManager_Init(struct PlayState* play, ActorCutscene* cutsceneList, s16 numEntries); +void CutsceneManager_Init(struct PlayState* play, CutsceneEntry* cutsceneList, s16 numEntries); void CutsceneManager_StoreCamera(Camera* camera); void CutsceneManager_ClearWaiting(void); s16 CutsceneManager_Update(void); @@ -838,7 +831,7 @@ s16 CutsceneManager_StartWithPlayerCsAndSetFlag(s16 csId, Actor* actor); s16 CutsceneManager_Start(s16 csId, Actor* actor); s16 CutsceneManager_Stop(s16 csId); s16 CutsceneManager_GetCurrentCsId(void); -ActorCutscene* CutsceneManager_GetCutsceneEntry(s16 csId); +CutsceneEntry* CutsceneManager_GetCutsceneEntry(s16 csId); s16 CutsceneManager_GetAdditionalCsId(s16 csId); s16 CutsceneManager_GetLength(s16 csId); s16 CutsceneManager_GetCutsceneScriptIndex(s16 csId); diff --git a/include/z64cutscene_commands.h b/include/z64cutscene_commands.h index 50e1ce451e..749f742f85 100644 --- a/include/z64cutscene_commands.h +++ b/include/z64cutscene_commands.h @@ -665,40 +665,6 @@ */ #define CS_END() { CMD_W(0xFFFFFFFF) } -// TODO: Fix ZAPD and delete these -#define CS_ACTOR_ACTION_LIST CS_ACTOR_CUE_LIST -#define CS_ACTOR_ACTION CS_ACTOR_CUE -#define CS_PLAYER_ACTION_LIST CS_PLAYER_CUE_LIST -#define CS_PLAYER_ACTION CS_PLAYER_CUE -#define CS_LIGHTING_LIST CS_LIGHT_SETTING_LIST -#define CS_CAMERA_LIST CS_CAM_SPLINE_LIST -#define CS_TEXT_DISPLAY_TEXTBOX CS_TEXT -#define CS_TEXT_LEARN_SONG CS_TEXT_OCARINA_ACTION -#define CS_SCENE_TRANS_FX_LIST CS_TRANSITION_LIST -#define CS_SCENE_TRANS_FX CS_TRANSITION -#define CS_GIVETATL_LIST CS_GIVE_TATL_LIST -#define CS_GIVETATL CS_GIVE_TATL -#define CS_PLAYSEQ_LIST CS_START_SEQ_LIST -#define CS_STOPSEQ_LIST CS_STOP_SEQ_LIST -#define CS_FADESEQ_LIST CS_FADE_OUT_SEQ_LIST -#define CS_FADESEQ CS_FADE_OUT_SEQ -#define CS_PLAYAMBIENCE_LIST CS_START_AMBIENCE_LIST -#define CS_PLAYAMBIENCE CS_START_AMBIENCE -#define CS_FADEAMBIENCE_LIST CS_FADE_OUT_AMBIENCE_LIST -#define CS_FADEAMBIENCE CS_FADE_OUT_AMBIENCE -#define CS_SCENE_UNK_130_LIST CS_SFX_REVERB_INDEX_2_LIST -#define CS_SCENE_UNK_130 CS_SFX_REVERB_INDEX_2 -#define CS_SCENE_UNK_131_LIST CS_SFX_REVERB_INDEX_1_LIST -#define CS_SCENE_UNK_131 CS_SFX_REVERB_INDEX_1 -#define CS_SCENE_UNK_132_LIST CS_MODIFY_SEQ_LIST -#define CS_SCENE_UNK_132 CS_MODIFY_SEQ -#define CS_MOTIONBLUR_LIST CS_MOTION_BLUR_LIST -#define CS_MOTIONBLUR CS_MOTION_BLUR -#define CS_FADESCREEN_LIST CS_TRANSITION_GENERAL_LIST -#define CS_FADESCREEN CS_TRANSITION_GENERAL -#define CS_TERMINATOR_LIST CS_DESTINATION_LIST -#define CS_TERMINATOR CS_DESTINATION - #define CS_PLAYSEQ(seqId, startFrame, endFrame) \ CS_START_SEQ((seqId)-1, startFrame, endFrame) diff --git a/include/z64scene.h b/include/z64scene.h index c994caa08a..d89aacb64c 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -312,9 +312,6 @@ typedef union { RoomShapeCullable cullable; } RoomShape; // "Ground Shape" -// TODO: update ZAPD -#define SCENE_CMD_MESH SCENE_CMD_ROOM_SHAPE - // TODO: Check which ones don't exist typedef enum { /* 0 */ ROOM_BEHAVIOR_TYPE1_0, @@ -468,10 +465,6 @@ typedef struct { /* 0x4 */ void* params; } AnimatedMaterial; // size = 0x8 -// TODO: ZAPD -typedef RoomShapeCullableEntry PolygonDlist2; -typedef RoomShapeCullable PolygonType2; - #define OBJECT_SLOT_NONE -1 typedef struct { @@ -522,8 +515,6 @@ typedef struct { /* 0x4 */ Vec3s* actorCsCamFuncData; // s16 data grouped in threes } ActorCsCamInfo; // size = 0x8 -typedef ActorCsCamInfo CsCameraEntry; // TODO: Remove once ZAPD updates its structs - typedef union { /* Command: N/A */ SCmdBase base; /* Command: 0x00 */ SCmdSpawnList spawnList; @@ -898,9 +889,6 @@ typedef enum { #define SCENE_CMD_MINIMAP_COMPASS_ICON_INFO(compassIconCount, compassIconInfo) \ { SCENE_CMD_ID_MINIMAP_COMPASS_ICON_INFO, compassIconCount, CMD_PTR(compassIconInfo) } - // TODO: ZAPD Capatability -#define SCENE_CMD_MISC_SETTINGS SCENE_CMD_SET_REGION_VISITED -#define SCENE_CMD_CUTSCENE_LIST SCENE_CMD_CUTSCENE_SCRIPT_LIST s32 Object_SpawnPersistent(ObjectContext* objectCtx, s16 id); void Object_InitContext(struct GameState* gameState, ObjectContext* objectCtx); diff --git a/include/z64skin.h b/include/z64skin.h index b334e939ce..2359ada620 100644 --- a/include/z64skin.h +++ b/include/z64skin.h @@ -48,13 +48,6 @@ typedef struct { /* 0x8 */ Gfx* dlist; } SkinAnimatedLimbData; // size = 0xC -// ZAPD compatibility typedefs -// TODO: Remove when ZAPD adds support for them -typedef SkinVertex Struct_800A57C0; -typedef SkinTransformation Struct_800A598C_2; -typedef SkinAnimatedLimbData Struct_800A5E28; -typedef SkinLimbModif Struct_800A598C; - #define SKIN_LIMB_TYPE_ANIMATED 4 #define SKIN_LIMB_TYPE_NORMAL 11 diff --git a/src/code/PreRender.c b/src/code/PreRender.c index d058fded39..70963d1261 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -16,6 +16,7 @@ #include "slowly.h" #include "stack.h" #include "stackcheck.h" +#include "prevent_bss_reordering.h" /** * Assigns the "save" values in PreRender diff --git a/src/code/z_eventmgr.c b/src/code/z_eventmgr.c index d682ed4f44..5bad9f1a14 100644 --- a/src/code/z_eventmgr.c +++ b/src/code/z_eventmgr.c @@ -8,7 +8,7 @@ #include "z64shrink_window.h" #include "libc/string.h" -ActorCutscene sGlobalCutsceneList[] = { +CutsceneEntry sGlobalCutsceneList[] = { // CS_ID_GLOBAL_78 { -100, -1, CS_CAM_ID_NONE, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE_ALT, 255, CS_HUD_VISIBILITY_ALL_ALT, 255, 255 }, @@ -57,7 +57,7 @@ CutsceneManager sCutsceneMgr = { CS_ID_NONE, 0, CS_ID_NONE, SUB_CAM_ID_DONE, NULL, CS_START_0, NULL, CAM_ID_MAIN, false, }; -ActorCutscene* sSceneCutsceneList; +CutsceneEntry* sSceneCutsceneList; s16 sSceneCutsceneCount; u8 sWaitingCutsceneList[16]; static s32 sBssPad; @@ -110,7 +110,7 @@ s16 CutsceneManager_SetHudVisibility(s16 csHudVisibility) { return hudVisibility; } -ActorCutscene* CutsceneManager_GetCutsceneEntryImpl(s16 csId) { +CutsceneEntry* CutsceneManager_GetCutsceneEntryImpl(s16 csId) { if (csId < CS_ID_GLOBAL_78) { return &sSceneCutsceneList[csId]; } else { @@ -119,7 +119,7 @@ ActorCutscene* CutsceneManager_GetCutsceneEntryImpl(s16 csId) { } } -void CutsceneManager_Init(PlayState* play, ActorCutscene* cutsceneList, s16 numEntries) { +void CutsceneManager_Init(PlayState* play, CutsceneEntry* cutsceneList, s16 numEntries) { s32 i; sSceneCutsceneList = cutsceneList; @@ -204,7 +204,7 @@ s16 CutsceneManager_MarkNextCutscenes(void) { #define CUR_CAM sCutsceneMgr.play->cameraPtrs[sCutsceneMgr.subCamId] void CutsceneManager_End(void) { - ActorCutscene* csEntry; + CutsceneEntry* csEntry; s16 oldCamId; s16 oldStateFlags; @@ -375,7 +375,7 @@ s16 CutsceneManager_StartWithPlayerCsAndSetFlag(s16 csId, Actor* actor) { } s16 CutsceneManager_Start(s16 csId, Actor* actor) { - ActorCutscene* csEntry; + CutsceneEntry* csEntry; Camera* subCam; Camera* retCam; s32 csType = 0; @@ -444,7 +444,7 @@ s16 CutsceneManager_Start(s16 csId, Actor* actor) { } s16 CutsceneManager_Stop(s16 csId) { - ActorCutscene* csEntry; + CutsceneEntry* csEntry; if (csId <= CS_ID_NONE) { return csId; @@ -472,7 +472,7 @@ s16 CutsceneManager_GetCurrentCsId(void) { return sCutsceneMgr.csId; } -ActorCutscene* CutsceneManager_GetCutsceneEntry(s16 csId) { +CutsceneEntry* CutsceneManager_GetCutsceneEntry(s16 csId) { return CutsceneManager_GetCutsceneEntryImpl(csId); } diff --git a/src/code/z_play.c b/src/code/z_play.c index bd19cbc940..046eae6760 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -2040,7 +2040,7 @@ s16 sPlayerCsIdToCsCamId[] = { /** * Extract the common cutscene ids used by Player from the scene and set the cutscene ids in this->playerCsIds. * If a playerCsId is not present in the scene, then that particular id is set to CS_ID_NONE. - * Otherwise, if there is an ActorCutscene where csCamId matches the appropriate element of sPlayerCsIdToCsCamId, + * Otherwise, if there is an CutsceneEntry where csCamId matches the appropriate element of sPlayerCsIdToCsCamId, * set the corresponding playerActorCsId (and possibly change its priority for the zeroth one). */ void Play_AssignPlayerCsIdsFromScene(GameState* thisx, s32 spawnCsId) { @@ -2050,7 +2050,7 @@ void Play_AssignPlayerCsIdsFromScene(GameState* thisx, s32 spawnCsId) { s16* csCamId = sPlayerCsIdToCsCamId; for (i = 0; i < ARRAY_COUNT(this->playerCsIds); i++, curPlayerCsId++, csCamId++) { - ActorCutscene* csEntry; + CutsceneEntry* csEntry; s32 curCsId; *curPlayerCsId = CS_ID_NONE; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index e58c6e536b..946c77c0fb 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -809,7 +809,7 @@ void EnMa4_SetupBeginEponasSongCs(EnMa4* this) { this->actionFunc = EnMa4_BeginEponasSongCs; } -// Epona's Song cutscene is an ActorCutscene +// Epona's Song cutscene is an CutsceneEntry void EnMa4_BeginEponasSongCs(EnMa4* this, PlayState* play) { s16 csId = this->actor.csId; diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index c4e1aa7c18..b6d175e836 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -329,7 +329,7 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { sCsIdList[THREEDAY_DAYTIME_NIGHT] = csId; if (csId > CS_ID_NONE) { - ActorCutscene* csEntry = CutsceneManager_GetCutsceneEntry(sCsIdList[THREEDAY_DAYTIME_NIGHT]); + CutsceneEntry* csEntry = CutsceneManager_GetCutsceneEntry(sCsIdList[THREEDAY_DAYTIME_NIGHT]); SET_EVENTINF(EVENTINF_HAS_DAYTIME_TRANSITION_CS); sCsIdList[THREEDAY_DAYTIME_DAY] = csEntry->additionalCsId; diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index c8d51d0cf9..7eb187efc7 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 7f398831fbcf67210b37882b5017093a1d187d5c - parent = 71e36ae371f89b5f86a6d59c7ebc24b8a55ee43e + commit = 9601f2699c142bb8273d33763ef4d84e8a7d650f + parent = 3e1207d5e7818ab6676422cda10f206b180126db method = merge cmdver = 0.4.6 diff --git a/tools/ZAPD/ExporterTest/RoomExporter.cpp b/tools/ZAPD/ExporterTest/RoomExporter.cpp index 9a5ea19d14..4cc06b76f5 100644 --- a/tools/ZAPD/ExporterTest/RoomExporter.cpp +++ b/tools/ZAPD/ExporterTest/RoomExporter.cpp @@ -290,7 +290,7 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* uint32_t oldOffset = writer->GetBaseAddress(); writer->Seek(baseStreamEnd, SeekOffsetType::Start); - for (EntranceEntry entry : cmdEntrance->entrances) + for (Spawn entry : cmdEntrance->entrances) { writer->Write((uint8_t)entry.startPositionIndex); writer->Write((uint8_t)entry.roomToLoad); diff --git a/tools/ZAPD/README.md b/tools/ZAPD/README.md index e2d1f64e01..76dfbd1e95 100644 --- a/tools/ZAPD/README.md +++ b/tools/ZAPD/README.md @@ -28,7 +28,7 @@ to install it via Homebrew. #### Linux / *nix -ZAPD uses the clasic `Makefile` approach. To build just run `make` (or even better `make -j` for faster compilations). +ZAPD uses the classic `Makefile` approach. To build just run `make` (or even better `make -j` for faster compilations). You can configure a bit your ZAPD build with the following options: diff --git a/tools/ZAPD/ZAPD/GameConfig.cpp b/tools/ZAPD/ZAPD/GameConfig.cpp index 638480875c..2140464ec6 100644 --- a/tools/ZAPD/ZAPD/GameConfig.cpp +++ b/tools/ZAPD/ZAPD/GameConfig.cpp @@ -165,6 +165,98 @@ void GameConfig::ConfigFunc_ExternalFile(const tinyxml2::XMLElement& element) externalFiles.push_back(ExternalFile(fs::path(xmlPathValue), fs::path(outPathValue))); } +void GameConfig::ConfigFunc_EnumData(const tinyxml2::XMLElement& element) +{ + std::string path = Path::GetDirectoryName(configFilePath).string(); + path = path.append("/").append(element.Attribute("File")); + tinyxml2::XMLDocument doc; + tinyxml2::XMLError eResult = doc.LoadFile(path.c_str()); + + if (eResult != tinyxml2::XML_SUCCESS) + { + throw std::runtime_error("Error: Unable to read enum data."); + } + + tinyxml2::XMLNode* root = doc.FirstChild(); + + if (root == nullptr) + return; + + for (tinyxml2::XMLElement* csEnum = root->FirstChildElement(); csEnum != nullptr; + csEnum = csEnum->NextSiblingElement()) + { + for (tinyxml2::XMLElement* item = csEnum->FirstChildElement(); item != nullptr; + item = item->NextSiblingElement()) + { + std::string enumKey = csEnum->Attribute("Key"); + uint16_t itemIndex = atoi(item->Attribute("Index")); + const char* itemID = item->Attribute("ID"); + + // Common + if (enumKey == "cmd") + enumData.cutsceneCmd[itemIndex] = itemID; + + else if (enumKey == "miscType") + enumData.miscType[itemIndex] = itemID; + + else if (enumKey == "textType") + enumData.textType[itemIndex] = itemID; + + else if (enumKey == "fadeOutSeqPlayer") + enumData.fadeOutSeqPlayer[itemIndex] = itemID; + + else if (enumKey == "transitionType") + enumData.transitionType[itemIndex] = itemID; + + else if (enumKey == "destination") + enumData.destination[itemIndex] = itemID; + + else if (enumKey == "naviQuestHintType") + enumData.naviQuestHintType[itemIndex] = itemID; + + else if (enumKey == "ocarinaSongActionId") + enumData.ocarinaSongActionId[itemIndex] = itemID; + + else if (enumKey == "seqId") + enumData.seqId[itemIndex] = itemID; + + else if (enumKey == "playerCueId") + enumData.playerCueId[itemIndex] = itemID; + + // MM + else if (enumKey == "modifySeqType") + enumData.modifySeqType[itemIndex] = itemID; + + else if (enumKey == "chooseCreditsSceneType") + enumData.chooseCreditsSceneType[itemIndex] = itemID; + + else if (enumKey == "destinationType") + enumData.destinationType[itemIndex] = itemID; + + else if (enumKey == "motionBlurType") + enumData.motionBlurType[itemIndex] = itemID; + + else if (enumKey == "transitionGeneralType") + enumData.transitionGeneralType[itemIndex] = itemID; + + else if (enumKey == "rumbleType") + enumData.rumbleType[itemIndex] = itemID; + + else if (enumKey == "spawnFlag") + enumData.spawnFlag[itemIndex] = itemID; + + else if (enumKey == "endSfx") + enumData.endSfx[itemIndex] = itemID; + + else if (enumKey == "csSplineInterpType") + enumData.interpType[itemIndex] = itemID; + + else if (enumKey == "csSplineRelTo") + enumData.relTo[itemIndex] = itemID; + } + } +} + void GameConfig::ReadConfigFile(const fs::path& argConfigFilePath) { static const std::unordered_map ConfigFuncDictionary = { @@ -175,6 +267,7 @@ void GameConfig::ReadConfigFile(const fs::path& argConfigFilePath) {"SpecialEntranceList", &GameConfig::ConfigFunc_specialEntranceList}, {"TexturePool", &GameConfig::ConfigFunc_TexturePool}, {"BGConfig", &GameConfig::ConfigFunc_BGConfig}, + {"EnumData", &GameConfig::ConfigFunc_EnumData}, {"ExternalXMLFolder", &GameConfig::ConfigFunc_ExternalXMLFolder}, {"ExternalFile", &GameConfig::ConfigFunc_ExternalFile}, }; diff --git a/tools/ZAPD/ZAPD/GameConfig.h b/tools/ZAPD/ZAPD/GameConfig.h index d650c6d704..4f3b91f8c7 100644 --- a/tools/ZAPD/ZAPD/GameConfig.h +++ b/tools/ZAPD/ZAPD/GameConfig.h @@ -21,6 +21,37 @@ public: ExternalFile(fs::path nXmlPath, fs::path nOutPath); }; +// Stores data from the XML file, the integer is the index (via ATOI) and the string is the value +class EnumData +{ +public: + // Common + std::map cutsceneCmd; + std::map miscType; + std::map fadeOutSeqPlayer; + std::map transitionType; + std::map naviQuestHintType; + std::map ocarinaSongActionId; + std::map seqId; + + // OoT + std::map textType; + std::map destination; + std::map playerCueId; + + // MM + std::map modifySeqType; + std::map chooseCreditsSceneType; + std::map destinationType; + std::map motionBlurType; + std::map transitionGeneralType; + std::map rumbleType; + std::map spawnFlag; + std::map endSfx; + std::map interpType; + std::map relTo; +}; + class ZFile; class GameConfig @@ -34,6 +65,7 @@ public: std::vector entranceList; std::vector specialEntranceList; std::map texturePool; // Key = CRC + EnumData enumData; // ZBackground uint32_t bgScreenWidth = 320, bgScreenHeight = 240; @@ -59,6 +91,7 @@ public: void ConfigFunc_BGConfig(const tinyxml2::XMLElement& element); void ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element); void ConfigFunc_ExternalFile(const tinyxml2::XMLElement& element); + void ConfigFunc_EnumData(const tinyxml2::XMLElement& element); void ReadConfigFile(const fs::path& configFilePath); }; diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp index edefbc0518..b47bc40e16 100644 --- a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp @@ -1,40 +1,48 @@ #include "CutsceneMM_Commands.h" -#include #include - +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" +#include "WarningHandler.h" + +/**** GENERIC ****/ // Specific for command lists where each entry has size 8 bytes -const std::unordered_map csCommandsDescMM = { - {CutsceneMMCommands::CS_CMD_MISC, {"CS_MISC", "(0x%02X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_SET_LIGHTING, {"CS_LIGHTING", "(0x%02X, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX, {"CS_SCENE_TRANS_FX", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_MOTIONBLUR, {"CS_MOTIONBLUR", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_GIVETATL, {"CS_GIVETATL", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_PLAYSEQ, {"CS_PLAYSEQ", "(0x%04X, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_130, {"CS_SCENE_UNK_130", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_131, {"CS_SCENE_UNK_131", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_132, {"CS_SCENE_UNK_132", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_STOPSEQ, {"CS_STOPSEQ", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_PLAYAMBIENCE, {"CS_PLAYAMBIENCE", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_FADEAMBIENCE, {"CS_FADEAMBIENCE", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_TERMINATOR, {"CS_TERMINATOR", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES, - {"CS_CHOOSE_CREDITS_SCENES", "(%i, %i, %i)"}}, +const std::unordered_map csCommandsDescMM = { + {CutsceneMM_CommandType::CS_CMD_MISC, {"CS_MISC", "(%s, %i, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_LIGHT_SETTING, {"CS_LIGHT_SETTING", "(0x%02X, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_TRANSITION, {"CS_TRANSITION", "(%s, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_MOTION_BLUR, {"CS_MOTION_BLUR", "(%s, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_GIVE_TATL, {"CS_GIVE_TATL", "(%s, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_START_SEQ, {"CS_START_SEQ", "(%s, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_SFX_REVERB_INDEX_2, + {"CS_SFX_REVERB_INDEX_2", "(0x%04X, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_SFX_REVERB_INDEX_1, + {"CS_SFX_REVERB_INDEX_1", "(0x%04X, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_MODIFY_SEQ, {"CS_MODIFY_SEQ", "(%s, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_STOP_SEQ, {"CS_STOP_SEQ", "(%s, %i, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_START_AMBIENCE, {"CS_START_AMBIENCE", "(0x%04X, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_FADE_OUT_AMBIENCE, + {"CS_FADE_OUT_AMBIENCE", "(0x%04X, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_DESTINATION, {"CS_DESTINATION", "(%s, %i, %i)"}}, + {CutsceneMM_CommandType::CS_CMD_CHOOSE_CREDITS_SCENES, + {"CS_CHOOSE_CREDITS_SCENES", "(%s, %i, %i)"}}, }; -CutsceneSubCommandEntry_GenericMMCmd::CutsceneSubCommandEntry_GenericMMCmd( - const std::vector& rawData, offset_t rawDataIndex, CutsceneMMCommands cmdId) +CutsceneMMSubCommandEntry_GenericCmd::CutsceneMMSubCommandEntry_GenericCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneMM_CommandType cmdId) : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) { } -std::string CutsceneSubCommandEntry_GenericMMCmd::GetBodySourceCode() const +std::string CutsceneMMSubCommandEntry_GenericCmd::GetBodySourceCode() const { + EnumData* enumData = &Globals::Instance->cfg.enumData; const auto& element = csCommandsDescMM.find(commandId); std::string entryFmt = "CS_UNK_DATA(0x%02X, %i, %i, %i)"; + std::string type = ""; + bool isIndexInSeqId = enumData->seqId.find(base - 1) != enumData->seqId.end(); if (element != csCommandsDescMM.end()) { @@ -42,12 +50,54 @@ std::string CutsceneSubCommandEntry_GenericMMCmd::GetBodySourceCode() const entryFmt += element->second.args; } + if (commandId == CutsceneMM_CommandType::CS_CMD_MISC && + enumData->miscType.find(base) != enumData->miscType.end()) + type = enumData->miscType[base]; + + else if (commandId == CutsceneMM_CommandType::CS_CMD_TRANSITION && + enumData->transitionType.find(base) != enumData->transitionType.end()) + type = enumData->transitionType[base]; + + else if (commandId == CutsceneMM_CommandType::CS_CMD_MOTION_BLUR && + enumData->motionBlurType.find(base) != enumData->motionBlurType.end()) + type = enumData->motionBlurType[base]; + + else if (commandId == CutsceneMM_CommandType::CS_CMD_MODIFY_SEQ && + enumData->modifySeqType.find(base) != enumData->modifySeqType.end()) + type = enumData->modifySeqType[base]; + + else if (commandId == CutsceneMM_CommandType::CS_CMD_DESTINATION && + enumData->destinationType.find(base) != enumData->destinationType.end()) + type = enumData->destinationType[base]; + + else if (commandId == CutsceneMM_CommandType::CS_CMD_CHOOSE_CREDITS_SCENES && + enumData->chooseCreditsSceneType.find(base) != enumData->chooseCreditsSceneType.end()) + type = enumData->chooseCreditsSceneType[base]; + + else if ((commandId == CutsceneMM_CommandType::CS_CMD_START_SEQ || + commandId == CutsceneMM_CommandType::CS_CMD_STOP_SEQ) && + isIndexInSeqId) + type = enumData->seqId[base - 1]; + + else if (commandId == CutsceneMM_CommandType::CS_CMD_GIVE_TATL) + type = base ? "true" : "false"; + + if (type != "") + return StringHelper::Sprintf(entryFmt.c_str(), type.c_str(), startFrame, endFrame, pad); + + if (commandId == CutsceneMM_CommandType::CS_CMD_LIGHT_SETTING || + commandId == CutsceneMM_CommandType::CS_CMD_START_SEQ || + commandId == CutsceneMM_CommandType::CS_CMD_STOP_SEQ) + { + return StringHelper::Sprintf(entryFmt.c_str(), base - 1, startFrame, endFrame, pad); + } + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad); } CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, - CutsceneMMCommands cmdId) + CutsceneMM_CommandType cmdId) : CutsceneCommand(rawData, rawDataIndex) { rawDataIndex += 4; @@ -57,7 +107,7 @@ CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vectorGetRawSize(); } @@ -65,7 +115,7 @@ CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector(commandID)); + const auto& element = csCommandsDescMM.find(static_cast(commandID)); if (element != csCommandsDescMM.end()) { @@ -75,43 +125,157 @@ std::string CutsceneMMCommand_GenericCmd::GetCommandMacro() const return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); } -CutsceneSubCommandEntry_Camera::CutsceneSubCommandEntry_Camera(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) +/**** CAMERA ****/ + +CutsceneSubCommandEntry_SplineCamPoint::CutsceneSubCommandEntry_SplineCamPoint(const std::vector& rawData, + offset_t rawDataIndex): CutsceneSubCommandEntry(rawData, rawDataIndex) { + interpType = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0); + weight = BitConverter::ToUInt8BE(rawData, rawDataIndex + 1); + duration = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + posX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + posY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + posZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); + relTo = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); } -std::string CutsceneSubCommandEntry_Camera::GetBodySourceCode() const +std::string CutsceneSubCommandEntry_SplineCamPoint::GetBodySourceCode() const { - return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X)", base, startFrame); + const auto interpTypeMap = &Globals::Instance->cfg.enumData.interpType; + const auto relToMap = &Globals::Instance->cfg.enumData.relTo; + + return StringHelper::Sprintf("CS_CAM_POINT(%s, 0x%02X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, %s)", interpTypeMap->at(interpType).c_str(), weight, duration, posX, posY, posZ, relToMap->at(relTo).c_str()); } -size_t CutsceneSubCommandEntry_Camera::GetRawSize() const +size_t CutsceneSubCommandEntry_SplineCamPoint::GetRawSize() const +{ + return 0x0C; +} + + +CutsceneSubCommandEntry_SplineMiscPoint::CutsceneSubCommandEntry_SplineMiscPoint(const std::vector& rawData, + offset_t rawDataIndex): CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + roll = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + fov = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unused1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); +} + +std::string CutsceneSubCommandEntry_SplineMiscPoint::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_CAM_MISC(0x%04X, 0x%04X, 0x%04X, 0x%04X)", unused0, roll, fov, unused1); +} + +size_t CutsceneSubCommandEntry_SplineMiscPoint::GetRawSize() const +{ + return 0x08; +} + +CutsceneSubCommandEntry_SplineHeader::CutsceneSubCommandEntry_SplineHeader(const std::vector& rawData, + offset_t rawDataIndex): CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + numEntries = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + unused1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + duration = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); +} + +std::string CutsceneSubCommandEntry_SplineHeader::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_CAM_SPLINE(0x%04X, 0x%04X, 0x%04X, 0x%04X)", numEntries, unused0, unused1, duration); + +} + +size_t CutsceneSubCommandEntry_SplineHeader::GetRawSize() const +{ + return 0x08; +} + +CutsceneSubCommandEntry_SplineFooter::CutsceneSubCommandEntry_SplineFooter(const std::vector& rawData, + offset_t rawDataIndex): CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + uint16_t firstHalfWord = BitConverter::ToUInt16BE(rawData, rawDataIndex); + uint16_t secondHalfWord = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + + if (firstHalfWord != 0xFFFF || secondHalfWord != 4) { + HANDLE_ERROR(WarningType::InvalidExtractedData, "Invalid Spline Footer", + StringHelper::Sprintf("Invalid Spline footer. Was expecting 0xFFFF, 0x0004. Got 0x%04X, 0x%04X", + firstHalfWord, secondHalfWord)); + } +} + +std::string CutsceneSubCommandEntry_SplineFooter::GetBodySourceCode() const +{ + return "CS_CAM_END()"; +} + +size_t CutsceneSubCommandEntry_SplineFooter::GetRawSize() const { return 0x04; } -CutsceneMMCommand_Camera::CutsceneMMCommand_Camera(const std::vector& rawData, +CutsceneMMCommand_Spline::CutsceneMMCommand_Spline(const std::vector& rawData, offset_t rawDataIndex) : CutsceneCommand(rawData, rawDataIndex) { + numHeaders = 0; + totalCommands = 0; rawDataIndex += 4; - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries / 4; i++) - { - auto* entry = new CutsceneSubCommandEntry_Camera(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); + while(1) { + if (BitConverter::ToUInt16BE(rawData, rawDataIndex) == 0xFFFF) { + break; + } + numHeaders++; + + auto* header = new CutsceneSubCommandEntry_SplineHeader(rawData, rawDataIndex); + rawDataIndex += header->GetRawSize(); + entries.push_back(header); + + totalCommands += header->numEntries; + + for (uint32_t i = 0; i < header->numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_SplineCamPoint(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } + + for (uint32_t i = 0; i < header->numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_SplineCamPoint(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } + + for (uint32_t i = 0; i < header->numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_SplineMiscPoint(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } } + + auto* footer = new CutsceneSubCommandEntry_SplineFooter(rawData, rawDataIndex); + entries.push_back(footer); + rawDataIndex += footer->GetRawSize(); } -std::string CutsceneMMCommand_Camera::GetCommandMacro() const +std::string CutsceneMMCommand_Spline::GetCommandMacro() const { - return StringHelper::Sprintf("CS_CAMERA_LIST(%i)", numEntries); + return StringHelper::Sprintf("CS_CAM_SPLINE_LIST(%i)", numEntries); } -CutsceneSubCommandEntry_FadeScreen::CutsceneSubCommandEntry_FadeScreen( +size_t CutsceneMMCommand_Spline::GetCommandSize() const +{ + // 8 Bytes once for the spline command, 8 Bytes per spline the header, two groups of size 12, 1 group of size 8, 4 bytes for the footer. + return 8 + (8 * numHeaders) + ((totalCommands * 2) * 0xC) + (totalCommands * 8) + 4; +} + +/**** TRANSITION GENERAL ****/ + +CutsceneSubCommandEntry_TransitionGeneral::CutsceneSubCommandEntry_TransitionGeneral( const std::vector& rawData, offset_t rawDataIndex) : CutsceneSubCommandEntry(rawData, rawDataIndex) { @@ -123,18 +287,71 @@ CutsceneSubCommandEntry_FadeScreen::CutsceneSubCommandEntry_FadeScreen( unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); } -std::string CutsceneSubCommandEntry_FadeScreen::GetBodySourceCode() const +std::string CutsceneSubCommandEntry_TransitionGeneral::GetBodySourceCode() const { - return StringHelper::Sprintf("CS_FADESCREEN(0x%02X, %i, %i, %i, %i, %i)", base, startFrame, - endFrame, unk_06, unk_07, unk_08); + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (enumData->transitionGeneralType.find(base) != enumData->transitionGeneralType.end()) + return StringHelper::Sprintf("CS_TRANSITION_GENERAL(%s, %i, %i, %i, %i, %i)", + enumData->transitionGeneralType[base].c_str(), startFrame, + endFrame, unk_06, unk_07, unk_08); + + return StringHelper::Sprintf("CS_TRANSITION_GENERAL(0x%02X, %i, %i, %i, %i, %i)", base, + startFrame, endFrame, unk_06, unk_07, unk_08); } -size_t CutsceneSubCommandEntry_FadeScreen::GetRawSize() const +size_t CutsceneSubCommandEntry_TransitionGeneral::GetRawSize() const { return 0x0C; } -CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vector& rawData, +CutsceneMMCommand_TransitionGeneral::CutsceneMMCommand_TransitionGeneral( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_TransitionGeneral(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_TransitionGeneral::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TRANSITION_GENERAL_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeOutSeq::CutsceneSubCommandEntry_FadeOutSeq( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +/**** FADE OUT SEQUENCE ****/ + +std::string CutsceneSubCommandEntry_FadeOutSeq::GetBodySourceCode() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (enumData->fadeOutSeqPlayer.find(base) != enumData->fadeOutSeqPlayer.end()) + return StringHelper::Sprintf("CS_FADE_OUT_SEQ(%s, %i, %i)", + enumData->fadeOutSeqPlayer[base].c_str(), startFrame, + endFrame); + + return StringHelper::Sprintf("CS_FADE_OUT_SEQ(%i, %i, %i)", base, startFrame, endFrame); +} + +size_t CutsceneSubCommandEntry_FadeOutSeq::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeOutSeq::CutsceneMMCommand_FadeOutSeq(const std::vector& rawData, offset_t rawDataIndex) : CutsceneCommand(rawData, rawDataIndex) { @@ -143,53 +360,18 @@ CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vectorGetRawSize(); } } -std::string CutsceneMMCommand_FadeScreen::GetCommandMacro() const +std::string CutsceneMMCommand_FadeOutSeq::GetCommandMacro() const { - return StringHelper::Sprintf("CS_FADESCREEN_LIST(%i)", numEntries); + return StringHelper::Sprintf("CS_FADE_OUT_SEQ_LIST(%i)", numEntries); } -CutsceneSubCommandEntry_FadeSeq::CutsceneSubCommandEntry_FadeSeq( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); -} - -std::string CutsceneSubCommandEntry_FadeSeq::GetBodySourceCode() const -{ - return StringHelper::Sprintf("CS_FADESEQ(%i, %i, %i)", base, startFrame, endFrame); -} - -size_t CutsceneSubCommandEntry_FadeSeq::GetRawSize() const -{ - return 0x0C; -} - -CutsceneMMCommand_FadeSeq::CutsceneMMCommand_FadeSeq(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_FadeSeq(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneMMCommand_FadeSeq::GetCommandMacro() const -{ - return StringHelper::Sprintf("CS_FADESEQ_LIST(%i)", numEntries); -} +/**** NON IMPLEMENTED ****/ CutsceneSubCommandEntry_NonImplemented::CutsceneSubCommandEntry_NonImplemented( const std::vector& rawData, offset_t rawDataIndex) @@ -211,3 +393,210 @@ CutsceneMMCommand_NonImplemented::CutsceneMMCommand_NonImplemented( rawDataIndex += entry->GetRawSize(); } } + +/**** RUMBLE ****/ + +CutsceneMMSubCommandEntry_Rumble::CutsceneMMSubCommandEntry_Rumble( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + intensity = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + decayTimer = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + decayStep = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); +} + +std::string CutsceneMMSubCommandEntry_Rumble::GetBodySourceCode() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (enumData->rumbleType.find(base) != enumData->rumbleType.end()) + return StringHelper::Sprintf("CS_RUMBLE(%s, %i, %i, 0x%02X, 0x%02X, 0x%02X)", + enumData->rumbleType[base].c_str(), startFrame, endFrame, + intensity, decayTimer, decayStep); + + return StringHelper::Sprintf("CS_RUMBLE(0x%04X, %i, %i, 0x%02X, 0x%02X, 0x%02X)", base, + startFrame, endFrame, intensity, decayTimer, decayStep); +} + +size_t CutsceneMMSubCommandEntry_Rumble::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_Rumble::CutsceneMMCommand_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneMMSubCommandEntry_Rumble(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_Rumble::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_RUMBLE_LIST(%i)", numEntries); +} + +/**** TEXT ****/ + +CutsceneMMSubCommandEntry_Text::CutsceneMMSubCommandEntry_Text(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + textId1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + textId2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); +} + +std::string CutsceneMMSubCommandEntry_Text::GetBodySourceCode() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (type == 0xFFFF) + { + return StringHelper::Sprintf("CS_TEXT_NONE(%i, %i)", startFrame, endFrame); + } + + if (type == 2 && + enumData->ocarinaSongActionId.find(base) != enumData->ocarinaSongActionId.end()) + { + return StringHelper::Sprintf("CS_TEXT_OCARINA_ACTION(%s, %i, %i, 0x%X)", + enumData->ocarinaSongActionId[base].c_str(), startFrame, + endFrame, textId1); + } + + switch (type) + { + case 0: + return StringHelper::Sprintf("CS_TEXT_DEFAULT(0x%X, %i, %i, 0x%X, 0x%X)", base, startFrame, + endFrame, textId1, textId2); + + case 1: + return StringHelper::Sprintf("CS_TEXT_TYPE_1(0x%X, %i, %i, 0x%X, 0x%X)", base, startFrame, + endFrame, textId1, textId2); + + case 3: + return StringHelper::Sprintf("CS_TEXT_TYPE_3(0x%X, %i, %i, 0x%X, 0x%X)", base, startFrame, + endFrame, textId1, textId2); + + case 4: + return StringHelper::Sprintf("CS_TEXT_BOSSES_REMAINS(0x%X, %i, %i, 0x%X)", base, startFrame, + endFrame, textId1); + + case 5: + return StringHelper::Sprintf("CS_TEXT_ALL_NORMAL_MASKS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + } + + return nullptr; +} + +size_t CutsceneMMSubCommandEntry_Text::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_Text::CutsceneMMCommand_Text(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneMMSubCommandEntry_Text(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_Text::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TEXT_LIST(%i)", numEntries); +} + +/**** ACTOR CUE ****/ + +CutsceneMMSubCommandEntry_ActorCue::CutsceneMMSubCommandEntry_ActorCue( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); + startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0xC); + startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x10); + startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x14); + endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x18); + endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x1C); + endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x20); + normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x24); + normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x28); + normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneMMSubCommandEntry_ActorCue::GetBodySourceCode() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (static_cast(commandID) == CutsceneMM_CommandType::CS_CMD_PLAYER_CUE) + { + return StringHelper::Sprintf("CS_PLAYER_CUE(%s, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " + "%i, %i, %i, %i, %.8ef, %.8ef, %.8ef)", + enumData->playerCueId[base].c_str(), startFrame, endFrame, + rotX, rotY, rotZ, startPosX, startPosY, startPosZ, endPosX, + endPosY, endPosZ, normalX, normalY, normalZ); + } + else + { + return StringHelper::Sprintf("CS_ACTOR_CUE(%i, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " + "%i, %i, %i, %i, %.8ef, %.8ef, %.8ef)", + base, startFrame, endFrame, rotX, rotY, rotZ, startPosX, + startPosY, startPosZ, endPosX, endPosY, endPosZ, normalX, + normalY, normalZ); + } +} + +size_t CutsceneMMSubCommandEntry_ActorCue::GetRawSize() const +{ + return 0x30; +} + +CutsceneMMCommand_ActorCue::CutsceneMMCommand_ActorCue(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneMMSubCommandEntry_ActorCue(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_ActorCue::GetCommandMacro() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (static_cast(commandID) == CutsceneMM_CommandType::CS_CMD_PLAYER_CUE) + { + return StringHelper::Sprintf("CS_PLAYER_CUE_LIST(%i)", numEntries); + } + + if (enumData->cutsceneCmd.find(commandID) != enumData->cutsceneCmd.end()) + { + return StringHelper::Sprintf("CS_ACTOR_CUE_LIST(%s, %i)", + enumData->cutsceneCmd[commandID].c_str(), numEntries); + } + return StringHelper::Sprintf("CS_ACTOR_CUE_LIST(0x%03X, %i)", commandID, numEntries); +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h index c8ae4eb603..9891a24ac4 100644 --- a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h @@ -1,51 +1,256 @@ #pragma once -#include "Cutscene_Commands.h" +#include "Cutscene_Common.h" -enum class CutsceneMMCommands +// https://github.com/zeldaret/mm/blob/0c7b90cf97f26483c8b6a98ae099a295f61e72ab/include/z64cutscene.h#L294-530 +enum class CutsceneMM_CommandType { - /* 0x00A */ CS_CMD_TEXTBOX = 0xA, - /* 0x05A */ CS_CMD_CAMERA = 0x5A, - /* 0x096 */ CS_CMD_MISC = 0x96, - /* 0x097 */ CS_CMD_SET_LIGHTING, - /* 0x098 */ CS_CMD_SCENE_TRANS_FX, - /* 0x099 */ CS_CMD_MOTIONBLUR, - /* 0x09A */ CS_CMD_GIVETATL, - /* 0x09B */ CS_CMD_FADESCREEN, - /* 0x09C */ CS_CMD_FADESEQ, - /* 0x09D */ CS_CMD_SETTIME, - /* 0x0C8 */ CS_CMD_SET_PLAYER_ACTION = 0xC8, - /* 0x0FA */ CS_CMD_UNK_FA = 0xFA, - /* 0x0FE */ CS_CMD_UNK_FE = 0xFE, - /* 0x0FF */ CS_CMD_UNK_FF, - /* 0x100 */ CS_CMD_UNK_100, - /* 0x101 */ CS_CMD_UNK_101, - /* 0x102 */ CS_CMD_UNK_102, - /* 0x103 */ CS_CMD_UNK_103, - /* 0x104 */ CS_CMD_UNK_104, - /* 0x105 */ CS_CMD_UNK_105, - /* 0x108 */ CS_CMD_UNK_108 = 0x108, - /* 0x109 */ CS_CMD_UNK_109, - /* 0x12C */ CS_CMD_PLAYSEQ = 0x12C, - /* 0x12D */ CS_CMD_UNK_12D, - /* 0x130 */ CS_CMD_130 = 0x130, - /* 0x131 */ CS_CMD_131 = 0x131, - /* 0x132 */ CS_CMD_132 = 0x132, - /* 0x133 */ CS_CMD_STOPSEQ, - /* 0x134 */ CS_CMD_PLAYAMBIENCE, - /* 0x135 */ CS_CMD_FADEAMBIENCE, - /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* -2 */ CS_CMD_ACTOR_CUE_POST_PROCESS = -2, + /* -1 */ CS_CAM_STOP, + /* 0x00A */ CS_CMD_TEXT = 10, + /* 0x05A */ CS_CMD_CAMERA_SPLINE = 90, + /* 0x064 */ CS_CMD_ACTOR_CUE_100 = 100, + /* 0x065 */ CS_CMD_ACTOR_CUE_101, + /* 0x066 */ CS_CMD_ACTOR_CUE_102, + /* 0x067 */ CS_CMD_ACTOR_CUE_103, + /* 0x068 */ CS_CMD_ACTOR_CUE_104, + /* 0x069 */ CS_CMD_ACTOR_CUE_105, + /* 0x06A */ CS_CMD_ACTOR_CUE_106, + /* 0x06B */ CS_CMD_ACTOR_CUE_107, + /* 0x06C */ CS_CMD_ACTOR_CUE_108, + /* 0x06D */ CS_CMD_ACTOR_CUE_109, + /* 0x06E */ CS_CMD_ACTOR_CUE_110, + /* 0x06F */ CS_CMD_ACTOR_CUE_111, + /* 0x070 */ CS_CMD_ACTOR_CUE_112, + /* 0x071 */ CS_CMD_ACTOR_CUE_113, + /* 0x072 */ CS_CMD_ACTOR_CUE_114, + /* 0x073 */ CS_CMD_ACTOR_CUE_115, + /* 0x074 */ CS_CMD_ACTOR_CUE_116, + /* 0x075 */ CS_CMD_ACTOR_CUE_117, + /* 0x076 */ CS_CMD_ACTOR_CUE_118, + /* 0x077 */ CS_CMD_ACTOR_CUE_119, + /* 0x078 */ CS_CMD_ACTOR_CUE_120, + /* 0x079 */ CS_CMD_ACTOR_CUE_121, + /* 0x07A */ CS_CMD_ACTOR_CUE_122, + /* 0x07B */ CS_CMD_ACTOR_CUE_123, + /* 0x07C */ CS_CMD_ACTOR_CUE_124, + /* 0x07D */ CS_CMD_ACTOR_CUE_125, + /* 0x07E */ CS_CMD_ACTOR_CUE_126, + /* 0x07F */ CS_CMD_ACTOR_CUE_127, + /* 0x080 */ CS_CMD_ACTOR_CUE_128, + /* 0x081 */ CS_CMD_ACTOR_CUE_129, + /* 0x082 */ CS_CMD_ACTOR_CUE_130, + /* 0x083 */ CS_CMD_ACTOR_CUE_131, + /* 0x084 */ CS_CMD_ACTOR_CUE_132, + /* 0x085 */ CS_CMD_ACTOR_CUE_133, + /* 0x086 */ CS_CMD_ACTOR_CUE_134, + /* 0x087 */ CS_CMD_ACTOR_CUE_135, + /* 0x088 */ CS_CMD_ACTOR_CUE_136, + /* 0x089 */ CS_CMD_ACTOR_CUE_137, + /* 0x08A */ CS_CMD_ACTOR_CUE_138, + /* 0x08B */ CS_CMD_ACTOR_CUE_139, + /* 0x08C */ CS_CMD_ACTOR_CUE_140, + /* 0x08D */ CS_CMD_ACTOR_CUE_141, + /* 0x08E */ CS_CMD_ACTOR_CUE_142, + /* 0x08F */ CS_CMD_ACTOR_CUE_143, + /* 0x090 */ CS_CMD_ACTOR_CUE_144, + /* 0x091 */ CS_CMD_ACTOR_CUE_145, + /* 0x092 */ CS_CMD_ACTOR_CUE_146, + /* 0x093 */ CS_CMD_ACTOR_CUE_147, + /* 0x094 */ CS_CMD_ACTOR_CUE_148, + /* 0x095 */ CS_CMD_ACTOR_CUE_149, + /* 0x096 */ CS_CMD_MISC, + /* 0x097 */ CS_CMD_LIGHT_SETTING, + /* 0x098 */ CS_CMD_TRANSITION, + /* 0x099 */ CS_CMD_MOTION_BLUR, + /* 0x09A */ CS_CMD_GIVE_TATL, + /* 0x09B */ CS_CMD_TRANSITION_GENERAL, + /* 0x09C */ CS_CMD_FADE_OUT_SEQ, + /* 0x09D */ CS_CMD_TIME, + /* 0x0C8 */ CS_CMD_PLAYER_CUE = 200, + /* 0x0C9 */ CS_CMD_ACTOR_CUE_201, + /* 0x0FA */ CS_CMD_UNK_DATA_FA = 0xFA, + /* 0x0FE */ CS_CMD_UNK_DATA_FE = 0xFE, + /* 0x0FF */ CS_CMD_UNK_DATA_FF, + /* 0x100 */ CS_CMD_UNK_DATA_100, + /* 0x101 */ CS_CMD_UNK_DATA_101, + /* 0x102 */ CS_CMD_UNK_DATA_102, + /* 0x103 */ CS_CMD_UNK_DATA_103, + /* 0x104 */ CS_CMD_UNK_DATA_104, + /* 0x105 */ CS_CMD_UNK_DATA_105, + /* 0x108 */ CS_CMD_UNK_DATA_108 = 0x108, + /* 0x109 */ CS_CMD_UNK_DATA_109, + /* 0x12C */ CS_CMD_START_SEQ = 300, + /* 0x12D */ CS_CMD_STOP_SEQ, + /* 0x12E */ CS_CMD_START_AMBIENCE, + /* 0x12F */ CS_CMD_FADE_OUT_AMBIENCE, + /* 0x130 */ CS_CMD_SFX_REVERB_INDEX_2, + /* 0x131 */ CS_CMD_SFX_REVERB_INDEX_1, + /* 0x132 */ CS_CMD_MODIFY_SEQ, + /* 0x15E */ CS_CMD_DESTINATION = 350, /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, - /* 0x190 */ CS_CMD_RUMBLE = 0x190, + /* 0x190 */ CS_CMD_RUMBLE = 400, + /* 0x1C2 */ CS_CMD_ACTOR_CUE_450 = 450, + /* 0x1C3 */ CS_CMD_ACTOR_CUE_451, + /* 0x1C4 */ CS_CMD_ACTOR_CUE_452, + /* 0x1C5 */ CS_CMD_ACTOR_CUE_453, + /* 0x1C6 */ CS_CMD_ACTOR_CUE_454, + /* 0x1C7 */ CS_CMD_ACTOR_CUE_455, + /* 0x1C8 */ CS_CMD_ACTOR_CUE_456, + /* 0x1C9 */ CS_CMD_ACTOR_CUE_457, + /* 0x1CA */ CS_CMD_ACTOR_CUE_458, + /* 0x1CB */ CS_CMD_ACTOR_CUE_459, + /* 0x1CC */ CS_CMD_ACTOR_CUE_460, + /* 0x1CD */ CS_CMD_ACTOR_CUE_461, + /* 0x1CE */ CS_CMD_ACTOR_CUE_462, + /* 0x1CF */ CS_CMD_ACTOR_CUE_463, + /* 0x1D0 */ CS_CMD_ACTOR_CUE_464, + /* 0x1D1 */ CS_CMD_ACTOR_CUE_465, + /* 0x1D2 */ CS_CMD_ACTOR_CUE_466, + /* 0x1D3 */ CS_CMD_ACTOR_CUE_467, + /* 0x1D4 */ CS_CMD_ACTOR_CUE_468, + /* 0x1D5 */ CS_CMD_ACTOR_CUE_469, + /* 0x1D6 */ CS_CMD_ACTOR_CUE_470, + /* 0x1D7 */ CS_CMD_ACTOR_CUE_471, + /* 0x1D8 */ CS_CMD_ACTOR_CUE_472, + /* 0x1D9 */ CS_CMD_ACTOR_CUE_473, + /* 0x1DA */ CS_CMD_ACTOR_CUE_474, + /* 0x1DB */ CS_CMD_ACTOR_CUE_475, + /* 0x1DC */ CS_CMD_ACTOR_CUE_476, + /* 0x1DD */ CS_CMD_ACTOR_CUE_477, + /* 0x1DE */ CS_CMD_ACTOR_CUE_478, + /* 0x1DF */ CS_CMD_ACTOR_CUE_479, + /* 0x1E0 */ CS_CMD_ACTOR_CUE_480, + /* 0x1E1 */ CS_CMD_ACTOR_CUE_481, + /* 0x1E2 */ CS_CMD_ACTOR_CUE_482, + /* 0x1E3 */ CS_CMD_ACTOR_CUE_483, + /* 0x1E4 */ CS_CMD_ACTOR_CUE_484, + /* 0x1E5 */ CS_CMD_ACTOR_CUE_485, + /* 0x1E6 */ CS_CMD_ACTOR_CUE_486, + /* 0x1E7 */ CS_CMD_ACTOR_CUE_487, + /* 0x1E8 */ CS_CMD_ACTOR_CUE_488, + /* 0x1E9 */ CS_CMD_ACTOR_CUE_489, + /* 0x1EA */ CS_CMD_ACTOR_CUE_490, + /* 0x1EB */ CS_CMD_ACTOR_CUE_491, + /* 0x1EC */ CS_CMD_ACTOR_CUE_492, + /* 0x1ED */ CS_CMD_ACTOR_CUE_493, + /* 0x1EE */ CS_CMD_ACTOR_CUE_494, + /* 0x1EF */ CS_CMD_ACTOR_CUE_495, + /* 0x1F0 */ CS_CMD_ACTOR_CUE_496, + /* 0x1F1 */ CS_CMD_ACTOR_CUE_497, + /* 0x1F2 */ CS_CMD_ACTOR_CUE_498, + /* 0x1F3 */ CS_CMD_ACTOR_CUE_499, + /* 0x1F4 */ CS_CMD_ACTOR_CUE_500, + /* 0x1F5 */ CS_CMD_ACTOR_CUE_501, + /* 0x1F6 */ CS_CMD_ACTOR_CUE_502, + /* 0x1F7 */ CS_CMD_ACTOR_CUE_503, + /* 0x1F8 */ CS_CMD_ACTOR_CUE_504, + /* 0x1F9 */ CS_CMD_ACTOR_CUE_SOTCS, + /* 0x1FA */ CS_CMD_ACTOR_CUE_506, + /* 0x1FB */ CS_CMD_ACTOR_CUE_507, + /* 0x1FC */ CS_CMD_ACTOR_CUE_508, + /* 0x1FD */ CS_CMD_ACTOR_CUE_509, + /* 0x1FE */ CS_CMD_ACTOR_CUE_510, + /* 0x1FF */ CS_CMD_ACTOR_CUE_511, + /* 0x200 */ CS_CMD_ACTOR_CUE_512, + /* 0x201 */ CS_CMD_ACTOR_CUE_513, + /* 0x202 */ CS_CMD_ACTOR_CUE_514, + /* 0x203 */ CS_CMD_ACTOR_CUE_515, + /* 0x204 */ CS_CMD_ACTOR_CUE_516, + /* 0x205 */ CS_CMD_ACTOR_CUE_517, + /* 0x206 */ CS_CMD_ACTOR_CUE_518, + /* 0x207 */ CS_CMD_ACTOR_CUE_519, + /* 0x208 */ CS_CMD_ACTOR_CUE_520, + /* 0x209 */ CS_CMD_ACTOR_CUE_521, + /* 0x20A */ CS_CMD_ACTOR_CUE_522, + /* 0x20B */ CS_CMD_ACTOR_CUE_523, + /* 0x20C */ CS_CMD_ACTOR_CUE_524, + /* 0x20D */ CS_CMD_ACTOR_CUE_525, + /* 0x20E */ CS_CMD_ACTOR_CUE_526, + /* 0x20F */ CS_CMD_ACTOR_CUE_527, + /* 0x210 */ CS_CMD_ACTOR_CUE_528, + /* 0x211 */ CS_CMD_ACTOR_CUE_529, + /* 0x212 */ CS_CMD_ACTOR_CUE_530, + /* 0x213 */ CS_CMD_ACTOR_CUE_531, + /* 0x214 */ CS_CMD_ACTOR_CUE_532, + /* 0x215 */ CS_CMD_ACTOR_CUE_533, + /* 0x216 */ CS_CMD_ACTOR_CUE_534, + /* 0x217 */ CS_CMD_ACTOR_CUE_535, + /* 0x218 */ CS_CMD_ACTOR_CUE_536, + /* 0x219 */ CS_CMD_ACTOR_CUE_537, + /* 0x21A */ CS_CMD_ACTOR_CUE_538, + /* 0x21B */ CS_CMD_ACTOR_CUE_539, + /* 0x21C */ CS_CMD_ACTOR_CUE_540, + /* 0x21D */ CS_CMD_ACTOR_CUE_541, + /* 0x21E */ CS_CMD_ACTOR_CUE_542, + /* 0x21F */ CS_CMD_ACTOR_CUE_543, + /* 0x220 */ CS_CMD_ACTOR_CUE_544, + /* 0x221 */ CS_CMD_ACTOR_CUE_545, + /* 0x222 */ CS_CMD_ACTOR_CUE_546, + /* 0x223 */ CS_CMD_ACTOR_CUE_547, + /* 0x224 */ CS_CMD_ACTOR_CUE_548, + /* 0x225 */ CS_CMD_ACTOR_CUE_549, + /* 0x226 */ CS_CMD_ACTOR_CUE_550, + /* 0x227 */ CS_CMD_ACTOR_CUE_551, + /* 0x228 */ CS_CMD_ACTOR_CUE_552, + /* 0x229 */ CS_CMD_ACTOR_CUE_553, + /* 0x22A */ CS_CMD_ACTOR_CUE_554, + /* 0x22B */ CS_CMD_ACTOR_CUE_555, + /* 0x22C */ CS_CMD_ACTOR_CUE_556, + /* 0x22D */ CS_CMD_ACTOR_CUE_557, + /* 0x22E */ CS_CMD_ACTOR_CUE_558, + /* 0x22F */ CS_CMD_ACTOR_CUE_559, + /* 0x230 */ CS_CMD_ACTOR_CUE_560, + /* 0x231 */ CS_CMD_ACTOR_CUE_561, + /* 0x232 */ CS_CMD_ACTOR_CUE_562, + /* 0x233 */ CS_CMD_ACTOR_CUE_563, + /* 0x234 */ CS_CMD_ACTOR_CUE_564, + /* 0x235 */ CS_CMD_ACTOR_CUE_565, + /* 0x236 */ CS_CMD_ACTOR_CUE_566, + /* 0x237 */ CS_CMD_ACTOR_CUE_567, + /* 0x238 */ CS_CMD_ACTOR_CUE_568, + /* 0x239 */ CS_CMD_ACTOR_CUE_569, + /* 0x23A */ CS_CMD_ACTOR_CUE_570, + /* 0x23B */ CS_CMD_ACTOR_CUE_571, + /* 0x23C */ CS_CMD_ACTOR_CUE_572, + /* 0x23D */ CS_CMD_ACTOR_CUE_573, + /* 0x23E */ CS_CMD_ACTOR_CUE_574, + /* 0x23F */ CS_CMD_ACTOR_CUE_575, + /* 0x240 */ CS_CMD_ACTOR_CUE_576, + /* 0x241 */ CS_CMD_ACTOR_CUE_577, + /* 0x242 */ CS_CMD_ACTOR_CUE_578, + /* 0x243 */ CS_CMD_ACTOR_CUE_579, + /* 0x244 */ CS_CMD_ACTOR_CUE_580, + /* 0x245 */ CS_CMD_ACTOR_CUE_581, + /* 0x246 */ CS_CMD_ACTOR_CUE_582, + /* 0x247 */ CS_CMD_ACTOR_CUE_583, + /* 0x248 */ CS_CMD_ACTOR_CUE_584, + /* 0x249 */ CS_CMD_ACTOR_CUE_585, + /* 0x24A */ CS_CMD_ACTOR_CUE_586, + /* 0x24B */ CS_CMD_ACTOR_CUE_587, + /* 0x24C */ CS_CMD_ACTOR_CUE_588, + /* 0x24D */ CS_CMD_ACTOR_CUE_589, + /* 0x24E */ CS_CMD_ACTOR_CUE_590, + /* 0x24F */ CS_CMD_ACTOR_CUE_591, + /* 0x250 */ CS_CMD_ACTOR_CUE_592, + /* 0x251 */ CS_CMD_ACTOR_CUE_593, + /* 0x252 */ CS_CMD_ACTOR_CUE_594, + /* 0x253 */ CS_CMD_ACTOR_CUE_595, + /* 0x254 */ CS_CMD_ACTOR_CUE_596, + /* 0x255 */ CS_CMD_ACTOR_CUE_597, + /* 0x256 */ CS_CMD_ACTOR_CUE_598, + /* 0x257 */ CS_CMD_ACTOR_CUE_599 }; -class CutsceneSubCommandEntry_GenericMMCmd : public CutsceneSubCommandEntry +/**** GENERIC ****/ + +class CutsceneMMSubCommandEntry_GenericCmd : public CutsceneSubCommandEntry { public: - CutsceneMMCommands commandId; + CutsceneMM_CommandType commandId; - CutsceneSubCommandEntry_GenericMMCmd(const std::vector& rawData, offset_t rawDataIndex, - CutsceneMMCommands cmdId); + CutsceneMMSubCommandEntry_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMM_CommandType cmdId); std::string GetBodySourceCode() const override; }; @@ -54,34 +259,89 @@ class CutsceneMMCommand_GenericCmd : public CutsceneCommand { public: CutsceneMMCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, - CutsceneMMCommands cmdId); + CutsceneMM_CommandType cmdId); std::string GetCommandMacro() const override; }; +/**** CAMERA ****/ + // TODO: MM cutscene camera command is implemented as a placeholder until we better understand how // it works -class CutsceneSubCommandEntry_Camera : public CutsceneSubCommandEntry + +class CutsceneSubCommandEntry_SplineCamPoint : public CutsceneSubCommandEntry { public: - uint32_t unk_08; + uint8_t interpType; + uint8_t weight; + uint16_t duration; - CutsceneSubCommandEntry_Camera(const std::vector& rawData, offset_t rawDataIndex); + uint16_t posX; + uint16_t posY; + + uint16_t posZ; + uint16_t relTo; + + CutsceneSubCommandEntry_SplineCamPoint(const std::vector& rawData, offset_t rawDataIndex); std::string GetBodySourceCode() const override; size_t GetRawSize() const override; }; -class CutsceneMMCommand_Camera : public CutsceneCommand +class CutsceneSubCommandEntry_SplineMiscPoint : public CutsceneSubCommandEntry { public: - CutsceneMMCommand_Camera(const std::vector& rawData, offset_t rawDataIndex); + uint16_t unused0; + uint16_t roll; + uint16_t fov; + uint16_t unused1; + + CutsceneSubCommandEntry_SplineMiscPoint(const std::vector& rawData, offset_t rawDataIndex); - std::string GetCommandMacro() const override; + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; }; -class CutsceneSubCommandEntry_FadeScreen : public CutsceneSubCommandEntry +class CutsceneSubCommandEntry_SplineFooter : public CutsceneSubCommandEntry +{ +public: + CutsceneSubCommandEntry_SplineFooter(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneSubCommandEntry_SplineHeader : public CutsceneSubCommandEntry +{ +public: + uint16_t numEntries; + uint16_t unused0; + uint16_t unused1; + uint16_t duration; + CutsceneSubCommandEntry_SplineHeader(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_Spline : public CutsceneCommand +{ +public: + uint32_t numHeaders; + uint32_t totalCommands; + CutsceneMMCommand_Spline(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; + size_t GetCommandSize() const override; +}; + +/**** TRANSITION GENERAL ****/ + +class CutsceneSubCommandEntry_TransitionGeneral : public CutsceneSubCommandEntry { public: uint8_t unk_06; @@ -91,41 +351,46 @@ public: uint8_t unk_0A; uint8_t unk_0B; - CutsceneSubCommandEntry_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + CutsceneSubCommandEntry_TransitionGeneral(const std::vector& rawData, + offset_t rawDataIndex); std::string GetBodySourceCode() const override; size_t GetRawSize() const override; }; -class CutsceneMMCommand_FadeScreen : public CutsceneCommand +class CutsceneMMCommand_TransitionGeneral : public CutsceneCommand { public: - CutsceneMMCommand_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + CutsceneMMCommand_TransitionGeneral(const std::vector& rawData, offset_t rawDataIndex); std::string GetCommandMacro() const override; }; -class CutsceneSubCommandEntry_FadeSeq : public CutsceneSubCommandEntry +/**** FADE OUT SEQUENCE ****/ + +class CutsceneSubCommandEntry_FadeOutSeq : public CutsceneSubCommandEntry { public: uint32_t unk_08; - CutsceneSubCommandEntry_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + CutsceneSubCommandEntry_FadeOutSeq(const std::vector& rawData, offset_t rawDataIndex); std::string GetBodySourceCode() const override; size_t GetRawSize() const override; }; -class CutsceneMMCommand_FadeSeq : public CutsceneCommand +class CutsceneMMCommand_FadeOutSeq : public CutsceneCommand { public: - CutsceneMMCommand_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + CutsceneMMCommand_FadeOutSeq(const std::vector& rawData, offset_t rawDataIndex); std::string GetCommandMacro() const override; }; +/**** NON IMPLEMENTED ****/ + class CutsceneSubCommandEntry_NonImplemented : public CutsceneSubCommandEntry { public: @@ -138,3 +403,75 @@ class CutsceneMMCommand_NonImplemented : public CutsceneCommand public: CutsceneMMCommand_NonImplemented(const std::vector& rawData, offset_t rawDataIndex); }; + +/**** RUMBLE ****/ + +class CutsceneMMSubCommandEntry_Rumble : public CutsceneSubCommandEntry +{ +public: + uint8_t intensity; + uint8_t decayTimer; + uint8_t decayStep; + + CutsceneMMSubCommandEntry_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_Rumble : public CutsceneCommand +{ +public: + CutsceneMMCommand_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +/**** TEXT ****/ + +class CutsceneMMSubCommandEntry_Text : public CutsceneSubCommandEntry +{ +public: + uint16_t type; + uint16_t textId1; + uint16_t textId2; + + CutsceneMMSubCommandEntry_Text(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_Text : public CutsceneCommand +{ +public: + CutsceneMMCommand_Text(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +/**** ACTOR CUE ****/ + +class CutsceneMMSubCommandEntry_ActorCue : public CutsceneSubCommandEntry +{ +public: + uint16_t rotX, rotY, rotZ; + int32_t startPosX, startPosY, startPosZ; + int32_t endPosX, endPosY, endPosZ; + float normalX, normalY, normalZ; + + CutsceneMMSubCommandEntry_ActorCue(const std::vector& rawData, offset_t rawDataIndex); + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_ActorCue : public CutsceneCommand +{ +public: + CutsceneMMCommand_ActorCue(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneOoT_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/CutsceneOoT_Commands.cpp new file mode 100644 index 0000000000..8c530f796e --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneOoT_Commands.cpp @@ -0,0 +1,461 @@ +#include "CutsceneOoT_Commands.h" + +#include +#include +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +/**** GENERIC ****/ + +// Specific for command lists where each entry has size 0x30 bytes +const std::unordered_map csCommandsDesc = { + {CutsceneOoT_CommandType::CS_CMD_MISC, + {"CS_MISC", "(%s, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneOoT_CommandType::CS_CMD_LIGHT_SETTING, + {"CS_LIGHT_SETTING", "(0x%02X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneOoT_CommandType::CS_CMD_START_SEQ, + {"CS_START_SEQ", "(%s, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneOoT_CommandType::CS_CMD_STOP_SEQ, + {"CS_STOP_SEQ", "(%s, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneOoT_CommandType::CS_CMD_FADE_OUT_SEQ, + {"CS_FADE_OUT_SEQ", "(%s, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, +}; + +CutsceneOoTSubCommandEntry_GenericCmd::CutsceneOoTSubCommandEntry_GenericCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneOoT_CommandType cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ + word0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0); + word1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x4); + + unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x8); + unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0xC); + unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x10); + unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x14); + unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x18); + unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x1C); + unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x20); + unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x24); + unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x28); + unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneOoTSubCommandEntry_GenericCmd::GetBodySourceCode() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + const auto& element = csCommandsDesc.find(commandId); + + if (element != csCommandsDesc.end()) + { + bool isIndexInMisc = enumData->miscType.find(base) != enumData->miscType.end(); + bool isIndexInFade = + enumData->fadeOutSeqPlayer.find(base) != enumData->fadeOutSeqPlayer.end(); + bool isIndexInSeqId = enumData->seqId.find(base - 1) != enumData->seqId.end(); + std::string entryFmt = element->second.cmdMacro; + std::string firstArg; + entryFmt += element->second.args; + + if (commandId == CutsceneOoT_CommandType::CS_CMD_MISC && isIndexInMisc) + firstArg = enumData->miscType[base]; + else if (commandId == CutsceneOoT_CommandType::CS_CMD_FADE_OUT_SEQ && isIndexInFade) + firstArg = enumData->fadeOutSeqPlayer[base]; + else if (commandId == CutsceneOoT_CommandType::CS_CMD_START_SEQ && isIndexInSeqId) + firstArg = enumData->seqId[base - 1]; + else if (commandId == CutsceneOoT_CommandType::CS_CMD_STOP_SEQ && isIndexInSeqId) + firstArg = enumData->seqId[base - 1]; + else + { + return StringHelper::Sprintf(entryFmt.c_str(), base - 1, startFrame, endFrame, pad, + unused1, unused2, unused3, unused4, unused5, unused6, + unused7, unused8, unused9, unused10); + } + return StringHelper::Sprintf(entryFmt.c_str(), firstArg.c_str(), startFrame, endFrame, pad, + unused1, unused2, unused3, unused4, unused5, unused6, unused7, + unused8, unused9, unused10); + } + return StringHelper::Sprintf("CS_UNK_DATA(0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, " + "0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X)", + word0, word1, unused1, unused2, unused3, unused4, unused5, unused6, + unused7, unused8, unused9, unused10); +} + +size_t CutsceneOoTSubCommandEntry_GenericCmd::GetRawSize() const +{ + return 0x30; +} + +CutsceneOoTCommand_GenericCmd::CutsceneOoTCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneOoT_CommandType cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + entries.reserve(numEntries); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneOoTSubCommandEntry_GenericCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneOoTCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDesc.find(static_cast(commandID)); + + if (element != csCommandsDesc.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +/**** CAMERA ****/ + +CutsceneOoTCommand_CameraPoint::CutsceneOoTCommand_CameraPoint(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + continueFlag = BitConverter::ToInt8BE(rawData, rawDataIndex + 0); + cameraRoll = BitConverter::ToInt8BE(rawData, rawDataIndex + 1); + nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); + + posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); + posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); + posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); + + unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); +} + +std::string CutsceneOoTCommand_CameraPoint::GetBodySourceCode() const +{ + std::string continueMacro = "CS_CAM_CONTINUE"; + if (continueFlag != 0) + continueMacro = "CS_CAM_STOP"; + + return StringHelper::Sprintf("CS_CAM_POINT(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X)", + continueMacro.c_str(), cameraRoll, nextPointFrame, viewAngle, posX, + posY, posZ, unused); +} + +size_t CutsceneOoTCommand_CameraPoint::GetRawSize() const +{ + return 0x10; +} + +CutsceneOoTCommand_GenericCameraCmd::CutsceneOoTCommand_GenericCameraCmd( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + bool shouldContinue = true; + + uint32_t currentPtr = rawDataIndex + 8; + + while (shouldContinue) + { + CutsceneOoTCommand_CameraPoint* camPoint = + new CutsceneOoTCommand_CameraPoint(rawData, currentPtr); + entries.push_back(camPoint); + + if (camPoint->continueFlag == -1) + shouldContinue = false; + + currentPtr += camPoint->GetRawSize(); + } +} + +std::string CutsceneOoTCommand_GenericCameraCmd::GetCommandMacro() const +{ + std::string result; + const char* listStr; + + if (commandID == (uint32_t)CutsceneOoT_CommandType::CS_CMD_CAM_AT_SPLINE) + { + listStr = "CS_CAM_AT_SPLINE"; + } + else if (commandID == (uint32_t)CutsceneOoT_CommandType::CS_CMD_CAM_AT_SPLINE_REL_TO_PLAYER) + { + listStr = "CS_CAM_AT_SPLINE_REL_TO_PLAYER"; + } + else if (commandID == (uint32_t)CutsceneOoT_CommandType::CS_CMD_CAM_EYE_SPLINE_REL_TO_PLAYER) + { + listStr = "CS_CAM_EYE_SPLINE_REL_TO_PLAYER"; + } + else + { + listStr = "CS_CAM_EYE_SPLINE"; + } + + result += StringHelper::Sprintf("%s(%i, %i)", listStr, startFrame, endFrame); + + return result; +} + +size_t CutsceneOoTCommand_GenericCameraCmd::GetCommandSize() const +{ + return 0x0C + entries.at(0)->GetRawSize() * entries.size(); +} + +/**** RUMBLE ****/ + +CutsceneOoTSubCommandEntry_Rumble::CutsceneOoTSubCommandEntry_Rumble( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + sourceStrength = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + duration = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + decreaseRate = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); +} + +std::string CutsceneOoTSubCommandEntry_Rumble::GetBodySourceCode() const +{ + // Note: the first argument is unused + return StringHelper::Sprintf("CS_RUMBLE_CONTROLLER(%i, %i, %i, %i, %i, %i, 0x%02X, 0x%02X)", + base, startFrame, endFrame, sourceStrength, duration, decreaseRate, + unk_09, unk_0A); +} + +size_t CutsceneOoTSubCommandEntry_Rumble::GetRawSize() const +{ + return 0x0C; +} + +CutsceneOoTCommand_Rumble::CutsceneOoTCommand_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneOoTSubCommandEntry_Rumble(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneOoTCommand_Rumble::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_RUMBLE_CONTROLLER_LIST(%i)", numEntries); +} + +/**** TEXT ****/ + +CutsceneOoTSubCommandEntry_Text::CutsceneOoTSubCommandEntry_Text( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + textId1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + textId2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); +} + +std::string CutsceneOoTSubCommandEntry_Text::GetBodySourceCode() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (type == 0xFFFF) + { + return StringHelper::Sprintf("CS_TEXT_NONE(%i, %i)", startFrame, endFrame); + } + if (type == 2 && + enumData->ocarinaSongActionId.find(base) != enumData->ocarinaSongActionId.end()) + { + return StringHelper::Sprintf("CS_TEXT_OCARINA_ACTION(%s, %i, %i, 0x%X)", + enumData->ocarinaSongActionId[base].c_str(), startFrame, + endFrame, textId1); + } + + if (enumData->textType.find(type) != enumData->textType.end()) + { + return StringHelper::Sprintf("CS_TEXT(0x%X, %i, %i, %s, 0x%X, 0x%X)", base, startFrame, + endFrame, enumData->textType[type].c_str(), textId1, textId2); + } + + return StringHelper::Sprintf("CS_TEXT(0x%X, %i, %i, %i, 0x%X, 0x%X)", base, startFrame, + endFrame, type, textId1, textId2); +} + +size_t CutsceneOoTSubCommandEntry_Text::GetRawSize() const +{ + return 0x0C; +} + +CutsceneOoTCommand_Text::CutsceneOoTCommand_Text(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneOoTSubCommandEntry_Text(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneOoTCommand_Text::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TEXT_LIST(%i)", numEntries); +} + +/**** ACTOR CUE ****/ + +CutsceneOoTSubCommandEntry_ActorCue::CutsceneOoTSubCommandEntry_ActorCue( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); + startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0xC); + startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x10); + startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x14); + endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x18); + endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x1C); + endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x20); + normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x24); + normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x28); + normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneOoTSubCommandEntry_ActorCue::GetBodySourceCode() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (static_cast(commandID) == + CutsceneOoT_CommandType::CS_CMD_PLAYER_CUE) + { + return StringHelper::Sprintf("CS_PLAYER_CUE(%s, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " + "%i, %i, %i, %i, %.8ef, %.8ef, %.8ef)", + enumData->playerCueId[base].c_str(), startFrame, endFrame, + rotX, rotY, rotZ, startPosX, startPosY, startPosZ, endPosX, + endPosY, endPosZ, normalX, normalY, normalZ); + } + else + { + return StringHelper::Sprintf("CS_ACTOR_CUE(%i, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " + "%i, %i, %i, %i, %.8ef, %.8ef, %.8ef)", + base, startFrame, endFrame, rotX, rotY, rotZ, startPosX, + startPosY, startPosZ, endPosX, endPosY, endPosZ, normalX, + normalY, normalZ); + } +} + +size_t CutsceneOoTSubCommandEntry_ActorCue::GetRawSize() const +{ + return 0x30; +} + +CutsceneOoTCommand_ActorCue::CutsceneOoTCommand_ActorCue(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneOoTSubCommandEntry_ActorCue(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneOoTCommand_ActorCue::GetCommandMacro() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (static_cast(commandID) == + CutsceneOoT_CommandType::CS_CMD_PLAYER_CUE) + { + return StringHelper::Sprintf("CS_PLAYER_CUE_LIST(%i)", entries.size()); + } + + if (enumData->cutsceneCmd.find(commandID) != enumData->cutsceneCmd.end()) + { + return StringHelper::Sprintf("CS_ACTOR_CUE_LIST(%s, %i)", + enumData->cutsceneCmd[commandID].c_str(), entries.size()); + } + + return StringHelper::Sprintf("CS_ACTOR_CUE_LIST(0x%04X, %i)", commandID, entries.size()); +} + +/**** DESTINATION ****/ + +CutsceneOoTCommand_Destination::CutsceneOoTCommand_Destination(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate +} + +std::string CutsceneOoTCommand_Destination::GenerateSourceCode() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (enumData->destination.find(base) != enumData->destination.end()) + { + return StringHelper::Sprintf("CS_DESTINATION(%s, %i, %i),\n", + enumData->destination[base].c_str(), startFrame, endFrame); + } + + return StringHelper::Sprintf("CS_DESTINATION(%i, %i, %i),\n", base, startFrame, endFrame); +} + +size_t CutsceneOoTCommand_Destination::GetCommandSize() const +{ + return 0x10; +} + +/**** TRANSITION ****/ + +CutsceneOoTCommand_Transition::CutsceneOoTCommand_Transition(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); +} + +std::string CutsceneOoTCommand_Transition::GenerateSourceCode() const +{ + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (enumData->transitionType.find(base) != enumData->transitionType.end()) + { + return StringHelper::Sprintf("CS_TRANSITION(%s, %i, %i),\n", + enumData->transitionType[base].c_str(), startFrame, endFrame); + } + + return StringHelper::Sprintf("CS_TRANSITION(%i, %i, %i),\n", base, startFrame, endFrame); +} + +size_t CutsceneOoTCommand_Transition::GetCommandSize() const +{ + return 0x10; +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneOoT_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/CutsceneOoT_Commands.h new file mode 100644 index 0000000000..ff9b6797c3 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneOoT_Commands.h @@ -0,0 +1,314 @@ +#pragma once + +#include "Cutscene_Common.h" + +// https://github.com/zeldaret/oot/blob/7235af2249843fb68740111b70089bad827a4730/include/z64cutscene.h#L35-L165 +enum class CutsceneOoT_CommandType +{ + CS_CMD_CAM_EYE_SPLINE = 0x01, + CS_CMD_CAM_AT_SPLINE, + CS_CMD_MISC, + CS_CMD_LIGHT_SETTING, + CS_CMD_CAM_EYE_SPLINE_REL_TO_PLAYER, + CS_CMD_CAM_AT_SPLINE_REL_TO_PLAYER, + CS_CMD_CAM_EYE, + CS_CMD_CAM_AT, + CS_CMD_RUMBLE_CONTROLLER, + CS_CMD_PLAYER_CUE, + CS_CMD_UNIMPLEMENTED_B, + CS_CMD_UNIMPLEMENTED_D = 0x0D, + CS_CMD_ACTOR_CUE_1_0, + CS_CMD_ACTOR_CUE_0_0, + CS_CMD_ACTOR_CUE_1_1, + CS_CMD_ACTOR_CUE_0_1, + CS_CMD_ACTOR_CUE_0_2, + CS_CMD_TEXT, + CS_CMD_UNIMPLEMENTED_15 = 0x15, + CS_CMD_UNIMPLEMENTED_16, + CS_CMD_ACTOR_CUE_0_3, + CS_CMD_ACTOR_CUE_1_2, + CS_CMD_ACTOR_CUE_2_0, + CS_CMD_UNIMPLEMENTED_1B = 0x1B, + CS_CMD_UNIMPLEMENTED_1C, + CS_CMD_ACTOR_CUE_3_0, + CS_CMD_ACTOR_CUE_4_0, + CS_CMD_ACTOR_CUE_6_0, + CS_CMD_UNIMPLEMENTED_20, + CS_CMD_UNIMPLEMENTED_21, + CS_CMD_ACTOR_CUE_0_4, + CS_CMD_ACTOR_CUE_1_3, + CS_CMD_ACTOR_CUE_2_1, + CS_CMD_ACTOR_CUE_3_1, + CS_CMD_ACTOR_CUE_4_1, + CS_CMD_ACTOR_CUE_0_5, + CS_CMD_ACTOR_CUE_1_4, + CS_CMD_ACTOR_CUE_2_2, + CS_CMD_ACTOR_CUE_3_2, + CS_CMD_ACTOR_CUE_4_2, + CS_CMD_ACTOR_CUE_5_0, + CS_CMD_TRANSITION, + CS_CMD_ACTOR_CUE_0_6, + CS_CMD_ACTOR_CUE_4_3, + CS_CMD_ACTOR_CUE_1_5, + CS_CMD_ACTOR_CUE_7_0, + CS_CMD_ACTOR_CUE_2_3, + CS_CMD_ACTOR_CUE_3_3, + CS_CMD_ACTOR_CUE_6_1, + CS_CMD_ACTOR_CUE_3_4, + CS_CMD_ACTOR_CUE_4_4, + CS_CMD_ACTOR_CUE_5_1, + CS_CMD_ACTOR_CUE_6_2 = 0x39, + CS_CMD_ACTOR_CUE_6_3, + CS_CMD_UNIMPLEMENTED_3B, + CS_CMD_ACTOR_CUE_7_1, + CS_CMD_UNIMPLEMENTED_3D, + CS_CMD_ACTOR_CUE_8_0, + CS_CMD_ACTOR_CUE_3_5, + CS_CMD_ACTOR_CUE_1_6, + CS_CMD_ACTOR_CUE_3_6, + CS_CMD_ACTOR_CUE_3_7, + CS_CMD_ACTOR_CUE_2_4, + CS_CMD_ACTOR_CUE_1_7, + CS_CMD_ACTOR_CUE_2_5, + CS_CMD_ACTOR_CUE_1_8, + CS_CMD_UNIMPLEMENTED_47, + CS_CMD_ACTOR_CUE_2_6, + CS_CMD_UNIMPLEMENTED_49, + CS_CMD_ACTOR_CUE_2_7, + CS_CMD_ACTOR_CUE_3_8, + CS_CMD_ACTOR_CUE_0_7, + CS_CMD_ACTOR_CUE_5_2, + CS_CMD_ACTOR_CUE_1_9, + CS_CMD_ACTOR_CUE_4_5, + CS_CMD_ACTOR_CUE_1_10, + CS_CMD_ACTOR_CUE_2_8, + CS_CMD_ACTOR_CUE_3_9, + CS_CMD_ACTOR_CUE_4_6, + CS_CMD_ACTOR_CUE_5_3, + CS_CMD_ACTOR_CUE_0_8, + CS_CMD_START_SEQ, + CS_CMD_STOP_SEQ, + CS_CMD_ACTOR_CUE_6_4, + CS_CMD_ACTOR_CUE_7_2, + CS_CMD_ACTOR_CUE_5_4, + CS_CMD_ACTOR_CUE_0_9 = 0x5D, + CS_CMD_ACTOR_CUE_1_11, + CS_CMD_ACTOR_CUE_0_10 = 0x69, + CS_CMD_ACTOR_CUE_2_9, + CS_CMD_ACTOR_CUE_0_11, + CS_CMD_ACTOR_CUE_3_10, + CS_CMD_UNIMPLEMENTED_6D, + CS_CMD_ACTOR_CUE_0_12, + CS_CMD_ACTOR_CUE_7_3, + CS_CMD_UNIMPLEMENTED_70, + CS_CMD_UNIMPLEMENTED_71, + CS_CMD_ACTOR_CUE_7_4, + CS_CMD_ACTOR_CUE_6_5, + CS_CMD_ACTOR_CUE_1_12, + CS_CMD_ACTOR_CUE_2_10, + CS_CMD_ACTOR_CUE_1_13, + CS_CMD_ACTOR_CUE_0_13, + CS_CMD_ACTOR_CUE_1_14, + CS_CMD_ACTOR_CUE_2_11, + CS_CMD_ACTOR_CUE_0_14 = 0x7B, + CS_CMD_FADE_OUT_SEQ, + CS_CMD_ACTOR_CUE_1_15, + CS_CMD_ACTOR_CUE_2_12, + CS_CMD_ACTOR_CUE_3_11, + CS_CMD_ACTOR_CUE_4_7, + CS_CMD_ACTOR_CUE_5_5, + CS_CMD_ACTOR_CUE_6_6, + CS_CMD_ACTOR_CUE_1_16, + CS_CMD_ACTOR_CUE_2_13, + CS_CMD_ACTOR_CUE_3_12, + CS_CMD_ACTOR_CUE_7_5, + CS_CMD_ACTOR_CUE_4_8, + CS_CMD_ACTOR_CUE_5_6, + CS_CMD_ACTOR_CUE_6_7, + CS_CMD_ACTOR_CUE_0_15, + CS_CMD_ACTOR_CUE_0_16, + CS_CMD_TIME, + CS_CMD_ACTOR_CUE_1_17, + CS_CMD_ACTOR_CUE_7_6, + CS_CMD_ACTOR_CUE_9_0, + CS_CMD_ACTOR_CUE_0_17, + CS_CMD_DESTINATION = 0x03E8, + CS_CMD_END = 0xFFFF +}; + +/**** GENERIC ****/ + +class CutsceneOoTSubCommandEntry_GenericCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneOoT_CommandType commandId; + + uint32_t word0 = 0; + uint32_t word1 = 0; + + uint32_t unused1 = 0; + uint32_t unused2 = 0; + uint32_t unused3 = 0; + uint32_t unused4 = 0; + uint32_t unused5 = 0; + uint32_t unused6 = 0; + uint32_t unused7 = 0; + uint32_t unused8 = 0; + uint32_t unused9 = 0; + uint32_t unused10 = 0; + + CutsceneOoTSubCommandEntry_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, CutsceneOoT_CommandType cmdId); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneOoTCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneOoTCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneOoT_CommandType cmdId); + + std::string GetCommandMacro() const override; +}; + +/**** CAMERA ****/ + +class CutsceneOoTCommand_CameraPoint : public CutsceneSubCommandEntry +{ +public: + int8_t continueFlag; + int8_t cameraRoll; + int16_t nextPointFrame; + float viewAngle; + int16_t posX, posY, posZ; + int16_t unused; + + CutsceneOoTCommand_CameraPoint(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneOoTCommand_GenericCameraCmd : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unused; + + CutsceneOoTCommand_GenericCameraCmd(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; + + size_t GetCommandSize() const override; +}; + +/**** TRANSITION ****/ + +class CutsceneOoTCommand_Transition : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + + CutsceneOoTCommand_Transition(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; + +/**** RUMBLE ****/ + +class CutsceneOoTSubCommandEntry_Rumble : public CutsceneSubCommandEntry +{ +public: + uint8_t sourceStrength; + uint8_t duration; + uint8_t decreaseRate; + uint8_t unk_09; + uint8_t unk_0A; + + CutsceneOoTSubCommandEntry_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneOoTCommand_Rumble : public CutsceneCommand +{ +public: + CutsceneOoTCommand_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +/**** TEXT ****/ + +class CutsceneOoTSubCommandEntry_Text : public CutsceneSubCommandEntry +{ +public: + uint16_t type; + uint16_t textId1; + uint16_t textId2; + + CutsceneOoTSubCommandEntry_Text(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneOoTCommand_Text : public CutsceneCommand +{ +public: + CutsceneOoTCommand_Text(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +/**** ACTOR CUE ****/ + +class CutsceneOoTSubCommandEntry_ActorCue : public CutsceneSubCommandEntry +{ +public: + uint16_t rotX, rotY, rotZ; + int32_t startPosX, startPosY, startPosZ; + int32_t endPosX, endPosY, endPosZ; + float normalX, normalY, normalZ; + + CutsceneOoTSubCommandEntry_ActorCue(const std::vector& rawData, offset_t rawDataIndex); + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneOoTCommand_ActorCue : public CutsceneCommand +{ +public: + CutsceneOoTCommand_ActorCue(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +/**** DESTINATION ****/ + +class CutsceneOoTCommand_Destination : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unknown; + + CutsceneOoTCommand_Destination(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp deleted file mode 100644 index 8ae4c69d7d..0000000000 --- a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp +++ /dev/null @@ -1,596 +0,0 @@ -#include "Cutscene_Commands.h" - -#include -#include - -#include "CutsceneMM_Commands.h" -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -/* CutsceneSubCommandEntry */ - -CutsceneSubCommandEntry::CutsceneSubCommandEntry(const std::vector& rawData, - offset_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - pad = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); -} - -std::string CutsceneSubCommandEntry::GetBodySourceCode() const -{ - return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X), CMD_HH(0x%04X, 0x%04X)", base, startFrame, - endFrame, pad); -} - -size_t CutsceneSubCommandEntry::GetRawSize() const -{ - return 0x08; -} - -/* CutsceneCommand */ - -CutsceneCommand::CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex) -{ - numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); -} - -CutsceneCommand::~CutsceneCommand() -{ - for (auto& entry : entries) - { - delete entry; - } -} - -std::string CutsceneCommand::GetCommandMacro() const -{ - return StringHelper::Sprintf("CMD_W(0x%08X), CMD_W(0x%08X)", commandID, numEntries); -} - -std::string CutsceneCommand::GenerateSourceCode() const -{ - std::string result; - - result += GetCommandMacro(); - result += ",\n"; - - for (auto& entry : entries) - { - result += " "; - result += entry->GetBodySourceCode(); - result += ",\n"; - } - - return result; -} - -size_t CutsceneCommand::GetCommandSize() const -{ - size_t size = 0; - if (entries.size() > 0) - { - size = entries.at(0)->GetRawSize() * entries.size(); - } - else - { - size = 0x08 * numEntries; - } - return 0x08 + size; -} - -void CutsceneCommand::SetCommandID(uint32_t nCommandID) -{ - commandID = nCommandID; - - for (auto& entry : entries) - { - entry->commandID = commandID; - } -} - -// Specific for command lists where each entry has size 0x30 bytes -const std::unordered_map csCommandsDesc = { - {CutsceneCommands::Misc, - {"CS_MISC", "(0x%04X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, - {CutsceneCommands::SetLighting, - {"CS_LIGHTING", "(0x%02X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, - {CutsceneCommands::PlayBGM, {"CS_PLAY_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, - {CutsceneCommands::StopBGM, {"CS_STOP_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, - {CutsceneCommands::FadeBGM, {"CS_FADE_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, -}; - -CutsceneSubCommandEntry_GenericCmd::CutsceneSubCommandEntry_GenericCmd( - const std::vector& rawData, offset_t rawDataIndex, CutsceneCommands cmdId) - : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) -{ - word0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0); - word1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x4); - - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0xC); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x10); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x14); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x18); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x1C); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x20); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x24); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x28); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x2C); -} - -std::string CutsceneSubCommandEntry_GenericCmd::GetBodySourceCode() const -{ - const auto& element = csCommandsDesc.find(commandId); - - if (element != csCommandsDesc.end()) - { - std::string entryFmt = element->second.cmdMacro; - entryFmt += element->second.args; - - return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad, unused1, - unused2, unused3, unused4, unused5, unused6, unused7, unused8, - unused9, unused10); - } - - return StringHelper::Sprintf("CS_UNK_DATA(0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, " - "0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X)", - word0, word1, unused1, unused2, unused3, unused4, unused5, unused6, - unused7, unused8, unused9, unused10); -} - -size_t CutsceneSubCommandEntry_GenericCmd::GetRawSize() const -{ - return 0x30; -} - -CutsceneCommand_GenericCmd::CutsceneCommand_GenericCmd(const std::vector& rawData, - offset_t rawDataIndex, - CutsceneCommands cmdId) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - commandID = static_cast(cmdId); - entries.reserve(numEntries); - - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_GenericCmd(rawData, rawDataIndex, cmdId); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_GenericCmd::GetCommandMacro() const -{ - const auto& element = csCommandsDesc.find(static_cast(commandID)); - - if (element != csCommandsDesc.end()) - { - return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); - } - - return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); -} - -CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - continueFlag = BitConverter::ToInt8BE(rawData, rawDataIndex + 0); - cameraRoll = BitConverter::ToInt8BE(rawData, rawDataIndex + 1); - nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); - - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); - - unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -std::string CutsceneCameraPoint::GetBodySourceCode() const -{ - std::string result = ""; - - if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) - { - result += "CS_CAM_FOCUS_POINT"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) - { - result += "CS_CAM_FOCUS_POINT_PLAYER"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) - { - result += "CS_CAM_POS_PLAYER"; - } - else - { - result += "CS_CAM_POS"; - } - - std::string continueMacro = "CS_CMD_CONTINUE"; - if (continueFlag != 0) - continueMacro = "CS_CMD_STOP"; - - result += - StringHelper::Sprintf("(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X)", continueMacro.c_str(), - cameraRoll, nextPointFrame, viewAngle, posX, posY, posZ, unused); - return result; -} - -size_t CutsceneCameraPoint::GetRawSize() const -{ - return 0x10; -} - -CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - - bool shouldContinue = true; - - uint32_t currentPtr = rawDataIndex + 8; - - while (shouldContinue) - { - CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); - entries.push_back(camPoint); - - if (camPoint->continueFlag == -1) - shouldContinue = false; - - currentPtr += camPoint->GetRawSize(); - } -} - -std::string CutsceneCommandSetCameraPos::GetCommandMacro() const -{ - std::string result; - - std::string listStr; - - if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) - { - listStr = "CS_CAM_FOCUS_POINT_LIST"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) - { - listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) - { - listStr = "CS_CAM_POS_PLAYER_LIST"; - } - else - { - listStr = "CS_CAM_POS_LIST"; - } - - result += StringHelper::Sprintf("%s(%i, %i)", listStr.c_str(), startFrame, endFrame); - - return result; -} - -size_t CutsceneCommandSetCameraPos::GetCommandSize() const -{ - return 0x0C + entries.at(0)->GetRawSize() * entries.size(); -} - -CutsceneSubCommandEntry_Rumble::CutsceneSubCommandEntry_Rumble(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); - unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); - unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); - unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); - unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); - unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); -} - -std::string CutsceneSubCommandEntry_Rumble::GetBodySourceCode() const -{ - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - return StringHelper::Sprintf("CS_RUMBLE(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X)", base, - startFrame, endFrame, unk_06, unk_07, unk_08); - } - - return StringHelper::Sprintf("CS_CMD_09(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X)", - base, startFrame, endFrame, unk_06, unk_07, unk_08, unk_09, unk_0A, - unk_0B); -} - -size_t CutsceneSubCommandEntry_Rumble::GetRawSize() const -{ - return 0x0C; -} - -CutsceneCommand_Rumble::CutsceneCommand_Rumble(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_Rumble(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_Rumble::GetCommandMacro() const -{ - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - return StringHelper::Sprintf("CS_RUMBLE_LIST(%i)", numEntries); - } - return StringHelper::Sprintf("CS_CMD_09_LIST(%i)", numEntries); -} - -CutsceneSubCommandEntry_SetTime::CutsceneSubCommandEntry_SetTime( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - hour = BitConverter::ToUInt8BE(rawData, rawDataIndex + 6); - minute = BitConverter::ToUInt8BE(rawData, rawDataIndex + 7); - unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); -} - -std::string CutsceneSubCommandEntry_SetTime::GetBodySourceCode() const -{ - return StringHelper::Sprintf("CS_TIME(%i, %i, %i, %i, %i, %i)", base, startFrame, endFrame, - hour, minute, unk_08); -} - -size_t CutsceneSubCommandEntry_SetTime::GetRawSize() const -{ - return 0x0C; -} - -CutsceneCommand_SetTime::CutsceneCommand_SetTime(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_SetTime(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_SetTime::GetCommandMacro() const -{ - return StringHelper::Sprintf("CS_TIME_LIST(%i)", numEntries); -} - -CutsceneSubCommandEntry_TextBox::CutsceneSubCommandEntry_TextBox( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); - textId1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); - textId2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); -} - -std::string CutsceneSubCommandEntry_TextBox::GetBodySourceCode() const -{ - if (type == 0xFFFF) - { - return StringHelper::Sprintf("CS_TEXT_NONE(%i, %i)", startFrame, endFrame); - } - if (type == 2) - { - return StringHelper::Sprintf("CS_TEXT_LEARN_SONG(%i, %i, %i, 0x%X)", base, startFrame, - endFrame, textId1); - } - - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - switch (type) - { - case 0: - return StringHelper::Sprintf("CS_TEXT_DEFAULT(0x%X, %i, %i, 0x%X, 0x%X)", base, - startFrame, endFrame, textId1, textId2); - - case 1: - return StringHelper::Sprintf("CS_TEXT_TYPE_1(0x%X, %i, %i, 0x%X, 0x%X)", base, - startFrame, endFrame, textId1, textId2); - - case 3: - return StringHelper::Sprintf("CS_TEXT_TYPE_3(0x%X, %i, %i, 0x%X, 0x%X)", base, - startFrame, endFrame, textId1, textId2); - - case 4: - return StringHelper::Sprintf("CS_TEXT_BOSSES_REMAINS(0x%X, %i, %i, 0x%X)", base, - startFrame, endFrame, textId1); - - case 5: - return StringHelper::Sprintf("CS_TEXT_ALL_NORMAL_MASKS(0x%X, %i, %i, 0x%X)", base, - startFrame, endFrame, textId1); - } - } - - return StringHelper::Sprintf("CS_TEXT_DISPLAY_TEXTBOX(0x%X, %i, %i, %i, 0x%X, 0x%X)", base, - startFrame, endFrame, type, textId1, textId2); -} - -size_t CutsceneSubCommandEntry_TextBox::GetRawSize() const -{ - return 0x0C; -} - -CutsceneCommand_TextBox::CutsceneCommand_TextBox(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_TextBox(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_TextBox::GetCommandMacro() const -{ - return StringHelper::Sprintf("CS_TEXT_LIST(%i)", numEntries); -} - -CutsceneSubCommandEntry_ActorAction::CutsceneSubCommandEntry_ActorAction( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); - rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); - rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); - startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0xC); - startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x10); - startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x14); - endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x18); - endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x1C); - endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x20); - normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x24); - normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x28); - normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x2C); -} - -std::string CutsceneSubCommandEntry_ActorAction::GetBodySourceCode() const -{ - std::string result; - - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - if (static_cast(commandID) == - CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) - { - result = "CS_PLAYER_ACTION"; - } - else - { - result = "CS_ACTOR_ACTION"; - } - } - else - { - if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) - { - result = "CS_PLAYER_ACTION"; - } - else - { - result = "CS_NPC_ACTION"; - } - } - - result += - StringHelper::Sprintf("(%i, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " - "%i, %i, %i, %i, %.11ef, %.11ef, %.11ef)", - base, startFrame, endFrame, rotX, rotY, rotZ, startPosX, startPosY, - startPosZ, endPosX, endPosY, endPosZ, normalX, normalY, normalZ); - return result; -} - -size_t CutsceneSubCommandEntry_ActorAction::GetRawSize() const -{ - return 0x30; -} - -CutsceneCommand_ActorAction::CutsceneCommand_ActorAction(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_ActorAction(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_ActorAction::GetCommandMacro() const -{ - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - if (static_cast(commandID) == - CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) - { - return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", numEntries); - } - return StringHelper::Sprintf("CS_ACTOR_ACTION_LIST(0x%03X, %i)", commandID, numEntries); - } - - if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) - { - return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", entries.size()); - } - return StringHelper::Sprintf("CS_NPC_ACTION_LIST(0x%03X, %i)", commandID, entries.size()); -} - -CutsceneCommand_Terminator::CutsceneCommand_Terminator(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate -} - -std::string CutsceneCommand_Terminator::GenerateSourceCode() const -{ - std::string result; - - result += StringHelper::Sprintf("CS_TERMINATOR(%i, %i, %i),\n", base, startFrame, endFrame); - - return result; -} - -size_t CutsceneCommand_Terminator::GetCommandSize() const -{ - return 0x10; -} - -CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandSceneTransFX::GenerateSourceCode() const -{ - return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); -} - -size_t CutsceneCommandSceneTransFX::GetCommandSize() const -{ - return 0x10; -} diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h deleted file mode 100644 index c462735873..0000000000 --- a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h +++ /dev/null @@ -1,267 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "Declaration.h" - -enum class CutsceneCommands -{ - SetCameraPos = 0x0001, - SetCameraFocus = 0x0002, - Misc = 0x0003, - SetLighting = 0x0004, - SetCameraPosLink = 0x0005, - SetCameraFocusLink = 0x0006, - Cmd07 = 0x0007, - Cmd08 = 0x0008, - Cmd09 = 0x0009, // Rumble - Textbox = 0x0013, - SetPlayerAction = 0x000A, - SetActorAction1 = 0x000F, - SetActorAction2 = 0x000E, - SetActorAction3 = 0x0019, - SetActorAction4 = 0x001D, - SetActorAction5 = 0x001E, - SetActorAction6 = 0x002C, - SetActorAction7 = 0x001F, - SetActorAction8 = 0x0031, - SetActorAction9 = 0x003E, - SetActorAction10 = 0x008F, - SetSceneTransFX = 0x002D, - PlayBGM = 0x0056, - StopBGM = 0x0057, - FadeBGM = 0x007C, - SetTime = 0x008C, - Terminator = 0x03E8, -}; - -typedef struct CsCommandListDescriptor -{ - const char* cmdMacro; - const char* args; -} CsCommandListDescriptor; - -class CutsceneSubCommandEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t pad; - - uint32_t commandID; - - CutsceneSubCommandEntry(const std::vector& rawData, offset_t rawDataIndex); - virtual ~CutsceneSubCommandEntry() = default; - - virtual std::string GetBodySourceCode() const; - - virtual size_t GetRawSize() const; -}; - -class CutsceneCommand -{ -public: - uint32_t commandID; - uint32_t commandIndex; - - uint32_t numEntries; - std::vector entries; - - CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex); - virtual ~CutsceneCommand(); - - virtual std::string GetCommandMacro() const; - virtual std::string GenerateSourceCode() const; - virtual size_t GetCommandSize() const; - - virtual void SetCommandID(uint32_t nCommandID); -}; - -class CutsceneSubCommandEntry_GenericCmd : public CutsceneSubCommandEntry -{ -public: - CutsceneCommands commandId; - - uint32_t word0 = 0; - uint32_t word1 = 0; - - uint32_t unused1 = 0; - uint32_t unused2 = 0; - uint32_t unused3 = 0; - uint32_t unused4 = 0; - uint32_t unused5 = 0; - uint32_t unused6 = 0; - uint32_t unused7 = 0; - uint32_t unused8 = 0; - uint32_t unused9 = 0; - uint32_t unused10 = 0; - - CutsceneSubCommandEntry_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, - CutsceneCommands cmdId); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_GenericCmd : public CutsceneCommand -{ -public: - CutsceneCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, - CutsceneCommands cmdId); - - std::string GetCommandMacro() const override; -}; - -class CutsceneCameraPoint : public CutsceneSubCommandEntry -{ -public: - int8_t continueFlag; - int8_t cameraRoll; - int16_t nextPointFrame; - float viewAngle; - int16_t posX, posY, posZ; - int16_t unused; - - CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommandSetCameraPos : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused; - - CutsceneCommandSetCameraPos(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; - - size_t GetCommandSize() const override; -}; - -class CutsceneCommandSceneTransFX : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandSceneTransFX(const std::vector& rawData, offset_t rawDataIndex); - - std::string GenerateSourceCode() const override; - size_t GetCommandSize() const override; -}; - -class CutsceneSubCommandEntry_Rumble : public CutsceneSubCommandEntry -{ -public: - uint8_t unk_06; - uint8_t unk_07; - uint8_t unk_08; - uint8_t unk_09; - uint8_t unk_0A; - uint8_t unk_0B; - - CutsceneSubCommandEntry_Rumble(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_Rumble : public CutsceneCommand -{ -public: - CutsceneCommand_Rumble(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneSubCommandEntry_SetTime : public CutsceneSubCommandEntry -{ -public: - uint8_t hour; - uint8_t minute; - uint32_t unk_08; - - CutsceneSubCommandEntry_SetTime(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_SetTime : public CutsceneCommand -{ -public: - CutsceneCommand_SetTime(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneSubCommandEntry_TextBox : public CutsceneSubCommandEntry -{ -public: - uint16_t type; - uint16_t textId1; - uint16_t textId2; - - CutsceneSubCommandEntry_TextBox(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_TextBox : public CutsceneCommand -{ -public: - CutsceneCommand_TextBox(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneSubCommandEntry_ActorAction : public CutsceneSubCommandEntry -{ -public: - uint16_t rotX, rotY, rotZ; - int32_t startPosX, startPosY, startPosZ; - int32_t endPosX, endPosY, endPosZ; - float normalX, normalY, normalZ; - - CutsceneSubCommandEntry_ActorAction(const std::vector& rawData, offset_t rawDataIndex); - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_ActorAction : public CutsceneCommand -{ -public: - CutsceneCommand_ActorAction(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneCommand_Terminator : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown; - - CutsceneCommand_Terminator(const std::vector& rawData, offset_t rawDataIndex); - - std::string GenerateSourceCode() const override; - size_t GetCommandSize() const override; -}; diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Common.cpp b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Common.cpp new file mode 100644 index 0000000000..a5ea609af8 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Common.cpp @@ -0,0 +1,128 @@ +#include "Cutscene_Common.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +/* CutsceneSubCommandEntry */ + +CutsceneSubCommandEntry::CutsceneSubCommandEntry(const std::vector& rawData, + offset_t rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + pad = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); +} + +std::string CutsceneSubCommandEntry::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X), CMD_HH(0x%04X, 0x%04X)", base, startFrame, + endFrame, pad); +} + +size_t CutsceneSubCommandEntry::GetRawSize() const +{ + return 0x08; +} + +/* CutsceneCommand */ + +CutsceneCommand::CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex) +{ + numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); +} + +CutsceneCommand::~CutsceneCommand() +{ + for (auto entry : entries) + { + delete entry; + } +} + +std::string CutsceneCommand::GetCommandMacro() const +{ + return StringHelper::Sprintf("CMD_W(0x%08X), CMD_W(0x%08X)", commandID, numEntries); +} + +std::string CutsceneCommand::GenerateSourceCode() const +{ + std::string result; + + result += GetCommandMacro(); + result += ",\n"; + + for (auto& entry : entries) + { + result += " "; + result += entry->GetBodySourceCode(); + result += ",\n"; + } + + return result; +} + +size_t CutsceneCommand::GetCommandSize() const +{ + size_t size = 0; + if (entries.size() > 0) + { + size = entries.at(0)->GetRawSize() * entries.size(); + } + else + { + size = 0x08 * numEntries; + } + return 0x08 + size; +} + +void CutsceneCommand::SetCommandID(uint32_t nCommandID) +{ + commandID = nCommandID; + + for (auto& entry : entries) + { + entry->commandID = commandID; + } +} + +/*** TIME ****/ + +CutsceneSubCommandEntry_SetTime::CutsceneSubCommandEntry_SetTime( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + hour = BitConverter::ToUInt8BE(rawData, rawDataIndex + 6); + minute = BitConverter::ToUInt8BE(rawData, rawDataIndex + 7); +} + +std::string CutsceneSubCommandEntry_SetTime::GetBodySourceCode() const +{ + // Note: Both OoT and MM have the first argument unused + return StringHelper::Sprintf("CS_TIME(%i, %i, %i, %i, %i)", base, startFrame, endFrame, hour, + minute); +} + +size_t CutsceneSubCommandEntry_SetTime::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_Time::CutsceneCommand_Time(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_SetTime(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_Time::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TIME_LIST(%i)", numEntries); +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Common.h b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Common.h new file mode 100644 index 0000000000..9d8dcf63de --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Common.h @@ -0,0 +1,72 @@ +#pragma once + +#include +#include +#include +#include "Declaration.h" + +typedef struct CsCommandListDescriptor +{ + const char* cmdMacro; + const char* args; +} CsCommandListDescriptor; + +class CutsceneSubCommandEntry +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t pad; + + uint32_t commandID; + + CutsceneSubCommandEntry(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneSubCommandEntry() = default; + + virtual std::string GetBodySourceCode() const; + + virtual size_t GetRawSize() const; +}; + +class CutsceneCommand +{ +public: + uint32_t commandID; + uint32_t commandIndex; + + uint32_t numEntries; + std::vector entries; + + CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneCommand(); + + virtual std::string GetCommandMacro() const; + virtual std::string GenerateSourceCode() const; + virtual size_t GetCommandSize() const; + + virtual void SetCommandID(uint32_t nCommandID); +}; + +/**** TIME ****/ + +class CutsceneSubCommandEntry_SetTime : public CutsceneSubCommandEntry +{ +public: + uint8_t hour; + uint8_t minute; + + CutsceneSubCommandEntry_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_Time : public CutsceneCommand +{ +public: + CutsceneCommand_Time(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; diff --git a/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp index 4c12062b23..e85bdefe76 100644 --- a/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp +++ b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp @@ -6,149 +6,149 @@ #include "ZDisplayList.h" #include "ZFile.h" -/* Struct_800A57C0 */ +/* SkinVertex */ -Struct_800A57C0::Struct_800A57C0(ZFile* nParent) : ZResource(nParent) +SkinVertex::SkinVertex(ZFile* nParent) : ZResource(nParent) { } -void Struct_800A57C0::ParseRawData() +void SkinVertex::ParseRawData() { const auto& rawData = parent->GetRawData(); - unk_0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); - unk_2 = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x02); - unk_4 = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x04); - unk_6 = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x06); - unk_7 = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x07); - unk_8 = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x08); - unk_9 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + index = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); + s = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x02); + t = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x04); + normX = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x06); + normY = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x07); + normZ = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x08); + alpha = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); } -std::string Struct_800A57C0::GetBodySourceCode() const +std::string SkinVertex::GetBodySourceCode() const { - return StringHelper::Sprintf("0x%02X, %i, %i, %i, %i, %i, 0x%02X", unk_0, unk_2, unk_4, unk_6, - unk_7, unk_8, unk_9); + return StringHelper::Sprintf("0x%02X, %i, %i, %i, %i, %i, 0x%02X", index, s, t, normX, normY, + normZ, alpha); } -std::string Struct_800A57C0::GetSourceTypeName() const +std::string SkinVertex::GetSourceTypeName() const { - return "Struct_800A57C0"; + return "SkinVertex"; } -ZResourceType Struct_800A57C0::GetResourceType() const +ZResourceType SkinVertex::GetResourceType() const { // TODO return ZResourceType::Error; } -size_t Struct_800A57C0::GetRawDataSize() const +size_t SkinVertex::GetRawDataSize() const { return 0x0A; } -/* Struct_800A598C_2 */ +/* SkinTransformation */ -Struct_800A598C_2::Struct_800A598C_2(ZFile* nParent) : ZResource(nParent) +SkinTransformation::SkinTransformation(ZFile* nParent) : ZResource(nParent) { } -void Struct_800A598C_2::ParseRawData() +void SkinTransformation::ParseRawData() { const auto& rawData = parent->GetRawData(); - unk_0 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x00); + limbIndex = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x00); x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x02); y = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x04); z = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x06); - unk_8 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + scale = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); } -std::string Struct_800A598C_2::GetBodySourceCode() const +std::string SkinTransformation::GetBodySourceCode() const { - return StringHelper::Sprintf("0x%02X, %i, %i, %i, 0x%02X", unk_0, x, y, z, unk_8); + return StringHelper::Sprintf("0x%02X, %i, %i, %i, 0x%02X", limbIndex, x, y, z, scale); } -std::string Struct_800A598C_2::GetSourceTypeName() const +std::string SkinTransformation::GetSourceTypeName() const { - return "Struct_800A598C_2"; + return "SkinTransformation"; } -ZResourceType Struct_800A598C_2::GetResourceType() const +ZResourceType SkinTransformation::GetResourceType() const { // TODO return ZResourceType::Error; } -size_t Struct_800A598C_2::GetRawDataSize() const +size_t SkinTransformation::GetRawDataSize() const { return 0x0A; } -/* Struct_800A598C */ +/* SkinLimbModif */ -Struct_800A598C::Struct_800A598C(ZFile* nParent) : ZResource(nParent) +SkinLimbModif::SkinLimbModif(ZFile* nParent) : ZResource(nParent) { } -void Struct_800A598C::ParseRawData() +void SkinLimbModif::ParseRawData() { const auto& rawData = parent->GetRawData(); - unk_0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); - unk_2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x02); + vtxCount = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); + transformCount = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x02); unk_4 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x04); - unk_8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); - unk_C = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0C); + skinVertices = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); + limbTransformations = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0C); - if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment) + if (skinVertices != 0 && GETSEGNUM(skinVertices) == parent->segment) { - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); + uint32_t unk_8_Offset = Seg2Filespace(skinVertices, parent->baseAddress); - unk_8_arr.reserve(unk_0); - for (size_t i = 0; i < unk_0; i++) + skinVertices_arr.reserve(vtxCount); + for (size_t i = 0; i < vtxCount; i++) { - Struct_800A57C0 unk8_data(parent); - unk8_data.ExtractFromFile(unk_8_Offset); - unk_8_arr.push_back(unk8_data); + SkinVertex skinVertices_data(parent); + skinVertices_data.ExtractFromFile(unk_8_Offset); + skinVertices_arr.push_back(skinVertices_data); - unk_8_Offset += unk8_data.GetRawDataSize(); + unk_8_Offset += skinVertices_data.GetRawDataSize(); } } - if (unk_C != 0 && GETSEGNUM(unk_8) == parent->segment) + if (limbTransformations != 0 && GETSEGNUM(skinVertices) == parent->segment) { - uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); + uint32_t unk_C_Offset = Seg2Filespace(limbTransformations, parent->baseAddress); - unk_C_arr.reserve(unk_2); - for (size_t i = 0; i < unk_2; i++) + limbTransformations_arr.reserve(transformCount); + for (size_t i = 0; i < transformCount; i++) { - Struct_800A598C_2 unkC_data(parent); - unkC_data.ExtractFromFile(unk_C_Offset); - unk_C_arr.push_back(unkC_data); + SkinTransformation limbTransformations_data(parent); + limbTransformations_data.ExtractFromFile(unk_C_Offset); + limbTransformations_arr.push_back(limbTransformations_data); - unk_C_Offset += unkC_data.GetRawDataSize(); + unk_C_Offset += limbTransformations_data.GetRawDataSize(); } } } -void Struct_800A598C::DeclareReferences(const std::string& prefix) +void SkinLimbModif::DeclareReferences(const std::string& prefix) { std::string varPrefix = prefix; if (name != "") varPrefix = name; - if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment) + if (skinVertices != 0 && GETSEGNUM(skinVertices) == parent->segment) { - const auto& res = unk_8_arr.at(0); + const auto& res = skinVertices_arr.at(0); std::string unk_8_Str = res.GetDefaultName(varPrefix); - size_t arrayItemCnt = unk_8_arr.size(); + size_t arrayItemCnt = skinVertices_arr.size(); std::string entryStr = ""; for (size_t i = 0; i < arrayItemCnt; i++) { - auto& child = unk_8_arr[i]; + auto& child = skinVertices_arr[i]; child.DeclareReferences(varPrefix); entryStr += StringHelper::Sprintf("\t{ %s },", child.GetBodySourceCode().c_str()); @@ -156,11 +156,11 @@ void Struct_800A598C::DeclareReferences(const std::string& prefix) entryStr += "\n"; } - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(unk_8_Offset); + uint32_t skinVertices_Offset = Seg2Filespace(skinVertices, parent->baseAddress); + Declaration* decl = parent->GetDeclaration(skinVertices_Offset); if (decl == nullptr) { - parent->AddDeclarationArray(unk_8_Offset, res.GetDeclarationAlignment(), + parent->AddDeclarationArray(skinVertices_Offset, res.GetDeclarationAlignment(), arrayItemCnt * res.GetRawDataSize(), res.GetSourceTypeName(), unk_8_Str, arrayItemCnt, entryStr); } @@ -168,17 +168,17 @@ void Struct_800A598C::DeclareReferences(const std::string& prefix) decl->declBody = entryStr; } - if (unk_C != 0 && GETSEGNUM(unk_C) == parent->segment) + if (limbTransformations != 0 && GETSEGNUM(limbTransformations) == parent->segment) { - const auto& res = unk_C_arr.at(0); + const auto& res = limbTransformations_arr.at(0); std::string unk_C_Str = res.GetDefaultName(varPrefix); - size_t arrayItemCnt = unk_C_arr.size(); + size_t arrayItemCnt = limbTransformations_arr.size(); std::string entryStr = ""; for (size_t i = 0; i < arrayItemCnt; i++) { - auto& child = unk_C_arr[i]; + auto& child = limbTransformations_arr[i]; child.DeclareReferences(varPrefix); entryStr += StringHelper::Sprintf("\t{ %s },", child.GetBodySourceCode().c_str()); @@ -186,7 +186,7 @@ void Struct_800A598C::DeclareReferences(const std::string& prefix) entryStr += "\n"; } - uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); + uint32_t unk_C_Offset = Seg2Filespace(limbTransformations, parent->baseAddress); Declaration* decl = parent->GetDeclaration(unk_C_Offset); if (decl == nullptr) { @@ -199,69 +199,70 @@ void Struct_800A598C::DeclareReferences(const std::string& prefix) } } -std::string Struct_800A598C::GetBodySourceCode() const +std::string SkinLimbModif::GetBodySourceCode() const { - std::string unk_8_Str; + std::string skinVertices_Str; std::string unk_C_Str; - Globals::Instance->GetSegmentedPtrName(unk_8, parent, "Struct_800A57C0", unk_8_Str); - Globals::Instance->GetSegmentedPtrName(unk_C, parent, "Struct_800A598C_2", unk_C_Str); + Globals::Instance->GetSegmentedPtrName(skinVertices, parent, "SkinVertex", skinVertices_Str); + Globals::Instance->GetSegmentedPtrName(limbTransformations, parent, "SkinTransformation", + unk_C_Str); std::string entryStr = StringHelper::Sprintf("\n\t\tARRAY_COUNTU(%s), ARRAY_COUNTU(%s),\n", - unk_8_Str.c_str(), unk_C_Str.c_str()); - entryStr += - StringHelper::Sprintf("\t\t%i, %s, %s\n\t", unk_4, unk_8_Str.c_str(), unk_C_Str.c_str()); + skinVertices_Str.c_str(), unk_C_Str.c_str()); + entryStr += StringHelper::Sprintf("\t\t%i, %s, %s\n\t", unk_4, skinVertices_Str.c_str(), + unk_C_Str.c_str()); return entryStr; } -std::string Struct_800A598C::GetSourceTypeName() const +std::string SkinLimbModif::GetSourceTypeName() const { - return "Struct_800A598C"; + return "SkinLimbModif"; } -ZResourceType Struct_800A598C::GetResourceType() const +ZResourceType SkinLimbModif::GetResourceType() const { // TODO return ZResourceType::Error; } -size_t Struct_800A598C::GetRawDataSize() const +size_t SkinLimbModif::GetRawDataSize() const { return 0x10; } -/* Struct_800A5E28 */ +/* SkinAnimatedLimbData */ -Struct_800A5E28::Struct_800A5E28(ZFile* nParent) : ZResource(nParent) +SkinAnimatedLimbData::SkinAnimatedLimbData(ZFile* nParent) : ZResource(nParent) { } -void Struct_800A5E28::ParseRawData() +void SkinAnimatedLimbData::ParseRawData() { const auto& rawData = parent->GetRawData(); - unk_0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); - unk_2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x02); - unk_4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04); - unk_8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); + totalVtxCount = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); + limbModifCount = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x02); + limbModifications = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04); + dlist = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); - if (unk_4 != 0 && GETSEGNUM(unk_4) == parent->segment) + if (limbModifications != 0 && GETSEGNUM(limbModifications) == parent->segment) { - uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); + uint32_t limbModifications_Offset = Seg2Filespace(limbModifications, parent->baseAddress); - unk_4_arr.reserve(unk_2); - for (size_t i = 0; i < unk_2; i++) + limbModifications_arr.reserve(limbModifCount); + for (size_t i = 0; i < limbModifCount; i++) { - Struct_800A598C unk_4_data(parent); - unk_4_data.ExtractFromFile(unk_4_Offset); - unk_4_arr.push_back(unk_4_data); + SkinLimbModif limbModifications_data(parent); + limbModifications_data.ExtractFromFile(limbModifications_Offset); + limbModifications_arr.push_back(limbModifications_data); - unk_4_Offset += unk_4_data.GetRawDataSize(); + limbModifications_Offset += limbModifications_data.GetRawDataSize(); } } } -void Struct_800A5E28::DeclareReferences(const std::string& prefix) +void SkinAnimatedLimbData::DeclareReferences(const std::string& prefix) { std::string varPrefix = prefix; if (name != "") @@ -269,17 +270,17 @@ void Struct_800A5E28::DeclareReferences(const std::string& prefix) ZResource::DeclareReferences(varPrefix); - if (unk_4 != SEGMENTED_NULL && GETSEGNUM(unk_4) == parent->segment) + if (limbModifications != SEGMENTED_NULL && GETSEGNUM(limbModifications) == parent->segment) { - const auto& res = unk_4_arr.at(0); - std::string unk_4_Str = res.GetDefaultName(varPrefix); + const auto& res = limbModifications_arr.at(0); + std::string limbModifications_Str = res.GetDefaultName(varPrefix); - size_t arrayItemCnt = unk_4_arr.size(); + size_t arrayItemCnt = limbModifications_arr.size(); std::string entryStr = ""; for (size_t i = 0; i < arrayItemCnt; i++) { - auto& child = unk_4_arr[i]; + auto& child = limbModifications_arr[i]; child.DeclareReferences(varPrefix); entryStr += StringHelper::Sprintf("\t{ %s },", child.GetBodySourceCode().c_str()); @@ -287,63 +288,67 @@ void Struct_800A5E28::DeclareReferences(const std::string& prefix) entryStr += "\n"; } - uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(unk_4_Offset); + uint32_t limbModifications_Offset = Seg2Filespace(limbModifications, parent->baseAddress); + Declaration* decl = parent->GetDeclaration(limbModifications_Offset); if (decl == nullptr) { - parent->AddDeclarationArray(unk_4_Offset, res.GetDeclarationAlignment(), + parent->AddDeclarationArray(limbModifications_Offset, res.GetDeclarationAlignment(), arrayItemCnt * res.GetRawDataSize(), - res.GetSourceTypeName(), unk_4_Str, arrayItemCnt, entryStr); + res.GetSourceTypeName(), limbModifications_Str, + arrayItemCnt, entryStr); } else decl->declBody = entryStr; } - if (unk_8 != SEGMENTED_NULL && GETSEGNUM(unk_8) == parent->segment) + if (dlist != SEGMENTED_NULL && GETSEGNUM(dlist) == parent->segment) { - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); + uint32_t dlist_Offset = Seg2Filespace(dlist, parent->baseAddress); int32_t dlistLength = ZDisplayList::GetDListLength( - parent->GetRawData(), unk_8_Offset, + parent->GetRawData(), dlist_Offset, Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - ZDisplayList* unk_8_dlist = new ZDisplayList(parent); - unk_8_dlist->ExtractFromBinary(unk_8_Offset, dlistLength); + ZDisplayList* dlist_data = new ZDisplayList(parent); + dlist_data->ExtractFromBinary(dlist_Offset, dlistLength); std::string dListStr = - StringHelper::Sprintf("%sSkinLimbDL_%06X", varPrefix.c_str(), unk_8_Offset); - unk_8_dlist->SetName(dListStr); - unk_8_dlist->DeclareVar(varPrefix, ""); - unk_8_dlist->DeclareReferences(varPrefix); - parent->AddResource(unk_8_dlist); + StringHelper::Sprintf("%sSkinLimbDL_%06X", varPrefix.c_str(), dlist_Offset); + dlist_data->SetName(dListStr); + dlist_data->DeclareVar(varPrefix, ""); + dlist_data->DeclareReferences(varPrefix); + parent->AddResource(dlist_data); } } -std::string Struct_800A5E28::GetBodySourceCode() const +std::string SkinAnimatedLimbData::GetBodySourceCode() const { - std::string unk_4_Str; - std::string unk_8_Str; - Globals::Instance->GetSegmentedPtrName(unk_4, parent, "Struct_800A598C", unk_4_Str); - Globals::Instance->GetSegmentedPtrName(unk_8, parent, "Gfx", unk_8_Str); + std::string limbModifications_Str; + std::string dlist_Str; + Globals::Instance->GetSegmentedPtrName(limbModifications, parent, "SkinLimbModif", + limbModifications_Str); + Globals::Instance->GetSegmentedPtrName(dlist, parent, "Gfx", dlist_Str); std::string entryStr = "\n"; - entryStr += StringHelper::Sprintf("\t%i, ARRAY_COUNTU(%s),\n", unk_0, unk_4_Str.c_str()); - entryStr += StringHelper::Sprintf("\t%s, %s\n", unk_4_Str.c_str(), unk_8_Str.c_str()); + entryStr += StringHelper::Sprintf("\t%i, ARRAY_COUNTU(%s),\n", totalVtxCount, + limbModifications_Str.c_str()); + entryStr += + StringHelper::Sprintf("\t%s, %s\n", limbModifications_Str.c_str(), dlist_Str.c_str()); return entryStr; } -std::string Struct_800A5E28::GetSourceTypeName() const +std::string SkinAnimatedLimbData::GetSourceTypeName() const { - return "Struct_800A5E28"; + return "SkinAnimatedLimbData"; } -ZResourceType Struct_800A5E28::GetResourceType() const +ZResourceType SkinAnimatedLimbData::GetResourceType() const { // TODO return ZResourceType::Error; } -size_t Struct_800A5E28::GetRawDataSize() const +size_t SkinAnimatedLimbData::GetRawDataSize() const { return 0x0C; } diff --git a/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h index 33edd07cae..f338ebeddc 100644 --- a/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h +++ b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h @@ -6,19 +6,17 @@ #include "ZResource.h" -// TODO: check if more types exists enum class ZLimbSkinType { - SkinType_0, // Segment = 0 - SkinType_4 = 4, // Segment = segmented address // Struct_800A5E28 - SkinType_5 = 5, // Segment = 0 - SkinType_DList = 11, // Segment = DList address + SkinType_Null, // SkinLimb segment = NULL + SkinType_Animated = 4, // SkinLimb segment = SkinAnimatedLimbData* + SkinType_Normal = 11, // SkinLimb segment = Gfx* }; -class Struct_800A57C0 : public ZResource +class SkinVertex : public ZResource { public: - Struct_800A57C0(ZFile* nParent); + SkinVertex(ZFile* nParent); void ParseRawData() override; @@ -30,19 +28,19 @@ public: size_t GetRawDataSize() const override; protected: - uint16_t unk_0; - int16_t unk_2; - int16_t unk_4; - int8_t unk_6; - int8_t unk_7; - int8_t unk_8; - uint8_t unk_9; + uint16_t index; + int16_t s; + int16_t t; + int8_t normX; + int8_t normY; + int8_t normZ; + uint8_t alpha; }; -class Struct_800A598C_2 : public ZResource +class SkinTransformation : public ZResource { public: - Struct_800A598C_2(ZFile* nParent); + SkinTransformation(ZFile* nParent); void ParseRawData() override; @@ -54,17 +52,17 @@ public: size_t GetRawDataSize() const override; protected: - uint8_t unk_0; + uint8_t limbIndex; int16_t x; int16_t y; int16_t z; - uint8_t unk_8; + uint8_t scale; }; -class Struct_800A598C : public ZResource +class SkinLimbModif : public ZResource { public: - Struct_800A598C(ZFile* nParent); + SkinLimbModif(ZFile* nParent); void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; @@ -77,20 +75,20 @@ public: size_t GetRawDataSize() const override; protected: - uint16_t unk_0; // Length of unk_8 - uint16_t unk_2; // Length of unk_C - uint16_t unk_4; // 0 or 1 // Used as an index for unk_C - segptr_t unk_8; // Struct_800A57C0* - segptr_t unk_C; // Struct_800A598C_2* + uint16_t vtxCount; // Number of vertices in this modif entry + uint16_t transformCount; // Length of limbTransformations + uint16_t unk_4; // 0 or 1, used as an index for limbTransformations + segptr_t skinVertices; // SkinVertex* + segptr_t limbTransformations; // SkinTransformation* - std::vector unk_8_arr; - std::vector unk_C_arr; + std::vector skinVertices_arr; + std::vector limbTransformations_arr; }; -class Struct_800A5E28 : public ZResource +class SkinAnimatedLimbData : public ZResource { public: - Struct_800A5E28(ZFile* nParent); + SkinAnimatedLimbData(ZFile* nParent); void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; @@ -103,11 +101,11 @@ public: size_t GetRawDataSize() const override; protected: - uint16_t unk_0; // Vtx count - uint16_t unk_2; // Length of unk_4 - segptr_t unk_4; // Struct_800A598C* - segptr_t unk_8; // Gfx* + uint16_t totalVtxCount; + uint16_t limbModifCount; // Length of limbModifications + segptr_t limbModifications; // SkinLimbModif* + segptr_t dlist; // Gfx* - std::vector unk_4_arr; + std::vector limbModifications_arr; // ZDisplayList* unk_8_dlist = nullptr; }; diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj b/tools/ZAPD/ZAPD/ZAPD.vcxproj index 77d0bd16eb..22bc720e9d 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj @@ -186,7 +186,8 @@ mkdir build\ZAPD - + + @@ -198,9 +199,9 @@ mkdir build\ZAPD - + @@ -278,7 +279,8 @@ mkdir build\ZAPD - + + @@ -296,9 +298,9 @@ mkdir build\ZAPD - + diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters index eac471961c..f693a749d2 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters @@ -228,9 +228,6 @@ Source Files\Z64\ZRoom\Commands - - Source Files\Z64\ZRoom\Commands - Source Files\Z64\ZRoom\Commands @@ -279,9 +276,6 @@ Source Files\Z64 - - Source Files\Z64 - Source Files\Z64 @@ -297,6 +291,15 @@ Source Files\Z64 + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + @@ -497,9 +500,6 @@ Header Files\Z64\ZRoom\Commands - - Header Files\Z64\ZRoom\Commands - Header Files\Z64\ZRoom\Commands @@ -548,9 +548,6 @@ Header Files\Z64 - - Header Files\Z64 - Header Files\Z64 @@ -569,6 +566,15 @@ Header Files + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + diff --git a/tools/ZAPD/ZAPD/ZAnimation.cpp b/tools/ZAPD/ZAPD/ZAnimation.cpp index 0d72344075..959fff8291 100644 --- a/tools/ZAPD/ZAPD/ZAnimation.cpp +++ b/tools/ZAPD/ZAPD/ZAnimation.cpp @@ -153,7 +153,10 @@ size_t ZLinkAnimation::GetRawDataSize() const std::string ZLinkAnimation::GetSourceTypeName() const { - return "LinkAnimationHeader"; + if (Globals::Instance->game == ZGame::MM_RETAIL) + return "PlayerAnimationHeader"; + else + return "LinkAnimationHeader"; } void ZLinkAnimation::ParseRawData() @@ -174,8 +177,8 @@ std::string ZLinkAnimation::GetBodySourceCode() const /* ZCurveAnimation */ -TransformData::TransformData(ZFile* parent, const std::vector& rawData, - uint32_t fileOffset) +CurveInterpKnot::CurveInterpKnot(ZFile* parent, const std::vector& rawData, + uint32_t fileOffset) : parent(parent) { unk_00 = BitConverter::ToUInt16BE(rawData, fileOffset + 0); @@ -185,26 +188,26 @@ TransformData::TransformData(ZFile* parent, const std::vector& rawData, unk_08 = BitConverter::ToFloatBE(rawData, fileOffset + 8); } -TransformData::TransformData(ZFile* parent, const std::vector& rawData, - uint32_t fileOffset, size_t index) - : TransformData(parent, rawData, fileOffset + index * GetRawDataSize()) +CurveInterpKnot::CurveInterpKnot(ZFile* parent, const std::vector& rawData, + uint32_t fileOffset, size_t index) + : CurveInterpKnot(parent, rawData, fileOffset + index * GetRawDataSize()) { } -std::string TransformData::GetBody([[maybe_unused]] const std::string& prefix) const +std::string CurveInterpKnot::GetBody([[maybe_unused]] const std::string& prefix) const { return StringHelper::Sprintf("0x%04X, 0x%04X, %i, %i, %ff", unk_00, unk_02, unk_04, unk_06, unk_08); } -size_t TransformData::GetRawDataSize() const +size_t CurveInterpKnot::GetRawDataSize() const { return 0x0C; } -std::string TransformData::GetSourceTypeName() +std::string CurveInterpKnot::GetSourceTypeName() { - return "TransformData"; + return "CurveInterpKnot"; } ZCurveAnimation::ZCurveAnimation(ZFile* nParent) : ZAnimation(nParent) @@ -369,7 +372,7 @@ std::string ZCurveAnimation::GetBodySourceCode() const std::string refIndexStr; Globals::Instance->GetSegmentedPtrName(refIndex, parent, "u8", refIndexStr); std::string transformDataStr; - Globals::Instance->GetSegmentedPtrName(transformData, parent, "TransformData", + Globals::Instance->GetSegmentedPtrName(transformData, parent, "CurveInterpKnot", transformDataStr); std::string copyValuesStr; Globals::Instance->GetSegmentedPtrName(copyValues, parent, "s16", copyValuesStr); @@ -390,7 +393,7 @@ DeclarationAlignment ZCurveAnimation::GetDeclarationAlignment() const std::string ZCurveAnimation::GetSourceTypeName() const { - return "TransformUpdateIndex"; + return "CurveAnimationHeader"; } /* ZLegacyAnimation */ @@ -423,7 +426,7 @@ void ZLegacyAnimation::ParseRawData() ptr = jointKeyOffset; for (int32_t i = 0; i < limbCount + 1; i++) { - JointKey key(parent); + LegacyJointKey key(parent); key.ExtractFromFile(ptr); jointKeyArray.push_back(key); @@ -495,7 +498,7 @@ std::string ZLegacyAnimation::GetBodySourceCode() const std::string frameDataName; std::string jointKeyName; Globals::Instance->GetSegmentedPtrName(frameData, parent, "s16", frameDataName); - Globals::Instance->GetSegmentedPtrName(jointKey, parent, "JointKey", jointKeyName); + Globals::Instance->GetSegmentedPtrName(jointKey, parent, "LegacyJointKey", jointKeyName); body += StringHelper::Sprintf("\t%i, %i,\n", frameCount, limbCount); body += StringHelper::Sprintf("\t%s,\n", frameDataName.c_str()); @@ -514,11 +517,11 @@ size_t ZLegacyAnimation::GetRawDataSize() const return 0x0C; } -JointKey::JointKey(ZFile* nParent) : ZResource(nParent) +LegacyJointKey::LegacyJointKey(ZFile* nParent) : ZResource(nParent) { } -void JointKey::ParseRawData() +void LegacyJointKey::ParseRawData() { ZResource::ParseRawData(); @@ -531,23 +534,23 @@ void JointKey::ParseRawData() z = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x0A); } -std::string JointKey::GetBodySourceCode() const +std::string LegacyJointKey::GetBodySourceCode() const { return StringHelper::Sprintf("%6i, %6i, %6i, %6i, %6i, %6i", xMax, x, yMax, y, zMax, z); } -std::string JointKey::GetSourceTypeName() const +std::string LegacyJointKey::GetSourceTypeName() const { - return "JointKey"; + return "LegacyJointKey"; } -ZResourceType JointKey::GetResourceType() const +ZResourceType LegacyJointKey::GetResourceType() const { // TODO return ZResourceType::Error; } -size_t JointKey::GetRawDataSize() const +size_t LegacyJointKey::GetRawDataSize() const { return 0x0C; } diff --git a/tools/ZAPD/ZAPD/ZAnimation.h b/tools/ZAPD/ZAPD/ZAnimation.h index 2c04b4ff81..643842b891 100644 --- a/tools/ZAPD/ZAPD/ZAnimation.h +++ b/tools/ZAPD/ZAPD/ZAnimation.h @@ -67,7 +67,7 @@ public: void ParseRawData() override; }; -class TransformData +class CurveInterpKnot { protected: ZFile* parent; @@ -84,10 +84,10 @@ protected: float unk_08; public: - TransformData() = default; - TransformData(ZFile* parent, const std::vector& rawData, uint32_t fileOffset); - TransformData(ZFile* parent, const std::vector& rawData, uint32_t fileOffset, - size_t index); + CurveInterpKnot() = default; + CurveInterpKnot(ZFile* parent, const std::vector& rawData, uint32_t fileOffset); + CurveInterpKnot(ZFile* parent, const std::vector& rawData, uint32_t fileOffset, + size_t index); [[nodiscard]] std::string GetBody(const std::string& prefix) const; @@ -102,7 +102,7 @@ protected: ///* 0x0000 */ u8* refIndex; segptr_t refIndex = 0; - ///* 0x0004 */ TransformData* transformData; + ///* 0x0004 */ CurveInterpKnot* transformData; segptr_t transformData = 0; ///* 0x0008 */ s16* copyValues; segptr_t copyValues = 0; @@ -114,7 +114,7 @@ protected: uint8_t limbCount = 0; std::vector refIndexArr; - std::vector transformDataArr; + std::vector transformDataArr; std::vector copyValuesArr; public: @@ -132,14 +132,14 @@ public: std::string GetSourceTypeName() const override; }; -// TransformUpdateIndex +// CurveAnimationHeader /* ZLegacyAnimation */ -class JointKey : public ZResource +class LegacyJointKey : public ZResource { public: - JointKey(ZFile* nParent); + LegacyJointKey(ZFile* nParent); void ParseRawData() override; std::string GetBodySourceCode() const override; @@ -172,8 +172,8 @@ public: protected: int16_t limbCount; segptr_t frameData; // s16* - segptr_t jointKey; // JointKey* + segptr_t jointKey; // LegacyJointKey* std::vector frameDataArray; - std::vector jointKeyArray; + std::vector jointKeyArray; }; diff --git a/tools/ZAPD/ZAPD/ZCollision.cpp b/tools/ZAPD/ZAPD/ZCollision.cpp index 8c193167b1..d177e036cb 100644 --- a/tools/ZAPD/ZAPD/ZCollision.cpp +++ b/tools/ZAPD/ZAPD/ZCollision.cpp @@ -99,7 +99,7 @@ void ZCollisionHeader::ParseRawData() // usually ordered. If for some reason the data was in some other funny // order, this would probably break. // The most common ordering is: - // - *CamData* + // - *BgCamInfo* // - SurfaceType // - CollisionPoly // - Vertices @@ -261,7 +261,7 @@ std::string ZCollisionHeader::GetBodySourceCode() const declaration += StringHelper::Sprintf("\t%s,\n", surfaceName.c_str()); std::string camName; - Globals::Instance->GetSegmentedPtrName(camDataAddress, parent, "CamData", camName); + Globals::Instance->GetSegmentedPtrName(camDataAddress, parent, "BgCamInfo", camName); declaration += StringHelper::Sprintf("\t%s,\n", camName.c_str()); std::string waterBoxName; @@ -370,7 +370,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, } parent->AddDeclarationArray( - rawDataIndex, DeclarationAlignment::Align4, entries.size() * 8, "CamData", + rawDataIndex, DeclarationAlignment::Align4, entries.size() * 8, "BgCamInfo", StringHelper::Sprintf("%sCamDataList", prefix.c_str(), rawDataIndex), entries.size(), declaration); diff --git a/tools/ZAPD/ZAPD/ZCutscene.cpp b/tools/ZAPD/ZAPD/ZCutscene.cpp index c2e6c2b8ff..b90fb872d6 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.cpp +++ b/tools/ZAPD/ZAPD/ZCutscene.cpp @@ -3,7 +3,6 @@ #include #include "Globals.h" -#include "OtherStructs/CutsceneMM_Commands.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" @@ -129,174 +128,147 @@ void ZCutscene::ParseRawData() CutsceneCommand* ZCutscene::GetCommandOoT(uint32_t id, offset_t currentPtr) const { - CutsceneCommands cmdID = static_cast(id); + CutsceneOoT_CommandType cmdID = static_cast(id); const auto& rawData = parent->GetRawData(); - switch (id) - { - case 10: // CutsceneCommands::SetPlayerAction - case 15: // CutsceneCommands::SetActorAction1 - case 17: - case 18: - case 23: - case 34: - case 39: - case 46: - case 76: - case 85: - case 93: - case 105: - case 107: - case 110: - case 119: - case 123: - case 138: - case 139: - case 144: - case 14: // CutsceneCommands::SetActorAction2 - case 16: - case 24: - case 35: - case 40: - case 48: - case 64: - case 68: - case 70: - case 78: - case 80: - case 94: - case 116: - case 118: - case 120: - case 125: - case 131: - case 141: - case 25: // CutsceneCommands::SetActorAction3 - case 36: - case 41: - case 50: - case 67: - case 69: - case 72: - case 81: - case 106: - case 117: - case 121: - case 126: - case 132: - case 29: // CutsceneCommands::SetActorAction4 - case 37: - case 42: - case 51: - case 53: - case 63: - case 65: - case 66: - case 75: - case 82: - case 108: - case 127: - case 133: - case 30: // CutsceneCommands::SetActorAction5 - case 38: - case 43: - case 47: - case 54: - case 79: - case 83: - case 128: - case 135: - case 44: // CutsceneCommands::SetActorAction6 - case 55: - case 77: - case 84: - case 90: - case 129: - case 136: - case 31: // CutsceneCommands::SetActorAction7 - case 52: - case 57: - case 58: - case 88: - case 115: - case 130: - case 137: - case 49: // CutsceneCommands::SetActorAction8 - case 60: - case 89: - case 111: - case 114: - case 134: - case 142: - case 62: // CutsceneCommands::SetActorAction9 - case 143: // CutsceneCommands::SetActorAction10 - case 74: - return new CutsceneCommand_ActorAction(rawData, currentPtr); - - case 0x0B: - case 0x0D: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x20: - case 0x21: - case 0x3B: - case 0x3D: - case 0x47: - case 0x49: - case 0x6D: - case 0x15: - case 0x16: - case 0x70: - case 0x71: - return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); - } - switch (cmdID) { - case CutsceneCommands::Misc: - case CutsceneCommands::SetLighting: - case CutsceneCommands::PlayBGM: - case CutsceneCommands::StopBGM: - case CutsceneCommands::FadeBGM: - return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); + case CutsceneOoT_CommandType::CS_CMD_PLAYER_CUE: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_1: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_1: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_2: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_3: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_2: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_4_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_6_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_4: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_3: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_1: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_1: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_4_1: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_5: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_4: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_2: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_2: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_4_2: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_5_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_6: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_4_3: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_5: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_7_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_3: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_3: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_6_1: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_4: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_4_4: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_5_1: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_6_2: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_6_3: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_7_1: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_8_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_5: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_6: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_6: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_7: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_4: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_7: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_5: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_8: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_6: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_7: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_8: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_7: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_5_2: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_9: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_4_5: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_10: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_8: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_9: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_4_6: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_5_3: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_8: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_6_4: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_7_2: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_5_4: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_9: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_11: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_10: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_9: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_11: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_10: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_12: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_7_3: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_7_4: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_6_5: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_12: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_10: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_13: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_13: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_14: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_11: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_14: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_15: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_12: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_11: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_4_7: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_5_5: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_6_6: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_16: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_2_13: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_3_12: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_7_5: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_4_8: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_5_6: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_6_7: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_15: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_16: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_1_17: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_7_6: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_9_0: + case CutsceneOoT_CommandType::CS_CMD_ACTOR_CUE_0_17: + return new CutsceneOoTCommand_ActorCue(rawData, currentPtr); - case CutsceneCommands::SetCameraPos: - case CutsceneCommands::SetCameraFocus: - case CutsceneCommands::SetCameraPosLink: - case CutsceneCommands::SetCameraFocusLink: - return new CutsceneCommandSetCameraPos(rawData, currentPtr); + case CutsceneOoT_CommandType::CS_CMD_MISC: + case CutsceneOoT_CommandType::CS_CMD_LIGHT_SETTING: + case CutsceneOoT_CommandType::CS_CMD_START_SEQ: + case CutsceneOoT_CommandType::CS_CMD_STOP_SEQ: + case CutsceneOoT_CommandType::CS_CMD_FADE_OUT_SEQ: + return new CutsceneOoTCommand_GenericCmd(rawData, currentPtr, cmdID); - case CutsceneCommands::Cmd07: - break; - case CutsceneCommands::Cmd08: - break; - case CutsceneCommands::Cmd09: - return new CutsceneCommand_Rumble(rawData, currentPtr); - case CutsceneCommands::Textbox: - return new CutsceneCommand_TextBox(rawData, currentPtr); + case CutsceneOoT_CommandType::CS_CMD_CAM_EYE_SPLINE: + case CutsceneOoT_CommandType::CS_CMD_CAM_AT_SPLINE: + case CutsceneOoT_CommandType::CS_CMD_CAM_EYE_SPLINE_REL_TO_PLAYER: + case CutsceneOoT_CommandType::CS_CMD_CAM_AT_SPLINE_REL_TO_PLAYER: + return new CutsceneOoTCommand_GenericCameraCmd(rawData, currentPtr); - case CutsceneCommands::SetPlayerAction: - case CutsceneCommands::SetActorAction1: - case CutsceneCommands::SetActorAction2: - case CutsceneCommands::SetActorAction3: - case CutsceneCommands::SetActorAction4: - case CutsceneCommands::SetActorAction5: - case CutsceneCommands::SetActorAction6: - case CutsceneCommands::SetActorAction7: - case CutsceneCommands::SetActorAction8: - case CutsceneCommands::SetActorAction9: - case CutsceneCommands::SetActorAction10: + case CutsceneOoT_CommandType::CS_CMD_RUMBLE_CONTROLLER: + return new CutsceneOoTCommand_Rumble(rawData, currentPtr); + + case CutsceneOoT_CommandType::CS_CMD_TEXT: + return new CutsceneOoTCommand_Text(rawData, currentPtr); + + case CutsceneOoT_CommandType::CS_CMD_TRANSITION: + return new CutsceneOoTCommand_Transition(rawData, currentPtr); + + case CutsceneOoT_CommandType::CS_CMD_TIME: + return new CutsceneCommand_Time(rawData, currentPtr); + + case CutsceneOoT_CommandType::CS_CMD_DESTINATION: + return new CutsceneOoTCommand_Destination(rawData, currentPtr); + + case CutsceneOoT_CommandType::CS_CMD_CAM_EYE: + case CutsceneOoT_CommandType::CS_CMD_CAM_AT: break; - case CutsceneCommands::SetSceneTransFX: - return new CutsceneCommandSceneTransFX(rawData, currentPtr); - - case CutsceneCommands::SetTime: - return new CutsceneCommand_SetTime(rawData, currentPtr); - case CutsceneCommands::Terminator: - return new CutsceneCommand_Terminator(rawData, currentPtr); + default: + std::string errorHeader = + StringHelper::Sprintf("Warning: Invalid cutscene command ID: '0x%04X'", cmdID); + return new CutsceneOoTCommand_GenericCmd(rawData, currentPtr, cmdID); } return nullptr; @@ -304,60 +276,74 @@ CutsceneCommand* ZCutscene::GetCommandOoT(uint32_t id, offset_t currentPtr) cons CutsceneCommand* ZCutscene::GetCommandMM(uint32_t id, offset_t currentPtr) const { - CutsceneMMCommands cmdID = static_cast(id); + CutsceneMM_CommandType cmdID = static_cast(id); const auto& rawData = parent->GetRawData(); - if (((id >= 100) && (id < 150)) || (id == 201) || ((id >= 450) && (id < 600))) + if (((id >= (uint32_t)CutsceneMM_CommandType::CS_CMD_ACTOR_CUE_100) && + (id <= (uint32_t)CutsceneMM_CommandType::CS_CMD_ACTOR_CUE_149)) || + (id == (uint32_t)CutsceneMM_CommandType::CS_CMD_ACTOR_CUE_201) || + ((id >= (uint32_t)CutsceneMM_CommandType::CS_CMD_ACTOR_CUE_450) && + (id <= (uint32_t)CutsceneMM_CommandType::CS_CMD_ACTOR_CUE_599))) { - return new CutsceneCommand_ActorAction(rawData, currentPtr); + return new CutsceneMMCommand_ActorCue(rawData, currentPtr); } switch (cmdID) { - case CutsceneMMCommands::CS_CMD_MISC: - case CutsceneMMCommands::CS_CMD_SET_LIGHTING: - case CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX: - case CutsceneMMCommands::CS_CMD_MOTIONBLUR: - case CutsceneMMCommands::CS_CMD_GIVETATL: - case CutsceneMMCommands::CS_CMD_PLAYSEQ: - case CutsceneMMCommands::CS_CMD_130: - case CutsceneMMCommands::CS_CMD_131: - case CutsceneMMCommands::CS_CMD_132: - case CutsceneMMCommands::CS_CMD_STOPSEQ: - case CutsceneMMCommands::CS_CMD_PLAYAMBIENCE: - case CutsceneMMCommands::CS_CMD_FADEAMBIENCE: - case CutsceneMMCommands::CS_CMD_TERMINATOR: - case CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES: + case CutsceneMM_CommandType::CS_CMD_MISC: + case CutsceneMM_CommandType::CS_CMD_LIGHT_SETTING: + case CutsceneMM_CommandType::CS_CMD_TRANSITION: + case CutsceneMM_CommandType::CS_CMD_MOTION_BLUR: + case CutsceneMM_CommandType::CS_CMD_GIVE_TATL: + case CutsceneMM_CommandType::CS_CMD_START_SEQ: + case CutsceneMM_CommandType::CS_CMD_SFX_REVERB_INDEX_2: + case CutsceneMM_CommandType::CS_CMD_SFX_REVERB_INDEX_1: + case CutsceneMM_CommandType::CS_CMD_MODIFY_SEQ: + case CutsceneMM_CommandType::CS_CMD_STOP_SEQ: + case CutsceneMM_CommandType::CS_CMD_START_AMBIENCE: + case CutsceneMM_CommandType::CS_CMD_FADE_OUT_AMBIENCE: + case CutsceneMM_CommandType::CS_CMD_DESTINATION: + case CutsceneMM_CommandType::CS_CMD_CHOOSE_CREDITS_SCENES: - case CutsceneMMCommands::CS_CMD_UNK_FA: - case CutsceneMMCommands::CS_CMD_UNK_FE: - case CutsceneMMCommands::CS_CMD_UNK_FF: - case CutsceneMMCommands::CS_CMD_UNK_100: - case CutsceneMMCommands::CS_CMD_UNK_101: - case CutsceneMMCommands::CS_CMD_UNK_102: - case CutsceneMMCommands::CS_CMD_UNK_103: - case CutsceneMMCommands::CS_CMD_UNK_104: - case CutsceneMMCommands::CS_CMD_UNK_105: - case CutsceneMMCommands::CS_CMD_UNK_108: - case CutsceneMMCommands::CS_CMD_UNK_109: - case CutsceneMMCommands::CS_CMD_UNK_12D: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_FA: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_FE: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_FF: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_100: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_101: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_102: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_103: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_104: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_105: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_108: + case CutsceneMM_CommandType::CS_CMD_UNK_DATA_109: return new CutsceneMMCommand_GenericCmd(rawData, currentPtr, cmdID); - case CutsceneMMCommands::CS_CMD_TEXTBOX: - return new CutsceneCommand_TextBox(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_CAMERA: - return new CutsceneMMCommand_Camera(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_FADESCREEN: - return new CutsceneMMCommand_FadeScreen(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_FADESEQ: - return new CutsceneMMCommand_FadeSeq(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_SETTIME: - return new CutsceneCommand_SetTime(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION: - return new CutsceneCommand_ActorAction(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_RUMBLE: - return new CutsceneCommand_Rumble(rawData, currentPtr); + case CutsceneMM_CommandType::CS_CMD_TEXT: + return new CutsceneMMCommand_Text(rawData, currentPtr); + + case CutsceneMM_CommandType::CS_CMD_CAMERA_SPLINE: + return new CutsceneMMCommand_Spline(rawData, currentPtr); + + case CutsceneMM_CommandType::CS_CMD_TRANSITION_GENERAL: + return new CutsceneMMCommand_TransitionGeneral(rawData, currentPtr); + + case CutsceneMM_CommandType::CS_CMD_FADE_OUT_SEQ: + return new CutsceneMMCommand_FadeOutSeq(rawData, currentPtr); + + case CutsceneMM_CommandType::CS_CMD_TIME: + return new CutsceneCommand_Time(rawData, currentPtr); + + case CutsceneMM_CommandType::CS_CMD_PLAYER_CUE: + return new CutsceneMMCommand_ActorCue(rawData, currentPtr); + + case CutsceneMM_CommandType::CS_CMD_RUMBLE: + return new CutsceneMMCommand_Rumble(rawData, currentPtr); + + default: + std::string errorHeader = + StringHelper::Sprintf("Warning: Invalid cutscene command ID: '0x%04X'", cmdID); + return new CutsceneMMCommand_GenericCmd(rawData, currentPtr, cmdID); } return nullptr; diff --git a/tools/ZAPD/ZAPD/ZCutscene.h b/tools/ZAPD/ZAPD/ZCutscene.h index 098f3ad868..5b54426cea 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.h +++ b/tools/ZAPD/ZAPD/ZCutscene.h @@ -5,7 +5,8 @@ #include #include "tinyxml2.h" -#include "OtherStructs/Cutscene_Commands.h" +#include "OtherStructs/CutsceneOoT_Commands.h" +#include "OtherStructs/CutsceneMM_Commands.h" #include "ZFile.h" #include "ZResource.h" diff --git a/tools/ZAPD/ZAPD/ZLimb.cpp b/tools/ZAPD/ZAPD/ZLimb.cpp index fd824d0101..b3acb940c1 100644 --- a/tools/ZAPD/ZAPD/ZLimb.cpp +++ b/tools/ZAPD/ZAPD/ZLimb.cpp @@ -106,7 +106,7 @@ void ZLimb::ParseRawData() skinSegmentType = static_cast(BitConverter::ToInt32BE(rawData, rawDataIndex + 8)); skinSegment = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - if (skinSegmentType == ZLimbSkinType::SkinType_4) + if (skinSegmentType == ZLimbSkinType::SkinType_Animated) { if (skinSegment != 0 && GETSEGNUM(skinSegment) == parent->segment) { @@ -181,7 +181,7 @@ void ZLimb::DeclareReferences(const std::string& prefix) case ZLimbType::Skin: switch (skinSegmentType) { - case ZLimbSkinType::SkinType_4: + case ZLimbSkinType::SkinType_Animated: if (skinSegment != 0 && GETSEGNUM(skinSegment) == parent->segment) { segmentStruct.DeclareReferences(varPrefix); @@ -189,7 +189,7 @@ void ZLimb::DeclareReferences(const std::string& prefix) } break; - case ZLimbSkinType::SkinType_DList: + case ZLimbSkinType::SkinType_Normal: DeclareDList(skinSegment, varPrefix, ""); break; diff --git a/tools/ZAPD/ZAPD/ZLimb.h b/tools/ZAPD/ZAPD/ZLimb.h index ce31e42958..52919bed92 100644 --- a/tools/ZAPD/ZAPD/ZLimb.h +++ b/tools/ZAPD/ZAPD/ZLimb.h @@ -28,9 +28,9 @@ public: ZLimbType type = ZLimbType::Standard; - ZLimbSkinType skinSegmentType = ZLimbSkinType::SkinType_0; // Skin only - segptr_t skinSegment = 0; // Skin only - Struct_800A5E28 segmentStruct; // Skin only + ZLimbSkinType skinSegmentType = ZLimbSkinType::SkinType_Null; // Skin only + segptr_t skinSegment = 0; // Skin only + SkinAnimatedLimbData segmentStruct; // Skin only // Legacy only float legTransX, legTransY, legTransZ; // Vec3f diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCameraSettings.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCameraSettings.cpp index ae2d31c81e..e30e1b682d 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCameraSettings.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCameraSettings.cpp @@ -2,6 +2,7 @@ #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" +#include "Globals.h" SetCameraSettings::SetCameraSettings(ZFile* nParent) : ZRoomCommand(nParent) { @@ -16,8 +17,12 @@ void SetCameraSettings::ParseRawData() std::string SetCameraSettings::GetBodySourceCode() const { - return StringHelper::Sprintf("SCENE_CMD_MISC_SETTINGS(0x%02X, 0x%08X)", cameraMovement, - mapHighlight); + if (Globals::Instance->game == ZGame::MM_RETAIL) + return StringHelper::Sprintf("SCENE_CMD_SET_REGION_VISITED(0x%02X, 0x%08X)", cameraMovement, + mapHighlight); + else + return StringHelper::Sprintf("SCENE_CMD_MISC_SETTINGS(0x%02X, 0x%08X)", cameraMovement, + mapHighlight); } std::string SetCameraSettings::GetCommandCName() const diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp index ada1a1038f..302d638d4c 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp @@ -21,7 +21,7 @@ void SetCsCamera::ParseRawData() cameras.reserve(numCameras); for (int32_t i = 0; i < numCameras; i++) { - CsCameraEntry entry(parent->GetRawData(), currentPtr); + ActorCsCamInfo entry(parent->GetRawData(), currentPtr); numPoints += entry.GetNumPoints(); currentPtr += entry.GetRawDataSize(); @@ -105,7 +105,7 @@ void SetCsCamera::DeclareReferences(const std::string& prefix) std::string SetCsCamera::GetBodySourceCode() const { std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CsCameraEntry", listName); + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorCsCamInfo", listName); return StringHelper::Sprintf("SCENE_CMD_ACTOR_CUTSCENE_CAM_LIST(%i, %s)", cameras.size(), listName.c_str()); } @@ -120,7 +120,7 @@ RoomCommand SetCsCamera::GetRoomCommand() const return RoomCommand::SetCsCamera; } -CsCameraEntry::CsCameraEntry(const std::vector& rawData, uint32_t rawDataIndex) +ActorCsCamInfo::ActorCsCamInfo(const std::vector& rawData, uint32_t rawDataIndex) : baseOffset(rawDataIndex), type(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)), numPoints(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)) { @@ -128,27 +128,27 @@ CsCameraEntry::CsCameraEntry(const std::vector& rawData, uint32_t rawDa segmentOffset = GETSEGOFFSET(camAddress); } -std::string CsCameraEntry::GetSourceTypeName() const +std::string ActorCsCamInfo::GetSourceTypeName() const { - return "CsCameraEntry"; + return "ActorCsCamInfo"; } -int32_t CsCameraEntry::GetRawDataSize() const +int32_t ActorCsCamInfo::GetRawDataSize() const { return 8; } -int16_t CsCameraEntry::GetNumPoints() const +int16_t ActorCsCamInfo::GetNumPoints() const { return numPoints; } -segptr_t CsCameraEntry::GetCamAddress() const +segptr_t ActorCsCamInfo::GetCamAddress() const { return camAddress; } -uint32_t CsCameraEntry::GetSegmentOffset() const +uint32_t ActorCsCamInfo::GetSegmentOffset() const { return segmentOffset; } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.h index 5e0e3c8257..2ce64e4e05 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.h @@ -3,10 +3,10 @@ #include "ZRoom/ZRoomCommand.h" #include "ZVector.h" -class CsCameraEntry +class ActorCsCamInfo { public: - CsCameraEntry(const std::vector& rawData, uint32_t rawDataIndex); + ActorCsCamInfo(const std::vector& rawData, uint32_t rawDataIndex); std::string GetSourceTypeName() const; int32_t GetRawDataSize() const; @@ -25,7 +25,7 @@ public: class SetCsCamera : public ZRoomCommand { public: - std::vector cameras; + std::vector cameras; std::vector points; SetCsCamera(ZFile* nParent); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutsceneEntryList.cpp similarity index 53% rename from tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp rename to tools/ZAPD/ZAPD/ZRoom/Commands/SetCutsceneEntryList.cpp index 15f2c6b451..96c50c3be2 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutsceneEntryList.cpp @@ -1,4 +1,4 @@ -#include "SetActorCutsceneList.h" +#include "SetCutsceneEntryList.h" #include "Globals.h" #include "Utils/BitConverter.h" @@ -19,7 +19,7 @@ void SetActorCutsceneList::ParseRawData() cutscenes.reserve(numCutscenes); for (int32_t i = 0; i < numCutscenes; i++) { - ActorCutsceneEntry entry(parent->GetRawData(), currentPtr); + CutsceneEntry entry(parent->GetRawData(), currentPtr); cutscenes.push_back(entry); currentPtr += 16; @@ -55,7 +55,7 @@ void SetActorCutsceneList::DeclareReferences(const std::string& prefix) std::string SetActorCutsceneList::GetBodySourceCode() const { std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorCutscene", listName); + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneEntry", listName); return StringHelper::Sprintf("SCENE_CMD_ACTOR_CUTSCENE_LIST(%i, %s)", cutscenes.size(), listName.c_str()); } @@ -70,25 +70,34 @@ RoomCommand SetActorCutsceneList::GetRoomCommand() const return RoomCommand::SetActorCutsceneList; } -ActorCutsceneEntry::ActorCutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) +CutsceneEntry::CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) : priority(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)), length(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)), - unk4(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), - unk6(BitConverter::ToInt16BE(rawData, rawDataIndex + 6)), - additionalCutscene(BitConverter::ToInt16BE(rawData, rawDataIndex + 8)), - sound(rawData[rawDataIndex + 0xA]), unkB(rawData[rawDataIndex + 0xB]), - unkC(BitConverter::ToInt16BE(rawData, rawDataIndex + 0xC)), unkE(rawData[rawDataIndex + 0xE]), - letterboxSize(rawData[rawDataIndex + 0xF]) + csCamId(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), + scriptIndex(BitConverter::ToInt16BE(rawData, rawDataIndex + 6)), + additionalCsId(BitConverter::ToInt16BE(rawData, rawDataIndex + 8)), + endSfx(rawData[rawDataIndex + 0xA]), customValue(rawData[rawDataIndex + 0xB]), + hudVisibility(BitConverter::ToInt16BE(rawData, rawDataIndex + 0xC)), + endCam(rawData[rawDataIndex + 0xE]), letterboxSize(rawData[rawDataIndex + 0xF]) { } -std::string ActorCutsceneEntry::GetBodySourceCode() const +std::string CutsceneEntry::GetBodySourceCode() const { - return StringHelper::Sprintf("%i, %i, %i, %i, %i, %i, %i, %i, %i, %i", priority, length, unk4, - unk6, additionalCutscene, sound, unkB, unkC, unkE, letterboxSize); + EnumData* enumData = &Globals::Instance->cfg.enumData; + + if (enumData->endSfx.find(endSfx) != enumData->endSfx.end()) + return StringHelper::Sprintf("%i, %i, %i, %i, %i, %s, %i, %i, %i, %i", priority, length, + csCamId, scriptIndex, additionalCsId, + enumData->endSfx[endSfx].c_str(), customValue, hudVisibility, + endCam, letterboxSize); + else + return StringHelper::Sprintf("%i, %i, %i, %i, %i, %i, %i, %i, %i, %i", priority, length, + csCamId, scriptIndex, additionalCsId, endSfx, customValue, + hudVisibility, endCam, letterboxSize); } -std::string ActorCutsceneEntry::GetSourceTypeName() const +std::string CutsceneEntry::GetSourceTypeName() const { - return "ActorCutscene"; + return "CutsceneEntry"; } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutsceneEntryList.h similarity index 66% rename from tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.h rename to tools/ZAPD/ZAPD/ZRoom/Commands/SetCutsceneEntryList.h index 8fd48e425c..6ba6c23abc 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutsceneEntryList.h @@ -2,22 +2,22 @@ #include "ZRoom/ZRoomCommand.h" -class ActorCutsceneEntry +class CutsceneEntry { protected: int16_t priority; int16_t length; - int16_t unk4; - int16_t unk6; - int16_t additionalCutscene; - uint8_t sound; - uint8_t unkB; - int16_t unkC; - uint8_t unkE; + int16_t csCamId; + int16_t scriptIndex; + int16_t additionalCsId; + uint8_t endSfx; + uint8_t customValue; + int16_t hudVisibility; + uint8_t endCam; uint8_t letterboxSize; public: - ActorCutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); + CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); std::string GetBodySourceCode() const; std::string GetSourceTypeName() const; @@ -26,7 +26,7 @@ public: class SetActorCutsceneList : public ZRoomCommand { public: - std::vector cutscenes; + std::vector cutscenes; SetActorCutsceneList(ZFile* nParent); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp index 51df68ca1a..d2a1c19561 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp @@ -23,7 +23,7 @@ void SetCutscenes::ParseRawData() cutsceneEntries.reserve(numCutscenes); for (uint8_t i = 0; i < numCutscenes; i++) { - CutsceneEntry entry(parent->GetRawData(), currentPtr); + CutsceneScriptEntry entry(parent->GetRawData(), currentPtr); cutsceneEntries.push_back(entry); currentPtr += 8; } @@ -32,6 +32,7 @@ void SetCutscenes::ParseRawData() void SetCutscenes::DeclareReferences(const std::string& prefix) { + EnumData* enumData = &Globals::Instance->cfg.enumData; std::string varPrefix = name; if (varPrefix == "") varPrefix = prefix; @@ -62,10 +63,14 @@ void SetCutscenes::DeclareReferences(const std::string& prefix) Globals::Instance->GetSegmentedPtrName(entry.segmentPtr, parent, "CutsceneData", csName); - declaration += - StringHelper::Sprintf(" { %s, 0x%04X, 0x%02X, 0x%02X },", csName.c_str(), - entry.exit, entry.entrance, entry.flag); - + if (enumData->spawnFlag.find(entry.flag) != enumData->spawnFlag.end()) + declaration += StringHelper::Sprintf(" { %s, 0x%04X, 0x%02X, %s },", + csName.c_str(), entry.exit, entry.entrance, + enumData->spawnFlag[entry.flag].c_str()); + else + declaration += + StringHelper::Sprintf(" { %s, 0x%04X, 0x%02X, 0x%02X },", csName.c_str(), + entry.exit, entry.entrance, entry.flag); if (i + 1 < numCutscenes) declaration += "\n"; @@ -73,8 +78,8 @@ void SetCutscenes::DeclareReferences(const std::string& prefix) } parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, - cutsceneEntries.size() * 8, "CutsceneEntry", - StringHelper::Sprintf("%sCutsceneEntryList_%06X", + cutsceneEntries.size() * 8, "CutsceneScriptEntry", + StringHelper::Sprintf("%sCutsceneScriptEntryList_%06X", zRoom->GetName().c_str(), segmentOffset), cutsceneEntries.size(), declaration); } @@ -102,8 +107,8 @@ std::string SetCutscenes::GetBodySourceCode() const if (Globals::Instance->game == ZGame::MM_RETAIL) { - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneEntry", listName); - return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes, + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneScriptEntry", listName); + return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_SCRIPT_LIST(%i, %s)", numCutscenes, listName.c_str()); } @@ -121,7 +126,7 @@ RoomCommand SetCutscenes::GetRoomCommand() const return RoomCommand::SetCutscenes; } -CutsceneEntry::CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) +CutsceneScriptEntry::CutsceneScriptEntry(const std::vector& rawData, uint32_t rawDataIndex) : segmentPtr(BitConverter::ToInt32BE(rawData, rawDataIndex + 0)), exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]), flag(rawData[rawDataIndex + 7]) diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h index 81a622c5b3..e6d979d0f6 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h @@ -3,10 +3,10 @@ #include "ZCutscene.h" #include "ZRoom/ZRoomCommand.h" -class CutsceneEntry +class CutsceneScriptEntry { public: - CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); + CutsceneScriptEntry(const std::vector& rawData, uint32_t rawDataIndex); segptr_t segmentPtr; uint16_t exit; @@ -17,8 +17,8 @@ public: class SetCutscenes : public ZRoomCommand { public: - std::vector cutsceneEntries; // (MM Only) - uint8_t numCutscenes; // (MM Only) + std::vector cutsceneEntries; // (MM Only) + uint8_t numCutscenes; // (MM Only) SetCutscenes(ZFile* nParent); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp index 79c87babfb..3ffba0ff12 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp @@ -30,7 +30,7 @@ void SetEntranceList::ParseRawDataLate() entrances.reserve(numEntrances); for (uint32_t i = 0; i < numEntrances; i++) { - EntranceEntry entry(parent->GetRawData(), currentPtr); + Spawn entry(parent->GetRawData(), currentPtr); entrances.push_back(entry); currentPtr += 2; @@ -55,16 +55,25 @@ void SetEntranceList::DeclareReferencesLate([[maybe_unused]] const std::string& std::string varName = StringHelper::Sprintf("%sEntranceList0x%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, - entrances.size() * 2, "EntranceEntry", varName, - entrances.size(), declaration); + + if (Globals::Instance->game != ZGame::MM_RETAIL) + parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, + entrances.size() * 2, "Spawn", varName, entrances.size(), + declaration); + else + parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, + entrances.size() * 2, "EntranceEntry", varName, + entrances.size(), declaration); } } std::string SetEntranceList::GetBodySourceCode() const { std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "EntranceEntry", listName); + if (Globals::Instance->game != ZGame::MM_RETAIL) + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "Spawn", listName); + else + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "EntranceEntry", listName); return StringHelper::Sprintf("SCENE_CMD_ENTRANCE_LIST(%s)", listName.c_str()); } @@ -78,13 +87,13 @@ RoomCommand SetEntranceList::GetRoomCommand() const return RoomCommand::SetEntranceList; } -EntranceEntry::EntranceEntry(const std::vector& rawData, uint32_t rawDataIndex) +Spawn::Spawn(const std::vector& rawData, uint32_t rawDataIndex) { startPositionIndex = rawData.at(rawDataIndex + 0); roomToLoad = rawData.at(rawDataIndex + 1); } -std::string EntranceEntry::GetBodySourceCode() const +std::string Spawn::GetBodySourceCode() const { return StringHelper::Sprintf("0x%02X, 0x%02X", startPositionIndex, roomToLoad); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.h index e13e9a8ce6..832232e06b 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.h @@ -2,13 +2,13 @@ #include "ZRoom/ZRoomCommand.h" -class EntranceEntry +class Spawn { public: uint8_t startPositionIndex; uint8_t roomToLoad; - EntranceEntry(const std::vector& rawData, uint32_t rawDataIndex); + Spawn(const std::vector& rawData, uint32_t rawDataIndex); std::string GetBodySourceCode() const; }; @@ -16,7 +16,7 @@ public: class SetEntranceList : public ZRoomCommand { public: - std::vector entrances; + std::vector entrances; SetEntranceList(ZFile* nParent); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp index ba5785cfcb..eaf01cd4c4 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp @@ -34,18 +34,28 @@ void SetLightingSettings::DeclareReferences(const std::string& prefix) declaration += "\n"; } - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, - settings.size() * settings.front().GetRawDataSize(), "LightSettings", - StringHelper::Sprintf("%sLightSettings0x%06X", prefix.c_str(), segmentOffset), - settings.size(), declaration); + if (Globals::Instance->game != ZGame::MM_RETAIL) + parent->AddDeclarationArray( + segmentOffset, DeclarationAlignment::Align4, + settings.size() * settings.front().GetRawDataSize(), "EnvLightSettings", + StringHelper::Sprintf("%sLightSettings0x%06X", prefix.c_str(), segmentOffset), + settings.size(), declaration); + else + parent->AddDeclarationArray( + segmentOffset, DeclarationAlignment::Align4, + settings.size() * settings.front().GetRawDataSize(), "LightSettings", + StringHelper::Sprintf("%sLightSettings0x%06X", prefix.c_str(), segmentOffset), + settings.size(), declaration); } } std::string SetLightingSettings::GetBodySourceCode() const { std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightSettings", listName); + if (Globals::Instance->game != ZGame::MM_RETAIL) + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "EnvLightSettings", listName); + else + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightSettings", listName); return StringHelper::Sprintf("SCENE_CMD_ENV_LIGHT_SETTINGS(%i, %s)", settings.size(), listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp index 40e0bddf25..9a4d30d516 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp @@ -24,7 +24,7 @@ void SetMesh::ParseRawData() switch (meshHeaderType) { case 0: - polyType = std::make_shared(parent, segmentOffset, zRoom); + polyType = std::make_shared(parent, segmentOffset, zRoom); break; case 1: @@ -32,7 +32,7 @@ void SetMesh::ParseRawData() break; case 2: - polyType = std::make_shared(parent, segmentOffset, zRoom); + polyType = std::make_shared(parent, segmentOffset, zRoom); break; default: @@ -79,7 +79,7 @@ std::string SetMesh::GetBodySourceCode() const { std::string list; Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "", list); - return StringHelper::Sprintf("SCENE_CMD_MESH(%s)", list.c_str()); + return StringHelper::Sprintf("SCENE_CMD_ROOM_SHAPE(%s)", list.c_str()); } std::string SetMesh::GetCommandCName() const @@ -92,11 +92,11 @@ RoomCommand SetMesh::GetRoomCommand() const return RoomCommand::SetMesh; } -PolygonDlist::PolygonDlist(ZFile* nParent) : ZResource(nParent) +RoomShapeDListsEntry::RoomShapeDListsEntry(ZFile* nParent) : ZResource(nParent) { } -void PolygonDlist::ParseRawData() +void RoomShapeDListsEntry::ParseRawData() { const auto& rawData = parent->GetRawData(); switch (polyType) @@ -118,13 +118,13 @@ void PolygonDlist::ParseRawData() } } -void PolygonDlist::DeclareReferences(const std::string& prefix) +void RoomShapeDListsEntry::DeclareReferences(const std::string& prefix) { opaDList = MakeDlist(opa, prefix); xluDList = MakeDlist(xlu, prefix); } -std::string PolygonDlist::GetBodySourceCode() const +std::string RoomShapeDListsEntry::GetBodySourceCode() const { std::string bodyStr; std::string opaStr; @@ -142,7 +142,7 @@ std::string PolygonDlist::GetBodySourceCode() const return bodyStr; } -void PolygonDlist::GetSourceOutputCode(const std::string& prefix) +void RoomShapeDListsEntry::GetSourceOutputCode(const std::string& prefix) { std::string bodyStr = StringHelper::Sprintf("\n\t%s\n", GetBodySourceCode().c_str()); @@ -154,25 +154,25 @@ void PolygonDlist::GetSourceOutputCode(const std::string& prefix) decl->declBody = bodyStr; } -std::string PolygonDlist::GetSourceTypeName() const +std::string RoomShapeDListsEntry::GetSourceTypeName() const { switch (polyType) { case 2: - return "PolygonDlist2"; + return "RoomShapeCullableEntry"; default: - return "PolygonDlist"; + return "RoomShapeDListsEntry"; } } -ZResourceType PolygonDlist::GetResourceType() const +ZResourceType RoomShapeDListsEntry::GetResourceType() const { // TODO return ZResourceType::Error; } -size_t PolygonDlist::GetRawDataSize() const +size_t RoomShapeDListsEntry::GetRawDataSize() const { switch (polyType) { @@ -184,12 +184,13 @@ size_t PolygonDlist::GetRawDataSize() const } } -void PolygonDlist::SetPolyType(uint8_t nPolyType) +void RoomShapeDListsEntry::SetPolyType(uint8_t nPolyType) { polyType = nPolyType; } -ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, [[maybe_unused]] const std::string& prefix) +ZDisplayList* RoomShapeDListsEntry::MakeDlist(segptr_t ptr, + [[maybe_unused]] const std::string& prefix) { if (ptr == 0) { @@ -210,15 +211,15 @@ ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, [[maybe_unused]] const std:: return dlist; } -/* BgImage */ +/* RoomShapeImageMultiBgEntry */ -BgImage::BgImage(ZFile* nParent) : ZResource(nParent) +RoomShapeImageMultiBgEntry::RoomShapeImageMultiBgEntry(ZFile* nParent) : ZResource(nParent) { } -BgImage::BgImage(bool nIsSubStruct, const std::string& prefix, uint32_t nRawDataIndex, - ZFile* nParent) - : BgImage(nParent) +RoomShapeImageMultiBgEntry::RoomShapeImageMultiBgEntry(bool nIsSubStruct, const std::string& prefix, + uint32_t nRawDataIndex, ZFile* nParent) + : RoomShapeImageMultiBgEntry(nParent) { rawDataIndex = nRawDataIndex; parent = nParent; @@ -230,7 +231,7 @@ BgImage::BgImage(bool nIsSubStruct, const std::string& prefix, uint32_t nRawData sourceBackground = MakeBackground(source, prefix); } -void BgImage::ParseRawData() +void RoomShapeImageMultiBgEntry::ParseRawData() { size_t pad = 0x00; const auto& rawData = parent->GetRawData(); @@ -252,7 +253,7 @@ void BgImage::ParseRawData() tlutCount = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x14); } -ZBackground* BgImage::MakeBackground(segptr_t ptr, const std::string& prefix) +ZBackground* RoomShapeImageMultiBgEntry::MakeBackground(segptr_t ptr, const std::string& prefix) { if (ptr == 0) return nullptr; @@ -272,12 +273,12 @@ ZBackground* BgImage::MakeBackground(segptr_t ptr, const std::string& prefix) return background; } -size_t BgImage::GetRawDataSize() const +size_t RoomShapeImageMultiBgEntry::GetRawDataSize() const { return 0x1C; } -std::string BgImage::GetBodySourceCode() const +std::string RoomShapeImageMultiBgEntry::GetBodySourceCode() const { std::string bodyStr = " "; if (!isSubStruct) @@ -340,12 +341,12 @@ std::string BgImage::GetBodySourceCode() const return bodyStr; } -std::string BgImage::GetSourceTypeName() const +std::string RoomShapeImageMultiBgEntry::GetSourceTypeName() const { - return "BgImage"; + return "RoomShapeImageMultiBgEntry"; } -ZResourceType BgImage::GetResourceType() const +ZResourceType RoomShapeImageMultiBgEntry::GetResourceType() const { // TODO return ZResourceType::Error; @@ -380,13 +381,13 @@ std::string PolygonTypeBase::GetSourceTypeName() const switch (type) { case 2: - return "PolygonType2"; + return "RoomShapeCullable"; case 1: return "PolygonType1"; default: - return "PolygonType0"; + return "RoomShapeNormal"; } } @@ -416,7 +417,7 @@ void PolygonType1::ParseRawData() if (dlist != 0) { - PolygonDlist polyGfxList(parent); + RoomShapeDListsEntry polyGfxList(parent); polyGfxList.zRoom = zRoom; polyGfxList.SetPolyType(type); polyGfxList.ExtractFromFile(Seg2Filespace(dlist, parent->baseAddress)); @@ -434,7 +435,7 @@ void PolygonType1::DeclareReferences(const std::string& prefix) switch (format) { case 1: - single = BgImage(true, prefix, rawDataIndex + 0x08, parent); + single = RoomShapeImageMultiBgEntry(true, prefix, rawDataIndex + 0x08, parent); break; case 2: @@ -446,7 +447,7 @@ void PolygonType1::DeclareReferences(const std::string& prefix) multiList.reserve(count); for (size_t i = 0; i < count; ++i) { - BgImage bg(false, prefix, auxPtr, parent); + RoomShapeImageMultiBgEntry bg(false, prefix, auxPtr, parent); multiList.push_back(bg); auxPtr += bg.GetRawDataSize(); bgImageArrayBody += bg.GetBodySourceCode(); @@ -507,7 +508,7 @@ std::string PolygonType1::GetBodySourceCode() const bodyStr += single.GetBodySourceCode(); break; case 2: - Globals::Instance->GetSegmentedPtrName(list, parent, "BgImage", listStr); + Globals::Instance->GetSegmentedPtrName(list, parent, "RoomShapeImageMultiBgEntry", listStr); bodyStr += StringHelper::Sprintf(" %i, %s, \n", count, listStr.c_str()); break; @@ -523,21 +524,21 @@ std::string PolygonType1::GetSourceTypeName() const switch (format) { case 1: - return "MeshHeader1Single"; + return "RoomShapeImageSingle"; case 2: - return "MeshHeader1Multi"; + return "RoomShapeImageMulti"; } return "ERROR"; // return "PolygonType1"; } -PolygonType2::PolygonType2(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom) +RoomShapeCullable::RoomShapeCullable(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom) : PolygonTypeBase(nParent, nRawDataIndex, nRoom) { } -void PolygonType2::ParseRawData() +void RoomShapeCullable::ParseRawData() { const auto& rawData = parent->GetRawData(); @@ -551,7 +552,7 @@ void PolygonType2::ParseRawData() polyDLists.reserve(num); for (size_t i = 0; i < num; i++) { - PolygonDlist entry(parent); + RoomShapeDListsEntry entry(parent); entry.zRoom = zRoom; entry.SetPolyType(type); entry.ExtractFromFile(currentPtr); @@ -561,7 +562,7 @@ void PolygonType2::ParseRawData() } } -void PolygonType2::DeclareReferences(const std::string& prefix) +void RoomShapeCullable::DeclareReferences(const std::string& prefix) { if (num > 0) { @@ -593,7 +594,7 @@ void PolygonType2::DeclareReferences(const std::string& prefix) "0x01000000"); } -std::string PolygonType2::GetBodySourceCode() const +std::string RoomShapeCullable::GetBodySourceCode() const { std::string listName; Globals::Instance->GetSegmentedPtrName(start, parent, "", listName); @@ -605,12 +606,12 @@ std::string PolygonType2::GetBodySourceCode() const return body; } -size_t PolygonType2::GetRawDataSize() const +size_t RoomShapeCullable::GetRawDataSize() const { return 0x0C; } -DeclarationAlignment PolygonType2::GetDeclarationAlignment() const +DeclarationAlignment RoomShapeCullable::GetDeclarationAlignment() const { return DeclarationAlignment::Align4; } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h index 9d9037417b..c0f15da9d3 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h @@ -5,7 +5,7 @@ #include "ZDisplayList.h" #include "ZRoom/ZRoomCommand.h" -class PolygonDlist : public ZResource +class RoomShapeDListsEntry : public ZResource { public: ZRoom* zRoom; @@ -21,7 +21,7 @@ public: ZDisplayList* opaDList = nullptr; // Gfx* ZDisplayList* xluDList = nullptr; // Gfx* - PolygonDlist(ZFile* nParent); + RoomShapeDListsEntry(ZFile* nParent); void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; @@ -41,7 +41,7 @@ protected: ZDisplayList* MakeDlist(segptr_t ptr, const std::string& prefix); }; -class BgImage : public ZResource +class RoomShapeImageMultiBgEntry : public ZResource { public: uint16_t unk_00; @@ -60,8 +60,9 @@ public: bool isSubStruct; - BgImage(ZFile* nParent); - BgImage(bool nIsSubStruct, const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent); + RoomShapeImageMultiBgEntry(ZFile* nParent); + RoomShapeImageMultiBgEntry(bool nIsSubStruct, const std::string& prefix, uint32_t nRawDataIndex, + ZFile* nParent); void ParseRawData() override; @@ -80,7 +81,7 @@ class PolygonTypeBase : public ZResource { public: uint8_t type; - std::vector polyDLists; + std::vector polyDLists; PolygonTypeBase(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); @@ -100,12 +101,12 @@ public: segptr_t dlist; // single - BgImage single; + RoomShapeImageMultiBgEntry single; // multi uint8_t count; - segptr_t list; // BgImage* - std::vector multiList; + segptr_t list; // RoomShapeImageMultiBgEntry* + std::vector multiList; PolygonType1(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); @@ -119,14 +120,14 @@ public: size_t GetRawDataSize() const override; }; -class PolygonType2 : public PolygonTypeBase +class RoomShapeCullable : public PolygonTypeBase { public: uint8_t num; segptr_t start; segptr_t end; - PolygonType2(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); + RoomShapeCullable(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp index 696a3de014..34edf5ae63 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp @@ -17,8 +17,14 @@ void SetSpecialObjects::ParseRawData() std::string SetSpecialObjects::GetBodySourceCode() const { + EnumData* enumData = &Globals::Instance->cfg.enumData; std::string objectName = ZNames::GetObjectName(globalObject); + if (enumData->naviQuestHintType.find(elfMessage) != enumData->naviQuestHintType.end()) + return StringHelper::Sprintf("SCENE_CMD_SPECIAL_FILES(%s, %s)", + enumData->naviQuestHintType[elfMessage].c_str(), + objectName.c_str()); + return StringHelper::Sprintf("SCENE_CMD_SPECIAL_FILES(0x%02X, %s)", elfMessage, objectName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetWorldMapVisited.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetWorldMapVisited.cpp index d20e4a3e29..fa28547e62 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetWorldMapVisited.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetWorldMapVisited.cpp @@ -1,6 +1,7 @@ #include "SetWorldMapVisited.h" #include "Utils/StringHelper.h" +#include "Globals.h" SetWorldMapVisited::SetWorldMapVisited(ZFile* nParent) : ZRoomCommand(nParent) { @@ -8,7 +9,10 @@ SetWorldMapVisited::SetWorldMapVisited(ZFile* nParent) : ZRoomCommand(nParent) std::string SetWorldMapVisited::GetBodySourceCode() const { - return "SCENE_CMD_MISC_SETTINGS()"; + if (Globals::Instance->game == ZGame::MM_RETAIL) + return "SCENE_CMD_SET_REGION_VISITED()"; + else + return "SCENE_CMD_MISC_SETTINGS()"; } std::string SetWorldMapVisited::GetCommandCName() const diff --git a/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp b/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp index a28ea7b909..a291c36feb 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp @@ -6,7 +6,7 @@ #include #include "Commands/EndMarker.h" -#include "Commands/SetActorCutsceneList.h" +#include "Commands/SetCutsceneEntryList.h" #include "Commands/SetActorList.h" #include "Commands/SetAlternateHeaders.h" #include "Commands/SetAnimatedMaterialList.h" @@ -336,7 +336,7 @@ std::string ZRoom::GetDefaultName(const std::string& prefix) const */ void ZRoom::SyotesRoomFix() { - PolygonType2 poly(parent, 0, this); + RoomShapeCullable poly(parent, 0, this); poly.ParseRawData(); poly.DeclareReferences(GetName()); diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index ca680c5f5e..86b578639f 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -189,7 +189,7 @@ std::string ZSkeleton::GetSourceTypeName() const case ZSkeletonType::Flex: return "FlexSkeletonHeader"; case ZSkeletonType::Curve: - return "SkelCurveLimbList"; + return "CurveSkeletonHeader"; } return "SkeletonHeader"; diff --git a/tools/ZAPD/ZAPDUtils/Utils/Directory.h b/tools/ZAPD/ZAPDUtils/Utils/Directory.h index 2e782624ed..d150f17727 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/Directory.h +++ b/tools/ZAPD/ZAPDUtils/Utils/Directory.h @@ -21,12 +21,21 @@ class Directory { public: #ifdef USE_BOOST_FS - static std::string GetCurrentDirectory() { return fs::current_path().string(); } + static std::string GetCurrentDirectory() + { + return fs::current_path().string(); + } #else - static std::string GetCurrentDirectory() { return fs::current_path().u8string(); } + static std::string GetCurrentDirectory() + { + return fs::current_path().u8string(); + } #endif - static bool Exists(const fs::path& path) { return fs::exists(path); } + static bool Exists(const fs::path& path) + { + return fs::exists(path); + } static void CreateDirectory(const std::string& path) { diff --git a/tools/ZAPDConfigs/MM/Config.xml b/tools/ZAPDConfigs/MM/Config.xml index 02656c7df7..be2c03dc32 100644 --- a/tools/ZAPDConfigs/MM/Config.xml +++ b/tools/ZAPDConfigs/MM/Config.xml @@ -2,7 +2,7 @@ - + diff --git a/tools/ZAPDConfigs/MM/EnumData.xml b/tools/ZAPDConfigs/MM/EnumData.xml new file mode 100644 index 0000000000..2ade5b3463 --- /dev/null +++ b/tools/ZAPDConfigs/MM/EnumData.xml @@ -0,0 +1,718 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +