mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 06:24:30 +00:00
Actor Struct Changes (and a few related things) (#617)
* reformat header * type -> category * done for now i think * some more stuff * first -> head * focus * flag comment * ground -> floor * remove asm, name wrapper funcs * name func, format * review * targetPriority, format * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "0305ec2c2" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "0305ec2c2" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * comment * review * feet flags * horse shadow
This commit is contained in:
parent
20206fba0d
commit
00a5edea71
697 changed files with 8157 additions and 7942 deletions
|
@ -6,7 +6,7 @@
|
|||
[subrepo]
|
||||
remote = https://github.com/zeldaret/ZAPD.git
|
||||
branch = master
|
||||
commit = 6e6ad445a69089b721bea75f6e43b23b14a553b6
|
||||
parent = cf6d96f133d98c6b69066c5ff195dc8a4d029444
|
||||
commit = 0305ec2c27412557fe831cc8ce23b7d8649809fa
|
||||
parent = db66460dbb2522a1a9822582f8b7d5205415af93
|
||||
method = merge
|
||||
cmdver = 0.4.3
|
||||
|
|
|
@ -24,23 +24,23 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix, con
|
|||
absMaxZ = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
|
||||
numVerts = BitConverter::ToInt16BE(data, rawDataIndex + 12);
|
||||
vtxSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 16) & 0x00FFFFFF;
|
||||
vtxSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 16);
|
||||
|
||||
numPolygons = BitConverter::ToInt16BE(data, rawDataIndex + 20);
|
||||
polySegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 24) & 0x00FFFFFF;
|
||||
polyTypeDefSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 28) & 0x00FFFFFF;
|
||||
camDataSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 32) & 0x00FFFFFF;
|
||||
polySegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 24);
|
||||
polyTypeDefSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 28);
|
||||
camDataSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 32);
|
||||
|
||||
numWaterBoxes = BitConverter::ToInt16BE(data, rawDataIndex + 36);
|
||||
waterBoxSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 40) & 0x00FFFFFF;
|
||||
|
||||
// HOTSPOT
|
||||
for (int i = 0; i < numVerts; i++)
|
||||
vertices.push_back(new VertexEntry(rawData, vtxSegmentOffset + (i * 6)));
|
||||
vertices.push_back(new VertexEntry(rawData, SEG2FILESPACE(vtxSegmentOffset) + (i * 6)));
|
||||
|
||||
// HOTSPOT
|
||||
for (int i = 0; i < numPolygons; i++)
|
||||
polygons.push_back(new PolygonEntry(rawData, polySegmentOffset + (i * 16)));
|
||||
polygons.push_back(new PolygonEntry(rawData, SEG2FILESPACE(polySegmentOffset) + (i * 16)));
|
||||
|
||||
int highestPolyType = 0;
|
||||
|
||||
|
@ -53,7 +53,7 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix, con
|
|||
//if (highestPolyType > 0)
|
||||
{
|
||||
for (int i = 0; i < highestPolyType + 1; i++)
|
||||
polygonTypes.push_back(BitConverter::ToUInt64BE(data, polyTypeDefSegmentOffset + (i * 8)));
|
||||
polygonTypes.push_back(BitConverter::ToUInt64BE(data, SEG2FILESPACE(polyTypeDefSegmentOffset) + (i * 8)));
|
||||
}
|
||||
//else
|
||||
//{
|
||||
|
@ -64,7 +64,7 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix, con
|
|||
//}
|
||||
|
||||
if (camDataSegmentOffset != 0)
|
||||
camData = new CameraDataList(parent, prefix, rawData, camDataSegmentOffset, polyTypeDefSegmentOffset, polygonTypes.size());
|
||||
camData = new CameraDataList(parent, prefix, rawData, SEG2FILESPACE(camDataSegmentOffset), SEG2FILESPACE(polyTypeDefSegmentOffset), polygonTypes.size());
|
||||
|
||||
for (int i = 0; i < numWaterBoxes; i++)
|
||||
waterBoxes.push_back(new WaterBoxHeader(rawData, waterBoxSegmentOffset + (i * 16)));
|
||||
|
@ -76,7 +76,7 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix, con
|
|||
{
|
||||
for (int i = 0; i < waterBoxes.size(); i++)
|
||||
{
|
||||
sprintf(line, "\t{ %i, %i, %i, %i, %i, 0x%08X },\n", waterBoxes[i]->xMin, waterBoxes[i]->ySurface, waterBoxes[i]->zMin, waterBoxes[i]->xLength, waterBoxes[i]->zLength, waterBoxes[i]->properties);
|
||||
sprintf(line, " { %i, %i, %i, %i, %i, 0x%08X },\n", waterBoxes[i]->xMin, waterBoxes[i]->ySurface, waterBoxes[i]->zMin, waterBoxes[i]->xLength, waterBoxes[i]->zLength, waterBoxes[i]->properties);
|
||||
declaration += line;
|
||||
}
|
||||
}
|
||||
|
@ -91,27 +91,29 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix, con
|
|||
|
||||
for (int i = 0; i < polygons.size(); i++)
|
||||
{
|
||||
sprintf(line, "\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X }, // 0x%08X\n",
|
||||
sprintf(line, " { 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X }, // 0x%08X\n",
|
||||
(uint16_t)polygons[i]->type, (uint16_t)polygons[i]->vtxA, (uint16_t)polygons[i]->vtxB, (uint16_t)polygons[i]->vtxC,
|
||||
(uint16_t)polygons[i]->a, (uint16_t)polygons[i]->b, (uint16_t)polygons[i]->c, (uint16_t)polygons[i]->d, polySegmentOffset + (i * 16));
|
||||
(uint16_t)polygons[i]->a, (uint16_t)polygons[i]->b, (uint16_t)polygons[i]->c, (uint16_t)polygons[i]->d, SEG2FILESPACE(polySegmentOffset) + (i * 16));
|
||||
declaration += line;
|
||||
}
|
||||
|
||||
if (polySegmentOffset != 0) {
|
||||
parent->AddDeclarationArray(polySegmentOffset, DeclarationAlignment::None, polygons.size() * 16, "CollisionPoly", StringHelper::Sprintf("%s_polygons_%08X", prefix.c_str(), polySegmentOffset), 0, declaration);
|
||||
parent->AddDeclarationArray(SEG2FILESPACE(polySegmentOffset), DeclarationAlignment::None, polygons.size() * 16, "CollisionPoly", StringHelper::Sprintf("%s_polygons_%08X", prefix.c_str(), SEG2FILESPACE(polySegmentOffset)), 0, declaration);
|
||||
}
|
||||
}
|
||||
|
||||
declaration = "";
|
||||
for (int i = 0; i < polygonTypes.size(); i++)
|
||||
{
|
||||
sprintf(line, "\t 0x%08lX, 0x%08lX, \n", polygonTypes[i] >> 32, polygonTypes[i] & 0xFFFFFFFF);
|
||||
declaration += line;
|
||||
declaration += StringHelper::Sprintf(" 0x%08lX, 0x%08lX,", polygonTypes[i] >> 32, polygonTypes[i] & 0xFFFFFFFF);
|
||||
|
||||
if (i < polygonTypes.size() - 1)
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
if (polyTypeDefSegmentOffset != 0)
|
||||
parent->AddDeclarationArray(polyTypeDefSegmentOffset, DeclarationAlignment::None, polygonTypes.size() * 8,
|
||||
"u32", StringHelper::Sprintf("%s_polygonTypes_%08X", prefix.c_str(), polyTypeDefSegmentOffset), 0, declaration);
|
||||
parent->AddDeclarationArray(SEG2FILESPACE(polyTypeDefSegmentOffset), DeclarationAlignment::None, polygonTypes.size() * 8,
|
||||
"u32", StringHelper::Sprintf("%s_polygonTypes_%08X", prefix.c_str(), SEG2FILESPACE(polyTypeDefSegmentOffset)), 0, declaration);
|
||||
|
||||
declaration = "";
|
||||
|
||||
|
@ -121,14 +123,15 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix, con
|
|||
|
||||
for (int i = 0; i < vertices.size(); i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %i, %i, %i }, // 0x%08X", vertices[i]->x, vertices[i]->y, vertices[i]->z, SEG2FILESPACE(vtxSegmentOffset) + (i * 6));
|
||||
|
||||
sprintf(line, "{ %i, %i, %i }, // 0x%08X\n", vertices[i]->x, vertices[i]->y, vertices[i]->z, vtxSegmentOffset + (i * 6));
|
||||
declaration += line;
|
||||
if (i < vertices.size() - 1)
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
if (vtxSegmentOffset != 0)
|
||||
parent->AddDeclarationArray(vtxSegmentOffset, DeclarationAlignment::None, vertices.size() * 6,
|
||||
"Vec3s", StringHelper::Sprintf("%s_vtx_%08X", prefix.c_str(), vtxSegmentOffset), 0, declaration);
|
||||
parent->AddDeclarationArray(SEG2FILESPACE(vtxSegmentOffset), DeclarationAlignment::None, vertices.size() * 6,
|
||||
"Vec3s", StringHelper::Sprintf("%s_vtx_%08X", prefix.c_str(), SEG2FILESPACE(vtxSegmentOffset)), 0, declaration);
|
||||
|
||||
declaration = "";
|
||||
}
|
||||
|
@ -144,9 +147,9 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix, con
|
|||
declaration += StringHelper::Sprintf("%i, %i, %i, %i, %i, %i, %i, %s_vtx_%08X, %i, %s_polygons_%08X, %s_polygonTypes_%08X, &%s_camDataList_%08X, %i, %s",
|
||||
absMinX, absMinY, absMinZ,
|
||||
absMaxX, absMaxY, absMaxZ,
|
||||
numVerts, prefix.c_str(), vtxSegmentOffset, numPolygons,
|
||||
prefix.c_str(), polySegmentOffset, prefix.c_str(), polyTypeDefSegmentOffset,
|
||||
prefix.c_str(), camDataSegmentOffset, numWaterBoxes, waterBoxStr);
|
||||
numVerts, prefix.c_str(), SEG2FILESPACE(vtxSegmentOffset), numPolygons,
|
||||
prefix.c_str(), SEG2FILESPACE(polySegmentOffset), prefix.c_str(), SEG2FILESPACE(polyTypeDefSegmentOffset),
|
||||
prefix.c_str(), SEG2FILESPACE(camDataSegmentOffset), numWaterBoxes, waterBoxStr);
|
||||
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, DeclarationPadding::Pad16, 44, "CollisionHeader",
|
||||
StringHelper::Sprintf("%s", prefix.c_str(), rawDataIndex), declaration);
|
||||
|
@ -250,7 +253,10 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, const s
|
|||
else
|
||||
sprintf(camSegLine, "0x%08X", entries[i]->cameraPosDataSeg);
|
||||
|
||||
declaration += StringHelper::Sprintf("\t{ 0x%04X, %i, %s }, // 0x%08X\n", entries[i]->cameraSType, entries[i]->numData, camSegLine, rawDataIndex + (i * 8));
|
||||
declaration += StringHelper::Sprintf("\t{ 0x%04X, %i, %s },", entries[i]->cameraSType, entries[i]->numData, camSegLine, rawDataIndex + (i * 8));
|
||||
|
||||
if (i < entries.size() - 1)
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::None, entries.size() * 8, "CamData", StringHelper::Sprintf("%s_camDataList_%08X", prefix.c_str(), rawDataIndex), entries.size(), declaration);
|
||||
|
|
|
@ -67,11 +67,11 @@ public:
|
|||
int16_t absMinX, absMinY, absMinZ;
|
||||
int16_t absMaxX, absMaxY, absMaxZ;
|
||||
int16_t numVerts;
|
||||
int32_t vtxSegmentOffset;
|
||||
segptr_t vtxSegmentOffset;
|
||||
int16_t numPolygons;
|
||||
int32_t polySegmentOffset;
|
||||
int32_t polyTypeDefSegmentOffset;
|
||||
int32_t camDataSegmentOffset;
|
||||
segptr_t polySegmentOffset;
|
||||
segptr_t polyTypeDefSegmentOffset;
|
||||
segptr_t camDataSegmentOffset;
|
||||
|
||||
int32_t numWaterBoxes;
|
||||
int32_t waterBoxSegmentOffset;
|
||||
|
|
|
@ -126,6 +126,21 @@ int ZCutscene::GetRawDataSize()
|
|||
return size;
|
||||
}
|
||||
|
||||
ZCutscene* ZCutscene::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZCutscene* cs = new ZCutscene(nRawData, rawDataIndex, 9999);
|
||||
cs->rawData = nRawData;
|
||||
cs->rawDataIndex = rawDataIndex;
|
||||
cs->ParseXML(reader);
|
||||
cs->ParseRawData();
|
||||
|
||||
return cs;
|
||||
}
|
||||
|
||||
void ZCutscene::ParseRawData()
|
||||
{
|
||||
}
|
||||
|
||||
CutsceneCommands ZCutscene::GetCommandFromID(int id)
|
||||
{
|
||||
switch (id)
|
||||
|
|
|
@ -408,8 +408,12 @@ public:
|
|||
|
||||
std::string GetSourceOutputCode(const std::string& prefix);
|
||||
int GetRawDataSize();
|
||||
private:
|
||||
|
||||
static ZCutscene* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath);
|
||||
protected:
|
||||
int numCommands;
|
||||
int endFrame;
|
||||
std::vector<CutsceneCommand*> commands;
|
||||
|
||||
void ParseRawData();
|
||||
};
|
||||
|
|
|
@ -165,7 +165,7 @@ int ZDisplayList::OptimizationCheck_LoadTextureBlock(int startIndex, string& out
|
|||
|
||||
Declaration* texDecl = nullptr;
|
||||
|
||||
if (parent != nullptr)
|
||||
if (parent != nullptr && segmentNumber != 2) // HACK: Until we have declarations use segment addresses, we'll exclude scene references...
|
||||
{
|
||||
texDecl = parent->GetDeclaration(texAddr);
|
||||
|
||||
|
@ -345,22 +345,20 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
if (parent != nullptr)
|
||||
dListDecl = parent->GetDeclaration(SEG2FILESPACE(data));
|
||||
|
||||
// TEST
|
||||
if (segNum != 8 && scene != nullptr && scene->parent->GetDeclarationName(data & 0x00FFFFFF) != "ERROR_COULD_NOT_FIND_DECLARATION")
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
if (pp != 0)
|
||||
{
|
||||
if (dListDecl != nullptr)
|
||||
if (!Globals::Instance->HasSegment(segNum))
|
||||
sprintf(line, "gsSPBranchList(0x%08lX),", data & 0xFFFFFFFF);
|
||||
else if (dListDecl != nullptr)
|
||||
sprintf(line, "gsSPBranchList(%s),", dListDecl->varName.c_str());
|
||||
else
|
||||
sprintf(line, "gsSPBranchList(%sDlist0x%06lX),", prefix.c_str(), SEG2FILESPACE(data));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dListDecl != nullptr)
|
||||
if (!Globals::Instance->HasSegment(segNum))
|
||||
sprintf(line, "gsSPDisplayList(0x%08lX),", data & 0xFFFFFFFF);
|
||||
else if (dListDecl != nullptr)
|
||||
sprintf(line, "gsSPDisplayList(%s),", dListDecl->varName.c_str());
|
||||
else
|
||||
sprintf(line, "gsSPDisplayList(%sDlist0x%06lX),", prefix.c_str(), SEG2FILESPACE(data));
|
||||
|
@ -379,6 +377,7 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
{
|
||||
ZDisplayList* nList = new ZDisplayList(fileData, data & 0x00FFFFFF, GetDListLength(fileData, data & 0x00FFFFFF));
|
||||
nList->scene = scene;
|
||||
nList->parent = parent;
|
||||
otherDLists.push_back(nList);
|
||||
}
|
||||
}
|
||||
|
@ -446,27 +445,55 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
if (GETSEGNUM(data) == 0x80) // Are these vertices defined in code?
|
||||
vtxAddr -= SEG2FILESPACE(parent->baseAddress);
|
||||
|
||||
sprintf(line, "gsSPVertex(%sVtx_%06X, %i, %i),", prefix.c_str(), vtxAddr, nn, ((aa >> 1) - nn));
|
||||
//sprintf(line, "gsSPVertex(%sVtx_%06X, %i, %i),", prefix.c_str(), vtxAddr, nn, ((aa >> 1) - nn));
|
||||
sprintf(line, "gsSPVertex(@r, %i, %i),", nn, ((aa >> 1) - nn));
|
||||
references.push_back(vtxAddr);
|
||||
|
||||
{
|
||||
uint32_t currentPtr = data & 0x00FFFFFF;
|
||||
uint32_t currentPtr = SEG2FILESPACE(data);
|
||||
|
||||
if (GETSEGNUM(data) == 0x80) // Are these vertices defined in code?
|
||||
currentPtr -= SEG2FILESPACE(parent->baseAddress);
|
||||
|
||||
vector<Vertex> vtxList = vector<Vertex>();
|
||||
|
||||
vtxList.reserve(nn);
|
||||
|
||||
for (int i = 0; i < nn; i++)
|
||||
// Check for vertex intersections from other display lists
|
||||
// TODO: These two could probably be condenced to one...
|
||||
if (parent->GetDeclarationRanged(vtxAddr + (nn * 16)) != nullptr)
|
||||
{
|
||||
Vertex vtx = Vertex(fileData, currentPtr);
|
||||
vtxList.push_back(vtx);
|
||||
|
||||
currentPtr += 16;
|
||||
Declaration* decl = parent->GetDeclarationRanged(vtxAddr + (nn * 16));
|
||||
uint32_t addr = parent->GetDeclarationRangedAddress(vtxAddr + (nn * 16));
|
||||
int diff = addr - vtxAddr;
|
||||
if (diff > 0)
|
||||
nn = diff / 16;
|
||||
else
|
||||
nn = 0;
|
||||
}
|
||||
|
||||
vertices[vtxAddr] = vtxList;
|
||||
if (parent->GetDeclarationRanged(vtxAddr) != nullptr)
|
||||
{
|
||||
Declaration* decl = parent->GetDeclarationRanged(vtxAddr);
|
||||
uint32_t addr = parent->GetDeclarationRangedAddress(vtxAddr);
|
||||
int diff = addr - vtxAddr;
|
||||
if (diff > 0)
|
||||
nn = diff / 16;
|
||||
else
|
||||
nn = 0;
|
||||
}
|
||||
|
||||
if (nn > 0)
|
||||
{
|
||||
vector<Vertex> vtxList = vector<Vertex>();
|
||||
vtxList.reserve(nn);
|
||||
|
||||
for (int i = 0; i < nn; i++)
|
||||
{
|
||||
Vertex vtx = Vertex(fileData, currentPtr);
|
||||
vtxList.push_back(vtx);
|
||||
|
||||
currentPtr += 16;
|
||||
}
|
||||
|
||||
vertices[vtxAddr] = vtxList;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -502,6 +529,9 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
int32_t texAddress = SEG2FILESPACE(data);
|
||||
Declaration* texDecl = nullptr;
|
||||
|
||||
if (segmentNumber == 0x80) // Is this texture defined in code?
|
||||
texAddress -= SEG2FILESPACE(parent->baseAddress);
|
||||
|
||||
if (parent != nullptr)
|
||||
{
|
||||
if (Globals::Instance->HasSegment(segmentNumber))
|
||||
|
@ -523,11 +553,13 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
//}
|
||||
//else
|
||||
{
|
||||
sprintf(texStr, "0x%08lX", data);
|
||||
sprintf(texStr, "0x%08lX", data & 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(line, "gsDPSetTextureImage(%s, %s, %i, %s),", fmtTbl[fmt].c_str(), sizTbl[siz].c_str(), www + 1, texStr);
|
||||
//sprintf(line, "gsDPSetTextureImage(%s, %s, %i, @r),", fmtTbl[fmt].c_str(), sizTbl[siz].c_str(), www + 1);
|
||||
//references.push_back(data & 0x00FFFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1002,6 +1034,7 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
|
||||
ZDisplayList* nList = new ZDisplayList(fileData, h & 0x00FFFFFF, GetDListLength(fileData, h & 0x00FFFFFF));
|
||||
nList->scene = scene;
|
||||
nList->parent = parent;
|
||||
otherDLists.push_back(nList);
|
||||
|
||||
i++;
|
||||
|
@ -1056,9 +1089,9 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
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;
|
||||
});
|
||||
{
|
||||
return lhs.first < rhs.first;
|
||||
});
|
||||
|
||||
for (int i = 0; i < verticesSorted.size() - 1; i++)
|
||||
{
|
||||
|
@ -1075,7 +1108,7 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
vertices[verticesSorted[i].first].push_back(verticesSorted[i + 1].second[j]);
|
||||
}
|
||||
|
||||
defines += StringHelper::Sprintf("#define %sVtx_%06X ((u32)%sVtx_%06X + 0x%06X)\n", prefix.c_str(), verticesSorted[i + 1].first, prefix.c_str(), verticesSorted[i].first, verticesSorted[i + 1].first - verticesSorted[i].first);
|
||||
//defines += StringHelper::Sprintf("#define %sVtx_%06X ((u32)%sVtx_%06X + 0x%06X)\n", prefix.c_str(), verticesSorted[i + 1].first, prefix.c_str(), verticesSorted[i].first, verticesSorted[i + 1].first - verticesSorted[i].first);
|
||||
|
||||
int nSize = (int)vertices[verticesSorted[i].first].size();
|
||||
|
||||
|
@ -1111,10 +1144,11 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
|
||||
if (parent != nullptr)
|
||||
{
|
||||
parent->AddDeclarationArray(item.first, DeclarationAlignment::None, item.second.size() * 16, "static Vtx",
|
||||
parent->AddDeclarationArray(item.first, DeclarationAlignment::None, item.second.size() * 16, "static Vtx",
|
||||
StringHelper::Sprintf("%sVtx_%06X", prefix.c_str(), item.first, item.second.size()), item.second.size(), declaration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for texture intersections
|
||||
{
|
||||
|
@ -1153,9 +1187,9 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
vector<pair<uint32_t, ZTexture*>> texturesSorted(textures.begin(), textures.end());
|
||||
|
||||
sort(texturesSorted.begin(), texturesSorted.end(), [](const auto& lhs, const auto& rhs)
|
||||
{
|
||||
return lhs.first < rhs.first;
|
||||
});
|
||||
{
|
||||
return lhs.first < rhs.first;
|
||||
});
|
||||
|
||||
for (int i = 0; i < texturesSorted.size() - 1; i++)
|
||||
{
|
||||
|
@ -1163,15 +1197,15 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
break;
|
||||
|
||||
int texSize = textures[texturesSorted[i].first]->GetRawDataSize();
|
||||
|
||||
|
||||
if ((texturesSorted[i].first + texSize) > texturesSorted[i + 1].first)
|
||||
{
|
||||
int intersectAmt = (texturesSorted[i].first + texSize) - texturesSorted[i + 1].first;
|
||||
|
||||
|
||||
// If we're working with a palette, resize it to its "real" dimensions
|
||||
if (texturesSorted[i].second->isPalette)
|
||||
{
|
||||
texturesSorted[i].second->SetWidth(intersectAmt / 2);
|
||||
texturesSorted[i].second->SetWidth((texturesSorted[i + 1].first - texturesSorted[i].first) / 2);
|
||||
texturesSorted[i].second->SetHeight(1);
|
||||
}
|
||||
else
|
||||
|
@ -1187,7 +1221,6 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate Texture Declarations
|
||||
for (pair<int32_t, ZTexture*> item : textures)
|
||||
|
@ -1218,7 +1251,8 @@ string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
|
|||
|
||||
if (parent != nullptr)
|
||||
{
|
||||
parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), "Gfx", StringHelper::Sprintf("%s", name.c_str()), 0, sourceOutput);
|
||||
Declaration* decl = parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), "Gfx", StringHelper::Sprintf("%s", name.c_str()), 0, sourceOutput);
|
||||
decl->references = references;
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -1244,7 +1278,7 @@ bool ZDisplayList::TextureGenCheck(vector<uint8_t> fileData, map<uint32_t, ZText
|
|||
if (Globals::Instance->verbosity >= VERBOSITY_DEBUG)
|
||||
printf("TextureGenCheck seg=%i width=%i height=%i ispal=%i addr=0x%06X\n", segmentNumber, texWidth, texHeight, texIsPalette, texAddr);
|
||||
|
||||
if (texAddr != 0 && texWidth != 0 && texHeight != 0 && texLoaded && Globals::Instance->HasSegment(segmentNumber))
|
||||
if ((texSeg != 0 || texAddr != 0) && texWidth != 0 && texHeight != 0 && texLoaded && Globals::Instance->HasSegment(segmentNumber))
|
||||
{
|
||||
if (segmentNumber != 2) // Not from a scene file
|
||||
{
|
||||
|
|
|
@ -244,6 +244,8 @@ public:
|
|||
std::map<uint32_t, ZTexture*> textures;
|
||||
std::map<uint32_t, std::string> texDeclarations;
|
||||
|
||||
std::vector<uint32_t> references;
|
||||
|
||||
std::string defines; // Hack for special cases where vertex arrays intersect...
|
||||
std::vector<uint8_t> fileData;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "ZCollision.h"
|
||||
#include "ZScalar.h"
|
||||
#include "ZVector.h"
|
||||
#include "ZCutscene.h"
|
||||
#include "Path.h"
|
||||
#include "File.h"
|
||||
#include "Directory.h"
|
||||
|
@ -288,6 +289,20 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, bool placeholderMode)
|
|||
printf("No ZVector created!!");
|
||||
}
|
||||
}
|
||||
else if (string(child->Name()) == "Cutscene")
|
||||
{
|
||||
ZCutscene* cs = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
cs = ZCutscene::ExtractFromXML(child, rawData, rawDataIndex, folderName);
|
||||
|
||||
if (cs != nullptr)
|
||||
{
|
||||
cs->parent = this;
|
||||
resources.push_back(cs);
|
||||
rawDataIndex += cs->GetRawDataSize();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Globals::Instance->verbosity >= VERBOSITY_DEBUG)
|
||||
|
@ -394,7 +409,7 @@ Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignm
|
|||
return decl;
|
||||
}
|
||||
|
||||
void ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, string varType, string varName, std::string body)
|
||||
Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, string varType, string varName, std::string body)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (declarations.find(address) != declarations.end())
|
||||
|
@ -406,9 +421,10 @@ void ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, Dec
|
|||
AddDeclarationDebugChecks(address);
|
||||
|
||||
declarations[address] = new Declaration(alignment, padding, size, varType, varName, false, body);
|
||||
return declarations[address];
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, uint32_t size, std::string varType, std::string varName, int arrayItemCnt, std::string body)
|
||||
Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, uint32_t size, std::string varType, std::string varName, int arrayItemCnt, std::string body)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (declarations.find(address) != declarations.end())
|
||||
|
@ -420,10 +436,11 @@ void ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment
|
|||
AddDeclarationDebugChecks(address);
|
||||
|
||||
declarations[address] = new Declaration(alignment, size, varType, varName, true, arrayItemCnt, body);
|
||||
return declarations[address];
|
||||
}
|
||||
|
||||
|
||||
void ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, string varType, string varName, int arrayItemCnt, std::string body)
|
||||
Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, string varType, string varName, int arrayItemCnt, std::string body)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (declarations.find(address) != declarations.end())
|
||||
|
@ -435,34 +452,41 @@ void ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment
|
|||
AddDeclarationDebugChecks(address);
|
||||
|
||||
declarations[address] = new Declaration(alignment, padding, size, varType, varName, true, arrayItemCnt, body);
|
||||
return declarations[address];
|
||||
}
|
||||
|
||||
|
||||
void ZFile::AddDeclarationPlaceholder(uint32_t address)
|
||||
Declaration* ZFile::AddDeclarationPlaceholder(uint32_t address)
|
||||
{
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
if (declarations.find(address) == declarations.end())
|
||||
declarations[address] = new Declaration(DeclarationAlignment::None, 0, "", "", false, "");
|
||||
|
||||
return declarations[address];
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationPlaceholder(uint32_t address, string varName)
|
||||
Declaration* ZFile::AddDeclarationPlaceholder(uint32_t address, string varName)
|
||||
{
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
if (declarations.find(address) == declarations.end())
|
||||
declarations[address] = new Declaration(DeclarationAlignment::None, 0, "", varName, false, "");
|
||||
|
||||
return declarations[address];
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationInclude(uint32_t address, string includePath, uint32_t size, string varType, string varName)
|
||||
Declaration* ZFile::AddDeclarationInclude(uint32_t address, string includePath, uint32_t size, string varType, string varName)
|
||||
{
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
if (declarations.find(address) == declarations.end())
|
||||
declarations[address] = new Declaration(includePath, size, varType, varName);
|
||||
|
||||
return declarations[address];
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationIncludeArray(uint32_t address, std::string includePath, uint32_t size, std::string varType, std::string varName, int arrayItemCnt)
|
||||
Declaration* ZFile::AddDeclarationIncludeArray(uint32_t address, std::string includePath, uint32_t size, std::string varType, std::string varName, int arrayItemCnt)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (declarations.find(address) != declarations.end())
|
||||
|
@ -479,12 +503,13 @@ void ZFile::AddDeclarationIncludeArray(uint32_t address, std::string includePath
|
|||
decl->arrayItemCnt = arrayItemCnt;
|
||||
|
||||
declarations[address] = decl;
|
||||
return declarations[address];
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationDebugChecks(uint32_t address)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (address == 0xB888E0)
|
||||
if (address == 0x5600)
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
|
@ -516,15 +541,24 @@ Declaration* ZFile::GetDeclarationRanged(uint32_t address)
|
|||
{
|
||||
for (const auto decl : declarations)
|
||||
{
|
||||
if (address >= decl.first && address <= decl.first + decl.second->size)
|
||||
{
|
||||
if (address >= decl.first && address < decl.first + decl.second->size)
|
||||
return decl.second;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t ZFile::GetDeclarationRangedAddress(uint32_t address)
|
||||
{
|
||||
for (const auto decl : declarations)
|
||||
{
|
||||
if (address >= decl.first && address < decl.first + decl.second->size)
|
||||
return decl.first;
|
||||
}
|
||||
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
bool ZFile::HasDeclaration(uint32_t address)
|
||||
{
|
||||
return (declarations.find(address) != declarations.end());
|
||||
|
@ -661,6 +695,41 @@ string ZFile::ProcessDeclarations()
|
|||
|
||||
//printf("RANGE START: 0x%06X - RANGE END: 0x%06X\n", rangeStart, rangeEnd);
|
||||
|
||||
// Optimization: See if there are any arrays side by side that can be merged...
|
||||
//pair<int32_t, Declaration*> lastItem = declarationKeysSorted[0];
|
||||
|
||||
//for (int i = 1; i < declarationKeysSorted.size(); i++)
|
||||
//{
|
||||
// pair<int32_t, Declaration*> curItem = declarationKeysSorted[i];
|
||||
|
||||
// if (curItem.second->isArray && lastItem.second->isArray)
|
||||
// {
|
||||
// if (curItem.second->varType == lastItem.second->varType)
|
||||
// {
|
||||
// // TEST: For now just do Vtx declarations...
|
||||
// if (lastItem.second->varType == "static Vtx")
|
||||
// {
|
||||
// lastItem.second->size += curItem.second->size;
|
||||
// lastItem.second->arrayItemCnt += curItem.second->arrayItemCnt;
|
||||
// lastItem.second->text += "\n" + curItem.second->text;
|
||||
// declarations.erase(curItem.first);
|
||||
// declarationKeysSorted.erase(declarationKeysSorted.begin() + i);
|
||||
// i--;
|
||||
// continue;
|
||||
|
||||
// int bp = 0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// lastItem = curItem;
|
||||
//}
|
||||
|
||||
for (pair<int32_t, Declaration*> item : declarations)
|
||||
{
|
||||
ProcessDeclarationText(item.second);
|
||||
}
|
||||
|
||||
for (pair<int32_t, Declaration*> item : declarationKeysSorted)
|
||||
{
|
||||
while (declarations[item.first]->size % 4 != 0)
|
||||
|
@ -756,7 +825,7 @@ string ZFile::ProcessDeclarations()
|
|||
|
||||
uint8_t* rawDataArr = rawData.data();
|
||||
|
||||
if (lastAddr + lastSize != item.first)
|
||||
if (lastAddr + lastSize != item.first && lastAddr >= rangeStart && lastAddr + lastSize < rangeEnd)
|
||||
{
|
||||
//int diff = item.first - (lastAddr + declarations[lastAddr]->size);
|
||||
int diff = item.first - (lastAddr + lastSize);
|
||||
|
@ -887,6 +956,44 @@ string ZFile::ProcessDeclarations()
|
|||
return output;
|
||||
}
|
||||
|
||||
void ZFile::ProcessDeclarationText(Declaration* decl)
|
||||
{
|
||||
int refIndex = 0;
|
||||
|
||||
if (decl->references.size() > 0)
|
||||
{
|
||||
for (int i = 0; i < decl->text.size() - 1; i++)
|
||||
{
|
||||
char c = decl->text[i];
|
||||
char c2 = decl->text[i + 1];
|
||||
|
||||
if (c == '@' && c2 == 'r')
|
||||
{
|
||||
Declaration* refDecl = GetDeclarationRanged(decl->references[refIndex]);
|
||||
uint32_t refDeclAddr = GetDeclarationRangedAddress(decl->references[refIndex]);
|
||||
|
||||
if (refDecl != nullptr)
|
||||
{
|
||||
if (refDecl->isArray)
|
||||
{
|
||||
int itemSize = refDecl->size / refDecl->arrayItemCnt;
|
||||
int itemIndex = (decl->references[refIndex] - refDeclAddr) / itemSize;
|
||||
|
||||
decl->text.replace(i, 2, StringHelper::Sprintf("&%s[%i]", refDecl->varName.c_str(), itemIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
decl->text.replace(i, 2, refDecl->varName);
|
||||
}
|
||||
}
|
||||
else
|
||||
decl->text.replace(i, 2, "ERROR");
|
||||
|
||||
refIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string ZFile::ProcessExterns()
|
||||
{
|
||||
|
|
|
@ -37,17 +37,18 @@ public:
|
|||
void AddResource(ZResource* res);
|
||||
|
||||
Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment, uint32_t size, std::string varType, std::string varName, std::string body);
|
||||
void AddDeclaration(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, std::string varType, std::string varName, std::string body);
|
||||
void AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, uint32_t size, std::string varType, std::string varName, int arrayItemCnt, std::string body);
|
||||
void AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, std::string varType, std::string varName, int arrayItemCnt, std::string body);
|
||||
void AddDeclarationPlaceholder(uint32_t address);
|
||||
void AddDeclarationPlaceholder(uint32_t address, std::string varName);
|
||||
void AddDeclarationInclude(uint32_t address, std::string includePath, uint32_t size, std::string varType, std::string varName);
|
||||
void AddDeclarationIncludeArray(uint32_t address, std::string includePath, uint32_t size, std::string varType, std::string varName, int arrayItemCnt);
|
||||
Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, std::string varType, std::string varName, std::string body);
|
||||
Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, uint32_t size, std::string varType, std::string varName, int arrayItemCnt, std::string body);
|
||||
Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, std::string varType, std::string varName, int arrayItemCnt, std::string body);
|
||||
Declaration* AddDeclarationPlaceholder(uint32_t address);
|
||||
Declaration* AddDeclarationPlaceholder(uint32_t address, std::string varName);
|
||||
Declaration* AddDeclarationInclude(uint32_t address, std::string includePath, uint32_t size, std::string varType, std::string varName);
|
||||
Declaration* AddDeclarationIncludeArray(uint32_t address, std::string includePath, uint32_t size, std::string varType, std::string varName, int arrayItemCnt);
|
||||
std::string GetDeclarationName(uint32_t address);
|
||||
std::string GetDeclarationName(uint32_t address, std::string defaultResult);
|
||||
Declaration* GetDeclaration(uint32_t address);
|
||||
Declaration* GetDeclarationRanged(uint32_t address);
|
||||
uint32_t GetDeclarationRangedAddress(uint32_t address);
|
||||
bool HasDeclaration(uint32_t address);
|
||||
std::string GetHeaderInclude();
|
||||
void GeneratePlaceholderDeclarations();
|
||||
|
@ -65,5 +66,6 @@ protected:
|
|||
void GenerateHLIntermediette();
|
||||
void AddDeclarationDebugChecks(uint32_t address);
|
||||
std::string ProcessDeclarations();
|
||||
void ProcessDeclarationText(Declaration* decl);
|
||||
std::string ProcessExterns();
|
||||
};
|
|
@ -16,6 +16,8 @@
|
|||
#define SEG2FILESPACE(x) (x & 0x00FFFFFF)
|
||||
#define GETSEGNUM(x) ((x >> 24) & 0xFF)
|
||||
|
||||
typedef uint32_t segptr_t;
|
||||
|
||||
class ZFile;
|
||||
class HLFileIntermediette;
|
||||
|
||||
|
@ -108,6 +110,7 @@ public:
|
|||
std::string includePath;
|
||||
bool isArray;
|
||||
int arrayItemCnt;
|
||||
std::vector<uint32_t> references;
|
||||
|
||||
Declaration(DeclarationAlignment nAlignment, uint32_t nSize, std::string nVarType, std::string nVarName, bool nIsArray, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, uint32_t nSize, std::string nVarType, std::string nVarName, bool nIsArray, std::string nText);
|
||||
|
|
|
@ -47,6 +47,7 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
{
|
||||
entry->opaqueDList = new ZDisplayList(rawData, entry->opaqueDListAddr, ZDisplayList::GetDListLength(rawData, entry->opaqueDListAddr));
|
||||
entry->opaqueDList->scene = zRoom->scene;
|
||||
entry->opaqueDList->parent = zRoom->parent;
|
||||
GenDListDeclarations(rawData, entry->opaqueDList);
|
||||
}
|
||||
|
||||
|
@ -54,6 +55,7 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
{
|
||||
entry->translucentDList = new ZDisplayList(rawData, entry->translucentDListAddr, ZDisplayList::GetDListLength(rawData, entry->translucentDListAddr));
|
||||
entry->translucentDList->scene = zRoom->scene;
|
||||
entry->translucentDList->parent = zRoom->parent;
|
||||
GenDListDeclarations(rawData, entry->translucentDList);
|
||||
}
|
||||
|
||||
|
@ -206,6 +208,7 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
{
|
||||
entry->opaqueDList = new ZDisplayList(rawData, entry->opaqueDListAddr, ZDisplayList::GetDListLength(rawData, entry->opaqueDListAddr));
|
||||
entry->opaqueDList->scene = zRoom->scene;
|
||||
entry->opaqueDList->parent = zRoom->parent;
|
||||
GenDListDeclarations(rawData, entry->opaqueDList); // HOTSPOT
|
||||
}
|
||||
|
||||
|
@ -213,6 +216,7 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
{
|
||||
entry->translucentDList = new ZDisplayList(rawData, entry->translucentDListAddr, ZDisplayList::GetDListLength(rawData, entry->translucentDListAddr));
|
||||
entry->translucentDList->scene = zRoom->scene;
|
||||
entry->translucentDList->parent = zRoom->parent;
|
||||
GenDListDeclarations(rawData, entry->translucentDList); // HOTSPOT
|
||||
}
|
||||
|
||||
|
@ -291,16 +295,17 @@ SetMesh::~SetMesh()
|
|||
|
||||
void SetMesh::GenDListDeclarations(std::vector<uint8_t> rawData, ZDisplayList* dList)
|
||||
{
|
||||
string sourceOutput = dList->GetSourceOutputCode(zRoom->GetName()); // HOTSPOT
|
||||
|
||||
string srcVarName = "";
|
||||
|
||||
if (Globals::Instance->includeFilePrefix)
|
||||
//if (Globals::Instance->includeFilePrefix)
|
||||
srcVarName = StringHelper::Sprintf("%s%s", zRoom->GetName().c_str(), dList->GetName().c_str());
|
||||
else
|
||||
srcVarName = StringHelper::Sprintf("%s", dList->GetName().c_str());
|
||||
//else
|
||||
//srcVarName = StringHelper::Sprintf("%s", dList->GetName().c_str());
|
||||
|
||||
zRoom->parent->AddDeclarationArray(dList->GetRawDataIndex(), DeclarationAlignment::None, dList->GetRawDataSize(), "static Gfx", srcVarName, dList->GetRawDataSize() / 8, sourceOutput);
|
||||
dList->SetName(srcVarName);
|
||||
string sourceOutput = dList->GetSourceOutputCode(zRoom->GetName()); // HOTSPOT
|
||||
|
||||
//zRoom->parent->AddDeclarationArray(dList->GetRawDataIndex(), DeclarationAlignment::None, dList->GetRawDataSize(), "static Gfx", srcVarName, dList->GetRawDataSize() / 8, sourceOutput);
|
||||
|
||||
for (ZDisplayList* otherDList : dList->otherDLists)
|
||||
GenDListDeclarations(rawData, otherDList);
|
||||
|
@ -324,7 +329,7 @@ void SetMesh::GenDListDeclarations(std::vector<uint8_t> rawData, ZDisplayList* d
|
|||
|
||||
zRoom->parent->AddDeclarationIncludeArray(texEntry.first, StringHelper::Sprintf("%s/%s.%s.inc.c",
|
||||
Globals::Instance->outputPath.c_str(), Path::GetFileNameWithoutExtension(zRoom->textures[texEntry.first]->GetName()).c_str(), zRoom->textures[texEntry.first]->GetExternalExtension().c_str()),
|
||||
zRoom->textures[texEntry.first]->GetRawDataSize(), "u64", StringHelper::Sprintf("%sTex_%06X", zRoom->textures[texEntry.first]->GetName().c_str(), texEntry.first), 0);
|
||||
zRoom->textures[texEntry.first]->GetRawDataSize(), "u64", StringHelper::Sprintf("%s", zRoom->textures[texEntry.first]->GetName().c_str(), texEntry.first), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,10 @@ ZRoom* ZRoom::ExtractFromXML(XMLElement* reader, vector<uint8_t> nRawData, int r
|
|||
|
||||
for (XMLElement* child = reader->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
||||
{
|
||||
// TODO: Bunch of repeated code between all of these that needs to be combined.
|
||||
if (string(child->Name()) == "DListHint")
|
||||
{
|
||||
string name = "";
|
||||
string comment = "";
|
||||
|
||||
if (child->Attribute("Comment") != NULL)
|
||||
|
@ -92,11 +94,18 @@ ZRoom* ZRoom::ExtractFromXML(XMLElement* reader, vector<uint8_t> nRawData, int r
|
|||
int address = strtol(StringHelper::Split(addressStr, "0x")[1].c_str(), NULL, 16);
|
||||
|
||||
ZDisplayList* dList = new ZDisplayList(room->rawData, address, ZDisplayList::GetDListLength(room->rawData, address));
|
||||
dList->GetSourceOutputCode(room->name);
|
||||
|
||||
if (child->Attribute("Name") != NULL)
|
||||
name = string(child->Attribute("Name"));
|
||||
else
|
||||
name = room->name;
|
||||
|
||||
dList->GetSourceOutputCode(name);
|
||||
delete dList;
|
||||
}
|
||||
else if (string(child->Name()) == "BlobHint")
|
||||
{
|
||||
string name = "";
|
||||
string comment = "";
|
||||
|
||||
if (child->Attribute("Comment") != NULL)
|
||||
|
@ -109,10 +118,18 @@ ZRoom* ZRoom::ExtractFromXML(XMLElement* reader, vector<uint8_t> nRawData, int r
|
|||
int size = strtol(StringHelper::Split(sizeStr, "0x")[1].c_str(), NULL, 16);
|
||||
|
||||
ZBlob* blob = new ZBlob(room->rawData, address, size, StringHelper::Sprintf("%sBlob0x%06X", room->name.c_str(), address));
|
||||
room->parent->AddDeclarationArray(address, DeclarationAlignment::None, blob->GetRawDataSize(), "u8", StringHelper::Sprintf("%s_%s", room->name.c_str(), blob->GetName().c_str()), 0, blob->GetSourceOutputCode(room->name));
|
||||
|
||||
if (child->Attribute("Name") != NULL)
|
||||
name = string(child->Attribute("Name"));
|
||||
else
|
||||
name = StringHelper::Sprintf("%s_%s", room->name.c_str(), blob->GetName().c_str());
|
||||
|
||||
room->parent->AddDeclarationArray(address, DeclarationAlignment::None, blob->GetRawDataSize(), "u8", name, 0, blob->GetSourceOutputCode(room->name));
|
||||
delete blob;
|
||||
}
|
||||
else if (string(child->Name()) == "CutsceneHint")
|
||||
{
|
||||
string name = "";
|
||||
string comment = "";
|
||||
|
||||
if (child->Attribute("Comment") != NULL)
|
||||
|
@ -123,11 +140,18 @@ ZRoom* ZRoom::ExtractFromXML(XMLElement* reader, vector<uint8_t> nRawData, int r
|
|||
|
||||
ZCutscene* cutscene = new ZCutscene(room->rawData, address, 9999);
|
||||
|
||||
if (child->Attribute("Name") != NULL)
|
||||
name = string(child->Attribute("Name"));
|
||||
else
|
||||
name = StringHelper::Sprintf("%sCutsceneData0x%06X", room->name.c_str(), cutscene->segmentOffset);
|
||||
|
||||
room->parent->AddDeclarationArray(address, DeclarationAlignment::None, DeclarationPadding::Pad16, cutscene->GetRawDataSize(), "s32",
|
||||
StringHelper::Sprintf("%sCutsceneData0x%06X", room->name.c_str(), cutscene->segmentOffset), 0, cutscene->GetSourceOutputCode(room->name));
|
||||
name, 0, cutscene->GetSourceOutputCode(room->name));
|
||||
delete cutscene;
|
||||
}
|
||||
else if (string(child->Name()) == "AltHeaderHint")
|
||||
{
|
||||
string name = "";
|
||||
string comment = "";
|
||||
|
||||
if (child->Attribute("Comment") != NULL)
|
||||
|
@ -180,6 +204,7 @@ ZRoom* ZRoom::ExtractFromXML(XMLElement* reader, vector<uint8_t> nRawData, int r
|
|||
ZTexture* tex = ZTexture::FromBinary(ZTexture::GetTextureTypeFromString(typeStr), room->rawData, address, StringHelper::Sprintf("%sTex_%06X", room->name.c_str(), address), width, height);
|
||||
room->parent->AddDeclarationArray(address, DeclarationAlignment::None, tex->GetRawDataSize(), "u64", StringHelper::Sprintf("%s", tex->GetName().c_str()), 0,
|
||||
tex->GetSourceOutputCode(room->name));
|
||||
delete tex;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -533,6 +558,7 @@ Declaration::Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPa
|
|||
isArray = false;
|
||||
arrayItemCnt = 0;
|
||||
includePath = "";
|
||||
references = vector<uint32_t>();
|
||||
}
|
||||
|
||||
Declaration::Declaration(DeclarationAlignment nAlignment, uint32_t nSize, string nVarType, string nVarName, bool nIsArray, string nText) : Declaration(nAlignment, DeclarationPadding::None, nSize, nText)
|
||||
|
|
|
@ -34,7 +34,7 @@ def get_actor_id_name(actor_id):
|
|||
def get_actor_type_name(actor_type):
|
||||
matches = re.findall(actor_type + " .*\n", z64actor_text)
|
||||
for m in matches:
|
||||
if "ACTORTYPE" in m:
|
||||
if "ACTORCAT" in m:
|
||||
match = m.replace(",", "").strip().split(" ")[-1]
|
||||
return match
|
||||
return "0x" + actor_type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue