mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-14 05:25:09 -05:00
f31a841789
* 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>
142 lines
4.9 KiB
C++
142 lines
4.9 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "ZSymbol.h"
|
|
#include "ZTexture.h"
|
|
#include "tinyxml2.h"
|
|
|
|
enum class ZFileMode
|
|
{
|
|
BuildTexture,
|
|
BuildOverlay,
|
|
BuildBlob,
|
|
BuildSourceFile,
|
|
BuildBackground,
|
|
Extract,
|
|
ExternalFile,
|
|
ExtractDirectory,
|
|
Invalid,
|
|
Custom = 1000, // Used for exporter file modes
|
|
};
|
|
|
|
enum class ZGame
|
|
{
|
|
OOT_RETAIL,
|
|
OOT_SW97,
|
|
MM_RETAIL
|
|
};
|
|
|
|
class ZFile
|
|
{
|
|
public:
|
|
std::map<offset_t, Declaration*> declarations;
|
|
std::vector<ZResource*> resources;
|
|
std::string defines;
|
|
|
|
int workerID;
|
|
bool isCompilable = false;
|
|
|
|
// Default to using virtual addresses
|
|
uint32_t segment = 0x80;
|
|
uint32_t baseAddress, rangeStart, rangeEnd;
|
|
bool isExternalFile = false;
|
|
|
|
ZFile(const fs::path& nOutPath, const std::string& nName);
|
|
ZFile(ZFileMode nMode, tinyxml2::XMLElement* reader, const fs::path& nBasePath,
|
|
const fs::path& nOutPath, const std::string& filename, const fs::path& nXmlFilePath, int nWorkerID);
|
|
~ZFile();
|
|
|
|
std::string GetName() const;
|
|
std::string GetOutName() const;
|
|
ZFileMode GetMode() const;
|
|
const fs::path& GetXmlFilePath() const;
|
|
const std::vector<uint8_t>& GetRawData() const;
|
|
void ExtractResources();
|
|
void BuildSourceFile();
|
|
void AddResource(ZResource* res);
|
|
ZResource* FindResource(offset_t rawDataIndex);
|
|
std::vector<ZResource*> GetResourcesOfType(ZResourceType resType);
|
|
|
|
Declaration* AddDeclaration(offset_t address, DeclarationAlignment alignment, size_t size,
|
|
const std::string& varType, const std::string& varName,
|
|
const std::string& body);
|
|
|
|
Declaration* AddDeclarationArray(offset_t address, DeclarationAlignment alignment, size_t size,
|
|
const std::string& varType, const std::string& varName,
|
|
size_t arrayItemCnt, const std::string& body);
|
|
Declaration* AddDeclarationArray(offset_t address, DeclarationAlignment alignment, size_t size,
|
|
const std::string& varType, const std::string& varName,
|
|
const std::string& arrayItemCntStr, const std::string& body);
|
|
|
|
Declaration* AddDeclarationPlaceholder(offset_t address, const std::string& varName);
|
|
|
|
Declaration* AddDeclarationInclude(offset_t address, const std::string& includePath,
|
|
size_t size, const std::string& varType,
|
|
const std::string& varName);
|
|
Declaration* AddDeclarationIncludeArray(offset_t address, std::string& includePath, size_t size,
|
|
const std::string& varType, const std::string& varName,
|
|
size_t arrayItemCnt);
|
|
|
|
bool GetDeclarationPtrName(segptr_t segAddress, const std::string& expectedType,
|
|
std::string& declName) const;
|
|
bool GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSize,
|
|
const std::string& expectedType,
|
|
std::string& declName) const;
|
|
|
|
Declaration* GetDeclaration(offset_t address) const;
|
|
Declaration* GetDeclarationRanged(offset_t address) const;
|
|
bool HasDeclaration(offset_t address);
|
|
|
|
std::string GetHeaderInclude() const;
|
|
std::string GetZRoomHeaderInclude() const;
|
|
std::string GetExternalFileHeaderInclude() const;
|
|
|
|
void GeneratePlaceholderDeclarations();
|
|
|
|
void AddTextureResource(uint32_t offset, ZTexture* tex);
|
|
ZTexture* GetTextureResource(uint32_t offset) const;
|
|
|
|
void AddSymbolResource(uint32_t offset, ZSymbol* sym);
|
|
ZSymbol* GetSymbolResource(uint32_t offset) const;
|
|
ZSymbol* GetSymbolResourceRanged(uint32_t offset) const;
|
|
|
|
fs::path GetSourceOutputFolderPath() const;
|
|
|
|
bool IsOffsetInFileRange(uint32_t offset) const;
|
|
bool IsSegmentedInFilespaceRange(segptr_t segAddress) const;
|
|
|
|
static std::map<std::string, ZResourceFactoryFunc*>* GetNodeMap();
|
|
static void RegisterNode(std::string nodeName, ZResourceFactoryFunc* nodeFunc);
|
|
|
|
protected:
|
|
std::string name;
|
|
fs::path outName = "";
|
|
fs::path basePath;
|
|
fs::path outputPath;
|
|
fs::path xmlFilePath;
|
|
std::vector<uint8_t> rawData;
|
|
|
|
// Keep track of every texture of this ZFile.
|
|
// The pointers declared here are "borrowed" (somebody else is the owner),
|
|
// so ZFile shouldn't delete/free those textures.
|
|
std::map<uint32_t, ZTexture*> texturesResources;
|
|
std::map<uint32_t, ZSymbol*> symbolResources;
|
|
ZFileMode mode = ZFileMode::Invalid;
|
|
|
|
ZFile();
|
|
void ParseXML(tinyxml2::XMLElement* reader, const std::string& filename);
|
|
void DeclareResourceSubReferences();
|
|
void GenerateSourceFiles();
|
|
void GenerateSourceHeaderFiles();
|
|
bool AddDeclarationChecks(uint32_t address, const std::string& varName);
|
|
std::string ProcessDeclarations();
|
|
void ProcessDeclarationText(Declaration* decl);
|
|
std::string ProcessExterns();
|
|
|
|
std::string ProcessTextureIntersections(const std::string& prefix);
|
|
void HandleUnaccountedData();
|
|
bool HandleUnaccountedAddress(offset_t currentAddress, offset_t lastAddr, uint32_t& lastSize);
|
|
};
|