mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-16 12:02:50 +00:00
Update ZAPD (#1001)
* remove fake match * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "3e9ed72e2" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "3e9ed72e2" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * new extraction script and a hack to make clear tag work * fix clear tag again * remove static from clear tag DLists * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "e7a8a48cf" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "e7a8a48cf" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "e243634e5" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "e243634e5" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "d0cd6b397" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "d0cd6b397" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Update ovl_En_Clear_Tag.xml
This commit is contained in:
parent
ed487b4bb8
commit
750c0cab35
272 changed files with 7790 additions and 58414 deletions
|
@ -1,9 +1,10 @@
|
|||
#include "ZSkeleton.h"
|
||||
|
||||
#include <cassert>
|
||||
#include "BitConverter.h"
|
||||
#include "HighLevel/HLModelIntermediette.h"
|
||||
#include "StringHelper.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
REGISTER_ZFILENODE(Skeleton, ZSkeleton);
|
||||
REGISTER_ZFILENODE(LimbTable, ZLimbTable);
|
||||
|
@ -14,14 +15,6 @@ ZSkeleton::ZSkeleton(ZFile* nParent) : ZResource(nParent), limbsTable(nParent)
|
|||
RegisterRequiredAttribute("LimbType");
|
||||
}
|
||||
|
||||
void ZSkeleton::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex)
|
||||
{
|
||||
ZResource::ExtractFromXML(reader, nRawDataIndex);
|
||||
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(),
|
||||
GetSourceTypeName(), name, "");
|
||||
}
|
||||
|
||||
void ZSkeleton::ParseXML(tinyxml2::XMLElement* reader)
|
||||
{
|
||||
ZResource::ParseXML(reader);
|
||||
|
@ -34,24 +27,18 @@ void ZSkeleton::ParseXML(tinyxml2::XMLElement* reader)
|
|||
type = ZSkeletonType::Curve;
|
||||
else if (skelTypeXml != "Normal")
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ZSkeleton::ParseXML: Warning in '%s'.\n"
|
||||
"\t Invalid Type found: '%s'.\n"
|
||||
"\t Defaulting to 'Normal'.\n",
|
||||
name.c_str(), skelTypeXml.c_str());
|
||||
type = ZSkeletonType::Normal;
|
||||
throw std::runtime_error(StringHelper::Sprintf("ZSkeleton::ParseXML: Error in '%s'.\n"
|
||||
"\t Invalid Type found: '%s'.\n",
|
||||
name.c_str(), skelTypeXml.c_str()));
|
||||
}
|
||||
|
||||
std::string limbTypeXml = registeredAttributes.at("LimbType").value;
|
||||
limbType = ZLimb::GetTypeByAttributeName(limbTypeXml);
|
||||
if (limbType == ZLimbType::Invalid)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ZSkeleton::ParseXML: Warning in '%s'.\n"
|
||||
"\t Invalid LimbType found: '%s'.\n"
|
||||
"\t Defaulting to 'Standard'.\n",
|
||||
name.c_str(), limbTypeXml.c_str());
|
||||
limbType = ZLimbType::Standard;
|
||||
throw std::runtime_error(StringHelper::Sprintf("ZSkeleton::ParseXML: Error in '%s'.\n"
|
||||
"\t Invalid LimbType found: '%s'.\n",
|
||||
name.c_str(), limbTypeXml.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,6 +64,8 @@ void ZSkeleton::DeclareReferences(const std::string& prefix)
|
|||
if (defaultPrefix == "")
|
||||
defaultPrefix = prefix;
|
||||
|
||||
ZResource::DeclareReferences(defaultPrefix);
|
||||
|
||||
if (limbsArrayAddress != 0 && GETSEGNUM(limbsArrayAddress) == parent->segment)
|
||||
{
|
||||
uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress);
|
||||
|
@ -91,29 +80,22 @@ void ZSkeleton::DeclareReferences(const std::string& prefix)
|
|||
|
||||
std::string ZSkeleton::GetBodySourceCode() const
|
||||
{
|
||||
std::string limbTableName = parent->GetDeclarationPtrName(limbsArrayAddress);
|
||||
std::string limbArrayName;
|
||||
Globals::Instance->GetSegmentedPtrName(limbsArrayAddress, parent, "", limbArrayName);
|
||||
|
||||
std::string headerStr;
|
||||
switch (type)
|
||||
{
|
||||
case ZSkeletonType::Normal:
|
||||
case ZSkeletonType::Curve:
|
||||
headerStr = StringHelper::Sprintf("\n\t%s, %i\n", limbTableName.c_str(), limbCount);
|
||||
break;
|
||||
return StringHelper::Sprintf("\n\t%s, %i\n", limbArrayName.c_str(), limbCount);
|
||||
|
||||
case ZSkeletonType::Flex:
|
||||
headerStr = StringHelper::Sprintf("\n\t{ %s, %i }, %i\n", limbTableName.c_str(), limbCount,
|
||||
dListCount);
|
||||
break;
|
||||
return StringHelper::Sprintf("\n\t{ %s, %i }, %i\n", limbArrayName.c_str(), limbCount,
|
||||
dListCount);
|
||||
}
|
||||
|
||||
return headerStr;
|
||||
}
|
||||
|
||||
void ZSkeleton::GenerateHLIntermediette(HLFileIntermediette& hlFile)
|
||||
{
|
||||
HLModelIntermediette* mdl = (HLModelIntermediette*)&hlFile;
|
||||
HLModelIntermediette::FromZSkeleton(mdl, this);
|
||||
mdl->blocks.push_back(new HLTerminator());
|
||||
// TODO: Throw exception?
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
size_t ZSkeleton::GetRawDataSize() const
|
||||
|
@ -129,25 +111,6 @@ size_t ZSkeleton::GetRawDataSize() const
|
|||
}
|
||||
}
|
||||
|
||||
std::string ZSkeleton::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
std::string headerStr = GetBodySourceCode();
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(GetAddress());
|
||||
|
||||
if (decl == nullptr)
|
||||
{
|
||||
parent->AddDeclaration(GetAddress(), DeclarationAlignment::Align16, GetRawDataSize(),
|
||||
GetSourceTypeName(), name, headerStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
decl->text = headerStr;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ZSkeleton::GetSourceTypeName() const
|
||||
{
|
||||
switch (type)
|
||||
|
@ -168,9 +131,9 @@ ZResourceType ZSkeleton::GetResourceType() const
|
|||
return ZResourceType::Skeleton;
|
||||
}
|
||||
|
||||
segptr_t ZSkeleton::GetAddress()
|
||||
DeclarationAlignment ZSkeleton::GetDeclarationAlignment() const
|
||||
{
|
||||
return rawDataIndex;
|
||||
return DeclarationAlignment::Align16;
|
||||
}
|
||||
|
||||
uint8_t ZSkeleton::GetLimbCount()
|
||||
|
@ -186,14 +149,6 @@ ZLimbTable::ZLimbTable(ZFile* nParent) : ZResource(nParent)
|
|||
RegisterRequiredAttribute("Count");
|
||||
}
|
||||
|
||||
void ZLimbTable::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex)
|
||||
{
|
||||
ZResource::ExtractFromXML(reader, nRawDataIndex);
|
||||
|
||||
parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(),
|
||||
GetSourceTypeName(), name, limbsAddresses.size(), "");
|
||||
}
|
||||
|
||||
void ZLimbTable::ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nLimbType, size_t nCount)
|
||||
{
|
||||
rawDataIndex = nRawDataIndex;
|
||||
|
@ -237,9 +192,9 @@ void ZLimbTable::ParseRawData()
|
|||
|
||||
void ZLimbTable::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
std::string varPrefix = prefix;
|
||||
if (name != "")
|
||||
varPrefix = name;
|
||||
std::string varPrefix = name;
|
||||
if (varPrefix == "")
|
||||
varPrefix = prefix;
|
||||
|
||||
ZResource::DeclareReferences(varPrefix);
|
||||
|
||||
|
@ -252,22 +207,39 @@ void ZLimbTable::DeclareReferences(const std::string& prefix)
|
|||
uint32_t limbOffset = Seg2Filespace(limbAddress, parent->baseAddress);
|
||||
if (!parent->HasDeclaration(limbOffset))
|
||||
{
|
||||
ZLimb* limb = new ZLimb(limbType, varPrefix, limbOffset, parent);
|
||||
ZLimb* limb = new ZLimb(parent);
|
||||
limb->ExtractFromBinary(limbOffset, limbType);
|
||||
limb->SetName(limb->GetDefaultName(varPrefix));
|
||||
limb->DeclareVar(varPrefix, "");
|
||||
limb->DeclareReferences(varPrefix);
|
||||
limb->GetSourceOutputCode(varPrefix);
|
||||
parent->AddResource(limb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Declaration* ZLimbTable::DeclareVar(const std::string& prefix, const std::string& bodyStr)
|
||||
{
|
||||
std::string auxName = name;
|
||||
|
||||
if (name == "")
|
||||
auxName = GetDefaultName(prefix);
|
||||
|
||||
Declaration* decl =
|
||||
parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(),
|
||||
GetSourceTypeName(), auxName, limbsAddresses.size(), bodyStr);
|
||||
decl->staticConf = staticConf;
|
||||
return decl;
|
||||
}
|
||||
|
||||
std::string ZLimbTable::GetBodySourceCode() const
|
||||
{
|
||||
std::string body = "";
|
||||
std::string body;
|
||||
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
std::string limbName = parent->GetDeclarationPtrName(limbsAddresses[i]);
|
||||
std::string limbName;
|
||||
Globals::Instance->GetSegmentedPtrName(limbsAddresses[i], parent, "", limbName);
|
||||
body += StringHelper::Sprintf("\t%s,", limbName.c_str());
|
||||
|
||||
if (i + 1 < count)
|
||||
|
@ -277,20 +249,6 @@ std::string ZLimbTable::GetBodySourceCode() const
|
|||
return body;
|
||||
}
|
||||
|
||||
std::string ZLimbTable::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
std::string body = GetBodySourceCode();
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(rawDataIndex);
|
||||
if (decl == nullptr || decl->isPlaceholder)
|
||||
parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(),
|
||||
GetSourceTypeName(), name, limbsAddresses.size(), body);
|
||||
else
|
||||
decl->text = body;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ZLimbTable::GetSourceTypeName() const
|
||||
{
|
||||
switch (limbType)
|
||||
|
@ -305,6 +263,7 @@ std::string ZLimbTable::GetSourceTypeName() const
|
|||
return StringHelper::Sprintf("%s*", ZLimb::GetSourceTypeName(limbType));
|
||||
|
||||
case ZLimbType::Invalid:
|
||||
// TODO: Proper error message or something.
|
||||
assert("Invalid limb type.\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue