Some x64 improvements

This commit is contained in:
dbalatoni13 2025-04-11 18:27:23 +02:00
parent dfc51f4912
commit 9e062adfa4
9 changed files with 135 additions and 116 deletions

View file

@ -98,4 +98,4 @@ After you got the GameCube build up and running for `GMPE01_00`:
``` ```
Linux and MacOS, and x64 support is coming later. Linux and MacOS, and x64 support is coming later.
- Open the solution in Visual Studio and build. [Fix for UtilsVulkan.h](https://github.com/encounter/dawn-cmake/blob/f10e70a26db00bb89f88be4204cf49ffc869e194/src/dawn/native/vulkan/UtilsVulkan.h#L128-L132) - Open the solution in Visual Studio and build.

View file

@ -104,7 +104,7 @@ struct model_data {
u16 unk_26; u16 unk_26;
u16 unk_28[8]; u16 unk_28[8];
s16 unk_38[8]; s16 unk_38[8];
u32 unk_48; uintptr_t unk_48;
u32 unk_4C; u32 unk_4C;
u32 attr; u32 attr;
u32 motion_attr; u32 motion_attr;

View file

@ -134,20 +134,20 @@ typedef struct _JUMP_BUFFER {
#endif #endif
#if defined(_M_IX86) || defined(__i386__) #if defined(_M_IX86) || defined(__i386__)
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Eip = (size_t)func #define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Eip = (uintptr_t)func
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Esp = (size_t)sp #define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Esp = (uintptr_t)sp
#elif defined(_M_X64) || defined(__x86_64__) #elif defined(_M_X64) || defined(__x86_64__)
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Rip = (size_t)func #define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Rip = (uintptr_t)func
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Rsp = (size_t)sp #define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Rsp = (uintptr_t)sp
#elif defined(_M_ARM) || defined(__arm__) #elif defined(_M_ARM) || defined(__arm__)
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Pc = (size_t)func #define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Pc = (uintptr_t)func
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Sp = (size_t)sp #define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Sp = (uintptr_t)sp
#elif defined(_M_ARM64) || defined(__aarch64__) #elif defined(_M_ARM64) || defined(__aarch64__)
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Lr = (size_t)func #define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Lr = (uintptr_t)func
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Sp = (size_t)sp #define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Sp = (uintptr_t)sp
#elif defined(__riscv) #elif defined(__riscv)
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->ra = (size_t)func #define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->ra = (uintptr_t)func
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->sp = (size_t)sp #define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->sp = (uintptr_t)sp
#endif #endif
#else #else

View file

@ -26,7 +26,7 @@ typedef struct process {
u16 stat; u16 stat;
u16 prio; u16 prio;
s32 sleep_time; s32 sleep_time;
u32 base_sp; uintptr_t base_sp;
jmp_buf jump; jmp_buf jump;
void (*dtor)(void); void (*dtor)(void);
void *user_data; void *user_data;

View file

@ -145,7 +145,7 @@ typedef struct HsfObjectData32b {
float baseMorph; float baseMorph;
float morphWeight[33]; float morphWeight[33];
} mesh; } mesh;
struct hsf_object *replica; u32 replica;
}; };
u32 face; u32 face;

View file

@ -1842,7 +1842,9 @@ static s32 LoadTexture(ModelData *arg0, HsfBitmap *arg1, HsfAttribute *arg2, s16
GXLoadTexObj(&sp1C, arg3); GXLoadTexObj(&sp1C, arg3);
#ifdef TARGET_PC #ifdef TARGET_PC
GXDestroyTexObj(&sp1C); GXDestroyTexObj(&sp1C);
GXDestroyTlutObj(&sp10); if (arg1->dataFmt == 9 || arg1->dataFmt == 10 || arg1->dataFmt == 11) {
GXDestroyTlutObj(&sp10);
}
#endif #endif
} }
@ -2579,6 +2581,9 @@ static void MDFaceDraw(HsfObject *arg0, HsfFace *arg1) {
GXTexCoord1x16(arg1->indices[1][3]); GXTexCoord1x16(arg1->indices[1][3]);
} }
} }
#ifdef TARGET_PC
GXEnd();
#endif
faceCnt = faceNumBuf[drawCnt] / 3; faceCnt = faceNumBuf[drawCnt] / 3;
break; break;
case 3: case 3:
@ -2649,6 +2654,9 @@ static void MDFaceDraw(HsfObject *arg0, HsfFace *arg1) {
GXTexCoord1x16(arg1->indices[1][3]); GXTexCoord1x16(arg1->indices[1][3]);
} }
} }
#ifdef TARGET_PC
GXEnd();
#endif
faceCnt = faceNumBuf[drawCnt] / 4; faceCnt = faceNumBuf[drawCnt] / 4;
break; break;
case 4: case 4:
@ -2720,6 +2728,9 @@ static void MDFaceDraw(HsfObject *arg0, HsfFace *arg1) {
GXTexCoord1x16(var_r24[3]); GXTexCoord1x16(var_r24[3]);
} }
} }
#ifdef TARGET_PC
GXEnd();
#endif
faceCnt = arg1->strip.count + 1; faceCnt = arg1->strip.count + 1;
break; break;
} }

View file

@ -5,9 +5,11 @@
#include "game/hsfdraw.h" #include "game/hsfdraw.h"
#include "game/hsfman.h" #include "game/hsfman.h"
#include "game/object.h" #include "game/object.h"
#include <game/sprite.h>
#include "game/pad.h" #include "game/pad.h"
#include "game/printfunc.h" #include "game/printfunc.h"
#define OM_OVL_HIS_MAX 16 #define OM_OVL_HIS_MAX 16
#define OM_MAX_GROUPS 10 #define OM_MAX_GROUPS 10

View file

@ -109,47 +109,47 @@ template <typename B, typename T> T *offset_ptr(B &base, T *ptr, void *extra)
return reinterpret_cast<T *>(reinterpret_cast<uintptr_t>(&base) + reinterpret_cast<uintptr_t>(ptr) + reinterpret_cast<uintptr_t>(extra)); return reinterpret_cast<T *>(reinterpret_cast<uintptr_t>(&base) + reinterpret_cast<uintptr_t>(ptr) + reinterpret_cast<uintptr_t>(extra));
} }
template <typename B, typename T> static inline void bswap(B &base, T &data); // template <typename B, typename T> static inline void bswap(B &base, T &data);
template <typename B, typename P> void bswap(B &base, P *&ptr) // template <typename B, typename P> void bswap(B &base, P *&ptr)
{ // {
ptr = bswap32(ptr); // ptr = bswap32(ptr);
} // }
template <typename B, typename T> void bswap(B &base, T *&ptr, s32 count) // template <typename B, typename T> void bswap(B &base, T *&ptr, s32 count)
{ // {
ptr = bswap32(ptr); // ptr = bswap32(ptr);
if (ptr == nullptr) { // if (ptr == nullptr) {
return; // return;
} // }
T *objBase = offset_ptr(base, ptr); // T *objBase = offset_ptr(base, ptr);
for (s32 i = 0; i < count; ++i) { // for (s32 i = 0; i < count; ++i) {
if (sVisitedPtrs.contains(objBase)) { // if (sVisitedPtrs.contains(objBase)) {
continue; // continue;
} // }
sVisitedPtrs.insert(objBase); // sVisitedPtrs.insert(objBase);
bswap(base, *objBase); // bswap(base, *objBase);
++objBase; // ++objBase;
} // }
} // }
template <typename B, typename T> void bswap_list(B &base, T **&ptr) // template <typename B, typename T> void bswap_list(B &base, T **&ptr)
{ // {
ptr = bswap32(ptr); // ptr = bswap32(ptr);
if (ptr == nullptr) { // if (ptr == nullptr) {
return; // return;
} // }
T **objBase = offset_ptr(base, ptr); // T **objBase = offset_ptr(base, ptr);
while (*objBase != nullptr) { // while (*objBase != nullptr) {
bswap(base, *objBase, 1); // bswap(base, *objBase, 1);
++objBase; // ++objBase;
} // }
} // }
template <typename B, typename T> void bswap_list(B &base, T *(&ptr)[]) // template <typename B, typename T> void bswap_list(B &base, T *(&ptr)[])
{ // {
T **objBase = ptr; // T **objBase = ptr;
while (*objBase != nullptr) { // while (*objBase != nullptr) {
bswap(base, *objBase, 1); // bswap(base, *objBase, 1);
++objBase; // ++objBase;
} // }
} // }
template <typename B, typename T> void bswap_flat(B &base, T *start, s32 count) template <typename B, typename T> void bswap_flat(B &base, T *start, s32 count)
{ {
T *objBase = start; T *objBase = start;
@ -228,9 +228,9 @@ template <typename B> void bswap(B &base, AnimData32b &obj, AnimData &dest)
dest.patNum = obj.patNum; dest.patNum = obj.patNum;
dest.bmpNum = obj.bmpNum; dest.bmpNum = obj.bmpNum;
dest.useNum = obj.useNum; dest.useNum = obj.useNum;
dest.bank = reinterpret_cast<AnimBankData *>(obj.bank); dest.bank = reinterpret_cast<AnimBankData *>(static_cast<uintptr_t>(obj.bank));
dest.pat = reinterpret_cast<AnimPatData *>(obj.pat); dest.pat = reinterpret_cast<AnimPatData *>(static_cast<uintptr_t>(obj.pat));
dest.bmp = reinterpret_cast<AnimBmpData *>(obj.bmp); dest.bmp = reinterpret_cast<AnimBmpData *>(static_cast<uintptr_t>(obj.bmp));
} }
template <typename B> void bswap(B &base, AnimBankData32b &obj, AnimBankData &dest) template <typename B> void bswap(B &base, AnimBankData32b &obj, AnimBankData &dest)
@ -241,7 +241,7 @@ template <typename B> void bswap(B &base, AnimBankData32b &obj, AnimBankData &de
dest.timeNum = obj.timeNum; dest.timeNum = obj.timeNum;
dest.unk = obj.unk; dest.unk = obj.unk;
dest.frame = reinterpret_cast<AnimFrameData *>(obj.frame); dest.frame = reinterpret_cast<AnimFrameData *>(static_cast<uintptr_t>(obj.frame));
} }
template <typename B> void bswap(B &base, AnimPatData32b &obj, AnimPatData &dest) template <typename B> void bswap(B &base, AnimPatData32b &obj, AnimPatData &dest)
@ -258,7 +258,7 @@ template <typename B> void bswap(B &base, AnimPatData32b &obj, AnimPatData &dest
dest.centerY = obj.centerY; dest.centerY = obj.centerY;
dest.sizeX = obj.sizeX; dest.sizeX = obj.sizeX;
dest.sizeY = obj.sizeY; dest.sizeY = obj.sizeY;
dest.layer = reinterpret_cast<AnimLayerData *>(obj.layer); dest.layer = reinterpret_cast<AnimLayerData *>(static_cast<uintptr_t>(obj.layer));
} }
template <typename B> void bswap(B &base, AnimBmpData32b &obj, AnimBmpData &dest) template <typename B> void bswap(B &base, AnimBmpData32b &obj, AnimBmpData &dest)
@ -278,8 +278,8 @@ template <typename B> void bswap(B &base, AnimBmpData32b &obj, AnimBmpData &dest
dest.sizeX = obj.sizeX; dest.sizeX = obj.sizeX;
dest.sizeY = obj.sizeY; dest.sizeY = obj.sizeY;
dest.dataSize = obj.dataSize; dest.dataSize = obj.dataSize;
dest.palData = reinterpret_cast<void *>(obj.palData); dest.palData = reinterpret_cast<void *>(static_cast<uintptr_t>(obj.palData));
dest.data = reinterpret_cast<void *>(obj.data); dest.data = reinterpret_cast<void *>(static_cast<uintptr_t>(obj.data));
} }
template <typename B> void bswap(B &base, AnimFrameData &obj) template <typename B> void bswap(B &base, AnimFrameData &obj)
@ -349,10 +349,10 @@ template <typename B> void bswap(B &base, HsfCluster32b &obj, HsfCluster &dest)
bswap(base, obj.vertexCnt); bswap(base, obj.vertexCnt);
bswap(base, obj.vertex); bswap(base, obj.vertex);
dest.name[0] = reinterpret_cast<char *>(obj.name[0]); dest.name[0] = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name[0]));
dest.name[1] = reinterpret_cast<char *>(obj.name[1]); dest.name[1] = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name[1]));
dest.targetName = reinterpret_cast<char *>(obj.targetName); dest.targetName = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.targetName));
dest.index = obj.index; dest.index = obj.index;
std::copy(std::begin(obj.weight), std::end(obj.weight), dest.weight); std::copy(std::begin(obj.weight), std::end(obj.weight), dest.weight);
@ -360,7 +360,7 @@ template <typename B> void bswap(B &base, HsfCluster32b &obj, HsfCluster &dest)
dest.unk95 = obj.unk95; dest.unk95 = obj.unk95;
dest.type = obj.type; dest.type = obj.type;
dest.vertexCnt = obj.vertexCnt; dest.vertexCnt = obj.vertexCnt;
dest.vertex = reinterpret_cast<HsfBuffer **>(obj.vertex); dest.vertex = reinterpret_cast<HsfBuffer **>(static_cast<uintptr_t>(obj.vertex));
} }
template <typename B> void bswap(B &base, HsfAttribute32b &obj, HsfAttribute &dest) template <typename B> void bswap(B &base, HsfAttribute32b &obj, HsfAttribute &dest)
@ -380,8 +380,8 @@ template <typename B> void bswap(B &base, HsfAttribute32b &obj, HsfAttribute &de
bswap(base, obj.flag); bswap(base, obj.flag);
bswap(base, obj.bitmap); bswap(base, obj.bitmap);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.unk04 = reinterpret_cast<struct hsfdraw_struct_01 *>(obj.unk04); dest.unk04 = reinterpret_cast<struct hsfdraw_struct_01 *>(static_cast<uintptr_t>(obj.unk04));
std::copy(std::begin(obj.unk8), std::end(obj.unk8), dest.unk8); std::copy(std::begin(obj.unk8), std::end(obj.unk8), dest.unk8);
dest.unk0C = obj.unk0C; dest.unk0C = obj.unk0C;
std::copy(std::begin(obj.unk10), std::end(obj.unk10), dest.unk10); std::copy(std::begin(obj.unk10), std::end(obj.unk10), dest.unk10);
@ -399,7 +399,7 @@ template <typename B> void bswap(B &base, HsfAttribute32b &obj, HsfAttribute &de
std::copy(std::begin(obj.unk6C), std::end(obj.unk6C), dest.unk6C); std::copy(std::begin(obj.unk6C), std::end(obj.unk6C), dest.unk6C);
dest.unk78 = obj.unk78; dest.unk78 = obj.unk78;
dest.flag = obj.flag; dest.flag = obj.flag;
dest.bitmap = reinterpret_cast<HsfBitmap *>(obj.bitmap); dest.bitmap = reinterpret_cast<HsfBitmap *>(static_cast<uintptr_t>(obj.bitmap));
} }
template <typename B> void bswap(B &base, HsfMaterial32b &obj, HsfMaterial &dest) template <typename B> void bswap(B &base, HsfMaterial32b &obj, HsfMaterial &dest)
@ -416,7 +416,7 @@ template <typename B> void bswap(B &base, HsfMaterial32b &obj, HsfMaterial &dest
bswap(base, obj.numAttrs); bswap(base, obj.numAttrs);
bswap(base, obj.attrs); bswap(base, obj.attrs);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
std::copy(std::begin(obj.unk4), std::end(obj.unk4), dest.unk4); std::copy(std::begin(obj.unk4), std::end(obj.unk4), dest.unk4);
dest.pass = obj.pass; dest.pass = obj.pass;
dest.vtxMode = obj.vtxMode; dest.vtxMode = obj.vtxMode;
@ -431,7 +431,7 @@ template <typename B> void bswap(B &base, HsfMaterial32b &obj, HsfMaterial &dest
dest.unk2C = obj.unk2C; dest.unk2C = obj.unk2C;
dest.flags = obj.flags; dest.flags = obj.flags;
dest.numAttrs = obj.numAttrs; dest.numAttrs = obj.numAttrs;
dest.attrs = reinterpret_cast<s32 *>(obj.attrs); dest.attrs = reinterpret_cast<s32 *>(static_cast<uintptr_t>(obj.attrs));
} }
template <typename B> void bswap(B &base, HsfScene &obj) template <typename B> void bswap(B &base, HsfScene &obj)
@ -449,9 +449,9 @@ template <typename B> void bswap(B &base, HsfBuffer32b &obj, HsfBuffer &dest)
bswap(base, obj.count); bswap(base, obj.count);
bswap(base, obj.data); bswap(base, obj.data);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.count = obj.count; dest.count = obj.count;
dest.data = reinterpret_cast<void *>(obj.data); dest.data = reinterpret_cast<void *>(static_cast<uintptr_t>(obj.data));
} }
template <typename B> void bswap(B &base, HsfMatrix &obj) template <typename B> void bswap(B &base, HsfMatrix &obj)
@ -459,7 +459,7 @@ template <typename B> void bswap(B &base, HsfMatrix &obj)
bswap(base, obj.base_idx); bswap(base, obj.base_idx);
bswap(base, obj.count); bswap(base, obj.count);
obj.data = (Mtx *)((uintptr_t)&obj + sizeof(0xC)); // hardcoded for 64 bit support obj.data = reinterpret_cast<Mtx *>(reinterpret_cast<uintptr_t>(&obj) + 0xC); // hardcoded for 64 bit support
for (s32 i = 0; i < obj.count; i++) { for (s32 i = 0; i < obj.count; i++) {
for (s32 j = 0; j < 3; j++) { for (s32 j = 0; j < 3; j++) {
bswap_flat(base, obj.data[i][j], 4); bswap_flat(base, obj.data[i][j], 4);
@ -474,10 +474,10 @@ template <typename B> void bswap(B &base, HsfPalette32b &obj, HsfPalette &dest)
bswap(base, obj.palSize); bswap(base, obj.palSize);
bswap(base, obj.data); bswap(base, obj.data);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.unk = obj.unk; dest.unk = obj.unk;
dest.palSize = obj.palSize; dest.palSize = obj.palSize;
dest.data = reinterpret_cast<u16 *>(obj.data); dest.data = reinterpret_cast<u16 *>(static_cast<uintptr_t>(obj.data));
} }
template <typename B> void bswap(B &base, HsfPart32b &obj, HsfPart &dest) template <typename B> void bswap(B &base, HsfPart32b &obj, HsfPart &dest)
@ -486,9 +486,9 @@ template <typename B> void bswap(B &base, HsfPart32b &obj, HsfPart &dest)
bswap(base, obj.count); bswap(base, obj.count);
bswap(base, obj.vertex); bswap(base, obj.vertex);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.count = obj.count; dest.count = obj.count;
dest.vertex = reinterpret_cast<u16 *>(obj.vertex); dest.vertex = reinterpret_cast<u16 *>(static_cast<uintptr_t>(obj.vertex));
} }
template <typename B> void bswap(B &base, HsfBitmap32b &obj, HsfBitmap &dest) template <typename B> void bswap(B &base, HsfBitmap32b &obj, HsfBitmap &dest)
@ -502,7 +502,7 @@ template <typename B> void bswap(B &base, HsfBitmap32b &obj, HsfBitmap &dest)
bswap(base, obj.unk); bswap(base, obj.unk);
bswap(base, obj.data); bswap(base, obj.data);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.maxLod = obj.maxLod; dest.maxLod = obj.maxLod;
dest.dataFmt = obj.dataFmt; dest.dataFmt = obj.dataFmt;
dest.pixSize = obj.pixSize; dest.pixSize = obj.pixSize;
@ -510,9 +510,9 @@ template <typename B> void bswap(B &base, HsfBitmap32b &obj, HsfBitmap &dest)
dest.sizeY = obj.sizeY; dest.sizeY = obj.sizeY;
dest.palSize = obj.palSize; dest.palSize = obj.palSize;
dest.tint = obj.tint; dest.tint = obj.tint;
dest.palData = reinterpret_cast<void *>(obj.palData); dest.palData = reinterpret_cast<void *>(static_cast<uintptr_t>(obj.palData));
dest.unk = obj.unk; dest.unk = obj.unk;
dest.data = reinterpret_cast<void *>(obj.data); dest.data = reinterpret_cast<void *>(static_cast<uintptr_t>(obj.data));
} }
template <typename B> void bswap(B &base, HsfMapAttr32b &obj, HsfMapAttr &dest) template <typename B> void bswap(B &base, HsfMapAttr32b &obj, HsfMapAttr &dest)
@ -527,7 +527,7 @@ template <typename B> void bswap(B &base, HsfMapAttr32b &obj, HsfMapAttr &dest)
dest.minX = obj.minX; dest.minX = obj.minX;
dest.minZ = obj.minZ; dest.minZ = obj.minZ;
dest.maxX = obj.maxZ; dest.maxX = obj.maxZ;
dest.data = reinterpret_cast<u16 *>(obj.data); dest.data = reinterpret_cast<u16 *>(static_cast<uintptr_t>(obj.data));
dest.dataLen = obj.dataLen; dest.dataLen = obj.dataLen;
} }
@ -543,7 +543,7 @@ template <typename B> void bswap(B &base, HsfSkeleton32b &obj, HsfSkeleton &dest
bswap(base, obj.name); bswap(base, obj.name);
bswap(base, obj.transform); bswap(base, obj.transform);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.transform = obj.transform; dest.transform = obj.transform;
} }
@ -552,8 +552,8 @@ template <typename B> void bswap(B &base, HsfShape32b &obj, HsfShape &dest)
bswap(base, obj.name); bswap(base, obj.name);
bswap(base, obj.vertex); bswap(base, obj.vertex);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.vertex = reinterpret_cast<HsfBuffer **>(obj.vertex); dest.vertex = reinterpret_cast<HsfBuffer **>(static_cast<uintptr_t>(obj.vertex));
} }
template <typename B> void bswap(B &base, HsfCenvSingle &obj) template <typename B> void bswap(B &base, HsfCenvSingle &obj)
@ -577,10 +577,10 @@ template <typename B> void bswap(B &base, HsfCenv32b &obj, HsfCenv &dest)
bswap(base, obj.vtxCount); bswap(base, obj.vtxCount);
bswap(base, obj.copyCount); bswap(base, obj.copyCount);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.singleData = reinterpret_cast<HsfCenvSingle *>(obj.singleData); dest.singleData = reinterpret_cast<HsfCenvSingle *>(static_cast<uintptr_t>(obj.singleData));
dest.dualData = reinterpret_cast<HsfCenvDual *>(obj.dualData); dest.dualData = reinterpret_cast<HsfCenvDual *>(static_cast<uintptr_t>(obj.dualData));
dest.multiData = reinterpret_cast<HsfCenvMulti *>(obj.multiData); dest.multiData = reinterpret_cast<HsfCenvMulti *>(static_cast<uintptr_t>(obj.multiData));
dest.singleCount = obj.singleCount; dest.singleCount = obj.singleCount;
dest.dualCount = obj.dualCount; dest.dualCount = obj.dualCount;
dest.multiCount = obj.multiCount; dest.multiCount = obj.multiCount;
@ -610,29 +610,29 @@ template <typename B> void bswap(B &base, HsfObjectData32b &obj, HsfObjectData &
bswap(base, obj.cenv); bswap(base, obj.cenv);
bswap_flat(base, obj.file, sizeof(obj.file) / sizeof(u32)); bswap_flat(base, obj.file, sizeof(obj.file) / sizeof(u32));
dest.parent = reinterpret_cast<struct hsf_object *>(obj.parent); dest.parent = reinterpret_cast<struct hsf_object *>(static_cast<uintptr_t>(obj.parent));
dest.childrenCount = obj.childrenCount; dest.childrenCount = obj.childrenCount;
dest.children = reinterpret_cast<struct hsf_object **>(obj.children); dest.children = reinterpret_cast<struct hsf_object **>(static_cast<uintptr_t>(obj.children));
dest.base = obj.base; dest.base = obj.base;
dest.curr = obj.curr; dest.curr = obj.curr;
dest.face = reinterpret_cast<HsfBuffer *>(obj.face); dest.face = reinterpret_cast<HsfBuffer *>(static_cast<uintptr_t>(obj.face));
dest.vertex = reinterpret_cast<HsfBuffer *>(obj.vertex); dest.vertex = reinterpret_cast<HsfBuffer *>(static_cast<uintptr_t>(obj.vertex));
dest.normal = reinterpret_cast<HsfBuffer *>(obj.normal); dest.normal = reinterpret_cast<HsfBuffer *>(static_cast<uintptr_t>(obj.normal));
dest.color = reinterpret_cast<HsfBuffer *>(obj.color); dest.color = reinterpret_cast<HsfBuffer *>(static_cast<uintptr_t>(obj.color));
dest.st = reinterpret_cast<HsfBuffer *>(obj.st); dest.st = reinterpret_cast<HsfBuffer *>(static_cast<uintptr_t>(obj.st));
dest.material = reinterpret_cast<HsfMaterial *>(obj.material); dest.material = reinterpret_cast<HsfMaterial *>(static_cast<uintptr_t>(obj.material));
dest.attribute = reinterpret_cast<HsfAttribute *>(obj.attribute); dest.attribute = reinterpret_cast<HsfAttribute *>(static_cast<uintptr_t>(obj.attribute));
std::copy(std::begin(obj.unk120), std::end(obj.unk120), dest.unk120); std::copy(std::begin(obj.unk120), std::end(obj.unk120), dest.unk120);
dest.shapeType = obj.shapeType; dest.shapeType = obj.shapeType;
dest.unk123 = obj.unk123; dest.unk123 = obj.unk123;
dest.vertexShapeCnt = obj.vertexShapeCnt; dest.vertexShapeCnt = obj.vertexShapeCnt;
dest.vertexShape = reinterpret_cast<HsfBuffer **>(obj.vertexShape); dest.vertexShape = reinterpret_cast<HsfBuffer **>(static_cast<uintptr_t>(obj.vertexShape));
dest.clusterCnt = obj.clusterCnt; dest.clusterCnt = obj.clusterCnt;
dest.cluster = reinterpret_cast<HsfCluster **>(obj.cluster); dest.cluster = reinterpret_cast<HsfCluster **>(static_cast<uintptr_t>(obj.cluster));
dest.cenvCnt = obj.cenvCnt; dest.cenvCnt = obj.cenvCnt;
dest.cenv = reinterpret_cast<HsfCenv *>(obj.cenv); dest.cenv = reinterpret_cast<HsfCenv *>(static_cast<uintptr_t>(obj.cenv));
dest.file[0] = reinterpret_cast<void *>(obj.file[0]); dest.file[0] = reinterpret_cast<void *>(static_cast<uintptr_t>(obj.file[0]));
dest.file[1] = reinterpret_cast<void *>(obj.file[1]); dest.file[1] = reinterpret_cast<void *>(static_cast<uintptr_t>(obj.file[1]));
switch (type) { switch (type) {
case HSF_OBJ_MESH: case HSF_OBJ_MESH:
@ -649,7 +649,7 @@ template <typename B> void bswap(B &base, HsfObjectData32b &obj, HsfObjectData &
case HSF_OBJ_REPLICA: case HSF_OBJ_REPLICA:
bswap(base, obj.replica); bswap(base, obj.replica);
dest.replica = obj.replica; dest.replica = reinterpret_cast<struct hsf_object *>(static_cast<uintptr_t>(obj.replica));
break; break;
default: default:
break; break;
@ -663,9 +663,9 @@ template <typename B> void bswap(B &base, HsfObject32b &obj, HsfObject &dest)
bswap(base, obj.constData); bswap(base, obj.constData);
bswap(base, obj.flags); bswap(base, obj.flags);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.type = obj.type; dest.type = obj.type;
dest.constData = reinterpret_cast<void *>(obj.constData); dest.constData = reinterpret_cast<void *>(static_cast<uintptr_t>(obj.constData));
dest.flags = obj.flags; dest.flags = obj.flags;
bswap(base, obj.data, dest.data, obj.type); bswap(base, obj.data, dest.data, obj.type);
@ -677,7 +677,7 @@ template <typename B> void bswap(B &base, HsfBitmapKey32b &obj, HsfBitmapKey &de
bswap(base, obj.data); bswap(base, obj.data);
dest.time = obj.time; dest.time = obj.time;
dest.data = reinterpret_cast<HsfBitmap *>(obj.data); dest.data = reinterpret_cast<HsfBitmap *>(static_cast<uintptr_t>(obj.data));
} }
template <typename B> void bswap(B &base, HsfTrack32b &obj, HsfTrack &dest) template <typename B> void bswap(B &base, HsfTrack32b &obj, HsfTrack &dest)
@ -686,17 +686,23 @@ template <typename B> void bswap(B &base, HsfTrack32b &obj, HsfTrack &dest)
bswap(base, obj.start); bswap(base, obj.start);
bswap(base, obj.curveType); bswap(base, obj.curveType);
bswap(base, obj.numKeyframes); bswap(base, obj.numKeyframes);
bswap(base, obj.data); // this byteswaps "value" too
dest.type = obj.type; dest.type = obj.type;
dest.start = obj.start; dest.start = obj.start;
dest.curveType = obj.curveType; dest.curveType = obj.curveType;
dest.numKeyframes = obj.numKeyframes; dest.numKeyframes = obj.numKeyframes;
dest.data = reinterpret_cast<void *>(obj.data); // this correctly sets "value" too
if (obj.type = HSF_TRACK_CLUSTER_WEIGHT) { if (obj.curveType == HSF_CURVE_CONST) {
bswap(base, obj.value);
dest.value = obj.value;
}
else {
bswap(base, obj.data);
dest.data = reinterpret_cast<void *>(static_cast<uintptr_t>(obj.data));
}
if (obj.type == HSF_TRACK_CLUSTER_WEIGHT) {
bswap(base, obj.unk04); bswap(base, obj.unk04);
dest.unk04 = obj.unk04; dest.unk04 = obj.unk04;
} }
else { else {
@ -715,9 +721,9 @@ template <typename B> void bswap(B &base, HsfMotion32b &obj, HsfMotion &dest)
bswap(base, obj.track); bswap(base, obj.track);
bswap(base, obj.len); bswap(base, obj.len);
dest.name = reinterpret_cast<char *>(obj.name); dest.name = reinterpret_cast<char *>(static_cast<uintptr_t>(obj.name));
dest.numTracks = obj.numTracks; dest.numTracks = obj.numTracks;
dest.track = reinterpret_cast<HsfTrack *>(obj.track); dest.track = reinterpret_cast<HsfTrack *>(static_cast<uintptr_t>(obj.track));
dest.len = obj.len; dest.len = obj.len;
} }
@ -737,7 +743,7 @@ template <typename B> void bswap(B &base, HsfFace32b &obj, HsfFace &dest)
bswap_flat(base, obj.strip.indices[0], 3 * 4); bswap_flat(base, obj.strip.indices[0], 3 * 4);
dest.strip.count = obj.strip.count; dest.strip.count = obj.strip.count;
dest.strip.data = reinterpret_cast<s16 *>(obj.strip.data); dest.strip.data = reinterpret_cast<s16 *>(static_cast<uintptr_t>(obj.strip.data));
std::copy(&obj.strip.indices[0][0], &obj.strip.indices[0][0] + 3 * 4, &dest.strip.indices[0][0]); std::copy(&obj.strip.indices[0][0], &obj.strip.indices[0][0] + 3 * 4, &dest.strip.indices[0][0]);
} }
else { else {

View file

@ -629,7 +629,7 @@ void GXSetTexCoordScaleManually(GXTexCoordID coord, u8 enable, u16 ss, u16 ts)
void GXResetWriteGatherPipe(void) void GXResetWriteGatherPipe(void)
{ {
puts("GXResetWriteGatherPipe is a stub"); // puts("GXResetWriteGatherPipe is a stub");
} }
void ARQInit(void) { void ARQInit(void) {