diff options
| author | Yanis42 <35189056+Yanis42@users.noreply.github.com> | 2023-10-08 21:27:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-08 15:27:57 -0400 |
| commit | 338e35f89afc905399ad90c952d154ae7b20bf75 (patch) | |
| tree | 46bdbf3fc8f41b42454e3f68c38f281824b552f9 /ZAPD/OtherStructs/Cutscene_Common.cpp | |
| parent | c7dd81e67783a93e728e5662dfe0c8732d79ce59 (diff) | |
Update OoT and MM's cutscene names (#303)
* progress
* fixed non-matching issues
* moved the enums to their own file & improvements
* format
* split MM and OoT
* more cleanup
* initial MM update
* MM improvements
* format
* class/function name update
* reduce the amount of zeroes (match)
* enum rename
* format
* removed hardcoded enums for OoT
* review 1
* remove mm hardcoded enums
* format
* ActorCutscene -> CutsceneEntry
CutsceneEntry -> CutsceneScriptEntry
* format
* some changes in (actor) cutsceneentry
* config "CutsceneEnumData" -> "EnumData"
* add ``else if``s inside ``ConfigFunc_EnumData``
* more ``else if``s
* removed reference in ``~CutsceneCommand``
Diffstat (limited to 'ZAPD/OtherStructs/Cutscene_Common.cpp')
| -rw-r--r-- | ZAPD/OtherStructs/Cutscene_Common.cpp | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/ZAPD/OtherStructs/Cutscene_Common.cpp b/ZAPD/OtherStructs/Cutscene_Common.cpp new file mode 100644 index 0000000..a5ea609 --- /dev/null +++ b/ZAPD/OtherStructs/Cutscene_Common.cpp @@ -0,0 +1,128 @@ +#include "Cutscene_Common.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; + } +} + +/*** TIME ****/ + +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); +} + +std::string CutsceneSubCommandEntry_SetTime::GetBodySourceCode() const +{ + // Note: Both OoT and MM have the first argument unused + return StringHelper::Sprintf("CS_TIME(%i, %i, %i, %i, %i)", base, startFrame, endFrame, hour, + minute); +} + +size_t CutsceneSubCommandEntry_SetTime::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_Time::CutsceneCommand_Time(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_Time::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TIME_LIST(%i)", numEntries); +} |
