diff --git a/include/port/byteswap.h b/include/port/byteswap.h index 4e65aa47..40f9efee 100644 --- a/include/port/byteswap.h +++ b/include/port/byteswap.h @@ -299,6 +299,25 @@ void byteswap_hsfbitmapkey(HsfBitmapKey32b *src, HsfBitmapKey *dest); void byteswap_hsftrack(HsfTrack32b *src, HsfTrack *dest); void byteswap_hsfmotion(HsfMotion32b *src, HsfMotion *dest); void byteswap_hsfface(HsfFace32b *src, HsfFace *dest); +void byteswap_hsfcluster(HsfCluster32b *src, HsfCluster *dest); +void byteswap_hsfattribute(HsfAttribute32b *src, HsfAttribute *dest); +void byteswap_hsfmaterial(HsfMaterial32b *src, HsfMaterial *dest); +void byteswap_hsfscene(HsfScene *src); +void byteswap_hsfbuffer(HsfBuffer32b *src, HsfBuffer *dest); +void byteswap_hsfmatrix(HsfMatrix *src); +void byteswap_hsfpalette(HsfPalette32b *src, HsfPalette *dest); +void byteswap_hsfpart(HsfPart32b *src, HsfPart *dest); +void byteswap_hsfbitmap(HsfBitmap32b *src, HsfBitmap *dest); +void byteswap_hsfmapattr(HsfMapAttr32b *src, HsfMapAttr *dest); +void byteswap_hsfskeleton(HsfSkeleton32b *src, HsfSkeleton *dest); +void byteswap_hsfshape(HsfShape32b *src, HsfShape *dest); +void byteswap_hsfcenv_single(HsfCenvSingle *src); +void byteswap_hsfcenv(HsfCenv32b *src, HsfCenv *dest); +void byteswap_hsfobject(HsfObject32b *src, HsfObject *dest); +void byteswap_hsfbitmapkey(HsfBitmapKey32b *src, HsfBitmapKey *dest); +void byteswap_hsftrack(HsfTrack32b *src, HsfTrack *dest); +void byteswap_hsfmotion(HsfMotion32b *src, HsfMotion *dest); +void byteswap_hsfface(HsfFace32b *src, HsfFace *dest); #ifdef __cplusplus } diff --git a/src/REL/bootDll/main.c b/src/REL/bootDll/main.c index 391a9065..3850bc7d 100644 --- a/src/REL/bootDll/main.c +++ b/src/REL/bootDll/main.c @@ -546,8 +546,6 @@ void ObjectSetup(void) s16 sprite; AnimData *sprite_data; s16 i; -#ifdef __MWERKS__ - // TODO PC titleMdlId[0] = model = Hu3DModelCreateFile(TITLE_CHAR_HSF); Hu3DModelAttrSet(model, HU3D_ATTR_DISPOFF); Hu3DModelAttrSet(model, HU3D_MOTATTR_LOOP); @@ -559,7 +557,6 @@ void ObjectSetup(void) Hu3DModelAttrSet(model, HU3D_MOTATTR_LOOP); Hu3DModelCameraInfoSet(model, 1); Hu3DModelLightInfoSet(model, 1); -#endif #if VERSION_NTSC bootGrpId = HuSprGrpCreate(4); #else diff --git a/src/game/hsfdraw.c b/src/game/hsfdraw.c index b304a7df..6aca1642 100755 --- a/src/game/hsfdraw.c +++ b/src/game/hsfdraw.c @@ -90,6 +90,7 @@ static u16 *faceNumBuf; static s32 DLTotalNum; static u32 totalSize; static uintptr_t mallocNo; +static uintptr_t mallocNo; static s32 curModelID; static s16 polySize; static s32 PGFinishF; diff --git a/src/port/byteswap.cpp b/src/port/byteswap.cpp index 86d73508..ac844e4b 100644 --- a/src/port/byteswap.cpp +++ b/src/port/byteswap.cpp @@ -1,4 +1,5 @@ #include "game/hsfformat.h" +#include "game/hsfformat.h" #include #include #include @@ -6,6 +7,7 @@ #include #include +extern "C" { extern "C" { #include "port/byteswap.h" } @@ -17,6 +19,7 @@ template [[nodiscard]] constexpr T bswap16(T val) noexcept u16 u; T t; } v { .t = val }; + } v { .t = val }; #if __GNUC__ v.u = __builtin_bswap16(v.u); #elif _WIN32 @@ -34,12 +37,14 @@ template [[nodiscard]] constexpr T bswap32(T val) noexcept u32 u; T t; } v { .t = val }; + } v { .t = val }; #if __GNUC__ v.u = __builtin_bswap32(v.u); #elif _WIN32 v.u = _byteswap_ulong(v.u); #else v.u = ((v.u & 0x0000FFFF) << 16) | ((v.u & 0xFFFF0000) >> 16) | ((v.u & 0x00FF00FF) << 8) | ((v.u & 0xFF00FF00) >> 8); + v.u = ((v.u & 0x0000FFFF) << 16) | ((v.u & 0xFFFF0000) >> 16) | ((v.u & 0x00FF00FF) << 8) | ((v.u & 0xFF00FF00) >> 8); #endif return v.t; } @@ -66,10 +71,12 @@ static std::unordered_set sVisitedPtrs; template T *offset_ptr(B &base, T *ptr) { return reinterpret_cast(reinterpret_cast(&base) + reinterpret_cast(ptr)); + return reinterpret_cast(reinterpret_cast(&base) + reinterpret_cast(ptr)); } template T *offset_ptr(B &base, T *ptr, void *extra) { return reinterpret_cast(reinterpret_cast(&base) + reinterpret_cast(ptr) + reinterpret_cast(extra)); + return reinterpret_cast(reinterpret_cast(&base) + reinterpret_cast(ptr) + reinterpret_cast(extra)); } // template static inline void bswap(B &base, T &data); @@ -116,6 +123,7 @@ template T *offset_ptr(B &base, T *ptr, void *extra) template void bswap_flat(B &base, T *start, s32 count) { T *objBase = start; + for (s32 i = 0; i < count; ++i) { for (s32 i = 0; i < count; ++i) { bswap(base, objBase[i]); } @@ -177,6 +185,13 @@ template void bswap(B &base, HsfVector3f &vec) bswap(base, vec.z); } +template void bswap(B &base, HsfVector3f &vec) +{ + bswap(base, vec.x); + bswap(base, vec.y); + bswap(base, vec.z); +} + template void bswap(B &base, AnimData32b &obj, AnimData &dest) { bswap(base, obj.bankNum); @@ -752,6 +767,19 @@ void byteswap_hsfvec2f(HsfVector2f *src) sVisitedPtrs.clear(); } +void byteswap_hsfvec3f(HsfVector3f *src) +{ + bswap(*src, *src); + sVisitedPtrs.clear(); +} + +void byteswap_hsfvec2f(HsfVector2f *src) +{ + auto *vec = reinterpret_cast(src); + bswap(*vec, *vec); + sVisitedPtrs.clear(); +} + void byteswap_animdata(void *src, AnimData *dest) { auto *anim = reinterpret_cast(src); @@ -909,4 +937,120 @@ void byteswap_hsfface(HsfFace32b *src, HsfFace *dest) { bswap(*src, *src, *dest); sVisitedPtrs.clear(); -} \ No newline at end of file +} + +void byteswap_hsfcluster(HsfCluster32b *src, HsfCluster *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfattribute(HsfAttribute32b *src, HsfAttribute *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfmaterial(HsfMaterial32b *src, HsfMaterial *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfscene(HsfScene *src) +{ + bswap(*src, *src); + sVisitedPtrs.clear(); +} + +void byteswap_hsfbuffer(HsfBuffer32b *src, HsfBuffer *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfmatrix(HsfMatrix *src) +{ + bswap(*src, *src); + sVisitedPtrs.clear(); +} + +void byteswap_hsfpalette(HsfPalette32b *src, HsfPalette *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfpart(HsfPart32b *src, HsfPart *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfbitmap(HsfBitmap32b *src, HsfBitmap *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfmapattr(HsfMapAttr32b *src, HsfMapAttr *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfskeleton(HsfSkeleton32b *src, HsfSkeleton *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfshape(HsfShape32b *src, HsfShape *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfcenv_single(HsfCenvSingle *src) +{ + bswap(*src, *src); + sVisitedPtrs.clear(); +} + +void byteswap_hsfcenv(HsfCenv32b *src, HsfCenv *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfobject(HsfObject32b *src, HsfObject *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + + +void byteswap_hsfbitmapkey(HsfBitmapKey32b *src, HsfBitmapKey *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + + +void byteswap_hsftrack(HsfTrack32b *src, HsfTrack *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfmotion(HsfMotion32b *src, HsfMotion *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +} + +void byteswap_hsfface(HsfFace32b *src, HsfFace *dest) +{ + bswap(*src, *src, *dest); + sVisitedPtrs.clear(); +}