From e7a8a48cf361a7591b88592eb3e333ddf8d3ab34 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sat, 16 Oct 2021 18:55:56 -0300 Subject: `ExternalFile`: Expose other XML's declarations during extraction (#151) * proof of concept * fix header include paths * GetDeclarationAlignment and others * this should fix this * minor * DeclareVar in ExtractFromXML * fix vtx intersections * Fix segmented vtxs * --version * zcollision changes * Use GetSegmentedPtrName a lot more * memory related stuff * minor style fixes and use the actual symbol for zlinkanimation instead of the hex address * Simplify lots of GetSourceOutputCode * ZSkeleton cleanup and other changes * Elevate unknown types in skeleton to errors * ZAnimation cleanup * Add ExternalFile to config * delete some code * Remove unused code * fix conflicts * format * remove redundant constructors * minor fixes * fix vtx warnings * extract every vtx as standalone files * format * uups * Bugfix: don't create extra blank files * Fix some Vtx warnings and remove "defaulting to normal" in skeleton error * Refactor ZLimb * Make each limb to look up in every file for dlists * Use GetSegmentedArrayIndexedName in VTX references in dlists * simplify simple condition * search by type * run format * Revert "search by type" This reverts commit a049bdfc94c4ab04613b354f466dee836a20508a. * Add range checks * uups * Always set rangeEnd * special case zsymbol * Revert "Revert "search by type"" This reverts commit 3f6e77c780bd30dc7000614304021a0940168316. * symbol fix and IsOffsetInFileRange * Bugfix and minor checks * run format * Don't extract data from external files * Fix extraction of overly big tluts * Minor changes * More minor fixes * Fix clang warnings * Remove unused parameter * Fix merge issues * Fix ZLimbTable::DeclareVar * Fix limbs not naming properly their DLists * Remove segment number check * Fix merge problems * Run formatter * Maybe fix? * path * empty commit * Fix a typo * Fix merge issues * Fix null ptr dereferencing * Fix merge issues and some clang warnings * Format * Fix not-matching * Format * Fix merge issues * Fix exporter * Last fixes I hope * Fix merge issues * format * fix * fix * I'm dumb * format * static fix * Whoops * fix asan * Fix? * fix * reduce artificial changes * reduce artificial changes 2 * reorder more stuff * format * fix borken thing * Remove redundant stuff in zfile * fix * Format * Fix conflict issues * format * cleanup header includes * format * Add error checks in for ExternalXMLFolder * format --- ZAPD/ZTextureAnimation.cpp | 55 +++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'ZAPD/ZTextureAnimation.cpp') 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 #include #include + #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(); -- cgit v1.2.3