Update ZAPD subrepo (#1338)

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "cb0342425"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "cb0342425"
git-subrepo:
  version:  "0.4.6"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "110b9eb"

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "505024b33"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "505024b33"
git-subrepo:
  version:  "0.4.6"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "110b9eb"

* Disable Wno-hardcoded-pointer for `make assets`
This commit is contained in:
Tom Overton
2023-07-28 18:20:12 -04:00
committed by GitHub
parent 6f7d6cc47e
commit bbfbc4073e
57 changed files with 1426 additions and 719 deletions
+1 -1
View File
@@ -309,7 +309,7 @@ setup:
python3 tools/decompress_yars.py
assets:
python3 extract_assets.py -j $(N_THREADS)
python3 extract_assets.py -j $(N_THREADS) -Z Wno-hardcoded-pointer
## Assembly generation
disasm:
+1 -1
View File
@@ -66,7 +66,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
+3 -3
View File
@@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/zeldaret/ZAPD.git
branch = master
commit = 23929ec9373d28cb298daad4ad7cb468e09c0a46
parent = 2e487b5008c129031ab311a3a7bfd42adeb4916b
commit = 505024b33eb1fcd00e3e9bb71f1355fa2ae6e9cf
parent = 387d3597142ebdbebe1fbb99858ea831aa2752b4
method = merge
cmdver = 0.4.3
cmdver = 0.4.6
@@ -67,9 +67,9 @@ void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] fs::path o
for (auto entry : col->camData->entries)
{
writer->Write(entry->cameraSType);
writer->Write(entry->numData);
writer->Write(entry->cameraPosDataSeg);
writer->Write(entry.cameraSType);
writer->Write(entry.numData);
writer->Write(entry.cameraPosDataSeg);
}
writer->Seek(oldOffset, SeekOffsetType::Start);
+1 -1
View File
@@ -17,7 +17,7 @@ clean:
rm -rf build $(LIB)
format:
clang-format-11 -i $(CPP_FILES) $(H_FILES)
clang-format-14 -i $(CPP_FILES) $(H_FILES)
.PHONY: all clean format
+1 -1
View File
@@ -106,7 +106,7 @@ clean:
rebuild: clean all
format:
clang-format-11 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES)
clang-format-14 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES)
$(MAKE) -C ZAPDUtils format
$(MAKE) -C ExporterTest format
+17 -16
View File
@@ -139,22 +139,23 @@ Each warning type uses one of these by default, but can be modified with flags,
All warning types currently implemented, with their default levels:
| Warning type | Default level | Description |
| --------------------------- | ------------- | ------------------------------------------------------------------------ |
| `-Wdeprecated` | Warn | Deprecated features |
| `-Whardcoded-pointer` | Warn | ZAPD lacks the info to make a symbol, so must output a hardcoded pointer |
| `-Wintersection` | Warn | Two assets intersect |
| `-Winvalid-attribute-value` | Err | Attribute declared in XML is wrong |
| `-Winvalid-extracted-data` | Err | Extracted data does not have correct form |
| `-Winvalid-jpeg` | Err | JPEG file does not conform to the game's format requirements |
| `-Winvalid-png` | Err | Issues arising when processing PNG data |
| `-Winvalid-xml` | Err | XML has syntax errors |
| `-Wmissing-attribute` | Warn | Required attribute missing in XML tag |
| `-Wmissing-offsets` | Warn | Offset attribute missing in XML tag |
| `-Wmissing-segment` | Warn | Segment not given in File tag in XML |
| `-Wnot-implemented` | Warn | ZAPD does not currently support this feature |
| `-Wunaccounted` | Off | Large blocks of unaccounted |
| `-Wunknown-attribute` | Warn | Unknown attribute in XML entry tag |
| Warning type | Default level | Description |
| ----------------------------- | ------------- | ------------------------------------------------------------------------ |
| `-Wdeprecated` | Warn | Deprecated features |
| `-Whardcoded-generic-pointer` | Off | A generic segmented pointer must be produced |
| `-Whardcoded-pointer` | Warn | ZAPD lacks the info to make a symbol, so must output a hardcoded pointer |
| `-Wintersection` | Warn | Two assets intersect |
| `-Winvalid-attribute-value` | Err | Attribute declared in XML is wrong |
| `-Winvalid-extracted-data` | Err | Extracted data does not have correct form |
| `-Winvalid-jpeg` | Err | JPEG file does not conform to the game's format requirements |
| `-Winvalid-png` | Err | Issues arising when processing PNG data |
| `-Winvalid-xml` | Err | XML has syntax errors |
| `-Wmissing-attribute` | Warn | Required attribute missing in XML tag |
| `-Wmissing-offsets` | Warn | Offset attribute missing in XML tag |
| `-Wmissing-segment` | Warn | Segment not given in File tag in XML |
| `-Wnot-implemented` | Warn | ZAPD does not currently support this feature |
| `-Wunaccounted` | Off | Large blocks of unaccounted |
| `-Wunknown-attribute` | Warn | Unknown attribute in XML entry tag |
There are also errors that do not have a type, and cannot be disabled.
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once
static uint32_t CRC32B(unsigned char* message, int32_t size)
static uint32_t CRC32B(const unsigned char* message, int32_t size)
{
int32_t byte, crc;
int32_t mask;
+1
View File
@@ -8,6 +8,7 @@
#endif
#include <array>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <ctime>
+100 -88
View File
@@ -4,61 +4,79 @@
#include "Utils/StringHelper.h"
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nText)
const std::string& nBody)
{
address = nAddress;
alignment = nAlignment;
size = nSize;
text = nText;
declBody = nBody;
}
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
const std::string& nText)
: Declaration(nAddress, nAlignment, nSize, nText)
Declaration* Declaration::Create(offset_t declAddr, DeclarationAlignment declAlign, size_t declSize,
const std::string& declType, const std::string& declName,
const std::string& declBody)
{
varType = nVarType;
varName = nVarName;
isArray = nIsArray;
Declaration* decl = new Declaration(declAddr, declAlign, declSize, declBody);
decl->declType = declType;
decl->declName = declName;
decl->declBody = declBody;
return decl;
}
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
size_t nArrayItemCnt, const std::string& nText)
: Declaration(nAddress, nAlignment, nSize, nText)
Declaration* Declaration::CreateArray(offset_t declAddr, DeclarationAlignment declAlign,
size_t declSize, const std::string& declType,
const std::string& declName, const std::string& declBody,
size_t declArrayItemCnt, bool isDeclExternal)
{
varType = nVarType;
varName = nVarName;
isArray = nIsArray;
arrayItemCnt = nArrayItemCnt;
Declaration* decl = new Declaration(declAddr, declAlign, declSize, declBody);
decl->declName = declName;
decl->declType = declType;
decl->arrayItemCnt = declArrayItemCnt;
decl->isExternal = isDeclExternal;
decl->isArray = true;
return decl;
}
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
const std::string& nArrayItemCntStr, const std::string& nText)
: Declaration(nAddress, nAlignment, nSize, nText)
Declaration* Declaration::CreateArray(offset_t declAddr, DeclarationAlignment declAlign,
size_t declSize, const std::string& declType,
const std::string& declName, const std::string& declBody,
const std::string& declArrayItemCntStr, bool isDeclExternal)
{
varType = nVarType;
varName = nVarName;
isArray = nIsArray;
arrayItemCntStr = nArrayItemCntStr;
Declaration* decl = new Declaration(declAddr, declAlign, declSize, declBody);
decl->declName = declName;
decl->declType = declType;
decl->arrayItemCntStr = declArrayItemCntStr;
decl->isExternal = isDeclExternal;
decl->isArray = true;
return decl;
}
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
size_t nArrayItemCnt, const std::string& nText, bool nIsExternal)
: Declaration(nAddress, nAlignment, nSize, nVarType, nVarName, nIsArray, nArrayItemCnt, nText)
Declaration* Declaration::CreateInclude(offset_t declAddr, const std::string& includePath,
size_t declSize, const std::string& declType,
const std::string& declName, const std::string& defines)
{
isExternal = nIsExternal;
Declaration* decl = new Declaration(declAddr, DeclarationAlignment::Align4, declSize, "");
decl->includePath = includePath;
decl->declType = declType;
decl->declName = declName;
decl->defines = defines;
return decl;
}
Declaration::Declaration(offset_t nAddress, const std::string& nIncludePath, size_t nSize,
const std::string& nVarType, const std::string& nVarName)
: Declaration(nAddress, DeclarationAlignment::Align4, nSize, "")
Declaration* Declaration::CreatePlaceholder(offset_t declAddr, const std::string& declName)
{
includePath = nIncludePath;
varType = nVarType;
varName = nVarName;
Declaration* decl = new Declaration(declAddr, DeclarationAlignment::Align4, 0, "");
decl->declName = declName;
decl->isPlaceholder = true;
return decl;
}
bool Declaration::IsStatic() const
@@ -82,9 +100,6 @@ std::string Declaration::GetNormalDeclarationStr() const
{
std::string output;
if (preText != "")
output += preText + "\n";
if (IsStatic())
{
output += "static ";
@@ -92,27 +107,28 @@ std::string Declaration::GetNormalDeclarationStr() const
if (isArray)
{
if (arrayItemCntStr != "" && (IsStatic() || forceArrayCnt))
bool includeArraySize = (IsStatic() || forceArrayCnt);
if (includeArraySize)
{
output += StringHelper::Sprintf("%s %s[%s];\n", varType.c_str(), varName.c_str(),
arrayItemCntStr.c_str());
}
else if (arrayItemCnt != 0 && (IsStatic() || forceArrayCnt))
{
output += StringHelper::Sprintf("%s %s[%i] = {\n", varType.c_str(), varName.c_str(),
arrayItemCnt);
if (arrayItemCntStr != "")
output += StringHelper::Sprintf("%s %s[%s];\n", declType.c_str(), declName.c_str(),
arrayItemCntStr.c_str());
else
output += StringHelper::Sprintf("%s %s[%i] = {\n", declType.c_str(),
declName.c_str(), arrayItemCnt);
}
else
{
output += StringHelper::Sprintf("%s %s[] = {\n", varType.c_str(), varName.c_str());
output += StringHelper::Sprintf("%s %s[] = {\n", declType.c_str(), declName.c_str());
}
output += text + "\n";
output += declBody + "\n";
}
else
{
output += StringHelper::Sprintf("%s %s = { ", varType.c_str(), varName.c_str());
output += text;
output += StringHelper::Sprintf("%s %s = { ", declType.c_str(), declName.c_str());
output += declBody;
}
if (output.back() == '\n')
@@ -120,14 +136,8 @@ std::string Declaration::GetNormalDeclarationStr() const
else
output += " };";
if (rightText != "")
output += " " + rightText + "";
output += "\n";
if (postText != "")
output += postText + "\n";
output += "\n";
return output;
@@ -137,41 +147,34 @@ std::string Declaration::GetExternalDeclarationStr() const
{
std::string output;
if (preText != "")
output += preText + "\n";
if (IsStatic())
{
output += "static ";
bool includeArraySize = (IsStatic() || forceArrayCnt);
if (includeArraySize)
{
if (arrayItemCntStr != "")
output += StringHelper::Sprintf("%s %s[%s] = ", declType.c_str(), declName.c_str(),
arrayItemCntStr.c_str());
else
output += StringHelper::Sprintf("%s %s[%i] = ", declType.c_str(), declName.c_str(),
arrayItemCnt);
}
else
{
output += StringHelper::Sprintf("%s %s[] = ", declType.c_str(), declName.c_str());
}
if (arrayItemCntStr != "" && (IsStatic() || forceArrayCnt))
output += StringHelper::Sprintf("%s %s[%s] = ", varType.c_str(), varName.c_str(),
arrayItemCntStr.c_str());
else if (arrayItemCnt != 0 && (IsStatic() || forceArrayCnt))
output +=
StringHelper::Sprintf("%s %s[%i] = ", varType.c_str(), varName.c_str(), arrayItemCnt);
else
output += StringHelper::Sprintf("%s %s[] = ", varType.c_str(), varName.c_str());
output += StringHelper::Sprintf("{\n#include \"%s\"\n};", includePath.c_str());
if (rightText != "")
output += " " + rightText + "";
output += "\n";
if (postText != "")
output += postText + "\n";
output += "\n";
output += "\n\n";
return output;
}
std::string Declaration::GetExternStr() const
{
if (IsStatic() || varType == "" || isUnaccounted)
if (IsStatic() || declType == "" || isUnaccounted)
{
return "";
}
@@ -180,19 +183,28 @@ std::string Declaration::GetExternStr() const
{
if (arrayItemCntStr != "" && (IsStatic() || forceArrayCnt))
{
return StringHelper::Sprintf("extern %s %s[%s];\n", varType.c_str(), varName.c_str(),
return StringHelper::Sprintf("extern %s %s[%s];\n", declType.c_str(), declName.c_str(),
arrayItemCntStr.c_str());
}
else if (arrayItemCnt != 0 && (IsStatic() || forceArrayCnt))
{
return StringHelper::Sprintf("extern %s %s[%i];\n", varType.c_str(), varName.c_str(),
return StringHelper::Sprintf("extern %s %s[%i];\n", declType.c_str(), declName.c_str(),
arrayItemCnt);
}
else
return StringHelper::Sprintf("extern %s %s[];\n", varType.c_str(), varName.c_str());
return StringHelper::Sprintf("extern %s %s[];\n", declType.c_str(), declName.c_str());
}
return StringHelper::Sprintf("extern %s %s;\n", varType.c_str(), varName.c_str());
return StringHelper::Sprintf("extern %s %s;\n", declType.c_str(), declName.c_str());
}
std::string Declaration::GetDefinesStr() const
{
if (IsStatic() || (declType == ""))
{
return "";
}
return StringHelper::Sprintf("%s", defines.c_str());
}
std::string Declaration::GetStaticForwardDeclarationStr() const
@@ -210,15 +222,15 @@ std::string Declaration::GetStaticForwardDeclarationStr() const
if (arrayItemCntStr != "")
{
return StringHelper::Sprintf("static %s %s[%s];\n", varType.c_str(), varName.c_str(),
return StringHelper::Sprintf("static %s %s[%s];\n", declType.c_str(), declName.c_str(),
arrayItemCntStr.c_str());
}
else
{
return StringHelper::Sprintf("static %s %s[%i];\n", varType.c_str(), varName.c_str(),
return StringHelper::Sprintf("static %s %s[%i];\n", declType.c_str(), declName.c_str(),
arrayItemCnt);
}
}
return StringHelper::Sprintf("static %s %s;\n", varType.c_str(), varName.c_str());
return StringHelper::Sprintf("static %s %s;\n", declType.c_str(), declName.c_str());
}
+129 -27
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
@@ -22,59 +23,160 @@ enum class StaticConfig
On
};
/// <summary>
/// A declaration is contains the C contents of a symbol for a file.
/// It contains at a minimum the address where the symbol would be in the binary file, alignment
/// settings, the size of the binary data, and the C code that makes it up. Optionally it can also
/// contain comments.
/// </summary>
class Declaration
{
public:
offset_t address;
DeclarationAlignment alignment;
size_t size;
std::string preText;
std::string text;
std::string rightText;
std::string postText;
std::string preComment;
std::string postComment;
std::string varType;
std::string varName;
std::string includePath;
// Where in the binary file (segment) will this C code end up being?
offset_t address = 0;
// How is this C code aligned?
DeclarationAlignment alignment = DeclarationAlignment::Align4;
// How many bytes will this C code take up in the resulting binary when compiled?
size_t size = 0;
// The C type of this declaration
std::string declType = "";
// The C variable name of this declaration
std::string declName = "";
// The body of the declaration containing the data.
// In "int j = 7;", "7" would be text.
std::string declBody = "";
// #define's to be included in the header
std::string defines = "";
std::string includePath = "";
// Is this declaration in an external file? (ie. a gameplay_keep reference being found in
// another file that wishes to use its data)
bool isExternal = false;
bool isArray = false;
// If true, will ensure that the arrays size is included in the declaration
bool forceArrayCnt = false;
// If this declaration is an array, how many items make it up?
size_t arrayItemCnt = 0;
// Overrides the brackets for the arrays size with a custom string
std::string arrayItemCntStr = "";
std::vector<segptr_t> references;
// If true, this declaration represents data inside the file which we do not understand it's
// purpose for. It will be outputted as just a byte array.
bool isUnaccounted = false;
// Is this declaration a placeholder that will be replaced later?
bool isPlaceholder = false;
// Does this declaration come straight from the XML?
// If false, this means that the declaration was created by ZAPD when it was parsing the
// resources.
bool declaredInXml = false;
StaticConfig staticConf = StaticConfig::Global;
Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
const std::string& nText);
Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
size_t nArrayItemCnt, const std::string& nText);
Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
const std::string& nArrayItemCntStr, const std::string& nText);
Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
size_t nArrayItemCnt, const std::string& nText, bool nIsExternal);
/// <summary>
/// Creates a regular declaration.
/// </summary>
/// <param name="declAddr">The address inside a binary file this declaration will be in when
/// compiled.</param> <param name="declAlign">The alignment of this declaration in the compiled
/// binary file.</param> <param name="declSize">The size of this declaration when it is compiled
/// to binary data.</param> <param name="declType">The C variable type this declaration will be
/// declared as.</param> <param name="declName">The C variable name this declaration will be
/// declared as.</param> <param name="declBody">The contents of the C variable
/// declaration.</param> <returns></returns>
static Declaration* Create(offset_t declAddr, DeclarationAlignment declAlign, size_t declSize,
const std::string& declType, const std::string& declName,
const std::string& declBody);
Declaration(offset_t nAddress, const std::string& nIncludePath, size_t nSize,
const std::string& nVarType, const std::string& nVarName);
/// <summary>
/// Creates an array declaration.
/// </summary>
/// <param name="declAddr">The address inside a binary file this declaration will be in when
/// compiled.</param> <param name="declAlign">The alignment of this declaration in the compiled
/// binary file.</param> <param name="declSize">The size of this declaration when it is compiled
/// to binary data.</param> <param name="declType">The C variable type this declaration will be
/// declared as.</param> <param name="declName">The C variable name this declaration will be
/// declared as.</param> <param name="declBody">The contents of the C variable
/// declaration.</param> <param name="declArrayItemCnt">The number of items in the
/// array.</param> <param name="isDeclExternal">(Optional) Is this declaration from another
/// segment?</param> <returns></returns>
static Declaration* CreateArray(offset_t declAddr, DeclarationAlignment declAlign,
size_t declSize, const std::string& declType,
const std::string& declName, const std::string& declBody,
size_t declArrayItemCnt = 0, bool isDeclExternal = false);
/// <summary>
/// Creates an array declaration who's size in the C code uses a custom string.
/// </summary>
/// <param name="declAddr">The address inside a binary file this declaration will be in when
/// compiled.</param> <param name="declAlign">The alignment of this declaration in the compiled
/// binary file.</param> <param name="declSize">The size of this declaration when it is compiled
/// to binary data.</param> <param name="declType">The C variable type this declaration will be
/// declared as.</param> <param name="declName">The C variable name this declaration will be
/// declared as.</param> <param name="declBody">The contents of the C variable
/// declaration.</param> <param name="declArrayItemCntStr">The string to be put in the C array's
/// size inbetween the brackets.</param> <param name="isDeclExternal">(Optional) Is this
/// declaration from another segment?</param> <returns></returns>
static Declaration* CreateArray(offset_t declAddr, DeclarationAlignment declAlign,
size_t declSize, const std::string& declType,
const std::string& declName, const std::string& declBody,
const std::string& declArrayItemCntStr,
bool isDeclExternal = false);
/// <summary>
/// Creates a declaration who's body uses a #include to include another file
/// </summary>
/// <param name="declAddr">The address inside a binary file this declaration will be in when
/// compiled.</param> <param name="includePath">The path to the file this declaration will be
/// #including.</param> <param name="declSize">The size of this declaration when it is compiled
/// to binary data.</param> <param name="declType">The C variable type this declaration will be
/// declared as.</param> <param name="declName">The C variable name this declaration will be
/// declared as.</param> <param name="defines">(Optional) Any #define's we want to have
/// outputted by this declaration.</param> <returns></returns>
static Declaration* CreateInclude(offset_t declAddr, const std::string& includePath,
size_t declSize, const std::string& declType,
const std::string& declName, const std::string& defines = "");
/// <summary>
/// Creates a placeholder declaration to be replaced later.
/// </summary>
/// <param name="declAddr">The address inside a binary file this declaration will be in when
/// compiled.</param> <param name="declName">The C variable name this declaration will be
/// declared as.</param> <returns></returns>
static Declaration* CreatePlaceholder(offset_t declAddr, const std::string& declName);
bool IsStatic() const;
// Returns the declaration as C code as it would be in the code file when the body contains the
// needed data
std::string GetNormalDeclarationStr() const;
// Returns the declaration as C code as it would be in the code file when the body #include's
// another file
std::string GetExternalDeclarationStr() const;
// Generates the extern for this item to be placed in header files.
std::string GetExternStr() const;
// Generates any #define's needed
std::string GetDefinesStr() const;
std::string GetStaticForwardDeclarationStr() const;
protected:
Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
const std::string& nText);
const std::string& nBody);
};
+24
View File
@@ -0,0 +1,24 @@
#pragma once
typedef void (*ExporterSetFunc)(ZFile*);
typedef bool (*ExporterSetFuncBool)(ZFileMode fileMode);
typedef void (*ExporterSetFuncVoid)(int argc, char* argv[], int& i);
typedef void (*ExporterSetFuncVoid2)(const std::string& buildMode, ZFileMode& fileMode);
typedef void (*ExporterSetFuncVoid3)();
typedef void (*ExporterSetResSave)(ZResource* res, BinaryWriter& writer);
class ExporterSet
{
public:
~ExporterSet();
std::map<ZResourceType, ZResourceExporter*> exporters;
ExporterSetFuncVoid parseArgsFunc = nullptr;
ExporterSetFuncVoid2 parseFileModeFunc = nullptr;
ExporterSetFuncBool processFileModeFunc = nullptr;
ExporterSetFunc beginFileFunc = nullptr;
ExporterSetFunc endFileFunc = nullptr;
ExporterSetFuncVoid3 beginXMLFunc = nullptr;
ExporterSetFuncVoid3 endXMLFunc = nullptr;
ExporterSetResSave resSaveFunc = nullptr;
};
+1
View File
@@ -124,6 +124,7 @@ void GameConfig::ConfigFunc_BGConfig(const tinyxml2::XMLElement& element)
{
bgScreenWidth = element.IntAttribute("ScreenWidth", 320);
bgScreenHeight = element.IntAttribute("ScreenHeight", 240);
useScreenWidthHeightConstants = element.BoolAttribute("UseScreenWidthHeightConstants", true);
}
void GameConfig::ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element)
+2
View File
@@ -37,6 +37,8 @@ public:
// ZBackground
uint32_t bgScreenWidth = 320, bgScreenHeight = 240;
bool useScreenWidthHeightConstants = true; // If true, ZBackground's will be declared with
// SCREEN_WIDTH * SCREEN_HEIGHT in the C file
// ExternalFile
fs::path externalXmlFolder;
+36 -4
View File
@@ -83,9 +83,10 @@ ExporterSet* Globals::GetExporterSet()
}
bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile,
const std::string& expectedType, std::string& declName)
const std::string& expectedType, std::string& declName,
bool warnIfNotFound)
{
if (segAddress == 0)
if (segAddress == SEGMENTED_NULL)
{
declName = "NULL";
return true;
@@ -160,14 +161,18 @@ bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile,
}
declName = StringHelper::Sprintf("0x%08X", segAddress);
if (warnIfNotFound)
{
WarnHardcodedPointer(segAddress, currentFile, nullptr, -1);
}
return false;
}
bool Globals::GetSegmentedArrayIndexedName(segptr_t segAddress, size_t elementSize,
ZFile* currentFile, const std::string& expectedType,
std::string& declName)
std::string& declName, bool warnIfNotFound)
{
if (segAddress == 0)
if (segAddress == SEGMENTED_NULL)
{
declName = "NULL";
return true;
@@ -197,9 +202,36 @@ bool Globals::GetSegmentedArrayIndexedName(segptr_t segAddress, size_t elementSi
}
declName = StringHelper::Sprintf("0x%08X", segAddress);
if (warnIfNotFound)
{
WarnHardcodedPointer(segAddress, currentFile, nullptr, -1);
}
return false;
}
void Globals::WarnHardcodedPointer(segptr_t segAddress, ZFile* currentFile, ZResource* res,
offset_t currentOffset)
{
uint8_t segment = GETSEGNUM(segAddress);
if ((segment >= 2 && segment <= 6) || segment == 0x80)
{
std::string errorHeader = "A hardcoded pointer was found";
std::string errorBody = StringHelper::Sprintf("Pointer: 0x%08X", segAddress);
HANDLE_WARNING_RESOURCE(WarningType::HardcodedPointer, currentFile, res, currentOffset,
errorHeader, errorBody);
}
else
{
std::string errorHeader = "A general purpose hardcoded pointer was found";
std::string errorBody = StringHelper::Sprintf("Pointer: 0x%08X", segAddress);
HANDLE_WARNING_RESOURCE(WarningType::HardcodedGenericPointer, currentFile, res,
currentOffset, errorHeader, errorBody);
}
}
ExternalFile::ExternalFile(fs::path nXmlPath, fs::path nOutPath)
: xmlPath{nXmlPath}, outPath{nOutPath}
{
+9 -25
View File
@@ -5,6 +5,7 @@
#include <vector>
#include "GameConfig.h"
#include "ZFile.h"
#include "ExporterSet.h"
class ZRoom;
@@ -15,29 +16,6 @@ enum class VerbosityLevel
VERBOSITY_DEBUG
};
typedef void (*ExporterSetFunc)(ZFile*);
typedef bool (*ExporterSetFuncBool)(ZFileMode fileMode);
typedef void (*ExporterSetFuncVoid)(int argc, char* argv[], int& i);
typedef void (*ExporterSetFuncVoid2)(const std::string& buildMode, ZFileMode& fileMode);
typedef void (*ExporterSetFuncVoid3)();
typedef void (*ExporterSetResSave)(ZResource* res, BinaryWriter& writer);
class ExporterSet
{
public:
~ExporterSet();
std::map<ZResourceType, ZResourceExporter*> exporters;
ExporterSetFuncVoid parseArgsFunc = nullptr;
ExporterSetFuncVoid2 parseFileModeFunc = nullptr;
ExporterSetFuncBool processFileModeFunc = nullptr;
ExporterSetFunc beginFileFunc = nullptr;
ExporterSetFunc endFileFunc = nullptr;
ExporterSetFuncVoid3 beginXMLFunc = nullptr;
ExporterSetFuncVoid3 endXMLFunc = nullptr;
ExporterSetResSave resSaveFunc = nullptr;
};
class Globals
{
public:
@@ -86,8 +64,14 @@ public:
* in which case `declName` will be set to the address formatted as a pointer.
*/
bool GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile,
const std::string& expectedType, std::string& declName);
const std::string& expectedType, std::string& declName,
bool warnIfNotFound = true);
bool GetSegmentedArrayIndexedName(segptr_t segAddress, size_t elementSize, ZFile* currentFile,
const std::string& expectedType, std::string& declName);
const std::string& expectedType, std::string& declName,
bool warnIfNotFound = true);
// TODO: consider moving to another place
void WarnHardcodedPointer(segptr_t segAddress, ZFile* currentFile, ZResource* res,
offset_t currentOffset);
};
+238 -150
View File
@@ -9,24 +9,52 @@
#include "ZFile.h"
#include "ZTexture.h"
#include <functional>
#include "CrashHandler.h"
#include <string>
#include <string_view>
#include "tinyxml2.h"
using ArgFunc = void (*)(int&, char**);
void Arg_SetOutputPath(int& i, char* argv[]);
void Arg_SetInputPath(int& i, char* argv[]);
void Arg_SetBaseromPath(int& i, char* argv[]);
void Arg_SetSourceOutputPath(int& i, char* argv[]);
void Arg_GenerateSourceFile(int& i, char* argv[]);
void Arg_TestMode(int& i, char* argv[]);
void Arg_LegacyDList(int& i, char* argv[]);
void Arg_EnableProfiling(int& i, char* argv[]);
void Arg_UseExternalResources(int& i, char* argv[]);
void Arg_SetTextureType(int& i, char* argv[]);
void Arg_ReadConfigFile(int& i, char* argv[]);
void Arg_EnableErrorHandler(int& i, char* argv[]);
void Arg_SetVerbosity(int& i, char* argv[]);
void Arg_VerboseUnaccounted(int& i, char* argv[]);
void Arg_SetExporter(int& i, char* argv[]);
void Arg_EnableGCCCompat(int& i, char* argv[]);
void Arg_ForceStatic(int& i, char* argv[]);
void Arg_ForceUnaccountedStatic(int& i, char* argv[]);
int main(int argc, char* argv[]);
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath,
ZFileMode fileMode);
void ParseArgs(int& argc, char* argv[]);
void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath);
void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath);
void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath);
ZFileMode ParseFileMode(const std::string& buildMode, ExporterSet* exporterSet);
int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet);
extern const char gBuildHash[];
int main(int argc, char* argv[])
{
// Syntax: ZAPD.out [mode (btex/bovl/e)] (Arbritrary Number of Arguments)
int returnCode = 0;
if (argc < 2)
{
@@ -55,112 +83,12 @@ int main(int argc, char* argv[])
}
}
// Parse other "commands"
for (int32_t i = 2; i < argc; i++)
{
std::string arg = argv[i];
if (arg == "-o" || arg == "--outputpath") // Set output path
{
Globals::Instance->outputPath = argv[++i];
if (Globals::Instance->sourceOutputPath == "")
Globals::Instance->sourceOutputPath = Globals::Instance->outputPath;
}
else if (arg == "-i" || arg == "--inputpath") // Set input path
{
Globals::Instance->inputPath = argv[++i];
}
else if (arg == "-b" || arg == "--baserompath") // Set baserom path
{
Globals::Instance->baseRomPath = argv[++i];
}
else if (arg == "-osf") // Set source output path
{
Globals::Instance->sourceOutputPath = argv[++i];
}
else if (arg == "-gsf") // Generate source file during extraction
{
Globals::Instance->genSourceFile = std::string_view(argv[++i]) == "1";
}
else if (arg == "-tm") // Test Mode (enables certain experimental features)
{
Globals::Instance->testMode = std::string_view(argv[++i]) == "1";
}
else if (arg == "-crc" ||
arg == "--output-crc") // Outputs a CRC file for each extracted texture.
{
Globals::Instance->testMode = std::string_view(argv[++i]) == "1";
}
else if (arg == "-ulzdl") // Use Legacy ZDisplay List
{
Globals::Instance->useLegacyZDList = std::string_view(argv[++i]) == "1";
}
else if (arg == "-profile") // Enable profiling
{
Globals::Instance->profile = std::string_view(argv[++i]) == "1";
}
else if (arg ==
"-uer") // Split resources into their individual components (enabled by default)
// TODO: We may wish to make this a part of the config file...
{
Globals::Instance->useExternalResources = std::string_view(argv[++i]) == "1";
}
else if (arg == "-tt") // Set texture type
{
Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[++i]);
}
else if (arg == "-rconf") // Read Config File
{
Globals::Instance->cfg.ReadConfigFile(argv[++i]);
}
else if (arg == "-eh") // Enable Error Handler
{
CrashHandler_Init();
}
else if (arg == "-v") // Verbose
{
Globals::Instance->verbosity = static_cast<VerbosityLevel>(strtol(argv[++i], NULL, 16));
}
else if (arg == "-vu" || arg == "--verbose-unaccounted") // Verbose unaccounted
{
Globals::Instance->verboseUnaccounted = true;
}
else if (arg == "-se" || arg == "--set-exporter") // Set Current Exporter
{
Globals::Instance->currentExporter = argv[++i];
}
else if (arg == "--gcc-compat") // GCC compatibility
{
Globals::Instance->gccCompat = true;
}
else if (arg == "-s" || arg == "--static")
{
Globals::Instance->forceStatic = true;
}
else if (arg == "-us" || arg == "--unaccounted-static")
{
Globals::Instance->forceUnaccountedStatic = true;
}
}
ParseArgs(argc, argv);
// Parse File Mode
ExporterSet* exporterSet = Globals::Instance->GetExporterSet();
std::string buildMode = argv[1];
ZFileMode fileMode = ZFileMode::Invalid;
if (buildMode == "btex")
fileMode = ZFileMode::BuildTexture;
else if (buildMode == "bren")
fileMode = ZFileMode::BuildBackground;
else if (buildMode == "bsf")
fileMode = ZFileMode::BuildSourceFile;
else if (buildMode == "bblb")
fileMode = ZFileMode::BuildBlob;
else if (buildMode == "e")
fileMode = ZFileMode::Extract;
else if (exporterSet != nullptr && exporterSet->parseFileModeFunc != nullptr)
exporterSet->parseFileModeFunc(buildMode, fileMode);
ZFileMode fileMode = ParseFileMode(buildMode, exporterSet);
if (fileMode == ZFileMode::Invalid)
{
@@ -170,7 +98,6 @@ int main(int argc, char* argv[])
// We've parsed through our commands once. If an exporter exists, it's been set by now.
// Now we'll parse through them again but pass them on to our exporter if one is available.
if (exporterSet != nullptr && exporterSet->parseArgsFunc != nullptr)
{
for (int32_t i = 2; i < argc; i++)
@@ -181,62 +108,20 @@ int main(int argc, char* argv[])
printf("ZAPD: Zelda Asset Processor For Decomp: %s\n", gBuildHash);
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG)
{
WarningHandler::PrintWarningsDebugInfo();
}
// TODO: switch
if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile)
{
bool procFileModeSuccess = false;
if (exporterSet != nullptr && exporterSet->processFileModeFunc != nullptr)
procFileModeSuccess = exporterSet->processFileModeFunc(fileMode);
if (!procFileModeSuccess)
{
bool parseSuccessful;
for (auto& extFile : Globals::Instance->cfg.externalFiles)
{
fs::path externalXmlFilePath =
Globals::Instance->cfg.externalXmlFolder / extFile.xmlPath;
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO)
{
printf("Parsing external file from config: '%s'\n",
externalXmlFilePath.c_str());
}
parseSuccessful = Parse(externalXmlFilePath, Globals::Instance->baseRomPath,
extFile.outPath, ZFileMode::ExternalFile);
if (!parseSuccessful)
return 1;
}
parseSuccessful = Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath,
Globals::Instance->outputPath, fileMode);
if (!parseSuccessful)
return 1;
}
}
returnCode = HandleExtract(fileMode, exporterSet);
else if (fileMode == ZFileMode::BuildTexture)
{
TextureType texType = Globals::Instance->texType;
BuildAssetTexture(Globals::Instance->inputPath, texType, Globals::Instance->outputPath);
}
BuildAssetTexture(Globals::Instance->inputPath, Globals::Instance->texType,
Globals::Instance->outputPath);
else if (fileMode == ZFileMode::BuildBackground)
{
BuildAssetBackground(Globals::Instance->inputPath, Globals::Instance->outputPath);
}
else if (fileMode == ZFileMode::BuildBlob)
{
BuildAssetBlob(Globals::Instance->inputPath, Globals::Instance->outputPath);
}
delete g;
return 0;
return returnCode;
}
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath,
@@ -339,6 +224,209 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path
return true;
}
void ParseArgs(int& argc, char* argv[])
{
static const std::unordered_map<std::string, ArgFunc> ArgFuncDictionary = {
{"-o", &Arg_SetOutputPath},
{"--outputpath", &Arg_SetOutputPath},
{"-i", &Arg_SetInputPath},
{"--inputpath", &Arg_SetInputPath},
{"-b", &Arg_SetBaseromPath},
{"--baserompath", &Arg_SetBaseromPath},
{"-osf", &Arg_SetSourceOutputPath},
{"-gsf", &Arg_GenerateSourceFile},
{"-tm", &Arg_TestMode},
{"-ulzdl", &Arg_LegacyDList},
{"-profile", &Arg_EnableProfiling},
{"-uer", &Arg_UseExternalResources},
{"-tt", &Arg_SetTextureType},
{"-rconf", &Arg_ReadConfigFile},
{"-eh", &Arg_EnableErrorHandler},
{"-v", &Arg_SetVerbosity},
{"-vu", &Arg_VerboseUnaccounted},
{"--verbose-unaccounted", &Arg_VerboseUnaccounted},
{"-se", &Arg_SetExporter},
{"--set-exporter", &Arg_SetExporter},
{"--gcc-compat", &Arg_EnableGCCCompat},
{"-s", &Arg_ForceStatic},
{"--static", &Arg_ForceStatic},
{"-us", &Arg_ForceUnaccountedStatic},
{"--unaccounted-static", &Arg_ForceUnaccountedStatic},
};
for (int32_t i = 2; i < argc; i++)
{
std::string arg = argv[i];
// Ignore warning args as they have already been parsed
if (arg.length() > 2 && arg[0] == '-' && arg[1] == 'W' && arg[2] != '\0')
{
continue;
}
auto it = ArgFuncDictionary.find(arg);
if (it == ArgFuncDictionary.end())
{
fprintf(stderr, "Unsupported argument: %s\n", arg.c_str());
continue;
}
std::invoke(it->second, i, argv);
}
}
ZFileMode ParseFileMode(const std::string& buildMode, ExporterSet* exporterSet)
{
ZFileMode fileMode = ZFileMode::Invalid;
if (buildMode == "btex")
fileMode = ZFileMode::BuildTexture;
else if (buildMode == "bren")
fileMode = ZFileMode::BuildBackground;
else if (buildMode == "bsf")
fileMode = ZFileMode::BuildSourceFile;
else if (buildMode == "bblb")
fileMode = ZFileMode::BuildBlob;
else if (buildMode == "e")
fileMode = ZFileMode::Extract;
else if (exporterSet != nullptr && exporterSet->parseFileModeFunc != nullptr)
exporterSet->parseFileModeFunc(buildMode, fileMode);
return fileMode;
}
void Arg_SetOutputPath(int& i, [[maybe_unused]] char* argv[])
{
Globals::Instance->outputPath = argv[++i];
if (Globals::Instance->sourceOutputPath == "")
Globals::Instance->sourceOutputPath = Globals::Instance->outputPath;
}
void Arg_SetInputPath(int& i, char* argv[])
{
Globals::Instance->inputPath = argv[++i];
}
void Arg_SetBaseromPath(int& i, char* argv[])
{
Globals::Instance->baseRomPath = argv[++i];
}
void Arg_SetSourceOutputPath(int& i, char* argv[])
{
Globals::Instance->sourceOutputPath = argv[++i];
}
void Arg_GenerateSourceFile(int& i, char* argv[])
{
// Generate source file during extraction
Globals::Instance->genSourceFile = std::string_view(argv[++i]) == "1";
}
void Arg_TestMode(int& i, char* argv[])
{
// Test Mode (enables certain experimental features)
Globals::Instance->testMode = std::string_view(argv[++i]) == "1";
}
void Arg_LegacyDList(int& i, char* argv[])
{
Globals::Instance->useLegacyZDList = std::string_view(argv[++i]) == "1";
}
void Arg_EnableProfiling(int& i, char* argv[])
{
Globals::Instance->profile = std::string_view(argv[++i]) == "1";
}
void Arg_UseExternalResources(int& i, char* argv[])
{
// Split resources into their individual components(enabled by default)
// TODO: We may wish to make this a part of the config file...
Globals::Instance->useExternalResources = std::string_view(argv[++i]) == "1";
}
void Arg_SetTextureType(int& i, char* argv[])
{
Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[++i]);
}
void Arg_ReadConfigFile(int& i, char* argv[])
{
Globals::Instance->cfg.ReadConfigFile(argv[++i]);
}
void Arg_EnableErrorHandler([[maybe_unused]] int& i, [[maybe_unused]] char* argv[])
{
CrashHandler_Init();
}
void Arg_SetVerbosity(int& i, char* argv[])
{
Globals::Instance->verbosity = static_cast<VerbosityLevel>(strtol(argv[++i], NULL, 16));
}
void Arg_VerboseUnaccounted([[maybe_unused]] int& i, [[maybe_unused]] char* argv[])
{
Globals::Instance->verboseUnaccounted = true;
}
void Arg_SetExporter(int& i, char* argv[])
{
Globals::Instance->currentExporter = argv[++i];
}
void Arg_EnableGCCCompat([[maybe_unused]] int& i, [[maybe_unused]] char* argv[])
{
Globals::Instance->gccCompat = true;
}
void Arg_ForceStatic([[maybe_unused]] int& i, [[maybe_unused]] char* argv[])
{
Globals::Instance->forceStatic = true;
}
void Arg_ForceUnaccountedStatic([[maybe_unused]] int& i, [[maybe_unused]] char* argv[])
{
Globals::Instance->forceUnaccountedStatic = true;
}
int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet)
{
bool procFileModeSuccess = false;
if (exporterSet != nullptr && exporterSet->processFileModeFunc != nullptr)
procFileModeSuccess = exporterSet->processFileModeFunc(fileMode);
if (!procFileModeSuccess)
{
bool parseSuccessful;
for (auto& extFile : Globals::Instance->cfg.externalFiles)
{
fs::path externalXmlFilePath =
Globals::Instance->cfg.externalXmlFolder / extFile.xmlPath;
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO)
printf("Parsing external file from config: '%s'\n", externalXmlFilePath.c_str());
parseSuccessful = Parse(externalXmlFilePath, Globals::Instance->baseRomPath,
extFile.outPath, ZFileMode::ExternalFile);
if (!parseSuccessful)
return 1;
}
parseSuccessful = Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath,
Globals::Instance->outputPath, fileMode);
if (!parseSuccessful)
return 1;
}
return 0;
}
void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath)
{
std::string name = outPath.stem().string();
@@ -165,7 +165,7 @@ void Struct_800A598C::DeclareReferences(const std::string& prefix)
res.GetSourceTypeName(), unk_8_Str, arrayItemCnt, entryStr);
}
else
decl->text = entryStr;
decl->declBody = entryStr;
}
if (unk_C != 0 && GETSEGNUM(unk_C) == parent->segment)
@@ -195,7 +195,7 @@ void Struct_800A598C::DeclareReferences(const std::string& prefix)
res.GetSourceTypeName(), unk_C_Str, arrayItemCnt, entryStr);
}
else
decl->text = entryStr;
decl->declBody = entryStr;
}
}
@@ -296,7 +296,7 @@ void Struct_800A5E28::DeclareReferences(const std::string& prefix)
res.GetSourceTypeName(), unk_4_Str, arrayItemCnt, entryStr);
}
else
decl->text = entryStr;
decl->declBody = entryStr;
}
if (unk_8 != SEGMENTED_NULL && GETSEGNUM(unk_8) == parent->segment)
+1
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <map>
#include <string>
#include <vector>
+19 -15
View File
@@ -84,26 +84,27 @@ typedef struct
*/
// clang-format off
static const std::unordered_map<std::string, WarningInfoInit> warningStringToInitMap = {
{"deprecated", {WarningType::Deprecated,
{"deprecated", {WarningType::Deprecated,
#ifdef DEPRECATION_ON
WarningLevel::Warn,
#else
WarningLevel::Off,
#endif
"Deprecated features"}},
{"unaccounted", {WarningType::Unaccounted, WarningLevel::Off, "Large blocks of unaccounted"}},
{"missing-offsets", {WarningType::MissingOffsets, WarningLevel::Warn, "Offset attribute missing in XML tag"}},
{"intersection", {WarningType::Intersection, WarningLevel::Warn, "Two assets intersect"}},
{"missing-attribute", {WarningType::MissingAttribute, WarningLevel::Warn, "Required attribute missing in XML tag"}},
{"invalid-attribute-value", {WarningType::InvalidAttributeValue, WarningLevel::Err, "Attribute declared in XML is wrong"}},
{"unknown-attribute", {WarningType::UnknownAttribute, WarningLevel::Warn, "Unknown attribute in XML entry tag"}},
{"invalid-xml", {WarningType::InvalidXML, WarningLevel::Err, "XML has syntax errors"}},
{"invalid-jpeg", {WarningType::InvalidJPEG, WarningLevel::Err, "JPEG file does not conform to the game's format requirements"}},
{"invalid-png", {WarningType::InvalidPNG, WarningLevel::Err, "Issues arising when processing PNG data"}},
{"invalid-extracted-data", {WarningType::InvalidExtractedData, WarningLevel::Err, "Extracted data does not have correct form"}},
{"missing-segment", {WarningType::MissingSegment, WarningLevel::Warn, "Segment not given in File tag in XML"}},
{"hardcoded-pointer", {WarningType::HardcodedPointer, WarningLevel::Warn, "ZAPD lacks the info to make a symbol, so must output a hardcoded pointer"}},
{"not-implemented", {WarningType::NotImplemented, WarningLevel::Warn, "ZAPD does not currently support this feature"}},
{"unaccounted", {WarningType::Unaccounted, WarningLevel::Off, "Large blocks of unaccounted"}},
{"missing-offsets", {WarningType::MissingOffsets, WarningLevel::Warn, "Offset attribute missing in XML tag"}},
{"intersection", {WarningType::Intersection, WarningLevel::Warn, "Two assets intersect"}},
{"missing-attribute", {WarningType::MissingAttribute, WarningLevel::Warn, "Required attribute missing in XML tag"}},
{"invalid-attribute-value", {WarningType::InvalidAttributeValue, WarningLevel::Err, "Attribute declared in XML is wrong"}},
{"unknown-attribute", {WarningType::UnknownAttribute, WarningLevel::Warn, "Unknown attribute in XML entry tag"}},
{"invalid-xml", {WarningType::InvalidXML, WarningLevel::Err, "XML has syntax errors"}},
{"invalid-jpeg", {WarningType::InvalidJPEG, WarningLevel::Err, "JPEG file does not conform to the game's format requirements"}},
{"invalid-png", {WarningType::InvalidPNG, WarningLevel::Err, "Issues arising when processing PNG data"}},
{"invalid-extracted-data", {WarningType::InvalidExtractedData, WarningLevel::Err, "Extracted data does not have correct form"}},
{"missing-segment", {WarningType::MissingSegment, WarningLevel::Warn, "Segment not given in File tag in XML"}},
{"hardcoded-generic-pointer", {WarningType::HardcodedGenericPointer, WarningLevel::Off, "A generic segmented pointer must be produced"}},
{"hardcoded-pointer", {WarningType::HardcodedPointer, WarningLevel::Warn, "ZAPD lacks the info to make a symbol, so must output a hardcoded pointer"}},
{"not-implemented", {WarningType::NotImplemented, WarningLevel::Warn, "ZAPD does not currently support this feature"}},
};
/**
@@ -229,7 +230,10 @@ void WarningHandler::ExtractedFilePreamble(const ZFile *parent, const ZResource*
if (res != nullptr) {
fprintf(stderr, "resource '%s' at ", res->GetName().c_str());
}
fprintf(stderr, "offset 0x%06X: \n\t", offset);
if (offset != static_cast<uint32_t>(-1)) {
fprintf(stderr, "offset 0x%06X:", offset);
}
fprintf(stderr, "\n\t");
}
/**

Some files were not shown because too many files have changed in this diff Show More