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,12 +1,13 @@
|
|||
#include "ZTexture.h"
|
||||
|
||||
#include <cassert>
|
||||
#include "BitConverter.h"
|
||||
|
||||
#include "CRC32.h"
|
||||
#include "Directory.h"
|
||||
#include "File.h"
|
||||
#include "Globals.h"
|
||||
#include "Path.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/Directory.h"
|
||||
#include "Utils/File.h"
|
||||
#include "Utils/Path.h"
|
||||
|
||||
REGISTER_ZFILENODE(Texture, ZTexture);
|
||||
|
||||
|
@ -21,21 +22,8 @@ ZTexture::ZTexture(ZFile* nParent) : ZResource(nParent)
|
|||
RegisterOptionalAttribute("TlutOffset");
|
||||
}
|
||||
|
||||
void ZTexture::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex)
|
||||
{
|
||||
ZResource::ExtractFromXML(reader, nRawDataIndex);
|
||||
|
||||
auto filepath = Globals::Instance->outputPath / fs::path(name).stem();
|
||||
|
||||
std::string incStr =
|
||||
StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(), GetExternalExtension().c_str());
|
||||
|
||||
parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), GetSourceTypeName(),
|
||||
name, 0);
|
||||
}
|
||||
|
||||
void ZTexture::FromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight,
|
||||
TextureType nType, bool nIsPalette)
|
||||
void ZTexture::ExtractFromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight,
|
||||
TextureType nType, bool nIsPalette)
|
||||
{
|
||||
width = nWidth;
|
||||
height = nHeight;
|
||||
|
@ -45,6 +33,10 @@ void ZTexture::FromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeigh
|
|||
name = GetDefaultName(parent->GetName());
|
||||
outName = name;
|
||||
|
||||
// Don't parse raw data of external files
|
||||
if (parent->GetMode() == ZFileMode::ExternalFile)
|
||||
return;
|
||||
|
||||
ParseRawData();
|
||||
CalcHash();
|
||||
}
|
||||
|
@ -52,17 +44,10 @@ void ZTexture::FromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeigh
|
|||
void ZTexture::FromPNG(const fs::path& pngFilePath, TextureType texType)
|
||||
{
|
||||
format = texType;
|
||||
name = StringHelper::Split(Path::GetFileNameWithoutExtension(pngFilePath), ".")[0];
|
||||
name = StringHelper::Split(Path::GetFileNameWithoutExtension(pngFilePath.string()), ".")[0];
|
||||
PrepareRawDataFromFile(pngFilePath);
|
||||
}
|
||||
|
||||
void ZTexture::FromHLTexture(HLTexture* hlTex)
|
||||
{
|
||||
width = hlTex->width;
|
||||
height = hlTex->height;
|
||||
format = static_cast<TextureType>(hlTex->type);
|
||||
}
|
||||
|
||||
void ZTexture::ParseXML(tinyxml2::XMLElement* reader)
|
||||
{
|
||||
ZResource::ParseXML(reader);
|
||||
|
@ -116,6 +101,12 @@ void ZTexture::ParseXML(tinyxml2::XMLElement* reader)
|
|||
|
||||
void ZTexture::ParseRawData()
|
||||
{
|
||||
if (rawDataIndex % 8 != 0)
|
||||
fprintf(stderr,
|
||||
"ZTexture::ParseXML: Warning in '%s'.\n"
|
||||
"\t This texture is not 64-bit aligned.\n",
|
||||
name.c_str());
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case TextureType::RGBA16bpp:
|
||||
|
@ -329,7 +320,7 @@ void ZTexture::PrepareBitmapPalette8()
|
|||
}
|
||||
}
|
||||
|
||||
void ZTexture::DeclareReferences(const std::string& prefix)
|
||||
void ZTexture::DeclareReferences([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (tlutOffset != static_cast<uint32_t>(-1))
|
||||
{
|
||||
|
@ -340,15 +331,10 @@ void ZTexture::DeclareReferences(const std::string& prefix)
|
|||
if (format == TextureType::Palette4bpp)
|
||||
tlutDim = 4;
|
||||
|
||||
auto filepath = Globals::Instance->outputPath / fs::path(name).stem();
|
||||
std::string incStr = StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(),
|
||||
GetExternalExtension().c_str());
|
||||
|
||||
tlut = new ZTexture(parent);
|
||||
tlut->FromBinary(tlutOffset, tlutDim, tlutDim, TextureType::RGBA16bpp, true);
|
||||
tlut->ExtractFromBinary(tlutOffset, tlutDim, tlutDim, TextureType::RGBA16bpp, true);
|
||||
parent->AddTextureResource(tlutOffset, tlut);
|
||||
parent->AddDeclarationIncludeArray(tlutOffset, incStr, tlut->GetRawDataSize(),
|
||||
tlut->GetSourceTypeName(), tlut->GetName(), 0);
|
||||
tlut->DeclareVar(prefix, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -686,7 +672,7 @@ std::string ZTexture::GetIMSizFromType()
|
|||
}
|
||||
}
|
||||
|
||||
std::string ZTexture::GetDefaultName(const std::string& prefix)
|
||||
std::string ZTexture::GetDefaultName(const std::string& prefix) const
|
||||
{
|
||||
const char* suffix = "Tex";
|
||||
if (isPalette)
|
||||
|
@ -722,14 +708,14 @@ void ZTexture::Save(const fs::path& outFolder)
|
|||
// process for generating the Texture Pool XML.
|
||||
if (Globals::Instance->outputCrc)
|
||||
{
|
||||
File::WriteAllText(Globals::Instance->outputPath / (outName + ".txt"),
|
||||
File::WriteAllText((Globals::Instance->outputPath / (outName + ".txt")).string(),
|
||||
StringHelper::Sprintf("%08lX", hash));
|
||||
}
|
||||
|
||||
auto outPath = GetPoolOutPath(outFolder);
|
||||
|
||||
if (!Directory::Exists(outPath))
|
||||
Directory::CreateDirectory(outPath);
|
||||
if (!Directory::Exists(outPath.string()))
|
||||
Directory::CreateDirectory(outPath.string());
|
||||
|
||||
auto outFileName = outPath / (outName + "." + GetExternalExtension() + ".png");
|
||||
|
||||
|
@ -747,9 +733,45 @@ void ZTexture::Save(const fs::path& outFolder)
|
|||
#endif
|
||||
}
|
||||
|
||||
Declaration* ZTexture::DeclareVar(const std::string& prefix,
|
||||
[[maybe_unused]] const std::string& bodyStr)
|
||||
{
|
||||
std::string auxName = name;
|
||||
std::string auxOutName = outName;
|
||||
|
||||
if (auxName == "")
|
||||
auxName = GetDefaultName(prefix);
|
||||
|
||||
if (auxOutName == "")
|
||||
auxOutName = GetDefaultName(prefix);
|
||||
|
||||
auto filepath = Globals::Instance->outputPath / fs::path(auxOutName).stem();
|
||||
|
||||
std::string incStr =
|
||||
StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(), GetExternalExtension().c_str());
|
||||
|
||||
if (!Globals::Instance->cfg.texturePool.empty())
|
||||
{
|
||||
CalcHash();
|
||||
|
||||
// TEXTURE POOL CHECK
|
||||
const auto& poolEntry = Globals::Instance->cfg.texturePool.find(hash);
|
||||
if (poolEntry != Globals::Instance->cfg.texturePool.end())
|
||||
{
|
||||
incStr = StringHelper::Sprintf("%s.%s.inc.c", poolEntry->second.path.c_str(),
|
||||
GetExternalExtension().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Declaration* decl = parent->AddDeclarationIncludeArray(
|
||||
rawDataIndex, incStr, GetRawDataSize(), GetSourceTypeName(), auxName, GetRawDataSize() / 8);
|
||||
decl->staticConf = staticConf;
|
||||
return decl;
|
||||
}
|
||||
|
||||
std::string ZTexture::GetBodySourceCode() const
|
||||
{
|
||||
std::string sourceOutput = "";
|
||||
std::string sourceOutput;
|
||||
|
||||
for (size_t i = 0; i < textureDataRaw.size(); i += 8)
|
||||
{
|
||||
|
@ -827,7 +849,7 @@ fs::path ZTexture::GetPoolOutPath(const fs::path& defaultValue)
|
|||
return defaultValue;
|
||||
}
|
||||
|
||||
TextureType ZTexture::GetTextureTypeFromString(std::string str)
|
||||
TextureType ZTexture::GetTextureTypeFromString(const std::string& str)
|
||||
{
|
||||
TextureType texType = TextureType::Error;
|
||||
|
||||
|
@ -839,11 +861,11 @@ TextureType ZTexture::GetTextureTypeFromString(std::string str)
|
|||
{
|
||||
texType = TextureType::RGBA16bpp;
|
||||
#ifdef DEPRECATION_ON
|
||||
fprintf(stderr,
|
||||
"ZTexture::GetTextureTypeFromString: Deprecation warning.\n"
|
||||
"\t The texture format 'rgb5a1' is currently deprecated, and will be removed in a future "
|
||||
"version.\n"
|
||||
"\t Use the format 'rgba16' instead.\n");
|
||||
fprintf(stderr, "ZTexture::GetTextureTypeFromString: Deprecation warning.\n"
|
||||
"\t The texture format 'rgb5a1' is currently deprecated, and will be "
|
||||
"removed in a future "
|
||||
"version.\n"
|
||||
"\t Use the format 'rgba16' instead.\n");
|
||||
#endif
|
||||
}
|
||||
else if (str == "i4")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue