summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2022-01-05 22:54:05 -0500
committerNicholas Estelami <NEstelami@users.noreply.github.com>2022-01-05 22:54:05 -0500
commite6469d7028bbb48a4ac78e042269561c02f42d4a (patch)
treee1fe4b86f7ac20ee7f8e731303aa56561fbabcbd
parentbe23fba68ea9cfcc0a6ec5db8928d26482020aae (diff)
Lots of exporters
-rw-r--r--OTRExporter/AnimationExporter.cpp70
-rw-r--r--OTRExporter/AnimationExporter.h13
-rw-r--r--OTRExporter/ArrayExporter.h3
-rw-r--r--OTRExporter/BackgroundExporter.h3
-rw-r--r--OTRExporter/CollisionExporter.cpp8
-rw-r--r--OTRExporter/CollisionExporter.h3
-rw-r--r--OTRExporter/CutsceneExporter.cpp278
-rw-r--r--OTRExporter/CutsceneExporter.h10
-rw-r--r--OTRExporter/DisplayListExporter.cpp66
-rw-r--r--OTRExporter/DisplayListExporter.h3
-rw-r--r--OTRExporter/Main.cpp22
-rw-r--r--OTRExporter/OTRExporter.cpp9
-rw-r--r--OTRExporter/OTRExporter.h12
-rw-r--r--OTRExporter/OTRExporter.vcxproj9
-rw-r--r--OTRExporter/OTRExporter.vcxproj.filters27
-rw-r--r--OTRExporter/OTRSkeletonExporter.cpp5
-rw-r--r--OTRExporter/OTRSkeletonExporter.h3
-rw-r--r--OTRExporter/OTRSkeletonLimbExporter.cpp5
-rw-r--r--OTRExporter/OTRSkeletonLimbExporter.h3
-rw-r--r--OTRExporter/PlayerAnimationExporter.cpp5
-rw-r--r--OTRExporter/PlayerAnimationExporter.h3
-rw-r--r--OTRExporter/RoomExporter.cpp126
-rw-r--r--OTRExporter/RoomExporter.h3
-rw-r--r--OTRExporter/TextureExporter.h3
-rw-r--r--OTRExporter/VtxExporter.cpp7
-rw-r--r--OTRExporter/VtxExporter.h3
-rw-r--r--OTRExporter/command_macros_base.h32
-rw-r--r--OTRExporter/z64cutscene.h290
-rw-r--r--OTRExporter/z64cutscene_commands.h448
29 files changed, 1388 insertions, 84 deletions
diff --git a/OTRExporter/AnimationExporter.cpp b/OTRExporter/AnimationExporter.cpp
new file mode 100644
index 0000000..eed3f6d
--- /dev/null
+++ b/OTRExporter/AnimationExporter.cpp
@@ -0,0 +1,70 @@
+#include "AnimationExporter.h"
+#include <OTRAnimation.h>
+
+void OTRExporter_Animation::Save(ZResource* res, const fs::path outPath, BinaryWriter* writer)
+{
+ ZAnimation* anim = (ZAnimation*)res;
+
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRAnimation);
+
+ ZNormalAnimation* normalAnim = dynamic_cast<ZNormalAnimation*>(anim);
+ ZCurveAnimation* curveAnim = dynamic_cast<ZCurveAnimation*>(anim);
+ ZLinkAnimation* linkAnim = dynamic_cast<ZLinkAnimation*>(anim);
+ if (linkAnim != nullptr)
+ {
+ writer->Write((uint32_t)OtrLib::AnimationType::Link);
+ writer->Write((uint16_t)linkAnim->frameCount);
+ writer->Write((uint32_t)linkAnim->segmentAddress);
+ }
+ else if (curveAnim != nullptr)
+ {
+ writer->Write((uint32_t)OtrLib::AnimationType::Curve);
+ writer->Write((uint16_t)curveAnim->frameCount);
+
+ writer->Write((uint32_t)curveAnim->refIndexArr.size());
+
+ for (auto val : curveAnim->refIndexArr)
+ writer->Write(val);
+
+ writer->Write((uint32_t)curveAnim->transformDataArr.size());
+
+ for (auto val : curveAnim->transformDataArr)
+ {
+ writer->Write(val.unk_00);
+ writer->Write(val.unk_02);
+ writer->Write(val.unk_04);
+ writer->Write(val.unk_06);
+ writer->Write(val.unk_08);
+ }
+
+ writer->Write((uint32_t)curveAnim->copyValuesArr.size());
+
+ for (auto val : curveAnim->copyValuesArr)
+ writer->Write(val);
+ }
+ else if (normalAnim != nullptr)
+ {
+ writer->Write((uint32_t)OtrLib::AnimationType::Normal);
+ writer->Write((uint16_t)normalAnim->frameCount);
+
+ writer->Write((uint32_t)normalAnim->rotationValues.size());
+
+ for (int i = 0; i < normalAnim->rotationValues.size(); i++)
+ writer->Write(normalAnim->rotationValues[i]);
+
+ writer->Write((uint32_t)normalAnim->rotationIndices.size());
+
+ for (int i = 0; i < normalAnim->rotationIndices.size(); i++)
+ {
+ writer->Write(normalAnim->rotationIndices[i].x);
+ writer->Write(normalAnim->rotationIndices[i].y);
+ writer->Write(normalAnim->rotationIndices[i].z);
+ }
+
+ writer->Write(normalAnim->limit);
+ }
+ else
+ {
+ writer->Write((uint32_t)OtrLib::AnimationType::Legacy);
+ }
+}
diff --git a/OTRExporter/AnimationExporter.h b/OTRExporter/AnimationExporter.h
new file mode 100644
index 0000000..66fad50
--- /dev/null
+++ b/OTRExporter/AnimationExporter.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "ZResource.h"
+#include "ZTexture.h"
+#include "ZAnimation.h"
+#include "OTRExporter.h"
+#include <Utils/BinaryWriter.h>
+
+class OTRExporter_Animation : public OTRExporter
+{
+public:
+ virtual void Save(ZResource* res, const fs::path outPath, BinaryWriter* writer) override;
+}; \ No newline at end of file
diff --git a/OTRExporter/ArrayExporter.h b/OTRExporter/ArrayExporter.h
index 1ac9974..bb2c067 100644
--- a/OTRExporter/ArrayExporter.h
+++ b/OTRExporter/ArrayExporter.h
@@ -1,9 +1,10 @@
#pragma once
#include "ZResource.h"
#include "ZArray.h"
+#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
-class OTRExporter_Array : public ZResourceExporter
+class OTRExporter_Array : public OTRExporter
{
public:
virtual void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override;
diff --git a/OTRExporter/BackgroundExporter.h b/OTRExporter/BackgroundExporter.h
index 7532540..d631f46 100644
--- a/OTRExporter/BackgroundExporter.h
+++ b/OTRExporter/BackgroundExporter.h
@@ -2,9 +2,10 @@
#include "ZResource.h"
#include "ZBackground.h"
+#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
-class OTRExporter_Background : public ZResourceExporter
+class OTRExporter_Background : public OTRExporter
{
public:
virtual void Save(ZResource* res, const fs::path outPath, BinaryWriter* writer) override;
diff --git a/OTRExporter/CollisionExporter.cpp b/OTRExporter/CollisionExporter.cpp
index 6531264..7c567ed 100644
--- a/OTRExporter/CollisionExporter.cpp
+++ b/OTRExporter/CollisionExporter.cpp
@@ -5,11 +5,8 @@ void OTRExporter_Collision::Save(ZResource* res, fs::path outPath, BinaryWriter*
{
ZCollisionHeader* col = (ZCollisionHeader*)res;
- writer->Write((uint8_t)Endianess::Little);
- writer->Write((uint32_t)OtrLib::ResourceType::OTRCollisionHeader);
- writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
- writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
-
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRCollisionHeader);
+
writer->Write(col->absMinX);
writer->Write(col->absMinY);
writer->Write(col->absMinZ);
@@ -77,7 +74,6 @@ void OTRExporter_Collision::Save(ZResource* res, fs::path outPath, BinaryWriter*
{
writer->Write(waterBox.xMin);
writer->Write(waterBox.ySurface);
- writer->Write(waterBox.xMin);
writer->Write(waterBox.zMin);
writer->Write(waterBox.xLength);
writer->Write(waterBox.zLength);
diff --git a/OTRExporter/CollisionExporter.h b/OTRExporter/CollisionExporter.h
index e2370c8..c3a2a0f 100644
--- a/OTRExporter/CollisionExporter.h
+++ b/OTRExporter/CollisionExporter.h
@@ -2,8 +2,9 @@
#include "ZResource.h"
#include "ZCollision.h"
+#include "OTRExporter.h"
-class OTRExporter_Collision : public ZResourceExporter
+class OTRExporter_Collision : public OTRExporter
{
public:
virtual void Save(ZResource* res, const fs::path outPath, BinaryWriter* writer) override;
diff --git a/OTRExporter/CutsceneExporter.cpp b/OTRExporter/CutsceneExporter.cpp
new file mode 100644
index 0000000..63e5775
--- /dev/null
+++ b/OTRExporter/CutsceneExporter.cpp
@@ -0,0 +1,278 @@
+#include "CutsceneExporter.h"
+#include <OTRResource.h>
+
+void OTRExporter_Cutscene::Save(ZResource* res, fs::path outPath, BinaryWriter* writer)
+{
+ ZCutscene* cs = (ZCutscene*)res;
+
+ writer->Write((uint8_t)Endianess::Little);
+ writer->Write((uint32_t)OtrLib::ResourceType::OTRCutscene);
+ writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
+ writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+
+ writer->Write(CS_BEGIN_CUTSCENE(cs->numCommands, cs->endFrame));
+
+ for (size_t i = 0; i < cs->commands.size(); i++)
+ {
+ switch ((CutsceneCommands)cs->commands[i]->commandID) {
+ case CutsceneCommands::SetCameraPos:
+ {
+ writer->Write(CS_CMD_CAM_EYE);
+ writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame));
+ writer->Write(CMD_HH(0x0000, ((CutsceneCommandSetCameraPos*)cs->commands[i])->endFrame));
+
+ for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame));
+ writer->Write(CMD_F(e->viewAngle));
+ writer->Write(CMD_HH(e->posX, e->posY));
+ writer->Write(CMD_HH(e->posZ, e->unused));
+ }
+ }
+ break;
+ case CutsceneCommands::SetCameraFocus:
+ {
+ writer->Write(CS_CMD_CAM_AT);
+ writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame));
+ writer->Write(CMD_HH(0x0000, ((CutsceneCommandSetCameraPos*)cs->commands[i])->endFrame));
+
+ for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame));
+ writer->Write(CMD_F(e->viewAngle));
+ writer->Write(CMD_HH(e->posX, e->posY));
+ writer->Write(CMD_HH(e->posZ, e->unused));
+ }
+ break;
+ }
+ case CutsceneCommands::SpecialAction:
+ {
+ writer->Write(CS_CMD_MISC);
+ writer->Write(CMD_W(((CutsceneCommandSpecialAction*)cs->commands[i])->entries.size()));
+ for (auto& e : ((CutsceneCommandSpecialAction*)cs->commands[i])->entries) //All in OOT seem to only have 1 entry
+ {
+ writer->Write(CMD_HH(e->base, e->startFrame));
+ writer->Write(CMD_HH(e->endFrame, e->unused0));
+ writer->Write(CMD_W(e->unused1));
+ writer->Write(CMD_W(e->unused2));
+ writer->Write(CMD_W(e->unused3));
+ writer->Write(CMD_W(e->unused4));
+ writer->Write(CMD_W(e->unused5));
+ writer->Write(CMD_W(e->unused6));
+ writer->Write(CMD_W(e->unused7));
+ writer->Write(CMD_W(e->unused8));
+ writer->Write(CMD_W(e->unused9));
+ writer->Write(CMD_W(e->unused10));
+ }
+ break;
+ }
+ case CutsceneCommands::SetLighting:
+ {
+ writer->Write(CS_CMD_SET_LIGHTING);
+ writer->Write(CMD_W(((CutsceneCommandEnvLighting*)cs->commands[i])->entries.size()));
+ for (auto& e : ((CutsceneCommandEnvLighting*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_HH(e->setting, e->startFrame));
+ writer->Write(CMD_HH(e->endFrame, e->unused0));
+ writer->Write(CMD_W(e->unused1));
+ writer->Write(CMD_W(e->unused2));
+ writer->Write(CMD_W(e->unused3));
+ writer->Write(CMD_W(e->unused4));
+ writer->Write(CMD_W(e->unused5));
+ writer->Write(CMD_W(e->unused6));
+ writer->Write(CMD_W(e->unused7));
+ writer->Write((uint32_t)0x0);
+ writer->Write((uint32_t)0x0);
+ writer->Write((uint32_t)0x0);
+ }
+ break;
+ }
+ case CutsceneCommands::SetCameraPosLink:
+ {
+ writer->Write(CS_CMD_CAM_EYE_REL_TO_PLAYER);
+ writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame));
+ writer->Write(CMD_HH(0x0000, ((CutsceneCommandSetCameraPos*)cs->commands[i])->endFrame));
+
+ for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame));
+ writer->Write(CMD_F(e->viewAngle));
+ writer->Write(CMD_HH(e->posX, e->posY));
+ writer->Write(CMD_HH(e->posZ, e->unused));
+ }
+ break;
+ }
+ case CutsceneCommands::SetCameraFocusLink:
+ {
+ writer->Write(CS_CMD_CAM_AT_REL_TO_PLAYER);
+ writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame));
+ writer->Write(CMD_HH(0x0000, ((CutsceneCommandSetCameraPos*)cs->commands[i])->endFrame));
+
+ for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame));
+ writer->Write(CMD_F(e->viewAngle));
+ writer->Write(CMD_HH(e->posX, e->posY));
+ writer->Write(CMD_HH(e->posZ, e->unused));
+ }
+ break;
+ }
+
+ case CutsceneCommands::Cmd07: // Not used in OOT
+ break;
+ case CutsceneCommands::Cmd08: // Not used in OOT
+ break;
+
+ case CutsceneCommands::Cmd09:
+ {
+ writer->Write(CS_CMD_09);
+ writer->Write(CMD_W(((CutsceneCommandUnknown9*)cs->commands[i])->entries.size()));
+
+ for (auto& e : ((CutsceneCommandUnknown9*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_HH(e->base, e->startFrame));
+ writer->Write(CMD_HBB(e->endFrame, e->unk2, e->unk3));
+ writer->Write(CMD_BBH(e->unk4, e->unused0, e->unused1));
+ }
+ break;
+ }
+
+ case CutsceneCommands::Textbox:
+ {
+ writer->Write(CS_CMD_TEXTBOX);
+ writer->Write(CMD_W(((CutsceneCommandTextbox*)cs->commands[i])->entries.size()));
+
+ for (auto& e : ((CutsceneCommandTextbox*)cs->commands[i])->entries)
+ {
+ if (e->base == 0xFFFF) // CS_TEXT_NONE
+ {
+ writer->Write(CMD_HH(0xFFFF, e->startFrame));
+ writer->Write(CMD_HH(e->endFrame, 0xFFFF));
+ writer->Write(CMD_HH(0xFFFF, 0xFFFF));
+ }
+ else // CS_TEXT_DISPLAY_TEXTBOX
+ {
+ writer->Write(CMD_HH(e->base, e->startFrame));
+ writer->Write(CMD_HH(e->endFrame, e->type));
+ writer->Write(CMD_HH(e->textID1, e->textID2));
+ }
+ }
+ break;
+ }
+ case CutsceneCommands::SetActorAction0:
+ 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:
+ {
+ // OTRTODO this one is weird
+ break;
+ }
+ case CutsceneCommands::SetSceneTransFX:
+ {
+ writer->Write(CS_CMD_SCENE_TRANS_FX);
+ writer->Write((uint32_t)1);
+ writer->Write(CMD_HH((((CutsceneCommandSceneTransFX*)cs->commands[i])->base), ((CutsceneCommandSceneTransFX*)cs->commands[i])->startFrame));
+ writer->Write(CMD_HH((((CutsceneCommandSceneTransFX*)cs->commands[i])->endFrame), ((CutsceneCommandSceneTransFX*)cs->commands[i])->endFrame));
+ break;
+ }
+ case CutsceneCommands::Nop: //Not used in OOT
+ break;
+ case CutsceneCommands::PlayBGM:
+ {
+ writer->Write(CS_CMD_PLAYBGM);
+ writer->Write(CMD_W(((CutsceneCommandPlayBGM*)cs->commands[i])->entries.size()));
+
+ for (auto& e : ((CutsceneCommandPlayBGM*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_HH(e->sequence, e->startFrame));
+ writer->Write(CMD_HH(e->endFrame, e->unknown0));
+ writer->Write(CMD_W(e->unknown2));
+ writer->Write(CMD_W(e->unknown3));
+ writer->Write(CMD_W(e->unknown4));
+ writer->Write(CMD_W(e->unknown5));
+ writer->Write(CMD_W(e->unknown6));
+ writer->Write(CMD_W(e->unknown7));
+ writer->Write((uint32_t)0);
+ writer->Write((uint32_t)0);
+ writer->Write((uint32_t)0);
+ }
+ break;
+ }
+ case CutsceneCommands::StopBGM:
+ {
+ writer->Write(CS_CMD_STOPBGM);
+ writer->Write(CMD_W(((CutsceneCommandStopBGM*)cs->commands[i])->entries.size()));
+
+ for (auto& e : ((CutsceneCommandStopBGM*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_HH(e->sequence, e->startFrame));
+ writer->Write(CMD_HH(e->endFrame, e->unknown0));
+ writer->Write(CMD_W(e->unknown2));
+ writer->Write(CMD_W(e->unknown3));
+ writer->Write(CMD_W(e->unknown4));
+ writer->Write(CMD_W(e->unknown5));
+ writer->Write(CMD_W(e->unknown6));
+ writer->Write(CMD_W(e->unknown7));
+ writer->Write((uint32_t)0);
+ writer->Write((uint32_t)0);
+ writer->Write((uint32_t)0);
+ }
+ break;
+ }
+ case CutsceneCommands::FadeBGM:
+ {
+ writer->Write(CS_CMD_FADEBGM);
+ writer->Write(CMD_W(((CutsceneCommandFadeBGM*)cs->commands[i])->entries.size()));
+
+ for (auto& e : ((CutsceneCommandFadeBGM*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_HH(e->base, e->startFrame));
+ writer->Write(CMD_HH(e->endFrame, e->unknown0));
+ writer->Write(CMD_W(e->unknown2));
+ writer->Write(CMD_W(e->unknown3));
+ writer->Write(CMD_W(e->unknown4));
+ writer->Write(CMD_W(e->unknown5));
+ writer->Write(CMD_W(e->unknown6));
+ writer->Write(CMD_W(e->unknown7));
+ writer->Write((uint32_t)0);
+ writer->Write((uint32_t)0);
+ writer->Write((uint32_t)0);
+ }
+ break;
+ }
+ case CutsceneCommands::SetTime:
+ {
+ writer->Write(CS_CMD_SETTIME);
+ writer->Write(CMD_W(((CutsceneCommandDayTime*)cs->commands[i])->entries.size()));
+
+ for (auto& e : ((CutsceneCommandDayTime*)cs->commands[i])->entries)
+ {
+ writer->Write(CMD_HH(e->base, e->startFrame));
+ writer->Write(CMD_HBB(e->endFrame, e->hour, e->minute));
+ writer->Write(CMD_W(e->unused));
+ }
+ break;
+ }
+ case CutsceneCommands::Terminator:
+ {
+ writer->Write(CS_CMD_TERMINATOR);
+ writer->Write((uint32_t)1);
+ writer->Write(CMD_HH(((CutsceneCommandTerminator*)cs->commands[i])->base, ((CutsceneCommandTerminator*)cs->commands[i])->startFrame));
+ writer->Write(CMD_HH(((CutsceneCommandTerminator*)cs->commands[i])->endFrame, ((CutsceneCommandTerminator*)cs->commands[i])->endFrame));
+ break;
+ }
+
+ //CS_END
+ writer->Write(0xFFFFFFFF);
+ writer->Write((uint32_t)0);
+ }
+
+ }
+} \ No newline at end of file
diff --git a/OTRExporter/CutsceneExporter.h b/OTRExporter/CutsceneExporter.h
new file mode 100644
index 0000000..c26fdf1
--- /dev/null
+++ b/OTRExporter/CutsceneExporter.h
@@ -0,0 +1,10 @@
+#pragma once
+#include "ZResource.h"
+#include "ZCutscene.h"
+#include "z64cutscene_commands.h"
+
+class OTRExporter_Cutscene : public ZResourceExporter
+{
+public:
+ virtual void Save(ZResource* res, const fs::path outPath, BinaryWriter* writer) override;
+}; \ No newline at end of file
diff --git a/OTRExporter/DisplayListExporter.cpp b/OTRExporter/DisplayListExporter.cpp
index 845f6b8..5deadfd 100644
--- a/OTRExporter/DisplayListExporter.cpp
+++ b/OTRExporter/DisplayListExporter.cpp
@@ -48,10 +48,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
printf("Exporting DList %s\n", dList->GetName().c_str());
- writer->Write((uint8_t)Endianess::Little);
- writer->Write((uint32_t)OtrLib::ResourceType::OTRDisplayList);
- writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
- writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRDisplayList);
while (writer->GetBaseAddress() % 8 != 0)
writer->Write((uint8_t)0xFF);
@@ -455,6 +452,11 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
uint32_t seg = data & 0xFFFFFFFF;
int32_t texAddress = Seg2Filespace(data, dList->parent->baseAddress);
+ if (StringHelper::Contains(res->GetName(), "gLinkChildHatNearDL"))
+ {
+ int bp = 0;
+ }
+
if (!Globals::Instance->HasSegment(GETSEGNUM(seg)))
{
int32_t __ = (data & 0x00FF000000000000) >> 48;
@@ -491,14 +493,17 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
if (foundDecl)
{
- std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), texName.c_str());
+ ZFile* assocFile = Globals::Instance->GetSegment(GETSEGNUM(seg));
+ std::string assocFileName = assocFile->GetName();
+ std::string fName = "";
+
+ if (GETSEGNUM(seg) == SEGMENT_SCENE || GETSEGNUM(seg) == SEGMENT_ROOM)
+ fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), texName.c_str());
+ else
+ fName = StringHelper::Sprintf("%s\\%s", assocFileName.c_str(), texName.c_str());
+
uint64_t hash = CRC64(fName.c_str());
- if (fName == "object_link_child\\gLinkChildDekuShieldBackTex")
- {
- int bp = 0;
- }
-
word0 = hash >> 32;
word1 = hash & 0xFFFFFFFF;
}
@@ -560,7 +565,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
{
uint32_t diff = segOffset - vtxDecl->address;
- Gfx value = gsSPVertex(diff, nn, 0);
+ Gfx value = gsSPVertex(diff, nn, ((aa >> 1) - nn));
word0 = value.words.w0;
word0 &= 0x00FFFFFF;
@@ -570,23 +575,12 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
writer->Write(word0);
writer->Write(word1);
- if (vtxDecl->address == 0x4B18)
- {
- int bp = 0;
- }
-
std::string fName = OTRExporter_DisplayList::GetPathToRes(res, vtxDecl->varName);
printf("Exporting VTX Data %s\n", fName.c_str());
uint64_t hash = CRC64(fName.c_str());
- if (StringHelper::Contains(fName, "object_link_childVtx_01C978"))
- {
- int addr = writer->GetBaseAddress();
- int bp = 0;
- }
-
word0 = hash >> 32;
word1 = hash & 0xFFFFFFFF;
@@ -698,8 +692,28 @@ std::string OTRExporter_DisplayList::GetPathToRes(ZResource* res, std::string va
std::string OTRExporter_DisplayList::GetParentFolderName(ZResource* res)
{
- if (StringHelper::Contains(res->parent->GetOutName(), "_scene") || StringHelper::Contains(res->parent->GetOutName(), "_room"))
- return (StringHelper::Split(res->parent->GetOutName(), "_")[0] + "_scene");
- else
- return res->parent->GetOutName();
+ //if (StringHelper::Contains(res->parent->GetOutName(), "_scene") || StringHelper::Contains(res->parent->GetOutName(), "_room"))
+ //return (StringHelper::Split(res->parent->GetOutName(), "_")[0] + "_scene");
+ //else
+ //return res->parent->GetOutName();
+
+ std::string oName = res->parent->GetOutName();
+
+ if (StringHelper::Contains(oName, "_scene"))
+ {
+ auto split = StringHelper::Split(oName, "_");
+ oName = "";
+ for (int i = 0; i < split.size() - 1; i++)
+ oName += split[i] + "_";
+
+ oName += "scene";
+
+ //oName = StringHelper::Split(oName, "_")[0] + "_scene";
+ }
+ else if (StringHelper::Contains(oName, "_room"))
+ {
+ oName = StringHelper::Split(oName, "_room")[0] + "_scene";
+ }
+
+ return oName;
}
diff --git a/OTRExporter/DisplayListExporter.h b/OTRExporter/DisplayListExporter.h
index 29e3b3e..c0c7402 100644
--- a/OTRExporter/DisplayListExporter.h
+++ b/OTRExporter/DisplayListExporter.h
@@ -3,9 +3,10 @@
#include "ZResource.h"
#include "ZTexture.h"
#include "ZDisplayList.h"
+#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
-class OTRExporter_DisplayList : public ZResourceExporter
+class OTRExporter_DisplayList : public OTRExporter
{
public:
virtual void Save(ZResource* res, const fs::path outPath, BinaryWriter* writer) override;
diff --git a/OTRExporter/Main.cpp b/OTRExporter/Main.cpp
index fcc6506..23a2016 100644
--- a/OTRExporter/Main.cpp
+++ b/OTRExporter/Main.cpp
@@ -10,6 +10,8 @@
#include "OTRSkeletonLimbExporter.h"
#include "ArrayExporter.h"
#include "VtxExporter.h"
+#include "AnimationExporter.h"
+#include "CutsceneExporter.h"
#include <Globals.h>
#include <Utils/File.h>
#include <Utils/Directory.h>
@@ -102,11 +104,20 @@ static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer)
std::string rName = res->GetName();
//if (res->GetResourceType() == ZResourceType::Room || res->GetResourceType() == ZResourceType::Scene)
- if (StringHelper::Contains(oName, "_scene") || StringHelper::Contains(oName, "_room"))
+ if (StringHelper::Contains(oName, "_scene"))
{
- //oName = StringHelper::Split(oName, "_")[0];
- oName = StringHelper::Split(oName, "_")[0] + "_scene";
- //rName = StringHelper::Split(rName, "_")[0];
+ auto split = StringHelper::Split(oName, "_");
+ oName = "";
+ for (int i = 0; i < split.size() - 1; i++)
+ oName += split[i] + "_";
+
+ oName += "scene";
+
+ //oName = StringHelper::Split(oName, "_")[0] + "_scene";
+ }
+ else if (StringHelper::Contains(oName, "_room"))
+ {
+ oName = StringHelper::Split(oName, "_room")[0] + "_scene";
}
std::string fName = StringHelper::Sprintf("%s\\%s", oName.c_str(), rName.c_str());
@@ -160,12 +171,15 @@ static void ImportExporters()
exporterSet->exporters[ZResourceType::Background] = new OTRExporter_Background();
exporterSet->exporters[ZResourceType::Texture] = new OTRExporter_Texture();
exporterSet->exporters[ZResourceType::Room] = new OTRExporter_Room();
+ exporterSet->exporters[ZResourceType::AltHeader] = new OTRExporter_Room();
exporterSet->exporters[ZResourceType::Scene] = new OTRExporter_Room();
exporterSet->exporters[ZResourceType::CollisionHeader] = new OTRExporter_Collision();
exporterSet->exporters[ZResourceType::DisplayList] = new OTRExporter_DisplayList();
exporterSet->exporters[ZResourceType::PlayerAnimationData] = new OTRExporter_PlayerAnimationExporter();
exporterSet->exporters[ZResourceType::Skeleton] = new OTRExporter_Skeleton();
exporterSet->exporters[ZResourceType::Limb] = new OTRExporter_SkeletonLimb();
+ exporterSet->exporters[ZResourceType::Animation] = new OTRExporter_Animation();
+ exporterSet->exporters[ZResourceType::Cutscene] = new OTRExporter_Cutscene();
//exporterSet->exporters[ZResourceType::Vertex] = new OTRExporter_Vtx();
//exporterSet->exporters[ZResourceType::Array] = new OTRExporter_Array();
diff --git a/OTRExporter/OTRExporter.cpp b/OTRExporter/OTRExporter.cpp
new file mode 100644
index 0000000..234ef31
--- /dev/null
+++ b/OTRExporter/OTRExporter.cpp
@@ -0,0 +1,9 @@
+#include "OTRExporter.h"
+
+void OTRExporter::WriteHeader(ZResource* res, fs::path outPath, BinaryWriter* writer, OtrLib::ResourceType resType)
+{
+ writer->Write((uint8_t)Endianess::Little);
+ writer->Write((uint32_t)resType);
+ writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
+ writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+}
diff --git a/OTRExporter/OTRExporter.h b/OTRExporter/OTRExporter.h
new file mode 100644
index 0000000..924d7ee
--- /dev/null
+++ b/OTRExporter/OTRExporter.h
@@ -0,0 +1,12 @@
+#pragma once
+#include "ZResource.h"
+#include "ZArray.h"
+#include "OTRExporter.h"
+#include <Utils/BinaryWriter.h>
+#include <OTRResource.h>
+
+class OTRExporter : public ZResourceExporter
+{
+protected:
+ void WriteHeader(ZResource* res, fs::path outPath, BinaryWriter* writer, OtrLib::ResourceType resType);
+}; \ No newline at end of file
diff --git a/OTRExporter/OTRExporter.vcxproj b/OTRExporter/OTRExporter.vcxproj
index faec55f..272913d 100644
--- a/OTRExporter/OTRExporter.vcxproj
+++ b/OTRExporter/OTRExporter.vcxproj
@@ -22,21 +22,30 @@
<ClInclude Include="ArrayExporter.h" />
<ClInclude Include="BackgroundExporter.h" />
<ClInclude Include="CollisionExporter.h" />
+ <ClInclude Include="command_macros_base.h" />
+ <ClInclude Include="CutsceneExporter.h" />
<ClInclude Include="DisplayListExporter.h" />
+ <ClInclude Include="AnimationExporter.h" />
<ClInclude Include="Main.h" />
+ <ClInclude Include="OTRExporter.h" />
<ClInclude Include="OTRSkeletonExporter.h" />
<ClInclude Include="OTRSkeletonLimbExporter.h" />
<ClInclude Include="PlayerAnimationExporter.h" />
<ClInclude Include="RoomExporter.h" />
<ClInclude Include="TextureExporter.h" />
<ClInclude Include="VtxExporter.h" />
+ <ClInclude Include="z64cutscene.h" />
+ <ClInclude Include="z64cutscene_commands.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ArrayExporter.cpp" />
<ClCompile Include="BackgroundExporter.cpp" />
<ClCompile Include="CollisionExporter.cpp" />
+ <ClCompile Include="CutsceneExporter.cpp" />
<ClCompile Include="DisplayListExporter.cpp" />
+ <ClCompile Include="AnimationExporter.cpp" />
<ClCompile Include="Main.cpp" />
+ <ClCompile Include="OTRExporter.cpp" />
<ClCompile Include="OTRSkeletonExporter.cpp" />
<ClCompile Include="OTRSkeletonLimbExporter.cpp" />
<ClCompile Include="PlayerAnimationExporter.cpp" />
diff --git a/OTRExporter/OTRExporter.vcxproj.filters b/OTRExporter/OTRExporter.vcxproj.filters
index e9df726..c93ed03 100644
--- a/OTRExporter/OTRExporter.vcxproj.filters
+++ b/OTRExporter/OTRExporter.vcxproj.filters
@@ -48,6 +48,24 @@
<ClInclude Include="ArrayExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="OTRExporter.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="AnimationExporter.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="CutsceneExporter.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="z64cutscene.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="z64cutscene_commands.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="command_macros_base.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CollisionExporter.cpp">
@@ -83,5 +101,14 @@
<ClCompile Include="ArrayExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="OTRExporter.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="AnimationExporter.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="CutsceneExporter.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/OTRExporter/OTRSkeletonExporter.cpp b/OTRExporter/OTRSkeletonExporter.cpp
index f52557c..d2ad3d9 100644
--- a/OTRExporter/OTRSkeletonExporter.cpp
+++ b/OTRExporter/OTRSkeletonExporter.cpp
@@ -5,10 +5,7 @@ void OTRExporter_Skeleton::Save(ZResource* res, fs::path outPath, BinaryWriter*
{
ZSkeleton* skel = (ZSkeleton*)res;
- writer->Write((uint8_t)Endianess::Little);
- writer->Write((uint32_t)OtrLib::ResourceType::OTRSkeleton);
- writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
- writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRSkeleton);
writer->Write((uint8_t)skel->type);
writer->Write((uint8_t)skel->limbType);
diff --git a/OTRExporter/OTRSkeletonExporter.h b/OTRExporter/OTRSkeletonExporter.h
index c6372e0..005433a 100644
--- a/OTRExporter/OTRSkeletonExporter.h
+++ b/OTRExporter/OTRSkeletonExporter.h
@@ -4,9 +4,10 @@
#include "ZTexture.h"
#include "ZDisplayList.h"
#include "ZSkeleton.h"
+#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
-class OTRExporter_Skeleton : public ZResourceExporter
+class OTRExporter_Skeleton : public OTRExporter
{
public:
virtual void Save(ZResource* res, const fs::path outPath, BinaryWriter* writer) override;
diff --git a/OTRExporter/OTRSkeletonLimbExporter.cpp b/OTRExporter/OTRSkeletonLimbExporter.cpp
index 83cc8f4..f5b861c 100644
--- a/OTRExporter/OTRSkeletonLimbExporter.cpp
+++ b/OTRExporter/OTRSkeletonLimbExporter.cpp
@@ -6,10 +6,7 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, fs::path outPath, BinaryWrit
{
ZLimb* limb = (ZLimb*)res;
- writer->Write((uint8_t)Endianess::Little);
- writer->Write((uint32_t)OtrLib::ResourceType::OTRSkeletonLimb);
- writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
- writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRSkeletonLimb);
writer->Write((uint8_t)limb->type);
writer->Write((uint8_t)limb->skinSegmentType);
diff --git a/OTRExporter/OTRSkeletonLimbExporter.h b/OTRExporter/OTRSkeletonLimbExporter.h
index 0411720..fd241c2 100644
--- a/OTRExporter/OTRSkeletonLimbExporter.h
+++ b/OTRExporter/OTRSkeletonLimbExporter.h
@@ -5,9 +5,10 @@
#include "ZDisplayList.h"
#include "ZSkeleton.h"
#include "ZLimb.h"
+#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
-class OTRExporter_SkeletonLimb : public ZResourceExporter
+class OTRExporter_SkeletonLimb : public OTRExporter
{
public:
virtual void Save(ZResource* res, const fs::path outPath, BinaryWriter* writer) override;
diff --git a/OTRExporter/PlayerAnimationExporter.cpp b/OTRExporter/PlayerAnimationExporter.cpp
index f6024eb..dbfc580 100644
--- a/OTRExporter/PlayerAnimationExporter.cpp
+++ b/OTRExporter/PlayerAnimationExporter.cpp
@@ -5,10 +5,7 @@ void OTRExporter_PlayerAnimationExporter::Save(ZResource* res, fs::path outPath,
{
ZPlayerAnimationData* anim = (ZPlayerAnimationData*)res;
- writer->Write((uint8_t)Endianess::Little);
- writer->Write((uint32_t)OtrLib::ResourceType::OTRPlayerAnimation);
- writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
- writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRPlayerAnimation);
auto start = std::chrono::steady_clock::now();
diff --git a/OTRExporter/PlayerAnimationExporter.h b/OTRExporter/PlayerAnimationExporter.h
index 51c1e4c..6351830 100644
--- a/OTRExporter/PlayerAnimationExporter.h
+++ b/OTRExporter/PlayerAnimationExporter.h
@@ -3,9 +3,10 @@
#include "ZResource.h"
#include "ZTexture.h"
#include "ZPlayerAnimationData.h"
+#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
-class OTRExporter_PlayerAnimationExporter : public ZResourceExporter
+class OTRExporter_PlayerAnimationExporter : public OTRExporter
{
public:
virtual void Save(ZResource* res, const fs::path outPath, BinaryWriter* writer) override;
diff --git a/OTRExporter/RoomExporter.cpp b/OTRExporter/RoomExporter.cpp
index a6f4ca4..21cf429 100644
--- a/OTRExporter/RoomExporter.cpp
+++ b/OTRExporter/RoomExporter.cpp
@@ -28,15 +28,15 @@
#include <ZRoom/Commands/SetExitList.h>
#include <ZRoom/Commands/SetPathways.h>
#include "TextureExporter.h"
+#include "Main.h"
+#include <ZRoom/Commands/SetCutscenes.h>
+#undef FindResource
void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter* writer)
{
ZRoom* room = (ZRoom*)res;
- writer->Write((uint8_t)Endianess::Little);
- writer->Write((uint32_t)OtrLib::ResourceType::OTRRoom);
- writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
- writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRRoom);
writer->Write((uint32_t)room->commands.size());
@@ -133,12 +133,25 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
{
SetCsCamera* cmdCsCam = (SetCsCamera*)cmd;
- writer->Write((uint8_t)cmdCsCam->cameras.size()); // 0x01
- writer->Write(cmdCsCam->segmentOffset); // 0x04
+ writer->Write((uint32_t)cmdCsCam->cameras.size());
for (int i = 0; i < cmdCsCam->cameras.size(); i++)
{
// OTRTODO: FINISH THIS...
+ writer->Write(cmdCsCam->cameras[i].baseOffset);
+ writer->Write(cmdCsCam->cameras[i].type);
+ writer->Write(cmdCsCam->cameras[i].numPoints);
+ //writer->Write(cmdCsCam->cameras[i].camAddress);
+ //writer->Write(cmdCsCam->cameras[i].segmentOffset);
+ }
+
+ writer->Write((uint32_t)cmdCsCam->points.size());
+
+ for (int i = 0; i < cmdCsCam->points.size(); i++)
+ {
+ writer->Write(cmdCsCam->points[i].scalars[0].scalarData.s16);
+ writer->Write(cmdCsCam->points[i].scalars[1].scalarData.s16);
+ writer->Write(cmdCsCam->points[i].scalars[2].scalarData.s16);
}
}
break;
@@ -156,29 +169,74 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
writer->Write(poly->num);
for (int i = 0; i < poly->num; i++)
- {
WritePolyDList(writer, room, &poly->polyDLists[i]);
- }
}
else if (cmdMesh->meshHeaderType == 1)
{
PolygonType1* poly = (PolygonType1*)cmdMesh->polyType.get();
- // OTRTODO: FINISH THIS
+ writer->Write(poly->format);
- //writer->Write(poly->format);
- //writer->Write(poly->dlist);
+ auto test = (PolygonDlist*)&poly->polyDLists[0];
+ Declaration* dListDeclOpa = poly->parent->GetDeclaration(GETSEGOFFSET(test->opa));
+ Declaration* dListDeclXlu = poly->parent->GetDeclaration(GETSEGOFFSET(test->xlu));
- /*if (poly->format == 2)
+ if (test->opa != 0)
+ writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclOpa->varName.c_str()));
+ else
+ writer->Write("");
+
+ if (test->xlu != 0)
+ writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclXlu->varName.c_str()));
+ else
+ writer->Write("");
+
+ if (poly->format == 2)
+ {
+ writer->Write((uint32_t)poly->count);
+
+ for (int i = 0; i < poly->count; i++)
+ {
+ writer->Write(poly->multiList[i].unk_00);
+ writer->Write(poly->multiList[i].id);
+
+ Declaration* bgDecl = poly->parent->GetDeclarationRanged(GETSEGOFFSET(poly->multiList[i].source));
+
+ writer->Write(OTRExporter_DisplayList::GetPathToRes(poly->multiList[i].sourceBackground, bgDecl->varName));
+
+ writer->Write(poly->multiList[i].unk_0C);
+ writer->Write(poly->multiList[i].tlut);
+ writer->Write(poly->multiList[i].width);
+ writer->Write(poly->multiList[i].height);
+ writer->Write(poly->multiList[i].fmt);
+ writer->Write(poly->multiList[i].siz);
+ writer->Write(poly->multiList[i].mode0);
+ writer->Write(poly->multiList[i].tlutCount);
+ }
+ }
+ else
{
- writer->Write(poly->count);
- writer->Write(poly->list);
+ writer->Write((uint32_t)1);
+
+ writer->Write(poly->single.unk_00);
+ writer->Write(poly->single.id);
+
+ Declaration* bgDecl = poly->parent->GetDeclarationRanged(GETSEGOFFSET(poly->single.source));
+
+ writer->Write(OTRExporter_DisplayList::GetPathToRes(poly->single.sourceBackground, bgDecl->varName));
+
+ writer->Write(poly->single.unk_0C);
+ writer->Write(poly->single.tlut);
+ writer->Write(poly->single.width);
+ writer->Write(poly->single.height);
+ writer->Write(poly->single.fmt);
+ writer->Write(poly->single.siz);
+ writer->Write(poly->single.mode0);
+ writer->Write(poly->single.tlutCount);
}
if (poly->dlist != 0)
- {
- WritePolyDList(writer, &poly->polyDLists[0]);
- }*/
+ WritePolyDList(writer, room, &poly->polyDLists[0]);
}
}
break;
@@ -255,7 +313,8 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
for (int i = 0;i < cmdRoom->romfile->numRooms; i++)
{
- std::string roomName = StringHelper::Sprintf("%s\\%s_room_%i", (StringHelper::Split(room->GetName(), "_")[0] + "_scene").c_str(), StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i);
+ //std::string roomName = StringHelper::Sprintf("%s\\%s_room_%i", (StringHelper::Split(room->GetName(), "_")[0] + "_scene").c_str(), StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i);
+ std::string roomName = OTRExporter_DisplayList::GetPathToRes(room, StringHelper::Sprintf("%s_room_%i", StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i));
writer->Write(roomName);
}
}
@@ -265,7 +324,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
SetCollisionHeader* cmdCollHeader = (SetCollisionHeader*)cmd;
Declaration* colHeaderDecl = room->parent->GetDeclaration(cmdCollHeader->segmentOffset);
- std::string path = StringHelper::Sprintf("%s\\%s", (StringHelper::Split(room->GetName(), "_")[0] + "_scene").c_str(), colHeaderDecl->varName.c_str());
+ std::string path = OTRExporter_DisplayList::GetPathToRes(room, colHeaderDecl->varName);
writer->Write(path);
}
break;
@@ -322,8 +381,20 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
uint32_t seg = cmdHeaders->headers[i] & 0xFFFFFFFF;
std::string headerName = "";
bool foundDecl = Globals::Instance->GetSegmentedPtrName(seg, room->parent, "", headerName);
+ std::string name = OTRExporter_DisplayList::GetPathToRes(room, headerName);
+
+ writer->Write(name);
+
+ // TEST
+ /*auto testRes = room->parent->FindResource(GETSEGOFFSET(seg));
+
+ std::shared_ptr<MemoryStream> headerStream = std::shared_ptr<MemoryStream>(new MemoryStream());
+ std::shared_ptr<BinaryWriter> headerWriter = std::shared_ptr<BinaryWriter>(new BinaryWriter(headerStream));
+ Save(testRes, outPath, headerWriter.get());
- writer->Write(OTRExporter_DisplayList::GetPathToRes(room, headerName));
+ otrArchive->AddFile(name, (uintptr_t)headerStream->ToVector().data(), headerWriter->GetBaseAddress());
+
+ int bp = 0;*/
}
}
break;
@@ -347,6 +418,15 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
writer->Write(cmdSetObjectList->objects[i]);
}
break;
+ case RoomCommand::SetCutscenes:
+ {
+ SetCutscenes* cmdSetCutscenes = (SetCutscenes*)cmd;
+
+ std::string listName;
+ Globals::Instance->GetSegmentedPtrName(cmdSetCutscenes->cmdArg2, room->parent, "CutsceneData", listName);
+ writer->Write(listName);
+ }
+ break;
case RoomCommand::EndMarker:
break;
default:
@@ -369,13 +449,15 @@ void OTRExporter_Room::WritePolyDList(BinaryWriter* writer, ZRoom* room, Polygon
writer->Write(dlist->z);
writer->Write(dlist->unk_06);
default:
+ //writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclOpa->varName.c_str()));
+
if (dlist->opaDList != nullptr)
- writer->Write(StringHelper::Sprintf("%s\\%s", (StringHelper::Split(room->GetName(), "_")[0] + "_scene").c_str(), dlist->opaDList->GetName().c_str()));
+ writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), dlist->opaDList->GetName().c_str()));
else
writer->Write("");
if (dlist->xluDList != nullptr)
- writer->Write(StringHelper::Sprintf("%s\\%s", (StringHelper::Split(room->GetName(), "_")[0] + "_scene").c_str(), dlist->xluDList->GetName().c_str()));
+ writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), dlist->xluDList->GetName().c_str()));
else
writer->Write("");
break;
diff --git a/OTRExporter/RoomExporter.h b/OTRExporter/RoomExporter.h
index f2ed5a2..d342cf9 100644
--- a/OTRExporter/RoomExporter.h
+++ b/OTRExporter/RoomExporter.h
@@ -1,11 +1,12 @@
#pragma once
#include "ZResource.h"
+#include "OTRExporter.h"
#include "ZRoom/ZRoom.h"
class PolygonDlist;
-class OTRExporter_Room : public ZResourceExporter
+class OTRExporter_Room : public OTRExporter
{
public:
void WritePolyDList(BinaryWriter* writer, ZRoom* room, PolygonDlist* dlist);
diff --git a/OTRExporter/TextureExporter.h b/OTRExporter/TextureExporter.h
index ce922bc..7951edc 100644
--- a/OTRExporter/TextureExporter.h
+++ b/OTRExporter/TextureExporter.h
@@ -2,9 +2,10 @@
#include "ZResource.h"
#include "ZTexture.h"
+#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
-class OTRExporter_Texture : public ZResourceExporter
+class OTRExporter_Texture : public OTRExporter
{
public:
virtual void Save(ZResource* res, const fs::path outPath, BinaryWriter* writer) override;
diff --git a/OTRExporter/VtxExporter.cpp b/OTRExporter/VtxExporter.cpp
index 2add880..8e36a76 100644
--- a/OTRExporter/VtxExporter.cpp
+++ b/OTRExporter/VtxExporter.cpp
@@ -8,6 +8,7 @@ void OTRExporter_Vtx::SaveArr(const std::vector<ZResource*>& vec, BinaryWriter*
writer->Write((uint32_t)OtrLib::ResourceType::OTRVtx);
writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+
for (auto& res: vec) {
ZVtx* vtx = (ZVtx*)res;
writer->Write(vtx->x);
@@ -27,10 +28,8 @@ void OTRExporter_Vtx::SaveArr(const std::vector<ZResource*>& vec, BinaryWriter*
void OTRExporter_Vtx::Save(ZResource* res, fs::path outPath, BinaryWriter* writer)
{
ZVtx* vtx = (ZVtx*)res;
- writer->Write((uint8_t)Endianess::Little);
- writer->Write((uint32_t)OtrLib::ResourceType::OTRVtx);
- writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
- writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRVtx);
writer->Write(vtx->x);
writer->Write(vtx->y);
diff --git a/OTRExporter/VtxExporter.h b/OTRExporter/VtxExporter.h
index 0003bd2..051e58a 100644
--- a/OTRExporter/VtxExporter.h
+++ b/OTRExporter/VtxExporter.h
@@ -2,9 +2,10 @@
#include "ZResource.h"
#include "ZVtx.h"
+#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
-class OTRExporter_Vtx : public ZResourceExporter
+class OTRExporter_Vtx : public OTRExporter
{
public:
void SaveArr(const std::vector<ZResource*>&, BinaryWriter* writer);
diff --git a/OTRExporter/command_macros_base.h b/OTRExporter/command_macros_base.h
new file mode 100644
index 0000000..bd9ac16
--- /dev/null
+++ b/OTRExporter/command_macros_base.h
@@ -0,0 +1,32 @@
+#ifndef COMMAND_MACROS_BASE_H
+#define COMMAND_MACROS_BASE_H
+
+/**
+ * Command Base macros intended for use in designing of more specific command macros
+ * Each macro packs bytes (B), halfwords (H) and words (W, for consistency) into a single word
+ */
+
+#define _SHIFTL(v, s, w) \
+ ((unsigned int) (((unsigned int)(v) & ((0x01 << (w)) - 1)) << (s)))
+#define _SHIFTR(v, s, w) \
+ ((unsigned int)(((unsigned int)(v) >> (s)) & ((0x01 << (w)) - 1)))
+
+#define CMD_BBBB(a, b, c, d) (_SHIFTL(a, 24, 8) | _SHIFTL(b, 16, 8) | _SHIFTL(c, 8, 8) | _SHIFTL(d, 0, 8))
+
+#define CMD_BBH(a, b, c) (_SHIFTL(a, 24, 8) | _SHIFTL(b, 16, 8) | _SHIFTL(c, 0, 16))
+
+#define CMD_HBB(a, b, c) (_SHIFTL(a, 16, 16) | _SHIFTL(b, 8, 8) | _SHIFTL(c, 0, 8))
+
+#define CMD_HH(a, b) (_SHIFTL(a, 16, 16) | _SHIFTL(b, 0, 16))
+
+#define CMD_W(a) (a)
+
+#if defined(__GNUC__)
+#define CMD_F(a) {.f = (a)}
+#else
+#define CMD_F(a) {(a)}
+#endif
+
+#define CMD_PTR(a) (u32)(a)
+
+#endif \ No newline at end of file
diff --git a/OTRExporter/z64cutscene.h b/OTRExporter/z64cutscene.h
new file mode 100644
index 0000000..4f44c10
--- /dev/null
+++ b/OTRExporter/z64cutscene.h
@@ -0,0 +1,290 @@
+#ifndef Z64CUTSCENE_H
+#define Z64CUTSCENE_H
+
+#if 0
+#include "ultra64.h"
+
+typedef struct {
+ /* 0x00 */ u16 entrance; // entrance index upon which the cutscene should trigger
+ /* 0x02 */ u8 ageRestriction; // 0 for adult only, 1 for child only, 2 for both ages
+ /* 0x03 */ u8 flag; // eventChkInf flag bound to the entrance cutscene
+ /* 0x04 */ void* segAddr; // segment offset location of the cutscene
+} EntranceCutscene; // size = 0x8
+
+typedef struct {
+ /* 0x00 */ s8 continueFlag;
+ /* 0x01 */ s8 cameraRoll;
+ /* 0x02 */ u16 nextPointFrame;
+ /* 0x04 */ f32 viewAngle; // in degrees
+ /* 0x08 */ Vec3s pos;
+} CutsceneCameraPoint; // size = 0x10
+
+typedef struct {
+ /* 0x00 */ Vec3f at;
+ /* 0x0C */ Vec3f eye;
+ /* 0x18 */ s16 roll;
+ /* 0x1A */ s16 fov;
+} CutsceneCameraAngle; // size = 0x1C
+
+typedef struct {
+ /* 0x0 */ CutsceneCameraPoint* atPoints;
+ /* 0x4 */ CutsceneCameraPoint* eyePoints;
+ /* 0x8 */ s16 relativeToPlayer;
+} CutsceneCameraMove; // size = 0xC
+
+typedef struct {
+ /* 0x00 */ u16 base;
+ /* 0x02 */ u16 startFrame;
+ /* 0x04 */ u16 endFrame;
+} CsCmdBase; // size = 0x6
+
+typedef struct {
+ /* 0x00 */ u8 unk_00;
+ /* 0x01 */ u8 setting;
+ /* 0x02 */ u16 startFrame;
+ /* 0x04 */ u16 endFrame;
+} CsCmdEnvLighting; // size = 0x6
+
+typedef struct {
+ /* 0x00 */ u8 unk_00;
+ /* 0x01 */ u8 sequence;
+ /* 0x02 */ u16 startFrame;
+ /* 0x04 */ u16 endFrame;
+} CsCmdMusicChange; // size = 0x6
+
+typedef struct {
+ /* 0x00 */ u16 type;
+ /* 0x02 */ u16 startFrame;
+ /* 0x04 */ u16 endFrame;
+} CsCmdMusicFade; // size = 0x6
+
+typedef struct {
+ /* 0x00 */ u16 unk_00;
+ /* 0x02 */ u16 startFrame;
+ /* 0x04 */ u16 endFrame;
+ /* 0x06 */ u8 unk_06;
+ /* 0x07 */ u8 unk_07;
+ /* 0x08 */ u8 unk_08;
+} CsCmdUnknown9; // size = 0xA
+
+typedef struct {
+ /* 0x00 */ u16 unk_00;
+ /* 0x02 */ u16 startFrame;
+ /* 0x04 */ u16 endFrame;
+ /* 0x06 */ u8 hour;
+ /* 0x07 */ u8 minute;
+} CsCmdDayTime; // size = 0x8
+
+typedef struct {
+ /* 0x00 */ u16 base;
+ /* 0x02 */ u16 startFrame;
+ /* 0x04 */ u16 endFrame;
+ /* 0x06 */ u16 type;
+ /* 0x08 */ u16 textId1;
+ /* 0x0A */ u16 textId2;
+} CsCmdTextbox; // size = 0xC
+
+typedef struct {
+ /* 0x00 */ u16 action; // "dousa"
+ /* 0x02 */ u16 startFrame;
+ /* 0x04 */ u16 endFrame;
+ union {
+ /* 0x06 */ Vec3s rot;
+ /* 0x06 */ Vec3us urot;
+ };
+ /* 0x0C */ Vec3i startPos;
+ /* 0x18 */ Vec3i endPos;
+ /* 0x24 */ Vec3i normal;
+} CsCmdActorAction; // size = 0x30
+#endif
+
+typedef enum {
+ CS_STATE_IDLE,
+ CS_STATE_SKIPPABLE_INIT,
+ CS_STATE_SKIPPABLE_EXEC,
+ CS_STATE_UNSKIPPABLE_INIT,
+ CS_STATE_UNSKIPPABLE_EXEC
+} CutsceneState;
+
+typedef enum {
+ CS_CMD_00 = 0x0000,
+ CS_CMD_CAM_EYE = 0x0001,
+ CS_CMD_CAM_AT = 0x0002,
+ CS_CMD_MISC = 0x0003,
+ CS_CMD_SET_LIGHTING = 0x0004,
+ CS_CMD_CAM_EYE_REL_TO_PLAYER = 0x0005,
+ CS_CMD_CAM_AT_REL_TO_PLAYER = 0x0006,
+ CS_CMD_07 = 0x0007,
+ CS_CMD_08 = 0x0008,
+ CS_CMD_09 = 0x0009,
+ CS_CMD_TEXTBOX = 0x0013,
+ CS_CMD_SET_PLAYER_ACTION = 0x000A,
+ CS_CMD_SET_ACTOR_ACTION_1 = 0x000F,
+ CS_CMD_SET_ACTOR_ACTION_2 = 0x000E,
+ CS_CMD_SET_ACTOR_ACTION_3 = 0x0019,
+ CS_CMD_SET_ACTOR_ACTION_4 = 0x001D,
+ CS_CMD_SET_ACTOR_ACTION_5 = 0x001E,
+ CS_CMD_SET_ACTOR_ACTION_6 = 0x002C,
+ CS_CMD_SET_ACTOR_ACTION_7 = 0x001F,
+ CS_CMD_SET_ACTOR_ACTION_8 = 0x0031,
+ CS_CMD_SET_ACTOR_ACTION_9 = 0x003E,
+ CS_CMD_SET_ACTOR_ACTION_10 = 0x008F,
+ CS_CMD_SCENE_TRANS_FX = 0x002D,
+ CS_CMD_NOP = 0x000B,
+ CS_CMD_PLAYBGM = 0x0056,
+ CS_CMD_STOPBGM = 0x0057,
+ CS_CMD_FADEBGM = 0x007C,
+ CS_CMD_SETTIME = 0x008C,
+ CS_CMD_TERMINATOR = 0x03E8,
+ CS_CMD_END = 0xFFFF
+} CutsceneCmd;
+
+/**
+ * Special type for blocks of cutscene data, asm-processor checks
+ * arrays for CutsceneData type and converts floats within the array
+ * to their IEEE-754 representation. The array must close with };
+ * on its own line.
+ *
+ * Files that contain this type that are included in other C files
+ * must include an 'EARLY' qualifier to inform asm-processor that it
+ * must recursively process that include.
+ *
+ * Example: #include "file.c" EARLY
+ */
+
+
+typedef union CutsceneData {
+ int i;
+ float f;
+ short s[2];
+ char b[4];
+} CutsceneData;
+
+#define CS_CMD_CONTINUE 0
+#define CS_CMD_STOP -1
+
+// TODO confirm correctness, clarify names
+typedef enum {
+ /* 0x00 */ INVALID_DESTINATION_0,
+ /* 0x01 */ CUTSCENE_MAP_GANON_HORSE,
+ /* 0x02 */ CUTSCENE_MAP_THREE_GODESSES_POST_DEKU_TREE,
+ /* 0x03 */ GERUDO_VALLEY_DIN,
+ /* 0x04 */ DEATH_MOUNTAIN_TRAIL_NAYRU,
+ /* 0x05 */ KOKIRI_FOREST_FARORE,
+ /* 0x06 */ CUTSCENE_MAP_TRIFORCE_CREATION,
+ /* 0x07 */ KOKIRI_FOREST_RECEIVE_KOKIRI_EMERALD,
+ /* 0x08 */ TEMPLE_OF_TIME_AFTER_USE_MS,
+ /* 0x09 */ GERUDO_VALLEY_DIN_2,
+ /* 0x0A */ LINKS_HOUSE_INTRO,
+ /* 0x0B */ KOKIRI_FOREST_INTRO,
+ /* 0x0C */ DEATH_MOUNTAIN_TRAIL_AFTER_GORON_RUBY,
+ /* 0x0D */ ZORAS_FOUNTAIN_AFTER_ZORAS_SAPPHIRE,
+ /* 0x0E */ KOKIRI_FOREST_AFTER_KOKIRI_EMERALD,
+ /* 0x0F */ TEMPLE_OF_TIME_KOKIRI_EMERALD, //unused
+ /* 0x10 */ TEMPLE_OF_TIME_GORON_RUBY, //unused
+ /* 0x11 */ TEMPLE_OF_TIME_ZORAS_SAPPHIRE, //unused
+ /* 0x12 */ TEMPLE_OF_TIME_AFTER_USE_MS_FIRST,
+ /* 0x13 */ DEATH_MOUNTAIN_TRAIL_AFTER_INTRO,
+ /* 0x14 */ INVALID_DESTINATION_14,
+ /* 0x15 */ LAKE_HYLIA_WATER_RISES,
+ /* 0x16 */ DESERT_COLOSSUS_REQUIEM,
+ /* 0x17 */ CUTSCENE_MAP_CURSE_YOU,
+ /* 0x18 */ JABU_JABU_INTRO,
+ /* 0x19 */ CHAMBER_OF_SAGES_LIGHT_MEDALLION,
+ /* 0x1A */ TEMPLE_OF_TIME_KOKIRI_EMERALD_2, //duplicate of 0x000F
+ /* 0x1B */ TEMPLE_OF_TIME_GORON_RUBY_2, //duplicate of 0x0010
+ /* 0x1C */ TEMPLE_OF_TIME_ZORAS_SAPPHIRE_2, //duplicate of 0x0011
+ /* 0x1D */ CHAMBER_OF_SAGES_FOREST_MEDALLION,
+ /* 0x1E */ CHAMBER_OF_SAGES_FIRE_MEDALLION,
+ /* 0x1F */ CHAMBER_OF_SAGES_WATER_MEDALLION,
+ /* 0x20 */ HYRULE_FIELD_FLASHBACK, //lacs part 4
+ /* 0x21 */ HYRULE_FIELD_AFTER_LAKE_HYLIA_OWL,
+ /* 0x22 */ CUTSCENE_MAP_GANON_AFTER_USE_MS,
+ /* 0x23 */ HYRULE_FIELD_INTRO_ZELDA_ESCAPE,
+ /* 0x24 */ INVALID_DESTINATION_24,
+ /* 0x25 */ INVALID_DESTINATION_25,
+ /* 0x26 */ CUTSCENE_MAP_SHEIKAH_LEGEND, //lacs part 2
+ /* 0x27 */ TEMPLE_OF_TIME_ZELDA_REVEAL, //lacs part 3
+ /* 0x28 */ TEMPLE_OF_TIME_GET_LIGHT_ARROWS, //lacs part 5
+ /* 0x29 */ LAKE_HYLIA_AFTER_BLUE_WARP,
+ /* 0x2A */ KAKARIKO_VILLAGE_DRAIN_WELL,
+ /* 0x2B */ WINDMILL_AFTER_DRAIN_WELL,
+ /* 0x2C */ TEMPLE_OF_TIME_AFTER_DOOR_OF_TIME_OPENS,
+ /* 0x2D */ INVALID_DESTINATION_2D,
+ /* 0x2E */ TEMPLE_OF_TIME_AFTER_USE_MS_FIRST_2, // duplicate of 0x0012
+ /* 0x2F */ KAKARIKO_VILLAGE_NOCTURNE_PART_2,
+ /* 0x30 */ DESERT_COLOSSUS_AFTER_REQUIEM,
+ /* 0x31 */ TEMPLE_OF_TIME_AFTER_LIGHT_ARROWS,
+ /* 0x32 */ KAKARIKO_VILLAGE_AFTER_NOCTURNE,
+ /* 0x33 */ HYRULE_FIELD_IMPA_ESCORT_CS,
+ /* 0x34 */ TEMPLE_OF_TIME_SONG_OF_TIME,
+ /* 0x35 */ HYRULE_FIELD_AFTER_SONG_OF_TIME,
+ /* 0x36 */ GERUDO_VALLEY_CREDITS,
+ /* 0x37 */ GERUDO_FORTRESS_CREDITS,
+ /* 0x38 */ KAKARIKO_VILLAGE_CREDITS,
+ /* 0x39 */ DEATH_MOUNTAIN_TRAIL_CREDITS_1,
+ /* 0x3A */ GORON_CITY_CREDITS, // unused?
+ /* 0x3B */ LAKE_HYLIA_CREDITS,
+ /* 0x3C */ ZORAS_FOUNTAIN_CREDITS, // unused
+ /* 0x3D */ ZORAS_DOMAIN_CREDITS,
+ /* 0x3E */ KOKIRI_FOREST_CREDITS_1,
+ /* 0x3F */ KOKIRI_FOREST_CREDITS_2,
+ /* 0x40 */ HYRULE_FIELD_CREDITS,
+ /* 0x41 */ LON_LON_RANCH_CREDITS_1,
+ /* 0x42 */ KAKARIKO_VILLAGE_AFTER_TRAIL_OWL,
+ /* 0x43 */ HTRULE_FIELD_UNUSED_ENTRANCE,
+ /* 0x44 */ CUTSCENE_MAP_FIRE,
+ /* 0x45 */ KOKIRI_FOREST_POST_FOREST_MEDALLION,
+ /* 0x46 */ DEATH_MOUNTAIN_TRAIL_CREDITS_2,
+ /* 0x47 */ TEMPLE_OF_TIME_CREDITS,
+ /* 0x48 */ ZELDAS_COURTYARD_CREDITS,
+ /* 0x49 */ LON_LON_RANCH_CREDITS_1_2, // duplicate of 0x0041
+ /* 0x4A */ LON_LON_RANCH_CREDITS_2,
+ /* 0x4B */ LON_LON_RANCH_CREDITS_3,
+ /* 0x4C */ LON_LON_RANCH_CREDITS_4,
+ /* 0x4D */ LON_LON_RANCH_CREDITS_5,
+ /* 0x4E */ LON_LON_RANCH_CREDITS_6,
+ /* 0x4F */ LON_LON_RANCH_NO_CS_1,
+ /* 0x50 */ LON_LON_RANCH_NO_CS_2,
+ /* 0x51 */ LON_LON_RANCH_NO_CS_3,
+ /* 0x52 */ LON_LON_RANCH_NO_CS_4,
+ /* 0x53 */ LON_LON_RANCH_NO_CS_5,
+ /* 0x54 */ LON_LON_RANCH_NO_CS_6,
+ /* 0x55 */ LON_LON_RANCH_NO_CS_7,
+ /* 0x56 */ LON_LON_RANCH_NO_CS_8,
+ /* 0x57 */ LON_LON_RANCH_NO_CS_9,
+ /* 0x58 */ LON_LON_RANCH_NO_CS_10,
+ /* 0x59 */ LON_LON_RANCH_NO_CS_11,
+ /* 0x5A */ LON_LON_RANCH_NO_CS_12,
+ /* 0x5B */ LON_LON_RANCH_NO_CS_13,
+ /* 0x5C */ LON_LON_RANCH_NO_CS_14,
+ /* 0x5D */ LON_LON_RANCH_NO_CS_15,
+ /* 0x5E */ LON_LON_RANCH_NO_CS_EPONAS_SONG,
+ /* 0x5F */ CONDITIONAL_DESTINATION, // TODO more descriptive name?
+ /* 0x60 */ DESERT_COLOSSUS_SPIRIT_BLUE_WARP,
+ /* 0x61 */ GRAVEYARD_AFTER_SHADOW_BLUE_WARP,
+ /* 0x62 */ DEATH_MOUNTAIN_CRATER_AFTER_FIRE_BLUE_WARP,
+ /* 0x63 */ SACRED_FOREST_MEADOW_AFTER_FOREST_BLUE_WARP,
+ /* 0x64 */ KOKIRI_FOREST_AFTER_FOREST_BLUE_WARP,
+ /* 0x65 */ DESERT_COLOSSUS_AFTER_SILVER_GAUNTLETS,
+ /* 0x66 */ TEMPLE_OF_TIME_FRONT_OF_PEDESTAL,
+ /* 0x67 */ HYRULE_FIELD_TITLE_SCREEN,
+ /* 0x68 */ SPIRIT_TEMPLE_BOSS_TITLE_SCREEN,
+ /* 0x69 */ GRAVEYARD_SUNS_SONG,
+ /* 0x6A */ ROYAL_FAMILYS_TOMB_SUNS_SONG,
+ /* 0x6B */ GANONS_CASTLE_AFTER_FOREST_TRIAL,
+ /* 0x6C */ GANONS_CASTLE_AFTER_WATER_TRIAL,
+ /* 0x6D */ GANONS_CASTLE_AFTER_SHADOW_TRIAL,
+ /* 0x6E */ GANONS_CASTLE_AFTER_FIRE_TRIAL,
+ /* 0x6F */ GANONS_CASTLE_AFTER_LIGHT_TRIAL,
+ /* 0x70 */ GANONS_CASTLE_AFTER_SPIRIT_TRIAL,
+ /* 0x71 */ GANONS_CASTLE_DISPEL_BARRIER_IF_CONDITIONS,
+ /* 0x72 */ HYRULE_FIELD_INTRO,
+ /* 0x73 */ HYRULE_FIELD_AFTER_IMPA_ESCORT,
+ /* 0x74 */ DESERT_COLOSSUS_SPIRIT_BLUE_WARP_2,
+ /* 0x75 */ HYRULE_FIELD_SKY,
+ /* 0x76 */ GANON_BATTLE_TOWER_COLLAPSE,
+ /* 0x77 */ ZELDAS_COURTYARD_RECEIVE_LETTER
+} CutsceneTerminatorDestination;
+
+#endif \ No newline at end of file
diff --git a/OTRExporter/z64cutscene_commands.h b/OTRExporter/z64cutscene_commands.h
new file mode 100644
index 0000000..5d440cc
--- /dev/null
+++ b/OTRExporter/z64cutscene_commands.h
@@ -0,0 +1,448 @@
+#ifndef Z64CUTSCENE_COMMANDS_H
+#define Z64CUTSCENE_COMMANDS_H
+
+#include "command_macros_base.h"
+#include "z64cutscene.h"
+
+/**
+ * ARGS
+ * s32 totalEntries (e), s32 endFrame (n)
+ * FORMAT
+ * eeeeeeee nnnnnnnn
+ * size = 0x8
+ */
+#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) CMD_W(totalEntries), CMD_W(endFrame)
+
+ /**
+ * ARGS
+ * s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * 00000001 0001ssss eeee0000
+ * size = 0xC
+ */
+#define CS_CAM_POS_LIST CS_CAM_EYE_LIST
+#define CS_CAM_EYE_LIST(startFrame, endFrame) \
+ CS_CMD_CAM_EYE, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000)
+
+ /**
+ * ARGS
+ * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a),
+ * s16 xPos (x), s16 yPos (y), s16 zPos (z)
+ * FORMAT
+ * Capital U is Unused
+ * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU
+ * size = 0x10
+ */
+#define CS_CAM_POS CS_CAM_EYE
+#define CS_CAM_EYE(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \
+ CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused)
+
+ /**
+ * ARGS
+ * s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * 00000002 0001ssss eeee0000
+ * size = 0xC
+ */
+#define CS_CAM_FOCUS_POINT_LIST CS_CAM_AT_LIST
+#define CS_CAM_AT_LIST(startFrame, endFrame) \
+ CS_CMD_CAM_AT, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000)
+
+ /**
+ * ARGS
+ * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a),
+ * s16 xPos (x), s16 yPos (y), s16 zPos (z)
+ * FORMAT
+ * Capital U is Unused
+ * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU
+ * size = 0x10
+ */
+#define CS_CAM_FOCUS_POINT CS_CAM_AT
+#define CS_CAM_AT(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \
+ CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused)
+
+ /**
+ * ARGS
+ * s32 entries (e)
+ * FORMAT
+ * 00000003 eeeeeeee
+ * size = 0x8
+ */
+#define CS_MISC_LIST(entries) CS_CMD_MISC, CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 unk (u), s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused
+ * uuuussss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU
+ * size = 0x30
+ */
+#define CS_MISC(unk, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7, unused8, unused9, unused10) \
+ CMD_HH(unk, startFrame), CMD_HH(endFrame, unused0), \
+ CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \
+ CMD_W(unused6), CMD_W(unused7), CMD_W(unused8), CMD_W(unused9), CMD_W(unused10)
+
+ /**
+ * ARGS
+ * s32 entries (e)
+ * FORMAT
+ * 00000004 eeeeeeee
+ * size = 0x8
+ */
+#define CS_LIGHTING_LIST(entries) CS_CMD_SET_LIGHTING, CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 setting (m), s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused
+ * mmmmssss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU 00000000 00000000 00000000
+ * size = 0x30
+ */
+#define CS_LIGHTING(setting, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \
+ CMD_HH(setting, startFrame), CMD_HH(endFrame, unused0), \
+ CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \
+ CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000
+
+ /**
+ * ARGS
+ * s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused , may be consistently zero
+ * 00000005 0001ssss eeee0000
+ * size = 0xC
+ */
+#define CS_CAM_POS_PLAYER_LIST CS_CAM_EYE_REL_TO_PLAYER_LIST
+#define CS_CAM_EYE_REL_TO_PLAYER_LIST(startFrame, endFrame) \
+ CS_CMD_CAM_EYE_REL_TO_PLAYER, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000)
+
+ /**
+ * ARGS
+ * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a),
+ * s16 xPos (x), s16 yPos (y), s16 zPos (z)
+ * FORMAT
+ * Capital U is Unused
+ * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU
+ * size = 0x10
+ */
+#define CS_CAM_POS_PLAYER CS_CAM_EYE_REL_TO_PLAYER
+#define CS_CAM_EYE_REL_TO_PLAYER(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \
+ CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused)
+
+ /**
+ * ARGS
+ * s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused , may be consistently zero
+ * 00000006 0001ssss eeee0000
+ * size = 0xC
+ */
+#define CS_CAM_FOCUS_POINT_PLAYER_LIST CS_CAM_AT_REL_TO_PLAYER_LIST
+#define CS_CAM_AT_REL_TO_PLAYER_LIST(startFrame, endFrame) \
+ CS_CMD_CAM_AT_REL_TO_PLAYER, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000)
+ /**
+ * ARGS
+ * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a),
+ * s16 xPos (x), s16 yPos (y), s16 zPos (z)
+ * FORMAT
+ * Capital U is Unused
+ * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU
+ * size = 0x10
+ */
+#define CS_CAM_FOCUS_POINT_PLAYER CS_CAM_AT_REL_TO_PLAYER
+#define CS_CAM_AT_REL_TO_PLAYER(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \
+ CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused)
+
+ /**
+ * ARGS
+ * s16 unk (u), s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused
+ * 00000007 uuuussss eeeeUUUU
+ * size = 0xC
+ */
+#define CS_CMD_07_LIST(unk, startFrame, endFrame, unused) \
+ CS_CMD_07, CMD_HH(unk, startFrame), CMD_HH(endFrame, unused)
+
+ /**
+ * ARGS
+ * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a),
+ * s16 xPos (x), s16 yPos (y), s16 zPos (z)
+ * FORMAT
+ * Capital U is Unused
+ * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU
+ * size = 0x10
+ */
+#define CS_CMD_07(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \
+ CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused)
+
+ /**
+ * ARGS
+ * s16 unk (u), s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused
+ * 00000008 uuuussss eeeeUUUU
+ * size = 0xC
+ */
+#define CS_CMD_08_LIST(unk, startFrame, endFrame, unused) \
+ CS_CMD_08, CMD_HH(unk, startFrame), CMD_HH(endFrame, unused)
+
+ /**
+ * ARGS
+ * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a),
+ * s16 xPos (x), s16 yPos (y), s16 zPos (z)
+ * FORMAT
+ * Capital U is Unused
+ * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU
+ * size = 0x10
+ */
+#define CS_CMD_08(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \
+ CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused)
+
+ /**
+ * ARGS
+ * s32 entries (e)
+ * FORMAT
+ * 00000009 eeeeeeee
+ * size = 0x8
+ */
+#define CS_CMD_09_LIST(entries) CS_CMD_09, CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 unk (u), s16 startFrame (s), s16 endFrame (e), s16 unk2 (v), s16 unk3 (w), s16 unk4 (x)
+ * FORMAT
+ * Capital U is Unused
+ * uuuussss eeeevvww xxUUUUUU
+ * size = 0xC
+ */
+#define CS_CMD_09(unk, startFrame, endFrame, unk2, unk3, unk4, unused0, unused1) \
+ CMD_HH(unk, startFrame), CMD_HBB(endFrame, unk2, unk3), CMD_BBH(unk4, unused0, unused1)
+
+ /**
+ * ARGS
+ * s32 cmdType (c), s32 entries (e)
+ * FORMAT
+ * cccccccc eeeeeeee
+ * size = 0x8
+ */
+#define CS_UNK_DATA_LIST(cmdType, entries) CMD_W(cmdType), CMD_W(entries)
+
+ /**
+ * ARGS
+ * s32 unk1 (a), s32 unk2 (b), s32 unk3 (c), s32 unk4 (d), s32 unk5 (e), s32 unk6 (f),
+ * s32 unk7 (g), s32 unk8 (h), s32 unk9 (i), s32 unk10 (j), s32 unk11 (k), s32 unk12 (l)
+ * FORMAT
+ * aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh iiiiiiii jjjjjjjj kkkkkkkk llllllll
+ * size = 0x30
+ */
+#define CS_UNK_DATA(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8, unk9, unk10, unk11, unk12) \
+ CMD_W(unk1), CMD_W(unk2), CMD_W(unk3), CMD_W(unk4), CMD_W(unk5), CMD_W(unk6), \
+ CMD_W(unk7), CMD_W(unk8), CMD_W(unk9), CMD_W(unk10), CMD_W(unk11), CMD_W(unk12)
+
+ /**
+ * ARGS
+ * s32 cmdType (c), s32 entries (e)
+ * FORMAT
+ * cccccccc eeeeeeee
+ * size = 0x8
+ */
+#define CS_NPC_ACTION_LIST(cmdType, entries) CMD_W(cmdType), CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 npcAction (a), s16 startFrame (s), s16 endFrame (e),
+ * s16 rotX (u), s16 rotY (v), s16 rotZ (w),
+ * s32 startX (i), s32 startY (j), s32 startZ (k),
+ * s32 endX (l), s32 endY (m), s32 endZ (n),
+ * f32 normX (x), f32 normY (y), f32 normZ (z),
+ * FORMAT
+ * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz
+ * size = 0x30
+ */
+#define CS_NPC_ACTION(npcAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \
+ CMD_HH(npcAction, startFrame), CMD_HH(endFrame, rotX), CMD_HH(rotY, rotZ), \
+ CMD_W(startX), CMD_W(startY), CMD_W(startZ), \
+ CMD_W(endX), CMD_W(endY), CMD_W(endZ), \
+ CMD_F(normX), CMD_F(normY), CMD_F(normZ)
+
+ /**
+ * ARGS
+ * s32 cmdType (c), s32 entries (e)
+ * FORMAT
+ * cccccccc eeeeeeee
+ * size = 0x8
+ */
+#define CS_PLAYER_ACTION_LIST(entries) CS_CMD_SET_PLAYER_ACTION, CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 linkAction (a), s16 startFrame (s), s16 endFrame (e),
+ * s16 rotX (u), s16 rotY (v), s16 rotZ (w),
+ * s32 startX (i), s32 startY (j), s32 startZ (k),
+ * s32 endX (l), s32 endY (m), s32 endZ (n),
+ * f32 normX (x), f32 normY (y), f32 normZ (z),
+ * FORMAT
+ * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz
+ * size = 0x30
+ */
+#define CS_PLAYER_ACTION(linkAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \
+ CS_NPC_ACTION(linkAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ)
+
+ /**
+ * ARGS
+ * s32 entries (e)
+ * FORMAT
+ * 00000013 eeeeeeee
+ * size = 0x8
+ */
+#define CS_TEXT_LIST(entries) CS_CMD_TEXTBOX, CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), s16 type (o),
+ * s16 topOptionBranch (y), s16 bottomOptionBranch (n)
+ * FORMAT
+ * iiiissss eeeeoooo yyyynnnn
+ * size = 0xC
+ */
+#define CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, type, topOptionBranch, bottomOptionBranch) \
+ CMD_HH(messageId, startFrame), CMD_HH(endFrame, type), CMD_HH(topOptionBranch, bottomOptionBranch)
+
+ /**
+ * ARGS
+ * s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * FFFFssss eeeeFFFF FFFFFFFF
+ * size = 0xC
+ */
+#define CS_TEXT_NONE(startFrame, endFrame) \
+ CS_TEXT_DISPLAY_TEXTBOX(0xFFFF, startFrame, endFrame, 0xFFFF, 0xFFFF, 0xFFFF)
+
+ /**
+ * ARGS
+ * s16 ocarinaSongAction (o), s16 startFrame (s), s16 endFrame (e), s16 topOptionBranch (i)
+ * FORMAT
+ * oooossss eeee0002 iiiiFFFF
+ * size = 0xC
+ */
+#define CS_TEXT_LEARN_SONG(ocarinaSongAction, startFrame, endFrame, messageId) \
+ CS_TEXT_DISPLAY_TEXTBOX(ocarinaSongAction, startFrame, endFrame, 0x0002, messageId, 0xFFFF)
+
+ /**
+ * ARGS
+ * s16 transitionType (t), s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused , endFrame duplicate
+ * 0000002D 00000001 ttttssss eeeeUUUU
+ * size = 0x10
+ */
+#define CS_SCENE_TRANS_FX(transitionType, startFrame, endFrame) \
+ CS_CMD_SCENE_TRANS_FX, 0x00000001, CMD_HH(transitionType, startFrame), CMD_HH(endFrame, endFrame)
+
+ /**
+ * ARGS
+ * s32 entries (e)
+ * FORMAT
+ * 00000056 eeeeeeee
+ * size = 0x8
+ */
+#define CS_PLAY_BGM_LIST(entries) CS_CMD_PLAYBGM, CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 sequence (q), s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused
+ * qqqqssss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU 00000000 00000000 00000000
+ * size = 0x30
+ */
+#define CS_PLAY_BGM(sequence, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \
+ CMD_HH(sequence, startFrame), CMD_HH(endFrame, unused0), \
+ CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \
+ CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000
+
+ /**
+ * ARGS
+ * s32 entries (e)
+ * FORMAT
+ * 00000057 eeeeeeee
+ * size = 0x8
+ */
+#define CS_STOP_BGM_LIST(entries) CS_CMD_STOPBGM, CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 sequence (q), s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused
+ * uuqqssss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU 00000000 00000000 00000000
+ * size = 0x30
+ */
+#define CS_STOP_BGM(sequence, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \
+ CMD_HH(sequence, startFrame), CMD_HH(endFrame, unused0), \
+ CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \
+ CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000
+
+ /**
+ * ARGS
+ * s32 entries (e)
+ * FORMAT
+ * 0000007C eeeeeeee
+ * size = 0x8
+ */
+#define CS_FADE_BGM_LIST(entries) CS_CMD_FADEBGM, CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 fadeType (t), s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused
+ * ttttssss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU 00000000 00000000 00000000
+ * size = 0x30
+ */
+#define CS_FADE_BGM(fadeType, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \
+ CMD_HH(fadeType, startFrame), CMD_HH(endFrame, unused0), \
+ CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \
+ CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000
+
+ /**
+ * ARGS
+ * s32 entries (e)
+ * FORMAT
+ * 0000008C eeeeeeee
+ * size = 0x8
+ */
+#define CS_TIME_LIST(entries) CS_CMD_SETTIME, CMD_W(entries)
+
+ /**
+ * ARGS
+ * s16 unk (u), s16 startFrame (s), s16 endFrame (e), s8 hour (h), s8 min (m)
+ * FORMAT
+ * Capital U is Unused
+ * uuuussss eeeehhmm UUUUUUUU
+ * size = 0xC
+ */
+#define CS_TIME(unk, startFrame, endFrame, hour, min, unused) \
+ CMD_HH(unk, startFrame), \
+ CMD_HBB(endFrame, hour, min), \
+ CMD_W(unused)
+
+ /**
+ * ARGS
+ * CutsceneTerminatorDestination dest (d), s16 startFrame (s), s16 endFrame (e)
+ * FORMAT
+ * Capital U is Unused , endFrame duplicate
+ * 000003E8 00000001 ddddssss eeeeUUUU
+ * size = 0x10
+ */
+#define CS_TERMINATOR(dest, startFrame, endFrame) \
+ CS_CMD_TERMINATOR, 0x00000001, CMD_HH(dest, startFrame), CMD_HH(endFrame, endFrame)
+
+ /**
+ * Marks the end of a cutscene
+ */
+#define CS_END() 0xFFFFFFFF, 0x00000000
+
+#endif \ No newline at end of file