summaryrefslogtreecommitdiff
path: root/ZAPD/ZTextureAnimation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ZAPD/ZTextureAnimation.cpp')
-rw-r--r--ZAPD/ZTextureAnimation.cpp55
1 files changed, 35 insertions, 20 deletions
diff --git a/ZAPD/ZTextureAnimation.cpp b/ZAPD/ZTextureAnimation.cpp
index 963a2f2..4332fcf 100644
--- a/ZAPD/ZTextureAnimation.cpp
+++ b/ZAPD/ZTextureAnimation.cpp
@@ -75,9 +75,11 @@
* Each of these will declare all its subsidiary arrays, using POD structs.
*/
#include "ZTextureAnimation.h"
+
#include <cassert>
#include <memory>
#include <vector>
+
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "ZFile.h"
@@ -189,7 +191,7 @@ std::string TextureScrollingParams::GetBodySourceCode() const
for (int i = 0; i < count; i++)
{
- bodyStr += StringHelper::Sprintf(" { %d, %d, 0x%02X, 0x%02X },\n", rows[i].xStep,
+ bodyStr += StringHelper::Sprintf("\t{ %d, %d, 0x%02X, 0x%02X },\n", rows[i].xStep,
rows[i].yStep, rows[i].width, rows[i].height);
}
@@ -297,7 +299,7 @@ void TextureColorChangingParams::DeclareReferences([[maybe_unused]] const std::s
for (const auto& color : primColorList)
{
- primColorBodyStr += StringHelper::Sprintf(" { %d, %d, %d, %d, %d },\n", color.r,
+ primColorBodyStr += StringHelper::Sprintf("\t{ %d, %d, %d, %d, %d },\n", color.r,
color.g, color.b, color.a, color.lodFrac);
}
@@ -317,7 +319,7 @@ void TextureColorChangingParams::DeclareReferences([[maybe_unused]] const std::s
for (const auto& color : envColorList)
{
- envColorBodyStr += StringHelper::Sprintf(" { %d, %d, %d, %d },\n", color.r, color.g,
+ envColorBodyStr += StringHelper::Sprintf("\t{ %d, %d, %d, %d },\n", color.r, color.g,
color.b, color.a);
}
@@ -333,7 +335,7 @@ void TextureColorChangingParams::DeclareReferences([[maybe_unused]] const std::s
if (frameDataListAddress != 0) // NULL
{
- std::string frameDataBodyStr = " ";
+ std::string frameDataBodyStr = "\t";
for (const auto& frame : frameDataList)
{
@@ -353,11 +355,17 @@ void TextureColorChangingParams::DeclareReferences([[maybe_unused]] const std::s
std::string TextureColorChangingParams::GetBodySourceCode() const
{
- std::string bodyStr =
- StringHelper::Sprintf("\n %d, %d, %s, %s, %s,\n", animLength, colorListCount,
- parent->GetDeclarationPtrName(primColorListAddress).c_str(),
- parent->GetDeclarationPtrName(envColorListAddress).c_str(),
- parent->GetDeclarationPtrName(frameDataListAddress).c_str());
+ std::string primColorListName;
+ std::string envColorListName;
+ std::string frameDataListName;
+
+ Globals::Instance->GetSegmentedPtrName(primColorListAddress, parent, "", primColorListName);
+ Globals::Instance->GetSegmentedPtrName(envColorListAddress, parent, "", envColorListName);
+ Globals::Instance->GetSegmentedPtrName(frameDataListAddress, parent, "", frameDataListName);
+
+ std::string bodyStr = StringHelper::Sprintf(
+ "\n %d, %d, %s, %s, %s,\n", animLength, colorListCount, primColorListName.c_str(),
+ envColorListName.c_str(), frameDataListName.c_str());
return bodyStr;
}
@@ -437,12 +445,12 @@ void TextureCyclingParams::DeclareReferences([[maybe_unused]] const std::string&
for (const auto& tex : textureList)
{
- texName = parent->GetDeclarationPtrName(tex);
+ bool texFound = Globals::Instance->GetSegmentedPtrName(tex, parent, "", texName);
// texName is a raw segmented pointer. This occurs if the texture is not declared
// separately since we cannot read the format. In theory we could scan DLists for the
// format on the appropriate segments.
- if (texName.length() == 10 && texName.substr(0, 2) == "0x")
+ if (!texFound)
{
comment = " // Raw pointer, declare texture in XML to use proper symbol";
@@ -462,8 +470,7 @@ void TextureCyclingParams::DeclareReferences([[maybe_unused]] const std::string&
Globals::Instance->inputPath.c_str(), parent->GetName().c_str(),
Seg2Filespace(textureListAddress, parent->baseAddress), texName.c_str());
}
- texturesBodyStr +=
- StringHelper::Sprintf(" %s,%s\n", texName.c_str(), comment.c_str());
+ texturesBodyStr += StringHelper::Sprintf("\t%s,%s\n", texName.c_str(), comment.c_str());
}
texturesBodyStr.pop_back();
@@ -478,7 +485,7 @@ void TextureCyclingParams::DeclareReferences([[maybe_unused]] const std::string&
if (textureIndexListAddress != 0) // NULL
{
- std::string indicesBodyStr = " ";
+ std::string indicesBodyStr = "\t";
for (uint8_t index : textureIndexList)
{
@@ -498,10 +505,15 @@ void TextureCyclingParams::DeclareReferences([[maybe_unused]] const std::string&
std::string TextureCyclingParams::GetBodySourceCode() const
{
- std::string bodyStr =
- StringHelper::Sprintf("\n %d, %s, %s,\n", cycleLength,
- parent->GetDeclarationPtrName(textureListAddress).c_str(),
- parent->GetDeclarationPtrName(textureIndexListAddress).c_str());
+ std::string textureListName;
+ std::string textureIndexListName;
+
+ Globals::Instance->GetSegmentedPtrName(textureListAddress, parent, "", textureListName);
+ Globals::Instance->GetSegmentedPtrName(textureIndexListAddress, parent, "",
+ textureIndexListName);
+
+ std::string bodyStr = StringHelper::Sprintf(
+ "\n %d, %s, %s,\n", cycleLength, textureListName.c_str(), textureIndexListName.c_str());
return bodyStr;
}
@@ -677,8 +689,11 @@ std::string ZTextureAnimation::GetBodySourceCode() const
for (const auto& entry : entries)
{
- bodyStr += StringHelper::Sprintf(" { %d, %d, %s },\n", entry.segment, entry.type,
- parent->GetDeclarationPtrName(entry.paramsPtr).c_str());
+ std::string paramName;
+ Globals::Instance->GetSegmentedPtrName(entry.paramsPtr, parent, "", paramName);
+
+ bodyStr += StringHelper::Sprintf("\t{ %d, %d, %s },\n", entry.segment, entry.type,
+ paramName.c_str());
}
bodyStr.pop_back();