git subrepo clone https://github.com/HarbourMasters/ZAPDTR.git
subrepo: subdir: "ZAPDTR" merged: "a53a53ea4" upstream: origin: "https://github.com/HarbourMasters/ZAPDTR.git" branch: "master" commit: "a53a53ea4" git-subrepo: version: "0.4.1" origin: "???" commit: "???"
This commit is contained in:
20
ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.cpp
Normal file
20
ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "EndMarker.h"
|
||||
|
||||
EndMarker::EndMarker(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
std::string EndMarker::GetBodySourceCode() const
|
||||
{
|
||||
return "SCENE_CMD_END()";
|
||||
}
|
||||
|
||||
std::string EndMarker::GetCommandCName() const
|
||||
{
|
||||
return "SCmdEndMarker";
|
||||
}
|
||||
|
||||
RoomCommand EndMarker::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::EndMarker;
|
||||
}
|
||||
13
ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.h
Normal file
13
ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class EndMarker : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
EndMarker(ZFile* nParent);
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
};
|
||||
93
ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp
Normal file
93
ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
#include "SetActorCutsceneList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetActorCutsceneList::SetActorCutsceneList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetActorCutsceneList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
int numCutscenes = cmdArg1;
|
||||
int32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numCutscenes; i++)
|
||||
{
|
||||
ActorCutsceneEntry entry(parent->GetRawData(), currentPtr);
|
||||
cutscenes.push_back(entry);
|
||||
|
||||
currentPtr += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void SetActorCutsceneList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
if (cutscenes.size() > 0)
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
for (size_t i = 0; i < cutscenes.size(); i++)
|
||||
{
|
||||
const auto& entry = cutscenes.at(i);
|
||||
declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str());
|
||||
|
||||
if (i + 1 < cutscenes.size())
|
||||
{
|
||||
declaration += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
std::string typeName = cutscenes.at(0).GetSourceTypeName();
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segmentOffset, GetDeclarationAlignment(), cutscenes.size() * 16, typeName,
|
||||
StringHelper::Sprintf("%s%sList_%06X", prefix.c_str(), typeName.c_str(), segmentOffset),
|
||||
cutscenes.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetActorCutsceneList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorCutscene", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ACTOR_CUTSCENE_LIST(%i, %s)", cutscenes.size(),
|
||||
listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetActorCutsceneList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdCutsceneActorList";
|
||||
}
|
||||
|
||||
RoomCommand SetActorCutsceneList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetActorCutsceneList;
|
||||
}
|
||||
|
||||
ActorCutsceneEntry::ActorCutsceneEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
: priority(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)),
|
||||
length(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
|
||||
unk4(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)),
|
||||
unk6(BitConverter::ToInt16BE(rawData, rawDataIndex + 6)),
|
||||
additionalCutscene(BitConverter::ToInt16BE(rawData, rawDataIndex + 8)),
|
||||
sound(rawData[rawDataIndex + 0xA]), unkB(rawData[rawDataIndex + 0xB]),
|
||||
unkC(BitConverter::ToInt16BE(rawData, rawDataIndex + 0xC)), unkE(rawData[rawDataIndex + 0xE]),
|
||||
letterboxSize(rawData[rawDataIndex + 0xF])
|
||||
{
|
||||
}
|
||||
|
||||
std::string ActorCutsceneEntry::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("%i, %i, %i, %i, %i, %i, %i, %i, %i, %i", priority, length, unk4,
|
||||
unk6, additionalCutscene, sound, unkB, unkC, unkE, letterboxSize);
|
||||
}
|
||||
|
||||
std::string ActorCutsceneEntry::GetSourceTypeName() const
|
||||
{
|
||||
return "ActorCutscene";
|
||||
}
|
||||
42
ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.h
Normal file
42
ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class ActorCutsceneEntry
|
||||
{
|
||||
protected:
|
||||
int16_t priority;
|
||||
int16_t length;
|
||||
int16_t unk4;
|
||||
int16_t unk6;
|
||||
int16_t additionalCutscene;
|
||||
uint8_t sound;
|
||||
uint8_t unkB;
|
||||
int16_t unkC;
|
||||
uint8_t unkE;
|
||||
uint8_t letterboxSize;
|
||||
|
||||
public:
|
||||
ActorCutsceneEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
|
||||
std::string GetBodySourceCode() const;
|
||||
std::string GetSourceTypeName() const;
|
||||
};
|
||||
|
||||
class SetActorCutsceneList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<ActorCutsceneEntry> cutscenes;
|
||||
|
||||
SetActorCutsceneList(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
|
||||
private:
|
||||
};
|
||||
179
ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.cpp
Normal file
179
ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.cpp
Normal file
@@ -0,0 +1,179 @@
|
||||
#include "SetActorList.h"
|
||||
|
||||
#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)
|
||||
{
|
||||
}
|
||||
|
||||
void SetActorList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
numActors = cmdArg1;
|
||||
}
|
||||
|
||||
void SetActorList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
if (numActors != 0 && cmdArg2 != 0)
|
||||
{
|
||||
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())
|
||||
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)
|
||||
{
|
||||
entry.SetLargestActorName(largestlength);
|
||||
declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str());
|
||||
|
||||
if (index < actors.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
std::string SetActorList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName);
|
||||
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";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
50
ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.h
Normal file
50
ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#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;
|
||||
|
||||
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;
|
||||
std::string GetCommandCName() const override;
|
||||
|
||||
protected:
|
||||
size_t GetActorListArraySize() const;
|
||||
};
|
||||
81
ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
Normal file
81
ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
#include "SetAlternateHeaders.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
|
||||
SetAlternateHeaders::SetAlternateHeaders(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (cmdArg2 != 0)
|
||||
{
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationPlaceholder(segmentOffset, varName);
|
||||
}
|
||||
}
|
||||
|
||||
void SetAlternateHeaders::ParseRawDataLate()
|
||||
{
|
||||
int numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
|
||||
|
||||
for (int32_t i = 0; i < numHeaders; i++)
|
||||
{
|
||||
int32_t address = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + (i * 4));
|
||||
headers.push_back(address);
|
||||
|
||||
if (address != 0 && parent->GetDeclaration(GETSEGOFFSET(address)) == nullptr)
|
||||
{
|
||||
ZRoom* altheader = new ZRoom(parent);
|
||||
altheader->ExtractFromBinary(GETSEGOFFSET(address), zRoom->GetResourceType());
|
||||
altheader->DeclareReferences(parent->GetName());
|
||||
|
||||
parent->resources.push_back(altheader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetAlternateHeaders::DeclareReferencesLate(const std::string& prefix)
|
||||
{
|
||||
if (!headers.empty())
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
for (size_t i = 0; i < headers.size(); i++)
|
||||
{
|
||||
std::string altHeaderName;
|
||||
Globals::Instance->GetSegmentedPtrName(headers.at(i), parent, "", altHeaderName);
|
||||
|
||||
declaration += StringHelper::Sprintf("\t%s,", altHeaderName.c_str());
|
||||
|
||||
if (i + 1 < headers.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationArray(segmentOffset, GetDeclarationAlignment(), headers.size() * 4,
|
||||
"SceneCmd*", varName, headers.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetAlternateHeaders::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "SceneCmd*", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ALTERNATE_HEADER_LIST(%s)", listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetAlternateHeaders::GetCommandCName() const
|
||||
{
|
||||
return "SCmdAltHeaders";
|
||||
}
|
||||
|
||||
RoomCommand SetAlternateHeaders::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetAlternateHeaders;
|
||||
}
|
||||
23
ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.h
Normal file
23
ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoom.h"
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetAlternateHeaders : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<uint32_t> headers;
|
||||
|
||||
SetAlternateHeaders(ZFile* nParent);
|
||||
|
||||
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;
|
||||
std::string GetCommandCName() const override;
|
||||
|
||||
private:
|
||||
};
|
||||
48
ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp
Normal file
48
ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* File: SetAnimatedMaterialList.cpp
|
||||
* Description: Defines a class SetAnimatedMaterialList to enable ZRoom to declare
|
||||
* ZTextureAnimations, using that ZResource to do the work.
|
||||
*/
|
||||
#include "SetAnimatedMaterialList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
#include "ZTextureAnimation.h"
|
||||
|
||||
SetAnimatedMaterialList::SetAnimatedMaterialList(ZFile* nParent)
|
||||
: ZRoomCommand(nParent), textureAnimation(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetAnimatedMaterialList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
textureAnimation.ExtractFromFile(segmentOffset);
|
||||
}
|
||||
|
||||
void SetAnimatedMaterialList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
textureAnimation.SetName(textureAnimation.GetDefaultName(prefix.c_str()));
|
||||
textureAnimation.DeclareReferences(prefix);
|
||||
textureAnimation.GetSourceOutputCode(prefix);
|
||||
}
|
||||
|
||||
std::string SetAnimatedMaterialList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "AnimatedMaterial", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ANIMATED_MATERIAL_LIST(%s)", listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetAnimatedMaterialList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdTextureAnimations";
|
||||
}
|
||||
|
||||
RoomCommand SetAnimatedMaterialList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetAnimatedMaterialList;
|
||||
}
|
||||
21
ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h
Normal file
21
ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
#include "ZTextureAnimation.h"
|
||||
|
||||
class SetAnimatedMaterialList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetAnimatedMaterialList(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
|
||||
private:
|
||||
ZTextureAnimation textureAnimation;
|
||||
};
|
||||
31
ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.cpp
Normal file
31
ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "SetCameraSettings.h"
|
||||
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetCameraSettings::SetCameraSettings(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetCameraSettings::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
cameraMovement = cmdArg1;
|
||||
mapHighlight = BitConverter::ToUInt32BE(parent->GetRawData(), rawDataIndex + 4);
|
||||
}
|
||||
|
||||
std::string SetCameraSettings::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("SCENE_CMD_MISC_SETTINGS(0x%02X, 0x%08X)", cameraMovement,
|
||||
mapHighlight);
|
||||
}
|
||||
|
||||
std::string SetCameraSettings::GetCommandCName() const
|
||||
{
|
||||
return "SCmdMiscSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetCameraSettings::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetCameraSettings;
|
||||
}
|
||||
21
ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.h
Normal file
21
ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetCameraSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t cameraMovement;
|
||||
uint32_t mapHighlight;
|
||||
|
||||
SetCameraSettings(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
|
||||
private:
|
||||
};
|
||||
44
ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp
Normal file
44
ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "SetCollisionHeader.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetCollisionHeader::SetCollisionHeader(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetCollisionHeader::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
|
||||
collisionHeader = new ZCollisionHeader(parent);
|
||||
collisionHeader->SetName(
|
||||
StringHelper::Sprintf("%sCollisionHeader_%06X", parent->GetName().c_str(), segmentOffset));
|
||||
collisionHeader->ExtractFromFile(segmentOffset);
|
||||
parent->AddResource(collisionHeader);
|
||||
}
|
||||
|
||||
void SetCollisionHeader::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
collisionHeader->DeclareVar(prefix, "");
|
||||
}
|
||||
|
||||
std::string SetCollisionHeader::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CollisionHeader", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_COL_HEADER(%s)", listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetCollisionHeader::GetCommandCName() const
|
||||
{
|
||||
return "SCmdColHeader";
|
||||
}
|
||||
|
||||
RoomCommand SetCollisionHeader::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetCollisionHeader;
|
||||
}
|
||||
20
ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.h
Normal file
20
ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZCollision.h"
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetCollisionHeader : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
ZCollisionHeader* collisionHeader;
|
||||
|
||||
SetCollisionHeader(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
};
|
||||
152
ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.cpp
Normal file
152
ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
#include "SetCsCamera.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetCsCamera::SetCsCamera(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetCsCamera::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
int numCameras = cmdArg1;
|
||||
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
int32_t numPoints = 0;
|
||||
|
||||
for (int32_t i = 0; i < numCameras; i++)
|
||||
{
|
||||
CsCameraEntry entry(parent->GetRawData(), currentPtr);
|
||||
numPoints += entry.GetNumPoints();
|
||||
|
||||
currentPtr += entry.GetRawDataSize();
|
||||
cameras.push_back(entry);
|
||||
}
|
||||
|
||||
if (numPoints > 0)
|
||||
{
|
||||
uint32_t currentPtr = cameras.at(0).GetSegmentOffset();
|
||||
|
||||
for (int32_t i = 0; i < numPoints; i++)
|
||||
{
|
||||
ZVector vec(parent);
|
||||
vec.ExtractFromBinary(currentPtr, ZScalarType::ZSCALAR_S16, 3);
|
||||
|
||||
currentPtr += vec.GetRawDataSize();
|
||||
points.push_back(vec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetCsCamera::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
if (points.size() > 0)
|
||||
{
|
||||
std::string declaration;
|
||||
size_t index = 0;
|
||||
for (auto& point : points)
|
||||
{
|
||||
declaration += StringHelper::Sprintf("\t{ %s },", point.GetBodySourceCode().c_str());
|
||||
|
||||
if (index < points.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
uint32_t segOffset = cameras.at(0).GetSegmentOffset();
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segOffset, DeclarationAlignment::Align4, points.size() * points.at(0).GetRawDataSize(),
|
||||
points.at(0).GetSourceTypeName().c_str(),
|
||||
StringHelper::Sprintf("%sCsCameraPoints_%06X", prefix.c_str(), segOffset),
|
||||
points.size(), declaration);
|
||||
}
|
||||
|
||||
if (!cameras.empty())
|
||||
{
|
||||
std::string camPointsName;
|
||||
Globals::Instance->GetSegmentedPtrName(cameras.at(0).GetCamAddress(), parent, "Vec3s",
|
||||
camPointsName);
|
||||
std::string declaration;
|
||||
|
||||
size_t index = 0;
|
||||
size_t pointsIndex = 0;
|
||||
for (const auto& entry : cameras)
|
||||
{
|
||||
declaration +=
|
||||
StringHelper::Sprintf("\t{ %i, %i, &%s[%i] },", entry.type, entry.numPoints,
|
||||
camPointsName.c_str(), pointsIndex);
|
||||
|
||||
if (index < cameras.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
pointsIndex += entry.GetNumPoints();
|
||||
}
|
||||
|
||||
const auto& entry = cameras.front();
|
||||
std::string camTypename = entry.GetSourceTypeName();
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::Align4, cameras.size() * entry.GetRawDataSize(),
|
||||
camTypename,
|
||||
StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), camTypename.c_str(), segmentOffset),
|
||||
cameras.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetCsCamera::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CsCameraEntry", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ACTOR_CUTSCENE_CAM_LIST(%i, %s)", cameras.size(),
|
||||
listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetCsCamera::GetCommandCName() const
|
||||
{
|
||||
return "SCmdCsCameraList";
|
||||
}
|
||||
|
||||
RoomCommand SetCsCamera::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetCsCamera;
|
||||
}
|
||||
|
||||
CsCameraEntry::CsCameraEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
: baseOffset(rawDataIndex), type(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)),
|
||||
numPoints(BitConverter::ToInt16BE(rawData, rawDataIndex + 2))
|
||||
{
|
||||
camAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
|
||||
segmentOffset = GETSEGOFFSET(camAddress);
|
||||
}
|
||||
|
||||
std::string CsCameraEntry::GetSourceTypeName() const
|
||||
{
|
||||
return "CsCameraEntry";
|
||||
}
|
||||
|
||||
int32_t CsCameraEntry::GetRawDataSize() const
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
int16_t CsCameraEntry::GetNumPoints() const
|
||||
{
|
||||
return numPoints;
|
||||
}
|
||||
|
||||
segptr_t CsCameraEntry::GetCamAddress() const
|
||||
{
|
||||
return camAddress;
|
||||
}
|
||||
|
||||
uint32_t CsCameraEntry::GetSegmentOffset() const
|
||||
{
|
||||
return segmentOffset;
|
||||
}
|
||||
40
ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.h
Normal file
40
ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
#include "ZVector.h"
|
||||
|
||||
class CsCameraEntry
|
||||
{
|
||||
public:
|
||||
CsCameraEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
|
||||
std::string GetSourceTypeName() const;
|
||||
int32_t GetRawDataSize() const;
|
||||
|
||||
int16_t GetNumPoints() const;
|
||||
segptr_t GetCamAddress() const;
|
||||
uint32_t GetSegmentOffset() const;
|
||||
|
||||
int baseOffset;
|
||||
int16_t type;
|
||||
int16_t numPoints;
|
||||
segptr_t camAddress;
|
||||
uint32_t segmentOffset;
|
||||
};
|
||||
|
||||
class SetCsCamera : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<CsCameraEntry> cameras;
|
||||
std::vector<ZVector> points;
|
||||
|
||||
SetCsCamera(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
112
ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.cpp
Normal file
112
ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
#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);
|
||||
|
||||
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])
|
||||
{
|
||||
}
|
||||
34
ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.h
Normal file
34
ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZCutscene.h"
|
||||
#include "ZCutsceneMM.h"
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class CutsceneEntry
|
||||
{
|
||||
public:
|
||||
CutsceneEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
|
||||
uint32_t segmentOffset;
|
||||
uint16_t exit;
|
||||
uint8_t entrance;
|
||||
uint8_t flag;
|
||||
};
|
||||
|
||||
class SetCutscenes : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<ZCutsceneBase*> cutscenes;
|
||||
std::vector<CutsceneEntry> cutsceneEntries; // (MM Only)
|
||||
uint8_t numCutscenes; // (MM Only)
|
||||
|
||||
SetCutscenes(ZFile* nParent);
|
||||
~SetCutscenes();
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
27
ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.cpp
Normal file
27
ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "SetEchoSettings.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetEchoSettings::SetEchoSettings(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetEchoSettings::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
echo = parent->GetRawData().at(rawDataIndex + 0x07);
|
||||
}
|
||||
|
||||
std::string SetEchoSettings::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("SCENE_CMD_ECHO_SETTINGS(%i)", echo);
|
||||
}
|
||||
|
||||
std::string SetEchoSettings::GetCommandCName() const
|
||||
{
|
||||
return "SCmdEchoSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetEchoSettings::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetEchoSettings;
|
||||
}
|
||||
18
ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.h
Normal file
18
ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetEchoSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t echo;
|
||||
|
||||
SetEchoSettings(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
};
|
||||
89
ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.cpp
Normal file
89
ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "SetEntranceList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "SetStartPositionList.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetEntranceList::SetEntranceList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetEntranceList::DeclareReferences([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (segmentOffset != 0)
|
||||
{
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sEntranceList0x%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationPlaceholder(segmentOffset, varName);
|
||||
}
|
||||
}
|
||||
|
||||
void SetEntranceList::ParseRawDataLate()
|
||||
{
|
||||
// Parse Entrances and Generate Declaration
|
||||
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numEntrances; i++)
|
||||
{
|
||||
EntranceEntry entry(parent->GetRawData(), currentPtr);
|
||||
entrances.push_back(entry);
|
||||
|
||||
currentPtr += 2;
|
||||
}
|
||||
}
|
||||
|
||||
void SetEntranceList::DeclareReferencesLate([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (!entrances.empty())
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
size_t index = 0;
|
||||
for (const auto& entry : entrances)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str());
|
||||
if (index + 1 < entrances.size())
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sEntranceList0x%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4,
|
||||
entrances.size() * 2, "EntranceEntry", varName,
|
||||
entrances.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetEntranceList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "EntranceEntry", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ENTRANCE_LIST(%s)", listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetEntranceList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdEntranceList";
|
||||
}
|
||||
|
||||
RoomCommand SetEntranceList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetEntranceList;
|
||||
}
|
||||
|
||||
EntranceEntry::EntranceEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
startPositionIndex = rawData.at(rawDataIndex + 0);
|
||||
roomToLoad = rawData.at(rawDataIndex + 1);
|
||||
}
|
||||
|
||||
std::string EntranceEntry::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("0x%02X, 0x%02X", startPositionIndex, roomToLoad);
|
||||
}
|
||||
31
ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.h
Normal file
31
ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class EntranceEntry
|
||||
{
|
||||
public:
|
||||
uint8_t startPositionIndex;
|
||||
uint8_t roomToLoad;
|
||||
|
||||
EntranceEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
|
||||
std::string GetBodySourceCode() const;
|
||||
};
|
||||
|
||||
class SetEntranceList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<EntranceEntry> entrances;
|
||||
|
||||
SetEntranceList(ZFile* nParent);
|
||||
|
||||
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;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
73
ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp
Normal file
73
ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "SetExitList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetExitList::SetExitList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (segmentOffset != 0)
|
||||
{
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationPlaceholder(segmentOffset, varName);
|
||||
}
|
||||
}
|
||||
|
||||
void SetExitList::ParseRawDataLate()
|
||||
{
|
||||
// Parse Entrances and Generate Declaration
|
||||
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numEntrances; i++)
|
||||
{
|
||||
uint16_t exit = BitConverter::ToUInt16BE(parent->GetRawData(), currentPtr);
|
||||
exits.push_back(exit);
|
||||
|
||||
currentPtr += 2;
|
||||
}
|
||||
}
|
||||
|
||||
void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (!exits.empty())
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
for (size_t i = 0; i < exits.size(); i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" 0x%04X,", exits.at(i));
|
||||
if (i + 1 < exits.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, exits.size() * 2,
|
||||
"u16", varName, exits.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetExitList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "u16", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_EXIT_LIST(%s)", listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetExitList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdExitList";
|
||||
}
|
||||
|
||||
RoomCommand SetExitList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetExitList;
|
||||
}
|
||||
20
ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.h
Normal file
20
ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetExitList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<uint16_t> exits;
|
||||
|
||||
SetExitList(ZFile* nParent);
|
||||
|
||||
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;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
97
ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp
Normal file
97
ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#include "SetLightList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetLightList::SetLightList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetLightList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
std::string declarations;
|
||||
|
||||
numLights = cmdArg1;
|
||||
int32_t currentPtr = segmentOffset;
|
||||
for (int i = 0; i < this->numLights; i++)
|
||||
{
|
||||
LightInfo light(parent->GetRawData(), currentPtr);
|
||||
|
||||
currentPtr += light.GetRawDataSize();
|
||||
lights.push_back(light);
|
||||
}
|
||||
}
|
||||
|
||||
void SetLightList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
if (!lights.empty())
|
||||
{
|
||||
std::string declarations;
|
||||
|
||||
for (size_t i = 0; i < lights.size(); i++)
|
||||
{
|
||||
declarations +=
|
||||
StringHelper::Sprintf("\t{ %s },", lights.at(i).GetBodySourceCode().c_str());
|
||||
|
||||
if (i < lights.size() - 1)
|
||||
declarations += "\n";
|
||||
}
|
||||
|
||||
const auto& light = lights.front();
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::Align4, lights.size() * light.GetRawDataSize(),
|
||||
light.GetSourceTypeName(),
|
||||
StringHelper::Sprintf("%sLightInfo0x%06X", prefix.c_str(), segmentOffset),
|
||||
lights.size(), declarations);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetLightList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightInfo", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_LIGHT_LIST(%i, %s)", numLights, listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetLightList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdLightList";
|
||||
}
|
||||
|
||||
RoomCommand SetLightList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetLightList;
|
||||
}
|
||||
|
||||
LightInfo::LightInfo(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
type = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0);
|
||||
x = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
y = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
z = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
r = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8);
|
||||
g = BitConverter::ToUInt8BE(rawData, rawDataIndex + 9);
|
||||
b = BitConverter::ToUInt8BE(rawData, rawDataIndex + 10);
|
||||
drawGlow = BitConverter::ToUInt8BE(rawData, rawDataIndex + 11);
|
||||
radius = BitConverter::ToInt16BE(rawData, rawDataIndex + 12);
|
||||
}
|
||||
|
||||
std::string LightInfo::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"0x%02X, { %i, %i, %i, { 0x%02X, 0x%02X, 0x%02X }, 0x%02X, 0x%04X }", type, x, y, z, r, g,
|
||||
b, drawGlow, radius);
|
||||
}
|
||||
|
||||
std::string LightInfo::GetSourceTypeName() const
|
||||
{
|
||||
return "LightInfo";
|
||||
}
|
||||
|
||||
size_t LightInfo::GetRawDataSize() const
|
||||
{
|
||||
return 0x0E;
|
||||
}
|
||||
42
ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.h
Normal file
42
ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class LightInfo
|
||||
{
|
||||
public:
|
||||
LightInfo(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
|
||||
std::string GetBodySourceCode() const;
|
||||
|
||||
std::string GetSourceTypeName() const;
|
||||
size_t GetRawDataSize() const;
|
||||
|
||||
public:
|
||||
uint8_t type;
|
||||
int16_t x, y, z;
|
||||
uint8_t r, g, b;
|
||||
uint8_t drawGlow;
|
||||
int16_t radius;
|
||||
};
|
||||
|
||||
class SetLightList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t numLights;
|
||||
std::vector<LightInfo> lights;
|
||||
|
||||
SetLightList(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
105
ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.cpp
Normal file
105
ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#include "SetLightingSettings.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetLightingSettings::SetLightingSettings(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetLightingSettings::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
uint8_t numLights = cmdArg1;
|
||||
|
||||
for (int i = 0; i < numLights; i++)
|
||||
settings.push_back(LightingSettings(parent->GetRawData(), segmentOffset + (i * 22)));
|
||||
}
|
||||
|
||||
void SetLightingSettings::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
if (settings.size() > 0)
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
for (size_t i = 0; i < settings.size(); i++)
|
||||
{
|
||||
declaration +=
|
||||
StringHelper::Sprintf("\t{ %s },", settings.at(i).GetBodySourceCode().c_str());
|
||||
if (i + 1 < settings.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::Align4,
|
||||
settings.size() * settings.front().GetRawDataSize(), "LightSettings",
|
||||
StringHelper::Sprintf("%sLightSettings0x%06X", prefix.c_str(), segmentOffset),
|
||||
settings.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetLightingSettings::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightSettings", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ENV_LIGHT_SETTINGS(%i, %s)", settings.size(),
|
||||
listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetLightingSettings::GetCommandCName() const
|
||||
{
|
||||
return "SCmdLightSettingList";
|
||||
}
|
||||
|
||||
RoomCommand SetLightingSettings::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetLightingSettings;
|
||||
}
|
||||
|
||||
LightingSettings::LightingSettings(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
ambientClrR = rawData.at(rawDataIndex + 0);
|
||||
ambientClrG = rawData.at(rawDataIndex + 1);
|
||||
ambientClrB = rawData.at(rawDataIndex + 2);
|
||||
|
||||
diffuseClrA_R = rawData.at(rawDataIndex + 3);
|
||||
diffuseClrA_G = rawData.at(rawDataIndex + 4);
|
||||
diffuseClrA_B = rawData.at(rawDataIndex + 5);
|
||||
|
||||
diffuseDirA_X = rawData.at(rawDataIndex + 6);
|
||||
diffuseDirA_Y = rawData.at(rawDataIndex + 7);
|
||||
diffuseDirA_Z = rawData.at(rawDataIndex + 8);
|
||||
|
||||
diffuseClrB_R = rawData.at(rawDataIndex + 9);
|
||||
diffuseClrB_G = rawData.at(rawDataIndex + 10);
|
||||
diffuseClrB_B = rawData.at(rawDataIndex + 11);
|
||||
|
||||
diffuseDirB_X = rawData.at(rawDataIndex + 12);
|
||||
diffuseDirB_Y = rawData.at(rawDataIndex + 13);
|
||||
diffuseDirB_Z = rawData.at(rawDataIndex + 14);
|
||||
|
||||
fogClrR = rawData.at(rawDataIndex + 15);
|
||||
fogClrG = rawData.at(rawDataIndex + 16);
|
||||
fogClrB = rawData.at(rawDataIndex + 17);
|
||||
|
||||
unk = BitConverter::ToInt16BE(rawData, rawDataIndex + 18);
|
||||
drawDistance = BitConverter::ToInt16BE(rawData, rawDataIndex + 20);
|
||||
}
|
||||
|
||||
std::string LightingSettings::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, "
|
||||
"0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%04X, 0x%04X",
|
||||
ambientClrR, ambientClrG, ambientClrB, diffuseClrA_R, diffuseClrA_G, diffuseClrA_B,
|
||||
diffuseDirA_X, diffuseDirA_Y, diffuseDirA_Z, diffuseClrB_R, diffuseClrB_G, diffuseClrB_B,
|
||||
diffuseDirB_X, diffuseDirB_Y, diffuseDirB_Z, fogClrR, fogClrG, fogClrB, unk, drawDistance);
|
||||
}
|
||||
|
||||
size_t LightingSettings::GetRawDataSize() const
|
||||
{
|
||||
return 0x16;
|
||||
}
|
||||
38
ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.h
Normal file
38
ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class LightingSettings
|
||||
{
|
||||
public:
|
||||
uint8_t ambientClrR, ambientClrG, ambientClrB;
|
||||
uint8_t diffuseClrA_R, diffuseClrA_G, diffuseClrA_B;
|
||||
uint8_t diffuseDirA_X, diffuseDirA_Y, diffuseDirA_Z;
|
||||
uint8_t diffuseClrB_R, diffuseClrB_G, diffuseClrB_B;
|
||||
uint8_t diffuseDirB_X, diffuseDirB_Y, diffuseDirB_Z;
|
||||
uint8_t fogClrR, fogClrG, fogClrB;
|
||||
uint16_t unk;
|
||||
uint16_t drawDistance;
|
||||
|
||||
LightingSettings(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
|
||||
std::string GetBodySourceCode() const;
|
||||
|
||||
size_t GetRawDataSize() const;
|
||||
};
|
||||
|
||||
class SetLightingSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<LightingSettings> settings;
|
||||
|
||||
SetLightingSettings(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
612
ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.cpp
Normal file
612
ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.cpp
Normal file
@@ -0,0 +1,612 @@
|
||||
#include "SetMesh.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/Path.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "WarningHandler.h"
|
||||
#include "ZBackground.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
void GenDListDeclarations(ZRoom* zRoom, ZFile* parent, ZDisplayList* dList);
|
||||
|
||||
SetMesh::SetMesh(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetMesh::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
auto& parentRawData = parent->GetRawData();
|
||||
meshHeaderType = parentRawData.at(segmentOffset);
|
||||
|
||||
switch (meshHeaderType)
|
||||
{
|
||||
case 0:
|
||||
polyType = std::make_shared<PolygonType2>(parent, segmentOffset, zRoom);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
polyType = std::make_shared<PolygonType1>(parent, segmentOffset, zRoom);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
polyType = std::make_shared<PolygonType2>(parent, segmentOffset, zRoom);
|
||||
break;
|
||||
|
||||
default:
|
||||
HANDLE_ERROR(WarningType::InvalidExtractedData,
|
||||
StringHelper::Sprintf("unknown meshHeaderType: %i", meshHeaderType), "");
|
||||
}
|
||||
|
||||
polyType->ParseRawData();
|
||||
}
|
||||
|
||||
void SetMesh::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
polyType->SetName(polyType->GetDefaultName(prefix));
|
||||
polyType->DeclareReferences(prefix);
|
||||
polyType->DeclareAndGenerateOutputCode(prefix);
|
||||
}
|
||||
|
||||
// TODO: is this really needed?
|
||||
void GenDListDeclarations(ZRoom* zRoom, ZFile* parent, ZDisplayList* dList)
|
||||
{
|
||||
if (dList == nullptr)
|
||||
return;
|
||||
|
||||
dList->DeclareReferences(zRoom->GetName());
|
||||
|
||||
for (ZDisplayList* otherDList : dList->otherDLists)
|
||||
GenDListDeclarations(zRoom, parent, otherDList);
|
||||
}
|
||||
|
||||
std::string SetMesh::GenDListExterns(ZDisplayList* dList)
|
||||
{
|
||||
std::string sourceOutput;
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("extern Gfx %sDL_%06X[];\n", zRoom->GetName().c_str(),
|
||||
dList->GetRawDataIndex());
|
||||
|
||||
for (ZDisplayList* otherDList : dList->otherDLists)
|
||||
sourceOutput += GenDListExterns(otherDList);
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
std::string SetMesh::GetBodySourceCode() const
|
||||
{
|
||||
std::string list;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "", list);
|
||||
return StringHelper::Sprintf("SCENE_CMD_MESH(%s)", list.c_str());
|
||||
}
|
||||
|
||||
std::string SetMesh::GetCommandCName() const
|
||||
{
|
||||
return "SCmdMesh";
|
||||
}
|
||||
|
||||
RoomCommand SetMesh::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetMesh;
|
||||
}
|
||||
|
||||
PolygonDlist::PolygonDlist(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void PolygonDlist::ParseRawData()
|
||||
{
|
||||
const auto& rawData = parent->GetRawData();
|
||||
switch (polyType)
|
||||
{
|
||||
case 2:
|
||||
x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
y = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
z = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
unk_06 = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
|
||||
opa = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8);
|
||||
xlu = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12);
|
||||
break;
|
||||
|
||||
default:
|
||||
opa = BitConverter::ToUInt32BE(rawData, rawDataIndex);
|
||||
xlu = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonDlist::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
opaDList = MakeDlist(opa, prefix);
|
||||
xluDList = MakeDlist(xlu, prefix);
|
||||
}
|
||||
|
||||
std::string PolygonDlist::GetBodySourceCode() const
|
||||
{
|
||||
std::string bodyStr;
|
||||
std::string opaStr;
|
||||
std::string xluStr;
|
||||
Globals::Instance->GetSegmentedPtrName(opa, parent, "Gfx", opaStr);
|
||||
Globals::Instance->GetSegmentedPtrName(xlu, parent, "Gfx", xluStr);
|
||||
|
||||
if (polyType == 2)
|
||||
{
|
||||
bodyStr += StringHelper::Sprintf("{ %6i, %6i, %6i }, %6i, ", x, y, z, unk_06);
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf("%s, %s", opaStr.c_str(), xluStr.c_str());
|
||||
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
void PolygonDlist::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
std::string bodyStr = StringHelper::Sprintf("\n\t%s\n", GetBodySourceCode().c_str());
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(rawDataIndex);
|
||||
|
||||
if (decl == nullptr)
|
||||
DeclareVar(prefix, bodyStr);
|
||||
else
|
||||
decl->text = bodyStr;
|
||||
}
|
||||
|
||||
std::string PolygonDlist::GetSourceTypeName() const
|
||||
{
|
||||
switch (polyType)
|
||||
{
|
||||
case 2:
|
||||
return "PolygonDlist2";
|
||||
|
||||
default:
|
||||
return "PolygonDlist";
|
||||
}
|
||||
}
|
||||
|
||||
ZResourceType PolygonDlist::GetResourceType() const
|
||||
{
|
||||
// TODO
|
||||
return ZResourceType::Error;
|
||||
}
|
||||
|
||||
size_t PolygonDlist::GetRawDataSize() const
|
||||
{
|
||||
switch (polyType)
|
||||
{
|
||||
case 2:
|
||||
return 0x10;
|
||||
|
||||
default:
|
||||
return 0x08;
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonDlist::SetPolyType(uint8_t nPolyType)
|
||||
{
|
||||
polyType = nPolyType;
|
||||
}
|
||||
|
||||
ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, [[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (ptr == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t dlistAddress = Seg2Filespace(ptr, parent->baseAddress);
|
||||
|
||||
int32_t dlistLength = ZDisplayList::GetDListLength(
|
||||
parent->GetRawData(), dlistAddress,
|
||||
Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX);
|
||||
ZDisplayList* dlist = new ZDisplayList(parent);
|
||||
parent->AddResource(dlist);
|
||||
dlist->ExtractFromBinary(dlistAddress, dlistLength);
|
||||
dlist->SetName(dlist->GetDefaultName(prefix));
|
||||
GenDListDeclarations(zRoom, parent, dlist);
|
||||
|
||||
return dlist;
|
||||
}
|
||||
|
||||
/* BgImage */
|
||||
|
||||
BgImage::BgImage(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
BgImage::BgImage(bool nIsSubStruct, const std::string& prefix, uint32_t nRawDataIndex,
|
||||
ZFile* nParent)
|
||||
: BgImage(nParent)
|
||||
{
|
||||
rawDataIndex = nRawDataIndex;
|
||||
parent = nParent;
|
||||
isSubStruct = nIsSubStruct;
|
||||
|
||||
name = GetDefaultName(prefix);
|
||||
|
||||
ParseRawData();
|
||||
sourceBackground = MakeBackground(source, prefix);
|
||||
}
|
||||
|
||||
void BgImage::ParseRawData()
|
||||
{
|
||||
size_t pad = 0x00;
|
||||
const auto& rawData = parent->GetRawData();
|
||||
if (!isSubStruct)
|
||||
{
|
||||
pad = 0x04;
|
||||
|
||||
unk_00 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00);
|
||||
id = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x02);
|
||||
}
|
||||
source = BitConverter::ToUInt32BE(rawData, rawDataIndex + pad + 0x00);
|
||||
unk_0C = BitConverter::ToUInt32BE(rawData, rawDataIndex + pad + 0x04);
|
||||
tlut = BitConverter::ToUInt32BE(rawData, rawDataIndex + pad + 0x08);
|
||||
width = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x0C);
|
||||
height = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x0E);
|
||||
fmt = BitConverter::ToUInt8BE(rawData, rawDataIndex + pad + 0x10);
|
||||
siz = BitConverter::ToUInt8BE(rawData, rawDataIndex + pad + 0x11);
|
||||
mode0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x12);
|
||||
tlutCount = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x14);
|
||||
}
|
||||
|
||||
ZBackground* BgImage::MakeBackground(segptr_t ptr, const std::string& prefix)
|
||||
{
|
||||
if (ptr == 0)
|
||||
return nullptr;
|
||||
|
||||
uint32_t backAddress = Seg2Filespace(ptr, parent->baseAddress);
|
||||
|
||||
ZBackground* background = new ZBackground(parent);
|
||||
background->ExtractFromFile(backAddress);
|
||||
|
||||
std::string defaultName = background->GetDefaultName(prefix);
|
||||
background->SetName(defaultName);
|
||||
background->SetOutName(defaultName);
|
||||
|
||||
background->DeclareVar(prefix, "");
|
||||
parent->resources.push_back(background);
|
||||
|
||||
return background;
|
||||
}
|
||||
|
||||
size_t BgImage::GetRawDataSize() const
|
||||
{
|
||||
return 0x1C;
|
||||
}
|
||||
|
||||
std::string BgImage::GetBodySourceCode() const
|
||||
{
|
||||
std::string bodyStr = " ";
|
||||
if (!isSubStruct)
|
||||
{
|
||||
bodyStr += "{ \n ";
|
||||
}
|
||||
|
||||
if (!isSubStruct)
|
||||
{
|
||||
bodyStr += StringHelper::Sprintf("0x%04X, ", unk_00);
|
||||
bodyStr += StringHelper::Sprintf("%i, ", id);
|
||||
bodyStr += "\n ";
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
std::string backgroundName;
|
||||
Globals::Instance->GetSegmentedPtrName(source, parent, "", backgroundName);
|
||||
bodyStr += StringHelper::Sprintf("%s, ", backgroundName.c_str());
|
||||
bodyStr += "\n ";
|
||||
if (!isSubStruct)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf("0x%08X, ", unk_0C);
|
||||
bodyStr += StringHelper::Sprintf("0x%08X, ", tlut);
|
||||
bodyStr += "\n ";
|
||||
if (!isSubStruct)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf("%i, ", width);
|
||||
bodyStr += StringHelper::Sprintf("%i, ", height);
|
||||
bodyStr += "\n ";
|
||||
if (!isSubStruct)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf("%i, ", fmt);
|
||||
bodyStr += StringHelper::Sprintf("%i, ", siz);
|
||||
bodyStr += "\n ";
|
||||
if (!isSubStruct)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf("0x%04X, ", mode0);
|
||||
bodyStr += StringHelper::Sprintf("0x%04X, ", tlutCount);
|
||||
if (!isSubStruct)
|
||||
{
|
||||
bodyStr += " \n }, ";
|
||||
}
|
||||
else
|
||||
{
|
||||
bodyStr += "\n";
|
||||
}
|
||||
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
std::string BgImage::GetSourceTypeName() const
|
||||
{
|
||||
return "BgImage";
|
||||
}
|
||||
|
||||
ZResourceType BgImage::GetResourceType() const
|
||||
{
|
||||
// TODO
|
||||
return ZResourceType::Error;
|
||||
}
|
||||
|
||||
/* PolygonType section */
|
||||
|
||||
PolygonTypeBase::PolygonTypeBase(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom)
|
||||
: ZResource(nParent), zRoom{nRoom}
|
||||
{
|
||||
rawDataIndex = nRawDataIndex;
|
||||
type = BitConverter::ToUInt8BE(parent->GetRawData(), rawDataIndex);
|
||||
}
|
||||
|
||||
void PolygonTypeBase::DeclareAndGenerateOutputCode(const std::string& prefix)
|
||||
{
|
||||
std::string bodyStr = GetBodySourceCode();
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(rawDataIndex);
|
||||
if (decl == nullptr)
|
||||
{
|
||||
DeclareVar(prefix, bodyStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
decl->text = bodyStr;
|
||||
}
|
||||
}
|
||||
|
||||
std::string PolygonTypeBase::GetSourceTypeName() const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 2:
|
||||
return "PolygonType2";
|
||||
|
||||
case 1:
|
||||
return "PolygonType1";
|
||||
|
||||
default:
|
||||
return "PolygonType0";
|
||||
}
|
||||
}
|
||||
|
||||
ZResourceType PolygonTypeBase::GetResourceType() const
|
||||
{
|
||||
// TODO
|
||||
return ZResourceType::Error;
|
||||
}
|
||||
|
||||
PolygonType1::PolygonType1(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom)
|
||||
: PolygonTypeBase(nParent, nRawDataIndex, nRoom), single(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void PolygonType1::ParseRawData()
|
||||
{
|
||||
const auto& rawData = parent->GetRawData();
|
||||
|
||||
format = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x01);
|
||||
dlist = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04);
|
||||
|
||||
if (format == 2)
|
||||
{
|
||||
count = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08);
|
||||
list = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0C);
|
||||
}
|
||||
|
||||
if (dlist != 0)
|
||||
{
|
||||
PolygonDlist polyGfxList(parent);
|
||||
polyGfxList.zRoom = zRoom;
|
||||
polyGfxList.SetPolyType(type);
|
||||
polyGfxList.ExtractFromFile(Seg2Filespace(dlist, parent->baseAddress));
|
||||
polyGfxList.DeclareReferences(zRoom->GetName());
|
||||
polyDLists.push_back(polyGfxList);
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonType1::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
polyDLists.at(0).GetSourceOutputCode(prefix);
|
||||
|
||||
uint32_t listAddress;
|
||||
std::string bgImageArrayBody;
|
||||
switch (format)
|
||||
{
|
||||
case 1:
|
||||
single = BgImage(true, prefix, rawDataIndex + 0x08, parent);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (list != 0)
|
||||
{
|
||||
listAddress = Seg2Filespace(list, parent->baseAddress);
|
||||
uint32_t auxPtr = listAddress;
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
BgImage bg(false, prefix, auxPtr, parent);
|
||||
multiList.push_back(bg);
|
||||
auxPtr += bg.GetRawDataSize();
|
||||
bgImageArrayBody += bg.GetBodySourceCode();
|
||||
if (i + 1 < count)
|
||||
{
|
||||
bgImageArrayBody += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(listAddress);
|
||||
if (decl == nullptr)
|
||||
{
|
||||
parent->AddDeclarationArray(
|
||||
listAddress, DeclarationAlignment::Align4,
|
||||
count * multiList.at(0).GetRawDataSize(), multiList.at(0).GetSourceTypeName(),
|
||||
multiList.at(0).GetName().c_str(), count, bgImageArrayBody);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
HANDLE_ERROR(WarningType::InvalidExtractedData,
|
||||
StringHelper::Sprintf("unknown format: %i", format), "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
size_t PolygonType1::GetRawDataSize() const
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case 1:
|
||||
return 0x20;
|
||||
|
||||
case 2:
|
||||
return 0x10;
|
||||
}
|
||||
return 0x20;
|
||||
}
|
||||
|
||||
std::string PolygonType1::GetBodySourceCode() const
|
||||
{
|
||||
std::string bodyStr = "\n ";
|
||||
|
||||
bodyStr += "{ ";
|
||||
bodyStr += StringHelper::Sprintf("%i, %i, ", type, format);
|
||||
|
||||
std::string dlistStr;
|
||||
Globals::Instance->GetSegmentedPtrName(dlist, parent, "", dlistStr);
|
||||
|
||||
bodyStr += StringHelper::Sprintf("%s, ", dlistStr.c_str());
|
||||
bodyStr += "}, \n";
|
||||
|
||||
std::string listStr = "NULL";
|
||||
switch (format)
|
||||
{
|
||||
case 1:
|
||||
bodyStr += single.GetBodySourceCode();
|
||||
break;
|
||||
case 2:
|
||||
Globals::Instance->GetSegmentedPtrName(list, parent, "BgImage", listStr);
|
||||
bodyStr += StringHelper::Sprintf(" %i, %s, \n", count, listStr.c_str());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
std::string PolygonType1::GetSourceTypeName() const
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case 1:
|
||||
return "MeshHeader1Single";
|
||||
|
||||
case 2:
|
||||
return "MeshHeader1Multi";
|
||||
}
|
||||
return "ERROR";
|
||||
// return "PolygonType1";
|
||||
}
|
||||
|
||||
PolygonType2::PolygonType2(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom)
|
||||
: PolygonTypeBase(nParent, nRawDataIndex, nRoom)
|
||||
{
|
||||
}
|
||||
|
||||
void PolygonType2::ParseRawData()
|
||||
{
|
||||
const auto& rawData = parent->GetRawData();
|
||||
|
||||
num = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x01);
|
||||
|
||||
start = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04);
|
||||
end = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08);
|
||||
|
||||
uint32_t currentPtr = GETSEGOFFSET(start);
|
||||
for (size_t i = 0; i < num; i++)
|
||||
{
|
||||
PolygonDlist entry(parent);
|
||||
entry.zRoom = zRoom;
|
||||
entry.SetPolyType(type);
|
||||
entry.ExtractFromFile(currentPtr);
|
||||
entry.DeclareReferences(zRoom->GetName());
|
||||
polyDLists.push_back(entry);
|
||||
currentPtr += entry.GetRawDataSize();
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonType2::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
if (num > 0)
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
for (size_t i = 0; i < polyDLists.size(); i++)
|
||||
{
|
||||
declaration +=
|
||||
StringHelper::Sprintf("\t{ %s },", polyDLists.at(i).GetBodySourceCode().c_str());
|
||||
if (i + 1 < polyDLists.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
std::string polyDlistType = polyDLists.at(0).GetSourceTypeName();
|
||||
std::string polyDListName;
|
||||
polyDListName = StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), polyDlistType.c_str(),
|
||||
GETSEGOFFSET(start));
|
||||
|
||||
Declaration* decl = parent->AddDeclarationArray(
|
||||
GETSEGOFFSET(start), DeclarationAlignment::Align4,
|
||||
polyDLists.size() * polyDLists.at(0).GetRawDataSize(), polyDlistType, polyDListName,
|
||||
polyDLists.size(), declaration);
|
||||
decl->forceArrayCnt = true;
|
||||
}
|
||||
|
||||
parent->AddDeclaration(GETSEGOFFSET(end), DeclarationAlignment::Align4, 4, "s32",
|
||||
StringHelper::Sprintf("%s_terminatorMaybe_%06X",
|
||||
parent->GetName().c_str(), GETSEGOFFSET(end)),
|
||||
"0x01000000");
|
||||
}
|
||||
|
||||
std::string PolygonType2::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(start, parent, "", listName);
|
||||
|
||||
std::string body = StringHelper::Sprintf("\n %i, %i,\n", type, polyDLists.size());
|
||||
body += StringHelper::Sprintf(" %s,\n", listName.c_str());
|
||||
body +=
|
||||
StringHelper::Sprintf(" %s + ARRAY_COUNTU(%s)\n", listName.c_str(), listName.c_str());
|
||||
return body;
|
||||
}
|
||||
|
||||
size_t PolygonType2::GetRawDataSize() const
|
||||
{
|
||||
return 0x0C;
|
||||
}
|
||||
|
||||
DeclarationAlignment PolygonType2::GetDeclarationAlignment() const
|
||||
{
|
||||
return DeclarationAlignment::Align4;
|
||||
}
|
||||
159
ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.h
Normal file
159
ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.h
Normal file
@@ -0,0 +1,159 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "ZBackground.h"
|
||||
#include "ZDisplayList.h"
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class PolygonDlist : public ZResource
|
||||
{
|
||||
public:
|
||||
ZRoom* zRoom;
|
||||
|
||||
uint8_t polyType;
|
||||
|
||||
int16_t x, y, z; // polyType == 2
|
||||
int16_t unk_06; // polyType == 2
|
||||
|
||||
segptr_t opa = 0; // Gfx*
|
||||
segptr_t xlu = 0; // Gfx*
|
||||
|
||||
ZDisplayList* opaDList = nullptr; // Gfx*
|
||||
ZDisplayList* xluDList = nullptr; // Gfx*
|
||||
|
||||
PolygonDlist(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
void GetSourceOutputCode(const std::string& prefix) override;
|
||||
|
||||
std::string GetSourceTypeName() const override;
|
||||
ZResourceType GetResourceType() const override;
|
||||
|
||||
size_t GetRawDataSize() const override;
|
||||
|
||||
void SetPolyType(uint8_t nPolyType);
|
||||
|
||||
protected:
|
||||
ZDisplayList* MakeDlist(segptr_t ptr, const std::string& prefix);
|
||||
};
|
||||
|
||||
class BgImage : public ZResource
|
||||
{
|
||||
public:
|
||||
uint16_t unk_00;
|
||||
uint8_t id;
|
||||
segptr_t source;
|
||||
uint32_t unk_0C;
|
||||
uint32_t tlut;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint8_t fmt;
|
||||
uint8_t siz;
|
||||
uint16_t mode0;
|
||||
uint16_t tlutCount;
|
||||
|
||||
ZBackground* sourceBackground;
|
||||
|
||||
bool isSubStruct;
|
||||
|
||||
BgImage(ZFile* nParent);
|
||||
BgImage(bool nIsSubStruct, const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetSourceTypeName() const override;
|
||||
ZResourceType GetResourceType() const override;
|
||||
|
||||
size_t GetRawDataSize() const override;
|
||||
|
||||
protected:
|
||||
ZBackground* MakeBackground(segptr_t ptr, const std::string& prefix);
|
||||
};
|
||||
|
||||
class PolygonTypeBase : public ZResource
|
||||
{
|
||||
public:
|
||||
uint8_t type;
|
||||
std::vector<PolygonDlist> polyDLists;
|
||||
|
||||
PolygonTypeBase(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom);
|
||||
|
||||
void DeclareAndGenerateOutputCode(const std::string& prefix);
|
||||
|
||||
std::string GetSourceTypeName() const override;
|
||||
ZResourceType GetResourceType() const override;
|
||||
|
||||
protected:
|
||||
ZRoom* zRoom;
|
||||
};
|
||||
|
||||
class PolygonType1 : public PolygonTypeBase
|
||||
{
|
||||
public:
|
||||
uint8_t format;
|
||||
segptr_t dlist;
|
||||
|
||||
// single
|
||||
BgImage single;
|
||||
|
||||
// multi
|
||||
uint8_t count;
|
||||
segptr_t list; // BgImage*
|
||||
std::vector<BgImage> multiList;
|
||||
|
||||
PolygonType1(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetSourceTypeName() const override;
|
||||
|
||||
size_t GetRawDataSize() const override;
|
||||
};
|
||||
|
||||
class PolygonType2 : public PolygonTypeBase
|
||||
{
|
||||
public:
|
||||
uint8_t num;
|
||||
segptr_t start;
|
||||
segptr_t end;
|
||||
|
||||
PolygonType2(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
size_t GetRawDataSize() const override;
|
||||
DeclarationAlignment GetDeclarationAlignment() const override;
|
||||
};
|
||||
|
||||
class SetMesh : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t data;
|
||||
uint8_t meshHeaderType;
|
||||
std::shared_ptr<PolygonTypeBase> polyType;
|
||||
|
||||
SetMesh(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
|
||||
private:
|
||||
std::string GenDListExterns(ZDisplayList* dList);
|
||||
};
|
||||
81
ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.cpp
Normal file
81
ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
#include "SetMinimapChests.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetMinimapChests::SetMinimapChests(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetMinimapChests::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
int numChests = cmdArg1;
|
||||
|
||||
int32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numChests; i++)
|
||||
{
|
||||
MinimapChest chest(parent->GetRawData(), currentPtr);
|
||||
chests.push_back(chest);
|
||||
|
||||
currentPtr += 10;
|
||||
}
|
||||
}
|
||||
|
||||
void SetMinimapChests::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
size_t index = 0;
|
||||
for (const auto& chest : chests)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %s },", chest.GetBodySourceCode().c_str());
|
||||
|
||||
if (index < chests.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::Align4, chests.size() * 10, "MinimapChest",
|
||||
StringHelper::Sprintf("%sMinimapChests0x%06X", prefix.c_str(), segmentOffset),
|
||||
chests.size(), declaration);
|
||||
}
|
||||
|
||||
std::string SetMinimapChests::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "MinimapChest", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_MINIMAP_COMPASS_ICON_INFO(0x%02X, %s)", chests.size(),
|
||||
listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetMinimapChests::GetCommandCName() const
|
||||
{
|
||||
return "SCmdMinimapChests";
|
||||
}
|
||||
|
||||
RoomCommand SetMinimapChests::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetMinimapChests;
|
||||
}
|
||||
|
||||
MinimapChest::MinimapChest(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
: unk0(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
|
||||
unk2(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)),
|
||||
unk4(BitConverter::ToUInt16BE(rawData, rawDataIndex + 4)),
|
||||
unk6(BitConverter::ToUInt16BE(rawData, rawDataIndex + 6)),
|
||||
unk8(BitConverter::ToUInt16BE(rawData, rawDataIndex + 8))
|
||||
{
|
||||
}
|
||||
|
||||
std::string MinimapChest::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X", unk0, unk2, unk4, unk6,
|
||||
unk8);
|
||||
}
|
||||
34
ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.h
Normal file
34
ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class MinimapChest
|
||||
{
|
||||
public:
|
||||
MinimapChest(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
|
||||
std::string GetBodySourceCode() const;
|
||||
|
||||
protected:
|
||||
uint16_t unk0;
|
||||
uint16_t unk2;
|
||||
uint16_t unk4;
|
||||
uint16_t unk6;
|
||||
uint16_t unk8;
|
||||
};
|
||||
|
||||
class SetMinimapChests : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<MinimapChest> chests;
|
||||
|
||||
SetMinimapChests(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
95
ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.cpp
Normal file
95
ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
#include "SetMinimapList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetMinimapList::SetMinimapList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetMinimapList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
listSegmentAddr = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset);
|
||||
listSegmentOffset = GETSEGOFFSET(listSegmentAddr);
|
||||
unk4 = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + 4);
|
||||
|
||||
int32_t currentPtr = listSegmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < zRoom->roomCount; i++)
|
||||
{
|
||||
MinimapEntry entry(parent->GetRawData(), currentPtr);
|
||||
minimaps.push_back(entry);
|
||||
|
||||
currentPtr += 10;
|
||||
}
|
||||
}
|
||||
|
||||
void SetMinimapList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
size_t index = 0;
|
||||
for (const auto& entry : minimaps)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str());
|
||||
|
||||
if (index < minimaps.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
listSegmentOffset, DeclarationAlignment::Align4, minimaps.size() * 10, "MinimapEntry",
|
||||
StringHelper::Sprintf("%sMinimapEntryList0x%06X", prefix.c_str(), listSegmentOffset),
|
||||
minimaps.size(), declaration);
|
||||
}
|
||||
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(listSegmentAddr, parent, "MinimapEntry", listName);
|
||||
std::string declaration = StringHelper::Sprintf("\n\t%s, 0x%08X\n", listName.c_str(), unk4);
|
||||
|
||||
parent->AddDeclaration(
|
||||
segmentOffset, DeclarationAlignment::Align4, 8, "MinimapList",
|
||||
StringHelper::Sprintf("%sMinimapList0x%06X", prefix.c_str(), segmentOffset),
|
||||
declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetMinimapList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "MinimapList", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_MINIMAP_INFO(%s)", listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetMinimapList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdMinimapSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetMinimapList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetMinimapList;
|
||||
}
|
||||
|
||||
MinimapEntry::MinimapEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
: unk0(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
|
||||
unk2(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)),
|
||||
unk4(BitConverter::ToUInt16BE(rawData, rawDataIndex + 4)),
|
||||
unk6(BitConverter::ToUInt16BE(rawData, rawDataIndex + 6)),
|
||||
unk8(BitConverter::ToUInt16BE(rawData, rawDataIndex + 8))
|
||||
{
|
||||
}
|
||||
|
||||
std::string MinimapEntry::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X", unk0, unk2, unk4, unk6,
|
||||
unk8);
|
||||
}
|
||||
39
ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.h
Normal file
39
ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class MinimapEntry
|
||||
{
|
||||
public:
|
||||
MinimapEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
|
||||
std::string GetBodySourceCode() const;
|
||||
|
||||
protected:
|
||||
uint16_t unk0;
|
||||
uint16_t unk2;
|
||||
uint16_t unk4;
|
||||
uint16_t unk6;
|
||||
uint16_t unk8;
|
||||
};
|
||||
|
||||
class SetMinimapList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<MinimapEntry> minimaps;
|
||||
|
||||
SetMinimapList(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
|
||||
private:
|
||||
segptr_t listSegmentAddr;
|
||||
uint32_t listSegmentOffset;
|
||||
uint32_t unk4;
|
||||
};
|
||||
66
ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.cpp
Normal file
66
ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "SetObjectList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZNames.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetObjectList::SetObjectList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetObjectList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
uint8_t objectCnt = parent->GetRawData().at(rawDataIndex + 1);
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (uint8_t i = 0; i < objectCnt; i++)
|
||||
{
|
||||
uint16_t objectIndex = BitConverter::ToInt16BE(parent->GetRawData(), currentPtr);
|
||||
objects.push_back(objectIndex);
|
||||
currentPtr += 2;
|
||||
}
|
||||
}
|
||||
|
||||
void SetObjectList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
if (!objects.empty())
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
for (size_t i = 0; i < objects.size(); i++)
|
||||
{
|
||||
uint16_t objectIndex = objects[i];
|
||||
declaration +=
|
||||
StringHelper::Sprintf(" %s,", ZNames::GetObjectName(objectIndex).c_str());
|
||||
|
||||
if (i < objects.size() - 1)
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::Align4, objects.size() * 2, "s16",
|
||||
StringHelper::Sprintf("%sObjectList_%06X", prefix.c_str(), segmentOffset),
|
||||
objects.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetObjectList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "s16", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_OBJECT_LIST(%i, %s)", objects.size(), listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetObjectList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdObjectList";
|
||||
}
|
||||
|
||||
RoomCommand SetObjectList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetObjectList;
|
||||
}
|
||||
19
ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.h
Normal file
19
ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetObjectList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<uint16_t> objects;
|
||||
|
||||
SetObjectList(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
};
|
||||
65
ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.cpp
Normal file
65
ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "SetPathways.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetPathways::SetPathways(ZFile* nParent) : ZRoomCommand(nParent), pathwayList(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetPathways::DeclareReferences([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (segmentOffset != 0)
|
||||
{
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sPathway_%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationPlaceholder(segmentOffset, varName);
|
||||
}
|
||||
}
|
||||
|
||||
void SetPathways::ParseRawDataLate()
|
||||
{
|
||||
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
||||
{
|
||||
auto numPaths = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 8;
|
||||
pathwayList.SetNumPaths(numPaths);
|
||||
}
|
||||
|
||||
if (Globals::Instance->otrMode)
|
||||
{
|
||||
auto zPath = (ZPath*)parent->FindResource(segmentOffset);
|
||||
|
||||
if (zPath != nullptr)
|
||||
pathwayList = *zPath;
|
||||
}
|
||||
|
||||
pathwayList.ExtractFromFile(segmentOffset);
|
||||
}
|
||||
|
||||
void SetPathways::DeclareReferencesLate(const std::string& prefix)
|
||||
{
|
||||
std::string varName = StringHelper::Sprintf("%sPathway_%06X", prefix.c_str(), segmentOffset);
|
||||
pathwayList.SetName(varName);
|
||||
pathwayList.DeclareReferences(prefix);
|
||||
pathwayList.GetSourceOutputCode(prefix);
|
||||
}
|
||||
|
||||
std::string SetPathways::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "Path", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_PATH_LIST(%s)", listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetPathways::GetCommandCName() const
|
||||
{
|
||||
return "SCmdPathList";
|
||||
}
|
||||
|
||||
RoomCommand SetPathways::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetPathways;
|
||||
}
|
||||
24
ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.h
Normal file
24
ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Vec3s.h"
|
||||
#include "ZPath.h"
|
||||
#include "ZResource.h"
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetPathways : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
ZPath pathwayList;
|
||||
|
||||
SetPathways(ZFile* nParent);
|
||||
|
||||
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;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
50
ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp
Normal file
50
ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "SetRoomBehavior.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetRoomBehavior::SetRoomBehavior(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetRoomBehavior::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
gameplayFlags = cmdArg1;
|
||||
gameplayFlags2 = BitConverter::ToInt32BE(parent->GetRawData(), rawDataIndex + 0x04);
|
||||
|
||||
currRoomUnk2 = gameplayFlags2 & 0xFF;
|
||||
|
||||
currRoomUnk5 = showInvisActors = (gameplayFlags2 >> 8) & 1;
|
||||
|
||||
msgCtxUnk = (gameplayFlags2 >> 10) & 1;
|
||||
|
||||
enablePosLights = (gameplayFlags2 >> 11) & 1;
|
||||
kankyoContextUnkE2 = (gameplayFlags2 >> 12) & 1;
|
||||
}
|
||||
|
||||
std::string SetRoomBehavior::GetBodySourceCode() const
|
||||
{
|
||||
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
||||
{
|
||||
std::string enableLights = StringHelper::BoolStr(enablePosLights);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ROOM_BEHAVIOR(0x%02X, 0x%02X, %i, %i, %s, %i)",
|
||||
gameplayFlags, currRoomUnk2, currRoomUnk5, msgCtxUnk,
|
||||
enableLights.c_str(), kankyoContextUnkE2);
|
||||
}
|
||||
std::string showInvisible = StringHelper::BoolStr(showInvisActors);
|
||||
std::string disableWarps = StringHelper::BoolStr(msgCtxUnk);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ROOM_BEHAVIOR(0x%02X, 0x%02X, %s, %s)", gameplayFlags,
|
||||
currRoomUnk2, showInvisible.c_str(), disableWarps.c_str());
|
||||
}
|
||||
|
||||
std::string SetRoomBehavior::GetCommandCName() const
|
||||
{
|
||||
return "SCmdRoomBehavior";
|
||||
}
|
||||
|
||||
RoomCommand SetRoomBehavior::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetRoomBehavior;
|
||||
}
|
||||
29
ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.h
Normal file
29
ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetRoomBehavior : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t gameplayFlags;
|
||||
uint32_t gameplayFlags2;
|
||||
|
||||
uint8_t currRoomUnk2;
|
||||
|
||||
uint8_t showInvisActors;
|
||||
uint8_t currRoomUnk5;
|
||||
|
||||
uint8_t msgCtxUnk;
|
||||
|
||||
uint8_t enablePosLights;
|
||||
uint8_t kankyoContextUnkE2;
|
||||
|
||||
SetRoomBehavior(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
154
ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.cpp
Normal file
154
ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
#include "SetRoomList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetRoomList::SetRoomList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetRoomList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
int numRooms = cmdArg1;
|
||||
|
||||
romfile = new RomFile(parent);
|
||||
romfile->numRooms = numRooms;
|
||||
romfile->ExtractFromFile(segmentOffset);
|
||||
|
||||
parent->resources.push_back(romfile);
|
||||
|
||||
zRoom->roomCount = numRooms;
|
||||
}
|
||||
|
||||
void SetRoomList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
ZRoomCommand::DeclareReferences(prefix);
|
||||
|
||||
romfile->DeclareVar(prefix, "");
|
||||
}
|
||||
|
||||
std::string SetRoomList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "RomFile", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ROOM_LIST(%i, %s)", romfile->rooms.size(),
|
||||
listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetRoomList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdRoomList";
|
||||
}
|
||||
|
||||
RoomCommand SetRoomList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetRoomList;
|
||||
}
|
||||
|
||||
RomFile::RomFile(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void RomFile::ParseXML(tinyxml2::XMLElement* reader)
|
||||
{
|
||||
ZResource::ParseXML(reader);
|
||||
|
||||
if (reader->Attribute("NumRooms") != nullptr)
|
||||
{
|
||||
numRooms = StringHelper::StrToL(std::string(reader->Attribute("NumRooms")));
|
||||
}
|
||||
}
|
||||
|
||||
void RomFile::ParseRawData()
|
||||
{
|
||||
ZResource::ParseRawData();
|
||||
|
||||
uint32_t currentPtr = rawDataIndex;
|
||||
|
||||
for (int32_t i = 0; i < numRooms; i++)
|
||||
{
|
||||
RoomEntry entry(parent->GetRawData(), currentPtr);
|
||||
rooms.push_back(entry);
|
||||
|
||||
currentPtr += 8;
|
||||
}
|
||||
}
|
||||
|
||||
Declaration* RomFile::DeclareVar(const std::string& prefix, const std::string& body)
|
||||
{
|
||||
std::string auxName = name;
|
||||
if (name == "")
|
||||
auxName = StringHelper::Sprintf("%sRoomList0x%06X", prefix.c_str(), rawDataIndex);
|
||||
|
||||
return parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4,
|
||||
rooms.size() * rooms.at(0).GetRawDataSize(),
|
||||
GetSourceTypeName(), auxName, rooms.size(), body);
|
||||
}
|
||||
|
||||
std::string RomFile::GetBodySourceCode() const
|
||||
{
|
||||
std::string declaration;
|
||||
bool isFirst = true;
|
||||
|
||||
for (ZFile* file : Globals::Instance->files)
|
||||
{
|
||||
for (ZResource* res : file->resources)
|
||||
{
|
||||
if (res->GetResourceType() == ZResourceType::Room)
|
||||
{
|
||||
std::string roomName = res->GetName();
|
||||
if (!isFirst)
|
||||
declaration += "\n";
|
||||
|
||||
declaration +=
|
||||
StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },",
|
||||
roomName.c_str(), roomName.c_str());
|
||||
isFirst = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return declaration;
|
||||
}
|
||||
|
||||
void RomFile::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
DeclareVar(prefix, GetBodySourceCode());
|
||||
}
|
||||
|
||||
std::string RomFile::GetSourceTypeName() const
|
||||
{
|
||||
return "RomFile";
|
||||
}
|
||||
|
||||
ZResourceType RomFile::GetResourceType() const
|
||||
{
|
||||
// TODO
|
||||
return ZResourceType::Error;
|
||||
}
|
||||
|
||||
size_t RomFile::GetRawDataSize() const
|
||||
{
|
||||
return 8 * rooms.size();
|
||||
}
|
||||
|
||||
RoomEntry::RoomEntry(uint32_t nVAS, uint32_t nVAE)
|
||||
{
|
||||
virtualAddressStart = nVAS;
|
||||
virtualAddressEnd = nVAE;
|
||||
}
|
||||
|
||||
RoomEntry::RoomEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
: RoomEntry(BitConverter::ToInt32BE(rawData, rawDataIndex + 0),
|
||||
BitConverter::ToInt32BE(rawData, rawDataIndex + 4))
|
||||
{
|
||||
}
|
||||
|
||||
size_t RoomEntry::GetRawDataSize() const
|
||||
{
|
||||
return 0x08;
|
||||
}
|
||||
53
ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.h
Normal file
53
ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class RoomEntry
|
||||
{
|
||||
public:
|
||||
int32_t virtualAddressStart;
|
||||
int32_t virtualAddressEnd;
|
||||
|
||||
RoomEntry(uint32_t nVAS, uint32_t nVAE);
|
||||
RoomEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
|
||||
size_t GetRawDataSize() const;
|
||||
};
|
||||
|
||||
class RomFile : public ZResource
|
||||
{
|
||||
public:
|
||||
RomFile(ZFile* nParent);
|
||||
|
||||
void ParseXML(tinyxml2::XMLElement* reader) override;
|
||||
void ParseRawData() override;
|
||||
|
||||
Declaration* DeclareVar(const std::string& prefix, const std::string& body) override;
|
||||
std::string GetBodySourceCode() const override;
|
||||
void GetSourceOutputCode(const std::string& prefix) override;
|
||||
|
||||
std::string GetSourceTypeName() const override;
|
||||
virtual ZResourceType GetResourceType() const override;
|
||||
|
||||
virtual size_t GetRawDataSize() const override;
|
||||
|
||||
uint8_t numRooms = 0;
|
||||
std::vector<RoomEntry> rooms;
|
||||
};
|
||||
|
||||
class SetRoomList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
// Borrowed reference. Don't delete.
|
||||
RomFile* romfile = nullptr;
|
||||
|
||||
SetRoomList(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
32
ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.cpp
Normal file
32
ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "SetSkyboxModifier.h"
|
||||
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetSkyboxModifier::SetSkyboxModifier(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetSkyboxModifier::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
disableSky = parent->GetRawData().at(rawDataIndex + 0x04);
|
||||
disableSunMoon = parent->GetRawData().at(rawDataIndex + 0x05);
|
||||
}
|
||||
|
||||
std::string SetSkyboxModifier::GetBodySourceCode() const
|
||||
{
|
||||
std::string sky = StringHelper::BoolStr(disableSky);
|
||||
std::string soonMoon = StringHelper::BoolStr(disableSunMoon);
|
||||
return StringHelper::Sprintf("SCENE_CMD_SKYBOX_DISABLES(%s, %s)", sky.c_str(),
|
||||
soonMoon.c_str());
|
||||
}
|
||||
|
||||
std::string SetSkyboxModifier::GetCommandCName() const
|
||||
{
|
||||
return "SCmdSkyboxDisables";
|
||||
}
|
||||
|
||||
RoomCommand SetSkyboxModifier::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetSkyboxModifier;
|
||||
}
|
||||
19
ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.h
Normal file
19
ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetSkyboxModifier : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t disableSky;
|
||||
uint8_t disableSunMoon;
|
||||
|
||||
SetSkyboxModifier(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
};
|
||||
36
ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.cpp
Normal file
36
ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "SetSkyboxSettings.h"
|
||||
#include "Globals.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetSkyboxSettings::SetSkyboxSettings(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetSkyboxSettings::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
unk1 = cmdArg1;
|
||||
skyboxNumber = parent->GetRawData().at(rawDataIndex + 0x04);
|
||||
cloudsType = parent->GetRawData().at(rawDataIndex + 0x05);
|
||||
isIndoors = parent->GetRawData().at(rawDataIndex + 0x06);
|
||||
}
|
||||
|
||||
std::string SetSkyboxSettings::GetBodySourceCode() const
|
||||
{
|
||||
std::string indoors = StringHelper::BoolStr(isIndoors);
|
||||
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
||||
return StringHelper::Sprintf("SCENE_CMD_SKYBOX_SETTINGS(0x%02X, %i, %i, %s)", unk1,
|
||||
skyboxNumber, cloudsType, indoors.c_str());
|
||||
return StringHelper::Sprintf("SCENE_CMD_SKYBOX_SETTINGS(%i, %i, %s)", skyboxNumber, cloudsType,
|
||||
indoors.c_str());
|
||||
}
|
||||
|
||||
std::string SetSkyboxSettings::GetCommandCName() const
|
||||
{
|
||||
return "SCmdSkyboxSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetSkyboxSettings::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetSkyboxSettings;
|
||||
}
|
||||
21
ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.h
Normal file
21
ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetSkyboxSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t unk1; // (MM Only)
|
||||
uint8_t skyboxNumber;
|
||||
uint8_t cloudsType;
|
||||
uint8_t isIndoors;
|
||||
|
||||
SetSkyboxSettings(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
};
|
||||
30
ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.cpp
Normal file
30
ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "SetSoundSettings.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetSoundSettings::SetSoundSettings(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetSoundSettings::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
reverb = cmdArg1;
|
||||
nightTimeSFX = parent->GetRawData().at(rawDataIndex + 0x06);
|
||||
musicSequence = parent->GetRawData().at(rawDataIndex + 0x07);
|
||||
}
|
||||
|
||||
std::string SetSoundSettings::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("SCENE_CMD_SOUND_SETTINGS(%i, %i, %i)", reverb, nightTimeSFX,
|
||||
musicSequence);
|
||||
}
|
||||
|
||||
std::string SetSoundSettings::GetCommandCName() const
|
||||
{
|
||||
return "SCmdSoundSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetSoundSettings::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetSoundSettings;
|
||||
}
|
||||
20
ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.h
Normal file
20
ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetSoundSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t reverb;
|
||||
uint8_t nightTimeSFX;
|
||||
uint8_t musicSequence;
|
||||
|
||||
SetSoundSettings(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
34
ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp
Normal file
34
ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "SetSpecialObjects.h"
|
||||
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZRoom/ZNames.h"
|
||||
|
||||
SetSpecialObjects::SetSpecialObjects(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetSpecialObjects::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
elfMessage = cmdArg1;
|
||||
globalObject = BitConverter::ToUInt16BE(parent->GetRawData(), rawDataIndex + 0x06);
|
||||
}
|
||||
|
||||
std::string SetSpecialObjects::GetBodySourceCode() const
|
||||
{
|
||||
std::string objectName = ZNames::GetObjectName(globalObject);
|
||||
|
||||
return StringHelper::Sprintf("SCENE_CMD_SPECIAL_FILES(0x%02X, %s)", elfMessage,
|
||||
objectName.c_str());
|
||||
}
|
||||
|
||||
std::string SetSpecialObjects::GetCommandCName() const
|
||||
{
|
||||
return "SCmdSpecialFiles";
|
||||
}
|
||||
|
||||
RoomCommand SetSpecialObjects::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetSpecialObjects;
|
||||
}
|
||||
19
ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.h
Normal file
19
ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetSpecialObjects : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t elfMessage;
|
||||
uint16_t globalObject;
|
||||
|
||||
SetSpecialObjects(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
66
ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.cpp
Normal file
66
ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "SetStartPositionList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZNames.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetStartPositionList::SetStartPositionList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetStartPositionList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
uint8_t numActors = cmdArg1;
|
||||
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numActors; i++)
|
||||
{
|
||||
actors.push_back(ActorSpawnEntry(parent->GetRawData(), currentPtr));
|
||||
currentPtr += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void SetStartPositionList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
if (!actors.empty())
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
size_t index = 0;
|
||||
for (const auto& entry : actors)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str());
|
||||
if (index + 1 < actors.size())
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::Align4, actors.size() * 16, "ActorEntry",
|
||||
StringHelper::Sprintf("%sStartPositionList0x%06X", prefix.c_str(), segmentOffset),
|
||||
actors.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetStartPositionList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_SPAWN_LIST(%i, %s)", actors.size(), listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetStartPositionList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdSpawnList";
|
||||
}
|
||||
|
||||
RoomCommand SetStartPositionList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetStartPositionList;
|
||||
}
|
||||
20
ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.h
Normal file
20
ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "SetActorList.h"
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetStartPositionList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<ActorSpawnEntry> actors;
|
||||
|
||||
SetStartPositionList(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
30
ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.cpp
Normal file
30
ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "SetTimeSettings.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetTimeSettings::SetTimeSettings(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetTimeSettings::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
hour = parent->GetRawData().at(rawDataIndex + 4);
|
||||
min = parent->GetRawData().at(rawDataIndex + 5);
|
||||
unk = parent->GetRawData().at(rawDataIndex + 6);
|
||||
}
|
||||
|
||||
std::string SetTimeSettings::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("SCENE_CMD_TIME_SETTINGS(%i, %i, %i)", hour, min, unk);
|
||||
}
|
||||
|
||||
std::string SetTimeSettings::GetCommandCName() const
|
||||
{
|
||||
return "SCmdTimeSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetTimeSettings::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetTimeSettings;
|
||||
}
|
||||
20
ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.h
Normal file
20
ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetTimeSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t hour;
|
||||
uint8_t min;
|
||||
uint8_t unk;
|
||||
|
||||
SetTimeSettings(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
};
|
||||
91
ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp
Normal file
91
ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
#include "SetTransitionActorList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZNames.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetTransitionActorList::SetTransitionActorList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetTransitionActorList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
int numActors = cmdArg1;
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numActors; i++)
|
||||
{
|
||||
TransitionActorEntry entry(parent->GetRawData(), currentPtr);
|
||||
transitionActors.push_back(entry);
|
||||
|
||||
currentPtr += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void SetTransitionActorList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
size_t index = 0;
|
||||
for (const auto& entry : transitionActors)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str());
|
||||
if (index + 1 < transitionActors.size())
|
||||
{
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::Align4, transitionActors.size() * 16,
|
||||
"TransitionActorEntry",
|
||||
StringHelper::Sprintf("%sTransitionActorList_%06X", prefix.c_str(), segmentOffset),
|
||||
transitionActors.size(), declaration);
|
||||
}
|
||||
|
||||
std::string SetTransitionActorList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "TransitionActorEntry", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_TRANSITION_ACTOR_LIST(%i, %s)", transitionActors.size(),
|
||||
listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetTransitionActorList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdTransiActorList";
|
||||
}
|
||||
|
||||
RoomCommand SetTransitionActorList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetTransitionActorList;
|
||||
}
|
||||
|
||||
TransitionActorEntry::TransitionActorEntry(const std::vector<uint8_t>& rawData, int rawDataIndex)
|
||||
{
|
||||
frontObjectRoom = rawData[rawDataIndex + 0];
|
||||
frontTransitionReaction = rawData[rawDataIndex + 1];
|
||||
backObjectRoom = rawData[rawDataIndex + 2];
|
||||
backTransitionReaction = rawData[rawDataIndex + 3];
|
||||
actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 8);
|
||||
posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 10);
|
||||
rotY = BitConverter::ToInt16BE(rawData, rawDataIndex + 12);
|
||||
initVar = BitConverter::ToInt16BE(rawData, rawDataIndex + 14);
|
||||
}
|
||||
|
||||
std::string TransitionActorEntry::GetBodySourceCode() const
|
||||
{
|
||||
std::string actorStr = ZNames::GetActorName(actorNum);
|
||||
|
||||
return StringHelper::Sprintf("%i, %i, %i, %i, %s, %i, %i, %i, %i, 0x%04X", frontObjectRoom,
|
||||
frontTransitionReaction, backObjectRoom, backTransitionReaction,
|
||||
actorStr.c_str(), posX, posY, posZ, rotY, initVar);
|
||||
}
|
||||
36
ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.h
Normal file
36
ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class TransitionActorEntry
|
||||
{
|
||||
public:
|
||||
uint8_t frontObjectRoom;
|
||||
uint8_t frontTransitionReaction;
|
||||
uint8_t backObjectRoom;
|
||||
uint8_t backTransitionReaction;
|
||||
uint16_t actorNum;
|
||||
int16_t posX, posY, posZ;
|
||||
int16_t rotY;
|
||||
uint16_t initVar;
|
||||
|
||||
TransitionActorEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
|
||||
std::string GetBodySourceCode() const;
|
||||
};
|
||||
|
||||
class SetTransitionActorList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<TransitionActorEntry> transitionActors;
|
||||
|
||||
SetTransitionActorList(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
32
ZAPDTR/ZAPD/ZRoom/Commands/SetWind.cpp
Normal file
32
ZAPDTR/ZAPD/ZRoom/Commands/SetWind.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "SetWind.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetWind::SetWind(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetWind::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
auto& parentRawData = parent->GetRawData();
|
||||
windWest = parentRawData.at(rawDataIndex + 0x04);
|
||||
windVertical = parentRawData.at(rawDataIndex + 0x05);
|
||||
windSouth = parentRawData.at(rawDataIndex + 0x06);
|
||||
clothFlappingStrength = parentRawData.at(rawDataIndex + 0x07);
|
||||
}
|
||||
|
||||
std::string SetWind::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("SCENE_CMD_WIND_SETTINGS(%i, %i, %i, %i)", windWest, windVertical,
|
||||
windSouth, clothFlappingStrength);
|
||||
}
|
||||
|
||||
std::string SetWind::GetCommandCName() const
|
||||
{
|
||||
return "SCmdWindSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetWind::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetWind;
|
||||
}
|
||||
21
ZAPDTR/ZAPD/ZRoom/Commands/SetWind.h
Normal file
21
ZAPDTR/ZAPD/ZRoom/Commands/SetWind.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetWind : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
uint8_t windWest;
|
||||
uint8_t windVertical;
|
||||
uint8_t windSouth;
|
||||
uint8_t clothFlappingStrength;
|
||||
|
||||
SetWind(ZFile* nParent);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
std::string GetCommandCName() const override;
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
};
|
||||
22
ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.cpp
Normal file
22
ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "SetWorldMapVisited.h"
|
||||
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetWorldMapVisited::SetWorldMapVisited(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
std::string SetWorldMapVisited::GetBodySourceCode() const
|
||||
{
|
||||
return "SCENE_CMD_MISC_SETTINGS()";
|
||||
}
|
||||
|
||||
std::string SetWorldMapVisited::GetCommandCName() const
|
||||
{
|
||||
return "SCmdWorldMapVisited";
|
||||
}
|
||||
|
||||
RoomCommand SetWorldMapVisited::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetWorldMapVisited;
|
||||
}
|
||||
14
ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.h
Normal file
14
ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class SetWorldMapVisited : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetWorldMapVisited(ZFile* nParent);
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
21
ZAPDTR/ZAPD/ZRoom/Commands/Unused09.cpp
Normal file
21
ZAPDTR/ZAPD/ZRoom/Commands/Unused09.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "Unused09.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
Unused09::Unused09(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
std::string Unused09::GetBodySourceCode() const
|
||||
{
|
||||
return "SCENE_CMD_UNK_09()";
|
||||
}
|
||||
|
||||
std::string Unused09::GetCommandCName() const
|
||||
{
|
||||
return "SceneCmd";
|
||||
}
|
||||
|
||||
RoomCommand Unused09::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::Unused09;
|
||||
}
|
||||
14
ZAPDTR/ZAPD/ZRoom/Commands/Unused09.h
Normal file
14
ZAPDTR/ZAPD/ZRoom/Commands/Unused09.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class Unused09 : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
Unused09(ZFile* nParent);
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
21
ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.cpp
Normal file
21
ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "Unused1D.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
Unused1D::Unused1D(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
std::string Unused1D::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("{ %s, 0x00, 0x00 }", GetCommandHex().c_str());
|
||||
}
|
||||
|
||||
std::string Unused1D::GetCommandCName() const
|
||||
{
|
||||
return "SceneCmd";
|
||||
}
|
||||
|
||||
RoomCommand Unused1D::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::Unused1D;
|
||||
}
|
||||
14
ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.h
Normal file
14
ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class Unused1D : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
Unused1D(ZFile* nParent);
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
std::string GetCommandCName() const override;
|
||||
};
|
||||
20
ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.cpp
Normal file
20
ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "ZRoomCommandUnk.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
ZRoomCommandUnk::ZRoomCommandUnk(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
std::string ZRoomCommandUnk::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("{ %s, 0x%02X, 0x%06X } /* WARNING: "
|
||||
"UNIMPLEMENTED ROOM COMMAND */",
|
||||
GetCommandHex().c_str(), cmdArg1, cmdArg2);
|
||||
}
|
||||
|
||||
RoomCommand ZRoomCommandUnk::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::Error;
|
||||
}
|
||||
12
ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.h
Normal file
12
ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "ZRoom/ZRoomCommand.h"
|
||||
|
||||
class ZRoomCommandUnk : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
ZRoomCommandUnk(ZFile* nParent);
|
||||
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
RoomCommand GetRoomCommand() const override;
|
||||
};
|
||||
49
ZAPDTR/ZAPD/ZRoom/ZNames.h
Normal file
49
ZAPDTR/ZAPD/ZRoom/ZNames.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
class ZNames
|
||||
{
|
||||
public:
|
||||
static std::string GetObjectName(size_t id)
|
||||
{
|
||||
if (id >= Globals::Instance->cfg.objectList.size())
|
||||
return StringHelper::Sprintf("0x%04X", id);
|
||||
return Globals::Instance->cfg.objectList.at(id);
|
||||
}
|
||||
|
||||
static std::string GetActorName(int32_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);
|
||||
else
|
||||
return StringHelper::Sprintf("0x%04X", id);
|
||||
case ZGame::MM_RETAIL:
|
||||
{
|
||||
int32_t flags = id & 0xF000;
|
||||
id &= 0xFFF;
|
||||
std::string name;
|
||||
if (id < ZNames::GetNumActors())
|
||||
name = Globals::Instance->cfg.actorList.at(id);
|
||||
else
|
||||
name = StringHelper::Sprintf("0x%04X", id);
|
||||
|
||||
if (flags == 0)
|
||||
return name;
|
||||
else
|
||||
return StringHelper::Sprintf("%s | 0x%04X", name.c_str(), flags);
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
static int32_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); }
|
||||
};
|
||||
427
ZAPDTR/ZAPD/ZRoom/ZRoom.cpp
Normal file
427
ZAPDTR/ZAPD/ZRoom/ZRoom.cpp
Normal file
@@ -0,0 +1,427 @@
|
||||
#include "ZRoom.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <cinttypes>
|
||||
#include <string_view>
|
||||
|
||||
#include "Commands/EndMarker.h"
|
||||
#include "Commands/SetActorCutsceneList.h"
|
||||
#include "Commands/SetActorList.h"
|
||||
#include "Commands/SetAlternateHeaders.h"
|
||||
#include "Commands/SetAnimatedMaterialList.h"
|
||||
#include "Commands/SetCameraSettings.h"
|
||||
#include "Commands/SetCollisionHeader.h"
|
||||
#include "Commands/SetCsCamera.h"
|
||||
#include "Commands/SetCutscenes.h"
|
||||
#include "Commands/SetEchoSettings.h"
|
||||
#include "Commands/SetEntranceList.h"
|
||||
#include "Commands/SetExitList.h"
|
||||
#include "Commands/SetLightList.h"
|
||||
#include "Commands/SetLightingSettings.h"
|
||||
#include "Commands/SetMesh.h"
|
||||
#include "Commands/SetMinimapChests.h"
|
||||
#include "Commands/SetMinimapList.h"
|
||||
#include "Commands/SetObjectList.h"
|
||||
#include "Commands/SetPathways.h"
|
||||
#include "Commands/SetRoomBehavior.h"
|
||||
#include "Commands/SetRoomList.h"
|
||||
#include "Commands/SetSkyboxModifier.h"
|
||||
#include "Commands/SetSkyboxSettings.h"
|
||||
#include "Commands/SetSoundSettings.h"
|
||||
#include "Commands/SetSpecialObjects.h"
|
||||
#include "Commands/SetStartPositionList.h"
|
||||
#include "Commands/SetTimeSettings.h"
|
||||
#include "Commands/SetTransitionActorList.h"
|
||||
#include "Commands/SetWind.h"
|
||||
#include "Commands/SetWorldMapVisited.h"
|
||||
#include "Commands/Unused09.h"
|
||||
#include "Commands/Unused1D.h"
|
||||
#include "Commands/ZRoomCommandUnk.h"
|
||||
#include "Globals.h"
|
||||
#include "Utils/File.h"
|
||||
#include "Utils/Path.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "WarningHandler.h"
|
||||
#include "ZBlob.h"
|
||||
#include "ZCutscene.h"
|
||||
#include "ZFile.h"
|
||||
|
||||
REGISTER_ZFILENODE(Room, ZRoom);
|
||||
REGISTER_ZFILENODE(Scene, ZRoom);
|
||||
REGISTER_ZFILENODE(AltHeader, ZRoom);
|
||||
|
||||
ZRoom::ZRoom(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
roomCount = -1;
|
||||
canHaveInner = true;
|
||||
RegisterOptionalAttribute("HackMode");
|
||||
}
|
||||
|
||||
ZRoom::~ZRoom()
|
||||
{
|
||||
for (ZRoomCommand* cmd : commands)
|
||||
delete cmd;
|
||||
}
|
||||
|
||||
void ZRoom::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex)
|
||||
{
|
||||
ZResource::ExtractFromXML(reader, nRawDataIndex);
|
||||
|
||||
if (hackMode == "syotes_room")
|
||||
{
|
||||
SyotesRoomHack();
|
||||
}
|
||||
else
|
||||
{
|
||||
DeclareVar(name, "");
|
||||
}
|
||||
}
|
||||
|
||||
void ZRoom::ExtractFromBinary(uint32_t nRawDataIndex, ZResourceType parentType)
|
||||
{
|
||||
rawDataIndex = nRawDataIndex;
|
||||
name = GetDefaultName(parent->GetName());
|
||||
|
||||
zroomType = ZResourceType::AltHeader;
|
||||
switch (parentType)
|
||||
{
|
||||
case ZResourceType::Scene:
|
||||
case ZResourceType::Room:
|
||||
case ZResourceType::AltHeader:
|
||||
parentZroomType = parentType;
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: error message or something
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
ParseRawData();
|
||||
DeclareVar(name, "");
|
||||
}
|
||||
|
||||
void ZRoom::ParseXML(tinyxml2::XMLElement* reader)
|
||||
{
|
||||
ZResource::ParseXML(reader);
|
||||
|
||||
// TODO: HACK: remove this specific check when the repo uses the correct HackMode="syotes_room"
|
||||
if (name == "syotes_room_0")
|
||||
{
|
||||
hackMode = "syotes_room";
|
||||
}
|
||||
|
||||
std::string nodeName = std::string(reader->Name());
|
||||
if (nodeName == "Scene")
|
||||
{
|
||||
zroomType = ZResourceType::Scene;
|
||||
}
|
||||
else if (nodeName == "Room")
|
||||
zroomType = ZResourceType::Room;
|
||||
else if (nodeName == "AltHeader")
|
||||
zroomType = ZResourceType::AltHeader;
|
||||
|
||||
if (reader->Attribute("HackMode") != nullptr)
|
||||
{
|
||||
hackMode = std::string(reader->Attribute("HackMode"));
|
||||
if (hackMode != "syotes_room")
|
||||
{
|
||||
std::string headerError = StringHelper::Sprintf(
|
||||
"invalid value found for 'HackMode' attribute: '%s'", hackMode.c_str());
|
||||
HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex,
|
||||
headerError, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZRoom::ParseRawData()
|
||||
{
|
||||
if (hackMode == "syotes_room")
|
||||
return;
|
||||
|
||||
bool shouldContinue = true;
|
||||
uint32_t currentIndex = 0;
|
||||
uint32_t currentPtr = rawDataIndex;
|
||||
|
||||
const auto& rawData = parent->GetRawData();
|
||||
while (shouldContinue)
|
||||
{
|
||||
RoomCommand opcode = static_cast<RoomCommand>(rawData.at(currentPtr));
|
||||
|
||||
ZRoomCommand* cmd = nullptr;
|
||||
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case RoomCommand::SetStartPositionList:
|
||||
cmd = new SetStartPositionList(parent);
|
||||
break; // 0x00
|
||||
case RoomCommand::SetActorList:
|
||||
cmd = new SetActorList(parent);
|
||||
break; // 0x01
|
||||
case RoomCommand::SetCsCamera:
|
||||
cmd = new SetCsCamera(parent);
|
||||
break; // 0x02 (MM-ONLY)
|
||||
case RoomCommand::SetCollisionHeader:
|
||||
cmd = new SetCollisionHeader(parent);
|
||||
break; // 0x03
|
||||
case RoomCommand::SetRoomList:
|
||||
cmd = new SetRoomList(parent);
|
||||
break; // 0x04
|
||||
case RoomCommand::SetWind:
|
||||
cmd = new SetWind(parent);
|
||||
break; // 0x05
|
||||
case RoomCommand::SetEntranceList:
|
||||
cmd = new SetEntranceList(parent);
|
||||
break; // 0x06
|
||||
case RoomCommand::SetSpecialObjects:
|
||||
cmd = new SetSpecialObjects(parent);
|
||||
break; // 0x07
|
||||
case RoomCommand::SetRoomBehavior:
|
||||
cmd = new SetRoomBehavior(parent);
|
||||
break; // 0x08
|
||||
case RoomCommand::Unused09:
|
||||
cmd = new Unused09(parent);
|
||||
break; // 0x09
|
||||
case RoomCommand::SetMesh:
|
||||
cmd = new SetMesh(parent);
|
||||
break; // 0x0A
|
||||
case RoomCommand::SetObjectList:
|
||||
cmd = new SetObjectList(parent);
|
||||
break; // 0x0B
|
||||
case RoomCommand::SetLightList:
|
||||
cmd = new SetLightList(parent);
|
||||
break; // 0x0C (MM-ONLY)
|
||||
case RoomCommand::SetPathways:
|
||||
cmd = new SetPathways(parent);
|
||||
break; // 0x0D
|
||||
case RoomCommand::SetTransitionActorList:
|
||||
cmd = new SetTransitionActorList(parent);
|
||||
break; // 0x0E
|
||||
case RoomCommand::SetLightingSettings:
|
||||
cmd = new SetLightingSettings(parent);
|
||||
break; // 0x0F
|
||||
case RoomCommand::SetTimeSettings:
|
||||
cmd = new SetTimeSettings(parent);
|
||||
break; // 0x10
|
||||
case RoomCommand::SetSkyboxSettings:
|
||||
cmd = new SetSkyboxSettings(parent);
|
||||
break; // 0x11
|
||||
case RoomCommand::SetSkyboxModifier:
|
||||
cmd = new SetSkyboxModifier(parent);
|
||||
break; // 0x12
|
||||
case RoomCommand::SetExitList:
|
||||
cmd = new SetExitList(parent);
|
||||
break; // 0x13
|
||||
case RoomCommand::EndMarker:
|
||||
cmd = new EndMarker(parent);
|
||||
break; // 0x14
|
||||
case RoomCommand::SetSoundSettings:
|
||||
cmd = new SetSoundSettings(parent);
|
||||
break; // 0x15
|
||||
case RoomCommand::SetEchoSettings:
|
||||
cmd = new SetEchoSettings(parent);
|
||||
break; // 0x16
|
||||
case RoomCommand::SetCutscenes:
|
||||
cmd = new SetCutscenes(parent);
|
||||
break; // 0x17
|
||||
case RoomCommand::SetAlternateHeaders:
|
||||
cmd = new SetAlternateHeaders(parent);
|
||||
break; // 0x18
|
||||
case RoomCommand::SetCameraSettings:
|
||||
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
||||
cmd = new SetWorldMapVisited(parent);
|
||||
else
|
||||
cmd = new SetCameraSettings(parent);
|
||||
break; // 0x19
|
||||
case RoomCommand::SetAnimatedMaterialList:
|
||||
cmd = new SetAnimatedMaterialList(parent);
|
||||
break; // 0x1A (MM-ONLY)
|
||||
case RoomCommand::SetActorCutsceneList:
|
||||
cmd = new SetActorCutsceneList(parent);
|
||||
break; // 0x1B (MM-ONLY)
|
||||
case RoomCommand::SetMinimapList:
|
||||
cmd = new SetMinimapList(parent);
|
||||
break; // 0x1C (MM-ONLY)
|
||||
case RoomCommand::Unused1D:
|
||||
cmd = new Unused1D(parent);
|
||||
break; // 0x1D
|
||||
case RoomCommand::SetMinimapChests:
|
||||
cmd = new SetMinimapChests(parent);
|
||||
break; // 0x1E (MM-ONLY)
|
||||
default:
|
||||
cmd = new ZRoomCommandUnk(parent);
|
||||
}
|
||||
|
||||
cmd->commandSet = rawDataIndex;
|
||||
cmd->ExtractCommandFromRoom(this, currentPtr);
|
||||
|
||||
if (Globals::Instance->profile)
|
||||
{
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
int64_t diff =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
||||
if (diff > 50)
|
||||
printf("OP: %s, TIME: %" PRIi64 "ms\n", cmd->GetCommandCName().c_str(), diff);
|
||||
}
|
||||
|
||||
cmd->cmdIndex = currentIndex;
|
||||
|
||||
commands.push_back(cmd);
|
||||
|
||||
if (opcode == RoomCommand::EndMarker)
|
||||
shouldContinue = false;
|
||||
|
||||
currentPtr += 8;
|
||||
currentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
void ZRoom::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
for (auto& cmd : commands)
|
||||
cmd->DeclareReferences(prefix);
|
||||
}
|
||||
|
||||
void ZRoom::ParseRawDataLate()
|
||||
{
|
||||
for (auto& cmd : commands)
|
||||
cmd->ParseRawDataLate();
|
||||
}
|
||||
|
||||
void ZRoom::DeclareReferencesLate(const std::string& prefix)
|
||||
{
|
||||
for (auto& cmd : commands)
|
||||
cmd->DeclareReferencesLate(prefix);
|
||||
}
|
||||
|
||||
Declaration* ZRoom::DeclareVar(const std::string& prefix, const std::string& body)
|
||||
{
|
||||
std::string auxName = name;
|
||||
if (auxName == "")
|
||||
auxName = GetDefaultName(prefix);
|
||||
if (zroomType == ZResourceType::Scene || zroomType == ZResourceType::Room)
|
||||
auxName = StringHelper::Sprintf("%sCommands", name.c_str());
|
||||
|
||||
Declaration* decl =
|
||||
parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(),
|
||||
GetSourceTypeName(), auxName, commands.size(), body);
|
||||
decl->staticConf = staticConf;
|
||||
return decl;
|
||||
}
|
||||
|
||||
std::string ZRoom::GetBodySourceCode() const
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
for (size_t i = 0; i < commands.size(); i++)
|
||||
{
|
||||
ZRoomCommand* cmd = commands[i];
|
||||
declaration += StringHelper::Sprintf("\t%s,", cmd->GetBodySourceCode().c_str());
|
||||
|
||||
if (i + 1 < commands.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
return declaration;
|
||||
}
|
||||
|
||||
std::string ZRoom::GetDefaultName(const std::string& prefix) const
|
||||
{
|
||||
return StringHelper::Sprintf("%sSet_%06X", prefix.c_str(), rawDataIndex);
|
||||
}
|
||||
|
||||
/*
|
||||
* There is one room in Ocarina of Time that lacks a header. Room 120, "Syotes", dates
|
||||
* back to very early in the game's development. Since this room is a special case,
|
||||
* declare automatically the data its contains whitout the need of a header.
|
||||
*/
|
||||
void ZRoom::SyotesRoomHack()
|
||||
{
|
||||
PolygonType2 poly(parent, 0, this);
|
||||
|
||||
poly.ParseRawData();
|
||||
poly.DeclareReferences(GetName());
|
||||
parent->AddDeclaration(0, poly.GetDeclarationAlignment(), poly.GetRawDataSize(),
|
||||
poly.GetSourceTypeName(), poly.GetDefaultName(GetName()),
|
||||
poly.GetBodySourceCode());
|
||||
}
|
||||
|
||||
ZRoomCommand* ZRoom::FindCommandOfType(RoomCommand cmdType)
|
||||
{
|
||||
for (size_t i = 0; i < commands.size(); i++)
|
||||
{
|
||||
if (commands[i]->GetRoomCommand() == cmdType)
|
||||
return commands[i];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t ZRoom::GetDeclarationSizeFromNeighbor(uint32_t declarationAddress)
|
||||
{
|
||||
auto currentDecl = parent->declarations.find(declarationAddress);
|
||||
if (currentDecl == parent->declarations.end())
|
||||
return 0;
|
||||
|
||||
auto nextDecl = currentDecl;
|
||||
std::advance(nextDecl, 1);
|
||||
if (nextDecl == parent->declarations.end())
|
||||
return parent->GetRawData().size() - currentDecl->first;
|
||||
|
||||
return nextDecl->first - currentDecl->first;
|
||||
}
|
||||
|
||||
size_t ZRoom::GetCommandSizeFromNeighbor(ZRoomCommand* cmd)
|
||||
{
|
||||
int32_t cmdIndex = -1;
|
||||
|
||||
for (size_t i = 0; i < commands.size(); i++)
|
||||
{
|
||||
if (commands[i] == cmd)
|
||||
{
|
||||
cmdIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cmdIndex != -1)
|
||||
{
|
||||
if (cmdIndex + 1 < (int32_t)commands.size())
|
||||
return commands[cmdIndex + 1]->cmdAddress - commands[cmdIndex]->cmdAddress;
|
||||
else
|
||||
return parent->GetRawData().size() - commands[cmdIndex]->cmdAddress;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ZRoom::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (hackMode != "syotes_room")
|
||||
DeclareVar(prefix, GetBodySourceCode());
|
||||
}
|
||||
|
||||
size_t ZRoom::GetRawDataSize() const
|
||||
{
|
||||
size_t size = 0;
|
||||
|
||||
for (ZRoomCommand* cmd : commands)
|
||||
size += cmd->GetRawDataSize();
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
std::string ZRoom::GetSourceTypeName() const
|
||||
{
|
||||
return "SceneCmd";
|
||||
}
|
||||
|
||||
ZResourceType ZRoom::GetResourceType() const
|
||||
{
|
||||
assert(zroomType == ZResourceType::Scene || zroomType == ZResourceType::Room ||
|
||||
zroomType == ZResourceType::AltHeader);
|
||||
return zroomType;
|
||||
}
|
||||
50
ZAPDTR/ZAPD/ZRoom/ZRoom.h
Normal file
50
ZAPDTR/ZAPD/ZRoom/ZRoom.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ZResource.h"
|
||||
#include "ZRoomCommand.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
class ZRoom : public ZResource
|
||||
{
|
||||
public:
|
||||
std::vector<ZRoomCommand*> commands;
|
||||
int32_t roomCount; // Only valid for scenes
|
||||
|
||||
std::string hackMode;
|
||||
|
||||
ZResourceType zroomType = ZResourceType::Error;
|
||||
ZResourceType parentZroomType = ZResourceType::Error;
|
||||
|
||||
ZRoom(ZFile* nParent);
|
||||
virtual ~ZRoom();
|
||||
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override;
|
||||
void ExtractFromBinary(uint32_t nRawDataIndex, ZResourceType parentType);
|
||||
|
||||
void ParseXML(tinyxml2::XMLElement* reader) override;
|
||||
void ParseRawData() override;
|
||||
void DeclareReferences(const std::string& prefix) override;
|
||||
void ParseRawDataLate() override;
|
||||
void DeclareReferencesLate(const std::string& prefix) override;
|
||||
|
||||
Declaration* DeclareVar(const std::string& prefix, const std::string& body) override;
|
||||
std::string GetBodySourceCode() const override;
|
||||
|
||||
void GetSourceOutputCode(const std::string& prefix) override;
|
||||
|
||||
std::string GetDefaultName(const std::string& prefix) const override;
|
||||
size_t GetDeclarationSizeFromNeighbor(uint32_t declarationAddress);
|
||||
size_t GetCommandSizeFromNeighbor(ZRoomCommand* cmd);
|
||||
ZRoomCommand* FindCommandOfType(RoomCommand cmdType);
|
||||
|
||||
size_t GetRawDataSize() const override;
|
||||
std::string GetSourceTypeName() const override;
|
||||
ZResourceType GetResourceType() const override;
|
||||
|
||||
protected:
|
||||
void SyotesRoomHack();
|
||||
};
|
||||
58
ZAPDTR/ZAPD/ZRoom/ZRoomCommand.cpp
Normal file
58
ZAPDTR/ZAPD/ZRoom/ZRoomCommand.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "ZRoomCommand.h"
|
||||
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZRoom.h"
|
||||
|
||||
ZRoomCommand::ZRoomCommand(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void ZRoomCommand::ExtractCommandFromRoom(ZRoom* nZRoom, uint32_t nRawDataIndex)
|
||||
{
|
||||
zRoom = nZRoom;
|
||||
rawDataIndex = nRawDataIndex;
|
||||
|
||||
ParseRawData();
|
||||
}
|
||||
|
||||
void ZRoomCommand::ParseRawData()
|
||||
{
|
||||
auto& parentRawData = parent->GetRawData();
|
||||
cmdID = static_cast<RoomCommand>(parentRawData.at(rawDataIndex));
|
||||
cmdAddress = rawDataIndex;
|
||||
|
||||
cmdArg1 = parentRawData.at(rawDataIndex + 1);
|
||||
cmdArg2 = BitConverter::ToUInt32BE(parentRawData, rawDataIndex + 4);
|
||||
segmentOffset = Seg2Filespace(cmdArg2, parent->baseAddress);
|
||||
}
|
||||
|
||||
RoomCommand ZRoomCommand::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::Error;
|
||||
}
|
||||
|
||||
size_t ZRoomCommand::GetRawDataSize() const
|
||||
{
|
||||
return 0x08;
|
||||
}
|
||||
|
||||
std::string ZRoomCommand::GetSourceTypeName() const
|
||||
{
|
||||
return GetCommandCName();
|
||||
}
|
||||
|
||||
ZResourceType ZRoomCommand::GetResourceType() const
|
||||
{
|
||||
return ZResourceType::RoomCommand;
|
||||
}
|
||||
|
||||
std::string ZRoomCommand::GetCommandCName() const
|
||||
{
|
||||
return "SceneCmd";
|
||||
}
|
||||
|
||||
std::string ZRoomCommand::GetCommandHex() const
|
||||
{
|
||||
return StringHelper::Sprintf("0x%02X", static_cast<uint8_t>(cmdID));
|
||||
}
|
||||
84
ZAPDTR/ZAPD/ZRoom/ZRoomCommand.h
Normal file
84
ZAPDTR/ZAPD/ZRoom/ZRoomCommand.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include "tinyxml2.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ZFile.h"
|
||||
#include "ZResource.h"
|
||||
|
||||
class ZRoom;
|
||||
|
||||
enum class RoomCommand : uint8_t
|
||||
{
|
||||
SetStartPositionList = 0x00,
|
||||
SetActorList = 0x01,
|
||||
SetCsCamera = 0x02,
|
||||
SetCollisionHeader = 0x03,
|
||||
SetRoomList = 0x04,
|
||||
SetWind = 0x05,
|
||||
SetEntranceList = 0x06,
|
||||
SetSpecialObjects = 0x07,
|
||||
SetRoomBehavior = 0x08,
|
||||
Unused09 = 0x09,
|
||||
SetMesh = 0x0A,
|
||||
SetObjectList = 0x0B,
|
||||
SetLightList = 0x0C,
|
||||
SetPathways = 0x0D,
|
||||
SetTransitionActorList = 0x0E,
|
||||
SetLightingSettings = 0x0F,
|
||||
SetTimeSettings = 0x10,
|
||||
SetSkyboxSettings = 0x11,
|
||||
SetSkyboxModifier = 0x12,
|
||||
SetExitList = 0x13,
|
||||
EndMarker = 0x14,
|
||||
SetSoundSettings = 0x15,
|
||||
SetEchoSettings = 0x16,
|
||||
SetCutscenes = 0x17,
|
||||
SetAlternateHeaders = 0x18,
|
||||
SetCameraSettings = 0x19,
|
||||
|
||||
// MM Commands
|
||||
SetWorldMapVisited = 0x19,
|
||||
SetAnimatedMaterialList = 0x1A,
|
||||
SetActorCutsceneList = 0x1B,
|
||||
SetMinimapList = 0x1C,
|
||||
Unused1D = 0x1D,
|
||||
SetMinimapChests = 0x1E,
|
||||
|
||||
Error = 0xFF
|
||||
};
|
||||
|
||||
class ZRoomCommand : public ZResource
|
||||
{
|
||||
public:
|
||||
int32_t cmdAddress;
|
||||
uint32_t cmdIndex;
|
||||
uint32_t commandSet;
|
||||
RoomCommand cmdID;
|
||||
offset_t segmentOffset;
|
||||
|
||||
ZRoomCommand(ZFile* nParent);
|
||||
virtual ~ZRoomCommand() = default;
|
||||
|
||||
virtual void ExtractCommandFromRoom(ZRoom* nZRoom, uint32_t nRawDataIndex);
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
std::string GetSourceTypeName() const override;
|
||||
ZResourceType GetResourceType() const override;
|
||||
|
||||
// Getters/Setters
|
||||
virtual RoomCommand GetRoomCommand() const = 0;
|
||||
size_t GetRawDataSize() const final override;
|
||||
virtual std::string GetCommandCName() const;
|
||||
|
||||
virtual std::string GetCommandHex() const;
|
||||
|
||||
public:
|
||||
ZRoom* zRoom;
|
||||
|
||||
uint8_t cmdArg1;
|
||||
segptr_t cmdArg2;
|
||||
};
|
||||
Reference in New Issue
Block a user