mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-24 09:08:52 -05:00
c80f9fbd57
* WIP Multiversion support * GC PAL Non-MQ support complete * Updated OtrGui to handle different game versions * Added version file * Added new extract mode to ZAPD and optimized OTR gen time * Fixed bug causing crash * Further optimized OTRExporter, saving around ~20 seconds. * ZAPD is now multi-threaded. * Fixed merge issue * Fixed memory leak and fog issue on pause screen. * Additional fog fixes. Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
114 lines
3.2 KiB
C++
114 lines
3.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)
|
|
{
|
|
}
|
|
|
|
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)
|
|
{
|
|
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);
|
|
}
|
|
else
|
|
{
|
|
int32_t currentPtr = segmentOffset;
|
|
std::string declaration;
|
|
|
|
for (uint8_t i = 0; i < numCutscenes; i++)
|
|
{
|
|
CutsceneEntry entry(parent->GetRawData(), currentPtr);
|
|
cutsceneEntries.push_back(entry);
|
|
currentPtr += 8;
|
|
|
|
// 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);
|
|
|
|
if (i < numCutscenes - 1)
|
|
declaration += "\n";
|
|
|
|
ZCutsceneMM* cutscene = new ZCutsceneMM(parent);
|
|
cutscene->ExtractFromFile(entry.segmentOffset);
|
|
cutscenes.push_back(cutscene);
|
|
}
|
|
|
|
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4,
|
|
cutsceneEntries.size() * 8, "CutsceneEntry",
|
|
StringHelper::Sprintf("%sCutsceneEntryList_%06X",
|
|
zRoom->GetName().c_str(), segmentOffset),
|
|
cutsceneEntries.size(), declaration);
|
|
}
|
|
|
|
for (ZCutsceneBase* cutscene : cutscenes)
|
|
{
|
|
if (cutscene->GetRawDataIndex() != 0)
|
|
{
|
|
Declaration* decl = parent->GetDeclaration(cutscene->GetRawDataIndex());
|
|
if (decl == nullptr)
|
|
{
|
|
cutscene->GetSourceOutputCode(zRoom->GetName());
|
|
}
|
|
else if (decl->text == "")
|
|
{
|
|
decl->text = cutscene->GetBodySourceCode();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
std::string SetCutscenes::GetBodySourceCode() const
|
|
{
|
|
std::string listName;
|
|
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName,
|
|
parent->workerID);
|
|
|
|
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
|
return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes,
|
|
listName.c_str());
|
|
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)
|
|
: segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 0))),
|
|
exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]),
|
|
flag(rawData[rawDataIndex + 7])
|
|
{
|
|
}
|