mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-16 20:10:28 +00:00
Remove submodule and use subrepo for ZAPD (#591)
* remove zap * git subrepo clone https://github.com/zeldaret/ZAPD.git tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "cd4a8760b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "cd4a8760b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * remove thanks.md * zap2 -> zapd and spec changes * remove submodule init
This commit is contained in:
parent
ae5a8f2700
commit
ba0c6965ca
220 changed files with 85641 additions and 554 deletions
119
tools/ZAPD/ZAPD/Globals.cpp
Normal file
119
tools/ZAPD/ZAPD/Globals.cpp
Normal file
|
@ -0,0 +1,119 @@
|
|||
#include "Globals.h"
|
||||
#include "File.h"
|
||||
#include "tinyxml2.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace tinyxml2;
|
||||
using namespace std;
|
||||
|
||||
Globals* Globals::Instance;
|
||||
|
||||
Globals::Globals()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
files = std::vector<ZFile*>();
|
||||
segments = std::vector<int>();
|
||||
symbolMap = std::map <uint32_t, std::string>();
|
||||
segmentRefs = map<int, string>();
|
||||
segmentRefFiles = map<int, ZFile*>();
|
||||
genSourceFile = true;
|
||||
testMode = false;
|
||||
debugMessages = false;
|
||||
profile = false;
|
||||
includeFilePrefix = false;
|
||||
useExternalResources = true;
|
||||
lastScene = nullptr;
|
||||
}
|
||||
|
||||
string Globals::FindSymbolSegRef(int segNumber, uint32_t symbolAddress)
|
||||
{
|
||||
if (segmentRefs.find(segNumber) != segmentRefs.end())
|
||||
{
|
||||
if (segmentRefFiles.find(segNumber) == segmentRefFiles.end())
|
||||
{
|
||||
XMLDocument doc;
|
||||
string filePath = segmentRefs[segNumber];
|
||||
XMLError eResult = doc.LoadFile(filePath.c_str());
|
||||
|
||||
if (eResult != tinyxml2::XML_SUCCESS)
|
||||
return "ERROR";
|
||||
|
||||
XMLNode* root = doc.FirstChild();
|
||||
|
||||
if (root == nullptr)
|
||||
return "ERROR";
|
||||
|
||||
//vector<ZFile*> files = vector<ZFile*>();
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
||||
{
|
||||
if (string(child->Name()) == "File")
|
||||
{
|
||||
ZFile* file = new ZFile(fileMode, child, "", "", true);
|
||||
file->GeneratePlaceholderDeclarations();
|
||||
segmentRefFiles[segNumber] = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return segmentRefFiles[segNumber]->GetDeclarationName(symbolAddress, "ERROR");
|
||||
}
|
||||
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
void Globals::ReadConfigFile(string configFilePath)
|
||||
{
|
||||
XMLDocument doc;
|
||||
XMLError eResult = doc.LoadFile(configFilePath.c_str());
|
||||
|
||||
if (eResult != tinyxml2::XML_SUCCESS)
|
||||
return;
|
||||
|
||||
XMLNode* root = doc.FirstChild();
|
||||
|
||||
if (root == nullptr)
|
||||
return;
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
||||
{
|
||||
if (string(child->Name()) == "SymbolMap")
|
||||
{
|
||||
string fileName = string(child->Attribute("File"));
|
||||
GenSymbolMap(fileName);
|
||||
}
|
||||
else if (string(child->Name()) == "Segment")
|
||||
{
|
||||
string fileName = string(child->Attribute("File"));
|
||||
int segNumber = child->IntAttribute("Number");
|
||||
segmentRefs[segNumber] = fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Globals::GenSymbolMap(string symbolMapPath)
|
||||
{
|
||||
auto symbolLines = File::ReadAllLines(symbolMapPath);
|
||||
|
||||
for (std::string symbolLine : symbolLines)
|
||||
{
|
||||
auto split = StringHelper::Split(symbolLine, " ");
|
||||
uint32_t addr = strtoul(split[0].c_str(), NULL, 16);
|
||||
std::string symbolName = split[1];
|
||||
|
||||
symbolMap[addr] = symbolName;
|
||||
}
|
||||
}
|
||||
|
||||
void Globals::AddSegment(int segment)
|
||||
{
|
||||
if (std::find(segments.begin(), segments.end(), segment) == segments.end())
|
||||
segments.push_back(segment);
|
||||
}
|
||||
|
||||
bool Globals::HasSegment(int segment)
|
||||
{
|
||||
return std::find(segments.begin(), segments.end(), segment) != segments.end();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue