summaryrefslogtreecommitdiff
path: root/ZAPD/ZRoom/Commands
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2021-05-26 22:52:01 -0400
committerGitHub <noreply@github.com>2021-05-26 22:52:01 -0400
commiteb2d42e89153a877bff1bc30f7ea39766faf45d5 (patch)
treea1a6333aa7c512784d2e572a4eb7ce633ac10679 /ZAPD/ZRoom/Commands
parentcd3e9527b185190c5f7826766bf2b4760bd12d5f (diff)
Hotfix: fix AnimatedMaterial and Minimap extraction (#139)
* Fix minimaplist * fix the animated textures stuff
Diffstat (limited to 'ZAPD/ZRoom/Commands')
-rw-r--r--ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp44
-rw-r--r--ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h9
-rw-r--r--ZAPD/ZRoom/Commands/SetMinimapList.cpp9
-rw-r--r--ZAPD/ZRoom/Commands/SetMinimapList.h1
4 files changed, 41 insertions, 22 deletions
diff --git a/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp b/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp
index ef606a2..de0d05b 100644
--- a/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp
+++ b/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp
@@ -97,7 +97,7 @@ void SetAnimatedMaterialList::DeclareReferences(const std::string& prefix)
for (size_t i = 0; i < textures.size(); i++)
{
- std::string textureName = parent->GetDeclarationPtrName(textures.at(i).segmentOffset);
+ std::string textureName = parent->GetDeclarationPtrName(textures.at(i).segmentAddress);
declaration += StringHelper::Sprintf("\t{ %2i, %2i, %s },", textures.at(i).segment,
textures.at(i).type, textureName.c_str());
@@ -143,9 +143,11 @@ RoomCommand SetAnimatedMaterialList::GetRoomCommand() const
}
AnimatedMaterial::AnimatedMaterial(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
- : segment(rawData.at(rawDataIndex)), type(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
- segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)))
+ : segment(rawData.at(rawDataIndex)), type(BitConverter::ToInt16BE(rawData, rawDataIndex + 2))
{
+ segmentAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
+ segmentOffset = GETSEGOFFSET(segmentAddress);
+
switch (type)
{
case 0:
@@ -201,13 +203,18 @@ FlashingTextureEnvColor::FlashingTextureEnvColor(const std::vector<uint8_t>& raw
FlashingTexture::FlashingTexture(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex,
int32_t type)
: cycleLength(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
- numKeyFrames(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)),
- primColorSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4))),
- envColorSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 8))),
- keyFrameSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 12)))
+ numKeyFrames(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2))
{
uint16_t length = (type == 2) ? cycleLength : numKeyFrames;
+ primColorSegmentAddr = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
+ envColorSegmentAddr = BitConverter::ToInt32BE(rawData, rawDataIndex + 8);
+ keyFrameSegmentAddr = BitConverter::ToInt32BE(rawData, rawDataIndex + 12);
+
+ primColorSegmentOffset = GETSEGOFFSET(primColorSegmentAddr);
+ envColorSegmentOffset = GETSEGOFFSET(envColorSegmentAddr);
+ keyFrameSegmentOffset = GETSEGOFFSET(keyFrameSegmentAddr);
+
int32_t currentPtr = primColorSegmentOffset;
for (uint16_t i = 0; i < length; i++)
{
@@ -251,7 +258,7 @@ std::string FlashingTexture::GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddre
zRoom->parent->AddDeclarationArray(
primColorSegmentOffset, DeclarationAlignment::Align4, primColors.size() * 5,
"F3DPrimColor",
- StringHelper::Sprintf("%sAnimatedMaterialPrimColor0x%06X", zRoom->GetName().c_str(),
+ StringHelper::Sprintf("%sAnimatedMaterialPrimColor_%06X", zRoom->GetName().c_str(),
primColorSegmentOffset),
primColors.size(), declaration);
}
@@ -302,9 +309,9 @@ std::string FlashingTexture::GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddre
keyFrames.size(), declaration);
}
- std::string primName = zRoom->parent->GetDeclarationPtrName(primColorSegmentOffset);
- std::string envName = zRoom->parent->GetDeclarationPtrName(envColorSegmentOffset);
- std::string keyName = zRoom->parent->GetDeclarationPtrName(keyFrameSegmentOffset);
+ std::string primName = zRoom->parent->GetDeclarationPtrName(primColorSegmentAddr);
+ std::string envName = zRoom->parent->GetDeclarationPtrName(envColorSegmentAddr);
+ std::string keyName = zRoom->parent->GetDeclarationPtrName(keyFrameSegmentAddr);
return StringHelper::Sprintf("%i, %i, %s, %s, %s", cycleLength, numKeyFrames, primName.c_str(),
envName.c_str(), keyName.c_str());
@@ -317,11 +324,14 @@ size_t FlashingTexture::GetParamsSize()
AnimatedMatTexCycleParams::AnimatedMatTexCycleParams(const std::vector<uint8_t>& rawData,
uint32_t rawDataIndex)
- : cycleLength(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
- textureSegmentOffsetsSegmentOffset(
- GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4))),
- textureIndicesSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 8)))
+ : cycleLength(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0))
{
+ textureSegmentOffsetsSegmentAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
+ textureIndicesSegmentAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 8);
+
+ textureSegmentOffsetsSegmentOffset = GETSEGOFFSET(textureSegmentOffsetsSegmentAddress);
+ textureIndicesSegmentOffset = GETSEGOFFSET(textureIndicesSegmentAddress);
+
int32_t currentPtr = textureIndicesSegmentOffset;
int32_t maxIndex = 0;
@@ -390,8 +400,8 @@ std::string AnimatedMatTexCycleParams::GenerateSourceCode(ZRoom* zRoom, uint32_t
textureIndices.size(), declaration);
}
- std::string segmName = zRoom->parent->GetDeclarationPtrName(textureSegmentOffsetsSegmentOffset);
- std::string indexesName = zRoom->parent->GetDeclarationPtrName(textureIndicesSegmentOffset);
+ std::string segmName = zRoom->parent->GetDeclarationPtrName(textureSegmentOffsetsSegmentAddress);
+ std::string indexesName = zRoom->parent->GetDeclarationPtrName(textureIndicesSegmentAddress);
return StringHelper::Sprintf("%i, %s, %s", cycleLength, segmName.c_str(), indexesName.c_str());
}
diff --git a/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h b/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h
index 003d37d..3284d81 100644
--- a/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h
+++ b/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h
@@ -56,6 +56,11 @@ public:
uint16_t cycleLength;
uint16_t numKeyFrames;
+
+ segptr_t primColorSegmentAddr;
+ segptr_t envColorSegmentAddr;
+ segptr_t keyFrameSegmentAddr;
+
uint32_t primColorSegmentOffset;
uint32_t envColorSegmentOffset;
uint32_t keyFrameSegmentOffset;
@@ -73,6 +78,9 @@ public:
size_t GetParamsSize() override;
uint16_t cycleLength;
+
+ segptr_t textureSegmentOffsetsSegmentAddress;
+ segptr_t textureIndicesSegmentAddress;
uint32_t textureSegmentOffsetsSegmentOffset;
uint32_t textureIndicesSegmentOffset;
@@ -87,6 +95,7 @@ public:
int8_t segment;
int16_t type;
+ segptr_t segmentAddress;
uint32_t segmentOffset;
std::vector<std::shared_ptr<AnitmatedTextureParams>> params;
};
diff --git a/ZAPD/ZRoom/Commands/SetMinimapList.cpp b/ZAPD/ZRoom/Commands/SetMinimapList.cpp
index 51a8a81..c94ef30 100644
--- a/ZAPD/ZRoom/Commands/SetMinimapList.cpp
+++ b/ZAPD/ZRoom/Commands/SetMinimapList.cpp
@@ -13,8 +13,8 @@ SetMinimapList::SetMinimapList(ZFile* nParent) : ZRoomCommand(nParent)
void SetMinimapList::ParseRawData()
{
ZRoomCommand::ParseRawData();
- listSegmentOffset =
- GETSEGOFFSET(BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + 0));
+ listSegmentAddr = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset);
+ listSegmentOffset = GETSEGOFFSET(listSegmentAddr);
unk4 = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + 4);
int32_t currentPtr = listSegmentOffset;
@@ -51,9 +51,8 @@ void SetMinimapList::DeclareReferences(const std::string& prefix)
}
{
- std::string listName = parent->GetDeclarationPtrName(listSegmentOffset);
-
- std::string declaration = StringHelper::Sprintf("(u32)%s, 0x%08X", listName.c_str(), unk4);
+ std::string listName = parent->GetDeclarationPtrName(listSegmentAddr);
+ std::string declaration = StringHelper::Sprintf("\n\t%s, 0x%08X\n", listName.c_str(), unk4);
parent->AddDeclaration(
segmentOffset, DeclarationAlignment::Align4, 8, "MinimapList",
diff --git a/ZAPD/ZRoom/Commands/SetMinimapList.h b/ZAPD/ZRoom/Commands/SetMinimapList.h
index 2794c80..079e7b3 100644
--- a/ZAPD/ZRoom/Commands/SetMinimapList.h
+++ b/ZAPD/ZRoom/Commands/SetMinimapList.h
@@ -34,6 +34,7 @@ public:
private:
std::vector<MinimapEntry> minimaps;
+ segptr_t listSegmentAddr;
uint32_t listSegmentOffset;
uint32_t unk4;
};