From 71bbaab48551e9368d7ed1c57df193db8f18136e Mon Sep 17 00:00:00 2001 From: fig02 Date: Sat, 27 Mar 2021 23:57:14 -0400 Subject: [PATCH] git subrepo pull --force tools/ZAPD (#742) subrepo: subdir: "tools/ZAPD" merged: "c4773301a" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "c4773301a" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" --- tools/ZAPD/.gitrepo | 4 ++-- tools/ZAPD/ZAPD/ZAnimation.cpp | 14 ++++++++++++-- tools/ZAPD/ZAPD/ZAnimation.h | 4 ++++ tools/ZAPD/ZAPD/ZSkeleton.cpp | 6 +++++- tools/ZAPD/lib/libgfxd/.gitrepo | 12 ++++++++++++ tools/ZAPD/lib/libgfxd/gbi.h | 30 +++++++++++++++++++++-------- tools/ZAPD/lib/libgfxd/uc_macrofn.c | 17 ++++++++-------- 7 files changed, 66 insertions(+), 21 deletions(-) create mode 100644 tools/ZAPD/lib/libgfxd/.gitrepo diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 0fcc361bdb..a05cb306e6 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 4751db5c9ee0a25a26379ca5b44efad72215d256 - parent = 77ec4d491610620338e592a0f853b7c59af7fba5 + commit = c4773301a17a5a9f9c964a3e7ba6dfbf0730a94b + parent = 97f80eeb3f79bafac383fa6dd17765ae291e05d7 method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/ZAPD/ZAnimation.cpp b/tools/ZAPD/ZAPD/ZAnimation.cpp index 4ae07e1e53..417a26f75c 100644 --- a/tools/ZAPD/ZAPD/ZAnimation.cpp +++ b/tools/ZAPD/ZAPD/ZAnimation.cpp @@ -66,7 +66,7 @@ std::string ZNormalAnimation::GetSourceOutputCode(const std::string& prefix) string headerStr = StringHelper::Sprintf("{ %i }, %sFrameData, %sJointIndices, %i", frameCount, defaultPrefix.c_str(), defaultPrefix.c_str(), limit); - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, 16, "AnimationHeader", + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), GetSourceTypeName(), StringHelper::Sprintf("%s", name.c_str()), headerStr); string indicesStr = ""; @@ -111,6 +111,11 @@ int ZNormalAnimation::GetRawDataSize() return 16; } +std::string ZNormalAnimation::GetSourceTypeName() +{ + return "AnimationHeader"; +} + ZNormalAnimation* ZNormalAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, std::vector nRawData, int rawDataIndex, const std::string& nRelPath) @@ -170,7 +175,7 @@ std::string ZLinkAnimation::GetSourceOutputCode(const std::string& prefix) segmentAddress, StringHelper::Sprintf("%sSeg%06X", name.c_str(), segmentAddress)); string headerStr = StringHelper::Sprintf("{ %i }, 0x%08X", frameCount, segmentAddress); - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, 16, "LinkAnimationHeader", + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), GetSourceTypeName(), StringHelper::Sprintf("%s", name.c_str()), headerStr); } @@ -182,6 +187,11 @@ int ZLinkAnimation::GetRawDataSize() return 8; } +std::string ZLinkAnimation::GetSourceTypeName() +{ + return "LinkAnimationHeader"; +} + ZLinkAnimation* ZLinkAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, std::vector nRawData, int rawDataIndex, const std::string& nRelPath) diff --git a/tools/ZAPD/ZAPD/ZAnimation.h b/tools/ZAPD/ZAPD/ZAnimation.h index 71fbf2d109..2e69d7db04 100644 --- a/tools/ZAPD/ZAPD/ZAnimation.h +++ b/tools/ZAPD/ZAPD/ZAnimation.h @@ -51,6 +51,8 @@ public: std::string GetSourceOutputCode(const std::string& prefix) override; int GetRawDataSize() override; + std::string GetSourceTypeName() override; + static ZNormalAnimation* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector nRawData, int rawDataIndex, const std::string& nRelPath); @@ -69,6 +71,8 @@ public: std::string GetSourceOutputCode(const std::string& prefix) override; int GetRawDataSize() override; + std::string GetSourceTypeName() override; + static ZLinkAnimation* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector nRawData, int rawDataIndex, const std::string& nRelPath); diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index e100e2333a..85e22fbcb6 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -207,6 +207,10 @@ std::string ZSkeleton::GetSourceOutputCode(const std::string& prefix) { // Table string tblStr = ""; + string limbArrTypeStr = "static void*"; + if (limbType == ZLimbType::Curve) { + limbArrTypeStr = StringHelper::Sprintf("static %s*", ZLimb::GetSourceTypeName(limbType)); + } for (size_t i = 0; i < limbs.size(); i++) { @@ -222,7 +226,7 @@ std::string ZSkeleton::GetSourceOutputCode(const std::string& prefix) tblStr += decl; } - parent->AddDeclarationArray(ptr, DeclarationAlignment::None, 4 * limbCount, "static void*", + parent->AddDeclarationArray(ptr, DeclarationAlignment::None, 4 * limbCount, limbArrTypeStr, StringHelper::Sprintf("%sLimbs", defaultPrefix.c_str()), limbCount, tblStr); } diff --git a/tools/ZAPD/lib/libgfxd/.gitrepo b/tools/ZAPD/lib/libgfxd/.gitrepo new file mode 100644 index 0000000000..59040be776 --- /dev/null +++ b/tools/ZAPD/lib/libgfxd/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme +; +[subrepo] + remote = https://github.com/glankk/libgfxd.git + branch = master + commit = 2f00ff7dff14ae44c12ed421be54b9fec815541b + parent = a43a526c4296d7dc48852f6017fe069724465494 + method = merge + cmdver = 0.4.3 diff --git a/tools/ZAPD/lib/libgfxd/gbi.h b/tools/ZAPD/lib/libgfxd/gbi.h index e502ee9508..72df3584f6 100644 --- a/tools/ZAPD/lib/libgfxd/gbi.h +++ b/tools/ZAPD/lib/libgfxd/gbi.h @@ -1,5 +1,5 @@ /** - * gbi.h version 0.3.3 + * gbi.h version 0.3.4 * n64 graphics microcode interface library * compatible with fast3d, f3dex, f3dex2, s2dex, and s2dex2 * @@ -201,6 +201,10 @@ #define G_TX_LOADTILE 7 #define G_TX_RENDERTILE 0 +/* loadblock constants */ +#define G_TX_DXT_FRAC 11 +#define G_TX_LDBLK_MAX_TXL 2047 + /* geometry mode */ #define G_ZBUFFER (gI_(0b1) << 0) #define G_SHADE (gI_(0b1) << 2) @@ -1813,8 +1817,7 @@ gsDPLoadSync(), \ gsDPLoadBlock( \ G_TX_LOADTILE, 0, 0, \ - (((width) * (height) + 1) * G_SIZ_BITS(siz) - 1) / \ - G_SIZ_BITS(G_SIZ_LDSIZ(siz)) - 1, \ + G_LTB_LRS(width, height, siz), \ dxt), \ gsDPPipeSync(), \ gsDPSetTile( \ @@ -2112,7 +2115,7 @@ gF_(uls, 12, 12) | \ gF_(ult, 12, 0), \ gF_(tile, 3, 24) | \ - gF_(lrs, 12, 12) | \ + gF_(G_LDBLK_TXL(lrs), 12, 12) | \ gF_(dxt, 12, 0)) #define gsDPNoOp() \ @@ -3719,10 +3722,21 @@ typedef struct #define G_SIZ_LDBITS(siz) ((siz) < G_IM_SIZ_16b ? G_SIZ_BITS(siz) : 16) #define G_DXT(siz, width) \ ( \ - (width) * G_SIZ_BITS(siz) <= 64 ? \ - (1 << 11) : \ - ((1 << 11) + (width) * G_SIZ_BITS(siz) / 64 - 1) / \ - ((width) * G_SIZ_BITS(siz) / 64) \ + (width) * G_SIZ_BITS(siz) > 64 ? \ + ((1 << 11) + (width) * G_SIZ_BITS(siz) / 64 - 1) / \ + ((width) * G_SIZ_BITS(siz) / 64) : \ + (1 << 11) \ + ) +#define G_LTB_LRS(width, height, siz) \ + ( \ + (((width) * (height) + 1) * G_SIZ_BITS(siz) - 1) / \ + G_SIZ_BITS(G_SIZ_LDSIZ(siz)) - 1 \ + ) +#define G_LDBLK_TXL(txl) \ + ( \ + (txl) > G_TX_LDBLK_MAX_TXL ? \ + G_TX_LDBLK_MAX_TXL : \ + (txl) \ ) /* depth value macros */ diff --git a/tools/ZAPD/lib/libgfxd/uc_macrofn.c b/tools/ZAPD/lib/libgfxd/uc_macrofn.c index 707c0cbf5a..7baeb707b6 100644 --- a/tools/ZAPD/lib/libgfxd/uc_macrofn.c +++ b/tools/ZAPD/lib/libgfxd/uc_macrofn.c @@ -274,15 +274,10 @@ UCFUNC int c_ltb(gfxd_macro_t *m, int n_macro, int id, int mdxt, int mtmem, } int width = (argvu(&m[6], 3) >> 2) + 1; int height = (argvu(&m[6], 4) >> 2) + 1; - unsigned lrs = ((width * height + 1) * G_SIZ_BITS(siz) - 1) / - G_SIZ_BITS(G_SIZ_LDSIZ(siz)) - 1; + unsigned lrs = G_LDBLK_TXL(G_LTB_LRS(width, height, siz)); unsigned dxt = 0; if (!mdxt) - { - dxt = (width * G_SIZ_BITS(siz) <= 64 ? (1 << 11) : - ((1 << 11) + width * G_SIZ_BITS(siz) / 64 - 1) / - (width * G_SIZ_BITS(siz) / 64)); - } + dxt = G_DXT(siz, width); int line; if (myuv) line = (width + 7) / 8; @@ -592,7 +587,13 @@ UCFUNC int d_DPLoadBlock(gfxd_macro_t *m, uint32_t hi, uint32_t lo) argu(m, 2, "ult", getfield(hi, 12, 0), gfxd_Coordi); argu(m, 3, "lrs", getfield(lo, 12, 12), gfxd_Coordi); argu(m, 4, "dxt", getfield(lo, 12, 0), gfxd_Dxt); - return 0; + if (argvu(m, 3) > G_TX_LDBLK_MAX_TXL) { + badarg(m, 3); + return -1; + } + else { + return 0; + } } UCFUNC int d_DPNoOp(gfxd_macro_t *m, uint32_t hi, uint32_t lo)