ZAPD Update (#2851)
* git subrepo clone --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/ subrepo: subdir: "ZAPDTR" merged: "6aa54a551" upstream: origin: "C:/ZeldaStuff/ZAPDTR" branch: "rebase2" commit: "6aa54a551" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * git subrepo clone --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/ subrepo: subdir: "ZAPDTR" merged: "88b012240" upstream: origin: "C:/ZeldaStuff/ZAPDTR" branch: "rebase2" commit: "88b012240" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Update (its broken) * fix the enum * git subrepo push --remote=C:/ZeldaStuff/ZAPDTR/ ZAPDTR subrepo: subdir: "ZAPDTR" merged: "b7b6e1c82" upstream: origin: "C:/ZeldaStuff/ZAPDTR/" branch: "rebase2" commit: "b7b6e1c82" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * New names for LUS actions * git subrepo push --remote=C:/ZeldaStuff/ZAPDTR/ ZAPDTR subrepo: subdir: "ZAPDTR" merged: "c5cfebeee" upstream: origin: "C:/ZeldaStuff/ZAPDTR/" branch: "rebase2" commit: "c5cfebeee" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * git subrepo clone (merge) --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/ subrepo: subdir: "ZAPDTR" merged: "d5f4769b8" upstream: origin: "C:/ZeldaStuff/ZAPDTR" branch: "rebase2" commit: "d5f4769b8" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Fix missing commands in the exporter. * Cleanups. * git subrepo pull --force --remote=https://github.com/harbourmasters/ZAPDTR --branch=master ZAPDTR subrepo: subdir: "ZAPDTR" merged: "d4c35b90a" upstream: origin: "https://github.com/harbourmasters/ZAPDTR" branch: "master" commit: "d4c35b90a" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Add unordered_map include to fix MacOS * fix string_view * Update Main.cpp * fix string view * So close I can almost taste it * So close * Fix missed git marker. * Fix surface types and * Update ZFile.cpp * Delete Jenkinsfile --------- Co-authored-by: Christopher Leggett <chris@leggett.dev> Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
This commit is contained in:
@@ -18,11 +18,15 @@ ZTexture::ZTexture(ZFile* nParent) : ZResource(nParent)
|
||||
height = 0;
|
||||
dWordAligned = true;
|
||||
genOTRDef = true;
|
||||
splitTlut = false;
|
||||
|
||||
RegisterRequiredAttribute("Width");
|
||||
RegisterRequiredAttribute("Height");
|
||||
RegisterRequiredAttribute("Format");
|
||||
RegisterOptionalAttribute("TlutOffset");
|
||||
RegisterOptionalAttribute("ExternalTlut");
|
||||
RegisterOptionalAttribute("ExternalTlutOffset");
|
||||
RegisterOptionalAttribute("SplitTlut");
|
||||
}
|
||||
|
||||
void ZTexture::ExtractFromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight,
|
||||
@@ -57,6 +61,7 @@ void ZTexture::ParseXML(tinyxml2::XMLElement* reader)
|
||||
|
||||
std::string widthXml = registeredAttributes.at("Width").value;
|
||||
std::string heightXml = registeredAttributes.at("Height").value;
|
||||
std::string SplitTlutXml = registeredAttributes.at("SplitTlut").value;
|
||||
|
||||
if (!StringHelper::HasOnlyDigits(widthXml))
|
||||
{
|
||||
@@ -73,6 +78,27 @@ void ZTexture::ParseXML(tinyxml2::XMLElement* reader)
|
||||
errorHeader, "");
|
||||
}
|
||||
|
||||
if (!registeredAttributes.at("ExternalTlut").wasSet &&
|
||||
registeredAttributes.at("SplitTlut").wasSet)
|
||||
{
|
||||
std::string errorHeader =
|
||||
StringHelper::Sprintf("SplitTlut set without using an external tlut");
|
||||
HANDLE_WARNING_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex,
|
||||
errorHeader, "");
|
||||
}
|
||||
|
||||
if (!SplitTlutXml.empty())
|
||||
{
|
||||
if (!tinyxml2::XMLUtil::ToBool(SplitTlutXml.c_str(), &splitTlut))
|
||||
{
|
||||
std::string errorHeader = StringHelper::Sprintf(
|
||||
"Invalid value passed to SplitTlut: '%s'. Valid values are true, false, 1, 0",
|
||||
SplitTlutXml.c_str());
|
||||
HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex,
|
||||
errorHeader, "");
|
||||
}
|
||||
}
|
||||
|
||||
width = StringHelper::StrToL(widthXml);
|
||||
height = StringHelper::StrToL(heightXml);
|
||||
|
||||
@@ -146,6 +172,47 @@ void ZTexture::ParseRawData()
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::ParseRawDataLate()
|
||||
{
|
||||
if (registeredAttributes["ExternalTlut"].wasSet)
|
||||
{
|
||||
const std::string externPalette = registeredAttributes["ExternalTlut"].value;
|
||||
for (const auto& file : Globals::Instance->files)
|
||||
{
|
||||
if (file->GetName() == externPalette)
|
||||
{
|
||||
offset_t palOffset = 0;
|
||||
if (registeredAttributes["ExternalTlutOffset"].wasSet)
|
||||
{
|
||||
palOffset =
|
||||
StringHelper::StrToL(registeredAttributes["ExternalTlutOffset"].value, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
HANDLE_WARNING_RESOURCE(
|
||||
WarningType::MissingOffsets, parent, this, rawDataIndex,
|
||||
StringHelper::Sprintf(
|
||||
"No ExternalTlutOffset Given. Assuming offset of 0x0"),
|
||||
"");
|
||||
}
|
||||
for (const auto& res : file->resources)
|
||||
{
|
||||
if (res->GetRawDataIndex() == palOffset)
|
||||
{
|
||||
ZTexture* palette = (ZTexture*)res;
|
||||
ZTexture tlutTemp(file);
|
||||
|
||||
tlut = &tlutTemp;
|
||||
tlut->ExtractFromBinary(palOffset, palette->width, palette->height,
|
||||
TextureType::RGBA16bpp, true);
|
||||
SetTlut(tlut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareBitmapRGBA16()
|
||||
{
|
||||
textureData.InitEmptyRGBImage(width, height, true);
|
||||
@@ -351,34 +418,42 @@ void ZTexture::DeclareReferences([[maybe_unused]] const std::string& prefix)
|
||||
|
||||
void ZTexture::PrepareRawDataFromFile(const fs::path& pngFilePath)
|
||||
{
|
||||
textureData.ReadPng(pngFilePath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case TextureType::RGBA16bpp:
|
||||
PrepareRawDataRGBA16(pngFilePath);
|
||||
PrepareRawDataRGBA16();
|
||||
break;
|
||||
case TextureType::RGBA32bpp:
|
||||
PrepareRawDataRGBA32(pngFilePath);
|
||||
PrepareRawDataRGBA32();
|
||||
break;
|
||||
case TextureType::Grayscale4bpp:
|
||||
PrepareRawDataGrayscale4(pngFilePath);
|
||||
PrepareRawDataGrayscale4();
|
||||
break;
|
||||
case TextureType::Grayscale8bpp:
|
||||
PrepareRawDataGrayscale8(pngFilePath);
|
||||
PrepareRawDataGrayscale8();
|
||||
break;
|
||||
case TextureType::GrayscaleAlpha4bpp:
|
||||
PrepareRawDataGrayscaleAlpha4(pngFilePath);
|
||||
PrepareRawDataGrayscaleAlpha4();
|
||||
break;
|
||||
case TextureType::GrayscaleAlpha8bpp:
|
||||
PrepareRawDataGrayscaleAlpha8(pngFilePath);
|
||||
PrepareRawDataGrayscaleAlpha8();
|
||||
break;
|
||||
case TextureType::GrayscaleAlpha16bpp:
|
||||
PrepareRawDataGrayscaleAlpha16(pngFilePath);
|
||||
PrepareRawDataGrayscaleAlpha16();
|
||||
break;
|
||||
case TextureType::Palette4bpp:
|
||||
PrepareRawDataPalette4(pngFilePath);
|
||||
PrepareRawDataPalette4();
|
||||
break;
|
||||
case TextureType::Palette8bpp:
|
||||
PrepareRawDataPalette8(pngFilePath);
|
||||
PrepareRawDataPalette8();
|
||||
break;
|
||||
case TextureType::Error:
|
||||
HANDLE_ERROR_PROCESS(WarningType::InvalidPNG, "Input PNG file has invalid format type", "");
|
||||
@@ -386,15 +461,8 @@ void ZTexture::PrepareRawDataFromFile(const fs::path& pngFilePath)
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareRawDataRGBA16(const fs::path& rgbaPath)
|
||||
void ZTexture::PrepareRawDataRGBA16()
|
||||
{
|
||||
textureData.ReadPng(rgbaPath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
for (uint16_t y = 0; y < height; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < width; x++)
|
||||
@@ -416,15 +484,8 @@ void ZTexture::PrepareRawDataRGBA16(const fs::path& rgbaPath)
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareRawDataRGBA32(const fs::path& rgbaPath)
|
||||
void ZTexture::PrepareRawDataRGBA32()
|
||||
{
|
||||
textureData.ReadPng(rgbaPath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
for (uint16_t y = 0; y < height; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < width; x++)
|
||||
@@ -440,15 +501,8 @@ void ZTexture::PrepareRawDataRGBA32(const fs::path& rgbaPath)
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareRawDataGrayscale4(const fs::path& grayPath)
|
||||
void ZTexture::PrepareRawDataGrayscale4()
|
||||
{
|
||||
textureData.ReadPng(grayPath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
for (uint16_t y = 0; y < height; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < width; x += 2)
|
||||
@@ -462,15 +516,8 @@ void ZTexture::PrepareRawDataGrayscale4(const fs::path& grayPath)
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareRawDataGrayscale8(const fs::path& grayPath)
|
||||
void ZTexture::PrepareRawDataGrayscale8()
|
||||
{
|
||||
textureData.ReadPng(grayPath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
for (uint16_t y = 0; y < height; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < width; x++)
|
||||
@@ -482,15 +529,8 @@ void ZTexture::PrepareRawDataGrayscale8(const fs::path& grayPath)
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareRawDataGrayscaleAlpha4(const fs::path& grayAlphaPath)
|
||||
void ZTexture::PrepareRawDataGrayscaleAlpha4()
|
||||
{
|
||||
textureData.ReadPng(grayAlphaPath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
for (uint16_t y = 0; y < height; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < width; x += 2)
|
||||
@@ -515,15 +555,8 @@ void ZTexture::PrepareRawDataGrayscaleAlpha4(const fs::path& grayAlphaPath)
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareRawDataGrayscaleAlpha8(const fs::path& grayAlphaPath)
|
||||
void ZTexture::PrepareRawDataGrayscaleAlpha8()
|
||||
{
|
||||
textureData.ReadPng(grayAlphaPath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
for (uint16_t y = 0; y < height; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < width; x++)
|
||||
@@ -539,15 +572,8 @@ void ZTexture::PrepareRawDataGrayscaleAlpha8(const fs::path& grayAlphaPath)
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareRawDataGrayscaleAlpha16(const fs::path& grayAlphaPath)
|
||||
void ZTexture::PrepareRawDataGrayscaleAlpha16()
|
||||
{
|
||||
textureData.ReadPng(grayAlphaPath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
for (uint16_t y = 0; y < height; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < width; x++)
|
||||
@@ -564,15 +590,8 @@ void ZTexture::PrepareRawDataGrayscaleAlpha16(const fs::path& grayAlphaPath)
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareRawDataPalette4(const fs::path& palPath)
|
||||
void ZTexture::PrepareRawDataPalette4()
|
||||
{
|
||||
textureData.ReadPng(palPath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
for (uint16_t y = 0; y < height; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < width; x += 2)
|
||||
@@ -587,15 +606,8 @@ void ZTexture::PrepareRawDataPalette4(const fs::path& palPath)
|
||||
}
|
||||
}
|
||||
|
||||
void ZTexture::PrepareRawDataPalette8(const fs::path& palPath)
|
||||
void ZTexture::PrepareRawDataPalette8()
|
||||
{
|
||||
textureData.ReadPng(palPath);
|
||||
|
||||
width = textureData.GetWidth();
|
||||
height = textureData.GetHeight();
|
||||
|
||||
textureDataRaw.clear();
|
||||
textureDataRaw.resize(GetRawDataSize());
|
||||
for (uint16_t y = 0; y < height; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < width; x++)
|
||||
@@ -728,11 +740,7 @@ void ZTexture::Save(const fs::path& outFolder)
|
||||
if (!Directory::Exists(outPath.string()))
|
||||
Directory::CreateDirectory(outPath.string());
|
||||
|
||||
//#ifdef _MSC_VER
|
||||
fs::path outFileName;
|
||||
//#else
|
||||
//std::filesystem::__cxx11::path outFileName;
|
||||
//#endif
|
||||
|
||||
if (!dWordAligned)
|
||||
outFileName = outPath / (outName + ".u32" + "." + GetExternalExtension() + ".png");
|
||||
@@ -790,9 +798,8 @@ Declaration* ZTexture::DeclareVar(const std::string& prefix,
|
||||
incStr = StringHelper::Sprintf("%s.%s.inc.c", poolEntry->second.path.c_str(),
|
||||
GetExternalExtension().c_str());
|
||||
else
|
||||
incStr =
|
||||
StringHelper::Sprintf("%s.u32.%s.inc.c", poolEntry->second.path.c_str(),
|
||||
GetExternalExtension().c_str());
|
||||
incStr = StringHelper::Sprintf("%s.u32.%s.inc.c", poolEntry->second.path.c_str(),
|
||||
GetExternalExtension().c_str());
|
||||
}
|
||||
}
|
||||
size_t texSizeDivisor = (dWordAligned) ? 8 : 4;
|
||||
@@ -951,7 +958,7 @@ void ZTexture::SetTlut(ZTexture* nTlut)
|
||||
assert(nTlut->isPalette);
|
||||
tlut = nTlut;
|
||||
|
||||
textureData.SetPalette(tlut->textureData);
|
||||
textureData.SetPalette(tlut->textureData, splitTlut ? 128 : 0);
|
||||
}
|
||||
|
||||
bool ZTexture::HasTlut() const
|
||||
|
||||
Reference in New Issue
Block a user