Skip to content

Commit

Permalink
Update ZAPD (#1569)
Browse files Browse the repository at this point in the history
* 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!
  • Loading branch information
Dragorn421 authored Oct 25, 2023
1 parent 503f6d8 commit 4e55168
Show file tree
Hide file tree
Showing 97 changed files with 4,204 additions and 2,307 deletions.
4 changes: 0 additions & 4 deletions include/z64animation_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions include/z64bgcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 0 additions & 6 deletions include/z64curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions include/z64cutscene.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
46 changes: 0 additions & 46 deletions include/z64cutscene_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions include/z64environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions include/z64scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions include/z64skin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tools/ZAPD/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
Expand Down
6 changes: 3 additions & 3 deletions tools/ZAPD/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions tools/ZAPD/ExporterTest/CollisionExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/ZAPD/ExporterTest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tools/ZAPD/ExporterTest/RoomExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 18 additions & 1 deletion tools/ZAPD/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
35 changes: 18 additions & 17 deletions tools/ZAPD/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion tools/ZAPD/ZAPD/CRC32.h
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions tools/ZAPD/ZAPD/CrashHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#endif

#include <array>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <ctime>
Expand Down
Loading

0 comments on commit 4e55168

Please sign in to comment.