mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-10 08:50:23 +00:00
Building on Macs (#1086)
* git subrepo pull (merge) tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "945e6ca1a" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "50242eca9" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Fix extract_assets.py multithreading * Update binutils doc a bit * Remove * import, add multiprocessing option and way to pass arguments to ZAPD * Update format.sh to be more platform-independent * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "fd5a7f434" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "fd5a7f434" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Remove ; * Update formatting script to not just use 11 * Add Python requirements, move the Mac stuff in the README into its own doc * Fix readme link * Minor format thing * . * Move ZAPDArgs into its own function * Update readme and remove requirements.txt * Dragorn-inspired rewrite of processZAPDArgs * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "a0d3f7b68" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "a0d3f7b68" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Fix function definition * Building docs overhaul * Add Python packages to Mac and Cygwin * Heading number * format format.sh (!) * Replace "currently" * Remove Debian * git subrepo pull (merge) --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "0ba781304" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "0ba781304" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596"
This commit is contained in:
parent
9450272503
commit
9b67778a00
41 changed files with 640 additions and 325 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "Globals.h"
|
||||
#include "OutputFormatter.h"
|
||||
#include "Utils/BinaryWriter.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/Directory.h"
|
||||
#include "Utils/File.h"
|
||||
#include "Utils/MemoryStream.h"
|
||||
|
@ -192,7 +193,7 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
|
|||
rawData = File::ReadAllBytes((basePath / name).string());
|
||||
|
||||
if (reader->Attribute("RangeEnd") == nullptr)
|
||||
rangeEnd = rawData.size();
|
||||
rangeEnd = rawData.size();
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> nameSet;
|
||||
|
@ -378,7 +379,7 @@ void ZFile::ExtractResources()
|
|||
ZResourceExporter* exporter = Globals::Instance->GetExporter(res->GetResourceType());
|
||||
if (exporter != nullptr)
|
||||
{
|
||||
//exporter->Save(res, Globals::Instance->outputPath.string(), &writerFile);
|
||||
// exporter->Save(res, Globals::Instance->outputPath.string(), &writerFile);
|
||||
exporter->Save(res, Globals::Instance->outputPath.string(), &writerRes);
|
||||
}
|
||||
|
||||
|
@ -391,7 +392,7 @@ void ZFile::ExtractResources()
|
|||
File::WriteAllBytes(StringHelper::Sprintf("%s%s.bin",
|
||||
Globals::Instance->outputPath.string().c_str(),
|
||||
GetName().c_str()),
|
||||
memStreamFile->ToVector());
|
||||
memStreamFile->ToVector());
|
||||
}
|
||||
|
||||
writerFile.Close();
|
||||
|
@ -949,9 +950,6 @@ std::string ZFile::ProcessDeclarations()
|
|||
|
||||
defines += ProcessTextureIntersections(name);
|
||||
|
||||
// Account for padding/alignment
|
||||
uint32_t lastAddr = 0;
|
||||
|
||||
// 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...
|
||||
|
@ -1002,43 +1000,6 @@ std::string ZFile::ProcessDeclarations()
|
|||
{
|
||||
while (item.second->size % 4 != 0)
|
||||
item.second->size++;
|
||||
|
||||
if (lastAddr != 0)
|
||||
{
|
||||
if (item.second->alignment == DeclarationAlignment::Align16)
|
||||
{
|
||||
int32_t curPtr = lastAddr + declarations[lastAddr]->size;
|
||||
|
||||
while (curPtr % 4 != 0)
|
||||
{
|
||||
declarations[lastAddr]->size++;
|
||||
curPtr++;
|
||||
}
|
||||
}
|
||||
else if (item.second->alignment == DeclarationAlignment::Align8)
|
||||
{
|
||||
size_t curPtr = lastAddr + declarations[lastAddr]->size;
|
||||
|
||||
while (curPtr % 4 != 0)
|
||||
{
|
||||
declarations[lastAddr]->size++;
|
||||
curPtr++;
|
||||
}
|
||||
|
||||
while (curPtr % 8 != 0)
|
||||
{
|
||||
char buffer[2048];
|
||||
|
||||
sprintf(buffer, "u32 %s_align%02zX = 0;\n", name.c_str(), curPtr);
|
||||
item.second->preText = buffer + item.second->preText;
|
||||
|
||||
declarations[lastAddr]->size += 4;
|
||||
curPtr += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastAddr = item.first;
|
||||
}
|
||||
|
||||
HandleUnaccountedData();
|
||||
|
@ -1199,14 +1160,15 @@ void ZFile::HandleUnaccountedData()
|
|||
{
|
||||
uint32_t lastAddr = 0;
|
||||
uint32_t lastSize = 0;
|
||||
std::vector<uint32_t> declsAddresses;
|
||||
std::vector<offset_t> declsAddresses;
|
||||
|
||||
for (const auto& item : declarations)
|
||||
{
|
||||
declsAddresses.push_back(item.first);
|
||||
}
|
||||
|
||||
bool breakLoop = false;
|
||||
for (uint32_t currentAddress : declsAddresses)
|
||||
for (offset_t currentAddress : declsAddresses)
|
||||
{
|
||||
if (currentAddress >= rangeEnd)
|
||||
{
|
||||
|
@ -1235,7 +1197,7 @@ void ZFile::HandleUnaccountedData()
|
|||
}
|
||||
}
|
||||
|
||||
bool ZFile::HandleUnaccountedAddress(uint32_t currentAddress, uint32_t lastAddr, uint32_t& lastSize)
|
||||
bool ZFile::HandleUnaccountedAddress(offset_t currentAddress, offset_t lastAddr, uint32_t& lastSize)
|
||||
{
|
||||
if (currentAddress != lastAddr && declarations.find(lastAddr) != declarations.end())
|
||||
{
|
||||
|
@ -1275,6 +1237,29 @@ bool ZFile::HandleUnaccountedAddress(uint32_t currentAddress, uint32_t lastAddr,
|
|||
xmlFilePath.c_str(), currentAddress, name.c_str(), rawData.size()));
|
||||
}
|
||||
|
||||
// Handle Align8
|
||||
if (currentAddress % 8 == 0 && diff % 8 != 0)
|
||||
{
|
||||
Declaration* currentDecl = GetDeclaration(currentAddress);
|
||||
|
||||
if (currentDecl != nullptr)
|
||||
{
|
||||
if (currentDecl->alignment == DeclarationAlignment::Align8)
|
||||
{
|
||||
// Check removed bytes are zeroes
|
||||
if (BitConverter::ToUInt32BE(rawData, unaccountedAddress + diff - 4) == 0)
|
||||
{
|
||||
diff -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (diff == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < diff; i++)
|
||||
{
|
||||
uint8_t val = rawData.at(unaccountedAddress + i);
|
||||
|
@ -1320,7 +1305,10 @@ bool ZFile::HandleUnaccountedAddress(uint32_t currentAddress, uint32_t lastAddr,
|
|||
StringHelper::Sprintf("%s_%s_%06X", name.c_str(), unaccountedPrefix.c_str(),
|
||||
unaccountedAddress),
|
||||
diff, src);
|
||||
|
||||
decl->isUnaccounted = true;
|
||||
if (Globals::Instance->forceUnaccountedStatic)
|
||||
decl->staticConf = StaticConfig::On;
|
||||
|
||||
if (nonZeroUnaccounted)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue