1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-16 20:10:28 +00:00
oot/tools/ZAPD/ZAPD/ZMtx.cpp
Anghelo Carvajal 5c147e5e03
ZAPD update: Gotta go fast! (#877)
* copy over the xml

* Rename anims

* A bunch of renames

* minor extract_assets fixes

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "820678b4e"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "820678b4e"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Change rgb5a1 to rgba16

* eye and eyebrows

* some dlists

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "6be9af65d"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "6be9af65d"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
2021-07-27 22:16:03 -04:00

95 lines
1.9 KiB
C++

#include "ZMtx.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "ZFile.h"
REGISTER_ZFILENODE(Mtx, ZMtx);
ZMtx::ZMtx(ZFile* nParent) : ZResource(nParent)
{
}
ZMtx::ZMtx(const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent) : ZResource(nParent)
{
name = GetDefaultName(prefix.c_str(), rawDataIndex);
ExtractFromFile(nRawDataIndex);
DeclareVar("", "");
}
void ZMtx::ParseRawData()
{
ZResource::ParseRawData();
const auto& rawData = parent->GetRawData();
for (size_t i = 0; i < 4; ++i)
for (size_t j = 0; j < 4; ++j)
mtx[i][j] = BitConverter::ToInt32BE(rawData, rawDataIndex + (i * 4 + j) * 4);
}
void ZMtx::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex)
{
ZResource::ExtractFromXML(reader, nRawDataIndex);
DeclareVar("", "");
}
size_t ZMtx::GetRawDataSize() const
{
return 64;
}
void ZMtx::DeclareVar(const std::string& prefix, const std::string& bodyStr) const
{
std::string auxName = name;
if (name == "")
auxName = GetDefaultName(prefix, rawDataIndex);
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align8, GetRawDataSize(),
GetSourceTypeName(), auxName, bodyStr);
}
std::string ZMtx::GetBodySourceCode()
{
std::string bodyStr = "\n";
for (const auto& row : mtx)
{
bodyStr += " ";
for (int32_t val : row)
bodyStr += StringHelper::Sprintf("%-11i, ", val);
bodyStr += "\n";
}
return bodyStr;
}
std::string ZMtx::GetSourceOutputCode(const std::string& prefix)
{
std::string bodyStr = GetBodySourceCode();
Declaration* decl = parent->GetDeclaration(rawDataIndex);
if (decl == nullptr)
DeclareVar(prefix, bodyStr);
else
decl->text = bodyStr;
return "";
}
std::string ZMtx::GetDefaultName(const std::string& prefix, uint32_t address)
{
return StringHelper::Sprintf("%sMtx_%06X", prefix.c_str(), address);
}
std::string ZMtx::GetSourceTypeName() const
{
return "Mtx";
}
ZResourceType ZMtx::GetResourceType() const
{
return ZResourceType::Mtx;
}