Spock Bravo -> Develop

This commit is contained in:
briaguya 2023-05-11 00:15:37 -04:00 committed by GitHub
commit 7dff8b6efc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
335 changed files with 6293 additions and 8936 deletions

View File

@ -5,8 +5,8 @@ set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
project(Ship VERSION 7.0.0 LANGUAGES C CXX)
set(PROJECT_BUILD_NAME "Spock Alfa" CACHE STRING "")
project(Ship VERSION 7.0.1 LANGUAGES C CXX)
set(PROJECT_BUILD_NAME "Spock Bravo" CACHE STRING "")
set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "")
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT soh)

View File

@ -5,20 +5,20 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary
{
ZAnimation* anim = (ZAnimation*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Animation);
WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Animation);
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)Ship::AnimationType::Link);
writer->Write((uint32_t)LUS::AnimationType::Link);
writer->Write((uint16_t)linkAnim->frameCount);
writer->Write((uint32_t)linkAnim->segmentAddress);
}
else if (curveAnim != nullptr)
{
writer->Write((uint32_t)Ship::AnimationType::Curve);
writer->Write((uint32_t)LUS::AnimationType::Curve);
writer->Write((uint16_t)curveAnim->frameCount);
writer->Write((uint32_t)curveAnim->refIndexArr.size());
@ -44,7 +44,7 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary
}
else if (normalAnim != nullptr)
{
writer->Write((uint32_t)Ship::AnimationType::Normal);
writer->Write((uint32_t)LUS::AnimationType::Normal);
writer->Write((uint16_t)normalAnim->frameCount);
writer->Write((uint32_t)normalAnim->rotationValues.size());
@ -65,6 +65,6 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary
}
else
{
writer->Write((uint32_t)Ship::AnimationType::Legacy);
writer->Write((uint32_t)LUS::AnimationType::Legacy);
}
}

View File

@ -5,7 +5,7 @@ void OTRExporter_Array::Save(ZResource* res, const fs::path& outPath, BinaryWrit
{
ZArray* arr = (ZArray*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::Array);
WriteHeader(res, outPath, writer, LUS::ResourceType::Array);
writer->Write((uint32_t)arr->resList[0]->GetResourceType());
writer->Write((uint32_t)arr->arrayCnt);

View File

@ -2,7 +2,7 @@
#include "Main.h"
#include <Utils/MemoryStream.h>
#include <Globals.h>
#include <Utils/File.h>
#include <Utils/DiskFile.h>
#include "DisplayListExporter.h"
void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* entry, std::map<uint32_t, SampleEntry*> samples, BinaryWriter* writer)
@ -29,7 +29,7 @@ void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* en
void OTRExporter_Audio::WriteSampleEntry(SampleEntry* entry, BinaryWriter* writer)
{
WriteHeader(nullptr, "", writer, Ship::ResourceType::SOH_AudioSample, Ship::Version::Rachael);
WriteHeader(nullptr, "", writer, LUS::ResourceType::SOH_AudioSample, 2);
writer->Write(entry->codec);
writer->Write(entry->medium);
@ -81,7 +81,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
{
ZAudio* audio = (ZAudio*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Audio, Ship::Version::Rachael);
WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Audio, 2);
// Write Samples as individual files
for (auto pair : audio->samples)
@ -114,7 +114,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
MemoryStream* fntStream = new MemoryStream();
BinaryWriter fntWriter = BinaryWriter(fntStream);
WriteHeader(nullptr, "", &fntWriter, Ship::ResourceType::SOH_AudioSoundFont, Ship::Version::Rachael);
WriteHeader(nullptr, "", &fntWriter, LUS::ResourceType::SOH_AudioSoundFont, 2);
fntWriter.Write((uint32_t)i);
fntWriter.Write(audio->soundFontTable[i].medium);
@ -173,7 +173,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
MemoryStream* seqStream = new MemoryStream();
BinaryWriter seqWriter = BinaryWriter(seqStream);
WriteHeader(nullptr, "", &seqWriter, Ship::ResourceType::SOH_AudioSequence, Ship::Version::Rachael);
WriteHeader(nullptr, "", &seqWriter, LUS::ResourceType::SOH_AudioSequence, 2);
seqWriter.Write((uint32_t)seq.size());
seqWriter.Write(seq.data(), seq.size());

View File

@ -5,7 +5,7 @@ void OTRExporter_Background::Save(ZResource* res, const fs::path& outPath, Binar
{
ZBackground* bg = (ZBackground*)res;
WriteHeader(bg, outPath, writer, Ship::ResourceType::SOH_Background);
WriteHeader(bg, outPath, writer, LUS::ResourceType::SOH_Background);
writer->Write((uint32_t)bg->GetRawDataSize());

View File

@ -5,7 +5,7 @@ void OTRExporter_Blob::Save(ZResource* res, const fs::path& outPath, BinaryWrite
{
ZBlob* blob = (ZBlob*)res;
WriteHeader(blob, outPath, writer, Ship::ResourceType::Blob);
WriteHeader(blob, outPath, writer, LUS::ResourceType::Blob);
auto start = std::chrono::steady_clock::now();

View File

@ -5,7 +5,7 @@ void OTRExporter_Collision::Save(ZResource* res, const fs::path& outPath, Binary
{
ZCollisionHeader* col = (ZCollisionHeader*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_CollisionHeader);
WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_CollisionHeader);
writer->Write(col->absMinX);
writer->Write(col->absMinY);
@ -32,16 +32,18 @@ void OTRExporter_Collision::Save(ZResource* res, const fs::path& outPath, Binary
writer->Write(col->polygons[i].vtxA);
writer->Write(col->polygons[i].vtxB);
writer->Write(col->polygons[i].vtxC);
writer->Write(col->polygons[i].a);
writer->Write(col->polygons[i].b);
writer->Write(col->polygons[i].c);
writer->Write(col->polygons[i].d);
writer->Write(col->polygons[i].normX);
writer->Write(col->polygons[i].normY);
writer->Write(col->polygons[i].normZ);
writer->Write(col->polygons[i].dist);
}
writer->Write((uint32_t)col->polygonTypes.size());
writer->Write((uint32_t)col->PolygonTypes.size());
for (uint16_t i = 0; i < col->polygonTypes.size(); i++)
writer->Write(col->polygonTypes[i]);
for (uint16_t i = 0; i < col->PolygonTypes.size(); i++) {
writer->Write(col->PolygonTypes[i].data[1]);
writer->Write(col->PolygonTypes[i].data[0]);
}
writer->Write((uint32_t)col->camData->entries.size());

View File

@ -5,12 +5,11 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
{
ZCutscene* cs = (ZCutscene*)res;
WriteHeader(cs, outPath, writer, Ship::ResourceType::SOH_Cutscene);
WriteHeader(cs, outPath, writer, LUS::ResourceType::SOH_Cutscene);
//writer->Write((uint32_t)cs->commands.size() + 2 + 2);
writer->Write((uint32_t)0);
int currentStream = writer->GetBaseAddress();
const auto currentStream = writer->GetBaseAddress();
writer->Write(CS_BEGIN_CUTSCENE(cs->numCommands, cs->endFrame));
@ -26,12 +25,13 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame));
writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000));
for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries)
for (const auto& e : cs->commands[i]->entries)
{
writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame));
writer->Write(e->viewAngle);
writer->Write(CMD_HH(e->posX, e->posY));
writer->Write(CMD_HH(e->posZ, e->unused));
CutsceneCameraPoint* point = (CutsceneCameraPoint*)e;
writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame));
writer->Write(point->viewAngle);
writer->Write(CMD_HH(point->posX, point->posY));
writer->Write(CMD_HH(point->posZ, point->unused));
}
}
break;
@ -43,51 +43,54 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
writer->Write(CMD_HH(0x0001, cmdCamPos->startFrame));
writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000));
for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries)
for (const auto& e : cs->commands[i]->entries)
{
writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame));
writer->Write(e->viewAngle);
writer->Write(CMD_HH(e->posX, e->posY));
writer->Write(CMD_HH(e->posZ, e->unused));
CutsceneCameraPoint* point = (CutsceneCameraPoint*)e;
writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame));
writer->Write(point->viewAngle);
writer->Write(CMD_HH(point->posX, point->posY));
writer->Write(CMD_HH(point->posZ, point->unused));
}
break;
}
case (uint32_t)CutsceneCommands::SpecialAction:
case (uint32_t)CutsceneCommands::Misc:
{
writer->Write(CS_CMD_MISC);
writer->Write((uint32_t)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((uint32_t)CMD_W((cs->commands[i])->entries.size()));
for (const auto& e : 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));
CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e;
writer->Write(CMD_HH(cmd->base, cmd->startFrame));
writer->Write(CMD_HH(cmd->endFrame, cmd->pad));
writer->Write(CMD_W(cmd->unused1));
writer->Write(CMD_W(cmd->unused2));
writer->Write(CMD_W(cmd->unused3));
writer->Write(CMD_W(cmd->unused4));
writer->Write(CMD_W(cmd->unused5));
writer->Write(CMD_W(cmd->unused6));
writer->Write(CMD_W(cmd->unused7));
writer->Write(CMD_W(cmd->unused8));
writer->Write(CMD_W(cmd->unused9));
writer->Write(CMD_W(cmd->unused10));
}
break;
}
case (uint32_t)CutsceneCommands::SetLighting:
{
writer->Write(CS_CMD_SET_LIGHTING);
writer->Write((uint32_t)CMD_W(((CutsceneCommandEnvLighting*)cs->commands[i])->entries.size()));
for (auto& e : ((CutsceneCommandEnvLighting*)cs->commands[i])->entries)
writer->Write((uint32_t)CMD_W((cs->commands[i])->entries.size()));
for (const auto& e : 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));
CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e;
writer->Write(CMD_HH(cmd->base, cmd->startFrame));
writer->Write(CMD_HH(cmd->endFrame, cmd->pad));
writer->Write(CMD_W(cmd->unused1));
writer->Write(CMD_W(cmd->unused2));
writer->Write(CMD_W(cmd->unused3));
writer->Write(CMD_W(cmd->unused4));
writer->Write(CMD_W(cmd->unused5));
writer->Write(CMD_W(cmd->unused6));
writer->Write(CMD_W(cmd->unused7));
writer->Write((uint32_t)0x0);
writer->Write((uint32_t)0x0);
writer->Write((uint32_t)0x0);
@ -102,12 +105,13 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame));
writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000));
for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries)
for (const auto& e : cs->commands[i]->entries)
{
writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame));
writer->Write(e->viewAngle);
writer->Write(CMD_HH(e->posX, e->posY));
writer->Write(CMD_HH(e->posZ, e->unused));
CutsceneCameraPoint* point = (CutsceneCameraPoint*)e;
writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame));
writer->Write(point->viewAngle);
writer->Write(CMD_HH(point->posX, point->posY));
writer->Write(CMD_HH(point->posZ, point->unused));
}
break;
}
@ -119,12 +123,13 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame));
writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000));
for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries)
for (const auto& e : cs->commands[i]->entries)
{
writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame));
writer->Write(e->viewAngle);
writer->Write(CMD_HH(e->posX, e->posY));
writer->Write(CMD_HH(e->posZ, e->unused));
CutsceneCameraPoint* point = (CutsceneCameraPoint*)e;
writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame));
writer->Write(point->viewAngle);
writer->Write(CMD_HH(point->posX, point->posY));
writer->Write(CMD_HH(point->posZ, point->unused));
}
break;
}
@ -137,24 +142,26 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
case (uint32_t)CutsceneCommands::Cmd09:
{
writer->Write(CS_CMD_09);
writer->Write((uint32_t)CMD_W(((CutsceneCommandUnknown9*)cs->commands[i])->entries.size()));
writer->Write((uint32_t)CMD_W(((CutsceneCommand_Rumble*)cs->commands[i])->entries.size()));
for (auto& e : ((CutsceneCommandUnknown9*)cs->commands[i])->entries)
for (const auto& e : 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));
CutsceneSubCommandEntry_Rumble* r = (CutsceneSubCommandEntry_Rumble*)e;
writer->Write(CMD_HH(r->base, r->startFrame));
writer->Write(CMD_HBB(e->endFrame, r->unk_06, r->unk_07));
writer->Write(CMD_BBH(r->unk_08, r->unk_09, r->unk_0A));
}
break;
}
case 0x15:
case (uint32_t)CutsceneCommands::Unknown:
case 0x15://Both unused in OoT
case 0x1A://(uint32_t)CutsceneCommands::Unknown:
{
#if 0
CutsceneCommandUnknown* cmdUnk = (CutsceneCommandUnknown*)cs->commands[i];
writer->Write((uint32_t)cs->commands[i]->commandID);
writer->Write((uint32_t)cmdUnk->entries.size());
for (auto e : cmdUnk->entries)
for (const auto e : cmdUnk->entries)
{
writer->Write(CMD_W(e->unused0));
writer->Write(CMD_W(e->unused1));
@ -169,31 +176,33 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
writer->Write(CMD_W(e->unused10));
writer->Write(CMD_W(e->unused11));
}
#endif
}
break;
case (uint32_t)CutsceneCommands::Textbox:
{
writer->Write(CS_CMD_TEXTBOX);
writer->Write((uint32_t)CMD_W(((CutsceneCommandTextbox*)cs->commands[i])->entries.size()));
writer->Write((uint32_t)CMD_W((cs->commands[i])->entries.size()));
for (auto& e : ((CutsceneCommandTextbox*)cs->commands[i])->entries)
for (const auto& e : cs->commands[i]->entries)
{
if (e->base == 0xFFFF) // CS_TEXT_NONE
CutsceneSubCommandEntry_TextBox* textBox = (CutsceneSubCommandEntry_TextBox*)e;
if (textBox->base == 0xFFFF) // CS_TEXT_NONE
{
writer->Write(CMD_HH(0xFFFF, e->startFrame));
writer->Write(CMD_HH(e->endFrame, 0xFFFF));
writer->Write(CMD_HH(0xFFFF, textBox->startFrame));
writer->Write(CMD_HH(textBox->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));
writer->Write(CMD_HH(textBox->base, textBox->startFrame));
writer->Write(CMD_HH(textBox->endFrame, textBox->type));
writer->Write(CMD_HH(textBox->textId1, textBox->textId2));
}
}
break;
}
case (uint32_t)CutsceneCommands::SetActorAction0:
case 10: //ActorAction0
case (uint32_t)CutsceneCommands::SetActorAction1:
case 17:
case 18:
@ -292,11 +301,12 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
case (uint32_t)CutsceneCommands::SetActorAction10:
{
writer->Write((uint32_t)(CutsceneCommands)cs->commands[i]->commandID);
writer->Write((uint32_t)CMD_W(((CutsceneCommandActorAction*)cs->commands[i])->entries.size()));
writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size()));
for (auto& actorAct : ((CutsceneCommandActorAction*)cs->commands[i])->entries)
for (const auto& e : cs->commands[i]->entries)
{
writer->Write(CMD_HH(actorAct->action, actorAct->startFrame));
CutsceneSubCommandEntry_ActorAction* actorAct = (CutsceneSubCommandEntry_ActorAction*)e;
writer->Write(CMD_HH(actorAct->base, actorAct->startFrame));
writer->Write(CMD_HH(actorAct->endFrame, actorAct->rotX));
writer->Write(CMD_HH(actorAct->rotY, actorAct->rotZ));
writer->Write(CMD_W(actorAct->startPosX));
@ -322,24 +332,23 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
writer->Write(CMD_HH((((CutsceneCommandSceneTransFX*)cs->commands[i])->endFrame), ((CutsceneCommandSceneTransFX*)cs->commands[i])->endFrame));
break;
}
case (uint32_t)CutsceneCommands::Nop: //Not used in OOT
break;
case (uint32_t)CutsceneCommands::PlayBGM:
{
writer->Write(CS_CMD_PLAYBGM);
writer->Write((uint32_t)CMD_W(((CutsceneCommandPlayBGM*)cs->commands[i])->entries.size()));
writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size()));
for (auto& e : ((CutsceneCommandPlayBGM*)cs->commands[i])->entries)
for (const auto& e : 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->unknown1));
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));
CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e;
writer->Write(CMD_HH(cmd->base, cmd->startFrame));
writer->Write(CMD_HH(cmd->endFrame, cmd->pad));
writer->Write(CMD_W(cmd->unused1));
writer->Write(CMD_W(cmd->unused2));
writer->Write(CMD_W(cmd->unused3));
writer->Write(CMD_W(cmd->unused4));
writer->Write(CMD_W(cmd->unused5));
writer->Write(CMD_W(cmd->unused6));
writer->Write(CMD_W(cmd->unused7));
writer->Write((uint32_t)0);
writer->Write((uint32_t)0);
writer->Write((uint32_t)0);
@ -349,19 +358,20 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
case (uint32_t)CutsceneCommands::StopBGM:
{
writer->Write(CS_CMD_STOPBGM);
writer->Write((uint32_t)CMD_W(((CutsceneCommandStopBGM*)cs->commands[i])->entries.size()));
writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size()));
for (auto& e : ((CutsceneCommandStopBGM*)cs->commands[i])->entries)
for (const auto& e : 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->unknown1));
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));
CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e;
writer->Write(CMD_HH(cmd->base, cmd->startFrame));
writer->Write(CMD_HH(cmd->endFrame, cmd->pad));
writer->Write(CMD_W(cmd->unused1));
writer->Write(CMD_W(cmd->unused2));
writer->Write(CMD_W(cmd->unused3));
writer->Write(CMD_W(cmd->unused4));
writer->Write(CMD_W(cmd->unused5));
writer->Write(CMD_W(cmd->unused6));
writer->Write(CMD_W(cmd->unused7));
writer->Write((uint32_t)0);
writer->Write((uint32_t)0);
writer->Write((uint32_t)0);
@ -371,19 +381,20 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
case (uint32_t)CutsceneCommands::FadeBGM:
{
writer->Write(CS_CMD_FADEBGM);
writer->Write((uint32_t)CMD_W(((CutsceneCommandFadeBGM*)cs->commands[i])->entries.size()));
writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size()));
for (auto& e : ((CutsceneCommandFadeBGM*)cs->commands[i])->entries)
for (const auto& e : 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->unknown1));
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));
CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e;
writer->Write(CMD_HH(cmd->base, cmd->startFrame));
writer->Write(CMD_HH(cmd->endFrame, cmd->pad));
writer->Write(CMD_W(cmd->unused1));
writer->Write(CMD_W(cmd->unused2));
writer->Write(CMD_W(cmd->unused3));
writer->Write(CMD_W(cmd->unused4));
writer->Write(CMD_W(cmd->unused5));
writer->Write(CMD_W(cmd->unused6));
writer->Write(CMD_W(cmd->unused7));
writer->Write((uint32_t)0);
writer->Write((uint32_t)0);
writer->Write((uint32_t)0);
@ -393,22 +404,24 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
case (uint32_t)CutsceneCommands::SetTime:
{
writer->Write(CS_CMD_SETTIME);
writer->Write((uint32_t)CMD_W(((CutsceneCommandDayTime*)cs->commands[i])->entries.size()));
writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size()));
for (auto& e : ((CutsceneCommandDayTime*)cs->commands[i])->entries)
for (const auto& e : cs->commands[i]->entries)
{
writer->Write(CMD_HH(e->base, e->startFrame));
writer->Write(CMD_HBB(e->endFrame, e->hour, e->minute));
writer->Write((uint32_t)CMD_W(e->unused));
CutsceneSubCommandEntry_SetTime* t = (CutsceneSubCommandEntry_SetTime*)e;
writer->Write(CMD_HH(t->base, t->startFrame));
writer->Write(CMD_HBB(t->endFrame, t->hour, t->minute));
writer->Write((uint32_t)CMD_W(t->unk_08));
}
break;
}
case (uint32_t)CutsceneCommands::Terminator:
{
CutsceneCommand_Terminator* t = (CutsceneCommand_Terminator*)cs->commands[i];
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));
writer->Write(CMD_HH(t->base, t->startFrame));
writer->Write(CMD_HH(t->endFrame, t->endFrame));
break;
}
default:
@ -424,8 +437,8 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
writer->Write(0xFFFFFFFF);
writer->Write((uint32_t)0);
int endStream = writer->GetBaseAddress();
writer->Seek(currentStream - 4, SeekOffsetType::Start);
const auto endStream = writer->GetBaseAddress();
writer->Seek((uint32_t)currentStream - 4, SeekOffsetType::Start);
writer->Write((uint32_t)((endStream - currentStream) / 4));
writer->Seek(endStream, SeekOffsetType::Start);
writer->Seek((uint32_t)endStream, SeekOffsetType::Start);
}

View File

@ -10,7 +10,7 @@
#include <iostream>
#include <string>
#include "MtxExporter.h"
#include <Utils/File.h>
#include <Utils/DiskFile.h>
#include "VersionInfo.h"
#define GFX_SIZE 8
@ -50,7 +50,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
//printf("Exporting DList %s\n", dList->GetName().c_str());
WriteHeader(res, outPath, writer, Ship::ResourceType::DisplayList);
WriteHeader(res, outPath, writer, LUS::ResourceType::DisplayList);
while (writer->GetBaseAddress() % 8 != 0)
writer->Write((uint8_t)0xFF);
@ -356,7 +356,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
//std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str());
std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str());
if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName))
if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName))
{
MemoryStream* dlStream = new MemoryStream();
BinaryWriter dlWriter = BinaryWriter(dlStream);
@ -442,7 +442,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
//std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str());
std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str());
if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName))
if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName))
{
MemoryStream* dlStream = new MemoryStream();
BinaryWriter dlWriter = BinaryWriter(dlStream);
@ -767,7 +767,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
word0 = hash >> 32;
word1 = hash & 0xFFFFFFFF;
if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName))
if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName))
{
// Write vertices to file
MemoryStream* vtxStream = new MemoryStream();
@ -786,7 +786,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
}
// OTRTODO: Once we aren't relying on text representations, we should call ArrayExporter...
OTRExporter::WriteHeader(nullptr, "", &vtxWriter, Ship::ResourceType::Array);
OTRExporter::WriteHeader(nullptr, "", &vtxWriter, LUS::ResourceType::Array);
vtxWriter.Write((uint32_t)ZResourceType::Vertex);
vtxWriter.Write((uint32_t)arrCnt);

View File

@ -1,7 +1,7 @@
#include "Exporter.h"
#include "VersionInfo.h"
void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, Ship::Version resVersion)
void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, LUS::ResourceType resType, int32_t resVersion)
{
writer->Write((uint8_t)Endianness::Little); // 0x00
writer->Write((uint8_t)0); // 0x01

View File

@ -1,6 +1,7 @@
#pragma once
#include "ZResource.h"
#include "ZArray.h"
#include "stdint.h"
//#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
#include <libultraship/bridge.h>
@ -9,5 +10,5 @@
class OTRExporter : public ZResourceExporter
{
protected:
static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, Ship::Version resVersion = MAJOR_VERSION);
static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, LUS::ResourceType resType, int32_t resVersion = 0);
};

View File

@ -18,7 +18,7 @@
#include "MtxExporter.h"
#include "AudioExporter.h"
#include <Globals.h>
#include <Utils/File.h>
#include <Utils/DiskFile.h>
#include <Utils/Directory.h>
#include <Utils/MemoryStream.h>
#include <Utils/BinaryWriter.h>
@ -26,7 +26,7 @@
#include <mutex>
std::string otrFileName = "oot.otr";
std::shared_ptr<Ship::Archive> otrArchive;
std::shared_ptr<LUS::Archive> otrArchive;
BinaryWriter* fileWriter;
std::chrono::steady_clock::time_point fileStart, resStart;
std::map<std::string, std::vector<char>> files;
@ -47,16 +47,16 @@ static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileM
printf("BOTR: Generating OTR Archive...\n");
if (File::Exists(otrFileName))
otrArchive = std::shared_ptr<Ship::Archive>(new Ship::Archive(otrFileName, true));
if (DiskFile::Exists(otrFileName))
otrArchive = std::shared_ptr<LUS::Archive>(new LUS::Archive(otrFileName, true));
else
otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000);
otrArchive = LUS::Archive::CreateArchive(otrFileName, 40000);
auto lst = Directory::ListFiles("Extract");
for (auto item : lst)
{
auto fileData = File::ReadAllBytes(item);
auto fileData = DiskFile::ReadAllBytes(item);
otrArchive->AddFile(StringHelper::Split(item, "Extract/")[1], (uintptr_t)fileData.data(), fileData.size());
}
}
@ -70,7 +70,7 @@ static void ExporterProgramEnd()
if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory)
{
std::string romPath = Globals::Instance->baseRomPath.string();
const std::vector<uint8_t>& romData = File::ReadAllBytes(romPath);
const std::vector<uint8_t>& romData = DiskFile::ReadAllBytes(romPath);
crc = BitConverter::ToUInt32BE(romData, 0x10);
printf("Creating version file...\n");
@ -86,7 +86,7 @@ static void ExporterProgramEnd()
printf("Created version file.\n");
printf("Generating OTR Archive...\n");
otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000);
otrArchive = LUS::Archive::CreateArchive(otrFileName, 40000);
otrArchive->AddFile("version", (uintptr_t)versionStream->ToVector().data(), versionStream->GetLength());
@ -111,11 +111,11 @@ static void ExporterProgramEnd()
files.clear();
// Add any additional files that need to be manually copied...
if (File::Exists("soh.otr")) {
if (DiskFile::Exists("soh.otr")) {
return;
}
const auto& lst = Directory::ListFiles("Extract");
std::shared_ptr<Ship::Archive> sohOtr = Ship::Archive::CreateArchive("soh.otr", 4096);
std::shared_ptr<LUS::Archive> sohOtr = LUS::Archive::CreateArchive("soh.otr", 4096);
//sohOtr->AddFile("version", (uintptr_t)versionStream->ToVector().data(), versionStream->GetLength());
for (const auto& item : lst)
@ -158,14 +158,14 @@ static void ExporterProgramEnd()
splitPath.pop_back();
if (extension == "json")
{
const auto &fileData = File::ReadAllBytes(item);
const auto &fileData = DiskFile::ReadAllBytes(item);
printf("Adding accessibility texts %s\n", StringHelper::Split(item, "texts/")[1].c_str());
sohOtr->AddFile(StringHelper::Split(item, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size());
}
continue;
}
const auto& fileData = File::ReadAllBytes(item);
const auto& fileData = DiskFile::ReadAllBytes(item);
printf("sohOtr->AddFile(%s)\n", StringHelper::Split(item, "Extract/")[1].c_str());
sohOtr->AddFile(StringHelper::Split(item, item.find("Extract/assets/") != std::string::npos ? "Extract/assets/" : "Extract/")[1], (uintptr_t)fileData.data(), fileData.size());
}
@ -249,7 +249,7 @@ static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer)
files[fName] = strem->ToVector();
}
else
File::WriteAllBytes("Extract/" + fName, strem->ToVector());
DiskFile::WriteAllBytes("Extract/" + fName, strem->ToVector());
}
auto end = std::chrono::steady_clock::now();
@ -275,7 +275,7 @@ static void ExporterXMLEnd()
void AddFile(std::string fName, std::vector<char> data)
{
if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory)
File::WriteAllBytes("Extract/" + fName, data);
DiskFile::WriteAllBytes("Extract/" + fName, data);
else
{
std::unique_lock Lock(fileMutex);

View File

@ -2,7 +2,7 @@
#include <libultraship/bridge.h>
extern std::shared_ptr<Ship::Archive> otrArchive;
extern std::shared_ptr<LUS::Archive> otrArchive;
extern std::map<std::string, std::vector<char>> files;
void AddFile(std::string fName, std::vector<char> data);

View File

@ -4,7 +4,7 @@ void OTRExporter_MtxExporter::Save(ZResource* res, const fs::path& outPath, Bina
{
ZMtx* mtx = (ZMtx*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::Matrix);
WriteHeader(res, outPath, writer, LUS::ResourceType::Matrix);
for (size_t i = 0; i < 4; i++)
for (size_t j = 0; j < 4; j++)

View File

@ -5,7 +5,7 @@ void OTRExporter_Path::Save(ZResource* res, const fs::path& outPath, BinaryWrite
{
ZPath* path = (ZPath*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Path);
WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Path);
writer->Write((uint32_t)path->pathways.size());

View File

@ -5,7 +5,7 @@ void OTRExporter_PlayerAnimationExporter::Save(ZResource* res, const fs::path& o
{
ZPlayerAnimationData* anim = (ZPlayerAnimationData*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_PlayerAnimation);
WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_PlayerAnimation);
auto start = std::chrono::steady_clock::now();

View File

@ -1,7 +1,7 @@
#include "RoomExporter.h"
#include "Utils/BinaryWriter.h"
#include "Utils/MemoryStream.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include <ZRoom/Commands/SetMesh.h>
#include <ZRoom/Commands/SetWind.h>
#include <ZRoom/Commands/SetTimeSettings.h>
@ -39,7 +39,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite
{
ZRoom* room = (ZRoom*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Room);
WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Room);
writer->Write((uint32_t)room->commands.size());
@ -80,10 +80,8 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite
// This can cause issues if we export actors with garbage data, so let's trust the command size
writer->Write((uint32_t)cmdSetActorList->numActors);
for (int i = 0; i < cmdSetActorList->numActors; i++)
for (const auto& entry : cmdSetActorList->actorList->actors)
{
const ActorSpawnEntry& entry = cmdSetActorList->actors[i];
writer->Write(entry.actorNum);
writer->Write(entry.posX);
writer->Write(entry.posY);
@ -91,7 +89,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite
writer->Write(entry.rotX);
writer->Write(entry.rotY);
writer->Write(entry.rotZ);
writer->Write(entry.initVar);
writer->Write(entry.params);
}
}
break;
@ -393,7 +391,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite
writer->Write(entry.rotX);
writer->Write(entry.rotY);
writer->Write(entry.rotZ);
writer->Write(entry.initVar);
writer->Write(entry.params);
}
}
break;

View File

@ -7,7 +7,7 @@ void OTRExporter_Skeleton::Save(ZResource* res, const fs::path& outPath, BinaryW
{
ZSkeleton* skel = (ZSkeleton*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Skeleton);
WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Skeleton);
writer->Write((uint8_t)skel->type);
writer->Write((uint8_t)skel->limbType);
@ -15,15 +15,15 @@ void OTRExporter_Skeleton::Save(ZResource* res, const fs::path& outPath, BinaryW
writer->Write((uint32_t)skel->limbCount);
writer->Write((uint32_t)skel->dListCount);
writer->Write((uint8_t)skel->limbsTable.limbType);
writer->Write((uint32_t)skel->limbsTable.count);
writer->Write((uint8_t)skel->limbsTable->limbType);
writer->Write((uint32_t)skel->limbsTable->count);
for (size_t i = 0; i < skel->limbsTable.count; i++)
for (size_t i = 0; i < skel->limbsTable->count; i++)
{
Declaration* skelDecl = skel->parent->GetDeclarationRanged(GETSEGOFFSET(skel->limbsTable.limbsAddresses[i]));
Declaration* skelDecl = skel->parent->GetDeclarationRanged(GETSEGOFFSET(skel->limbsTable->limbsAddresses[i]));
std::string name;
bool foundDecl = Globals::Instance->GetSegmentedPtrName(skel->limbsTable.limbsAddresses[i], skel->parent, "", name, res->parent->workerID);
bool foundDecl = Globals::Instance->GetSegmentedPtrName(skel->limbsTable->limbsAddresses[i], skel->parent, "", name, res->parent->workerID);
if (foundDecl)
{
if (name.at(0) == '&')

View File

@ -7,7 +7,7 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, const fs::path& outPath, Bin
{
ZLimb* limb = (ZLimb*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_SkeletonLimb);
WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_SkeletonLimb);
writer->Write((uint8_t)limb->type);
writer->Write((uint8_t)limb->skinSegmentType);

View File

@ -5,7 +5,7 @@ void OTRExporter_Text::Save(ZResource* res, const fs::path& outPath, BinaryWrite
{
ZText* txt = (ZText*)res;
WriteHeader(txt, outPath, writer, Ship::ResourceType::SOH_Text);
WriteHeader(txt, outPath, writer, LUS::ResourceType::SOH_Text);
writer->Write((uint32_t)txt->messages.size());

View File

@ -5,7 +5,7 @@ void OTRExporter_Texture::Save(ZResource* res, const fs::path& outPath, BinaryWr
{
ZTexture* tex = (ZTexture*)res;
WriteHeader(tex, outPath, writer, Ship::ResourceType::Texture);
WriteHeader(tex, outPath, writer, LUS::ResourceType::Texture);
auto start = std::chrono::steady_clock::now();

View File

@ -1,25 +1,25 @@
#include "VersionInfo.h"
#include <libultraship/bridge.h>
std::map<Ship::ResourceType, uint32_t> resourceVersions;
std::map<LUS::ResourceType, uint32_t> resourceVersions;
void InitVersionInfo()
{
resourceVersions = std::map<Ship::ResourceType, uint32_t> {
{ Ship::ResourceType::SOH_Animation, 0 },
{ Ship::ResourceType::Texture, 0 },
{ Ship::ResourceType::SOH_PlayerAnimation, 0 },
{ Ship::ResourceType::DisplayList, 0 },
{ Ship::ResourceType::SOH_Room, 0 },
{ Ship::ResourceType::SOH_CollisionHeader, 0 },
{ Ship::ResourceType::SOH_Skeleton, 0 },
{ Ship::ResourceType::SOH_SkeletonLimb, 0 },
{ Ship::ResourceType::Matrix, 0 },
{ Ship::ResourceType::SOH_Path, 0 },
{ Ship::ResourceType::Vertex, 0 },
{ Ship::ResourceType::SOH_Cutscene, 0 },
{ Ship::ResourceType::Array, 0 },
{ Ship::ResourceType::SOH_Text, 0 },
{ Ship::ResourceType::Blob, 0 },
resourceVersions = std::map<LUS::ResourceType, uint32_t> {
{ LUS::ResourceType::SOH_Animation, 0 },
{ LUS::ResourceType::Texture, 0 },
{ LUS::ResourceType::SOH_PlayerAnimation, 0 },
{ LUS::ResourceType::DisplayList, 0 },
{ LUS::ResourceType::SOH_Room, 0 },
{ LUS::ResourceType::SOH_CollisionHeader, 0 },
{ LUS::ResourceType::SOH_Skeleton, 0 },
{ LUS::ResourceType::SOH_SkeletonLimb, 0 },
{ LUS::ResourceType::Matrix, 0 },
{ LUS::ResourceType::SOH_Path, 0 },
{ LUS::ResourceType::Vertex, 0 },
{ LUS::ResourceType::SOH_Cutscene, 0 },
{ LUS::ResourceType::Array, 0 },
{ LUS::ResourceType::SOH_Text, 0 },
{ LUS::ResourceType::Blob, 0 },
};
}

View File

@ -4,6 +4,4 @@
#include <vector>
#include "src/resource/Resource.h"
#define MAJOR_VERSION Ship::Version::Deckard
extern std::map<Ship::ResourceType, uint32_t> resourceVersions;
extern std::map<LUS::ResourceType, uint32_t> resourceVersions;

View File

@ -5,7 +5,7 @@
void OTRExporter_Vtx::SaveArr(ZResource* res, const fs::path& outPath, const std::vector<ZResource*>& vec, BinaryWriter* writer)
{
WriteHeader(res, outPath, writer, Ship::ResourceType::Vertex);
WriteHeader(res, outPath, writer, LUS::ResourceType::Vertex);
for (auto& res: vec) {
ZVtx* vtx = (ZVtx*)res;
@ -27,7 +27,7 @@ void OTRExporter_Vtx::Save(ZResource* res, const fs::path& outPath, BinaryWriter
{
ZVtx* vtx = (ZVtx*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::Vertex);
WriteHeader(res, outPath, writer, LUS::ResourceType::Vertex);
writer->Write((uint32_t)1); //Yes I'm hard coding it to one, it *should* be fine.

View File

@ -4,9 +4,9 @@
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = https://github.com/HarbourMasters/ZAPDTR.git
remote = https://github.com/harbourmasters/ZAPDTR
branch = master
commit = e23b125d89bd973998d2eb00896bcbaf1b53a329
parent = 17b1a8e7fd5517f9232e531da0fed6ef80a87f04
commit = d4c35b90aed66eeed61066b4b76e488bfab52b4d
parent = 9d17e19a1dcf2b5c6cef0d3c93816f98a280eb58
method = rebase
cmdver = 0.4.3

View File

@ -50,17 +50,19 @@ void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] const fs::
writer->Write(col->polygons[i].vtxA);
writer->Write(col->polygons[i].vtxB);
writer->Write(col->polygons[i].vtxC);
writer->Write(col->polygons[i].a);
writer->Write(col->polygons[i].b);
writer->Write(col->polygons[i].c);
writer->Write(col->polygons[i].d);
writer->Write(col->polygons[i].normX);
writer->Write(col->polygons[i].normY);
writer->Write(col->polygons[i].normZ);
writer->Write(col->polygons[i].dist);
}
writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start);
for (uint16_t i = 0; i < col->polygonTypes.size(); i++)
writer->Write(col->polygonTypes[i]);
for (const auto& poly : col->polygonTypes)
{
writer->Write(poly.data[0]);
writer->Write(poly.data[1]);
}
writer->Seek(col->camDataSegmentOffset, SeekOffsetType::Start);
for (auto entry : col->camData->entries)

View File

@ -36,7 +36,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@ -49,7 +49,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View File

@ -1,7 +1,7 @@
#include "RoomExporter.h"
#include "CollisionExporter.h"
#include "Utils/BinaryWriter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/MemoryStream.h"
#include "ZRoom/Commands/SetCameraSettings.h"
#include "ZRoom/Commands/SetCollisionHeader.h"
@ -334,7 +334,7 @@ void ExporterExample_Room::Save(ZResource* res, const fs::path& outPath, BinaryW
writer->Write(entry.rotX);
writer->Write(entry.rotY);
writer->Write(entry.rotZ);
writer->Write(entry.initVar);
writer->Write(entry.params);
}
writer->Seek(oldOffset, SeekOffsetType::Start);
@ -367,6 +367,6 @@ void ExporterExample_Room::Save(ZResource* res, const fs::path& outPath, BinaryW
}
// writer->Close();
// File::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()),
// DiskFile::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()),
// memStream->ToVector());
}

97
ZAPDTR/Jenkinsfile vendored
View File

@ -1,97 +0,0 @@
pipeline {
agent {
label 'ZAPD'
}
stages {
// Non-parallel ZAPD stage
stage('Build ZAPD') {
steps {
sh 'make -j WERROR=1'
}
}
// CHECKOUT THE REPOS
stage('Checkout Repos') {
parallel {
stage('Checkout oot') {
steps {
dir('oot') {
git url: 'https://github.com/zeldaret/oot.git'
}
}
}
stage('Checkout mm') {
steps{
dir('mm') {
git url: 'https://github.com/zeldaret/mm.git'
}
}
}
}
}
// SETUP THE REPOS
stage('Set up repos') {
parallel {
stage('Setup OOT') {
steps {
dir('oot') {
sh 'cp /usr/local/etc/roms/baserom_oot.z64 baserom_original.z64'
// Identical to `make setup` except for copying our newer ZAPD.out into oot
sh 'git submodule update --init --recursive'
sh 'make -C tools'
sh 'cp ../ZAPD.out tools/ZAPD/'
sh 'python3 fixbaserom.py'
sh 'python3 extract_baserom.py'
sh 'python3 extract_assets.py'
}
}
}
stage('Setup MM') {
steps {
dir('mm') {
sh 'cp /usr/local/etc/roms/mm.us.rev1.z64 baserom.mm.us.rev1.z64'
// Identical to `make setup` except for copying our newer ZAPD.out into mm
sh 'make -C tools'
sh 'cp ../ZAPD.out tools/ZAPD/'
sh 'python3 tools/fixbaserom.py'
sh 'python3 tools/extract_baserom.py'
sh 'python3 extract_assets.py -t$(nproc)'
}
}
}
}
}
// BUILD THE REPOS
stage('Build repos') {
parallel {
stage('Build oot') {
steps {
dir('oot') {
sh 'make -j'
}
}
}
stage('Build mm') {
steps {
dir('mm') {
sh 'make -j disasm'
sh 'make -j all'
}
}
}
}
}
}
post {
always {
cleanWs()
}
}
}

134
ZAPDTR/Makefile Normal file
View File

@ -0,0 +1,134 @@
# use variables in submakes
export
OPTIMIZATION_ON ?= 1
ASAN ?= 0
DEPRECATION_ON ?= 1
DEBUG ?= 0
COPYCHECK_ARGS ?=
LLD ?= 0
WERROR ?= 0
# Use clang++ if available, else use g++
ifeq ($(shell command -v clang++ >/dev/null 2>&1; echo $$?),0)
CXX := clang++
else
CXX := g++
endif
INC := -I ZAPD -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils
CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer
OPTFLAGS :=
ifneq ($(DEBUG),0)
OPTIMIZATION_ON = 0
CXXFLAGS += -g3 -DDEVELOPMENT -D_DEBUG
COPYCHECK_ARGS += --devel
DEPRECATION_ON = 0
endif
ifneq ($(WERROR),0)
CXXFLAGS += -Werror
endif
ifeq ($(OPTIMIZATION_ON),0)
OPTFLAGS := -O0
else
OPTFLAGS := -O2
endif
ifneq ($(ASAN),0)
CXXFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined
endif
ifneq ($(DEPRECATION_ON),0)
CXXFLAGS += -DDEPRECATION_ON
endif
# CXXFLAGS += -DTEXTURE_DEBUG
LDFLAGS := -lm -ldl -lpng
# Use LLD if available. Set LLD=0 to not use it
ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0)
LLD := 1
endif
ifneq ($(LLD),0)
LDFLAGS += -fuse-ld=lld
endif
UNAME := $(shell uname)
UNAMEM := $(shell uname -m)
ifneq ($(UNAME), Darwin)
LDFLAGS += -Wl,-export-dynamic -lstdc++fs
EXPORTERS := -Wl,--whole-archive ExporterTest/ExporterTest.a -Wl,--no-whole-archive
else
EXPORTERS := -Wl,-force_load ExporterTest/ExporterTest.a
ifeq ($(UNAMEM),arm64)
ifeq ($(shell brew list libpng > /dev/null 2>&1; echo $$?),0)
LDFLAGS += -L $(shell brew --prefix)/lib
INC += -I $(shell brew --prefix)/include
else
$(error Please install libpng via Homebrew)
endif
endif
endif
ZAPD_SRC_DIRS := $(shell find ZAPD -type d)
SRC_DIRS = $(ZAPD_SRC_DIRS) lib/tinyxml2
ZAPD_CPP_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.cpp))
ZAPD_H_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.h))
CPP_FILES += $(ZAPD_CPP_FILES) lib/tinyxml2/tinyxml2.cpp
O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f)
O_FILES += build/ZAPD/BuildInfo.o
# create build directories
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))
# Main targets
all: ZAPD.out copycheck
build/ZAPD/BuildInfo.o:
python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS)
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) build/ZAPD/BuildInfo.cpp
copycheck: ZAPD.out
python3 copycheck.py
clean:
rm -rf build ZAPD.out
$(MAKE) -C lib/libgfxd clean
$(MAKE) -C ZAPDUtils clean
$(MAKE) -C ExporterTest clean
rebuild: clean all
format:
clang-format-11 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES)
$(MAKE) -C ZAPDUtils format
$(MAKE) -C ExporterTest format
.PHONY: all build/ZAPD/BuildInfo.o copycheck clean rebuild format
build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) $<
# Submakes
lib/libgfxd/libgfxd.a:
$(MAKE) -C lib/libgfxd
.PHONY: ExporterTest
ExporterTest:
$(MAKE) -C ExporterTest
.PHONY: ZAPDUtils
ZAPDUtils:
$(MAKE) -C ZAPDUtils
# Linking
ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a ExporterTest ZAPDUtils
$(CXX) $(CXXFLAGS) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a $(EXPORTERS) $(LDFLAGS) $(OUTPUT_OPTION)

View File

@ -71,9 +71,6 @@ ZAPD needs a _File parsing mode_ to be passed as first parameter. The options ar
- `blb`: "Build blob" mode.
- In this mode, ZAPD expects a BIN file as input and a filename as ouput.
- ZAPD will try to convert the given BIN into the contents of a `uint8_t` C array.
- `bovl`: "Build overlay" mode.
- In this mode, ZAPD expects an overlay C file as input, a filename as ouput and an overlay configuration path (`-cfg`).
- ZAPD will generate a reloc `.s` file.
ZAPD also accepts the following list of extra parameters:
@ -102,8 +99,6 @@ ZAPD also accepts the following list of extra parameters:
- `ia16`
- `ci4`
- `ci8`
- `-cfg PATH`: Set cfg path (for overlays).
- Can be used only in `bovl` mode.
- `-rconf PATH` Read Config File.
- `-eh`: Enable error handler.
- Only available in non-Windows environments.

View File

@ -17,6 +17,7 @@ set(Header_Files
"ImageBackend.h"
"OutputFormatter.h"
"WarningHandler.h"
"CrashHandler.h"
)
source_group("Header Files" FILES ${Header_Files})
@ -27,22 +28,6 @@ set(Header_Files__Libraries
)
source_group("Header Files\\Libraries" FILES ${Header_Files__Libraries})
set(Header_Files__Libraries__elfio
"../lib/elfio/elfio/elf_types.hpp"
"../lib/elfio/elfio/elfio.hpp"
"../lib/elfio/elfio/elfio_dump.hpp"
"../lib/elfio/elfio/elfio_dynamic.hpp"
"../lib/elfio/elfio/elfio_header.hpp"
"../lib/elfio/elfio/elfio_note.hpp"
"../lib/elfio/elfio/elfio_relocation.hpp"
"../lib/elfio/elfio/elfio_section.hpp"
"../lib/elfio/elfio/elfio_segment.hpp"
"../lib/elfio/elfio/elfio_strings.hpp"
"../lib/elfio/elfio/elfio_symbols.hpp"
"../lib/elfio/elfio/elfio_utils.hpp"
)
source_group("Header Files\\Libraries\\elfio" FILES ${Header_Files__Libraries__elfio})
set(Header_Files__Libraries__libgfxd
"../lib/libgfxd/gbi.h"
"../lib/libgfxd/gfxd.h"
@ -58,15 +43,17 @@ source_group("Header Files\\Yaz0" FILES ${Header_Files__Yaz0})
set(Header_Files__Z64
"OtherStructs/SkinLimbStructs.h"
"Overlays/ZOverlay.h"
"OtherStructs/CutsceneMM_Commands.h"
"OtherStructs/Cutscene_Commands.h"
"ZAnimation.h"
"ZActorList.h"
"ZArray.h"
"ZAudio.h"
"ZBackground.h"
"ZBlob.h"
"ZCollision.h"
"ZCollisionPoly.h"
"ZCutscene.h"
"ZCutsceneMM.h"
"ZDisplayList.h"
"ZFile.h"
"ZLimb.h"
@ -77,6 +64,7 @@ set(Header_Files__Z64
"ZRom.h"
"ZScalar.h"
"ZSkeleton.h"
"ZSurfaceType.h"
"ZString.h"
"ZSymbol.h"
"ZText.h"
@ -136,6 +124,7 @@ set(Resource_Files
source_group("Resource Files" FILES ${Resource_Files})
set(Source_Files
"CrashHandler.cpp"
"Declaration.cpp"
"FileWorker.cpp"
"GameConfig.cpp"
@ -165,16 +154,18 @@ source_group("Source Files\\Yaz0" FILES ${Source_Files__Yaz0})
set(Source_Files__Z64
"OtherStructs/SkinLimbStructs.cpp"
"Overlays/ZOverlay.cpp"
"OtherStructs/CutsceneMM_Commands.cpp"
"OtherStructs/Cutscene_Commands.cpp"
"ZAnimation.cpp"
"ZActorList.cpp"
"ZArray.cpp"
"ZAudio.cpp"
"ZAudioDecode.cpp"
"ZBackground.cpp"
"ZBlob.cpp"
"ZCollision.cpp"
"ZCollisionPoly.cpp"
"ZCutscene.cpp"
"ZCutsceneMM.cpp"
"ZDisplayList.cpp"
"ZFile.cpp"
"ZLimb.cpp"
@ -185,6 +176,7 @@ set(Source_Files__Z64
"ZRom.cpp"
"ZScalar.cpp"
"ZSkeleton.cpp"
"ZSurfaceType.cpp"
"ZString.cpp"
"ZSymbol.cpp"
"ZText.cpp"
@ -241,7 +233,6 @@ source_group("Source Files\\Z64\\ZRoom\\Commands" FILES ${Source_Files__Z64__ZRo
set(ALL_FILES
${Header_Files}
${Header_Files__Libraries}
${Header_Files__Libraries__elfio}
${Header_Files__Libraries__libgfxd}
${Header_Files__Yaz0}
${Header_Files__Z64}

View File

@ -0,0 +1,205 @@
#include "CrashHandler.h"
#include "Utils/StringHelper.h"
#if __has_include(<unistd.h>)
#define HAS_POSIX 1
#else
#define HAS_POSIX 0
#endif
#include <array>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#if HAS_POSIX == 1
#include <csignal>
#include <cxxabi.h> // for __cxa_demangle
#include <dlfcn.h> // for dladdr
#include <execinfo.h>
#include <unistd.h>
#elif defined(_MSC_VER)
#include <Windows.h>
#include <DbgHelp.h>
#include <inttypes.h>
#pragma comment(lib, "Dbghelp.lib")
#endif
// Feel free to add more crash messages.
static std::array<const char* const, 14> crashEasterEgg = {
"\tYou've met with a terrible fate, haven't you?",
"\tSEA BEARS FOAM. SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY: CRASSSH!",
"\tZAPD has fallen and cannot get up.",
"\tIT'S A SECRET TO EVERYBODY. \n\tBut it shouldn't be, you'd better ask about it!",
"\tI AM ERROR.",
"\tGRUMBLE,GRUMBLE...",
"\tDODONGO DISLIKES SMOKE \n\tAnd ZAPD dislikes whatever you fed it.",
"\tMay the way of the Hero lead \n\tto the debugger.",
"\tTHE WIND FISH SLUMBERS LONG... \n\tTHE HERO'S LIFE GONE... ",
"\tSEA BEARS FOAM, SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY CRASSSH!",
"\tYou've met with a terrible fate, haven't you?",
"\tMaster, I calculate a 100% probability that ZAPD has crashed. \n\tAdditionally, the "
"batteries in your Wii Remote are nearly depleted.",
"\t CONGRATURATIONS! \n"
"\tAll Pages are displayed.\n"
"\t THANK YOU! \n"
"\t You are great debugger!",
"\tRCP is HUNG UP!!\n"
"\tOh! MY GOD!!",
};
#if HAS_POSIX == 1
void ErrorHandler(int sig)
{
std::array<void*, 4096> arr;
constexpr size_t nMaxFrames = arr.size();
size_t size = backtrace(arr.data(), nMaxFrames);
char** symbols = backtrace_symbols(arr.data(), nMaxFrames);
fprintf(stderr, "\nZAPD crashed. (Signal: %i)\n", sig);
srand(time(nullptr));
auto easterIndex = rand() % crashEasterEgg.size();
fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]);
fprintf(stderr, "Traceback:\n");
for (size_t i = 1; i < size; i++)
{
Dl_info info;
uint32_t gotAddress = dladdr(arr[i], &info);
std::string functionName(symbols[i]);
if (gotAddress != 0 && info.dli_sname != nullptr)
{
int32_t status;
char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
const char* nameFound = info.dli_sname;
if (status == 0)
{
nameFound = demangled;
}
functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound,
(char*)arr[i] - (char*)info.dli_saddr);
free(demangled);
}
fprintf(stderr, "%-3zd %s\n", i, functionName.c_str());
}
fprintf(stderr, "\n");
free(symbols);
exit(1);
}
#elif defined(_MSC_VER)
void printStack(CONTEXT* ctx)
{
BOOL result;
HANDLE process;
HANDLE thread;
HMODULE hModule;
ULONG frame;
DWORD64 displacement;
DWORD disp;
srand(time(nullptr));
auto easterIndex = rand() % crashEasterEgg.size();
fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]);
#if defined(_M_AMD64)
STACKFRAME64 stack;
memset(&stack, 0, sizeof(STACKFRAME64));
#else
STACKFRAME stack;
memset(&stack, 0, sizeof(STACKFRAME));
#endif
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME + sizeof(TCHAR)];
char module[512];
PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
CONTEXT ctx2;
memcpy(&ctx2, ctx, sizeof(CONTEXT));
process = GetCurrentProcess();
thread = GetCurrentThread();
SymInitialize(process, nullptr, TRUE);
constexpr DWORD machineType =
#if defined(_M_AMD64)
IMAGE_FILE_MACHINE_AMD64;
#else
IMAGE_FILE_MACHINE_I386;
#endif
displacement = 0;
for (frame = 0;; frame++)
{
result = StackWalk(machineType, process, thread, &stack, &ctx2, nullptr,
SymFunctionTableAccess, SymGetModuleBase, nullptr);
if (!result)
{
break;
}
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
symbol->MaxNameLen = MAX_SYM_NAME;
SymFromAddr(process, (ULONG64)stack.AddrPC.Offset, &displacement, symbol);
#if defined(_M_AMD64)
IMAGEHLP_LINE64 line;
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
#else
IMAGEHLP_LINE line;
line.SizeOfStruct = sizeof(IMAGEHLP_LINE);
#endif
if (SymGetLineFromAddr(process, stack.AddrPC.Offset, &disp, &line))
{
fprintf(stderr, "%u\t %s in %s: line: %lu: \n", frame, symbol->Name, line.FileName,
line.LineNumber);
}
else
{
fprintf(stderr, "%u\tat % s\n", frame, symbol->Name);
hModule = nullptr;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCTSTR)(stack.AddrPC.Offset), &hModule);
if (hModule != nullptr)
{
GetModuleFileNameA(hModule, module, 512 - 1);
}
fprintf(stderr, "%u\tIn %s\n", frame, module);
}
}
}
LONG seh_filter(_EXCEPTION_POINTERS* ex)
{
fprintf(stderr, "EXCEPTION 0x%x occured\n", ex->ExceptionRecord->ExceptionCode);
printStack(ex->ContextRecord);
return EXCEPTION_EXECUTE_HANDLER;
}
#endif
void CrashHandler_Init()
{
#if HAS_POSIX == 1
signal(SIGSEGV, ErrorHandler);
signal(SIGABRT, ErrorHandler);
#elif defined(_MSC_VER)
SetUnhandledExceptionFilter(seh_filter);
#else
HANDLE_WARNING(WarningType::Always,
"tried to set error handler, but this ZAPD build lacks support for one", "");
#endif
}

View File

@ -0,0 +1,6 @@
#ifndef CRASH_HANDLER_H
#define CRASH_HANDLER_H
void CrashHandler_Init();
#endif

View File

@ -178,7 +178,7 @@ std::string Declaration::GetExternalDeclarationStr() const
std::string Declaration::GetExternStr() const
{
if (IsStatic() || varType == "")
if (IsStatic() || varType == "" || isUnaccounted)
{
return "";
}

View File

@ -2,6 +2,7 @@
#include <string>
#include <vector>
#include <cstdint>
// TODO: should we drop the `_t` suffix because of UNIX compliance?
typedef uint32_t segptr_t;

View File

@ -2,9 +2,10 @@
#include <functional>
#include <string_view>
#include <unordered_map>
#include "Utils/Directory.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "ZFile.h"
#include "tinyxml2.h"
@ -56,7 +57,7 @@ void GameConfig::ReadTexturePool(const fs::path& texturePoolXmlPath)
void GameConfig::GenSymbolMap(const fs::path& symbolMapPath)
{
auto symbolLines = File::ReadAllLines(symbolMapPath);
auto symbolLines = DiskFile::ReadAllLines(symbolMapPath);
for (std::string& symbolLine : symbolLines)
{
@ -78,7 +79,7 @@ void GameConfig::ConfigFunc_ActorList(const tinyxml2::XMLElement& element)
{
std::string fileName = element.Attribute("File");
std::vector<std::string> lines =
File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
for (auto& line : lines)
actorList.emplace_back(std::move(line));
@ -88,12 +89,32 @@ void GameConfig::ConfigFunc_ObjectList(const tinyxml2::XMLElement& element)
{
std::string fileName = element.Attribute("File");
std::vector<std::string> lines =
File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
for (auto& line : lines)
objectList.emplace_back(std::move(line));
}
void GameConfig::ConfigFunc_EntranceList(const tinyxml2::XMLElement& element)
{
std::string fileName = element.Attribute("File");
std::vector<std::string> lines =
DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
for (auto& line : lines)
entranceList.emplace_back(std::move(line));
}
void GameConfig::ConfigFunc_specialEntranceList(const tinyxml2::XMLElement& element)
{
std::string fileName = element.Attribute("File");
std::vector<std::string> lines =
DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
for (auto& line : lines)
specialEntranceList.emplace_back(std::move(line));
}
void GameConfig::ConfigFunc_TexturePool(const tinyxml2::XMLElement& element)
{
std::string fileName = element.Attribute("File");
@ -145,10 +166,12 @@ void GameConfig::ConfigFunc_ExternalFile(const tinyxml2::XMLElement& element)
void GameConfig::ReadConfigFile(const fs::path& argConfigFilePath)
{
static const std::map<std::string, ConfigFunc> ConfigFuncDictionary = {
static const std::unordered_map<std::string, ConfigFunc> ConfigFuncDictionary = {
{"SymbolMap", &GameConfig::ConfigFunc_SymbolMap},
{"ActorList", &GameConfig::ConfigFunc_ActorList},
{"ObjectList", &GameConfig::ConfigFunc_ObjectList},
{"EntranceList", &GameConfig::ConfigFunc_EntranceList},
{"SpecialEntranceList", &GameConfig::ConfigFunc_specialEntranceList},
{"TexturePool", &GameConfig::ConfigFunc_TexturePool},
{"BGConfig", &GameConfig::ConfigFunc_BGConfig},
{"ExternalXMLFolder", &GameConfig::ConfigFunc_ExternalXMLFolder},

View File

@ -31,6 +31,8 @@ public:
std::map<uint32_t, std::string> symbolMap;
std::vector<std::string> actorList;
std::vector<std::string> objectList;
std::vector<std::string> entranceList;
std::vector<std::string> specialEntranceList;
std::map<uint32_t, TexturePoolEntry> texturePool; // Key = CRC
// ZBackground
@ -49,6 +51,8 @@ public:
void ConfigFunc_SymbolMap(const tinyxml2::XMLElement& element);
void ConfigFunc_ActorList(const tinyxml2::XMLElement& element);
void ConfigFunc_ObjectList(const tinyxml2::XMLElement& element);
void ConfigFunc_EntranceList(const tinyxml2::XMLElement& element);
void ConfigFunc_specialEntranceList(const tinyxml2::XMLElement& element);
void ConfigFunc_TexturePool(const tinyxml2::XMLElement& element);
void ConfigFunc_BGConfig(const tinyxml2::XMLElement& element);
void ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element);

View File

@ -3,7 +3,7 @@
#include <algorithm>
#include <string_view>
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "WarningHandler.h"
#include "tinyxml2.h"
@ -134,12 +134,12 @@ void Globals::BuildAssetTexture(const fs::path& pngFilePath, TextureType texType
tex.FromPNG(pngFilePath.string(), texType);
std::string cfgPath = StringHelper::Split(pngFilePath.string(), ".")[0] + ".cfg";
if (File::Exists(cfgPath))
name = File::ReadAllText(cfgPath);
if (DiskFile::Exists(cfgPath))
name = DiskFile::ReadAllText(cfgPath);
std::string src = tex.GetBodySourceCode();
File::WriteAllBytes(outPath.string(), src.c_str(), src.size());
DiskFile::WriteAllBytes(outPath.string(), src.c_str(), src.size());
}
std::map<std::string, ExporterSet*>& Globals::GetExporterMap()
@ -186,7 +186,7 @@ std::vector<uint8_t> Globals::GetBaseromFile(std::string fileName)
}
else
return File::ReadAllBytes(fileName);
return DiskFile::ReadAllBytes(fileName);
}
bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile,

View File

@ -398,7 +398,7 @@ void ImageBackend::SetPaletteIndex(size_t index, uint8_t nR, uint8_t nG, uint8_t
alphaPalette[index] = nA;
}
void ImageBackend::SetPalette(const ImageBackend& pal)
void ImageBackend::SetPalette(const ImageBackend& pal, uint32_t offset)
{
assert(isColorIndexed);
size_t bytePerPixel = pal.GetBytesPerPixel();
@ -422,7 +422,7 @@ void ImageBackend::SetPalette(const ImageBackend& pal)
uint8_t g = pal.pixelMatrix[y][x * bytePerPixel + 1];
uint8_t b = pal.pixelMatrix[y][x * bytePerPixel + 2];
uint8_t a = pal.pixelMatrix[y][x * bytePerPixel + 3];
SetPaletteIndex(index, r, g, b, a);
SetPaletteIndex(index + offset, r, g, b, a);
}
}
}

View File

@ -42,8 +42,9 @@ public:
void SetGrayscalePixel(size_t y, size_t x, uint8_t grayscale, uint8_t alpha = 0);
void SetIndexedPixel(size_t y, size_t x, uint8_t index, uint8_t grayscale);
void SetIndexedPixel(size_t y, size_t x, uint8_t index, RGBAPixel pixel);
void SetPaletteIndex(size_t index, uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA);
void SetPalette(const ImageBackend& pal);
void SetPalette(const ImageBackend& pal, uint32_t offset = 0);
uint32_t GetWidth() const;
uint32_t GetHeight() const;

View File

@ -1,7 +1,6 @@
#include "Globals.h"
#include "Overlays/ZOverlay.h"
#include "Utils/Directory.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "WarningHandler.h"
@ -72,15 +71,7 @@ ZRoom room(nullptr);
#include "ZFile.h"
#include "ZTexture.h"
#ifdef __linux__
#include <csignal>
#include <cstdlib>
#include <ctime>
#include <cxxabi.h> // for __cxa_demangle
#include <dlfcn.h> // for dladdr
#include <execinfo.h>
#include <unistd.h>
#endif
#include "CrashHandler.h"
#include <string>
#include <string_view>
@ -90,8 +81,6 @@ ZRoom room(nullptr);
//extern const char gBuildHash[];
const char gBuildHash[] = "";
// LINUX_TODO: remove, those are because of soh <-> lus dependency problems
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath,
ZFileMode fileMode, int workerID);
@ -102,62 +91,6 @@ int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileM
volatile int numWorkersLeft = 0;
#ifdef __linux__
#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0]))
void ErrorHandler(int sig)
{
void* array[4096];
const size_t nMaxFrames = sizeof(array) / sizeof(array[0]);
size_t size = backtrace(array, nMaxFrames);
char** symbols = backtrace_symbols(array, nMaxFrames);
fprintf(stderr, "\nZAPD crashed. (Signal: %i)\n", sig);
// Feel free to add more crash messages.
const char* crashEasterEgg[] = {
"\tYou've met with a terrible fate, haven't you?",
"\tSEA BEARS FOAM. SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY: CRASSSH!",
"\tZAPD has fallen and cannot get up.",
};
srand(time(nullptr));
auto easterIndex = rand() % ARRAY_COUNT(crashEasterEgg);
fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]);
fprintf(stderr, "Traceback:\n");
for (size_t i = 1; i < size; i++)
{
Dl_info info;
uint32_t gotAddress = dladdr(array[i], &info);
std::string functionName(symbols[i]);
if (gotAddress != 0 && info.dli_sname != nullptr)
{
int32_t status;
char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
const char* nameFound = info.dli_sname;
if (status == 0)
{
nameFound = demangled;
}
functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound,
(char*)array[i] - (char*)info.dli_saddr);
free(demangled);
}
fprintf(stderr, "%-3zd %s\n", i, functionName.c_str());
}
fprintf(stderr, "\n");
free(symbols);
exit(1);
}
#endif
extern void ImportExporters();
extern "C" int zapd_main(int argc, char* argv[])
@ -246,12 +179,6 @@ extern "C" int zapd_main(int argc, char* argv[])
{
Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[++i]);
}
else if (arg == "-cfg") // Set cfg path (for overlays)
// TODO: Change the name of this to something else so it doesn't
// get confused with XML config files.
{
Globals::Instance->cfgPath = argv[++i];
}
else if (arg == "-fl") // Set baserom filelist path
{
Globals::Instance->fileListPath = argv[++i];
@ -262,16 +189,7 @@ extern "C" int zapd_main(int argc, char* argv[])
}
else if (arg == "-eh") // Enable Error Handler
{
#ifdef __linux__
signal(SIGSEGV, ErrorHandler);
signal(SIGABRT, ErrorHandler);
#else
// HANDLE_WARNING(WarningType::Always,
// "tried to set error handler, but this ZAPD build lacks support for one",
// "");
#endif
CrashHandler_Init();
}
else if (arg == "-v") // Verbose
{
@ -326,8 +244,6 @@ extern "C" int zapd_main(int argc, char* argv[])
fileMode = ZFileMode::BuildTexture;
else if (buildMode == "bren")
fileMode = ZFileMode::BuildBackground;
else if (buildMode == "bovl")
fileMode = ZFileMode::BuildOverlay;
else if (buildMode == "bsf")
fileMode = ZFileMode::BuildSourceFile;
else if (buildMode == "bblb")
@ -662,7 +578,7 @@ void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath
ZBackground background(nullptr);
background.ParseBinaryFile(imageFilePath.string(), false);
File::WriteAllText(outPath.string(), background.GetBodySourceCode());
DiskFile::WriteAllText(outPath.string(), background.GetBodySourceCode());
}
void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath)
@ -672,7 +588,7 @@ void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath)
std::string src = blob->GetBodySourceCode();
File::WriteAllText(outPath.string(), src);
DiskFile::WriteAllText(outPath.string(), src);
delete blob;
}

View File

@ -0,0 +1,213 @@
#include "CutsceneMM_Commands.h"
#include <cassert>
#include <unordered_map>
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
// Specific for command lists where each entry has size 8 bytes
const std::unordered_map<CutsceneMMCommands, CsCommandListDescriptor> 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)"}},
};
CutsceneSubCommandEntry_GenericMMCmd::CutsceneSubCommandEntry_GenericMMCmd(
const std::vector<uint8_t>& rawData, offset_t rawDataIndex, CutsceneMMCommands cmdId)
: CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId)
{
}
std::string CutsceneSubCommandEntry_GenericMMCmd::GetBodySourceCode() const
{
const auto& element = csCommandsDescMM.find(commandId);
std::string entryFmt = "CS_UNK_DATA(0x%02X, %i, %i, %i)";
if (element != csCommandsDescMM.end())
{
entryFmt = element->second.cmdMacro;
entryFmt += element->second.args;
}
return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad);
}
CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex,
CutsceneMMCommands cmdId)
: CutsceneCommand(rawData, rawDataIndex)
{
rawDataIndex += 4;
commandID = static_cast<uint32_t>(cmdId);
entries.reserve(numEntries);
for (size_t i = 0; i < numEntries; i++)
{
auto* entry = new CutsceneSubCommandEntry_GenericMMCmd(rawData, rawDataIndex, cmdId);
entries.push_back(entry);
rawDataIndex += entry->GetRawSize();
}
}
std::string CutsceneMMCommand_GenericCmd::GetCommandMacro() const
{
const auto& element = csCommandsDescMM.find(static_cast<CutsceneMMCommands>(commandID));
if (element != csCommandsDescMM.end())
{
return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries);
}
return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries);
}
CutsceneSubCommandEntry_Camera::CutsceneSubCommandEntry_Camera(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex)
: CutsceneSubCommandEntry(rawData, rawDataIndex)
{
}
std::string CutsceneSubCommandEntry_Camera::GetBodySourceCode() const
{
return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X)", base, startFrame);
}
size_t CutsceneSubCommandEntry_Camera::GetRawSize() const
{
return 0x04;
}
CutsceneMMCommand_Camera::CutsceneMMCommand_Camera(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex)
: CutsceneCommand(rawData, rawDataIndex)
{
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();
}
}
std::string CutsceneMMCommand_Camera::GetCommandMacro() const
{
return StringHelper::Sprintf("CS_CAMERA_LIST(%i)", numEntries);
}
CutsceneSubCommandEntry_FadeScreen::CutsceneSubCommandEntry_FadeScreen(
const std::vector<uint8_t>& 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_FadeScreen::GetBodySourceCode() const
{
return StringHelper::Sprintf("CS_FADESCREEN(0x%02X, %i, %i, %i, %i, %i)", base, startFrame,
endFrame, unk_06, unk_07, unk_08);
}
size_t CutsceneSubCommandEntry_FadeScreen::GetRawSize() const
{
return 0x0C;
}
CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex)
: CutsceneCommand(rawData, rawDataIndex)
{
rawDataIndex += 4;
entries.reserve(numEntries);
for (size_t i = 0; i < numEntries; i++)
{
auto* entry = new CutsceneSubCommandEntry_FadeScreen(rawData, rawDataIndex);
entries.push_back(entry);
rawDataIndex += entry->GetRawSize();
}
}
std::string CutsceneMMCommand_FadeScreen::GetCommandMacro() const
{
return StringHelper::Sprintf("CS_FADESCREEN_LIST(%i)", numEntries);
}
CutsceneSubCommandEntry_FadeSeq::CutsceneSubCommandEntry_FadeSeq(
const std::vector<uint8_t>& 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<uint8_t>& 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);
}
CutsceneSubCommandEntry_NonImplemented::CutsceneSubCommandEntry_NonImplemented(
const std::vector<uint8_t>& rawData, offset_t rawDataIndex)
: CutsceneSubCommandEntry(rawData, rawDataIndex)
{
}
CutsceneMMCommand_NonImplemented::CutsceneMMCommand_NonImplemented(
const std::vector<uint8_t>& rawData, offset_t rawDataIndex)
: CutsceneCommand(rawData, rawDataIndex)
{
rawDataIndex += 4;
entries.reserve(numEntries);
for (size_t i = 0; i < numEntries; i++)
{
auto* entry = new CutsceneSubCommandEntry_NonImplemented(rawData, rawDataIndex);
entries.push_back(entry);
rawDataIndex += entry->GetRawSize();
}
}

View File

@ -0,0 +1,140 @@
#pragma once
#include "Cutscene_Commands.h"
enum class CutsceneMMCommands
{
/* 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,
/* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES,
/* 0x190 */ CS_CMD_RUMBLE = 0x190,
};
class CutsceneSubCommandEntry_GenericMMCmd : public CutsceneSubCommandEntry
{
public:
CutsceneMMCommands commandId;
CutsceneSubCommandEntry_GenericMMCmd(const std::vector<uint8_t>& rawData, offset_t rawDataIndex,
CutsceneMMCommands cmdId);
std::string GetBodySourceCode() const override;
};
class CutsceneMMCommand_GenericCmd : public CutsceneCommand
{
public:
CutsceneMMCommand_GenericCmd(const std::vector<uint8_t>& rawData, offset_t rawDataIndex,
CutsceneMMCommands cmdId);
std::string GetCommandMacro() const override;
};
// TODO: MM cutscene camera command is implemented as a placeholder until we better understand how
// it works
class CutsceneSubCommandEntry_Camera : public CutsceneSubCommandEntry
{
public:
uint32_t unk_08;
CutsceneSubCommandEntry_Camera(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
std::string GetBodySourceCode() const override;
size_t GetRawSize() const override;
};
class CutsceneMMCommand_Camera : public CutsceneCommand
{
public:
CutsceneMMCommand_Camera(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
std::string GetCommandMacro() const override;
};
class CutsceneSubCommandEntry_FadeScreen : 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_FadeScreen(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
std::string GetBodySourceCode() const override;
size_t GetRawSize() const override;
};
class CutsceneMMCommand_FadeScreen : public CutsceneCommand
{
public:
CutsceneMMCommand_FadeScreen(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
std::string GetCommandMacro() const override;
};
class CutsceneSubCommandEntry_FadeSeq : public CutsceneSubCommandEntry
{
public:
uint32_t unk_08;
CutsceneSubCommandEntry_FadeSeq(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
std::string GetBodySourceCode() const override;
size_t GetRawSize() const override;
};
class CutsceneMMCommand_FadeSeq : public CutsceneCommand
{
public:
CutsceneMMCommand_FadeSeq(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
std::string GetCommandMacro() const override;
};
class CutsceneSubCommandEntry_NonImplemented : public CutsceneSubCommandEntry
{
public:
CutsceneSubCommandEntry_NonImplemented(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex);
};
class CutsceneMMCommand_NonImplemented : public CutsceneCommand
{
public:
CutsceneMMCommand_NonImplemented(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
};

View File

@ -0,0 +1,596 @@
#include "Cutscene_Commands.h"
#include <cassert>
#include <unordered_map>
#include "CutsceneMM_Commands.h"
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
/* CutsceneSubCommandEntry */
CutsceneSubCommandEntry::CutsceneSubCommandEntry(const std::vector<uint8_t>& 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<uint8_t>& 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<CutsceneCommands, CsCommandListDescriptor> 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<uint8_t>& 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<uint8_t>& rawData,
offset_t rawDataIndex,
CutsceneCommands cmdId)
: CutsceneCommand(rawData, rawDataIndex)
{
rawDataIndex += 4;
commandID = static_cast<uint32_t>(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<CutsceneCommands>(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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<CutsceneMMCommands>(commandID) ==
CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION)
{
result = "CS_PLAYER_ACTION";
}
else
{
result = "CS_ACTOR_ACTION";
}
}
else
{
if (static_cast<CutsceneCommands>(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<uint8_t>& 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<CutsceneMMCommands>(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<CutsceneCommands>(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<uint8_t>& 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<uint8_t>& 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;
}

View File

@ -0,0 +1,267 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#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<uint8_t>& 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<CutsceneSubCommandEntry*> entries;
CutsceneCommand(const std::vector<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& rawData, offset_t rawDataIndex);
std::string GenerateSourceCode() const override;
size_t GetCommandSize() const override;
};

View File

@ -104,6 +104,8 @@ void Struct_800A598C::ParseRawData()
if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment)
{
uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress);
unk_8_arr.reserve(unk_0);
for (size_t i = 0; i < unk_0; i++)
{
Struct_800A57C0 unk8_data(parent);
@ -117,6 +119,8 @@ void Struct_800A598C::ParseRawData()
if (unk_C != 0 && GETSEGNUM(unk_8) == parent->segment)
{
uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress);
unk_C_arr.reserve(unk_2);
for (size_t i = 0; i < unk_2; i++)
{
Struct_800A598C_2 unkC_data(parent);
@ -246,6 +250,8 @@ void Struct_800A5E28::ParseRawData()
if (unk_4 != 0 && GETSEGNUM(unk_4) == parent->segment)
{
uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress);
unk_4_arr.reserve(unk_2);
for (size_t i = 0; i < unk_2; i++)
{
Struct_800A598C unk_4_data(parent);

View File

@ -3,6 +3,7 @@
#include <map>
#include <string>
#include <vector>
#include <cstdint>
class OutputFormatter
{

View File

@ -5,7 +5,7 @@
#include <unordered_set>
#include "Globals.h"
#include "Utils/Directory.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
@ -76,7 +76,7 @@ static const std::unordered_set<std::string> sSections = {
ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath)
{
std::string cfgText = File::ReadAllText(cfgFolderPath / "overlay.cfg");
std::string cfgText = DiskFile::ReadAllText(cfgFolderPath / "overlay.cfg");
std::vector<std::string> cfgLines = StringHelper::Split(cfgText, "\n");
ZOverlay* ovl = new ZOverlay(StringHelper::Strip(cfgLines[0], "\r"));

View File

@ -199,8 +199,16 @@ bool WarningHandler::WasElevatedToError(WarningType warnType) {
* Print file/line/function info for debugging
*/
void WarningHandler::FunctionPreamble(const char* filename, int32_t line, const char* function) {
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) {
fprintf(stderr, "%s:%i: in function %s:\n", filename, line, function);
bool forcePrint = false;
#ifdef DEVELOPMENT
forcePrint = true;
#endif
fprintf(stderr, "\n");
if (forcePrint || Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) {
fprintf(stderr, "%s:%i: in function <%s>:\n", filename, line, function);
}
}

372
ZAPDTR/ZAPD/ZAPD.vcxproj Normal file
View File

@ -0,0 +1,372 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.props" Condition="Exists('..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}</ProjectGuid>
<RootNamespace>ZAPD</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>ZAPD</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>$(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<Profile>true</Profile>
<SubSystem>Console</SubSystem>
</Link>
<PreBuildEvent>
<Command>cd ..
mkdir build\ZAPD
python ZAPD/genbuildinfo.py</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<Profile>true</Profile>
<AdditionalDependencies>ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<SubSystem>Console</SubSystem>
</Link>
<PreBuildEvent>
<Command>cd ..
mkdir build\ZAPD
python ZAPD/genbuildinfo.py</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PreBuildEvent>
<Command>cd ..
mkdir build\ZAPD
python ZAPD/genbuildinfo.py</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PreBuildEvent>
<Command>cd ..
mkdir build\ZAPD
python ZAPD/genbuildinfo.py</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\build\ZAPD\BuildInfo.cpp" />
<ClCompile Include="..\lib\libgfxd\gfxd.c" />
<ClCompile Include="..\lib\libgfxd\uc.c" />
<ClCompile Include="..\lib\libgfxd\uc_f3d.c" />
<ClCompile Include="..\lib\libgfxd\uc_f3db.c" />
<ClCompile Include="..\lib\libgfxd\uc_f3dex.c" />
<ClCompile Include="..\lib\libgfxd\uc_f3dex2.c" />
<ClCompile Include="..\lib\libgfxd\uc_f3dexb.c" />
<ClCompile Include="CrashHandler.cpp" />
<ClCompile Include="Declaration.cpp" />
<ClCompile Include="GameConfig.cpp" />
<ClCompile Include="Globals.cpp" />
<ClCompile Include="ImageBackend.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="OtherStructs\CutsceneMM_Commands.cpp" />
<ClCompile Include="OtherStructs\Cutscene_Commands.cpp" />
<ClCompile Include="OtherStructs\SkinLimbStructs.cpp" />
<ClCompile Include="OutputFormatter.cpp" />
<ClCompile Include="WarningHandler.cpp" />
<ClCompile Include="ZActorList.cpp" />
<ClCompile Include="ZArray.cpp" />
<ClCompile Include="ZBackground.cpp" />
<ClCompile Include="ZCollisionPoly.cpp" />
<ClCompile Include="ZLimb.cpp" />
<ClCompile Include="ZMtx.cpp" />
<ClCompile Include="ZPath.cpp" />
<ClCompile Include="ZPlayerAnimationData.cpp" />
<ClCompile Include="ZRoom\Commands\SetActorCutsceneList.cpp" />
<ClCompile Include="ZRoom\Commands\SetAnimatedMaterialList.cpp" />
<ClCompile Include="ZRoom\Commands\SetCsCamera.cpp" />
<ClCompile Include="ZRoom\Commands\SetMinimapChests.cpp" />
<ClCompile Include="ZRoom\Commands\SetMinimapList.cpp" />
<ClCompile Include="ZRoom\Commands\SetWorldMapVisited.cpp" />
<ClCompile Include="ZRoom\Commands\Unused1D.cpp" />
<ClCompile Include="ZScalar.cpp" />
<ClCompile Include="ZAnimation.cpp" />
<ClCompile Include="ZBlob.cpp" />
<ClCompile Include="ZCollision.cpp" />
<ClCompile Include="ZCutscene.cpp" />
<ClCompile Include="ZDisplayList.cpp" />
<ClCompile Include="ZFile.cpp" />
<ClCompile Include="ZSkeleton.cpp" />
<ClCompile Include="ZResource.cpp" />
<ClCompile Include="ZRoom\Commands\EndMarker.cpp" />
<ClCompile Include="ZRoom\Commands\SetActorList.cpp" />
<ClCompile Include="ZRoom\Commands\SetAlternateHeaders.cpp" />
<ClCompile Include="ZRoom\Commands\SetCameraSettings.cpp" />
<ClCompile Include="ZRoom\Commands\SetCollisionHeader.cpp" />
<ClCompile Include="ZRoom\Commands\SetCutscenes.cpp" />
<ClCompile Include="ZRoom\Commands\SetEchoSettings.cpp" />
<ClCompile Include="ZRoom\Commands\SetEntranceList.cpp" />
<ClCompile Include="ZRoom\Commands\SetExitList.cpp" />
<ClCompile Include="ZRoom\Commands\SetLightingSettings.cpp" />
<ClCompile Include="ZRoom\Commands\SetLightList.cpp" />
<ClCompile Include="ZRoom\Commands\SetMesh.cpp" />
<ClCompile Include="ZRoom\Commands\SetObjectList.cpp" />
<ClCompile Include="ZRoom\Commands\SetPathways.cpp" />
<ClCompile Include="ZRoom\Commands\SetRoomBehavior.cpp" />
<ClCompile Include="ZRoom\Commands\SetRoomList.cpp" />
<ClCompile Include="ZRoom\Commands\SetSkyboxModifier.cpp" />
<ClCompile Include="ZRoom\Commands\SetSkyboxSettings.cpp" />
<ClCompile Include="ZRoom\Commands\SetSoundSettings.cpp" />
<ClCompile Include="ZRoom\Commands\SetSpecialObjects.cpp" />
<ClCompile Include="ZRoom\Commands\SetStartPositionList.cpp" />
<ClCompile Include="ZRoom\Commands\SetTimeSettings.cpp" />
<ClCompile Include="ZRoom\Commands\SetTransitionActorList.cpp" />
<ClCompile Include="ZRoom\Commands\SetWind.cpp" />
<ClCompile Include="ZRoom\Commands\Unused09.cpp" />
<ClCompile Include="ZRoom\Commands\ZRoomCommandUnk.cpp" />
<ClCompile Include="ZRoom\ZRoom.cpp" />
<ClCompile Include="ZRoom\ZRoomCommand.cpp" />
<ClCompile Include="ZString.cpp" />
<ClCompile Include="ZSurfaceType.cpp" />
<ClCompile Include="ZSymbol.cpp" />
<ClCompile Include="ZTexture.cpp" />
<ClCompile Include="ZTextureAnimation.cpp" />
<ClCompile Include="ZVector.cpp" />
<ClCompile Include="ZVtx.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\lib\elfio\elfio\elfio.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_dump.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_dynamic.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_header.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_note.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_relocation.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_section.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_segment.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_strings.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_symbols.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elfio_utils.hpp" />
<ClInclude Include="..\lib\elfio\elfio\elf_types.hpp" />
<ClInclude Include="..\lib\libgfxd\gbi.h" />
<ClInclude Include="..\lib\libgfxd\gfxd.h" />
<ClInclude Include="..\lib\libgfxd\priv.h" />
<ClInclude Include="..\lib\stb\stb_image.h" />
<ClInclude Include="..\lib\stb\stb_image_write.h" />
<ClInclude Include="..\lib\stb\tinyxml2.h" />
<ClInclude Include="CrashHandler.h" />
<ClInclude Include="CRC32.h" />
<ClInclude Include="Declaration.h" />
<ClInclude Include="GameConfig.h" />
<ClInclude Include="Globals.h" />
<ClInclude Include="ImageBackend.h" />
<ClInclude Include="OtherStructs\CutsceneMM_Commands.h" />
<ClInclude Include="OtherStructs\Cutscene_Commands.h" />
<ClInclude Include="OtherStructs\SkinLimbStructs.h" />
<ClInclude Include="OutputFormatter.h" />
<ClInclude Include="WarningHandler.h" />
<ClInclude Include="ZActorList.h" />
<ClInclude Include="ZAnimation.h" />
<ClInclude Include="ZArray.h" />
<ClInclude Include="ZBackground.h" />
<ClInclude Include="ZBlob.h" />
<ClInclude Include="ZCollision.h" />
<ClInclude Include="ZCollisionPoly.h" />
<ClInclude Include="ZCutscene.h" />
<ClInclude Include="ZDisplayList.h" />
<ClInclude Include="ZFile.h" />
<ClInclude Include="ZLimb.h" />
<ClInclude Include="ZMtx.h" />
<ClInclude Include="ZPath.h" />
<ClInclude Include="ZPlayerAnimationData.h" />
<ClInclude Include="ZRoom\Commands\SetActorCutsceneList.h" />
<ClInclude Include="ZRoom\Commands\SetAnimatedMaterialList.h" />
<ClInclude Include="ZRoom\Commands\SetCsCamera.h" />
<ClInclude Include="ZRoom\Commands\SetMinimapChests.h" />
<ClInclude Include="ZRoom\Commands\SetMinimapList.h" />
<ClInclude Include="ZRoom\Commands\SetWorldMapVisited.h" />
<ClInclude Include="ZRoom\Commands\Unused1D.h" />
<ClInclude Include="ZScalar.h" />
<ClInclude Include="ZSkeleton.h" />
<ClInclude Include="ZResource.h" />
<ClInclude Include="ZRoom\Commands\EndMarker.h" />
<ClInclude Include="ZRoom\Commands\SetActorList.h" />
<ClInclude Include="ZRoom\Commands\SetAlternateHeaders.h" />
<ClInclude Include="ZRoom\Commands\SetCameraSettings.h" />
<ClInclude Include="ZRoom\Commands\SetCollisionHeader.h" />
<ClInclude Include="ZRoom\Commands\SetCutscenes.h" />
<ClInclude Include="ZRoom\Commands\SetEchoSettings.h" />
<ClInclude Include="ZRoom\Commands\SetEntranceList.h" />
<ClInclude Include="ZRoom\Commands\SetExitList.h" />
<ClInclude Include="ZRoom\Commands\SetLightingSettings.h" />
<ClInclude Include="ZRoom\Commands\SetLightList.h" />
<ClInclude Include="ZRoom\Commands\SetMesh.h" />
<ClInclude Include="ZRoom\Commands\SetObjectList.h" />
<ClInclude Include="ZRoom\Commands\SetPathways.h" />
<ClInclude Include="ZRoom\Commands\SetRoomBehavior.h" />
<ClInclude Include="ZRoom\Commands\SetRoomList.h" />
<ClInclude Include="ZRoom\Commands\SetSkyboxModifier.h" />
<ClInclude Include="ZRoom\Commands\SetSkyboxSettings.h" />
<ClInclude Include="ZRoom\Commands\SetSoundSettings.h" />
<ClInclude Include="ZRoom\Commands\SetSpecialObjects.h" />
<ClInclude Include="ZRoom\Commands\SetStartPositionList.h" />
<ClInclude Include="ZRoom\Commands\SetTimeSettings.h" />
<ClInclude Include="ZRoom\Commands\SetTransitionActorList.h" />
<ClInclude Include="ZRoom\Commands\SetWind.h" />
<ClInclude Include="ZRoom\Commands\Unused09.h" />
<ClInclude Include="ZRoom\Commands\ZRoomCommandUnk.h" />
<ClInclude Include="ZRoom\ZRoom.h" />
<ClInclude Include="ZRoom\ZRoomCommand.h" />
<ClInclude Include="ZString.h" />
<ClInclude Include="ZSurfaceType.h" />
<ClInclude Include="ZSymbol.h" />
<ClInclude Include="ZTexture.h" />
<ClInclude Include="ZTextureAnimation.h" />
<ClInclude Include="ZVector.h" />
<ClInclude Include="ZVtx.h" />
</ItemGroup>
<ItemGroup>
<Text Include="..\SymbolMap_OoTMqDbg.txt">
<DeploymentContent>true</DeploymentContent>
</Text>
<Text Include="any\any\zlib.static.txt" />
<Text Include="NuGet\libpng.static.txt" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" />
<Import Project="..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets')" />
<Import Project="..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.targets" Condition="Exists('..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.targets')" />
<Import Project="..\packages\zlib.static.1.2.5\build\native\zlib.static.targets" Condition="Exists('..\packages\zlib.static.1.2.5\build\native\zlib.static.targets')" />
<Import Project="..\packages\libpng.static.1.6.37\build\native\libpng.static.targets" Condition="Exists('..\packages\libpng.static.1.6.37\build\native\libpng.static.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets'))" />
<Error Condition="!Exists('..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets'))" />
<Error Condition="!Exists('..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.props'))" />
<Error Condition="!Exists('..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.targets'))" />
<Error Condition="!Exists('..\packages\zlib.static.1.2.5\build\native\zlib.static.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\zlib.static.1.2.5\build\native\zlib.static.targets'))" />
<Error Condition="!Exists('..\packages\libpng.static.1.6.37\build\native\libpng.static.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\libpng.static.1.6.37\build\native\libpng.static.targets'))" />
</Target>
</Project>

View File

@ -0,0 +1,572 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Source Files\Libraries">
<UniqueIdentifier>{02148456-5068-4613-8478-f10addc58e70}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Libraries">
<UniqueIdentifier>{bcab3136-95ba-4839-833c-43d78ad6e335}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Libraries\elfio">
<UniqueIdentifier>{dc06ed84-f6fe-4277-80f3-d62bd5cdbb98}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Z64">
<UniqueIdentifier>{6049c045-bc38-4221-b29e-ca6d4d8af4aa}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Z64\ZRoom">
<UniqueIdentifier>{490e3a08-047b-48d3-ab53-3a860a3b92aa}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Z64\ZRoom\Commands">
<UniqueIdentifier>{26c06845-8e8e-4b79-ad18-07c4f9c0f801}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Z64">
<UniqueIdentifier>{d45c420d-2378-47ac-92c5-80db9475c195}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Z64\ZRoom">
<UniqueIdentifier>{03cc56a2-e0e8-4167-80a0-98fb900a959a}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Z64\ZRoom\Commands">
<UniqueIdentifier>{73db0879-6df8-4f6a-8cc2-a1f836e9e796}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Libraries\fbx">
<UniqueIdentifier>{be9a5be0-ec6a-4200-8e39-bb58c7da7aa8}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Libraries\libgfxd">
<UniqueIdentifier>{7ee79d97-c6a8-4e82-93ef-37981f4d7838}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Libraries\libgfxd">
<UniqueIdentifier>{85600275-99fe-491d-8189-bcc3dc1a8903}</UniqueIdentifier>
</Filter>
<Filter Include="any">
<UniqueIdentifier>{ba9990b0-1082-48bb-874c-6108534b5455}</UniqueIdentifier>
</Filter>
<Filter Include="any\any">
<UniqueIdentifier>{ce9d91b0-ba20-4296-bc2d-8630965bb392}</UniqueIdentifier>
</Filter>
<Filter Include="NuGet">
<UniqueIdentifier>{730beb67-6d59-4849-9d9b-702c4a565fc0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZRoom\ZRoom.cpp">
<Filter>Source Files\Z64\ZRoom</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetEchoSettings.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\ZRoomCommand.cpp">
<Filter>Source Files\Z64\ZRoom</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetSoundSettings.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetWind.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetTimeSettings.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetSpecialObjects.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetRoomBehavior.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetSkyboxSettings.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetCameraSettings.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetSkyboxModifier.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetActorList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetEntranceList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetStartPositionList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="Globals.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetAlternateHeaders.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetExitList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\EndMarker.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetCollisionHeader.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetRoomList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetObjectList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetMesh.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\Unused09.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetLightingSettings.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetTransitionActorList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetPathways.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetCutscenes.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZAnimation.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZBlob.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZCutscene.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZDisplayList.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZFile.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZResource.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZTexture.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZSkeleton.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetLightList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\ZRoomCommandUnk.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZCollision.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZScalar.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZVector.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZArray.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZVtx.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZLimb.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="OutputFormatter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZSymbol.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="..\lib\libgfxd\gfxd.c">
<Filter>Source Files\Libraries\libgfxd</Filter>
</ClCompile>
<ClCompile Include="..\lib\libgfxd\uc.c">
<Filter>Source Files\Libraries\libgfxd</Filter>
</ClCompile>
<ClCompile Include="..\lib\libgfxd\uc_f3d.c">
<Filter>Source Files\Libraries\libgfxd</Filter>
</ClCompile>
<ClCompile Include="..\lib\libgfxd\uc_f3db.c">
<Filter>Source Files\Libraries\libgfxd</Filter>
</ClCompile>
<ClCompile Include="..\lib\libgfxd\uc_f3dex.c">
<Filter>Source Files\Libraries\libgfxd</Filter>
</ClCompile>
<ClCompile Include="..\lib\libgfxd\uc_f3dex2.c">
<Filter>Source Files\Libraries\libgfxd</Filter>
</ClCompile>
<ClCompile Include="..\lib\libgfxd\uc_f3dexb.c">
<Filter>Source Files\Libraries\libgfxd</Filter>
</ClCompile>
<ClCompile Include="ZMtx.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetWorldMapVisited.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\Unused1D.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetActorCutsceneList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetCsCamera.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetMinimapChests.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetMinimapList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZBackground.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetAnimatedMaterialList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZPath.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="Declaration.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ImageBackend.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZString.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="GameConfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZTextureAnimation.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="OtherStructs\SkinLimbStructs.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="..\build\ZAPD\BuildInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZPlayerAnimationData.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="WarningHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZCollisionPoly.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="OtherStructs\Cutscene_Commands.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="OtherStructs\CutsceneMM_Commands.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="CrashHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZSurfaceType.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ZRoom\ZRoom.h">
<Filter>Header Files\Z64\ZRoom</Filter>
</ClInclude>
<ClInclude Include="ZRoom\ZRoomCommand.h">
<Filter>Header Files\Z64\ZRoom</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetEchoSettings.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetSoundSettings.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetWind.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetTimeSettings.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetSpecialObjects.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetRoomBehavior.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetSkyboxSettings.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetCameraSettings.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetSkyboxModifier.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetActorList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetEntranceList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetStartPositionList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elf_types.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_dump.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_dynamic.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_header.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_note.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_relocation.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_section.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_segment.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_strings.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_symbols.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="..\lib\elfio\elfio\elfio_utils.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="Globals.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetAlternateHeaders.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetExitList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\EndMarker.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetCollisionHeader.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetRoomList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetObjectList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetMesh.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\Unused09.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetLightingSettings.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetTransitionActorList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetPathways.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetCutscenes.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="..\lib\stb\stb_image.h">
<Filter>Header Files\Libraries</Filter>
</ClInclude>
<ClInclude Include="..\lib\stb\stb_image_write.h">
<Filter>Header Files\Libraries</Filter>
</ClInclude>
<ClInclude Include="ZTexture.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZAnimation.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZBlob.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZCutscene.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZDisplayList.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZFile.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZResource.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZSkeleton.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetLightList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\ZRoomCommandUnk.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZCollision.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZScalar.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZVector.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="..\lib\stb\tinyxml2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZArray.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZVtx.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="CRC32.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZLimb.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="OutputFormatter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZSymbol.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="..\lib\libgfxd\gbi.h">
<Filter>Header Files\Libraries\libgfxd</Filter>
</ClInclude>
<ClInclude Include="..\lib\libgfxd\gfxd.h">
<Filter>Header Files\Libraries\libgfxd</Filter>
</ClInclude>
<ClInclude Include="..\lib\libgfxd\priv.h">
<Filter>Header Files\Libraries\libgfxd</Filter>
</ClInclude>
<ClInclude Include="ZMtx.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetWorldMapVisited.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetActorCutsceneList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\Unused1D.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetCsCamera.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetMinimapChests.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetMinimapList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZBackground.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetAnimatedMaterialList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ImageBackend.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZPath.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="Declaration.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZString.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="GameConfig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZTextureAnimation.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="OtherStructs\SkinLimbStructs.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZPlayerAnimationData.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="WarningHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZCollisionPoly.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="OtherStructs\Cutscene_Commands.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="OtherStructs\CutsceneMM_Commands.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="CrashHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZSurfaceType.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="..\SymbolMap_OoTMqDbg.txt">
<Filter>Resource Files</Filter>
</Text>
<Text Include="any\any\zlib.static.txt">
<Filter>any\any</Filter>
</Text>
<Text Include="NuGet\libpng.static.txt">
<Filter>NuGet</Filter>
</Text>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

194
ZAPDTR/ZAPD/ZActorList.cpp Normal file
View File

@ -0,0 +1,194 @@
#include "ZActorList.h"
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "WarningHandler.h"
#include "ZFile.h"
#include "ZRoom/ZNames.h"
REGISTER_ZFILENODE(ActorList, ZActorList);
ZActorList::ZActorList(ZFile* nParent) : ZResource(nParent)
{
RegisterRequiredAttribute("Count");
}
void ZActorList::ExtractFromBinary(uint32_t nRawDataIndex, uint8_t nNumActors)
{
rawDataIndex = nRawDataIndex;
numActors = nNumActors;
// Don't parse raw data of external files
if (parent->GetMode() == ZFileMode::ExternalFile)
return;
ParseRawData();
}
void ZActorList::ParseXML(tinyxml2::XMLElement* reader)
{
ZResource::ParseXML(reader);
numActors = StringHelper::StrToL(registeredAttributes.at("Count").value);
if (numActors < 1)
{
HANDLE_ERROR_RESOURCE(
WarningType::InvalidAttributeValue, parent, this, rawDataIndex,
StringHelper::Sprintf("invalid value '%d' found for 'NumPaths' attribute", numActors),
"Should be at least '1'");
}
}
void ZActorList::ParseRawData()
{
ZResource::ParseRawData();
offset_t currentPtr = rawDataIndex;
size_t largestlength = 0;
for (size_t i = 0; i < numActors; i++)
{
ActorSpawnEntry entry(parent->GetRawData(), currentPtr);
currentPtr += entry.GetRawDataSize();
actors.push_back(entry);
size_t actorNameLength = ZNames::GetActorName(entry.GetActorId()).size();
if (actorNameLength > largestlength)
largestlength = actorNameLength;
}
for (auto& entry : actors)
{
entry.SetLargestActorName(largestlength);
}
}
Declaration* ZActorList::DeclareVar(const std::string& prefix, const std::string& bodyStr)
{
std::string auxName = name;
if (name == "")
auxName = GetDefaultName(prefix);
Declaration* decl =
parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(),
GetSourceTypeName(), name, GetActorListArraySize(), bodyStr);
decl->staticConf = staticConf;
return decl;
}
std::string ZActorList::GetBodySourceCode() const
{
std::string declaration;
size_t index = 0;
for (auto& entry : actors)
{
declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str());
if (index < actors.size() - 1)
declaration += "\n";
index++;
}
return declaration;
}
std::string ZActorList::GetSourceTypeName() const
{
return actors.front().GetSourceTypeName();
}
ZResourceType ZActorList::GetResourceType() const
{
return ZResourceType::ActorList;
}
size_t ZActorList::GetRawDataSize() const
{
return actors.size() * actors.front().GetRawDataSize();
}
size_t ZActorList::GetActorListArraySize() const
{
size_t actorCount = 0;
// Doing an else-if here so we only do the loop when the game is SW97.
// Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count
// for it.
if (Globals::Instance->game == ZGame::OOT_SW97)
{
actorCount = 0;
for (const auto& entry : actors)
if (entry.GetActorId() != 0x22)
actorCount++;
}
else
{
actorCount = actors.size();
}
return actorCount;
}
/* ActorSpawnEntry */
ActorSpawnEntry::ActorSpawnEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
{
actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8);
rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10);
rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12);
params = BitConverter::ToInt16BE(rawData, rawDataIndex + 14);
}
std::string ActorSpawnEntry::GetBodySourceCode() const
{
std::string body;
std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1);
body =
StringHelper::Sprintf(actorNameFmt.c_str(), (ZNames::GetActorName(actorNum) + ",").c_str());
body += StringHelper::Sprintf("{ %6i, %6i, %6i }, ", posX, posY, posZ);
if (Globals::Instance->game == ZGame::MM_RETAIL)
body += StringHelper::Sprintf("{ SPAWN_ROT_FLAGS(%#5hX, 0x%04X)"
", SPAWN_ROT_FLAGS(%#5hX, 0x%04X)"
", SPAWN_ROT_FLAGS(%#5hX, 0x%04X) }, ",
(rotX >> 7) & 0b111111111, rotX & 0b1111111,
(rotY >> 7) & 0b111111111, rotY & 0b1111111,
(rotZ >> 7) & 0b111111111, rotZ & 0b1111111);
else
body += StringHelper::Sprintf("{ %#6hX, %#6hX, %#6hX }, ", rotX, rotY, rotZ);
body += StringHelper::Sprintf("0x%04X", params);
return body;
}
std::string ActorSpawnEntry::GetSourceTypeName() const
{
return "ActorEntry";
}
size_t ActorSpawnEntry::GetRawDataSize() const
{
return 16;
}
uint16_t ActorSpawnEntry::GetActorId() const
{
return actorNum;
}
void ActorSpawnEntry::SetLargestActorName(size_t nameSize)
{
largestActorName = nameSize;
}

52
ZAPDTR/ZAPD/ZActorList.h Normal file
View File

@ -0,0 +1,52 @@
#pragma once
#include "ZResource.h"
class ActorSpawnEntry
{
public:
uint16_t actorNum;
int16_t posX;
int16_t posY;
int16_t posZ;
uint16_t rotX;
uint16_t rotY;
uint16_t rotZ;
uint16_t params;
size_t largestActorName = 16;
ActorSpawnEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetBodySourceCode() const;
std::string GetSourceTypeName() const;
size_t GetRawDataSize() const;
uint16_t GetActorId() const;
void SetLargestActorName(size_t nameSize);
};
class ZActorList : public ZResource
{
public:
std::vector<ActorSpawnEntry> actors;
uint32_t numActors = 0;
ZActorList(ZFile* nParent);
void ExtractFromBinary(offset_t nRawDataIndex, uint8_t nNumActors);
void ParseXML(tinyxml2::XMLElement* reader) override;
void ParseRawData() override;
Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override;
std::string GetBodySourceCode() const override;
std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;
size_t GetRawDataSize() const override;
protected:
size_t GetActorListArraySize() const;
};

View File

@ -4,7 +4,7 @@
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
#include "ZFile.h"
@ -67,7 +67,7 @@ void ZNormalAnimation::ParseRawData()
{
ZAnimation::ParseRawData();
const uint8_t* data = parent->GetRawData().data();
auto& data = parent->GetRawData();
rotationValuesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 4);
rotationIndicesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 8);

View File

@ -44,6 +44,7 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader)
auto nodeMap = ZFile::GetNodeMap();
size_t childIndex = rawDataIndex;
resList.reserve(arrayCnt);
for (size_t i = 0; i < arrayCnt; i++)
{
ZResource* res = nodeMap->at(childName)(parent);
@ -95,17 +96,27 @@ Declaration* ZArray::DeclareVar(const std::string& prefix, const std::string& bo
std::string ZArray::GetBodySourceCode() const
{
std::string output = "";
std::string output;
for (size_t i = 0; i < arrayCnt; i++)
{
const auto& res = resList[i];
output += "\t";
if (res->GetResourceType() == ZResourceType::Scalar || res->GetResourceType() == ZResourceType::Vertex)
switch (res->GetResourceType())
{
case ZResourceType::Pointer:
case ZResourceType::Scalar:
case ZResourceType::Vertex:
case ZResourceType::CollisionPoly:
case ZResourceType::SurfaceType:
output += resList.at(i)->GetBodySourceCode();
else
break;
default:
output += StringHelper::Sprintf("{ %s }", resList.at(i)->GetBodySourceCode().c_str());
break;
}
if (i < arrayCnt - 1 || res->IsExternalResource())
output += ",\n";
@ -117,7 +128,7 @@ std::string ZArray::GetBodySourceCode() const
size_t ZArray::GetRawDataSize() const
{
size_t size = 0;
for (auto res : resList)
for (const auto res : resList)
size += res->GetRawDataSize();
return size;
}

View File

@ -2,7 +2,7 @@
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"

View File

@ -2,7 +2,7 @@
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
@ -46,7 +46,7 @@ void ZBackground::ParseBinaryFile(const std::string& inFolder, bool appendOutNam
if (appendOutName)
filepath = filepath / (outName + "." + GetExternalExtension());
data = File::ReadAllBytes(filepath.string());
data = DiskFile::ReadAllBytes(filepath.string());
// Add padding.
data.insert(data.end(), GetRawDataSize() - data.size(), 0x00);
@ -153,7 +153,7 @@ void ZBackground::Save(const fs::path& outFolder)
if (!Globals::Instance->otrMode)
{
fs::path filepath = outFolder / (outName + "." + GetExternalExtension());
File::WriteAllBytes(filepath.string(), data);
DiskFile::WriteAllBytes(filepath.string(), data);
}
}

View File

@ -2,7 +2,7 @@
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
@ -19,7 +19,7 @@ ZBlob* ZBlob::FromFile(const std::string& filePath)
{
ZBlob* blob = new ZBlob(nullptr);
blob->name = StringHelper::Split(Path::GetFileNameWithoutExtension(filePath), ".")[0];
blob->blobData = File::ReadAllBytes(filePath);
blob->blobData = DiskFile::ReadAllBytes(filePath);
return blob;
}
@ -87,7 +87,7 @@ std::string ZBlob::GetBodySourceCode() const
void ZBlob::Save(const fs::path& outFolder)
{
if (!Globals::Instance->otrMode)
File::WriteAllBytes((outFolder / (name + ".bin")).string(), blobData);
DiskFile::WriteAllBytes((outFolder / (name + ".bin")).string(), blobData);
}
bool ZBlob::IsExternalResource() const

View File

@ -1,5 +1,6 @@
#include "ZCollision.h"
#include <cassert>
#include <cstdint>
#include <string>
@ -51,7 +52,7 @@ void ZCollisionHeader::ParseRawData()
vertices.reserve(numVerts);
polygons.reserve(numPolygons);
uint32_t currentPtr = vtxSegmentOffset;
offset_t currentPtr = vtxSegmentOffset;
for (uint16_t i = 0; i < numVerts; i++)
{
@ -63,23 +64,67 @@ void ZCollisionHeader::ParseRawData()
}
for (uint16_t i = 0; i < numPolygons; i++)
polygons.push_back(PolygonEntry(rawData, polySegmentOffset + (i * 16)));
{
ZCollisionPoly poly(parent);
poly.SetRawDataIndex(polySegmentOffset + (i * 16));
poly.ParseRawData();
polygons.push_back(poly);
}
uint16_t highestPolyType = 0;
for (PolygonEntry poly : polygons)
for (const ZCollisionPoly& poly : polygons)
{
if (poly.type > highestPolyType)
highestPolyType = poly.type;
}
for (uint16_t i = 0; i < highestPolyType + 1; i++)
polygonTypes.push_back(
BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8)));
{
ZSurfaceType surfaceType(parent);
surfaceType.SetRawDataIndex(polyTypeDefSegmentOffset + (i * 8));
surfaceType.ParseRawData();
PolygonTypes.push_back(surfaceType);
}
// polygonTypes.push_back(
// BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8)));
if (camDataAddress != 0)
camData = new CameraDataList(parent, name, rawData, camDataSegmentOffset,
polyTypeDefSegmentOffset, polygonTypes.size());
if (camDataAddress != SEGMENTED_NULL)
{
// Try to guess how many elements the CamDataList array has.
// The "guessing algorithm" is basically a "best effort" one and it
// is error-prone.
// This is based mostly on observation of how CollisionHeader data is
// usually ordered. If for some reason the data was in some other funny
// order, this would probably break.
// The most common ordering is:
// - *CamData*
// - SurfaceType
// - CollisionPoly
// - Vertices
// - WaterBoxes
// - CollisionHeader
offset_t upperCameraBoundary = polyTypeDefSegmentOffset;
if (upperCameraBoundary == 0)
{
upperCameraBoundary = polySegmentOffset;
}
if (upperCameraBoundary == 0)
{
upperCameraBoundary = vtxSegmentOffset;
}
if (upperCameraBoundary == 0)
{
upperCameraBoundary = waterBoxSegmentOffset;
}
if (upperCameraBoundary == 0)
{
upperCameraBoundary = rawDataIndex;
}
camData =
new CameraDataList(parent, name, rawData, camDataSegmentOffset, upperCameraBoundary);
}
for (uint16_t i = 0; i < numWaterBoxes; i++)
waterBoxes.push_back(WaterBoxHeader(
@ -110,8 +155,7 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix)
parent->AddDeclarationArray(
waterBoxSegmentOffset, DeclarationAlignment::Align4, 16 * waterBoxes.size(), "WaterBox",
StringHelper::Sprintf("%s_waterBoxes_%06X", auxName.c_str(), waterBoxSegmentOffset),
waterBoxes.size(), declaration);
StringHelper::Sprintf("%sWaterBoxes", auxName.c_str()), waterBoxes.size(), declaration);
}
if (polygons.size() > 0)
@ -122,40 +166,31 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix)
{
for (size_t i = 0; i < polygons.size(); i++)
{
declaration += StringHelper::Sprintf(
"\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },",
polygons[i].type, polygons[i].vtxA, polygons[i].vtxB, polygons[i].vtxC,
polygons[i].a, polygons[i].b, polygons[i].c, polygons[i].d);
declaration +=
StringHelper::Sprintf("\t%s,", polygons[i].GetBodySourceCode().c_str());
if (i + 1 < polygons.size())
declaration += "\n";
}
}
parent->AddDeclarationArray(
polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, "CollisionPoly",
StringHelper::Sprintf("%s_polygons_%08X", auxName.c_str(), polySegmentOffset),
parent->AddDeclarationArray(polySegmentOffset, DeclarationAlignment::Align4,
polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(),
StringHelper::Sprintf("%sPolygons", auxName.c_str()),
polygons.size(), declaration);
}
declaration.clear();
if (!Globals::Instance->otrMode)
for (const auto& polyType : PolygonTypes)
{
for (size_t i = 0; i < polygonTypes.size(); i++)
{
declaration += StringHelper::Sprintf("\t{ 0x%08lX, 0x%08lX },", polygonTypes[i] >> 32,
polygonTypes[i] & 0xFFFFFFFF);
if (i < polygonTypes.size() - 1)
declaration += "\n";
}
declaration += StringHelper::Sprintf("\t%s,", polyType.GetBodySourceCode().c_str());
}
if (polyTypeDefAddress != 0)
parent->AddDeclarationArray(
polyTypeDefSegmentOffset, DeclarationAlignment::Align4, polygonTypes.size() * 8,
"SurfaceType",
StringHelper::Sprintf("%s_surfaceType_%08X", auxName.c_str(), polyTypeDefSegmentOffset),
polygonTypes.size(), declaration);
if (polyTypeDefAddress != SEGMENTED_NULL)
parent->AddDeclarationArray(polyTypeDefSegmentOffset, DeclarationAlignment::Align4,
PolygonTypes.size() * 8,
PolygonTypes[0].GetSourceTypeName().c_str(),
StringHelper::Sprintf("%sSurfaceType", auxName.c_str()),
PolygonTypes.size(), declaration);
declaration.clear();
@ -180,8 +215,7 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix)
parent->AddDeclarationArray(
vtxSegmentOffset, first.GetDeclarationAlignment(),
vertices.size() * first.GetRawDataSize(), first.GetSourceTypeName(),
StringHelper::Sprintf("%s_vtx_%08X", auxName.c_str(), vtxSegmentOffset),
vertices.size(), declaration);
StringHelper::Sprintf("%sVertices", auxName.c_str()), vertices.size(), declaration);
}
}
@ -244,34 +278,18 @@ size_t ZCollisionHeader::GetRawDataSize() const
return 44;
}
PolygonEntry::PolygonEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
{
const uint8_t* data = rawData.data();
type = BitConverter::ToUInt16BE(data, rawDataIndex + 0);
vtxA = BitConverter::ToUInt16BE(data, rawDataIndex + 2);
vtxB = BitConverter::ToUInt16BE(data, rawDataIndex + 4);
vtxC = BitConverter::ToUInt16BE(data, rawDataIndex + 6);
a = BitConverter::ToUInt16BE(data, rawDataIndex + 8);
b = BitConverter::ToUInt16BE(data, rawDataIndex + 10);
c = BitConverter::ToUInt16BE(data, rawDataIndex + 12);
d = BitConverter::ToUInt16BE(data, rawDataIndex + 14);
}
WaterBoxHeader::WaterBoxHeader(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
{
const uint8_t* data = rawData.data();
xMin = BitConverter::ToInt16BE(data, rawDataIndex + 0);
ySurface = BitConverter::ToInt16BE(data, rawDataIndex + 2);
zMin = BitConverter::ToInt16BE(data, rawDataIndex + 4);
xLength = BitConverter::ToInt16BE(data, rawDataIndex + 6);
zLength = BitConverter::ToInt16BE(data, rawDataIndex + 8);
xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
ySurface = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
zMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
xLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
zLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 8);
if (Globals::Instance->game == ZGame::OOT_SW97)
properties = BitConverter::ToInt16BE(data, rawDataIndex + 10);
properties = BitConverter::ToInt16BE(rawData, rawDataIndex + 10);
else
properties = BitConverter::ToInt32BE(data, rawDataIndex + 12);
properties = BitConverter::ToInt32BE(rawData, rawDataIndex + 12);
}
std::string WaterBoxHeader::GetBodySourceCode() const
@ -281,16 +299,17 @@ std::string WaterBoxHeader::GetBodySourceCode() const
}
CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
const std::vector<uint8_t>& rawData, uint32_t rawDataIndex,
uint32_t polyTypeDefSegmentOffset,
[[maybe_unused]] uint32_t polygonTypesCnt)
const std::vector<uint8_t>& rawData, offset_t rawDataIndex,
offset_t upperCameraBoundary)
{
std::string declaration;
// Parse CameraDataEntries
int32_t numElements = (polyTypeDefSegmentOffset - rawDataIndex) / 8;
uint32_t cameraPosDataSeg = rawDataIndex;
for (int32_t i = 0; i < numElements; i++)
size_t numElements = (upperCameraBoundary - rawDataIndex) / 8;
assert(numElements < 10000);
offset_t cameraPosDataSeg = rawDataIndex;
for (size_t i = 0; i < numElements; i++)
{
CameraDataEntry* entry = new CameraDataEntry();
@ -322,8 +341,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
{
int32_t index =
((entries[i]->cameraPosDataSeg & 0x00FFFFFF) - cameraPosDataOffset) / 0x6;
sprintf(camSegLine, "&%s_camPosData_%08X[%i]", prefix.c_str(), cameraPosDataOffset,
index);
sprintf(camSegLine, "&%sCamPosData[%i]", prefix.c_str(), index);
}
else
sprintf(camSegLine, "NULL");
@ -338,7 +356,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
parent->AddDeclarationArray(
rawDataIndex, DeclarationAlignment::Align4, entries.size() * 8, "CamData",
StringHelper::Sprintf("%s_camDataList_%08X", prefix.c_str(), rawDataIndex), entries.size(),
StringHelper::Sprintf("%sCamDataList", prefix.c_str(), rawDataIndex), entries.size(),
declaration);
uint32_t numDataTotal = (rawDataIndex - cameraPosDataOffset) / 0x6;
@ -359,9 +377,8 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
int32_t cameraPosDataIndex = GETSEGOFFSET(cameraPosDataSeg);
uint32_t entrySize = numDataTotal * 0x6;
parent->AddDeclarationArray(
cameraPosDataIndex, DeclarationAlignment::Align4, entrySize, "Vec3s",
StringHelper::Sprintf("%s_camPosData_%08X", prefix.c_str(), cameraPosDataIndex),
parent->AddDeclarationArray(cameraPosDataIndex, DeclarationAlignment::Align4, entrySize,
"Vec3s", StringHelper::Sprintf("%sCamPosData", prefix.c_str()),
numDataTotal, declaration);
}
}

View File

@ -1,20 +1,12 @@
#pragma once
#include "ZCollisionPoly.h"
#include "ZFile.h"
#include "ZResource.h"
#include "ZRoom/ZRoom.h"
#include "ZSurfaceType.h"
#include "ZVector.h"
class PolygonEntry
{
public:
uint16_t type;
uint16_t vtxA, vtxB, vtxC;
uint16_t a, b, c, d;
PolygonEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class WaterBoxHeader
{
public:
@ -54,8 +46,7 @@ public:
std::vector<CameraPositionData*> cameraPositionData;
CameraDataList(ZFile* parent, const std::string& prefix, const std::vector<uint8_t>& rawData,
uint32_t rawDataIndex, uint32_t polyTypeDefSegmentOffset,
uint32_t polygonTypesCnt);
offset_t rawDataIndex, offset_t upperCameraBoundary);
~CameraDataList();
};
@ -78,8 +69,8 @@ public:
waterBoxSegmentOffset;
std::vector<ZVector> vertices;
std::vector<PolygonEntry> polygons;
std::vector<uint64_t> polygonTypes;
std::vector<ZCollisionPoly> polygons;
std::vector<ZSurfaceType> PolygonTypes;
std::vector<WaterBoxHeader> waterBoxes;
CameraDataList* camData = nullptr;

View File

@ -0,0 +1,78 @@
#include "ZCollisionPoly.h"
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
REGISTER_ZFILENODE(CollisionPoly, ZCollisionPoly);
ZCollisionPoly::ZCollisionPoly(ZFile* nParent) : ZResource(nParent)
{
}
ZCollisionPoly::~ZCollisionPoly()
{
}
void ZCollisionPoly::ParseRawData()
{
const auto& rawData = parent->GetRawData();
type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0);
vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2);
vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4);
vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6);
normX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8);
normY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10);
normZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12);
dist = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14);
}
void ZCollisionPoly::DeclareReferences(const std::string& prefix)
{
std::string declaration;
std::string auxName = name;
if (name == "")
auxName = GetDefaultName(prefix);
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(),
GetSourceTypeName(), name.c_str(), GetBodySourceCode());
}
std::string ZCollisionPoly::GetBodySourceCode() const
{
std::string declaration;
declaration +=
StringHelper::Sprintf("{0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X}",
type, vtxA, vtxB, vtxC, normX, normY, normZ, dist);
return declaration;
}
std::string ZCollisionPoly::GetDefaultName(const std::string& prefix) const
{
return StringHelper::Sprintf("%sCollisionPoly_%06X", prefix.c_str(), rawDataIndex);
}
ZResourceType ZCollisionPoly::GetResourceType() const
{
return ZResourceType::CollisionPoly;
}
size_t ZCollisionPoly::GetRawDataSize() const
{
return 16;
}
std::string ZCollisionPoly::GetSourceTypeName() const
{
return "CollisionPoly";
}
bool ZCollisionPoly::DoesSupportArray() const
{
return true;
}

View File

@ -0,0 +1,29 @@
#pragma once
#include "ZFile.h"
#include "ZResource.h"
class ZCollisionPoly : public ZResource
{
public:
uint16_t type;
uint16_t vtxA, vtxB, vtxC;
uint16_t normX, normY, normZ;
uint16_t dist;
ZCollisionPoly(ZFile* nParent);
~ZCollisionPoly();
void ParseRawData() override;
void DeclareReferences(const std::string& prefix) override;
std::string GetBodySourceCode() const override;
std::string GetDefaultName(const std::string& prefix) const override;
std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;
bool DoesSupportArray() const override;
size_t GetRawDataSize() const override;
};

File diff suppressed because it is too large Load Diff

View File

@ -3,422 +3,13 @@
#include <cstdint>
#include <string>
#include <vector>
#include "ZFile.h"
#include "ZResource.h"
#include "tinyxml2.h"
enum class CutsceneCommands
{
Cmd00 = 0x0000,
SetCameraPos = 0x0001,
SetCameraFocus = 0x0002,
SpecialAction = 0x0003,
SetLighting = 0x0004,
SetCameraPosLink = 0x0005,
SetCameraFocusLink = 0x0006,
Cmd07 = 0x0007,
Cmd08 = 0x0008,
Cmd09 = 0x0009,
Unknown = 0x001A,
Textbox = 0x0013,
SetActorAction0 = 0x000A,
SetActorAction1 = 0x000F,
SetActorAction2 = 0x000E,
SetActorAction3 = 0x0019,
SetActorAction4 = 0x001D,
SetActorAction5 = 0x001E,
SetActorAction6 = 0x002C,
SetActorAction7 = 0x001F,
SetActorAction8 = 0x0031,
SetActorAction9 = 0x003E,
SetActorAction10 = 0x008F,
SetSceneTransFX = 0x002D,
Nop = 0x000B,
PlayBGM = 0x0056,
StopBGM = 0x0057,
FadeBGM = 0x007C,
SetTime = 0x008C,
Terminator = 0x03E8,
End = 0xFFFF,
Error = 0xFEAF,
};
#include "OtherStructs/Cutscene_Commands.h"
#include "ZFile.h"
#include "ZResource.h"
class CutsceneCameraPoint
{
public:
int8_t continueFlag;
int8_t cameraRoll;
int16_t nextPointFrame;
float viewAngle;
int16_t posX, posY, posZ;
int16_t unused;
CutsceneCameraPoint(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommand
{
public:
uint32_t commandID;
uint32_t commandIndex;
virtual ~CutsceneCommand();
CutsceneCommand(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
virtual std::string GetCName();
virtual std::string GenerateSourceCode(uint32_t baseAddress);
virtual size_t GetCommandSize();
};
class CutsceneCommandSetCameraPos : public CutsceneCommand
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
uint16_t unused;
std::vector<CutsceneCameraPoint*> entries;
~CutsceneCommandSetCameraPos();
CutsceneCommandSetCameraPos(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class SpecialActionEntry
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
uint16_t unused0;
uint32_t unused1;
uint32_t unused2;
uint32_t unused3;
uint32_t unused4;
uint32_t unused5;
uint32_t unused6;
uint32_t unused7;
uint32_t unused8;
uint32_t unused9;
uint32_t unused10;
SpecialActionEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommandSpecialAction : public CutsceneCommand
{
public:
std::vector<SpecialActionEntry*> entries;
CutsceneCommandSpecialAction(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandSpecialAction();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class MusicFadeEntry
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
uint16_t unknown0;
uint32_t unknown1;
uint32_t unknown2;
uint32_t unknown3;
uint32_t unknown4;
uint32_t unknown5;
uint32_t unknown6;
uint32_t unknown7;
uint32_t unknown8;
uint32_t unknown9;
uint32_t unknown10;
MusicFadeEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommandFadeBGM : public CutsceneCommand
{
public:
std::vector<MusicFadeEntry*> entries;
CutsceneCommandFadeBGM(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandFadeBGM();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class MusicChangeEntry
{
public:
uint16_t sequence;
uint16_t startFrame;
uint16_t endFrame;
uint16_t unknown0;
uint32_t unknown1;
uint32_t unknown2;
uint32_t unknown3;
uint32_t unknown4;
uint32_t unknown5;
uint32_t unknown6;
uint32_t unknown7;
MusicChangeEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommandPlayBGM : public CutsceneCommand
{
public:
std::vector<MusicChangeEntry*> entries;
CutsceneCommandPlayBGM(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandPlayBGM();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class CutsceneCommandStopBGM : public CutsceneCommand
{
public:
std::vector<MusicChangeEntry*> entries;
CutsceneCommandStopBGM(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandStopBGM();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class EnvLightingEntry
{
public:
uint16_t setting;
uint16_t startFrame;
uint16_t endFrame;
uint16_t unused0;
uint32_t unused1;
uint32_t unused2;
uint32_t unused3;
uint32_t unused4;
uint32_t unused5;
uint32_t unused6;
uint32_t unused7;
EnvLightingEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommandEnvLighting : public CutsceneCommand
{
public:
std::vector<EnvLightingEntry*> entries;
CutsceneCommandEnvLighting(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandEnvLighting();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class CutsceneCommandSceneTransFX : public CutsceneCommand
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
~CutsceneCommandSceneTransFX();
CutsceneCommandSceneTransFX(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class Unknown9Entry
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
uint16_t unk2;
uint16_t unk3;
uint16_t unk4;
uint8_t unused0;
uint8_t unused1;
Unknown9Entry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommandUnknown9 : public CutsceneCommand
{
public:
std::vector<Unknown9Entry*> entries;
CutsceneCommandUnknown9(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandUnknown9();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class UnkEntry
{
public:
uint32_t unused0;
uint32_t unused1;
uint32_t unused2;
uint32_t unused3;
uint32_t unused4;
uint32_t unused5;
uint32_t unused6;
uint32_t unused7;
uint32_t unused8;
uint32_t unused9;
uint32_t unused10;
uint32_t unused11;
UnkEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommandUnknown : public CutsceneCommand
{
public:
std::vector<UnkEntry*> entries;
CutsceneCommandUnknown(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandUnknown();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class DayTimeEntry
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
uint8_t hour;
uint8_t minute;
uint8_t unused;
DayTimeEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommandDayTime : public CutsceneCommand
{
public:
std::vector<DayTimeEntry*> entries;
CutsceneCommandDayTime(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandDayTime();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class TextboxEntry
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
uint16_t type;
uint16_t textID1;
uint16_t textID2;
TextboxEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommandTextbox : public CutsceneCommand
{
public:
std::vector<TextboxEntry*> entries;
CutsceneCommandTextbox(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandTextbox();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class ActorAction
{
public:
uint16_t action;
uint16_t startFrame;
uint16_t endFrame;
int16_t rotX, rotY, rotZ;
int32_t startPosX, startPosY, startPosZ;
int32_t endPosX, endPosY, endPosZ;
float normalX, normalY, normalZ;
ActorAction(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
class CutsceneCommandActorAction : public CutsceneCommand
{
public:
std::vector<ActorAction*> entries;
CutsceneCommandActorAction(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
~CutsceneCommandActorAction();
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class CutsceneCommandTerminator : public CutsceneCommand
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
uint16_t unknown;
CutsceneCommandTerminator(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class CutsceneCommandEnd : public CutsceneCommand
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
CutsceneCommandEnd(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetCName();
std::string GenerateSourceCode(uint32_t baseAddress);
size_t GetCommandSize();
};
class CutsceneCommandNop : public CutsceneCommand
{
public:
uint16_t base;
uint16_t startFrame;
uint16_t endFrame;
CutsceneCommandNop(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetCName();
size_t GetCommandSize();
};
class ZCutsceneBase : public ZResource
{
public:
ZCutsceneBase(ZFile* nParent);
Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override;
std::string GetSourceTypeName() const override;
};
class ZCutscene : public ZCutsceneBase
class ZCutscene : public ZResource
{
public:
ZCutscene(ZFile* nParent);
@ -426,15 +17,20 @@ public:
void ParseRawData() override;
Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override;
std::string GetBodySourceCode() const override;
size_t GetRawDataSize() const override;
std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;
CutsceneCommands GetCommandFromID(int32_t id);
int32_t numCommands;
int32_t endFrame;
std::vector<CutsceneCommand*> commands;
protected:
CutsceneCommand* GetCommandOoT(uint32_t id, offset_t currentPtr) const;
CutsceneCommand* GetCommandMM(uint32_t id, offset_t currentPtr) const;
};

View File

@ -1,61 +0,0 @@
#include "ZCutsceneMM.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
ZCutsceneMM::ZCutsceneMM(ZFile* nParent) : ZCutsceneBase(nParent)
{
}
ZCutsceneMM::~ZCutsceneMM()
{
for (CutsceneCommand* cmd : commands)
delete cmd;
}
std::string ZCutsceneMM::GetBodySourceCode() const
{
std::string output;
output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),", numCommands, endFrame);
for (size_t i = 0; i < data.size(); i++)
{
if ((i % 4) == 0)
output += "\n ";
output += StringHelper::Sprintf("0x%08X, ", data[i]);
}
return output;
}
size_t ZCutsceneMM::GetRawDataSize() const
{
return 8 + data.size() * 4;
}
void ZCutsceneMM::ParseRawData()
{
const auto& rawData = parent->GetRawData();
numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0);
commands = std::vector<CutsceneCommand*>();
endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
uint32_t currentPtr = rawDataIndex + 8;
uint32_t lastData = 0;
// TODO currently cutscenes aren't being parsed, so just consume words until we see an end
// marker.
do
{
lastData = BitConverter::ToInt32BE(rawData, currentPtr);
data.push_back(lastData);
currentPtr += 4;
} while (lastData != 0xFFFFFFFF);
}
ZResourceType ZCutsceneMM::GetResourceType() const
{
return ZResourceType::Cutscene;
}

View File

@ -1,29 +0,0 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include "ZCutscene.h"
#include "ZFile.h"
#include "tinyxml2.h"
class ZCutsceneMM : public ZCutsceneBase
{
public:
ZCutsceneMM(ZFile* nParent);
virtual ~ZCutsceneMM();
std::string GetBodySourceCode() const override;
size_t GetRawDataSize() const override;
void ParseRawData() override;
ZResourceType GetResourceType() const override;
protected:
int32_t numCommands;
int32_t endFrame;
std::vector<CutsceneCommand*> commands;
std::vector<uint32_t> data;
};

View File

@ -9,7 +9,7 @@
#include "Globals.h"
#include "OutputFormatter.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
@ -213,6 +213,7 @@ void ZDisplayList::ParseRawData()
instructions.reserve(numInstructions);
uint32_t ptr = rawDataIndex;
instructions.reserve(numInstructions);
for (size_t i = 0; i < numInstructions; i++)
{
instructions.push_back(BitConverter::ToUInt64BE(rawData, ptr));
@ -1981,7 +1982,7 @@ void ZDisplayList::DeclareReferences(const std::string& prefix)
// Generate Vertex Declarations
std::vector<int32_t> vtxKeys;
vtxKeys.reserve(vertices.size());
for (auto& item : vertices)
vtxKeys.push_back(item.first);

View File

@ -10,7 +10,7 @@
#include "Utils/BinaryWriter.h"
#include "Utils/BitConverter.h"
#include "Utils/Directory.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/MemoryStream.h"
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
@ -190,7 +190,7 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
{
if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory)
{
if (!File::Exists((basePath / name).string()))
if (!DiskFile::Exists((basePath / name).string()))
{
std::string errorHeader = StringHelper::Sprintf("binary file '%s' does not exist.",
(basePath / name).c_str());
@ -224,7 +224,12 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
// Check for repeated attributes.
if (offsetXml != nullptr)
{
rawDataIndex = strtol(StringHelper::Split(std::string(offsetXml), "0x")[1].c_str(), NULL, 16);
if (!StringHelper::IsValidOffset(std::string_view(offsetXml)))
{
HANDLE_ERROR(WarningType::InvalidXML,
StringHelper::Sprintf("Invalid offset %s entered", offsetXml), "");
}
rawDataIndex = strtol(offsetXml, NULL, 16);
if (offsetSet.find(offsetXml) != offsetSet.end())
{
@ -416,7 +421,7 @@ void ZFile::ExtractResources()
if (memStreamFile->GetLength() > 0)
{
File::WriteAllBytes(StringHelper::Sprintf("%s%s.bin",
DiskFile::WriteAllBytes(StringHelper::Sprintf("%s%s.bin",
Globals::Instance->outputPath.string().c_str(),
GetName().c_str()),
memStreamFile->ToVector());
@ -433,7 +438,7 @@ void ZFile::AddResource(ZResource* res)
resources.push_back(res);
}
ZResource* ZFile::FindResource(uint32_t rawDataIndex)
ZResource* ZFile::FindResource(offset_t rawDataIndex)
{
for (ZResource* res : resources)
{
@ -447,6 +452,7 @@ ZResource* ZFile::FindResource(uint32_t rawDataIndex)
std::vector<ZResource*> ZFile::GetResourcesOfType(ZResourceType resType)
{
std::vector<ZResource*> resList;
resList.reserve(resources.size());
for (ZResource* res : resources)
{
@ -722,7 +728,7 @@ bool ZFile::GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSi
return true;
}
Declaration* ZFile::GetDeclaration(uint32_t address) const
Declaration* ZFile::GetDeclaration(offset_t address) const
{
if (declarations.find(address) != declarations.end())
return declarations.at(address);
@ -730,7 +736,7 @@ Declaration* ZFile::GetDeclaration(uint32_t address) const
return nullptr;
}
Declaration* ZFile::GetDeclarationRanged(uint32_t address) const
Declaration* ZFile::GetDeclarationRanged(offset_t address) const
{
for (const auto decl : declarations)
{
@ -741,7 +747,7 @@ Declaration* ZFile::GetDeclarationRanged(uint32_t address) const
return nullptr;
}
bool ZFile::HasDeclaration(uint32_t address)
bool ZFile::HasDeclaration(offset_t address)
{
assert(GETSEGNUM(address) == 0);
return declarations.find(address) != declarations.end();
@ -796,7 +802,7 @@ void ZFile::GenerateSourceFiles()
OutputFormatter formatter;
formatter.Write(sourceOutput);
File::WriteAllText(outPath, formatter.GetOutput());
DiskFile::WriteAllText(outPath, formatter.GetOutput());
}
GenerateSourceHeaderFiles();
@ -805,9 +811,14 @@ void ZFile::GenerateSourceFiles()
void ZFile::GenerateSourceHeaderFiles()
{
OutputFormatter formatter;
std::string guard = outName.stem().string();
std::transform(guard.begin(), guard.end(), guard.begin(), ::toupper);
formatter.Write("#pragma once\n\n");
formatter.Write(
StringHelper::Sprintf("#ifndef %s_H\n#define %s_H 1\n\n", guard.c_str(), guard.c_str()));
formatter.Write("#include \"align_asset_macro.h\"\n");
std::set<std::string> nameSet;
for (ZResource* res : resources)
{
@ -827,6 +838,8 @@ void ZFile::GenerateSourceHeaderFiles()
formatter.Write(ProcessExterns());
formatter.Write("#endif\n");
fs::path headerFilename = GetSourceOutputFolderPath() / outName.stem().concat(".h");
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO)
@ -837,7 +850,7 @@ void ZFile::GenerateSourceHeaderFiles()
output.pop_back();
if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory)
File::WriteAllText(headerFilename, output);
DiskFile::WriteAllText(headerFilename, output);
else if (Globals::Instance->sourceOutputPath != "")
{
std::string xmlPath = xmlFilePath.string();
@ -862,7 +875,7 @@ void ZFile::GenerateSourceHeaderFiles()
outPath += "/";
}
File::WriteAllText(outPath, output);
DiskFile::WriteAllText(outPath, output);
}
}
@ -1108,7 +1121,7 @@ std::string ZFile::ProcessDeclarations()
extType = "vtx";
auto filepath = outputPath / item.second->varName;
File::WriteAllText(
DiskFile::WriteAllText(
StringHelper::Sprintf("%s.%s.inc", filepath.string().c_str(), extType.c_str()),
item.second->text);
}
@ -1244,6 +1257,10 @@ void ZFile::HandleUnaccountedData()
uint32_t lastSize = 0;
std::vector<offset_t> declsAddresses;
if (Globals::Instance->otrMode)
return;
declsAddresses.reserve(declarations.size());
if (Globals::Instance->otrMode)
return;

View File

@ -32,8 +32,8 @@ class ZFile
{
public:
std::map<offset_t, Declaration*> declarations;
std::string defines;
std::vector<ZResource*> resources;
std::string defines;
int workerID;
bool isCompilable = false;
@ -56,7 +56,7 @@ public:
void ExtractResources();
void BuildSourceFile();
void AddResource(ZResource* res);
ZResource* FindResource(uint32_t rawDataIndex);
ZResource* FindResource(offset_t rawDataIndex);
std::vector<ZResource*> GetResourcesOfType(ZResourceType resType);
Declaration* AddDeclaration(offset_t address, DeclarationAlignment alignment, size_t size,
@ -85,9 +85,9 @@ public:
const std::string& expectedType,
std::string& declName) const;
Declaration* GetDeclaration(uint32_t address) const;
Declaration* GetDeclarationRanged(uint32_t address) const;
bool HasDeclaration(uint32_t address);
Declaration* GetDeclaration(offset_t address) const;
Declaration* GetDeclarationRanged(offset_t address) const;
bool HasDeclaration(offset_t address);
std::string GetHeaderInclude() const;
std::string GetZRoomHeaderInclude() const;

View File

@ -4,12 +4,15 @@
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
#include "ZSkeleton.h"
REGISTER_ZFILENODE(Limb, ZLimb);
ZLimb::ZLimb(ZFile* nParent) : ZResource(nParent), segmentStruct(nParent)
{
RegisterOptionalAttribute("EnumName");
RegisterOptionalAttribute("LimbType");
RegisterOptionalAttribute("Type");
}
@ -30,6 +33,12 @@ void ZLimb::ParseXML(tinyxml2::XMLElement* reader)
{
ZResource::ParseXML(reader);
auto& enumNameXml = registeredAttributes.at("EnumName").value;
if (enumNameXml != "")
{
enumName = enumNameXml;
}
// Reading from a <Skeleton/>
std::string limbType = registeredAttributes.at("LimbType").value;
if (limbType == "") // Reading from a <Limb/>
@ -247,11 +256,24 @@ std::string ZLimb::GetBodySourceCode() const
}
else
{
std::string childStr;
std::string siblingStr;
if (limbsTable != nullptr)
{
childStr = limbsTable->GetLimbEnumName(childIndex);
siblingStr = limbsTable->GetLimbEnumName(siblingIndex);
}
else
{
childStr = StringHelper::Sprintf("0x%02X", childIndex);
siblingStr = StringHelper::Sprintf("0x%02X", siblingIndex);
}
if (type != ZLimbType::Curve)
{
entryStr += StringHelper::Sprintf("{ %i, %i, %i }, ", transX, transY, transZ);
}
entryStr += StringHelper::Sprintf("0x%02X, 0x%02X,\n", childIndex, siblingIndex);
entryStr += StringHelper::Sprintf("%s, %s,\n", childStr.c_str(), siblingStr.c_str());
switch (type)
{
@ -360,6 +382,11 @@ ZLimbType ZLimb::GetTypeByAttributeName(const std::string& attrName)
return ZLimbType::Invalid;
}
void ZLimb::SetLimbIndex(uint8_t nLimbIndex)
{
limbIndex = nLimbIndex;
}
void ZLimb::DeclareDList(segptr_t dListSegmentedPtr, const std::string& prefix,
const std::string& limbSuffix)
{

View File

@ -18,9 +18,14 @@ enum class ZLimbType
Legacy,
};
class ZLimbTable;
class ZLimb : public ZResource
{
public:
std::string enumName;
ZLimbTable* limbsTable = nullptr; // borrowed pointer, do not delete!
ZLimbType type = ZLimbType::Standard;
ZLimbSkinType skinSegmentType = ZLimbSkinType::SkinType_0; // Skin only
@ -39,6 +44,8 @@ public:
int16_t transX = 0, transY = 0, transZ = 0;
uint8_t childIndex = 0, siblingIndex = 0;
uint8_t limbIndex = 0;
ZLimb(ZFile* nParent);
void ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nType);
@ -59,6 +66,8 @@ public:
static const char* GetSourceTypeName(ZLimbType limbType);
static ZLimbType GetTypeByAttributeName(const std::string& attrName);
void SetLimbIndex(uint8_t nLimbIndex);
protected:
void DeclareDList(segptr_t dListSegmentedPtr, const std::string& prefix,
const std::string& limbSuffix);

View File

@ -35,6 +35,7 @@ void ZPath::ParseRawData()
uint32_t currentPtr = rawDataIndex;
pathways.reserve(numPaths);
for (size_t pathIndex = 0; pathIndex < numPaths; pathIndex++)
{
PathwayEntry path(parent);
@ -125,6 +126,7 @@ void PathwayEntry::ParseRawData()
uint32_t currentPtr = GETSEGOFFSET(listSegmentAddress);
points.reserve(numPoints);
for (int32_t i = 0; i < numPoints; i++)
{
ZVector vec(parent);

57
ZAPDTR/ZAPD/ZPointer.cpp Normal file
View File

@ -0,0 +1,57 @@
#include "ZPointer.h"
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
#include "ZFile.h"
REGISTER_ZFILENODE(Pointer, ZPointer);
ZPointer::ZPointer(ZFile* nParent) : ZResource(nParent)
{
RegisterRequiredAttribute("Type");
}
void ZPointer::ParseXML(tinyxml2::XMLElement* reader)
{
ZResource::ParseXML(reader);
type = registeredAttributes.at("Type").value;
}
void ZPointer::ParseRawData()
{
auto& rawData = parent->GetRawData();
ptr = BitConverter::ToUInt32BE(rawData, rawDataIndex);
}
std::string ZPointer::GetBodySourceCode() const
{
std::string ptrName;
Globals::Instance->GetSegmentedPtrName(ptr, parent, "", ptrName);
return ptrName;
}
bool ZPointer::DoesSupportArray() const
{
return true;
}
std::string ZPointer::GetSourceTypeName() const
{
return type + "*";
}
ZResourceType ZPointer::GetResourceType() const
{
return ZResourceType::Pointer;
}
size_t ZPointer::GetRawDataSize() const
{
return 0x04;
}

22
ZAPDTR/ZAPD/ZPointer.h Normal file
View File

@ -0,0 +1,22 @@
#pragma once
#include "ZResource.h"
class ZPointer : public ZResource
{
public:
segptr_t ptr = SEGMENTED_NULL;
std::string type;
ZPointer(ZFile* nParent);
void ParseXML(tinyxml2::XMLElement* reader) override;
void ParseRawData() override;
std::string GetBodySourceCode() const override;
bool DoesSupportArray() const override;
std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;
size_t GetRawDataSize() const override;
};

View File

@ -261,6 +261,11 @@ offset_t ZResource::GetRawDataIndex() const
return rawDataIndex;
}
void ZResource::SetRawDataIndex(offset_t nRawDataIndex)
{
rawDataIndex = nRawDataIndex;
}
std::string ZResource::GetBodySourceCode() const
{
return "ERROR";

View File

@ -52,7 +52,11 @@ enum class ZResourceType
Vector,
Vertex,
Text,
Audio
Audio,
ActorList,
CollisionPoly,
Pointer,
SurfaceType,
};
class ResourceAttribute
@ -153,6 +157,8 @@ public:
[[nodiscard]] const std::string& GetOutName() const;
void SetOutName(const std::string& nName);
[[nodiscard]] offset_t GetRawDataIndex() const;
void SetRawDataIndex(offset_t nRawDataIndex);
/**
* The size of the current struct being extracted, not counting data referenced by it
*/

View File

@ -1,6 +1,6 @@
#include "ZRom.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Directory.h"
#include "yaz0/yaz0.h"
@ -95,7 +95,7 @@ bool ZRom::IsMQ() {
ZRom::ZRom(std::string romPath)
{
RomVersion version;
romData = File::ReadAllBytes(romPath);
romData = DiskFile::ReadAllBytes(romPath);
version.crc = BitConverter::ToInt32BE(romData, 0x10);
@ -189,7 +189,7 @@ ZRom::ZRom(std::string romPath)
}
auto path = StringHelper::Sprintf("%s/%s", Globals::Instance->fileListPath.string().c_str(), version.listPath.c_str());
auto txt = File::ReadAllText(path);
auto txt = DiskFile::ReadAllText(path);
std::vector<std::string> lines = StringHelper::Split(txt, "\n");
std::vector<uint8_t> decompressedData(1);
@ -222,7 +222,7 @@ ZRom::ZRom(std::string romPath)
else
files[lines[i]] = outData;
//File::WriteAllBytes(StringHelper::Sprintf("baserom/%s", lines[i].c_str()), files[lines[i]]);
//DiskFile::WriteAllBytes(StringHelper::Sprintf("baserom/%s", lines[i].c_str()), files[lines[i]]);
}
}

View File

@ -14,8 +14,9 @@ void SetActorCutsceneList::ParseRawData()
{
ZRoomCommand::ParseRawData();
int numCutscenes = cmdArg1;
int32_t currentPtr = segmentOffset;
offset_t currentPtr = segmentOffset;
cutscenes.reserve(numCutscenes);
for (int32_t i = 0; i < numCutscenes; i++)
{
ActorCutsceneEntry entry(parent->GetRawData(), currentPtr);

View File

@ -1,10 +1,10 @@
#include "SetActorList.h"
#include <cassert>
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZNames.h"
#include "ZRoom/ZRoom.h"
SetActorList::SetActorList(ZFile* nParent) : ZRoomCommand(nParent)
@ -15,67 +15,28 @@ void SetActorList::ParseRawData()
{
ZRoomCommand::ParseRawData();
numActors = cmdArg1;
actorList = new ZActorList(parent);
actorList->ExtractFromBinary(segmentOffset, numActors);
}
void SetActorList::DeclareReferences(const std::string& prefix)
{
if (numActors != 0 && cmdArg2 != 0)
if (parent->HasDeclaration(segmentOffset))
{
std::string varName =
StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset);
parent->AddDeclarationPlaceholder(segmentOffset, varName);
}
}
void SetActorList::ParseRawDataLate()
{
ZRoomCommand::ParseRawDataLate();
size_t actorsAmount = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 0x10;
uint32_t currentPtr = segmentOffset;
for (size_t i = 0; i < actorsAmount; i++)
{
ActorSpawnEntry entry(parent->GetRawData(), currentPtr);
currentPtr += entry.GetRawDataSize();
actors.push_back(entry);
}
}
void SetActorList::DeclareReferencesLate(const std::string& prefix)
{
if (actors.empty())
delete actorList;
actorList = static_cast<ZActorList*>(parent->FindResource(segmentOffset));
assert(actorList != nullptr);
assert(actorList->GetResourceType() == ZResourceType::ActorList);
return;
std::string declaration;
size_t largestlength = 0;
for (const auto& entry : actors)
{
size_t actorNameLength = ZNames::GetActorName(entry.GetActorId()).size();
if (actorNameLength > largestlength)
largestlength = actorNameLength;
}
size_t index = 0;
for (auto& entry : actors)
if (actorList->GetName() == "")
{
entry.SetLargestActorName(largestlength);
declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str());
if (index < actors.size() - 1)
declaration += "\n";
index++;
actorList->SetName(actorList->GetDefaultName(prefix));
}
const auto& entry = actors.front();
std::string varName = StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset);
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4,
actors.size() * entry.GetRawDataSize(), entry.GetSourceTypeName(),
varName, GetActorListArraySize(), declaration);
actorList->DeclareVar(prefix, "");
parent->AddResource(actorList);
}
std::string SetActorList::GetBodySourceCode() const
@ -83,37 +44,10 @@ std::string SetActorList::GetBodySourceCode() const
std::string listName;
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName,
parent->workerID);
if (numActors != actors.size())
{
printf("%s: numActors(%i) ~ actors(%li)\n", parent->GetName().c_str(), numActors,
actors.size());
}
return StringHelper::Sprintf("SCENE_CMD_ACTOR_LIST(%i, %s)", numActors, listName.c_str());
}
size_t SetActorList::GetActorListArraySize() const
{
size_t actorCount = 0;
// Doing an else-if here so we only do the loop when the game is SW97.
// Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count
// for it.
if (Globals::Instance->game == ZGame::OOT_SW97)
{
actorCount = 0;
for (const auto& entry : actors)
if (entry.GetActorId() != 0x22)
actorCount++;
}
else
{
actorCount = actors.size();
}
return actorCount;
}
std::string SetActorList::GetCommandCName() const
{
return "SCmdActorList";
@ -123,58 +57,3 @@ RoomCommand SetActorList::GetRoomCommand() const
{
return RoomCommand::SetActorList;
}
ActorSpawnEntry::ActorSpawnEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
{
actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8);
rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10);
rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12);
initVar = BitConverter::ToInt16BE(rawData, rawDataIndex + 14);
}
std::string ActorSpawnEntry::GetBodySourceCode() const
{
std::string body;
std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1);
body =
StringHelper::Sprintf(actorNameFmt.c_str(), (ZNames::GetActorName(actorNum) + ",").c_str());
body += StringHelper::Sprintf("{ %6i, %6i, %6i }, ", posX, posY, posZ);
if (Globals::Instance->game == ZGame::MM_RETAIL)
body += StringHelper::Sprintf("{ SPAWN_ROT_FLAGS(%#5hX, 0x%04X)"
", SPAWN_ROT_FLAGS(%#5hX, 0x%04X)"
", SPAWN_ROT_FLAGS(%#5hX, 0x%04X) }, ",
(rotX >> 7) & 0b111111111, rotX & 0b1111111,
(rotY >> 7) & 0b111111111, rotY & 0b1111111,
(rotZ >> 7) & 0b111111111, rotZ & 0b1111111);
else
body += StringHelper::Sprintf("{ %#6hX, %#6hX, %#6hX }, ", rotX, rotY, rotZ);
body += StringHelper::Sprintf("0x%04X", initVar);
return body;
}
std::string ActorSpawnEntry::GetSourceTypeName() const
{
return "ActorEntry";
}
int32_t ActorSpawnEntry::GetRawDataSize() const
{
return 16;
}
uint16_t ActorSpawnEntry::GetActorId() const
{
return actorNum;
}
void ActorSpawnEntry::SetLargestActorName(size_t nameSize)
{
largestActorName = nameSize;
}

View File

@ -1,45 +1,19 @@
#pragma once
#include "ZActorList.h"
#include "ZRoom/ZRoomCommand.h"
class ActorSpawnEntry
{
public:
uint16_t actorNum;
int16_t posX;
int16_t posY;
int16_t posZ;
uint16_t rotX;
uint16_t rotY;
uint16_t rotZ;
uint16_t initVar;
size_t largestActorName = 16;
ActorSpawnEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetBodySourceCode() const;
std::string GetSourceTypeName() const;
int32_t GetRawDataSize() const;
uint16_t GetActorId() const;
void SetLargestActorName(size_t nameSize);
};
class SetActorList : public ZRoomCommand
{
public:
uint8_t numActors;
std::vector<ActorSpawnEntry> actors;
uint32_t numActors;
ZActorList* actorList = nullptr;
SetActorList(ZFile* nParent);
void ParseRawData() override;
void DeclareReferences(const std::string& prefix) override;
void ParseRawDataLate() override;
void DeclareReferencesLate(const std::string& prefix) override;
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;

View File

@ -21,9 +21,10 @@ void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string&
void SetAlternateHeaders::ParseRawDataLate()
{
int numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
size_t numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
for (int32_t i = 0; i < numHeaders; i++)
headers.reserve(numHeaders);
for (uint32_t i = 0; i < numHeaders; i++)
{
int32_t address = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + (i * 4));
headers.push_back(address);

View File

@ -18,6 +18,7 @@ void SetCsCamera::ParseRawData()
uint32_t currentPtr = segmentOffset;
int32_t numPoints = 0;
cameras.reserve(numCameras);
for (int32_t i = 0; i < numCameras; i++)
{
CsCameraEntry entry(parent->GetRawData(), currentPtr);
@ -31,6 +32,7 @@ void SetCsCamera::ParseRawData()
{
uint32_t currentPtr = cameras.at(0).GetSegmentOffset();
points.reserve(numPoints);
for (int32_t i = 0; i < numPoints; i++)
{
ZVector vec(parent);

View File

@ -10,19 +10,25 @@ SetCutscenes::SetCutscenes(ZFile* nParent) : ZRoomCommand(nParent)
{
}
SetCutscenes::~SetCutscenes()
{
for (ZCutsceneBase* cutscene : cutscenes)
delete cutscene;
}
void SetCutscenes::ParseRawData()
{
ZRoomCommand::ParseRawData();
std::string output;
numCutscenes = cmdArg1;
if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97)
if (Globals::Instance->game == ZGame::MM_RETAIL)
{
int32_t currentPtr = segmentOffset;
cutsceneEntries.reserve(numCutscenes);
for (uint8_t i = 0; i < numCutscenes; i++)
{
CutsceneEntry entry(parent->GetRawData(), currentPtr);
cutsceneEntries.push_back(entry);
currentPtr += 8;
}
}
else if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97)
{
ZCutscene* cutscene = new ZCutscene(parent);
cutscene->ExtractFromFile(segmentOffset);
@ -35,28 +41,48 @@ void SetCutscenes::ParseRawData()
cutscenes.push_back(cutscene);
}
else
}
void SetCutscenes::DeclareReferences(const std::string& prefix)
{
std::string varPrefix = name;
if (varPrefix == "")
varPrefix = prefix;
if (Globals::Instance->game == ZGame::MM_RETAIL)
{
int32_t currentPtr = segmentOffset;
std::string declaration;
size_t i = 0;
for (uint8_t i = 0; i < numCutscenes; i++)
for (const auto& entry : cutsceneEntries)
{
CutsceneEntry entry(parent->GetRawData(), currentPtr);
cutsceneEntries.push_back(entry);
currentPtr += 8;
if (entry.segmentPtr != SEGMENTED_NULL &&
GETSEGNUM(entry.segmentPtr) == parent->segment)
{
offset_t csOffset = Seg2Filespace(entry.segmentPtr, parent->baseAddress);
if (!parent->HasDeclaration(csOffset))
{
auto* cutscene = new ZCutscene(parent);
cutscene->ExtractFromFile(csOffset);
cutscene->SetName(cutscene->GetDefaultName(varPrefix));
cutscene->DeclareVar(varPrefix, "");
cutscene->DeclareReferences(varPrefix);
parent->AddResource(cutscene);
}
}
// TODO: don't hardcode %sCutsceneData_%06X, look up for the declared name instead
declaration += StringHelper::Sprintf(
" { %sCutsceneData_%06X, 0x%04X, 0x%02X, 0x%02X },", zRoom->GetName().c_str(),
entry.segmentOffset, entry.exit, entry.entrance, entry.flag);
std::string csName;
Globals::Instance->GetSegmentedPtrName(entry.segmentPtr, parent, "CutsceneData",
csName, parent->workerID);
if (i < numCutscenes - 1)
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";
ZCutsceneMM* cutscene = new ZCutsceneMM(parent);
cutscene->ExtractFromFile(entry.segmentOffset);
cutscenes.push_back(cutscene);
i++;
}
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4,
@ -65,19 +91,19 @@ void SetCutscenes::ParseRawData()
zRoom->GetName().c_str(), segmentOffset),
cutsceneEntries.size(), declaration);
}
for (ZCutsceneBase* cutscene : cutscenes)
else
{
if (cutscene->GetRawDataIndex() != 0)
if (cmdArg2 != SEGMENTED_NULL && GETSEGNUM(cmdArg2) == parent->segment)
{
Declaration* decl = parent->GetDeclaration(cutscene->GetRawDataIndex());
if (decl == nullptr)
offset_t csOffset = Seg2Filespace(cmdArg2, parent->baseAddress);
if (!parent->HasDeclaration(csOffset))
{
cutscene->GetSourceOutputCode(zRoom->GetName());
}
else if (decl->text == "")
{
decl->text = cutscene->GetBodySourceCode();
auto* cutscene = new ZCutscene(parent);
cutscene->ExtractFromFile(csOffset);
cutscene->SetName(cutscene->GetDefaultName(varPrefix));
cutscene->DeclareVar(varPrefix, "");
cutscene->DeclareReferences(varPrefix);
parent->AddResource(cutscene);
}
}
}
@ -90,8 +116,15 @@ std::string SetCutscenes::GetBodySourceCode() const
parent->workerID);
if (Globals::Instance->game == ZGame::MM_RETAIL)
{
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneEntry", listName,
parent->workerID);
return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes,
listName.c_str());
}
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName,
parent->workerID);
return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_DATA(%s)", listName.c_str());
}
@ -106,7 +139,7 @@ RoomCommand SetCutscenes::GetRoomCommand() const
}
CutsceneEntry::CutsceneEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
: segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 0))),
: segmentPtr(BitConverter::ToInt32BE(rawData, rawDataIndex + 0)),
exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]),
flag(rawData[rawDataIndex + 7])
{

View File

@ -1,7 +1,6 @@
#pragma once
#include "ZCutscene.h"
#include "ZCutsceneMM.h"
#include "ZRoom/ZRoomCommand.h"
class CutsceneEntry
@ -9,7 +8,7 @@ class CutsceneEntry
public:
CutsceneEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
uint32_t segmentOffset;
segptr_t segmentPtr;
uint16_t exit;
uint8_t entrance;
uint8_t flag;
@ -18,14 +17,14 @@ public:
class SetCutscenes : public ZRoomCommand
{
public:
std::vector<ZCutsceneBase*> cutscenes;
std::vector<ZCutscene*> cutscenes;
std::vector<CutsceneEntry> cutsceneEntries; // (MM Only)
uint8_t numCutscenes; // (MM Only)
SetCutscenes(ZFile* nParent);
~SetCutscenes();
void ParseRawData() override;
void DeclareReferences(const std::string& prefix) override;
std::string GetBodySourceCode() const override;

View File

@ -24,10 +24,11 @@ void SetEntranceList::DeclareReferences([[maybe_unused]] const std::string& pref
void SetEntranceList::ParseRawDataLate()
{
// Parse Entrances and Generate Declaration
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t currentPtr = segmentOffset;
for (int32_t i = 0; i < numEntrances; i++)
entrances.reserve(numEntrances);
for (uint32_t i = 0; i < numEntrances; i++)
{
EntranceEntry entry(parent->GetRawData(), currentPtr);
entrances.push_back(entry);

View File

@ -4,6 +4,7 @@
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZNames.h"
#include "ZRoom/ZRoom.h"
SetExitList::SetExitList(ZFile* nParent) : ZRoomCommand(nParent)
@ -23,10 +24,11 @@ void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix)
void SetExitList::ParseRawDataLate()
{
// Parse Entrances and Generate Declaration
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t currentPtr = segmentOffset;
for (int32_t i = 0; i < numEntrances; i++)
exits.reserve(numEntrances);
for (uint32_t i = 0; i < numEntrances; i++)
{
uint16_t exit = BitConverter::ToUInt16BE(parent->GetRawData(), currentPtr);
exits.push_back(exit);
@ -43,7 +45,8 @@ void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& pref
for (size_t i = 0; i < exits.size(); i++)
{
declaration += StringHelper::Sprintf(" 0x%04X,", exits.at(i));
declaration +=
StringHelper::Sprintf(" %s,", ZNames::GetEntranceName(exits[i]).c_str());
if (i + 1 < exits.size())
declaration += "\n";
}

View File

@ -15,6 +15,8 @@ void SetLightList::ParseRawData()
numLights = cmdArg1;
int32_t currentPtr = segmentOffset;
lights.reserve(this->numLights);
for (int i = 0; i < this->numLights; i++)
{
LightInfo light(parent->GetRawData(), currentPtr);

View File

@ -15,6 +15,7 @@ void SetLightingSettings::ParseRawData()
ZRoomCommand::ParseRawData();
uint8_t numLights = cmdArg1;
settings.reserve(numLights);
for (int i = 0; i < numLights; i++)
settings.push_back(LightingSettings(parent->GetRawData(), segmentOffset + (i * 22)));
}

View File

@ -442,6 +442,8 @@ void PolygonType1::DeclareReferences(const std::string& prefix)
{
listAddress = Seg2Filespace(list, parent->baseAddress);
uint32_t auxPtr = listAddress;
multiList.reserve(count);
for (size_t i = 0; i < count; ++i)
{
BgImage bg(false, prefix, auxPtr, parent);
@ -545,6 +547,8 @@ void PolygonType2::ParseRawData()
end = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08);
uint32_t currentPtr = GETSEGOFFSET(start);
polyDLists.reserve(num);
for (size_t i = 0; i < num; i++)
{
PolygonDlist entry(parent);

View File

@ -15,8 +15,9 @@ void SetMinimapChests::ParseRawData()
ZRoomCommand::ParseRawData();
int numChests = cmdArg1;
int32_t currentPtr = segmentOffset;
offset_t currentPtr = segmentOffset;
chests.reserve(numChests);
for (int32_t i = 0; i < numChests; i++)
{
MinimapChest chest(parent->GetRawData(), currentPtr);

View File

@ -17,8 +17,9 @@ void SetMinimapList::ParseRawData()
listSegmentOffset = GETSEGOFFSET(listSegmentAddr);
unk4 = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + 4);
int32_t currentPtr = listSegmentOffset;
uint32_t currentPtr = listSegmentOffset;
minimaps.reserve(zRoom->roomCount);
for (int32_t i = 0; i < zRoom->roomCount; i++)
{
MinimapEntry entry(parent->GetRawData(), currentPtr);

View File

@ -17,6 +17,7 @@ void SetObjectList::ParseRawData()
uint8_t objectCnt = parent->GetRawData().at(rawDataIndex + 1);
uint32_t currentPtr = segmentOffset;
objects.reserve(objectCnt);
for (uint8_t i = 0; i < objectCnt; i++)
{
uint16_t objectIndex = BitConverter::ToInt16BE(parent->GetRawData(), currentPtr);

View File

@ -69,6 +69,7 @@ void RomFile::ParseRawData()
uint32_t currentPtr = rawDataIndex;
rooms.reserve(numRooms);
for (int32_t i = 0; i < numRooms; i++)
{
RoomEntry entry(parent->GetRawData(), currentPtr);
@ -104,8 +105,8 @@ std::string RomFile::GetBodySourceCode() const
if (!isFirst)
declaration += "\n";
declaration +=
StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },",
declaration += StringHelper::Sprintf(
"\t{ (uintptr_t)_%sSegmentRomStart, (uintptr_t)_%sSegmentRomEnd },",
roomName.c_str(), roomName.c_str());
isFirst = false;
}

View File

@ -16,9 +16,10 @@ void SetStartPositionList::ParseRawData()
ZRoomCommand::ParseRawData();
uint8_t numActors = cmdArg1;
uint32_t currentPtr = segmentOffset;
offset_t currentPtr = segmentOffset;
for (int32_t i = 0; i < numActors; i++)
actors.reserve(numActors);
for (uint32_t i = 0; i < numActors; i++)
{
actors.push_back(ActorSpawnEntry(parent->GetRawData(), currentPtr));
currentPtr += 16;

View File

@ -17,6 +17,7 @@ void SetTransitionActorList::ParseRawData()
int numActors = cmdArg1;
uint32_t currentPtr = segmentOffset;
transitionActors.reserve(numActors);
for (int32_t i = 0; i < numActors; i++)
{
TransitionActorEntry entry(parent->GetRawData(), currentPtr);

View File

@ -12,17 +12,17 @@ public:
{
if (id >= Globals::Instance->cfg.objectList.size())
return StringHelper::Sprintf("0x%04X", id);
return Globals::Instance->cfg.objectList.at(id);
return Globals::Instance->cfg.objectList[id];
}
static std::string GetActorName(int32_t id)
static std::string GetActorName(uint16_t id)
{
switch (Globals::Instance->game)
{
case ZGame::OOT_RETAIL:
case ZGame::OOT_SW97:
if (id < ZNames::GetNumActors())
return Globals::Instance->cfg.actorList.at(id);
return Globals::Instance->cfg.actorList[id];
else
return StringHelper::Sprintf("0x%04X", id);
case ZGame::MM_RETAIL:
@ -31,7 +31,7 @@ public:
id &= 0xFFF;
std::string name;
if (id < ZNames::GetNumActors())
name = Globals::Instance->cfg.actorList.at(id);
name = Globals::Instance->cfg.actorList[id];
else
name = StringHelper::Sprintf("0x%04X", id);
@ -45,5 +45,20 @@ public:
return "";
}
static int32_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); }
static std::string GetEntranceName(uint16_t id)
{
if (ZNames::GetNumEntrances() == 0 || ZNames::GetNumSpecialEntrances() == 0)
return StringHelper::Sprintf("0x%04X", id);
if (id < ZNames::GetNumEntrances())
return Globals::Instance->cfg.entranceList[id];
else if ((id >= 0x7FF9 && id <= 0x7FFF) && !((id - 0x7FF9U) > GetNumSpecialEntrances())) // Special entrances
return Globals::Instance->cfg.specialEntranceList[id - 0x7FF9];
else
return StringHelper::Sprintf("0x%04X", id);
}
static size_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); }
static size_t GetNumEntrances() { return Globals::Instance->cfg.entranceList.size(); }
static size_t GetNumSpecialEntrances() { return Globals::Instance->cfg.specialEntranceList.size(); }
};

View File

@ -39,7 +39,7 @@
#include "Commands/Unused1D.h"
#include "Commands/ZRoomCommandUnk.h"
#include "Globals.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "WarningHandler.h"

View File

@ -2,7 +2,7 @@
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
#include "ZFile.h"

View File

@ -10,10 +10,15 @@
REGISTER_ZFILENODE(Skeleton, ZSkeleton);
REGISTER_ZFILENODE(LimbTable, ZLimbTable);
ZSkeleton::ZSkeleton(ZFile* nParent) : ZResource(nParent), limbsTable(nParent)
ZSkeleton::ZSkeleton(ZFile* nParent) : ZResource(nParent)
{
RegisterRequiredAttribute("Type");
RegisterRequiredAttribute("LimbType");
genOTRDef = true;
RegisterOptionalAttribute("EnumName");
RegisterOptionalAttribute("LimbNone");
RegisterOptionalAttribute("LimbMax");
genOTRDef = true;
}
@ -44,6 +49,41 @@ void ZSkeleton::ParseXML(tinyxml2::XMLElement* reader)
limbTypeXml.c_str()),
"Defaulting to 'Standard'.");
}
enumName = registeredAttributes.at("EnumName").value;
limbNoneName = registeredAttributes.at("LimbNone").value;
limbMaxName = registeredAttributes.at("LimbMax").value;
if (enumName != "")
{
if (limbNoneName == "" || limbMaxName == "")
{
HANDLE_ERROR_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex,
"'EnumName' attribute was used but either 'LimbNone' or "
"'LimbMax' attribute is missing",
"");
}
}
if (limbNoneName != "")
{
if (limbMaxName == "")
{
HANDLE_ERROR_RESOURCE(
WarningType::MissingAttribute, parent, this, rawDataIndex,
"'LimbNone' attribute was used but 'LimbMax' attribute is missing", "");
}
}
if (limbMaxName != "")
{
if (limbNoneName == "")
{
HANDLE_ERROR_RESOURCE(
WarningType::MissingAttribute, parent, this, rawDataIndex,
"'LimbMax' attribute was used but 'LimbNone' attribute is missing", "");
}
}
}
void ZSkeleton::ParseRawData()
@ -58,12 +98,6 @@ void ZSkeleton::ParseRawData()
{
dListCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8);
}
if (limbsArrayAddress != 0 && GETSEGNUM(limbsArrayAddress) == parent->segment)
{
uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress);
limbsTable.ExtractFromBinary(ptr, limbType, limbCount);
}
}
void ZSkeleton::DeclareReferences(const std::string& prefix)
@ -74,14 +108,33 @@ void ZSkeleton::DeclareReferences(const std::string& prefix)
ZResource::DeclareReferences(defaultPrefix);
if (limbsArrayAddress != 0 && GETSEGNUM(limbsArrayAddress) == parent->segment)
if (limbsArrayAddress != SEGMENTED_NULL && GETSEGNUM(limbsArrayAddress) == parent->segment)
{
uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress);
offset_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress);
if (!parent->HasDeclaration(ptr))
{
limbsTable.SetName(StringHelper::Sprintf("%sLimbs", defaultPrefix.c_str()));
limbsTable.DeclareReferences(prefix);
limbsTable.GetSourceOutputCode(prefix);
limbsTable = new ZLimbTable(parent);
limbsTable->ExtractFromBinary(ptr, limbType, limbCount);
limbsTable->SetName(StringHelper::Sprintf("%sLimbs", defaultPrefix.c_str()));
parent->AddResource(limbsTable);
}
else
{
limbsTable = static_cast<ZLimbTable*>(parent->FindResource(ptr));
}
if (limbsTable->enumName == "")
{
limbsTable->enumName = enumName;
}
if (limbsTable->limbNoneName == "")
{
limbsTable->limbNoneName = limbNoneName;
}
if (limbsTable->limbMaxName == "")
{
limbsTable->limbMaxName = limbMaxName;
}
}
}
@ -92,15 +145,27 @@ std::string ZSkeleton::GetBodySourceCode() const
Globals::Instance->GetSegmentedPtrName(limbsArrayAddress, parent, "", limbArrayName,
parent->workerID);
std::string countStr;
assert(limbsTable != nullptr);
// There are some Skeletons with the wrong limb count on them, so this check is necessary.
if (limbsTable->count == limbCount)
{
countStr = StringHelper::Sprintf("ARRAY_COUNT(%s)", limbArrayName.c_str());
}
else
{
countStr = StringHelper::Sprintf("%i", limbCount);
}
switch (type)
{
case ZSkeletonType::Normal:
case ZSkeletonType::Curve:
return StringHelper::Sprintf("\n\t%s, %i\n", limbArrayName.c_str(), limbCount);
return StringHelper::Sprintf("\n\t%s, %s\n", limbArrayName.c_str(), countStr.c_str());
case ZSkeletonType::Flex:
return StringHelper::Sprintf("\n\t{ %s, %i }, %i\n", limbArrayName.c_str(), limbCount,
dListCount);
return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(),
countStr.c_str(), dListCount);
}
// TODO: Throw exception?
@ -156,6 +221,9 @@ ZLimbTable::ZLimbTable(ZFile* nParent) : ZResource(nParent)
{
RegisterRequiredAttribute("LimbType");
RegisterRequiredAttribute("Count");
RegisterOptionalAttribute("EnumName");
RegisterOptionalAttribute("LimbNone");
RegisterOptionalAttribute("LimbMax");
}
void ZLimbTable::ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nLimbType, size_t nCount)
@ -182,6 +250,40 @@ void ZLimbTable::ParseXML(tinyxml2::XMLElement* reader)
}
count = StringHelper::StrToL(registeredAttributes.at("Count").value);
enumName = registeredAttributes.at("EnumName").value;
limbNoneName = registeredAttributes.at("LimbNone").value;
limbMaxName = registeredAttributes.at("LimbMax").value;
if (enumName != "")
{
if (limbNoneName == "" || limbMaxName == "")
{
HANDLE_ERROR_RESOURCE(
WarningType::MissingAttribute, parent, this, rawDataIndex,
"'EnumName' attribute was used but 'LimbNone'/'LimbMax' attributes is missing", "");
}
}
if (limbNoneName != "")
{
if (limbMaxName == "")
{
HANDLE_ERROR_RESOURCE(
WarningType::MissingAttribute, parent, this, rawDataIndex,
"'LimbNone' attribute was used but 'LimbMax' attribute is missing", "");
}
}
if (limbMaxName != "")
{
if (limbNoneName == "")
{
HANDLE_ERROR_RESOURCE(
WarningType::MissingAttribute, parent, this, rawDataIndex,
"'LimbMax' attribute was used but 'LimbNone' attribute is missing", "");
}
}
}
void ZLimbTable::ParseRawData()
@ -190,6 +292,8 @@ void ZLimbTable::ParseRawData()
const auto& rawData = parent->GetRawData();
uint32_t ptr = rawDataIndex;
limbsAddresses.reserve(count);
for (size_t i = 0; i < count; i++)
{
limbsAddresses.push_back(BitConverter::ToUInt32BE(rawData, ptr));
@ -204,7 +308,7 @@ void ZLimbTable::DeclareReferences(const std::string& prefix)
varPrefix = prefix;
ZResource::DeclareReferences(varPrefix);
limbsReferences.reserve(count);
for (size_t i = 0; i < count; i++)
{
segptr_t limbAddress = limbsAddresses[i];
@ -212,15 +316,28 @@ void ZLimbTable::DeclareReferences(const std::string& prefix)
if (limbAddress != 0 && GETSEGNUM(limbAddress) == parent->segment)
{
uint32_t limbOffset = Seg2Filespace(limbAddress, parent->baseAddress);
ZLimb* limb;
if (!parent->HasDeclaration(limbOffset))
{
ZLimb* limb = new ZLimb(parent);
limb = new ZLimb(parent);
limb->ExtractFromBinary(limbOffset, limbType);
limb->SetName(limb->GetDefaultName(varPrefix));
limb->DeclareVar(varPrefix, "");
limb->DeclareReferences(varPrefix);
parent->AddResource(limb);
}
else
{
limb = static_cast<ZLimb*>(parent->FindResource(limbOffset));
assert(limb != nullptr);
assert(limb->GetResourceType() == ZResourceType::Limb);
}
limb->limbsTable = this;
limb->SetLimbIndex(i + 1);
limbsReferences.push_back(limb);
}
}
}
@ -250,6 +367,13 @@ std::string ZLimbTable::GetBodySourceCode() const
parent->workerID);
body += StringHelper::Sprintf("\t%s,", limbName.c_str());
auto& limb = limbsReferences.at(i);
std::string limbEnumName = limb->enumName;
if (limbEnumName != "")
{
body += StringHelper::Sprintf(" /* %s */", limbEnumName.c_str());
}
if (i + 1 < count)
body += "\n";
}
@ -257,6 +381,46 @@ std::string ZLimbTable::GetBodySourceCode() const
return body;
}
std::string ZLimbTable::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix)
{
if (limbNoneName == "" || limbMaxName == "" || enumName == "")
{
// Don't produce a enum of any of those attributes is missing
return "";
}
std::string limbEnum = StringHelper::Sprintf("typedef enum %s {\n", enumName.c_str());
// This assumes there isn't any skeleton with more than 0x100 limbs
limbEnum += StringHelper::Sprintf(" /* 0x00 */ %s,\n", limbNoneName.c_str());
size_t i = 0;
for (; i < count; i++)
{
auto& limb = limbsReferences.at(i);
std::string limbEnumName = limb->enumName;
if (limbEnumName == "")
{
HANDLE_ERROR_RESOURCE(
WarningType::MissingAttribute, parent, this, rawDataIndex,
"Skeleton's enum attributes were used but at least one limb is missing its "
"'LimbName' attribute",
StringHelper::Sprintf("When processing limb %02i, named '%s' at offset '0x%X'",
i + 1, limb->GetName().c_str(), limb->GetRawDataIndex()));
}
limbEnum += StringHelper::Sprintf(" /* 0x%02X */ %s,\n", i + 1, limbEnumName.c_str());
}
limbEnum += StringHelper::Sprintf(" /* 0x%02X */ %s\n", i + 1, limbMaxName.c_str());
limbEnum += StringHelper::Sprintf("} %s;\n", enumName.c_str());
return limbEnum;
}
std::string ZLimbTable::GetSourceTypeName() const
{
switch (limbType)
@ -287,3 +451,28 @@ size_t ZLimbTable::GetRawDataSize() const
{
return 4 * limbsAddresses.size();
}
std::string ZLimbTable::GetLimbEnumName(uint8_t limbIndex) const
{
if (limbIndex == 0xFF)
{
return "LIMB_DONE";
}
if (limbIndex < count)
{
std::string limbEnumName = limbsReferences.at(limbIndex)->enumName;
if (limbEnumName != "")
{
return StringHelper::Sprintf("%s - 1", limbEnumName.c_str());
}
}
else
{
HANDLE_WARNING_RESOURCE(WarningType::InvalidExtractedData, parent, this, rawDataIndex,
StringHelper::Sprintf("Limb index '%02i' out of range", limbIndex),
"");
}
return StringHelper::Sprintf("0x%02X", limbIndex);
}

Some files were not shown because too many files have changed in this diff Show More