mirror of
https://github.com/HackerN64/HackerOoT.git
synced 2026-01-21 10:37:37 -08:00
Update ZAPD (#1569)
* git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "094e79734" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "094e79734" git-subrepo: version: "0.4.6" origin: "https://github.com/ingydotnet/git-subrepo" commit: "110b9eb" * Add EnumData.xml where some names are now externalized * Remove legacy typedefs for zapd, no longer needed!
This commit is contained in:
@@ -21,10 +21,6 @@ typedef struct {
|
||||
/* 0x0A */ s16 z;
|
||||
} LegacyJointKey; // size = 0x0C
|
||||
|
||||
// ZAPD compatibility typedefs
|
||||
// TODO: Remove when ZAPD adds support for them
|
||||
typedef LegacyJointKey JointKey;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ s16 frameCount;
|
||||
/* 0x02 */ s16 limbCount;
|
||||
|
||||
@@ -72,10 +72,6 @@ typedef struct {
|
||||
/* 0x4 */ Vec3s* bgCamFuncData; // s16 data grouped in threes (ex. Vec3s), is usually of type `BgCamFuncData`, but can be a list of points of type `Vec3s` for crawlspaces
|
||||
} BgCamInfo; // size = 0x8
|
||||
|
||||
// ZAPD compatibility typedefs
|
||||
// TODO: Remove when ZAPD adds support for them
|
||||
typedef BgCamInfo CamData;
|
||||
|
||||
// The structure used for all instances of s16 data from `BgCamInfo` with the exception of crawlspaces.
|
||||
// See `Camera_Subj4` for Vec3s data usage in crawlspaces
|
||||
typedef struct {
|
||||
|
||||
@@ -59,10 +59,4 @@ s32 SkelCurve_Update(struct PlayState* play, SkelCurve* skelCurve);
|
||||
void SkelCurve_Draw(Actor* actor, struct PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw,
|
||||
PostCurveLimbDraw postLimbDraw, s32 lod, void* data);
|
||||
|
||||
// ZAPD compatibility typedefs
|
||||
// TODO: Remove when ZAPD adds support for them
|
||||
typedef CurveInterpKnot TransformData;
|
||||
typedef CurveAnimationHeader TransformUpdateIndex;
|
||||
typedef CurveSkeletonHeader SkelCurveLimbList;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -494,10 +494,6 @@ typedef union {
|
||||
#define CS_CAM_CONTINUE 0
|
||||
#define CS_CAM_STOP -1
|
||||
|
||||
// todo: remove after ZAPD is updated
|
||||
#define CS_CMD_CONTINUE CS_CAM_CONTINUE
|
||||
#define CS_CMD_STOP CS_CAM_STOP
|
||||
|
||||
#define CS_CAM_DATA_NOT_APPLIED 0xFFFF
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -271,50 +271,4 @@
|
||||
CMD_W(unk1), CMD_W(unk2), CMD_W(unk3), CMD_W(unk4), CMD_W(unk5), CMD_W(unk6), \
|
||||
CMD_W(unk7), CMD_W(unk8), CMD_W(unk9), CMD_W(unk10), CMD_W(unk11), CMD_W(unk12)
|
||||
|
||||
// TODO: Fix ZAPD and delete these (everything to the end of the file)
|
||||
#define CS_CAM_POS_LIST CS_CAM_EYE_SPLINE
|
||||
#define CS_CAM_POS CS_CAM_POINT
|
||||
#define CS_CAM_FOCUS_POINT_LIST CS_CAM_AT_SPLINE
|
||||
#define CS_CAM_FOCUS_POINT CS_CAM_POINT
|
||||
#define CS_CAM_POS_PLAYER_LIST CS_CAM_EYE_SPLINE_REL_TO_PLAYER
|
||||
#define CS_CAM_POS_PLAYER CS_CAM_POINT
|
||||
#define CS_CAM_FOCUS_POINT_PLAYER_LIST CS_CAM_AT_SPLINE_REL_TO_PLAYER
|
||||
#define CS_CAM_FOCUS_POINT_PLAYER CS_CAM_POINT
|
||||
#define CS_NPC_ACTION_LIST CS_ACTOR_CUE_LIST
|
||||
#define CS_NPC_ACTION CS_ACTOR_CUE
|
||||
#define CS_PLAYER_ACTION_LIST CS_PLAYER_CUE_LIST
|
||||
#define CS_PLAYER_ACTION CS_PLAYER_CUE
|
||||
#define CS_LIGHTING_LIST CS_LIGHT_SETTING_LIST
|
||||
#define CS_CMD_09_LIST CS_RUMBLE_CONTROLLER_LIST
|
||||
#define CS_CMD_09 CS_RUMBLE_CONTROLLER
|
||||
#define CS_TEXT_DISPLAY_TEXTBOX CS_TEXT
|
||||
#define CS_TEXT_LEARN_SONG CS_TEXT_OCARINA_ACTION
|
||||
#define CS_SCENE_TRANS_FX CS_TRANSITION
|
||||
#define CS_PLAY_BGM_LIST CS_START_SEQ_LIST
|
||||
#define CS_STOP_BGM_LIST CS_STOP_SEQ_LIST
|
||||
#define CS_FADE_BGM_LIST CS_FADE_OUT_SEQ_LIST
|
||||
#define CS_FADE_BGM CS_FADE_OUT_SEQ
|
||||
#define CS_TERMINATOR CS_DESTINATION
|
||||
|
||||
// CS_TIME macro:
|
||||
// The last argument of the macro was removed, but ZAPD isn't aware
|
||||
// Passing 6 arguments to a 5-arguments macro works fine with IDO, so ignore this hack for IDO
|
||||
#ifndef __sgi
|
||||
// Only spot06_scene uses CS_TIME. Limit the hack to that file, so everything else can use the new macro
|
||||
# ifdef SPOT06_SCENE_H
|
||||
# undef CS_TIME
|
||||
# define CS_TIME(unused0, startFrame, endFrame, hour, min, _unusedZapdCompatibilityArg) \
|
||||
CMD_HH(unused0, startFrame), CMD_HBB(endFrame, hour, min), CMD_W(0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define CS_PLAY_BGM(seqId, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \
|
||||
CS_START_SEQ((seqId)-1, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7)
|
||||
|
||||
#define CS_STOP_BGM(seqId, frame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7, unused8) \
|
||||
CS_STOP_SEQ((seqId)-1, frame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7, unused8)
|
||||
|
||||
#define CS_LIGHTING(lightSetting, frame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7, unused8) \
|
||||
CS_LIGHT_SETTING((lightSetting)-1, frame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7, unused8)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -166,10 +166,6 @@ typedef struct {
|
||||
/* 0x14 */ s16 zFar;
|
||||
} EnvLightSettings; // size = 0x16
|
||||
|
||||
// ZAPD compatibility typedefs
|
||||
// TODO: Remove when ZAPD adds support for them
|
||||
typedef EnvLightSettings LightSettings;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ char unk_00[0x02];
|
||||
/* 0x02 */ u16 sceneTimeSpeed; // time speed value from the scene file
|
||||
|
||||
@@ -38,9 +38,6 @@ typedef struct {
|
||||
/* 0x01 */ u8 room;
|
||||
} Spawn;
|
||||
|
||||
// TODO: ZAPD Compatibility
|
||||
typedef Spawn EntranceEntry;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 count; // number of points in the path
|
||||
/* 0x04 */ Vec3s* points; // Segment Address to the array of points
|
||||
@@ -142,17 +139,6 @@ typedef union {
|
||||
RoomShapeCullable cullable;
|
||||
} RoomShape; // "Ground Shape"
|
||||
|
||||
// ZAPD compatibility typedefs
|
||||
// TODO: Remove when ZAPD adds support for them
|
||||
typedef RoomShapeDListsEntry PolygonDlist;
|
||||
typedef RoomShapeNormal PolygonType0;
|
||||
typedef RoomShapeImageSingle MeshHeader1Single;
|
||||
typedef RoomShapeImageMultiBgEntry BgImage;
|
||||
typedef RoomShapeImageMulti MeshHeader1Multi;
|
||||
typedef RoomShapeCullableEntry PolygonDlist2;
|
||||
typedef RoomShapeCullable PolygonType2;
|
||||
#define SCENE_CMD_MESH SCENE_CMD_ROOM_SHAPE
|
||||
|
||||
#define ROOM_DRAW_OPA (1 << 0)
|
||||
#define ROOM_DRAW_XLU (1 << 1)
|
||||
|
||||
@@ -459,7 +445,6 @@ typedef enum {
|
||||
#define SCENE_CAM_TYPE_SHOOTING_GALLERY 0x50 // Unreferenced in code, and used only by the main layer of the shooting gallery scene
|
||||
|
||||
// navi hints
|
||||
// TODO: make ZAPD use this enum for `SCENE_CMD_SPECIAL_FILES`
|
||||
typedef enum {
|
||||
NAVI_QUEST_HINTS_NONE,
|
||||
NAVI_QUEST_HINTS_OVERWORLD,
|
||||
|
||||
@@ -43,13 +43,6 @@ typedef struct {
|
||||
/* 0x08 */ Gfx* dlist;
|
||||
} SkinAnimatedLimbData; // size = 0xC
|
||||
|
||||
// ZAPD compatibility typedefs
|
||||
// TODO: Remove when ZAPD adds support for them
|
||||
typedef SkinVertex Struct_800A57C0;
|
||||
typedef SkinTransformation Struct_800A598C_2;
|
||||
typedef SkinAnimatedLimbData Struct_800A5E28;
|
||||
typedef SkinLimbModif Struct_800A598C;
|
||||
|
||||
#define SKIN_LIMB_TYPE_ANIMATED 4
|
||||
#define SKIN_LIMB_TYPE_NORMAL 11
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortIncludes: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[subrepo]
|
||||
remote = https://github.com/zeldaret/ZAPD.git
|
||||
branch = master
|
||||
commit = dcf56d93ecbd4db3bfd8a4832d7f991467964b98
|
||||
parent = 9bad1d108e6311562c8424eefc92f0f1004551c9
|
||||
commit = 094e797349c86d0baef4a624962f4287aefdfef2
|
||||
parent = 503f6d86d5fca5bd234640ef9de597d413cb91f5
|
||||
method = merge
|
||||
cmdver = 0.4.5
|
||||
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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter*
|
||||
uint32_t oldOffset = writer->GetBaseAddress();
|
||||
writer->Seek(baseStreamEnd, SeekOffsetType::Start);
|
||||
|
||||
for (EntranceEntry entry : cmdEntrance->entrances)
|
||||
for (Spawn entry : cmdEntrance->entrances)
|
||||
{
|
||||
writer->Write((uint8_t)entry.startPositionIndex);
|
||||
writer->Write((uint8_t)entry.roomToLoad);
|
||||
|
||||
@@ -8,6 +8,18 @@ COPYCHECK_ARGS ?=
|
||||
LLD ?= 0
|
||||
WERROR ?= 0
|
||||
|
||||
# On MacOS 10.14, use boost::filesystem, because
|
||||
# the system doesn't supply std::filesystem.
|
||||
ifneq ($(OS),Windows_NT)
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
MACOS_VERSION := $(shell sw_vers -productVersion | cut -d . -f 1,2)
|
||||
ifeq ($(MACOS_VERSION),10.14)
|
||||
USE_BOOST_FS ?= 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
USE_BOOST_FS ?= 0
|
||||
|
||||
# Use clang++ if available, else use g++
|
||||
ifeq ($(shell command -v clang++ >/dev/null 2>&1; echo $$?),0)
|
||||
CXX := clang++
|
||||
@@ -46,6 +58,11 @@ endif
|
||||
|
||||
LDFLAGS := -lm -ldl -lpng
|
||||
|
||||
ifneq ($(USE_BOOST_FS),0)
|
||||
CXXFLAGS += -DUSE_BOOST_FS
|
||||
LDFLAGS += -lboost_filesystem
|
||||
endif
|
||||
|
||||
# Use LLD if available. Set LLD=0 to not use it
|
||||
ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0)
|
||||
LLD := 1
|
||||
@@ -106,7 +123,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
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ to install it via Homebrew.
|
||||
|
||||
#### Linux / *nix
|
||||
|
||||
ZAPD uses the clasic `Makefile` approach. To build just run `make` (or even better `make -j` for faster compilations).
|
||||
ZAPD uses the classic `Makefile` approach. To build just run `make` (or even better `make -j` for faster compilations).
|
||||
|
||||
You can configure a bit your ZAPD build with the following options:
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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
tools/ZAPD/ZAPD/ExporterSet.h
Normal file
24
tools/ZAPD/ZAPD/ExporterSet.h
Normal 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;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user