summaryrefslogtreecommitdiff
path: root/ZAPD
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2021-10-16 22:21:04 -0300
committerGitHub <noreply@github.com>2021-10-16 21:21:04 -0400
commitd0cd6b3974706fc4d89c9b6545b8c17dd424b664 (patch)
treeadce2c5394489cab708303e63b80e697dd6c16cc /ZAPD
parente243634e5b0e7a7e3a6a5b2e7e9d73676df956ca (diff)
Fix static forward declarations for remaining resources (#202)
* Add sizes to almost every extracted array * Remove redundant stuff in zfile (cherry picked from commit c1cbf20f6786994dabdaf9e0cb95549fe7adcf34) * this is dumb * format * Fix merge issue * whoops
Diffstat (limited to 'ZAPD')
-rw-r--r--ZAPD/ZBlob.cpp2
-rw-r--r--ZAPD/ZCollision.cpp8
-rw-r--r--ZAPD/ZFile.cpp6
-rw-r--r--ZAPD/ZFile.h1
-rw-r--r--ZAPD/ZResource.cpp6
-rw-r--r--ZAPD/ZResource.h1
-rw-r--r--ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp2
-rw-r--r--ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp2
-rw-r--r--ZAPD/ZRoom/Commands/SetRoomList.cpp2
-rw-r--r--ZAPD/ZRoom/Commands/SetStartPositionList.cpp4
-rw-r--r--ZAPD/ZRoom/Commands/SetTransitionActorList.cpp4
-rw-r--r--ZAPD/ZRoom/ZRoom.cpp2
-rw-r--r--ZAPD/ZTexture.cpp4
13 files changed, 26 insertions, 18 deletions
diff --git a/ZAPD/ZBlob.cpp b/ZAPD/ZBlob.cpp
index 40c534e..c1f0788 100644
--- a/ZAPD/ZBlob.cpp
+++ b/ZAPD/ZBlob.cpp
@@ -57,7 +57,7 @@ Declaration* ZBlob::DeclareVar(const std::string& prefix,
StringHelper::Sprintf("%s.%s.inc.c", assetOutDir.c_str(), GetExternalExtension().c_str());
return parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(),
- GetSourceTypeName(), auxName, 0);
+ GetSourceTypeName(), auxName, blobData.size());
}
std::string ZBlob::GetBodySourceCode() const
diff --git a/ZAPD/ZCollision.cpp b/ZAPD/ZCollision.cpp
index 758164e..f9c0bf7 100644
--- a/ZAPD/ZCollision.cpp
+++ b/ZAPD/ZCollision.cpp
@@ -106,8 +106,8 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix)
parent->AddDeclarationArray(
waterBoxSegmentOffset, DeclarationAlignment::Align4, 16 * waterBoxes.size(), "WaterBox",
- StringHelper::Sprintf("%s_waterBoxes_%06X", auxName.c_str(), waterBoxSegmentOffset), 0,
- declaration);
+ StringHelper::Sprintf("%s_waterBoxes_%06X", auxName.c_str(), waterBoxSegmentOffset),
+ waterBoxes.size(), declaration);
}
if (polygons.size() > 0)
@@ -167,8 +167,8 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix)
parent->AddDeclarationArray(
vtxSegmentOffset, first.GetDeclarationAlignment(),
vertices.size() * first.GetRawDataSize(), first.GetSourceTypeName(),
- StringHelper::Sprintf("%s_vtx_%08X", auxName.c_str(), vtxSegmentOffset), 0,
- declaration);
+ StringHelper::Sprintf("%s_vtx_%08X", auxName.c_str(), vtxSegmentOffset),
+ vertices.size(), declaration);
}
}
diff --git a/ZAPD/ZFile.cpp b/ZAPD/ZFile.cpp
index e4bd771..82cb84f 100644
--- a/ZAPD/ZFile.cpp
+++ b/ZAPD/ZFile.cpp
@@ -702,8 +702,6 @@ void ZFile::GenerateSourceFiles()
sourceOutput += GetExternalFileHeaderInclude();
- sourceOutput += "\n";
-
GeneratePlaceholderDeclarations();
// Generate Code
@@ -810,7 +808,8 @@ void ZFile::GeneratePlaceholderDeclarations()
continue;
}
- Declaration* decl = AddDeclarationPlaceholder(res->GetRawDataIndex(), res->GetName());
+ Declaration* decl = res->DeclareVar(GetName(), "");
+ decl->staticConf = res->GetStaticConf();
if (res->GetResourceType() == ZResourceType::Symbol)
{
decl->staticConf = StaticConfig::Off;
@@ -1122,6 +1121,7 @@ std::string ZFile::ProcessTextureIntersections([[maybe_unused]] const std::strin
// Shrink palette so it doesn't overlap
currentTex->SetDimensions(offsetDiff / currentTex->GetPixelMultiplyer(), 1);
declarations.at(currentOffset)->size = currentTex->GetRawDataSize();
+ currentTex->DeclareVar(GetName(), "");
}
else
{
diff --git a/ZAPD/ZFile.h b/ZAPD/ZFile.h
index 00ae5e0..9323476 100644
--- a/ZAPD/ZFile.h
+++ b/ZAPD/ZFile.h
@@ -86,6 +86,7 @@ public:
std::string GetHeaderInclude() const;
std::string GetZRoomHeaderInclude() const;
std::string GetExternalFileHeaderInclude() const;
+
void GeneratePlaceholderDeclarations();
void AddTextureResource(uint32_t offset, ZTexture* tex);
diff --git a/ZAPD/ZResource.cpp b/ZAPD/ZResource.cpp
index 1e772ae..cb811f4 100644
--- a/ZAPD/ZResource.cpp
+++ b/ZAPD/ZResource.cpp
@@ -44,6 +44,7 @@ void ZResource::ExtractFromXML(tinyxml2::XMLElement* reader, offset_t nRawDataIn
if (decl != nullptr)
{
decl->declaredInXml = true;
+ decl->staticConf = staticConf;
}
}
}
@@ -231,6 +232,11 @@ bool ZResource::WasDeclaredInXml() const
return declaredInXml;
}
+StaticConfig ZResource::GetStaticConf() const
+{
+ return staticConf;
+}
+
offset_t ZResource::GetRawDataIndex() const
{
return rawDataIndex;
diff --git a/ZAPD/ZResource.h b/ZAPD/ZResource.h
index 87e4df6..727eca2 100644
--- a/ZAPD/ZResource.h
+++ b/ZAPD/ZResource.h
@@ -164,6 +164,7 @@ public:
* `false` otherwise (for example, a Vtx extracted indirectly by a DList)
*/
[[nodiscard]] bool WasDeclaredInXml() const;
+ [[nodiscard]] StaticConfig GetStaticConf() const;
protected:
std::string name;
diff --git a/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp b/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp
index ba31bc7..60391a9 100644
--- a/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp
+++ b/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp
@@ -47,7 +47,7 @@ void SetActorCutsceneList::DeclareReferences(const std::string& prefix)
parent->AddDeclarationArray(
segmentOffset, GetDeclarationAlignment(), cutscenes.size() * 16, typeName,
StringHelper::Sprintf("%s%sList_%06X", prefix.c_str(), typeName.c_str(), segmentOffset),
- 0, declaration);
+ cutscenes.size(), declaration);
}
}
diff --git a/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp b/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
index 016df12..629d4a0 100644
--- a/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
+++ b/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
@@ -59,7 +59,7 @@ void SetAlternateHeaders::DeclareReferencesLate(const std::string& prefix)
std::string varName =
StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset);
parent->AddDeclarationArray(segmentOffset, GetDeclarationAlignment(), headers.size() * 4,
- "SceneCmd*", varName, 0, declaration);
+ "SceneCmd*", varName, headers.size(), declaration);
}
}
diff --git a/ZAPD/ZRoom/Commands/SetRoomList.cpp b/ZAPD/ZRoom/Commands/SetRoomList.cpp
index e038139..43c3968 100644
--- a/ZAPD/ZRoom/Commands/SetRoomList.cpp
+++ b/ZAPD/ZRoom/Commands/SetRoomList.cpp
@@ -86,7 +86,7 @@ Declaration* RomFile::DeclareVar(const std::string& prefix, const std::string& b
return parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4,
rooms.size() * rooms.at(0).GetRawDataSize(),
- GetSourceTypeName(), auxName, 0, body);
+ GetSourceTypeName(), auxName, rooms.size(), body);
}
std::string RomFile::GetBodySourceCode() const
diff --git a/ZAPD/ZRoom/Commands/SetStartPositionList.cpp b/ZAPD/ZRoom/Commands/SetStartPositionList.cpp
index ad1d0a9..f75b5e0 100644
--- a/ZAPD/ZRoom/Commands/SetStartPositionList.cpp
+++ b/ZAPD/ZRoom/Commands/SetStartPositionList.cpp
@@ -43,8 +43,8 @@ void SetStartPositionList::DeclareReferences(const std::string& prefix)
parent->AddDeclarationArray(
segmentOffset, DeclarationAlignment::Align4, actors.size() * 16, "ActorEntry",
- StringHelper::Sprintf("%sStartPositionList0x%06X", prefix.c_str(), segmentOffset), 0,
- declaration);
+ StringHelper::Sprintf("%sStartPositionList0x%06X", prefix.c_str(), segmentOffset),
+ actors.size(), declaration);
}
}
diff --git a/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp b/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp
index d47ca34..a33d1c6 100644
--- a/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp
+++ b/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp
@@ -45,8 +45,8 @@ void SetTransitionActorList::DeclareReferences(const std::string& prefix)
parent->AddDeclarationArray(
segmentOffset, DeclarationAlignment::Align4, transitionActors.size() * 16,
"TransitionActorEntry",
- StringHelper::Sprintf("%sTransitionActorList_%06X", prefix.c_str(), segmentOffset), 0,
- declaration);
+ StringHelper::Sprintf("%sTransitionActorList_%06X", prefix.c_str(), segmentOffset),
+ transitionActors.size(), declaration);
}
std::string SetTransitionActorList::GetBodySourceCode() const
diff --git a/ZAPD/ZRoom/ZRoom.cpp b/ZAPD/ZRoom/ZRoom.cpp
index 9f4d5a9..edc0cad 100644
--- a/ZAPD/ZRoom/ZRoom.cpp
+++ b/ZAPD/ZRoom/ZRoom.cpp
@@ -301,7 +301,7 @@ Declaration* ZRoom::DeclareVar(const std::string& prefix, const std::string& bod
Declaration* decl =
parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(),
- GetSourceTypeName(), auxName, 0, body);
+ GetSourceTypeName(), auxName, commands.size(), body);
decl->staticConf = staticConf;
return decl;
}
diff --git a/ZAPD/ZTexture.cpp b/ZAPD/ZTexture.cpp
index 49ac16c..33ee54d 100644
--- a/ZAPD/ZTexture.cpp
+++ b/ZAPD/ZTexture.cpp
@@ -763,8 +763,8 @@ Declaration* ZTexture::DeclareVar(const std::string& prefix,
}
}
- Declaration* decl = parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(),
- GetSourceTypeName(), auxName, 0);
+ Declaration* decl = parent->AddDeclarationIncludeArray(
+ rawDataIndex, incStr, GetRawDataSize(), GetSourceTypeName(), auxName, GetRawDataSize() / 8);
decl->staticConf = staticConf;
return decl;
}