summaryrefslogtreecommitdiff
path: root/ZAPD/ZDisplayList.cpp
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2021-04-13 07:49:30 -0400
committerGitHub <noreply@github.com>2021-04-13 07:49:30 -0400
commit420508d2d872e8653081d95a43bf2ad8f85d894c (patch)
tree9019e0a87ad719c4a3b1e38c61e7b67feebfa63a /ZAPD/ZDisplayList.cpp
parent95bf5fc0080135f20f3ab17082f79b9e539e80a5 (diff)
Refactoring and various features added (#108)
* ZAPD prints out git hash * Refactor: ZResource constructor sets parent always. ZOverlay also no longer a ZResource, since it did not make much sense. * Organized ZResource a bit * A number of bug fixes, cleanup, and feature improvements. * Prepping for legacy dlist disasm * Fixed some merging issues. Fixed compilation issues with MSVC. Added in proper support for legacy display list disassembler. Refactored parts of ZFile. * Merge with upstream * Finished ZFile refactor, and other tidying. * Fixed up merge issues * Minor cleanup * Got rid of libgfxd_win.a * Fixed matching issue * Fixed up a few bugs * Fixed issue with exceptions * Fixed up merge issues with ZPrerender, along with cleaning up some code * Additional cleanup * Fixed merge issues with ZMtx and fixed a bug with ZDisplayList * Fixes based on PR feedback * run clang-format (#7) Signed-off-by: angie <angheloalf95@gmail.com> * Fixed merge issues with Roz's PR * Misc fixes * Fixed MM bug, removed redundant file. * Removed some commented out code Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com> Co-authored-by: Anghelo Carvajal <anghelo.carvajal.14@sansano.usm.cl>
Diffstat (limited to 'ZAPD/ZDisplayList.cpp')
-rw-r--r--ZAPD/ZDisplayList.cpp403
1 files changed, 298 insertions, 105 deletions
diff --git a/ZAPD/ZDisplayList.cpp b/ZAPD/ZDisplayList.cpp
index 5aff360..8938292 100644
--- a/ZAPD/ZDisplayList.cpp
+++ b/ZAPD/ZDisplayList.cpp
@@ -14,7 +14,11 @@
using namespace std;
using namespace tinyxml2;
-ZDisplayList::ZDisplayList() : ZResource()
+REGISTER_ZFILENODE(DList, ZDisplayList);
+
+ZDisplayList* ZDisplayList::Instance;
+
+ZDisplayList::ZDisplayList(ZFile* nParent) : ZResource(nParent)
{
defines = "";
sceneSegName = "";
@@ -40,36 +44,35 @@ ZDisplayList::ZDisplayList() : ZResource()
}
// EXTRACT MODE
-ZDisplayList* ZDisplayList::ExtractFromXML(XMLElement* reader, vector<uint8_t> nRawData,
- int nRawDataIndex, int rawDataSize, string nRelPath)
-{
- ZDisplayList* dList = new ZDisplayList();
-
- dList->ParseXML(reader);
-
- // dList->name = reader->Attribute("Name");
-
- dList->rawData = nRawData;
- dList->rawDataIndex = nRawDataIndex;
- dList->fileData = dList->rawData;
- dList->relativePath = nRelPath;
- dList->rawData = vector<uint8_t>(dList->rawData.data() + dList->rawDataIndex,
- dList->rawData.data() + dList->rawDataIndex + rawDataSize);
- dList->ParseRawData();
-
- return dList;
-}
-
-ZDisplayList* ZDisplayList::BuildFromXML(XMLElement* reader, string inFolder, bool readFile)
+void ZDisplayList::ExtractFromXML(tinyxml2::XMLElement* reader,
+ const std::vector<uint8_t>& nRawData, const int nRawDataIndex,
+ const std::string& nRelPath)
{
- ZDisplayList* dList = new ZDisplayList();
+ rawDataIndex = nRawDataIndex;
+ ParseXML(reader);
- dList->SetName(reader->Attribute("Name"));
- return dList;
+ // name = reader->Attribute("Name");
+ fileData = nRawData;
+ relativePath = nRelPath;
+ int rawDataSize = ZDisplayList::GetDListLength(
+ nRawData, rawDataIndex,
+ Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX);
+ rawData = vector<uint8_t>(nRawData.data() + rawDataIndex,
+ nRawData.data() + rawDataIndex + rawDataSize);
+ ParseRawData();
}
-ZDisplayList::ZDisplayList(vector<uint8_t> nRawData, int nRawDataIndex, int rawDataSize)
- : ZDisplayList()
+// ZDisplayList* ZDisplayList::BuildFromXML(XMLElement* reader, string inFolder, bool readFile)
+//{
+// ZDisplayList* dList = new ZDisplayList();
+//
+// dList->SetName(reader->Attribute("Name"));
+// return dList;
+//}
+
+ZDisplayList::ZDisplayList(vector<uint8_t> nRawData, int nRawDataIndex, int rawDataSize,
+ ZFile* nParent)
+ : ZDisplayList(nParent)
{
fileData = nRawData;
rawDataIndex = nRawDataIndex;
@@ -132,15 +135,11 @@ void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int i, std::s
}
break;
case F3DZEXOpcode::G_VTX:
- {
Opcode_G_VTX(data, i, prefix, line);
- }
- break;
+ break;
case F3DZEXOpcode::G_SETTIMG: // HOTSPOT
- {
Opcode_G_SETTIMG(data, i, prefix, line);
- }
- break;
+ break;
case F3DZEXOpcode::G_GEOMETRYMODE:
{
int cccccc = (data & 0x00FFFFFF00000000) >> 32;
@@ -278,10 +277,10 @@ void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int i, std::s
sprintf(line, "gsSPBranchLessZraw(%sDlist0x%06X, 0x%02X, 0x%02X),", prefix.c_str(),
h & 0x00FFFFFF, (a / 5) | (b / 2), z);
- ZDisplayList* nList = new ZDisplayList(
- fileData, h & 0x00FFFFFF, GetDListLength(fileData, h & 0x00FFFFFF, dListType));
+ ZDisplayList* nList =
+ new ZDisplayList(fileData, h & 0x00FFFFFF,
+ GetDListLength(fileData, h & 0x00FFFFFF, dListType), parent);
nList->scene = scene;
- nList->parent = parent;
otherDLists.push_back(nList);
i++;
@@ -725,12 +724,9 @@ void ZDisplayList::Opcode_G_DL(uint64_t data, int i, std::string prefix, char* l
sprintf(line, "gsSPDisplayList(%sDlist0x%06lX),", prefix.c_str(), GETSEGOFFSET(data));
}
- // TODO: This is the same as `segNum`. Consider resuing that variable instead of making a new
- // one.
- int segmentNumber = GETSEGNUM(data);
-
- if (segmentNumber == 8 || segmentNumber == 9 || segmentNumber == 10 || segmentNumber == 11 ||
- segmentNumber == 12 || segmentNumber == 13) // Used for runtime-generated display lists
+ // if (segNum == 8 || segNum == 9 || segNum == 10 || segNum == 11 || segNum == 12 || segNum ==
+ // 13) // Used for runtime-generated display lists
+ if (!Globals::Instance->HasSegment(segNum))
{
if (pp != 0)
sprintf(line, "gsSPBranchList(0x%08lX),", data & 0xFFFFFFFF);
@@ -739,11 +735,20 @@ void ZDisplayList::Opcode_G_DL(uint64_t data, int i, std::string prefix, char* l
}
else
{
- ZDisplayList* nList = new ZDisplayList(
- fileData, data & 0x00FFFFFF, GetDListLength(fileData, data & 0x00FFFFFF, dListType));
- nList->scene = scene;
- nList->parent = parent;
- otherDLists.push_back(nList);
+ ZDisplayList* nList =
+ new ZDisplayList(fileData, GETSEGOFFSET(data),
+ GetDListLength(fileData, GETSEGOFFSET(data), dListType), parent);
+
+ // if (scene != nullptr)
+ {
+ nList->scene = scene;
+ otherDLists.push_back(nList);
+ }
+ // else
+ //{
+ // nList->SetName(StringHelper::Sprintf("%sDlist0x%06lX", prefix.c_str(),
+ // SEG2FILESPACE(data))); nList->GetSourceOutputCode(prefix);
+ //}
}
}
@@ -1596,7 +1601,7 @@ static int GfxdCallback_FormatSingleEntry(void)
static int GfxdCallback_Vtx(uint32_t seg, int32_t count)
{
- ZDisplayList* instance = ZDisplayList::static_instance;
+ ZDisplayList* instance = ZDisplayList::Instance;
uint32_t vtxOffset = Seg2Filespace(seg, instance->parent->baseAddress);
string vtxName = "";
@@ -1661,7 +1666,7 @@ static int GfxdCallback_Vtx(uint32_t seg, int32_t count)
static int GfxdCallback_Texture(uint32_t seg, int32_t fmt, int32_t siz, int32_t width,
int32_t height, int32_t pal)
{
- ZDisplayList* instance = ZDisplayList::static_instance;
+ ZDisplayList* instance = ZDisplayList::Instance;
uint32_t texOffset = Seg2Filespace(seg, instance->parent->baseAddress);
uint32_t texSegNum = GETSEGNUM(seg);
Declaration* texDecl = nullptr;
@@ -1705,7 +1710,7 @@ static int GfxdCallback_Texture(uint32_t seg, int32_t fmt, int32_t siz, int32_t
static int GfxdCallback_Palette(uint32_t seg, int32_t idx, int32_t count)
{
- ZDisplayList* instance = ZDisplayList::static_instance;
+ ZDisplayList* instance = ZDisplayList::Instance;
uint32_t palOffset = Seg2Filespace(seg, instance->parent->baseAddress);
uint32_t palSegNum = GETSEGNUM(seg);
Declaration* palDecl = nullptr;
@@ -1749,7 +1754,7 @@ static int GfxdCallback_Palette(uint32_t seg, int32_t idx, int32_t count)
static int GfxdCallback_DisplayList(uint32_t seg)
{
- ZDisplayList* instance = ZDisplayList::static_instance;
+ ZDisplayList* instance = ZDisplayList::Instance;
uint32_t dListOffset = GETSEGOFFSET(seg);
uint32_t dListSegNum = GETSEGNUM(seg);
Declaration* dListDecl = nullptr;
@@ -1770,7 +1775,8 @@ static int GfxdCallback_DisplayList(uint32_t seg)
{
ZDisplayList* newDList = new ZDisplayList(
instance->fileData, dListOffset,
- instance->GetDListLength(instance->fileData, dListOffset, instance->dListType));
+ instance->GetDListLength(instance->fileData, dListOffset, instance->dListType),
+ instance->parent);
newDList->scene = instance->scene;
newDList->parent = instance->parent;
instance->otherDLists.push_back(newDList);
@@ -1784,7 +1790,7 @@ static int GfxdCallback_DisplayList(uint32_t seg)
static int GfxdCallback_Matrix(uint32_t seg)
{
string mtxName = "";
- ZDisplayList* instance = ZDisplayList::static_instance;
+ ZDisplayList* instance = ZDisplayList::Instance;
if (Globals::Instance->symbolMap.find(seg) != Globals::Instance->symbolMap.end())
mtxName = StringHelper::Sprintf("&%s", Globals::Instance->symbolMap[seg].c_str());
@@ -1796,6 +1802,7 @@ static int GfxdCallback_Matrix(uint32_t seg)
{
ZMtx mtx(instance->GetName(), instance->fileData,
Seg2Filespace(seg, instance->parent->baseAddress), instance->parent);
+
mtx.GetSourceOutputCode(instance->GetName());
instance->mtxList.push_back(mtx);
mtxName = "&" + mtx.GetName();
@@ -1813,42 +1820,14 @@ static int GfxdCallback_Matrix(uint32_t seg)
return 1;
}
-ZDisplayList* ZDisplayList::static_instance;
-
string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
{
- OutputFormatter outputformatter;
string sourceOutput = "";
- size_t dListSize = instructions.size() * sizeof(instructions[0]);
-
- gfxd_input_buffer(instructions.data(), dListSize);
- gfxd_endian(gfxd_endian_little, sizeof(uint64_t)); // tell gfxdis what format the data is
-
- gfxd_macro_fn(GfxdCallback_FormatSingleEntry); // format for each command entry
- gfxd_vtx_callback(GfxdCallback_Vtx); // handle vertices
- gfxd_timg_callback(GfxdCallback_Texture); // handle textures
- gfxd_tlut_callback(GfxdCallback_Palette); // handle palettes
- gfxd_dl_callback(GfxdCallback_DisplayList); // handle child display lists
- gfxd_mtx_callback(GfxdCallback_Matrix); // handle matrices
- gfxd_output_callback(
- outputformatter.static_writer()); // convert tabs to 4 spaces and enforce 120 line limit
-
- gfxd_enable(gfxd_emit_dec_color); // use decimal for colors
- // set microcode. see gfxd.h for more options.
- if (dListType == DListType::F3DZEX)
- {
- gfxd_target(gfxd_f3dex2);
- }
+ if (Globals::Instance->useLegacyZDList)
+ sourceOutput += ProcessLegacy(prefix);
else
- {
- gfxd_target(gfxd_f3dex);
- }
-
- this->curPrefix = prefix;
- static_instance = this;
- gfxd_execute(); // generate display list
- sourceOutput += outputformatter.get_output(); // write formatted display list
+ sourceOutput += ProcessGfxDis(prefix);
// Iterate through our vertex lists, connect intersecting lists.
if (vertices.size() > 0)
@@ -2011,19 +1990,31 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
{
if (parent->GetDeclaration(item.first) == nullptr)
{
- if (Globals::Instance->verbosity >= VERBOSITY_DEBUG)
- printf("SAVING IMAGE TO %s\n", Globals::Instance->outputPath.c_str());
-
+ auto start = chrono::steady_clock::now();
item.second->Save(Globals::Instance->outputPath);
+ auto end = chrono::steady_clock::now();
+ auto diff = chrono::duration_cast<chrono::milliseconds>(end - start).count();
+
+ if (Globals::Instance->verbosity >= VERBOSITY_DEBUG)
+ printf("SAVED IMAGE TO %s in %ims\n", Globals::Instance->outputPath.c_str(),
+ (int)diff);
+
+ std::string incStr = StringHelper::Sprintf(
+ "%s/%s.%s.inc.c", Globals::Instance->outputPath.c_str(),
+ Path::GetFileNameWithoutExtension(item.second->GetName()).c_str(),
+ item.second->GetExternalExtension().c_str());
+ std::string texName =
+ StringHelper::Sprintf("%sTex_%06X", prefix.c_str(), item.first);
+
+ if (Globals::Instance->cfg->texturePool.find(item.second->hash) !=
+ Globals::Instance->cfg->texturePool.end())
+ {
+ incStr = Globals::Instance->cfg->texturePool[item.second->hash];
+ texName = Path::GetFileNameWithoutExtension(incStr);
+ }
parent->AddDeclarationIncludeArray(
- item.first,
- StringHelper::Sprintf(
- "%s/%s.%s.inc.c", Globals::Instance->outputPath.c_str(),
- Path::GetFileNameWithoutExtension(item.second->GetName()).c_str(),
- item.second->GetExternalExtension().c_str()),
- item.second->GetRawDataSize(), "u64",
- StringHelper::Sprintf("%sTex_%06X", prefix.c_str(), item.first), 0);
+ item.first, incStr, item.second->GetRawDataSize(), "u64", texName, 0);
}
}
}
@@ -2033,15 +2024,194 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
{
Declaration* decl = parent->AddDeclarationArray(
rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), "Gfx",
- StringHelper::Sprintf("%s", name.c_str()), 0, sourceOutput);
+ StringHelper::Sprintf("%s", name.c_str()), 0, sourceOutput, true);
decl->references = references;
+ // return "";
+ // return sourceOutput;
+ }
+
+ // Iterate through our vertex lists, connect intersecting lists.
+ if (vertices.size() > 0)
+ {
+ vector<pair<int32_t, vector<Vertex>>> verticesSorted(vertices.begin(), vertices.end());
+
+ sort(verticesSorted.begin(), verticesSorted.end(),
+ [](const auto& lhs, const auto& rhs) { return lhs.first < rhs.first; });
+
+ for (int i = 0; i < verticesSorted.size() - 1; i++)
+ {
+ // int vtxSize = verticesSorted[i].second.size() * 16;
+ int vtxSize = (int)vertices[verticesSorted[i].first].size() * 16;
+
+ if ((verticesSorted[i].first + vtxSize) > verticesSorted[i + 1].first)
+ {
+ int intersectAmt =
+ (verticesSorted[i].first + vtxSize) - verticesSorted[i + 1].first;
+ int intersectIndex = intersectAmt / 16;
+
+ for (int j = intersectIndex; j < verticesSorted[i + 1].second.size(); j++)
+ vertices[verticesSorted[i].first].push_back(verticesSorted[i + 1].second[j]);
+
+ int nSize = (int)vertices[verticesSorted[i].first].size();
+
+ vertices.erase(verticesSorted[i + 1].first);
+ verticesSorted.erase(verticesSorted.begin() + i + 1);
+
+ i--;
+ }
+ }
+
+ if (scene == nullptr) // TODO: Bit of a hack but it works for now...
+ parent->defines += defines;
+
+ // Generate Vertex Declarations
+ vector<int32_t> vtxKeys;
+
+ for (pair<int32_t, vector<Vertex>> item : vertices)
+ vtxKeys.push_back(item.first);
+
+ // for (pair<int32_t, vector<Vertex>> item : vertices)
+ for (int i = 0; i < vtxKeys.size(); i++)
+ {
+ vector<Vertex> item = vertices[vtxKeys[i]];
+
+ // if (i < vtxKeys.size() - 1)
+ //{
+ // vector<Vertex> nextItem = vertices[vtxKeys[i + 1]];
+
+ // int endAddr = (vtxKeys[i] + (item.size() * 16));
+ // if (endAddr != vtxKeys[i + 1] && parent->GetDeclarationRanged(endAddr) == nullptr)
+ // {
+ // for (Vertex vtx : nextItem)
+ // {
+ // item.push_back(vtx);
+ // }
+
+ // vtxKeys.erase(vtxKeys.begin() + (i + 1));
+ // vertices.erase(vertices.begin() + (i + 1));
+ // //i--;
+ // }
+ //}
+
+ string declaration = "";
+
+ int curAddr = vtxKeys[i];
+
+ for (Vertex vtx : item)
+ {
+ if (curAddr != vtxKeys[i])
+ declaration += "\n";
+
+ declaration +=
+ StringHelper::Sprintf(" VTX(%i, %i, %i, %i, %i, %i, %i, %i, %i),", vtx.x,
+ vtx.y, vtx.z, vtx.s, vtx.t, vtx.r, vtx.g, vtx.b, vtx.a);
+
+ curAddr += 16;
+ }
+
+ vtxDeclarations[vtxKeys[i]] = declaration;
+
+ if (parent != nullptr)
+ {
+ std::string vtxName =
+ StringHelper::Sprintf("%sVtx_%06X", prefix.c_str(), vtxKeys[i]);
+ std::string incStr = StringHelper::Sprintf(
+ "%s/%s.%s.inc", Globals::Instance->outputPath.c_str(), vtxName.c_str(), "vtx");
+ parent->AddDeclarationArray(vtxKeys[i], DeclarationAlignment::None,
+ item.size() * 16, "static Vtx", vtxName, item.size(),
+ declaration);
+
+ Declaration* vtxDecl = parent->AddDeclarationIncludeArray(
+ vtxKeys[i], incStr, item.size() * 16, "static Vtx", vtxName, item.size());
+ vtxDecl->isExternal = true;
+ }
+ }
+ }
+
+ if (parent != nullptr)
return "";
+
+ return sourceOutput;
+}
+
+std::string ZDisplayList::ProcessLegacy(const std::string& prefix)
+{
+ char line[4096];
+ string sourceOutput = "";
+
+ for (int i = 0; i < instructions.size(); i++)
+ {
+ uint8_t opcode = (uint8_t)(instructions[i] >> 56);
+ uint64_t data = instructions[i];
+ sourceOutput += " ";
+
+ auto start = chrono::steady_clock::now();
+
+ int optimizationResult = OptimizationChecks(i, sourceOutput, prefix);
+
+ if (optimizationResult != -1)
+ {
+ i += optimizationResult - 1;
+ line[0] = '\0';
+ }
+ else
+ {
+ if (dListType == DListType::F3DZEX)
+ ParseF3DZEX((F3DZEXOpcode)opcode, data, i, prefix, line);
+ else
+ ParseF3DEX((F3DEXOpcode)opcode, data, i, prefix, line);
+ }
+
+ auto end = chrono::steady_clock::now();
+ auto diff = chrono::duration_cast<chrono::milliseconds>(end - start).count();
+
+ if (Globals::Instance->verbosity >= VERBOSITY_DEBUG && diff > 5)
+ printf("F3DOP: 0x%02X, TIME: %lims\n", opcode, diff);
+
+ sourceOutput += line;
+
+ if (i < instructions.size() - 1)
+ sourceOutput += "\n";
}
return sourceOutput;
}
-// HOTSPOT
+std::string ZDisplayList::ProcessGfxDis(const std::string& prefix)
+{
+ string sourceOutput = "";
+
+ OutputFormatter outputformatter;
+ int dListSize = instructions.size() * sizeof(instructions[0]);
+
+ gfxd_input_buffer(instructions.data(), dListSize);
+ gfxd_endian(gfxd_endian_little, sizeof(uint64_t)); // tell gfxdis what format the data is
+
+ gfxd_macro_fn(GfxdCallback_FormatSingleEntry); // format for each command entry
+ gfxd_vtx_callback(GfxdCallback_Vtx); // handle vertices
+ gfxd_timg_callback(GfxdCallback_Texture); // handle textures
+ gfxd_tlut_callback(GfxdCallback_Palette); // handle palettes
+ gfxd_dl_callback(GfxdCallback_DisplayList); // handle child display lists
+ gfxd_mtx_callback(GfxdCallback_Matrix); // handle matrices
+ gfxd_output_callback(
+ outputformatter.StaticWriter()); // convert tabs to 4 spaces and enforce 120 line limit
+
+ gfxd_enable(gfxd_emit_dec_color); // use decimal for colors
+
+ // set microcode. see gfxd.h for more options.
+ if (dListType == DListType::F3DZEX)
+ gfxd_target(gfxd_f3dex2);
+ else
+ gfxd_target(gfxd_f3dex);
+
+ this->curPrefix = prefix;
+ Instance = this;
+ gfxd_execute(); // generate display list
+ sourceOutput += outputformatter.GetOutput(); // write formatted display list
+
+ return sourceOutput;
+}
+
void ZDisplayList::TextureGenCheck(string prefix)
{
if (TextureGenCheck(fileData, textures, scene, parent, prefix, lastTexWidth, lastTexHeight,
@@ -2054,7 +2224,6 @@ void ZDisplayList::TextureGenCheck(string prefix)
}
}
-// HOTSPOT
bool ZDisplayList::TextureGenCheck(vector<uint8_t> fileData, map<uint32_t, ZTexture*>& textures,
ZRoom* scene, ZFile* parent, string prefix, int32_t texWidth,
int32_t texHeight, uint32_t texAddr, uint32_t texSeg,
@@ -2070,11 +2239,12 @@ bool ZDisplayList::TextureGenCheck(vector<uint8_t> fileData, map<uint32_t, ZText
if ((texSeg != 0 || texAddr != 0) && texWidth > 0 && texHeight > 0 && texLoaded &&
Globals::Instance->HasSegment(segmentNumber))
{
- if (segmentNumber != 2) // Not from a scene file
+ if (segmentNumber != SEGMENT_SCENE)
{
- ZTexture* tex = ZTexture::FromBinary(
- TexFormatToTexType(texFmt, texSiz), fileData, texAddr,
- StringHelper::Sprintf("%sTex_%06X", prefix.c_str(), texAddr), texWidth, texHeight);
+ ZTexture* tex =
+ ZTexture::FromBinary(TexFormatToTexType(texFmt, texSiz), fileData, texAddr,
+ StringHelper::Sprintf("%sTex_%06X", prefix.c_str(), texAddr),
+ texWidth, texHeight, parent);
tex->isPalette = texIsPalette;
textures[texAddr] = tex;
@@ -2086,7 +2256,7 @@ bool ZDisplayList::TextureGenCheck(vector<uint8_t> fileData, map<uint32_t, ZText
TexFormatToTexType(texFmt, texSiz), scene->GetRawData(), texAddr,
StringHelper::Sprintf("%sTex_%06X", Globals::Instance->lastScene->GetName().c_str(),
texAddr),
- texWidth, texHeight);
+ texWidth, texHeight, parent);
if (scene != nullptr)
{
@@ -2120,10 +2290,15 @@ TextureType ZDisplayList::TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSize
}
else if (fmt == F3DZEXTexFormats::G_IM_FMT_CI)
{
- if (siz == F3DZEXTexSizes::G_IM_SIZ_4b)
- return TextureType::Palette4bpp;
- else if (siz == F3DZEXTexSizes::G_IM_SIZ_8b)
+ if (Globals::Instance->useLegacyZDList)
return TextureType::Palette8bpp;
+ else
+ {
+ if (siz == F3DZEXTexSizes::G_IM_SIZ_4b)
+ return TextureType::Palette4bpp;
+ else if (siz == F3DZEXTexSizes::G_IM_SIZ_8b)
+ return TextureType::Palette8bpp;
+ }
}
else if (fmt == F3DZEXTexFormats::G_IM_FMT_IA)
{
@@ -2149,6 +2324,9 @@ TextureType ZDisplayList::TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSize
void ZDisplayList::Save(const std::string& outFolder)
{
+ // File::WriteAllText(StringHelper::Sprintf("%s/%s.%s.inc.c", outFolder.c_str(), name.c_str(),
+ // GetExternalExtension().c_str()), GetSourceOutputCode(""));
+
// HLModelIntermediette* mdl = HLModelIntermediette::FromZDisplayList(this);
// For testing purposes only at the moment...
@@ -2171,6 +2349,21 @@ void ZDisplayList::GenerateHLIntermediette(HLFileIntermediette& hlFile)
mdl->blocks.push_back(new HLTerminator());
}
+bool ZDisplayList::IsExternalResource()
+{
+ return false;
+}
+
+std::string ZDisplayList::GetExternalExtension()
+{
+ return "dlist";
+}
+
+std::string ZDisplayList::GetSourceTypeName()
+{
+ return "Gfx";
+}
+
ZResourceType ZDisplayList::GetResourceType()
{
return ZResourceType::DisplayList;