summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2022-01-06 23:24:29 -0500
committerNicholas Estelami <NEstelami@users.noreply.github.com>2022-01-06 23:24:29 -0500
commitd06fb101439a7e5de28bb824b70992f97d91b54a (patch)
treeb2872764f0708595d3ba762ef8d94fe009c518be
parent6ac2cf0d0960a79f63b898101bd2c1cf72189559 (diff)
Array exporter updated to be a bit more flexible.
Cutscene exporter added (thanks Louist) Path Exporter added (untested) DList fixes
-rw-r--r--OTRExporter/ArrayExporter.cpp59
-rw-r--r--OTRExporter/CutsceneExporter.cpp26
-rw-r--r--OTRExporter/DisplayListExporter.cpp24
-rw-r--r--OTRExporter/Main.cpp2
-rw-r--r--OTRExporter/OTRExporter.vcxproj2
-rw-r--r--OTRExporter/OTRExporter.vcxproj.filters6
-rw-r--r--OTRExporter/PathExporter.cpp18
-rw-r--r--OTRExporter/PathExporter.h12
-rw-r--r--OTRExporter/RoomExporter.cpp34
9 files changed, 166 insertions, 17 deletions
diff --git a/OTRExporter/ArrayExporter.cpp b/OTRExporter/ArrayExporter.cpp
index 0fc097c..7fc73fa 100644
--- a/OTRExporter/ArrayExporter.cpp
+++ b/OTRExporter/ArrayExporter.cpp
@@ -3,13 +3,60 @@
void OTRExporter_Array::Save(ZResource* res, fs::path outPath, BinaryWriter* writer)
{
ZArray* arr = (ZArray*)res;
- //There has to be a better way
- if (arr->resList[0]->GetResourceType() == ZResourceType::Vertex) {
- OTRExporter_Vtx exporter;
- exporter.SaveArr(arr->resList,writer);
- //exporter.count = arr->arrayCnt;
- //exporter.Save(res, outPath, writer);
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRArray);
+
+ writer->Write((uint32_t)arr->resList[0]->GetResourceType());
+ writer->Write((uint32_t)arr->arrayCnt);
+
+ for (int i = 0; i < arr->arrayCnt; i++)
+ {
+ ZScalar* scal = (ZScalar*)arr->resList[i];
+
+ writer->Write((uint32_t)scal->scalarType);
+
+ switch (scal->scalarType)
+ {
+ case ZScalarType::ZSCALAR_U8:
+ writer->Write(scal->scalarData.u8);
+ break;
+ case ZScalarType::ZSCALAR_S8:
+ writer->Write(scal->scalarData.s8);
+ break;
+ case ZScalarType::ZSCALAR_U16:
+ writer->Write(scal->scalarData.u16);
+ break;
+ case ZScalarType::ZSCALAR_S16:
+ writer->Write(scal->scalarData.s16);
+ break;
+ case ZScalarType::ZSCALAR_S32:
+ writer->Write(scal->scalarData.s32);
+ break;
+ case ZScalarType::ZSCALAR_U32:
+ writer->Write(scal->scalarData.u32);
+ break;
+ case ZScalarType::ZSCALAR_S64:
+ writer->Write(scal->scalarData.s64);
+ break;
+ case ZScalarType::ZSCALAR_U64:
+ writer->Write(scal->scalarData.u64);
+ break;
+ // OTRTODO: ADD OTHER TYPES
+ }
}
+
+ ////There has to be a better way™
+ //if (arr->resList[0]->GetResourceType() == ZResourceType::Vertex)
+ //{
+ // OTRExporter_Vtx exporter;
+ // exporter.SaveArr(arr->resList,writer);
+
+ // //exporter.count = arr->arrayCnt;
+ // //exporter.Save(res, outPath, writer);
+ //}
+ //else if (arr->resList[0]->GetResourceType() == ZResourceType::Vector)
+ //{
+ // WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRVtx);
+ //}
} \ No newline at end of file
diff --git a/OTRExporter/CutsceneExporter.cpp b/OTRExporter/CutsceneExporter.cpp
index 63e5775..a39505e 100644
--- a/OTRExporter/CutsceneExporter.cpp
+++ b/OTRExporter/CutsceneExporter.cpp
@@ -10,11 +10,17 @@ void OTRExporter_Cutscene::Save(ZResource* res, fs::path outPath, BinaryWriter*
writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+ //writer->Write((uint32_t)cs->commands.size() + 2 + 2);
+ writer->Write((uint32_t)0);
+
+ int currentStream = writer->GetBaseAddress();
+
writer->Write(CS_BEGIN_CUTSCENE(cs->numCommands, cs->endFrame));
- for (size_t i = 0; i < cs->commands.size(); i++)
+ for (size_t i = 0; i < cs->commands.size(); i++)
{
- switch ((CutsceneCommands)cs->commands[i]->commandID) {
+ switch ((CutsceneCommands)cs->commands[i]->commandID)
+ {
case CutsceneCommands::SetCameraPos:
{
writer->Write(CS_CMD_CAM_EYE);
@@ -176,6 +182,8 @@ void OTRExporter_Cutscene::Save(ZResource* res, fs::path outPath, BinaryWriter*
}
case CutsceneCommands::SetSceneTransFX:
{
+ CutsceneCommandSceneTransFX* cmdTFX = (CutsceneCommandSceneTransFX*)cs->commands[i];
+
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));
@@ -268,11 +276,15 @@ void OTRExporter_Cutscene::Save(ZResource* res, fs::path outPath, BinaryWriter*
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);
}
-
}
+
+ //CS_END
+ writer->Write(0xFFFFFFFF);
+ writer->Write((uint32_t)0);
+
+ int endStream = writer->GetBaseAddress();
+ writer->Seek(currentStream - 4, SeekOffsetType::Start);
+ writer->Write((uint32_t)((endStream - currentStream) / 4));
+ writer->Seek(endStream, SeekOffsetType::Start);
} \ No newline at end of file
diff --git a/OTRExporter/DisplayListExporter.cpp b/OTRExporter/DisplayListExporter.cpp
index be0dded..546da76 100644
--- a/OTRExporter/DisplayListExporter.cpp
+++ b/OTRExporter/DisplayListExporter.cpp
@@ -98,6 +98,17 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
word1 = value.words.w1;
}
break;
+ case G_MODIFYVTX:
+ {
+ int32_t ww = (data & 0x00FF000000000000ULL) >> 48;
+ int32_t nnnn = (data & 0x0000FFFF00000000ULL) >> 32;
+ int32_t vvvvvvvv = (data & 0x00000000FFFFFFFFULL);
+
+ Gfx value = gsSPModifyVertex(nnnn / 2, ww, vvvvvvvv);
+ word0 = value.words.w0;
+ word1 = value.words.w1;
+ }
+ break;
default:
{
printf("Undefined opcode: %02X\n", opcode);
@@ -318,11 +329,18 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
word1 = test.words.w1;
}
break;
- /*case G_QUAD:
+ case G_QUAD:
{
- gsSP1Quadrangle()
+ int32_t aa = ((data & 0x00FF000000000000ULL) >> 48) / 2;
+ int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2;
+ int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2;
+ int32_t dd = ((data & 0x000000000000FFULL)) / 2;
+
+ Gfx test = gsSP1Quadrangle(aa, bb, cc, dd, 0);
+ word0 = test.words.w0;
+ word1 = test.words.w1;
}
- break;*/
+ break;
case G_SETPRIMCOLOR:
{
int32_t mm = (data & 0x0000FF0000000000) >> 40;
diff --git a/OTRExporter/Main.cpp b/OTRExporter/Main.cpp
index 7f3e644..16db56f 100644
--- a/OTRExporter/Main.cpp
+++ b/OTRExporter/Main.cpp
@@ -12,6 +12,7 @@
#include "VtxExporter.h"
#include "AnimationExporter.h"
#include "CutsceneExporter.h"
+#include "PathExporter.h"
#include <Globals.h>
#include <Utils/File.h>
#include <Utils/Directory.h>
@@ -182,6 +183,7 @@ static void ImportExporters()
exporterSet->exporters[ZResourceType::Cutscene] = new OTRExporter_Cutscene();
exporterSet->exporters[ZResourceType::Vertex] = new OTRExporter_Vtx();
exporterSet->exporters[ZResourceType::Array] = new OTRExporter_Array();
+ exporterSet->exporters[ZResourceType::Path] = new OTRExporter_Path();
Globals::AddExporter("OTR", exporterSet);
}
diff --git a/OTRExporter/OTRExporter.vcxproj b/OTRExporter/OTRExporter.vcxproj
index 272913d..ddaa07f 100644
--- a/OTRExporter/OTRExporter.vcxproj
+++ b/OTRExporter/OTRExporter.vcxproj
@@ -30,6 +30,7 @@
<ClInclude Include="OTRExporter.h" />
<ClInclude Include="OTRSkeletonExporter.h" />
<ClInclude Include="OTRSkeletonLimbExporter.h" />
+ <ClInclude Include="PathExporter.h" />
<ClInclude Include="PlayerAnimationExporter.h" />
<ClInclude Include="RoomExporter.h" />
<ClInclude Include="TextureExporter.h" />
@@ -48,6 +49,7 @@
<ClCompile Include="OTRExporter.cpp" />
<ClCompile Include="OTRSkeletonExporter.cpp" />
<ClCompile Include="OTRSkeletonLimbExporter.cpp" />
+ <ClCompile Include="PathExporter.cpp" />
<ClCompile Include="PlayerAnimationExporter.cpp" />
<ClCompile Include="RoomExporter.cpp" />
<ClCompile Include="TextureExporter.cpp" />
diff --git a/OTRExporter/OTRExporter.vcxproj.filters b/OTRExporter/OTRExporter.vcxproj.filters
index c93ed03..eff628c 100644
--- a/OTRExporter/OTRExporter.vcxproj.filters
+++ b/OTRExporter/OTRExporter.vcxproj.filters
@@ -66,6 +66,9 @@
<ClInclude Include="command_macros_base.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="PathExporter.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CollisionExporter.cpp">
@@ -110,5 +113,8 @@
<ClCompile Include="CutsceneExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="PathExporter.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/OTRExporter/PathExporter.cpp b/OTRExporter/PathExporter.cpp
new file mode 100644
index 0000000..ed00646
--- /dev/null
+++ b/OTRExporter/PathExporter.cpp
@@ -0,0 +1,18 @@
+#include "PathExporter.h"
+#include "../ZAPD/ZFile.h"
+
+void OTRExporter_Path::Save(ZResource* res, fs::path outPath, BinaryWriter* writer)
+{
+ ZPath* path = (ZPath*)res;
+
+ WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRPath);
+
+ writer->Write((uint32_t)path->pathways[0].points.size());
+
+ for (int i = 0; i < path->pathways[0].points.size(); i++)
+ {
+ writer->Write(path->pathways[0].points[i].scalars[0].scalarData.s16);
+ writer->Write(path->pathways[0].points[i].scalars[1].scalarData.s16);
+ writer->Write(path->pathways[0].points[i].scalars[2].scalarData.s16);
+ }
+} \ No newline at end of file
diff --git a/OTRExporter/PathExporter.h b/OTRExporter/PathExporter.h
new file mode 100644
index 0000000..50beb08
--- /dev/null
+++ b/OTRExporter/PathExporter.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "ZResource.h"
+#include "ZPath.h"
+#include "OTRExporter.h"
+#include <Utils/BinaryWriter.h>
+
+class OTRExporter_Path : 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/RoomExporter.cpp b/OTRExporter/RoomExporter.cpp
index 07e448a..5c62a81 100644
--- a/OTRExporter/RoomExporter.cpp
+++ b/OTRExporter/RoomExporter.cpp
@@ -30,6 +30,8 @@
#include "TextureExporter.h"
#include "Main.h"
#include <ZRoom/Commands/SetCutscenes.h>
+#include "CutsceneExporter.h"
+#include <ZRoom/Commands/SetTransitionActorList.h>
#undef FindResource
void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter* writer)
@@ -48,6 +50,27 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
switch (cmd->cmdID)
{
+ case RoomCommand::SetTransitionActorList:
+ {
+ SetTransitionActorList* cmdTrans = (SetTransitionActorList*)cmd;
+
+ writer->Write((uint32_t)cmdTrans->transitionActors.size());
+
+ for (const TransitionActorEntry& entry : cmdTrans->transitionActors)
+ {
+ writer->Write(entry.frontObjectRoom);
+ writer->Write(entry.frontTransitionReaction);
+ writer->Write(entry.backObjectRoom);
+ writer->Write(entry.backTransitionReaction);
+ writer->Write(entry.actorNum);
+ writer->Write(entry.posX);
+ writer->Write(entry.posY);
+ writer->Write(entry.posZ);
+ writer->Write(entry.rotY);
+ writer->Write(entry.initVar);
+ }
+ }
+ break;
case RoomCommand::SetActorList:
{
SetActorList* cmdSetActorList = (SetActorList*)cmd;
@@ -424,7 +447,16 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
std::string listName;
Globals::Instance->GetSegmentedPtrName(cmdSetCutscenes->cmdArg2, room->parent, "CutsceneData", listName);
- writer->Write(listName);
+ std::string fName = StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), listName.c_str());
+ writer->Write(fName);
+
+ MemoryStream* csStream = new MemoryStream();
+ BinaryWriter csWriter = BinaryWriter(csStream);
+ OTRExporter_Cutscene cs;
+ cs.Save(cmdSetCutscenes->cutscenes[0], "", &csWriter);
+
+ //std::string fName = OTRExporter_DisplayList::GetPathToRes(res, vtxDecl->varName);
+ otrArchive->AddFile(fName, (uintptr_t)csStream->ToVector().data(), csWriter.GetBaseAddress());
}
break;
case RoomCommand::EndMarker: