mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-25 10:52:19 -05:00
f31a841789
* git subrepo clone --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/ subrepo: subdir: "ZAPDTR" merged: "6aa54a551" upstream: origin: "C:/ZeldaStuff/ZAPDTR" branch: "rebase2" commit: "6aa54a551" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * git subrepo clone --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/ subrepo: subdir: "ZAPDTR" merged: "88b012240" upstream: origin: "C:/ZeldaStuff/ZAPDTR" branch: "rebase2" commit: "88b012240" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Update (its broken) * fix the enum * git subrepo push --remote=C:/ZeldaStuff/ZAPDTR/ ZAPDTR subrepo: subdir: "ZAPDTR" merged: "b7b6e1c82" upstream: origin: "C:/ZeldaStuff/ZAPDTR/" branch: "rebase2" commit: "b7b6e1c82" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * New names for LUS actions * git subrepo push --remote=C:/ZeldaStuff/ZAPDTR/ ZAPDTR subrepo: subdir: "ZAPDTR" merged: "c5cfebeee" upstream: origin: "C:/ZeldaStuff/ZAPDTR/" branch: "rebase2" commit: "c5cfebeee" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * git subrepo clone (merge) --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/ subrepo: subdir: "ZAPDTR" merged: "d5f4769b8" upstream: origin: "C:/ZeldaStuff/ZAPDTR" branch: "rebase2" commit: "d5f4769b8" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Fix missing commands in the exporter. * Cleanups. * git subrepo pull --force --remote=https://github.com/harbourmasters/ZAPDTR --branch=master ZAPDTR subrepo: subdir: "ZAPDTR" merged: "d4c35b90a" upstream: origin: "https://github.com/harbourmasters/ZAPDTR" branch: "master" commit: "d4c35b90a" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Add unordered_map include to fix MacOS * fix string_view * Update Main.cpp * fix string view * So close I can almost taste it * So close * Fix missed git marker. * Fix surface types and * Update ZFile.cpp * Delete Jenkinsfile --------- Co-authored-by: Christopher Leggett <chris@leggett.dev> Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
147 lines
4.2 KiB
C++
147 lines
4.2 KiB
C++
#include "SetCutscenes.h"
|
|
|
|
#include "Globals.h"
|
|
#include "Utils/BitConverter.h"
|
|
#include "Utils/StringHelper.h"
|
|
#include "ZFile.h"
|
|
#include "ZRoom/ZRoom.h"
|
|
|
|
SetCutscenes::SetCutscenes(ZFile* nParent) : ZRoomCommand(nParent)
|
|
{
|
|
}
|
|
|
|
void SetCutscenes::ParseRawData()
|
|
{
|
|
ZRoomCommand::ParseRawData();
|
|
|
|
numCutscenes = cmdArg1;
|
|
|
|
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);
|
|
|
|
auto decl = parent->GetDeclaration(segmentOffset);
|
|
if (decl == nullptr)
|
|
{
|
|
cutscene->DeclareVar(zRoom->GetName().c_str(), "");
|
|
}
|
|
|
|
cutscenes.push_back(cutscene);
|
|
}
|
|
}
|
|
|
|
void SetCutscenes::DeclareReferences(const std::string& prefix)
|
|
{
|
|
std::string varPrefix = name;
|
|
if (varPrefix == "")
|
|
varPrefix = prefix;
|
|
|
|
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
|
{
|
|
std::string declaration;
|
|
size_t i = 0;
|
|
|
|
for (const auto& entry : cutsceneEntries)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
|
|
std::string csName;
|
|
Globals::Instance->GetSegmentedPtrName(entry.segmentPtr, parent, "CutsceneData",
|
|
csName, parent->workerID);
|
|
|
|
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";
|
|
|
|
i++;
|
|
}
|
|
|
|
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4,
|
|
cutsceneEntries.size() * 8, "CutsceneEntry",
|
|
StringHelper::Sprintf("%sCutsceneEntryList_%06X",
|
|
zRoom->GetName().c_str(), segmentOffset),
|
|
cutsceneEntries.size(), declaration);
|
|
}
|
|
else
|
|
{
|
|
if (cmdArg2 != SEGMENTED_NULL && GETSEGNUM(cmdArg2) == parent->segment)
|
|
{
|
|
offset_t csOffset = Seg2Filespace(cmdArg2, 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
std::string SetCutscenes::GetBodySourceCode() const
|
|
{
|
|
std::string listName;
|
|
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName,
|
|
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());
|
|
}
|
|
|
|
std::string SetCutscenes::GetCommandCName() const
|
|
{
|
|
return "SCmdCutsceneData";
|
|
}
|
|
|
|
RoomCommand SetCutscenes::GetRoomCommand() const
|
|
{
|
|
return RoomCommand::SetCutscenes;
|
|
}
|
|
|
|
CutsceneEntry::CutsceneEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
|
: segmentPtr(BitConverter::ToInt32BE(rawData, rawDataIndex + 0)),
|
|
exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]),
|
|
flag(rawData[rawDataIndex + 7])
|
|
{
|
|
}
|