summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis <35883445+louist103@users.noreply.github.com>2023-10-28 01:17:47 -0400
committerlouist103 <35883445+louist103@users.noreply.github.com>2025-03-29 13:50:21 -0400
commit27a6ec6211a9cbc43613ae23869339cc4bc08bb9 (patch)
tree01bb356a30008981e7311d1d39c7a7764c4f31a1
parent34777a3141e84fe017ba79fba1988ecb7864d8a7 (diff)
MM Runnings
-rw-r--r--OTRExporter/AnimationExporter.cpp19
-rw-r--r--OTRExporter/CMakeLists.txt2
-rw-r--r--OTRExporter/DisplayListExporter.cpp29
-rw-r--r--OTRExporter/Main.cpp7
-rw-r--r--OTRExporter/RoomExporter.cpp7
-rw-r--r--OTRExporter/TextureAnimationExporter.cpp99
-rw-r--r--OTRExporter/TextureAnimationExporter.h12
7 files changed, 156 insertions, 19 deletions
diff --git a/OTRExporter/AnimationExporter.cpp b/OTRExporter/AnimationExporter.cpp
index bc8c473..32e47d0 100644
--- a/OTRExporter/AnimationExporter.cpp
+++ b/OTRExporter/AnimationExporter.cpp
@@ -1,5 +1,9 @@
#include "AnimationExporter.h"
#include <resource/type/Animation.h>
+#include <Globals.h>
+#include "DisplayListExporter.h"
+#undef FindResource
+
void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer)
{
@@ -14,7 +18,20 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary
{
writer->Write((uint32_t)SOH::AnimationType::Link);
writer->Write((uint16_t)linkAnim->frameCount);
- writer->Write((uint32_t)linkAnim->segmentAddress);
+ std::string name;
+ bool found = Globals::Instance->GetSegmentedPtrName((linkAnim->segmentAddress), res->parent, "", name, res->parent->workerID);
+ if (found)
+ {
+ if (name.at(0) == '&')
+ name.erase(0, 1);
+
+ writer->Write(StringHelper::Sprintf("__OTR__misc/link_animetion/%s", name.c_str()));
+ }
+ else
+ {
+ writer->Write("");
+ }
+ //writer->Write((uint32_t)linkAnim->segmentAddress);
}
else if (curveAnim != nullptr)
{
diff --git a/OTRExporter/CMakeLists.txt b/OTRExporter/CMakeLists.txt
index 1c9ecbf..04774d3 100644
--- a/OTRExporter/CMakeLists.txt
+++ b/OTRExporter/CMakeLists.txt
@@ -24,6 +24,7 @@ set(Header_Files
"SkeletonLimbExporter.h"
"TextExporter.h"
"TextureExporter.h"
+ "TextureAnimationExporter.h"
"VersionInfo.h"
"VtxExporter.h"
"z64cutscene.h"
@@ -51,6 +52,7 @@ set(Source_Files
"SkeletonLimbExporter.cpp"
"TextExporter.cpp"
"TextureExporter.cpp"
+ "TextureAnimationExporter.cpp"
"VersionInfo.cpp"
"VtxExporter.cpp"
)
diff --git a/OTRExporter/DisplayListExporter.cpp b/OTRExporter/DisplayListExporter.cpp
index 6cc659f..7077a6e 100644
--- a/OTRExporter/DisplayListExporter.cpp
+++ b/OTRExporter/DisplayListExporter.cpp
@@ -891,7 +891,10 @@ std::string OTRExporter_DisplayList::GetParentFolderName(ZResource* res)
}
else if (StringHelper::Contains(oName, "_room"))
{
- oName = StringHelper::Split(oName, "_room")[0] + "_scene";
+ if (Globals::Instance->game != ZGame::MM_RETAIL)
+ oName = StringHelper::Split(oName, "_room")[0] + "_scene";
+ else
+ oName = StringHelper::Split(oName, "_room")[0];
}
if (prefix != "")
@@ -905,21 +908,15 @@ std::string OTRExporter_DisplayList::GetPrefix(ZResource* res)
std::string oName = res->parent->GetOutName();
std::string prefix = "";
std::string xmlPath = StringHelper::Replace(res->parent->GetXmlFilePath().string(), "\\", "/");
-
- if (StringHelper::Contains(oName, "_scene") || StringHelper::Contains(oName, "_room")) {
- prefix = "scenes/shared";
-
- // Regex for xml paths that are dungeons with unique MQ variants (only the main dungeon, not boss rooms)
- std::regex dungeonsWithMQ(R"(((ydan)|(ddan)|(bdan)|(Bmori1)|(HIDAN)|(MIZUsin)|(jyasinzou)|(HAKAdan)|(HAKAdanCH)|(ice_doukutu)|(men)|(ganontika))\.xml)");
-
- if (StringHelper::Contains(xmlPath, "dungeons/") && std::regex_search(xmlPath, dungeonsWithMQ)) {
- if (Globals::Instance->rom->IsMQ()) {
- prefix = "scenes/mq";
- } else {
- prefix = "scenes/nonmq";
- }
- }
- }
+ // BENTODO bring in the existing OTRExporter changes from SoHs
+ if (StringHelper::Contains(oName, "_scene") || StringHelper::Contains(oName, "_room") || (StringHelper::Contains(res->parent->GetXmlFilePath().string(), "/scenes/") || StringHelper::Contains(res->parent->GetXmlFilePath().string(), "\\scenes\\"))) {
+ prefix = "scenes";
+ if (Globals::Instance->rom->IsMQ()) {
+ prefix += "/mq";
+ } else {
+ prefix += "/nonmq";
+ }
+ }
else if (StringHelper::Contains(xmlPath, "objects/"))
prefix = "objects";
else if (StringHelper::Contains(xmlPath, "textures/"))
diff --git a/OTRExporter/Main.cpp b/OTRExporter/Main.cpp
index 1df1373..bac4eab 100644
--- a/OTRExporter/Main.cpp
+++ b/OTRExporter/Main.cpp
@@ -17,6 +17,7 @@
#include "BlobExporter.h"
#include "MtxExporter.h"
#include "AudioExporter.h"
+#include "TextureAnimationExporter.h"
#include <Globals.h>
#include <Utils/DiskFile.h>
#include <Utils/Directory.h>
@@ -298,7 +299,10 @@ static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer)
}
else if (StringHelper::Contains(oName, "_room"))
{
- oName = StringHelper::Split(oName, "_room")[0] + "_scene";
+ if (Globals::Instance->game != ZGame::MM_RETAIL)
+ oName = StringHelper::Split(oName, "_room")[0] + "_scene";
+ else
+ oName = StringHelper::Split(oName, "_room")[0];
}
std::string fName = "";
@@ -383,6 +387,7 @@ void ImportExporters()
exporterSet->exporters[ZResourceType::Blob] = new OTRExporter_Blob();
exporterSet->exporters[ZResourceType::Mtx] = new OTRExporter_MtxExporter();
exporterSet->exporters[ZResourceType::Audio] = new OTRExporter_Audio();
+ exporterSet->exporters[ZResourceType::TextureAnimation] = new OTRExporter_TextureAnimation();
Globals::AddExporter("OTR", exporterSet);
diff --git a/OTRExporter/RoomExporter.cpp b/OTRExporter/RoomExporter.cpp
index 43e4185..db301ff 100644
--- a/OTRExporter/RoomExporter.cpp
+++ b/OTRExporter/RoomExporter.cpp
@@ -340,7 +340,12 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite
for (size_t 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 = OTRExporter_DisplayList::GetPathToRes(room, StringHelper::Sprintf("%s_room_%i", StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i));
+ std::string roomName;
+ if (Globals::Instance->game != ZGame::MM_RETAIL)
+ roomName = OTRExporter_DisplayList::GetPathToRes(room, StringHelper::Sprintf("%s_room_%i", StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i));
+ else
+ roomName = OTRExporter_DisplayList::GetPathToRes(room, StringHelper::Sprintf("%s_room_%02d", StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i));
+
writer->Write(roomName);
writer->Write(cmdRoom->romfile->rooms[i].virtualAddressStart);
writer->Write(cmdRoom->romfile->rooms[i].virtualAddressEnd);
diff --git a/OTRExporter/TextureAnimationExporter.cpp b/OTRExporter/TextureAnimationExporter.cpp
new file mode 100644
index 0000000..52acde9
--- /dev/null
+++ b/OTRExporter/TextureAnimationExporter.cpp
@@ -0,0 +1,99 @@
+#define NO_GDI
+#define WIN32_LEAN_AND_MEAN
+#include "ZFile.h"
+#include <Globals.h>
+#include "TextureAnimationExporter.h"
+#include "DisplayListExporter.h"
+
+#undef FindResource
+
+void OTRExporter_TextureAnimation::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer)
+{
+ auto* anim = (ZTextureAnimation*)res;
+ WriteHeader(res, outPath, writer, LUS::ResourceType::TSH_TexAnim, 0);
+
+ for (const auto& e : anim->entries) {
+ if (GETSEGNUM(e.paramsPtr) == 0x80)
+ int bp = 0;
+ auto* params = (ZTextureAnimationParams*)res->parent->FindResource(Seg2Filespace(e.paramsPtr, res->parent->baseAddress));
+ writer->Write(e.segment);
+ writer->Write((uint8_t)e.type);
+ switch ((TextureAnimationParamsType)e.type) {
+ case TextureAnimationParamsType::SingleScroll:
+ case TextureAnimationParamsType::DualScroll: {
+ auto* scrollParams = (TextureScrollingParams*)params;
+
+ writer->Write(scrollParams->count);
+ writer->Write(scrollParams->rows[0].xStep);
+ writer->Write(scrollParams->rows[0].yStep);
+ writer->Write(scrollParams->rows[0].width);
+ writer->Write(scrollParams->rows[0].height);
+ if (scrollParams->count == 2) {
+ writer->Write(scrollParams->rows[1].xStep);
+ writer->Write(scrollParams->rows[1].yStep);
+ writer->Write(scrollParams->rows[1].width);
+ writer->Write(scrollParams->rows[1].height);
+ }
+ break;
+ }
+
+ case TextureAnimationParamsType::ColorChange:
+ case TextureAnimationParamsType::ColorChangeLERP:
+ case TextureAnimationParamsType::ColorChangeLagrange: {
+ auto* colorParams = (TextureColorChangingParams*)params;
+ writer->Write(colorParams->animLength);
+ for (const auto f : colorParams->frameDataList) {
+ writer->Write(f);
+ }
+ writer->Write(colorParams->primColorList.size());
+ for (const auto prim : colorParams->primColorList) {
+ writer->Write(prim.r);
+ writer->Write(prim.g);
+ writer->Write(prim.b);
+ writer->Write(prim.a);
+ writer->Write(prim.lodFrac);
+ }
+ writer->Write(colorParams->envColorList.size());
+ for (const auto env : colorParams->envColorList) {
+ writer->Write(env.r);
+ writer->Write(env.g);
+ writer->Write(env.b);
+ writer->Write(env.a);
+ }
+ break;
+ }
+ case TextureAnimationParamsType::TextureCycle: {
+ auto* cycleParams = (TextureCyclingParams*)params;
+
+ writer->Write(cycleParams->cycleLength);
+ writer->Write(cycleParams->textureList.size());
+
+ for (const auto t : cycleParams->textureList) {
+ std::string name;
+ //ZTexture* tex = (ZTexture*)res->parent->FindResource(t & 0x00FFFFFF);
+ bool found = Globals::Instance->GetSegmentedPtrName(GETSEGOFFSET(t), res->parent, "", name, res->parent->workerID);
+ if (found)
+ {
+ if (name.at(0) == '&')
+ name.erase(0, 1);
+
+ writer->Write(OTRExporter_DisplayList::GetPathToRes(res, name));
+ }
+ else
+ {
+ writer->Write("");
+ }
+ }
+ writer->Write(cycleParams->textureIndexList.size());
+ for (const auto index : cycleParams->textureIndexList) {
+ writer->Write(index);
+ }
+ break;
+ }
+ case TextureAnimationParamsType::Empty: {
+ writer->Write(SEGMENTED_NULL);
+ break;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/OTRExporter/TextureAnimationExporter.h b/OTRExporter/TextureAnimationExporter.h
new file mode 100644
index 0000000..40b1983
--- /dev/null
+++ b/OTRExporter/TextureAnimationExporter.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "ZResource.h"
+#include "ZTextureAnimation.h"
+#include "Exporter.h"
+#include <utils/BinaryWriter.h>
+
+class OTRExporter_TextureAnimation : public OTRExporter
+{
+public:
+ virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override;
+}; \ No newline at end of file