Files
oot/tools/ZAPD/ZAPD/ZFile.h
T
Nicholas Estelami 0432011bd9 Updated to use latest version of ZAPD (#777)
* Updated config file

* Added missing files

* Temporarily removed asm_processor changes.

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "96ffc1e62"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "96ffc1e62"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "179af7d11"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "179af7d11"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Cleanup and fixes.

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "50ad2fe78"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "50ad2fe78"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Makefile fix

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "b9120803e"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "b9120803e"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
2021-04-30 23:23:22 +02:00

101 lines
3.9 KiB
C++

#pragma once
#include <string>
#include <vector>
#include "Directory.h"
#include "ZResource.h"
#include "tinyxml2.h"
enum class ZFileMode
{
BuildTexture,
BuildOverlay,
BuildModelIntermediette,
BuildAnimationIntermediette,
BuildBlob,
BuildSourceFile,
BuildBackground,
Extract,
Invalid
};
enum class ZGame
{
OOT_RETAIL,
OOT_SW97,
MM_RETAIL
};
class ZFile
{
public:
std::map<uint32_t, Declaration*> declarations;
std::string defines;
std::vector<ZResource*> resources;
uint32_t baseAddress, rangeStart, rangeEnd;
ZFile(const fs::path& nOutPath, std::string nName);
ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, const fs::path& nBasePath,
const fs::path& nOutPath, std::string filename, const fs::path& nXmlFilePath,
bool placeholderMode);
~ZFile();
std::string GetVarName(uint32_t address);
std::string GetName();
void ExtractResources(fs::path outputDir);
void BuildSourceFile(fs::path outputDir);
void AddResource(ZResource* res);
ZResource* FindResource(uint32_t rawDataIndex);
std::vector<ZResource*> GetResourcesOfType(ZResourceType resType);
Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment, size_t size,
std::string varType, std::string varName, std::string body);
Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment,
DeclarationPadding padding, size_t size, std::string varType,
std::string varName, std::string body);
Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, size_t size,
std::string varType, std::string varName, size_t arrayItemCnt,
std::string body);
Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, size_t size,
std::string varType, std::string varName, size_t arrayItemCnt,
std::string body, bool isExternal);
Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment,
DeclarationPadding padding, size_t size, std::string varType,
std::string varName, size_t 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, size_t size,
std::string varType, std::string varName);
Declaration* AddDeclarationIncludeArray(uint32_t address, std::string includePath, size_t size,
std::string varType, std::string varName,
size_t 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();
static std::map<std::string, ZResourceFactoryFunc*>* GetNodeMap();
static void RegisterNode(std::string nodeName, ZResourceFactoryFunc* nodeFunc);
protected:
std::vector<uint8_t> rawData;
std::string name;
fs::path basePath;
fs::path outputPath;
fs::path xmlFilePath;
ZFile();
void ParseXML(ZFileMode mode, tinyxml2::XMLElement* reader, std::string filename,
bool placeholderMode);
void GenerateSourceFiles(fs::path outputDir);
void GenerateSourceHeaderFiles();
void GenerateHLIntermediette();
void AddDeclarationDebugChecks(uint32_t address);
std::string ProcessDeclarations();
void ProcessDeclarationText(Declaration* decl);
std::string ProcessExterns();
};