diff --git a/extern/aurora b/extern/aurora
index d9de6603..3b56e337 160000
--- a/extern/aurora
+++ b/extern/aurora
@@ -1 +1 @@
-Subproject commit d9de6603c79917a5353abd3a9cc26ec557ceee05
+Subproject commit 3b56e337c08a1dd4946c226298011364c319c7a2
diff --git a/include/game/hsfdraw.h b/include/game/hsfdraw.h
index a99d0bb1..0b9e0e8f 100755
--- a/include/game/hsfdraw.h
+++ b/include/game/hsfdraw.h
@@ -57,7 +57,7 @@ void Hu3DDrawPreInit(void);
void Hu3DDraw(ModelData *arg0, Mtx arg1, Vec *arg2);
s32 ObjCullCheck(HsfData *arg0, HsfObject *arg1, Mtx arg2);
void Hu3DDrawPost(void);
-void MakeDisplayList(s16 arg0, u32 arg1);
+void MakeDisplayList(s16 arg0, uintptr_t arg1);
HsfConstData *ObjConstantMake(HsfObject *arg0, u32 arg1);
void mtxTransCat(Mtx arg0, float arg1, float arg2, float arg3);
void mtxRotCat(Mtx arg0, float arg1, float arg2, float arg3);
diff --git a/include/game/hsfformat.h b/include/game/hsfformat.h
index 36c083a9..22ad98ab 100644
--- a/include/game/hsfformat.h
+++ b/include/game/hsfformat.h
@@ -227,9 +227,8 @@ typedef struct hsf_cluster {
s32 target;
};
HsfPart *part;
- float unk10;
- float unk14[1]; // unknown array size
- u8 unk18[124];
+ float index;
+ float weight[32]; // unknown array size
u8 adjusted;
u8 unk95;
u16 type;
@@ -261,7 +260,7 @@ typedef struct hsf_object_data {
} mesh;
struct hsf_object *replica;
};
-
+
HsfBuffer *face;
HsfBuffer *vertex;
HsfBuffer *normal;
@@ -351,6 +350,9 @@ typedef struct hsf_track {
float value;
void *data;
};
+#ifdef TARGET_PC
+ void *dataTop;
+#endif
} HsfTrack;
typedef struct hsf_motion {
@@ -397,6 +399,9 @@ typedef struct hsf_data {
HsfObject *object;
HsfMapAttr *mapAttr;
HsfMatrix *matrix;
+#ifdef TARGET_PC
+ void **symbol;
+#endif
s16 sceneCnt;
s16 attributeCnt;
s16 materialCnt;
diff --git a/include/game/hsfload.h b/include/game/hsfload.h
index 1b67cb21..c1003f05 100644
--- a/include/game/hsfload.h
+++ b/include/game/hsfload.h
@@ -8,5 +8,8 @@ void ClusterAdjustObject(HsfData *model, HsfData *src_model);
char *SetName(u32 *str_ofs);
char *MakeObjectName(char *name);
s32 CmpObjectName(char *name1, char *name2);
+#ifdef TARGET_PC
+void KillHSF(HsfData *data);
+#endif
#endif
\ No newline at end of file
diff --git a/include/game/hsfmotion.h b/include/game/hsfmotion.h
index f820bd7f..7b07bf9d 100644
--- a/include/game/hsfmotion.h
+++ b/include/game/hsfmotion.h
@@ -10,9 +10,9 @@
typedef struct motion_data {
- s16 unk_00;
- s16 unk_02;
- HsfData *unk_04;
+ s16 attr;
+ s16 modelId;
+ HsfData *hsfData;
} MotionData;
typedef struct {
diff --git a/include/game/memory.h b/include/game/memory.h
index a32b1a84..efc86334 100644
--- a/include/game/memory.h
+++ b/include/game/memory.h
@@ -19,9 +19,9 @@ void *HuMemInit(void *ptr, s32 size);
void HuMemDCFlushAll();
void HuMemDCFlush(HeapID heap);
void *HuMemDirectMalloc(HeapID heap, s32 size);
-void *HuMemDirectMallocNum(HeapID heap, s32 size, u32 num);
+void *HuMemDirectMallocNum(HeapID heap, s32 size, uintptr_t num);
void HuMemDirectFree(void *ptr);
-void HuMemDirectFreeNum(HeapID heap, u32 num);
+void HuMemDirectFreeNum(HeapID heap, uintptr_t num);
s32 HuMemUsedMallocSizeGet(HeapID heap);
s32 HuMemUsedMallocBlockGet(HeapID heap);
u32 HuMemHeapSizeGet(HeapID heap);
@@ -29,9 +29,9 @@ void *HuMemHeapPtrGet(HeapID heap);
void *HuMemHeapInit(void *ptr, s32 size);
void *HuMemMemoryAlloc(void *heap_ptr, s32 size, uintptr_t retaddr);
-void *HuMemMemoryAllocNum(void *heap_ptr, s32 size, u32 num, uintptr_t retaddr);
+void *HuMemMemoryAllocNum(void *heap_ptr, s32 size, uintptr_t num, uintptr_t retaddr);
void HuMemMemoryFree(void *ptr, uintptr_t retaddr);
-void HuMemMemoryFreeNum(void *heap_ptr, u32 num, uintptr_t retaddr);
+void HuMemMemoryFreeNum(void *heap_ptr, uintptr_t num, uintptr_t retaddr);
s32 HuMemUsedMemorySizeGet(void *heap_ptr);
s32 HuMemUsedMemoryBlockGet(void *heap_ptr);
s32 HuMemMemorySizeGet(void *ptr);
diff --git a/include/port/byteswap.h b/include/port/byteswap.h
index 26286fab..1d7549d9 100644
--- a/include/port/byteswap.h
+++ b/include/port/byteswap.h
@@ -9,8 +9,233 @@ extern "C"
#include "game/animdata.h"
#include "game/hsfformat.h"
+typedef struct HsfCluster32b {
+ u32 name[2];
+ u32 targetName;
+ u32 part;
+ float index;
+ float weight[32];
+ u8 adjusted;
+ u8 unk95;
+ u16 type;
+ u32 vertexCnt;
+ u32 vertex;
+} HsfCluster32b;
+
+typedef struct HsfAttribute32b {
+ u32 name;
+ u32 unk04;
+ u8 unk8[4];
+ float unk0C;
+ u8 unk10[4];
+ float unk14;
+ u8 unk18[8];
+ float unk20;
+ u8 unk24[4];
+ float unk28;
+ float unk2C;
+ float unk30;
+ float unk34;
+ u8 unk38[44];
+ u32 wrap_s;
+ u32 wrap_t;
+ u8 unk6C[12];
+ u32 unk78;
+ u32 flag;
+ u32 bitmap;
+} HsfAttribute32b;
+
+typedef struct HsfMaterial32b {
+ u32 name;
+ u8 unk4[4];
+ u16 pass;
+ u8 vtxMode;
+ u8 litColor[3];
+ u8 color[3];
+ u8 shadowColor[3];
+ float hilite_scale;
+ float unk18;
+ float invAlpha;
+ float unk20[2];
+ float refAlpha;
+ float unk2C;
+ u32 flags;
+ u32 numAttrs;
+ u32 attrs;
+} HsfMaterial32b;
+
+typedef struct HsfMapAttr32b {
+ float minX;
+ float minZ;
+ float maxX;
+ float maxZ;
+ u32 data;
+ u32 dataLen;
+} HsfMapAttr32b;
+
+typedef struct HsfBuffer32b {
+ u32 name;
+ s32 count;
+ u32 data;
+} HsfBuffer32b;
+
+typedef struct HsfPalette32b {
+ u32 name;
+ s32 unk;
+ u32 palSize;
+ u32 data;
+} HsfPalette32b;
+
+typedef struct HsfBitmap32b {
+ u32 name;
+ u32 maxLod;
+ u8 dataFmt;
+ u8 pixSize;
+ s16 sizeX;
+ s16 sizeY;
+ s16 palSize;
+ GXColor tint;
+ u32 palData;
+ u32 unk;
+ u32 data;
+} HsfBitmap32b;
+
+typedef struct HsfPart32b {
+ u32 name;
+ u32 count;
+ u32 vertex;
+} HsfPart32b;
+
+typedef struct HsfSkeleton32b {
+ u32 name;
+ HsfTransform transform;
+} HsfSkeleton32b;
+
+typedef struct HsfShape32b {
+ u32 name;
+ union {
+ u16 count16[2];
+ u32 vertexCnt;
+ };
+ u32 vertex;
+} HsfShape32b;
+
+typedef struct HsfCenv32b {
+ u32 name;
+ u32 singleData;
+ u32 dualData;
+ u32 multiData;
+ u32 singleCount;
+ u32 dualCount;
+ u32 multiCount;
+ u32 vtxCount;
+ u32 copyCount;
+} HsfCenv32b;
+
+typedef struct HsfObjectData32b {
+ u32 parent;
+ u32 childrenCount;
+ u32 children;
+ HsfTransform base;
+ HsfTransform curr;
+ union {
+ struct {
+ HsfVector3f min;
+ HsfVector3f max;
+ float baseMorph;
+ float morphWeight[33];
+ } mesh;
+ struct hsf_object *replica;
+ };
+
+ u32 face;
+ u32 vertex;
+ u32 normal;
+ u32 color;
+ u32 st;
+ u32 material;
+ u32 attribute;
+ u8 unk120[2];
+ u8 shapeType;
+ u8 unk123;
+ u32 vertexShapeCnt;
+ u32 vertexShape;
+ u32 clusterCnt;
+ u32 cluster;
+ u32 cenvCnt;
+ u32 cenv;
+ u32 file[2];
+} HsfObjectData32b;
+
+typedef struct HsfObject32b {
+ u32 name;
+ u32 type;
+ u32 constData;
+ u32 flags;
+ HsfObjectData32b data;
+} HsfObject32b;
+
+typedef struct HsfTrack32b {
+ u8 type;
+ u8 start;
+ union {
+ u16 target;
+ s16 target_s16;
+ };
+ union {
+ s32 unk04;
+ struct {
+ union {
+ s16 param;
+ u16 param_u16;
+ };
+ union {
+ u16 channel;
+ s16 channel_s16;
+ };
+ };
+ };
+ u16 curveType;
+ u16 numKeyframes;
+ union {
+ float value;
+ u32 data;
+ };
+} HsfTrack32b;
+
+typedef struct HsfMotion32b {
+ u32 name;
+ s32 numTracks;
+ u32 track;
+ float len;
+} HsfMotion32b;
+
+typedef struct HsfBitmapKey32b {
+ float time;
+ u32 data;
+} HsfBitmapKey32b;
+
+typedef struct HsfFace32b {
+ s16 type;
+ s16 mat;
+ union {
+ struct {
+ s16 indices[3][4];
+ u32 count;
+ u32 data;
+ } strip;
+ s16 indices[4][4];
+ };
+ Vec nbt;
+} HsfFace32b;
+
+void byteswap_u16(u16 *src);
+void byteswap_s16(s16 *src);
void byteswap_u32(u32 *src);
void byteswap_s32(s32 *src);
+void byteswap_hsfvec3f(HsfVector3f *src);
+void byteswap_hsfvec2f(HsfVector2f *src);
+
void byteswap_animdata(void *src, AnimData* dest);
void byteswap_animbankdata(void *src, AnimBankData *dest);
void byteswap_animpatdata(void *src, AnimPatData *dest);
@@ -18,8 +243,26 @@ void byteswap_animbmpdata(void *src, AnimBmpData *dest);
void byteswap_animframedata(AnimFrameData *src);
void byteswap_animlayerdata(AnimLayerData *src);
-
void byteswap_hsfheader(HsfHeader *src);
+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/E3setupDLL/main.c b/src/REL/E3setupDLL/main.c
index a080e2de..c035cd01 100644
--- a/src/REL/E3setupDLL/main.c
+++ b/src/REL/E3setupDLL/main.c
@@ -300,7 +300,7 @@ float MotionMaxTimeGet(s16 arg0)
HsfMotion *temp_r30;
s16 temp_r29;
- temp_r30 = temp_r31->unk_04->motion;
+ temp_r30 = temp_r31->hsfData->motion;
temp_r29 = temp_r30->len;
return temp_r29;
}
diff --git a/src/REL/bootDll/main.c b/src/REL/bootDll/main.c
index 56bb9c06..f6b09479 100644
--- a/src/REL/bootDll/main.c
+++ b/src/REL/bootDll/main.c
@@ -371,8 +371,10 @@ void ObjectSetup(void)
s16 group;
s16 sprite;
AnimData *data;
+#ifdef TARGET_PC
+ return;
+#else
option = 0;
-#ifdef __MWERKS__
if (OSGetResetCode() != OS_RESET_RESTART) {
return;
}
@@ -425,7 +427,6 @@ void ObjectSetup(void)
HuPrcVSleep();
}
#ifdef __MWERKS__
- // TODO PC
if (!option) {
OSSetProgressiveMode(OS_PROGRESSIVE_MODE_ON);
VIConfigure(&GXNtsc480Prog);
@@ -565,8 +566,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);
@@ -578,7 +577,6 @@ void ObjectSetup(void)
Hu3DModelAttrSet(model, HU3D_MOTATTR_LOOP);
Hu3DModelCameraInfoSet(model, 1);
Hu3DModelLightInfoSet(model, 1);
-#endif
#if VERSION_NTSC
bootGrpId = HuSprGrpCreate(4);
#else
@@ -640,11 +638,8 @@ void ObjectSetup(void)
s16 choice;
float temp;
repeat:
-#ifdef __MWERKS__
- // TODO PC
Hu3DModelAttrReset(titleMdlId[0], HU3D_ATTR_DISPOFF);
Hu3DModelAttrReset(titleMdlId[1], HU3D_ATTR_DISPOFF);
-#endif
HuSprAttrReset(bootGrpId, 0, HUSPR_ATTR_DISPOFF);
HuSprAttrReset(bootGrpId, 1, HUSPR_ATTR_DISPOFF);
#ifdef __MWERKS__
@@ -796,12 +791,9 @@ void ObjectSetup(void)
while (WipeStatGet()) {
HuPrcVSleep();
}
-#ifdef __MWERKS__
- // TODO PC
Hu3DModelAttrSet(titleMdlId[0], HU3D_ATTR_DISPOFF);
Hu3DModelAttrSet(titleMdlId[1], HU3D_ATTR_DISPOFF);
Hu3DModelAttrSet(titleMdlId[2], HU3D_ATTR_DISPOFF);
-#endif
#if VERSION_NTSC
HuSprAttrSet(bootGrpId, 0, HUSPR_ATTR_DISPOFF);
HuSprAttrSet(bootGrpId, 1, HUSPR_ATTR_DISPOFF);
diff --git a/src/REL/m409Dll/player.c b/src/REL/m409Dll/player.c
index 9157deeb..ed75457f 100644
--- a/src/REL/m409Dll/player.c
+++ b/src/REL/m409Dll/player.c
@@ -1263,7 +1263,7 @@ f32 fn_1_BF38(s16 arg0)
f32 length;
motionData = &Hu3DMotion[arg0];
- hsfMotionData = motionData->unk_04->motion;
+ hsfMotionData = motionData->hsfData->motion;
length = hsfMotionData->len;
return length;
}
diff --git a/src/game/ClusterExec.c b/src/game/ClusterExec.c
index 7a25f91d..af0b6981 100644
--- a/src/game/ClusterExec.c
+++ b/src/game/ClusterExec.c
@@ -3,7 +3,8 @@
#include "game/hsfmotion.h"
#include "game/sprite.h"
-float GetClusterCurve(HsfTrack *arg0, float arg1) {
+float GetClusterCurve(HsfTrack *arg0, float arg1)
+{
float *var_r30;
switch (arg0->curveType) {
@@ -18,7 +19,8 @@ float GetClusterCurve(HsfTrack *arg0, float arg1) {
return 0.0f;
}
-float GetClusterWeightCurve(HsfTrack *arg0, float arg1) {
+float GetClusterWeightCurve(HsfTrack *arg0, float arg1)
+{
float *var_r30;
switch (arg0->curveType) {
@@ -33,7 +35,8 @@ float GetClusterWeightCurve(HsfTrack *arg0, float arg1) {
return 0.0f;
}
-void SetClusterMain(HsfCluster *arg0) {
+void SetClusterMain(HsfCluster *arg0)
+{
float var_f30;
float var_f31;
s32 temp_r24;
@@ -53,51 +56,53 @@ void SetClusterMain(HsfCluster *arg0) {
temp_r30 = *arg0->vertex;
var_f30 = 0.0f;
for (i = 0; i < arg0->vertexCnt; i++) {
- var_f30 += arg0->unk14[i];
+ var_f30 += arg0->weight[i];
}
for (i = 0; i < temp_r27->count; i++, var_r28++) {
temp_r29 = *var_r28;
- Vertextop[temp_r29].x = ((Vec*) temp_r30->data)[i].x;
- Vertextop[temp_r29].y = ((Vec*) temp_r30->data)[i].y;
- Vertextop[temp_r29].z = ((Vec*) temp_r30->data)[i].z;
+ Vertextop[temp_r29].x = ((Vec *)temp_r30->data)[i].x;
+ Vertextop[temp_r29].y = ((Vec *)temp_r30->data)[i].y;
+ Vertextop[temp_r29].z = ((Vec *)temp_r30->data)[i].z;
}
for (i = 1; i < arg0->vertexCnt; i++) {
temp_r30 = arg0->vertex[i];
var_r28 = temp_r27->vertex;
- var_f31 = arg0->unk14[i];
+ var_f31 = arg0->weight[i];
if (var_f31 < 0.0f) {
var_f31 = 0.0f;
- } else if (var_f30 > 1.0f) {
+ }
+ else if (var_f30 > 1.0f) {
var_f31 /= var_f30;
}
for (j = 0; j < temp_r27->count; j++, var_r28++) {
temp_r29 = *var_r28;
- Vertextop[temp_r29].x += var_f31 * (((Vec*) temp_r30->data)[j].x - Vertextop[temp_r29].x);
- Vertextop[temp_r29].y += var_f31 * (((Vec*) temp_r30->data)[j].y - Vertextop[temp_r29].y);
- Vertextop[temp_r29].z += var_f31 * (((Vec*) temp_r30->data)[j].z - Vertextop[temp_r29].z);
+ Vertextop[temp_r29].x += var_f31 * (((Vec *)temp_r30->data)[j].x - Vertextop[temp_r29].x);
+ Vertextop[temp_r29].y += var_f31 * (((Vec *)temp_r30->data)[j].y - Vertextop[temp_r29].y);
+ Vertextop[temp_r29].z += var_f31 * (((Vec *)temp_r30->data)[j].z - Vertextop[temp_r29].z);
}
}
return;
}
- temp_r24 = arg0->unk10;
+ temp_r24 = arg0->index;
var_r23 = temp_r24 + 1;
if (var_r23 >= arg0->vertexCnt) {
var_r23 = temp_r24;
}
- var_f31 = arg0->unk10 - temp_r24;
+ var_f31 = arg0->index - temp_r24;
temp_r30 = arg0->vertex[temp_r24];
temp_r25 = arg0->vertex[var_r23];
var_r28 = temp_r27->vertex;
for (i = 0; i < temp_r27->count; i++, var_r28++) {
temp_r29 = *var_r28;
- Vertextop[temp_r29].x = ((Vec*) temp_r30->data)[i].x + var_f31 * (((Vec*) temp_r25->data)[i].x - ((Vec*) temp_r30->data)[i].x);
- Vertextop[temp_r29].y = ((Vec*) temp_r30->data)[i].y + var_f31 * (((Vec*) temp_r25->data)[i].y - ((Vec*) temp_r30->data)[i].y);
- Vertextop[temp_r29].z = ((Vec*) temp_r30->data)[i].z + var_f31 * (((Vec*) temp_r25->data)[i].z - ((Vec*) temp_r30->data)[i].z);
+ Vertextop[temp_r29].x = ((Vec *)temp_r30->data)[i].x + var_f31 * (((Vec *)temp_r25->data)[i].x - ((Vec *)temp_r30->data)[i].x);
+ Vertextop[temp_r29].y = ((Vec *)temp_r30->data)[i].y + var_f31 * (((Vec *)temp_r25->data)[i].y - ((Vec *)temp_r30->data)[i].y);
+ Vertextop[temp_r29].z = ((Vec *)temp_r30->data)[i].z + var_f31 * (((Vec *)temp_r25->data)[i].z - ((Vec *)temp_r30->data)[i].z);
}
}
}
-void ClusterProc(ModelData *arg0) {
+void ClusterProc(ModelData *arg0)
+{
s32 temp_r24;
s32 i;
s32 j;
@@ -112,7 +117,7 @@ void ClusterProc(ModelData *arg0) {
temp_r24 = arg0->unk_10[i];
if (temp_r24 != -1) {
temp_r22 = &Hu3DMotion[temp_r24];
- temp_r27 = temp_r22->unk_04;
+ temp_r27 = temp_r22->hsfData;
temp_r23 = arg0->hsfData;
var_r29 = temp_r27->cluster;
for (j = 0; j < temp_r27->clusterCnt; j++, var_r29++) {
@@ -122,9 +127,9 @@ void ClusterProc(ModelData *arg0) {
Vertextop = temp_r31->data.vertex->data;
if (temp_r31->data.cenvCnt) {
for (k = 0; k < temp_r31->data.vertex->count; k++) {
- Vertextop[k].x = ((Vec*) temp_r31->data.file[0])[k].x;
- Vertextop[k].y = ((Vec*) temp_r31->data.file[0])[k].y;
- Vertextop[k].z = ((Vec*) temp_r31->data.file[0])[k].z;
+ Vertextop[k].x = ((Vec *)temp_r31->data.file[0])[k].x;
+ Vertextop[k].y = ((Vec *)temp_r31->data.file[0])[k].y;
+ Vertextop[k].z = ((Vec *)temp_r31->data.file[0])[k].z;
}
}
SetClusterMain(var_r29);
@@ -136,7 +141,8 @@ void ClusterProc(ModelData *arg0) {
}
}
-void ClusterMotionExec(ModelData *arg0) {
+void ClusterMotionExec(ModelData *arg0)
+{
float temp_f31;
s32 i;
s32 j;
@@ -153,7 +159,7 @@ void ClusterMotionExec(ModelData *arg0) {
if (arg0->unk_10[i] != -1) {
var_r20 = arg0->unk_10[i];
var_r23 = &Hu3DMotion[var_r20];
- temp_r28 = var_r23->unk_04;
+ temp_r28 = var_r23->hsfData;
temp_r27 = temp_r28->motion;
var_r31 = temp_r27->track;
temp_f31 = arg0->unk_A4[i];
@@ -161,12 +167,12 @@ void ClusterMotionExec(ModelData *arg0) {
switch (var_r31->type) {
case 5:
temp_r26 = &temp_r28->cluster[var_r31->target_s16];
- temp_r26->unk10 = GetClusterCurve(var_r31, temp_f31);
+ temp_r26->index = GetClusterCurve(var_r31, temp_f31);
break;
case 6:
var_r30 = var_r31;
temp_r26 = &temp_r28->cluster[var_r30->target_s16];
- temp_r26->unk14[var_r30->unk04] = GetClusterCurve(var_r30, temp_f31);
+ temp_r26->weight[var_r30->unk04] = GetClusterCurve(var_r30, temp_f31);
break;
}
}
diff --git a/src/game/board/model.c b/src/game/board/model.c
index 599f05e2..5162b2fe 100644
--- a/src/game/board/model.c
+++ b/src/game/board/model.c
@@ -747,7 +747,7 @@ float BoardModelMotionShapeMaxTimeGet(s16 model)
return 0;
}
motion = &Hu3DMotion[hsf_model->unk_0E];
- motion_hsf = motion->unk_04->motion;
+ motion_hsf = motion->hsfData->motion;
return motion_hsf->len;
}
}
diff --git a/src/game/hsfdraw.c b/src/game/hsfdraw.c
index fbac2536..0d45b89c 100755
--- a/src/game/hsfdraw.c
+++ b/src/game/hsfdraw.c
@@ -89,7 +89,7 @@ static u16 faceCnt;
static u16 *faceNumBuf;
static s32 DLTotalNum;
static u32 totalSize;
-static u32 mallocNo;
+static uintptr_t mallocNo;
static s32 curModelID;
static s16 polySize;
static s32 PGFinishF;
@@ -2367,7 +2367,7 @@ static void ObjDraw(HsfDrawObject *arg0) {
}
}
-void MakeDisplayList(s16 arg0, u32 arg1) {
+void MakeDisplayList(s16 arg0, uintptr_t arg1) {
HsfData *temp_r31;
ModelData *var_r30;
diff --git a/src/game/hsfex.c b/src/game/hsfex.c
index 467def93..9455c65d 100644
--- a/src/game/hsfex.c
+++ b/src/game/hsfex.c
@@ -59,7 +59,7 @@ void CamMotionEx(s16 arg0, s16 arg1, Vec *arg2, Vec *arg3, Vec *arg4, float arg5
temp_r23 = &Hu3DData[arg0];
temp_r19 = &Hu3DMotion[temp_r23->unk_08];
temp_r22 = temp_r23->hsfData;
- temp_r18 = temp_r19->unk_04;
+ temp_r18 = temp_r19->hsfData;
temp_r26 = temp_r18->motion;
for (var_r25 = 0; var_r25 < HU3D_CAM_MAX; var_r25++) {
if (arg1 & (1 << var_r25)) {
diff --git a/src/game/hsfload.c b/src/game/hsfload.c
index d4472e0f..0a4882fd 100644
--- a/src/game/hsfload.c
+++ b/src/game/hsfload.c
@@ -3,6 +3,7 @@
#include "ctype.h"
#ifdef TARGET_PC
+#include "game/memory.h"
#include "port/byteswap.h"
#endif
@@ -26,6 +27,15 @@ HsfBuffer *vtxtop;
HsfCluster *ClusterTop;
HsfAttribute *AttributeTop;
HsfMaterial *MaterialTop;
+#ifdef TARGET_PC
+HsfBuffer *NormalTop;
+HsfBuffer *StTop;
+HsfBuffer *ColorTop;
+HsfBuffer *FaceTop;
+HsfCenv *CenvTop;
+HsfPart *PartTop;
+HsfBitmap *BitmapTop;
+#endif
static void FileLoad(void *data);
static HsfData *SetHsfModel(void);
@@ -118,17 +128,43 @@ void ClusterAdjustObject(HsfData *model, HsfData *src_model)
static void FileLoad(void *data)
{
+#ifdef TARGET_PC
+ s32 i;
+#endif
fileptr = data;
memcpy(&head, fileptr, sizeof(HsfHeader));
memset(&Model, 0, sizeof(HsfData));
#ifdef TARGET_PC
byteswap_hsfheader(&head);
-#endif
+ NSymIndex = HuMemDirectMallocNum(HEAP_DATA, sizeof(void*) * head.symbol.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.symbol.count; i++) {
+ u32 *file_symbol_real = (u32 *)((uintptr_t)fileptr + head.symbol.ofs);
+ byteswap_u32(&file_symbol_real[i]);
+ NSymIndex[i] = (void *)file_symbol_real[i];
+ }
+ StringTable = (char *)((uintptr_t)fileptr+head.string.ofs);
+ ClusterTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfCluster) * head.cluster.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.cluster.count; i++) {
+ HsfCluster32b *file_cluster_real = (HsfCluster32b *)((uintptr_t)fileptr + head.cluster.ofs);
+ byteswap_hsfcluster(&file_cluster_real[i], &ClusterTop[i]);
+ }
+ AttributeTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfAttribute) * head.attribute.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.attribute.count; i++) {
+ HsfAttribute32b *file_attribute_real = (HsfAttribute32b *)((uintptr_t)fileptr + head.attribute.ofs);
+ byteswap_hsfattribute(&file_attribute_real[i], &AttributeTop[i]);
+ }
+ MaterialTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfMaterial) * head.material.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.material.count; i++) {
+ HsfMaterial32b *file_material_real = (HsfMaterial32b *)((uintptr_t)fileptr + head.material.ofs);
+ byteswap_hsfmaterial(&file_material_real[i], &MaterialTop[i]);
+ }
+#else
NSymIndex = (void **)((uintptr_t)fileptr+head.symbol.ofs);
StringTable = (char *)((uintptr_t)fileptr+head.string.ofs);
ClusterTop = (HsfCluster *)((uintptr_t)fileptr+head.cluster.ofs);
AttributeTop = (HsfAttribute *)((uintptr_t)fileptr + head.attribute.ofs);
MaterialTop = (HsfMaterial *)((uintptr_t)fileptr + head.material.ofs);
+#endif
}
static HsfData *SetHsfModel(void)
@@ -173,6 +209,9 @@ static HsfData *SetHsfModel(void)
data->shapeCnt = Model.shapeCnt;
data->mapAttr = Model.mapAttr;
data->mapAttrCnt = Model.mapAttrCnt;
+#ifdef TARGET_PC
+ data->symbol = NSymIndex;
+#endif
return data;
}
@@ -193,7 +232,11 @@ static void MaterialLoad(void)
s32 i;
s32 j;
if(head.material.count) {
- HsfMaterial *file_mat = (HsfMaterial *)((u32)fileptr+head.material.ofs);
+#ifdef TARGET_PC
+ HsfMaterial *file_mat = MaterialTop;
+#else
+ HsfMaterial *file_mat = (HsfMaterial *)((uintptr_t)fileptr+head.material.ofs);
+#endif
HsfMaterial *curr_mat;
HsfMaterial *new_mat;
for(i=0; i
name = SetName((u32 *)&curr_mat->name);
@@ -244,7 +291,11 @@ static void AttributeLoad(void)
HsfAttribute *temp_attr;
s32 i;
if(head.attribute.count) {
+#ifdef TARGET_PC
+ temp_attr = file_attr = AttributeTop;
+#else
temp_attr = file_attr = (HsfAttribute *)((u32)fileptr+head.attribute.ofs);
+#endif
new_attr = temp_attr;
Model.attribute = new_attr;
Model.attributeCnt = head.attribute.count;
@@ -261,10 +312,18 @@ static void AttributeLoad(void)
static void SceneLoad(void)
{
+#ifdef TARGET_PC
+ s32 i;
+#endif
HsfScene *file_scene;
HsfScene *new_scene;
if(head.scene.count) {
- file_scene = (HsfScene *)((u32)fileptr+head.scene.ofs);
+ file_scene = (HsfScene *)((uintptr_t)fileptr+head.scene.ofs);
+#ifdef TARGET_PC
+ for (i = 0; i < head.scene.count; i++) {
+ byteswap_hsfscene(&file_scene[i]);
+ }
+#endif
new_scene = file_scene;
new_scene->end = file_scene->end;
new_scene->start = file_scene->start;
@@ -283,18 +342,30 @@ static void ColorLoad(void)
HsfBuffer *temp_color;
if(head.color.count) {
+#ifdef TARGET_PC
+ HsfBuffer32b * file_color_real = (HsfBuffer32b *)((uintptr_t)fileptr + head.color.ofs);
+ temp_color = file_color = ColorTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfBuffer) * head.color.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.color.count; i++) {
+ byteswap_hsfbuffer(&file_color_real[i], &file_color[i]);
+ }
+#else
temp_color = file_color = (HsfBuffer *)((u32)fileptr+head.color.ofs);
data = &file_color[head.color.count];
for(i=0; idata;
new_color->name = SetName((u32 *)&file_color->name);
- new_color->data = (void *)((u32)data+(u32)color_data);
+ new_color->data = (void *)((uintptr_t)data+(uintptr_t)color_data);
}
}
}
@@ -309,25 +380,40 @@ static void VertexLoad(void)
void *temp_data;
if(head.vertex.count) {
+#ifdef TARGET_PC
+ HsfBuffer32b *file_vertex_real = (HsfBuffer32b *)((uintptr_t)fileptr + head.vertex.ofs);
+ vtxtop = file_vertex = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfBuffer) * head.vertex.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.vertex.count; i++) {
+ byteswap_hsfbuffer(&file_vertex_real[i], &file_vertex[i]);
+ }
+#else
vtxtop = file_vertex = (HsfBuffer *)((u32)fileptr+head.vertex.ofs);
data = (void *)&file_vertex[head.vertex.count];
for(i=0; icount; j++) {
- data_elem = (HsfVector3f *)(((u32)data)+((u32)file_vertex->data)+(j*sizeof(HsfVector3f)));
+ data_elem = (HsfVector3f *)(((uintptr_t)data)+((uintptr_t)file_vertex->data)+(j*sizeof(HsfVector3f)));
}
}
+#endif
new_vertex = vtxtop;
Model.vertex = new_vertex;
Model.vertexCnt = head.vertex.count;
+#ifdef TARGET_PC
+ VertexDataTop = data = (void *)&file_vertex_real[head.vertex.count];
+#else
file_vertex = (HsfBuffer *)((u32)fileptr+head.vertex.ofs);
VertexDataTop = data = (void *)&file_vertex[head.vertex.count];
+#endif
for(i=0; idata;
new_vertex->count = file_vertex->count;
new_vertex->name = SetName((u32 *)&file_vertex->name);
- new_vertex->data = (void *)((u32)data+(u32)temp_data);
+ new_vertex->data = (void *)((uintptr_t)data + (uintptr_t)temp_data);
for(j=0; jcount; j++) {
- data_elem = (HsfVector3f *)(((u32)data)+((u32)temp_data)+(j*sizeof(HsfVector3f)));
+ data_elem = (HsfVector3f *)((uintptr_t)data + (uintptr_t)temp_data + (j * sizeof(HsfVector3f)));
+#ifdef TARGET_PC
+ byteswap_hsfvec3f(data_elem);
+#endif
((HsfVector3f *)new_vertex->data)[j].x = data_elem->x;
((HsfVector3f *)new_vertex->data)[j].y = data_elem->y;
((HsfVector3f *)new_vertex->data)[j].z = data_elem->z;
@@ -348,18 +434,38 @@ static void NormalLoad(void)
if(head.normal.count) {
s32 cenv_count = head.cenv.count;
+#ifdef TARGET_PC
+ HsfBuffer32b *file_normal_real = (HsfBuffer32b *)((uintptr_t)fileptr + head.normal.ofs);
+ temp_normal = file_normal = NormalTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfBuffer) * head.normal.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.normal.count; i++) {
+ byteswap_hsfbuffer(&file_normal_real[i], &file_normal[i]);
+ }
+#else
temp_normal = file_normal = (HsfBuffer *)((u32)fileptr+head.normal.ofs);
data = (void *)&file_normal[head.normal.count];
+#endif
new_normal = temp_normal;
Model.normal = new_normal;
Model.normalCnt = head.normal.count;
+#ifdef TARGET_PC
+ VertexDataTop = data = (void *)&file_normal_real[head.normal.count];
+#else
file_normal = (HsfBuffer *)((u32)fileptr+head.normal.ofs);
NormalDataTop = data = (void *)&file_normal[head.normal.count];
+#endif
for(i=0; idata;
new_normal->count = file_normal->count;
new_normal->name = SetName((u32 *)&file_normal->name);
- new_normal->data = (void *)((u32)data+(u32)temp_data);
+ new_normal->data = (void *)((uintptr_t)data+(uintptr_t)temp_data);
+#ifdef TARGET_PC
+ if (cenv_count != 0) {
+ for (i = 0; i < new_normal->count; i++) {
+ HsfVector3f *normalData = &((HsfVector3f *)new_normal->data)[i];
+ byteswap_hsfvec3f(normalData);
+ }
+ }
+#endif
}
}
}
@@ -375,6 +481,13 @@ static void STLoad(void)
void *temp_data;
if(head.st.count) {
+#ifdef TARGET_PC
+ HsfBuffer32b *file_st_real = (HsfBuffer32b *)((uintptr_t)fileptr + head.st.ofs);
+ temp_st = file_st = StTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfBuffer) * head.st.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.st.count; i++) {
+ byteswap_hsfbuffer(&file_st_real[i], &file_st[i]);
+ }
+#else
temp_st = file_st = (HsfBuffer *)((u32)fileptr+head.st.ofs);
data = (void *)&file_st[head.st.count];
for(i=0; idata)+(j*sizeof(HsfVector2f)));
}
}
+#endif
new_st = temp_st;
Model.st = new_st;
Model.stCnt = head.st.count;
+#ifdef TARGET_PC
+ data = (void *)&file_st_real[head.st.count];
+#else
file_st = (HsfBuffer *)((u32)fileptr+head.st.ofs);
data = (void *)&file_st[head.st.count];
+#endif
for(i=0; idata;
new_st->count = file_st->count;
new_st->name = SetName((u32 *)&file_st->name);
- new_st->data = (void *)((u32)data+(u32)temp_data);
+ new_st->data = (void *)((uintptr_t)data + (uintptr_t)temp_data);
for(j=0; jcount; j++) {
- data_elem = (HsfVector2f *)(((u32)data)+((u32)temp_data)+(j*sizeof(HsfVector2f)));
+ data_elem = (HsfVector2f *)((uintptr_t)data + (uintptr_t)temp_data + (j*sizeof(HsfVector2f)));
+#ifdef TARGET_PC
+ byteswap_hsfvec2f(data_elem);
+#endif
((HsfVector2f *)new_st->data)[j].x = data_elem->x;
((HsfVector2f *)new_st->data)[j].y = data_elem->y;
}
@@ -415,26 +536,57 @@ static void FaceLoad(void)
s32 j;
if(head.face.count) {
+#ifdef TARGET_PC
+ HsfBuffer32b *file_face_real = (HsfBuffer32b *)((uintptr_t)fileptr + head.face.ofs);
+ HsfFace32b *file_facedata_real = (HsfFace32b *)&file_face_real[head.face.count];
+ temp_face = file_face = FaceTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfBuffer) * head.face.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.face.count; i++) {
+ byteswap_hsfbuffer(&file_face_real[i], &file_face[i]);
+ }
+#else
temp_face = file_face = (HsfBuffer *)((u32)fileptr+head.face.ofs);
data = (HsfFace *)&file_face[head.face.count];
+#endif
new_face = temp_face;
Model.face = new_face;
Model.faceCnt = head.face.count;
+#ifdef __MWERKS__
file_face = (HsfBuffer *)((u32)fileptr+head.face.ofs);
data = (HsfFace *)&file_face[head.face.count];
+#endif
for(i=0; idata;
new_face->name = SetName((u32 *)&file_face->name);
new_face->count = file_face->count;
- new_face->data = (void *)((u32)data+(u32)temp_data);
+#ifdef TARGET_PC
+ {
+ HsfFace32b *facedata_start = (HsfFace32b *)((uintptr_t)file_facedata_real + (uintptr_t)temp_data);
+ data = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfFace) * new_face->count, MEMORY_DEFAULT_NUM);
+ for (j = 0; j < new_face->count; j++) {
+ byteswap_hsfface(&facedata_start[j], &data[j]);
+ }
+ new_face->data = data;
+ strip = (u8 *)(&facedata_start[new_face->count]);
+ }
+#else
+ new_face->data = (void *)((uintptr_t)data+(uintptr_t)temp_data);
strip = (u8 *)(&((HsfFace *)new_face->data)[new_face->count]);
+#endif
}
new_face = temp_face;
for(i=0; idata;
for(j=0; jcount; j++, new_face_strip++, file_face_strip++) {
if(AS_U16(file_face_strip->type) == 4) {
- new_face_strip->strip.data = (s16 *)(strip+(u32)file_face_strip->strip.data*(sizeof(s16)*4));
+ new_face_strip->strip.data = (s16 *)(strip+(uintptr_t)file_face_strip->strip.data*(sizeof(s16)*4));
+#ifdef TARGET_PC
+ {
+ s32 k;
+ for (k = 0; k < new_face_strip->strip.count; k++) {
+ byteswap_s16(&new_face_strip->strip.data[k]);
+ }
+ }
+#endif
}
}
}
@@ -463,9 +615,9 @@ static void DispObject(HsfObject *parent, HsfObject *object)
data = &object->data;
new_object = temp_object = object;
new_object->data.childrenCount = data->childrenCount;
- new_object->data.children = (HsfObject **)&NSymIndex[(u32)data->children];
+ new_object->data.children = (HsfObject **)&NSymIndex[(uintptr_t)data->children];
for(i=0; idata.childrenCount; i++) {
- child_obj = &objtop[(u32)new_object->data.children[i]];
+ child_obj = &objtop[(uintptr_t)new_object->data.children[i]];
new_object->data.children[i] = child_obj;
}
new_object->data.parent = parent;
@@ -478,14 +630,14 @@ static void DispObject(HsfObject *parent, HsfObject *object)
new_object->data.st = SearchStPtr((s32)data->st);
new_object->data.color = SearchColorPtr((s32)data->color);
new_object->data.face = SearchFacePtr((s32)data->face);
- new_object->data.vertexShape = (HsfBuffer **)&NSymIndex[(u32)data->vertexShape];
+ new_object->data.vertexShape = (HsfBuffer **)&NSymIndex[(uintptr_t)data->vertexShape];
for(i=0; idata.vertexShapeCnt; i++) {
- temp.shape = &vtxtop[(u32)new_object->data.vertexShape[i]];
+ temp.shape = &vtxtop[(uintptr_t)new_object->data.vertexShape[i]];
new_object->data.vertexShape[i] = temp.shape;
}
- new_object->data.cluster = (HsfCluster **)&NSymIndex[(u32)data->cluster];
+ new_object->data.cluster = (HsfCluster **)&NSymIndex[(uintptr_t)data->cluster];
for(i=0; idata.clusterCnt; i++) {
- temp.cluster = &ClusterTop[(u32)new_object->data.cluster[i]];
+ temp.cluster = &ClusterTop[(uintptr_t)new_object->data.cluster[i]];
new_object->data.cluster[i] = temp.cluster;
}
new_object->data.cenv = SearchCenvPtr((s32)data->cenv);
@@ -495,8 +647,8 @@ static void DispObject(HsfObject *parent, HsfObject *object)
} else {
new_object->data.attribute = NULL;
}
- new_object->data.file[0] = (void *)((u32)fileptr+(u32)data->file[0]);
- new_object->data.file[1] = (void *)((u32)fileptr+(u32)data->file[1]);
+ new_object->data.file[0] = (void *)((uintptr_t)fileptr + (uintptr_t)data->file[0]);
+ new_object->data.file[1] = (void *)((uintptr_t)fileptr + (uintptr_t)data->file[1]);
new_object->data.base.pos.x = data->base.pos.x;
new_object->data.base.pos.y = data->base.pos.y;
new_object->data.base.pos.z = data->base.pos.z;
@@ -526,9 +678,9 @@ static void DispObject(HsfObject *parent, HsfObject *object)
new_object = temp_object = object;
new_object->data.parent = parent;
new_object->data.childrenCount = data->childrenCount;
- new_object->data.children = (HsfObject **)&NSymIndex[(u32)data->children];
+ new_object->data.children = (HsfObject **)&NSymIndex[(uintptr_t)data->children];
for(i=0; idata.childrenCount; i++) {
- child_obj = &objtop[(u32)new_object->data.children[i]];
+ child_obj = &objtop[(uintptr_t)new_object->data.children[i]];
new_object->data.children[i] = child_obj;
}
if(Model.root == NULL) {
@@ -548,15 +700,15 @@ static void DispObject(HsfObject *parent, HsfObject *object)
new_object = temp_object = object;
new_object->data.parent = parent;
new_object->data.childrenCount = data->childrenCount;
- new_object->data.children = (HsfObject **)&NSymIndex[(u32)data->children];
+ new_object->data.children = (HsfObject **)&NSymIndex[(uintptr_t)data->children];
for(i=0; idata.childrenCount; i++) {
- child_obj = &objtop[(u32)new_object->data.children[i]];
+ child_obj = &objtop[(uintptr_t)new_object->data.children[i]];
new_object->data.children[i] = child_obj;
}
if(Model.root == NULL) {
Model.root = temp_object;
}
- new_object->data.replica = &objtop[(u32)new_object->data.replica];
+ new_object->data.replica = &objtop[(uintptr_t)new_object->data.replica];
for(i=0; ichildrenCount; i++) {
DispObject(new_object, new_object->data.children[i]);
}
@@ -691,7 +843,15 @@ static void ObjectLoad(void)
s32 obj_type;
if(head.object.count) {
+#ifdef TARGET_PC
+ HsfObject32b *file_object_real = (HsfObject32b *)((uintptr_t)fileptr + head.object.ofs);
+ objtop = object = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfObject) * head.object.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.object.count; i++) {
+ byteswap_hsfobject(&file_object_real[i], &objtop[i]);
+ }
+#else
objtop = object = (HsfObject *)((u32)fileptr+head.object.ofs);
+#endif
for(i=0; iname = SetName((u32 *)&object->name);
@@ -729,24 +889,37 @@ static void CenvLoad(void)
s32 i;
if(head.cenv.count) {
+#ifdef TARGET_PC
+ HsfCenv32b *file_cenv_real = (HsfCenv32b *)((uintptr_t)fileptr + head.cenv.ofs);
+ cenv_file = CenvTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfCenv) * head.cenv.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.cenv.count; i++) {
+ byteswap_hsfcenv(&file_cenv_real[i], &cenv_file[i]);
+ }
+ data_base = &file_cenv_real[head.cenv.count];
+#else
cenv_file = (HsfCenv *)((u32)fileptr+head.cenv.ofs);
data_base = &cenv_file[head.cenv.count];
+#endif
weight_base = data_base;
cenv_new = cenv_file;
Model.cenvCnt = head.cenv.count;
Model.cenv = cenv_file;
for(i=0; iname = SetName((u32 *)&part_file[i].name);
part_new->count = part_file[i].count;
- part_new->vertex = &data[(u32)part_file[i].vertex];
+ part_new->vertex = &data[(uintptr_t)part_file[i].vertex];
for(j=0; jcount; j++) {
part_new->vertex[j] = part_new->vertex[j];
+#ifdef TARGET_PC
+ byteswap_u16(&part_new->vertex[j]);
+#endif
}
}
}
@@ -845,7 +1041,11 @@ static void ClusterLoad(void)
s32 i, j;
if(head.cluster.count) {
+#ifdef TARGET_PC
+ cluster_new = cluster_file = ClusterTop;
+#else
cluster_new = cluster_file = (HsfCluster *)((u32)fileptr+head.cluster.ofs);
+#endif
Model.clusterCnt = head.cluster.count;
Model.cluster = cluster_file;
for(i=0; idata = &data[(u32)mapattr_file->data];
}
@@ -925,14 +1145,26 @@ static void BitmapLoad(void)
s32 i;
if(head.bitmap.count) {
+#ifdef TARGET_PC
+ HsfBitmap32b *file_bitmap_real = (HsfBitmap32b *)((uintptr_t)fileptr + head.bitmap.ofs);
+ bitmap_temp = bitmap_file = BitmapTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfBitmap) * head.bitmap.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.bitmap.count; i++) {
+ byteswap_hsfbitmap(&file_bitmap_real[i], &bitmap_file[i]);
+ }
+#else
bitmap_temp = bitmap_file = (HsfBitmap *)((u32)fileptr+head.bitmap.ofs);
data = &bitmap_file[head.bitmap.count];
for(i=0; iname = SetName((u32 *)&bitmap_file->name);
bitmap_new->dataFmt = bitmap_file->dataFmt;
@@ -940,11 +1172,11 @@ static void BitmapLoad(void)
bitmap_new->sizeX = bitmap_file->sizeX;
bitmap_new->sizeY = bitmap_file->sizeY;
bitmap_new->palSize = bitmap_file->palSize;
- palette = SearchPalettePtr((u32)bitmap_file->palData);
+ palette = SearchPalettePtr((uintptr_t)bitmap_file->palData);
if(palette) {
bitmap_new->palData = palette->data;
}
- bitmap_new->data = (void *)((u32)data+(u32)bitmap_file->data);
+ bitmap_new->data = (void *)((uintptr_t)data+(uintptr_t)bitmap_file->data);
}
}
}
@@ -962,24 +1194,39 @@ static void PaletteLoad(void)
u16 *data;
if(head.palette.count) {
+#ifdef TARGET_PC
+ HsfPalette32b *file_palette_real = (HsfPalette32b *)((uintptr_t)fileptr + head.palette.ofs);
+ palette_temp = palette_file = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfPalette) * head.palette.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.palette.count; i++) {
+ byteswap_hsfpalette(&file_palette_real[i], &palette_file[i]);
+ }
+#else
palette_temp = palette_file = (HsfPalette *)((u32)fileptr+head.palette.ofs);
data_base = (u16 *)&palette_file[head.palette.count];
for(i=0; idata);
+ temp_data = (u16 *)((uintptr_t)data_base+(uintptr_t)palette_file->data);
}
+#endif
Model.palette = palette_temp;
Model.paletteCnt = head.palette.count;
palette_new = palette_temp;
+#ifdef TARGET_PC
+ data_base = (u16 *)&file_palette_real[head.palette.count];
+#else
palette_file = (HsfPalette *)((u32)fileptr+head.palette.ofs);
data_base = (u16 *)&palette_file[head.palette.count];
+#endif
for(i=0; idata);
+ temp_data = (u16 *)((uintptr_t)data_base+(uintptr_t)palette_file->data);
data = temp_data;
palette_new->name = SetName((u32 *)&palette_file->name);
palette_new->data = data;
palette_new->palSize = palette_file->palSize;
for(j=0; jpalSize; j++) {
data[j] = data[j];
+#ifdef TARGET_PC
+ byteswap_u16(&data[j]);
+#endif
}
}
}
@@ -1126,21 +1373,21 @@ static inline void MotionLoadTransform(HsfTrack *track, void *data)
switch(track->curveType) {
case HSF_CURVE_STEP:
{
- step_data = (float *)((u32)data+(u32)track->data);
+ step_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = step_data;
}
break;
case HSF_CURVE_LINEAR:
{
- linear_data = (float *)((u32)data+(u32)track->data);
+ linear_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = linear_data;
}
break;
case HSF_CURVE_BEZIER:
{
- bezier_data = (float *)((u32)data+(u32)track->data);
+ bezier_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = bezier_data;
}
break;
@@ -1171,21 +1418,21 @@ static inline void MotionLoadCluster(HsfTrack *track, void *data)
switch(track->curveType) {
case HSF_CURVE_STEP:
{
- step_data = (float *)((u32)data+(u32)track->data);
+ step_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = step_data;
}
break;
case HSF_CURVE_LINEAR:
{
- linear_data = (float *)((u32)data+(u32)track->data);
+ linear_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = linear_data;
}
break;
case HSF_CURVE_BEZIER:
{
- bezier_data = (float *)((u32)data+(u32)track->data);
+ bezier_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = bezier_data;
}
break;
@@ -1216,21 +1463,21 @@ static inline void MotionLoadClusterWeight(HsfTrack *track, void *data)
switch(track->curveType) {
case HSF_CURVE_STEP:
{
- step_data = (float *)((u32)data+(u32)track->data);
+ step_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = step_data;
}
break;
case HSF_CURVE_LINEAR:
{
- linear_data = (float *)((u32)data+(u32)track->data);
+ linear_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = linear_data;
}
break;
case HSF_CURVE_BEZIER:
{
- bezier_data = (float *)((u32)data+(u32)track->data);
+ bezier_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = bezier_data;
}
break;
@@ -1252,21 +1499,21 @@ static inline void MotionLoadMaterial(HsfTrack *track, void *data)
switch(track->curveType) {
case HSF_CURVE_STEP:
{
- step_data = (float *)((u32)data+(u32)track->data);
+ step_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = step_data;
}
break;
case HSF_CURVE_LINEAR:
{
- linear_data = (float *)((u32)data+(u32)track->data);
+ linear_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = linear_data;
}
break;
case HSF_CURVE_BEZIER:
{
- bezier_data = (float *)((u32)data+(u32)track->data);
+ bezier_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = bezier_data;
}
break;
@@ -1299,30 +1546,38 @@ static inline void MotionLoadAttribute(HsfTrack *track, void *data)
switch(track->curveType) {
case HSF_CURVE_STEP:
{
- step_data = (float *)((u32)data+(u32)track->data);
+ step_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = step_data;
}
break;
case HSF_CURVE_LINEAR:
{
- linear_data = (float *)((u32)data+(u32)track->data);
+ linear_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = linear_data;
}
break;
case HSF_CURVE_BEZIER:
{
- bezier_data = (float *)((u32)data+(u32)track->data);
+ bezier_data = (float *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = bezier_data;
}
break;
case HSF_CURVE_BITMAP:
{
- new_frame = file_frame = (HsfBitmapKey *)((u32)data+(u32)track->data);
+#ifdef TARGET_PC
+ HsfBitmapKey32b *file_frame_real = (HsfBitmapKey32b *)((uintptr_t)data + (uintptr_t)track->data);
+ new_frame = file_frame = track->dataTop = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfBitmapKey) * track->numKeyframes, MEMORY_DEFAULT_NUM);
+#else
+ new_frame = file_frame = (HsfBitmapKey *)((uintptr_t)data + (uintptr_t)track->data);
out_track->data = file_frame;
+#endif
for(i=0; inumKeyframes; i++, file_frame++, new_frame++) {
+#ifdef TARGET_PC
+ byteswap_hsfbitmapkey(&file_frame_real[i], new_frame);
+#endif
new_frame->data = SearchBitmapPtr((s32)file_frame->data);
}
}
@@ -1344,12 +1599,31 @@ static void MotionLoad(void)
MotionOnly = FALSE;
MotionModel = NULL;
if(head.motion.count) {
- temp_motion = file_motion = (HsfMotion *)((u32)fileptr+head.motion.ofs);
+#ifdef TARGET_PC
+ HsfMotion32b *file_motion_real = (HsfMotion32b *)((uintptr_t)fileptr + head.motion.ofs);
+ temp_motion = file_motion = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfMotion) * head.motion.count, MEMORY_DEFAULT_NUM);
+ for (i = 0; i < head.motion.count; i++) {
+ byteswap_hsfmotion(&file_motion_real[i], &file_motion[i]);
+ }
+#else
+ temp_motion = file_motion = (HsfMotion *)((uintptr_t)fileptr+head.motion.ofs);
+#endif
new_motion = temp_motion;
Model.motion = new_motion;
Model.motionCnt = file_motion->numTracks;
+#ifdef TARGET_PC
+ {
+ HsfTrack32b *track_base_real = (HsfTrack32b *)&file_motion_real[head.motion.count];
+ track_base = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfTrack) * file_motion->numTracks, MEMORY_DEFAULT_NUM);
+ track_data = &track_base_real[file_motion->numTracks];
+ for (i = 0; i < file_motion->numTracks; i++) {
+ byteswap_hsftrack(&track_base_real[i], &track_base[i]);
+ }
+ }
+#else
track_base = (HsfTrack *)&file_motion[head.motion.count];
track_data = &track_base[file_motion->numTracks];
+#endif
new_motion->track = track_base;
for(i=0; i<(s32)file_motion->numTracks; i++) {
switch(track_base[i].type) {
@@ -1410,8 +1684,13 @@ static void MatrixLoad(void)
HsfMatrix *matrix_file;
if(head.matrix.count) {
- matrix_file = (HsfMatrix *)((u32)fileptr+head.matrix.ofs);
+#ifdef TARGET_PC
+ matrix_file = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfMatrix) * head.matrix.count, MEMORY_DEFAULT_NUM);
+ byteswap_hsfmatrix((HsfMatrix *)((uintptr_t)fileptr + head.matrix.ofs));
+#else
+ matrix_file = (HsfMatrix *)((uintptr_t)fileptr+head.matrix.ofs);
matrix_file->data = (Mtx *)((u32)fileptr+head.matrix.ofs+sizeof(HsfMatrix));
+#endif
Model.matrix = matrix_file;
Model.matrixCnt = head.matrix.count;
}
@@ -1436,7 +1715,11 @@ static HsfBuffer *SearchVertexPtr(s32 id)
if(id == -1) {
return NULL;
}
- vertex = (HsfBuffer *)((u32)fileptr+head.vertex.ofs);
+#ifdef TARGET_PC
+ vertex = vtxtop;
+#else
+ vertex = (HsfBuffer *)((uintptr_t)fileptr+head.vertex.ofs);
+#endif
vertex += id;
return vertex;
}
@@ -1447,7 +1730,11 @@ static HsfBuffer *SearchNormalPtr(s32 id)
if(id == -1) {
return NULL;
}
- normal = (HsfBuffer *)((u32)fileptr+head.normal.ofs);
+#ifdef TARGET_PC
+ normal = NormalTop;
+#else
+ normal = (HsfBuffer *)((uintptr_t)fileptr+head.normal.ofs);
+#endif
normal += id;
return normal;
}
@@ -1458,7 +1745,11 @@ static HsfBuffer *SearchStPtr(s32 id)
if(id == -1) {
return NULL;
}
- st = (HsfBuffer *)((u32)fileptr+head.st.ofs);
+#ifdef TARGET_PC
+ st = StTop;
+#else
+ st = (HsfBuffer *)((uintptr_t)fileptr+head.st.ofs);
+#endif
st += id;
return st;
}
@@ -1469,7 +1760,11 @@ static HsfBuffer *SearchColorPtr(s32 id)
if(id == -1) {
return NULL;
}
- color = (HsfBuffer *)((u32)fileptr+head.color.ofs);
+#ifdef TARGET_PC
+ color = ColorTop;
+#else
+ color = (HsfBuffer *)((uintptr_t)fileptr+head.color.ofs);
+#endif
color += id;
return color;
}
@@ -1480,7 +1775,11 @@ static HsfBuffer *SearchFacePtr(s32 id)
if(id == -1) {
return NULL;
}
- face = (HsfBuffer *)((u32)fileptr+head.face.ofs);
+#ifdef TARGET_PC
+ face = FaceTop;
+#else
+ face = (HsfBuffer *)((uintptr_t)fileptr+head.face.ofs);
+#endif
face += id;
return face;
}
@@ -1491,7 +1790,11 @@ static HsfCenv *SearchCenvPtr(s32 id)
if(id == -1) {
return NULL;
}
- cenv = (HsfCenv *)((u32)fileptr+head.cenv.ofs);
+#ifdef TARGET_PC
+ cenv = CenvTop;
+#else
+ cenv = (HsfCenv *)((uintptr_t)fileptr + head.cenv.ofs);
+#endif
cenv += id;
return cenv;
}
@@ -1502,7 +1805,11 @@ static HsfPart *SearchPartPtr(s32 id)
if(id == -1) {
return NULL;
}
- part = (HsfPart *)((u32)fileptr+head.part.ofs);
+#ifdef TARGET_PC
+ part = PartTop;
+#else
+ part = (HsfPart *)((uintptr_t)fileptr+head.part.ofs);
+#endif
part += id;
return part;
}
@@ -1524,7 +1831,11 @@ static HsfBitmap *SearchBitmapPtr(s32 id)
if(id == -1) {
return NULL;
}
- bitmap = (HsfBitmap *)((u32)fileptr+head.bitmap.ofs);
+#ifdef TARGET_PC
+ bitmap = BitmapTop;
+#else
+ bitmap = (HsfBitmap *)((uintptr_t)fileptr+head.bitmap.ofs);
+#endif
bitmap += id;
return bitmap;
}
@@ -1539,4 +1850,45 @@ static char *GetMotionString(u16 *str_ofs)
{
char *ret = &StringTable[*str_ofs];
return ret;
-}
\ No newline at end of file
+}
+
+#ifdef TARGET_PC
+void KillHSF(HsfData *data)
+{
+ s32 i, j;
+ HuMemDirectFree(data->attribute);
+ HuMemDirectFree(data->bitmap);
+ HuMemDirectFree(data->cenv);
+ HuMemDirectFree(data->skeleton);
+ for (i = 0; i < data->faceCnt; i++) {
+ HuMemDirectFree(data->face[i].data);
+ }
+ HuMemDirectFree(data->face);
+ HuMemDirectFree(data->material);
+ for (i = 0; i < data->motionCnt; i++) {
+ HsfMotion *motion = &data->motion[i];
+ for (j = 0; j < motion->numTracks; j++) {
+ HsfTrack *track = data->motion[i].track;
+ if (track->type == HSF_TRACK_ATTRIBUTE && track->curveType == HSF_CURVE_BITMAP) {
+ // in this case we needed to allocate space for HsfBitmapKey structs
+ HuMemDirectFree(track->dataTop);
+ }
+ }
+ HuMemDirectFree(motion->track);
+ }
+ HuMemDirectFree(data->motion);
+ HuMemDirectFree(data->normal);
+ HuMemDirectFree(data->object);
+ HuMemDirectFree(data->matrix);
+ HuMemDirectFree(data->palette);
+ HuMemDirectFree(data->st);
+ HuMemDirectFree(data->vertex);
+ HuMemDirectFree(data->cenv);
+ HuMemDirectFree(data->cluster);
+ HuMemDirectFree(data->part);
+ HuMemDirectFree(data->shape);
+ HuMemDirectFree(data->mapAttr);
+ HuMemDirectFree(data->symbol);
+ // TODO PC free embedded data
+}
+#endif
diff --git a/src/game/hsfman.c b/src/game/hsfman.c
index 7ef634ac..4ed699b0 100644
--- a/src/game/hsfman.c
+++ b/src/game/hsfman.c
@@ -43,7 +43,7 @@ s32 shadowModelDrawF;
s16 Hu3DProjectionNum;
s16 Hu3DCameraNo;
s16 Hu3DCameraBit;
-u32 Hu3DMallocNo;
+uintptr_t Hu3DMallocNo;
s16 Hu3DPauseF;
u16 Hu3DCameraExistF;
static u16 NoSyncF;
@@ -350,7 +350,7 @@ s16 Hu3DModelCreate(void *arg0) {
return -1;
}
var_r31->hsfData = LoadHSF(arg0);
- var_r31->unk_48 = Hu3DMallocNo = (u32)var_r31->hsfData;
+ var_r31->unk_48 = Hu3DMallocNo = (uintptr_t)var_r31->hsfData;
var_r31->attr = HU3D_ATTR_NONE;
var_r31->motion_attr = HU3D_ATTR_NONE;
var_r31->unk_02 = 0;
@@ -453,7 +453,7 @@ s16 Hu3DModelLink(s16 arg0) {
for (i = 0; i < 4; i++) {
var_r31->unk_10[i] = temp_r30->unk_10[i];
if (var_r31->unk_10[i] != -1) {
- ClusterAdjustObject(var_r31->hsfData, Hu3DMotion[var_r31->unk_10[i]].unk_04);
+ ClusterAdjustObject(var_r31->hsfData, Hu3DMotion[var_r31->unk_10[i]].hsfData);
var_r31->attr |= HU3D_ATTR_CLUSTER_ON;
}
}
@@ -564,6 +564,9 @@ void Hu3DModelKill(s16 arg0) {
}
Hu3DAnimModelKill(arg0);
if (temp_r31->unk_24 != -1) {
+#ifdef TARGET_PC
+ KillHSF(temp_r31->hsfData);
+#endif
HuMemDirectFree(temp_r31->hsfData);
HuMemDirectFreeNum(HEAP_DATA, temp_r31->unk_4C);
var_r28 = temp_r31->unk_C8;
@@ -581,7 +584,7 @@ void Hu3DModelKill(s16 arg0) {
if (temp_r31->unk_20 != -1) {
for (i = 0; i < HU3D_MODEL_MAX; i++, var_r30++) {
if (var_r30->hsfData != 0 && var_r30->unk_24 != -1 && var_r30->unk_C8 == var_r28) {
- Hu3DMotion[temp_r31->unk_20].unk_02 = i;
+ Hu3DMotion[temp_r31->unk_20].modelId = i;
break;
}
}
@@ -592,7 +595,7 @@ void Hu3DModelKill(s16 arg0) {
return;
}
if (temp_r31->unk_20 != -1 && Hu3DMotionKill(temp_r31->unk_20) == 0) {
- Hu3DMotion[temp_r31->unk_20].unk_02 = -1;
+ Hu3DMotion[temp_r31->unk_20].modelId = -1;
HuMemDirectFreeNum(HEAP_DATA, temp_r31->unk_48);
temp_r31->hsfData = NULL;
if (modelKillAllF == 0) {
@@ -600,6 +603,9 @@ void Hu3DModelKill(s16 arg0) {
}
return;
}
+#ifdef TARGET_PC
+ KillHSF(temp_r31->hsfData);
+#endif
HuMemDirectFree(temp_r31->hsfData);
HuMemDirectFreeNum(HEAP_DATA, temp_r31->unk_48);
for (i = 0; i < temp_r31->unk_26; i++) {
diff --git a/src/game/hsfmotion.c b/src/game/hsfmotion.c
index 010b5fb1..45f9b575 100644
--- a/src/game/hsfmotion.c
+++ b/src/game/hsfmotion.c
@@ -1,18 +1,19 @@
#include "game/hsfmotion.h"
#include "game/ClusterExec.h"
#include "game/EnvelopeExec.h"
+#include "game/ShapeExec.h"
#include "game/hsfdraw.h"
#include "game/hsfload.h"
#include "game/hsfman.h"
#include "game/init.h"
-#include "game/ShapeExec.h"
+
#include "ext_math.h"
#include "string.h"
-#define HU3D_MOTATTR_SHIFT_ALL (HU3D_MOTATTR_SHIFT_LOOP|HU3D_MOTATTR_SHIFT_PAUSE|HU3D_MOTATTR_SHIFT_REV)
-#define HU3D_MOTATTR_NOSHIFT_ALL (HU3D_MOTATTR_LOOP|HU3D_MOTATTR_PAUSE|HU3D_MOTATTR_REV)
-#define HU3D_MOTATTR_ALL (HU3D_MOTATTR_SHIFT_ALL|HU3D_MOTATTR_NOSHIFT_ALL)
+#define HU3D_MOTATTR_SHIFT_ALL (HU3D_MOTATTR_SHIFT_LOOP | HU3D_MOTATTR_SHIFT_PAUSE | HU3D_MOTATTR_SHIFT_REV)
+#define HU3D_MOTATTR_NOSHIFT_ALL (HU3D_MOTATTR_LOOP | HU3D_MOTATTR_PAUSE | HU3D_MOTATTR_REV)
+#define HU3D_MOTATTR_ALL (HU3D_MOTATTR_SHIFT_ALL | HU3D_MOTATTR_NOSHIFT_ALL)
static s32 SearchObjectIndex(HsfData *arg0, u32 arg1);
static s32 SearchAttributeIndex(HsfData *arg0, u32 arg1);
@@ -21,23 +22,25 @@ MotionData Hu3DMotion[HU3D_MOTION_MAX];
static HsfBitmap *bitMapPtr;
-void Hu3DMotionInit(void) {
+void Hu3DMotionInit(void)
+{
MotionData *var_r31;
s16 i;
- var_r31 = (MotionData*) Hu3DData;
+ var_r31 = (MotionData *)Hu3DData;
for (i = 0; i < HU3D_MOTION_MAX; i++, var_r31++) {
- var_r31->unk_04 = 0;
+ var_r31->hsfData = 0;
}
}
-s16 Hu3DMotionCreate(void *arg0) {
+s16 Hu3DMotionCreate(void *arg0)
+{
MotionData *var_r31;
s16 i;
var_r31 = Hu3DMotion;
for (i = 0; i < HU3D_MOTION_MAX; i++, var_r31++) {
- if (var_r31->unk_04 == 0) {
+ if (var_r31->hsfData == 0) {
break;
}
}
@@ -45,20 +48,21 @@ s16 Hu3DMotionCreate(void *arg0) {
OSReport("Error: Create Motion Over!\n");
return -1;
}
- var_r31->unk_04 = LoadHSF(arg0);
- var_r31->unk_00 = 0;
- var_r31->unk_02 = -1;
+ var_r31->hsfData = LoadHSF(arg0);
+ var_r31->attr = 0;
+ var_r31->modelId = -1;
return i;
}
-s16 Hu3DMotionModelCreate(s16 arg0) {
+s16 Hu3DMotionModelCreate(s16 arg0)
+{
ModelData *temp_r29 = &Hu3DData[arg0];
MotionData *var_r31;
s16 i;
var_r31 = Hu3DMotion;
for (i = 0; i < HU3D_MOTION_MAX; i++, var_r31++) {
- if (var_r31->unk_04 == 0) {
+ if (var_r31->hsfData == 0) {
break;
}
}
@@ -66,53 +70,60 @@ s16 Hu3DMotionModelCreate(s16 arg0) {
OSReport("Error: Create Motion Over!\n");
return -1;
}
- var_r31->unk_04 = temp_r29->hsfData;
- var_r31->unk_00 = 0;
- var_r31->unk_02 = arg0;
+ var_r31->hsfData = temp_r29->hsfData;
+ var_r31->attr = 0;
+ var_r31->modelId = arg0;
temp_r29->unk_20 = i;
return i;
}
-s32 Hu3DMotionKill(s16 arg0) {
+s32 Hu3DMotionKill(s16 arg0)
+{
ModelData *var_r30;
MotionData *temp_r31;
s16 i;
temp_r31 = &Hu3DMotion[arg0];
- if (temp_r31->unk_04 == 0) {
+ if (temp_r31->hsfData == 0) {
return 0;
}
var_r30 = Hu3DData;
for (i = 0; i < 512; i++, var_r30++) {
- if (var_r30->hsfData && var_r30->unk_08 == arg0 && temp_r31->unk_02 != i) {
+ if (var_r30->hsfData && var_r30->unk_08 == arg0 && temp_r31->modelId != i) {
break;
}
}
if (i != 512) {
return 0;
}
- if (temp_r31->unk_02 == -1) {
- HuMemDirectFree(temp_r31->unk_04);
- } else {
- Hu3DData[temp_r31->unk_02].unk_20 = -1;
+ if (temp_r31->modelId == -1) {
+#ifdef TARGET_PC
+ KillHSF(temp_r31->hsfData);
+#endif
+ HuMemDirectFree(temp_r31->hsfData);
}
- temp_r31->unk_04 = NULL;
+ else {
+ Hu3DData[temp_r31->modelId].unk_20 = -1;
+ }
+ temp_r31->hsfData = NULL;
return 1;
}
-void Hu3DMotionAllKill(void) {
+void Hu3DMotionAllKill(void)
+{
MotionData *var_r27;
s16 i;
var_r27 = Hu3DMotion;
for (i = 0; i < HU3D_MOTION_MAX; i++, var_r27++) {
- if (var_r27->unk_04) {
+ if (var_r27->hsfData) {
Hu3DMotionKill(i);
}
}
}
-void Hu3DMotionSet(s16 arg0, s16 arg1) {
+void Hu3DMotionSet(s16 arg0, s16 arg1)
+{
Hu3DData[arg0].unk_0C = -1;
Hu3DData[arg0].unk_08 = arg1;
Hu3DData[arg0].unk_64 = 0.0f;
@@ -120,29 +131,35 @@ void Hu3DMotionSet(s16 arg0, s16 arg1) {
Hu3DData[arg0].unk_70 = Hu3DMotionMaxTimeGet(arg0);
}
-void Hu3DMotionOverlaySet(s16 arg0, s16 arg1) {
+void Hu3DMotionOverlaySet(s16 arg0, s16 arg1)
+{
Hu3DData[arg0].unk_0A = arg1;
Hu3DData[arg0].unk_74 = 0.0f;
Hu3DData[arg0].unk_78 = 1.0f;
}
-void Hu3DMotionOverlayReset(s16 arg0) {
+void Hu3DMotionOverlayReset(s16 arg0)
+{
Hu3DData[arg0].unk_0A = -1;
}
-float Hu3DMotionOverlayTimeGet(s16 arg0) {
+float Hu3DMotionOverlayTimeGet(s16 arg0)
+{
return Hu3DData[arg0].unk_74;
}
-void Hu3DMotionOverlayTimeSet(s16 arg0, float arg1) {
+void Hu3DMotionOverlayTimeSet(s16 arg0, float arg1)
+{
Hu3DData[arg0].unk_74 = arg1;
}
-void Hu3DMotionOverlaySpeedSet(s16 arg0, float arg1) {
+void Hu3DMotionOverlaySpeedSet(s16 arg0, float arg1)
+{
Hu3DData[arg0].unk_78 = arg1;
}
-void Hu3DMotionShiftSet(s16 arg0, s16 arg1, float arg2, float arg3, u32 arg4) {
+void Hu3DMotionShiftSet(s16 arg0, s16 arg1, float arg2, float arg3, u32 arg4)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
MotionData *sp10 = &Hu3DMotion[arg1];
s32 var_r30;
@@ -167,7 +184,8 @@ void Hu3DMotionShiftSet(s16 arg0, s16 arg1, float arg2, float arg3, u32 arg4) {
temp_r31->motion_attr &= ~HU3D_MOTATTR_ALL;
temp_r31->motion_attr |= var_r30;
temp_r31->motion_attr &= ~HU3D_MOTATTR;
- } else {
+ }
+ else {
temp_r31->motion_attr &= ~HU3D_MOTATTR_SHIFT_ALL;
}
temp_r31->unk_0C = arg1;
@@ -191,7 +209,8 @@ void Hu3DMotionShiftSet(s16 arg0, s16 arg1, float arg2, float arg3, u32 arg4) {
temp_r31->motion_attr &= ~HU3D_MOTATTR;
}
-void Hu3DMotionShapeSet(s16 arg0, s16 arg1) {
+void Hu3DMotionShapeSet(s16 arg0, s16 arg1)
+{
Hu3DData[arg0].unk_0E = arg1;
Hu3DData[arg0].unk_94 = 0.0f;
Hu3DData[arg0].unk_98 = 1.0f;
@@ -199,34 +218,40 @@ void Hu3DMotionShapeSet(s16 arg0, s16 arg1) {
Hu3DData[arg0].unk_A0 = Hu3DMotionShapeMaxTimeGet(arg0);
}
-s16 Hu3DMotionShapeIDGet(s16 arg0) {
+s16 Hu3DMotionShapeIDGet(s16 arg0)
+{
return Hu3DData[arg0].unk_0E;
}
-void Hu3DMotionShapeSpeedSet(s16 arg0, float arg1) {
+void Hu3DMotionShapeSpeedSet(s16 arg0, float arg1)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
temp_r31->unk_98 = arg1;
}
-void Hu3DMotionShapeTimeSet(s16 arg0, float arg1) {
+void Hu3DMotionShapeTimeSet(s16 arg0, float arg1)
+{
Hu3DData[arg0].unk_94 = arg1;
}
-float Hu3DMotionShapeMaxTimeGet(s16 arg0) {
+float Hu3DMotionShapeMaxTimeGet(s16 arg0)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
return Hu3DMotionMotionMaxTimeGet(temp_r31->unk_0E);
}
-void Hu3DMotionShapeStartEndSet(s16 arg0, float arg1, float arg2) {
+void Hu3DMotionShapeStartEndSet(s16 arg0, float arg1, float arg2)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
temp_r31->unk_9C = arg1;
temp_r31->unk_A0 = arg2;
}
-s16 Hu3DMotionClusterSet(s16 arg0, s16 arg1) {
+s16 Hu3DMotionClusterSet(s16 arg0, s16 arg1)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
s16 i;
@@ -237,7 +262,7 @@ s16 Hu3DMotionClusterSet(s16 arg0, s16 arg1) {
temp_r31->unk_B4[i] = 1.0f;
temp_r31->cluster_attr[i] = HU3D_ATTR_NONE;
temp_r31->attr |= HU3D_ATTR_CLUSTER_ON;
- ClusterAdjustObject(temp_r31->hsfData, Hu3DMotion[arg1].unk_04);
+ ClusterAdjustObject(temp_r31->hsfData, Hu3DMotion[arg1].hsfData);
return i;
}
}
@@ -245,7 +270,8 @@ s16 Hu3DMotionClusterSet(s16 arg0, s16 arg1) {
return -1;
}
-s16 Hu3DMotionClusterNoSet(s16 arg0, s16 arg1, s16 arg2) {
+s16 Hu3DMotionClusterNoSet(s16 arg0, s16 arg1, s16 arg2)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
Hu3DMotionClusterReset(arg0, arg2);
@@ -253,15 +279,17 @@ s16 Hu3DMotionClusterNoSet(s16 arg0, s16 arg1, s16 arg2) {
temp_r31->unk_A4[arg2] = 0.0f;
temp_r31->unk_B4[arg2] = 1.0f;
temp_r31->attr |= HU3D_ATTR_CLUSTER_ON;
- ClusterAdjustObject(temp_r31->hsfData, Hu3DMotion[arg1].unk_04);
+ ClusterAdjustObject(temp_r31->hsfData, Hu3DMotion[arg1].hsfData);
return arg2;
}
-void Hu3DMotionShapeReset(s16 arg0) {
+void Hu3DMotionShapeReset(s16 arg0)
+{
Hu3DData[arg0].unk_0E = -1;
}
-void Hu3DMotionClusterReset(s16 arg0, s16 arg1) {
+void Hu3DMotionClusterReset(s16 arg0, s16 arg1)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
s16 i;
@@ -270,7 +298,8 @@ void Hu3DMotionClusterReset(s16 arg0, s16 arg1) {
temp_r31->unk_10[i] = -1;
}
temp_r31->attr &= ~HU3D_ATTR_CLUSTER_ON;
- } else {
+ }
+ else {
temp_r31->unk_10[arg1] = -1;
for (i = 0; i < 4; i++) {
if (temp_r31->unk_10[i] != -1) {
@@ -281,19 +310,22 @@ void Hu3DMotionClusterReset(s16 arg0, s16 arg1) {
}
}
-s16 Hu3DMotionIDGet(s16 arg0) {
+s16 Hu3DMotionIDGet(s16 arg0)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
return temp_r31->unk_08;
}
-s16 Hu3DMotionShiftIDGet(s16 arg0) {
+s16 Hu3DMotionShiftIDGet(s16 arg0)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
return temp_r31->unk_0C;
}
-void Hu3DMotionTimeSet(s16 arg0, float arg1) {
+void Hu3DMotionTimeSet(s16 arg0, float arg1)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
if (Hu3DMotionMaxTimeGet(arg0) <= arg1) {
@@ -303,7 +335,7 @@ void Hu3DMotionTimeSet(s16 arg0, float arg1) {
arg1 = 0.0f;
}
temp_r31->unk_64 = arg1;
- if (temp_r31->hsfData != (HsfData*) -1 && temp_r31->hsfData->cenvCnt != 0 && (temp_r31->motion_attr & HU3D_MOTATTR_PAUSE)) {
+ if (temp_r31->hsfData != (HsfData *)-1 && temp_r31->hsfData->cenvCnt != 0 && (temp_r31->motion_attr & HU3D_MOTATTR_PAUSE)) {
Hu3DMotionExec(arg0, temp_r31->unk_08, arg1, 0);
if (temp_r31->unk_0C != -1) {
Hu3DSubMotionExec(arg0);
@@ -312,19 +344,22 @@ void Hu3DMotionTimeSet(s16 arg0, float arg1) {
}
}
-float Hu3DMotionTimeGet(s16 arg0) {
+float Hu3DMotionTimeGet(s16 arg0)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
return temp_r31->unk_64;
}
-float Hu3DMotionShiftTimeGet(s16 arg0) {
+float Hu3DMotionShiftTimeGet(s16 arg0)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
return temp_r31->unk_84;
}
-float Hu3DMotionMaxTimeGet(s16 arg0) {
+float Hu3DMotionMaxTimeGet(s16 arg0)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
MotionData *temp_r30;
HsfMotion *temp_r29;
@@ -334,12 +369,13 @@ float Hu3DMotionMaxTimeGet(s16 arg0) {
return 0.0f;
}
temp_r30 = &Hu3DMotion[temp_r31->unk_08];
- temp_r29 = temp_r30->unk_04->motion;
+ temp_r29 = temp_r30->hsfData->motion;
temp_r28 = 0.0001 + temp_r29->len;
return temp_r28;
}
-float Hu3DMotionShiftMaxTimeGet(s16 arg0) {
+float Hu3DMotionShiftMaxTimeGet(s16 arg0)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
MotionData *temp_r30;
HsfMotion *temp_r29;
@@ -349,66 +385,75 @@ float Hu3DMotionShiftMaxTimeGet(s16 arg0) {
return 0.0f;
}
temp_r30 = &Hu3DMotion[temp_r31->unk_0C];
- temp_r29 = temp_r30->unk_04->motion;
+ temp_r29 = temp_r30->hsfData->motion;
temp_r28 = 0.0001 + temp_r29->len;
return temp_r28;
}
-void Hu3DMotionShiftStartEndSet(s16 arg0, float arg1, float arg2) {
+void Hu3DMotionShiftStartEndSet(s16 arg0, float arg1, float arg2)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
temp_r31->unk_8C = arg1;
temp_r31->unk_90 = arg2;
}
-float Hu3DMotionMotionMaxTimeGet(s16 arg0) {
+float Hu3DMotionMotionMaxTimeGet(s16 arg0)
+{
MotionData *temp_r31 = &Hu3DMotion[arg0];
HsfMotion *temp_r30;
s16 temp_r29;
- if (temp_r31->unk_04 == 0) {
+ if (temp_r31->hsfData == 0) {
return 0.0f;
}
- temp_r30 = temp_r31->unk_04->motion;
+ temp_r30 = temp_r31->hsfData->motion;
temp_r29 = 0.0001 + temp_r30->len;
return temp_r29;
}
-void Hu3DMotionStartEndSet(s16 arg0, float arg1, float arg2) {
+void Hu3DMotionStartEndSet(s16 arg0, float arg1, float arg2)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
temp_r31->unk_6C = arg1;
temp_r31->unk_70 = arg2;
}
-s32 Hu3DMotionEndCheck(s16 arg0) {
+s32 Hu3DMotionEndCheck(s16 arg0)
+{
if (!(Hu3DData[arg0].motion_attr & HU3D_MOTATTR_REV)) {
return (Hu3DMotionMaxTimeGet(arg0) <= Hu3DMotionTimeGet(arg0));
- } else {
+ }
+ else {
return (Hu3DMotionTimeGet(arg0) <= 0.0f);
}
}
-void Hu3DMotionSpeedSet(s16 arg0, float arg1) {
+void Hu3DMotionSpeedSet(s16 arg0, float arg1)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
temp_r31->unk_68 = arg1;
}
-void Hu3DMotionShiftSpeedSet(s16 arg0, float arg1) {
+void Hu3DMotionShiftSpeedSet(s16 arg0, float arg1)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
temp_r31->unk_88 = arg1;
}
-void Hu3DMotionNoMotSet(s16 arg0, char *arg1, u32 arg2) {
+void Hu3DMotionNoMotSet(s16 arg0, char *arg1, u32 arg2)
+{
HsfConstData *var_r29;
HsfObject *temp_r3;
temp_r3 = Hu3DModelObjPtrGet(arg0, arg1);
if (temp_r3->constData == 0) {
- var_r29 = ObjConstantMake(temp_r3, (u32) Hu3DData[arg0].unk_48);
- } else {
+ var_r29 = ObjConstantMake(temp_r3, (u32)Hu3DData[arg0].unk_48);
+ }
+ else {
var_r29 = temp_r3->constData;
}
var_r29->flags |= arg2;
@@ -432,7 +477,8 @@ void Hu3DMotionNoMotSet(s16 arg0, char *arg1, u32 arg2) {
}
}
-void Hu3DMotionNoMotReset(s16 arg0, char *arg1, u32 arg2) {
+void Hu3DMotionNoMotReset(s16 arg0, char *arg1, u32 arg2)
+{
HsfObject *temp_r31;
HsfConstData *temp_r30;
@@ -441,14 +487,16 @@ void Hu3DMotionNoMotReset(s16 arg0, char *arg1, u32 arg2) {
temp_r30->flags &= ~arg2;
}
-void Hu3DMotionForceSet(s16 arg0, char *arg1, u32 arg2, float arg3) {
+void Hu3DMotionForceSet(s16 arg0, char *arg1, u32 arg2, float arg3)
+{
HsfConstData *var_r29;
HsfObject *temp_r3;
temp_r3 = Hu3DModelObjPtrGet(arg0, arg1);
if (temp_r3->constData == 0) {
- var_r29 = ObjConstantMake(temp_r3, (u32) Hu3DData[arg0].unk_48);
- } else {
+ var_r29 = ObjConstantMake(temp_r3, (u32)Hu3DData[arg0].unk_48);
+ }
+ else {
var_r29 = temp_r3->constData;
}
var_r29->flags |= arg2;
@@ -472,7 +520,8 @@ void Hu3DMotionForceSet(s16 arg0, char *arg1, u32 arg2, float arg3) {
}
}
-void Hu3DMotionNext(s16 arg0) {
+void Hu3DMotionNext(s16 arg0)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
HsfMotion *temp_r29;
MotionData *temp_r27;
@@ -480,47 +529,55 @@ void Hu3DMotionNext(s16 arg0) {
s16 i;
temp_r27 = &Hu3DMotion[temp_r31->unk_08];
- temp_r29 = temp_r27->unk_04->motion;
+ temp_r29 = temp_r27->hsfData->motion;
temp_r28 = temp_r31->motion_attr;
if (temp_r31->unk_08 != -1) {
temp_r27 = &Hu3DMotion[temp_r31->unk_08];
if (!(temp_r28 & HU3D_MOTATTR_PAUSE)) {
if (!(temp_r28 & HU3D_MOTATTR_REV)) {
temp_r31->unk_64 += temp_r31->unk_68 * minimumVcountf;
- } else {
+ }
+ else {
temp_r31->unk_64 -= temp_r31->unk_68 * minimumVcountf;
}
if (temp_r28 & HU3D_MOTATTR_LOOP) {
if (temp_r31->unk_64 < temp_r31->unk_6C) {
temp_r31->unk_64 = temp_r31->unk_70 - (temp_r31->unk_6C - temp_r31->unk_64);
- } else if (temp_r31->unk_64 >= temp_r31->unk_70) {
+ }
+ else if (temp_r31->unk_64 >= temp_r31->unk_70) {
temp_r31->unk_64 = temp_r31->unk_6C + (temp_r31->unk_64 - temp_r31->unk_70);
}
- } else if (temp_r31->unk_64 < 0.0f) {
+ }
+ else if (temp_r31->unk_64 < 0.0f) {
temp_r31->unk_64 = 0.0f;
- } else if (temp_r31->unk_64 >= temp_r31->unk_70) {
+ }
+ else if (temp_r31->unk_64 >= temp_r31->unk_70) {
temp_r31->unk_64 = temp_r31->unk_70;
}
}
}
if (temp_r31->unk_0A != -1) {
temp_r27 = &Hu3DMotion[temp_r31->unk_0A];
- temp_r29 = temp_r27->unk_04->motion;
+ temp_r29 = temp_r27->hsfData->motion;
if (!(temp_r28 & HU3D_MOTATTR_OVL_PAUSE)) {
if (!(temp_r28 & HU3D_MOTATTR_OVL_REV)) {
temp_r31->unk_74 += temp_r31->unk_78 * minimumVcountf;
- } else {
+ }
+ else {
temp_r31->unk_74 -= temp_r31->unk_78 * minimumVcountf;
}
if (temp_r28 & HU3D_MOTATTR_OVL_LOOP) {
if (temp_r31->unk_74 < 0.0f) {
temp_r31->unk_74 = temp_r29->len;
- } else if (temp_r31->unk_74 >= temp_r29->len) {
+ }
+ else if (temp_r31->unk_74 >= temp_r29->len) {
temp_r31->unk_74 = 0.0f;
}
- } else if (temp_r31->unk_74 < 0.0f) {
+ }
+ else if (temp_r31->unk_74 < 0.0f) {
temp_r31->unk_74 = 0.0f;
- } else if (temp_r31->unk_74 >= temp_r29->len) {
+ }
+ else if (temp_r31->unk_74 >= temp_r29->len) {
temp_r31->unk_74 = temp_r29->len;
}
}
@@ -553,39 +610,47 @@ void Hu3DMotionNext(s16 arg0) {
temp_r27 = &Hu3DMotion[temp_r31->unk_0C];
if (!(temp_r31->motion_attr & HU3D_MOTATTR_SHIFT_REV)) {
temp_r31->unk_84 += temp_r31->unk_88 * minimumVcountf;
- } else {
+ }
+ else {
temp_r31->unk_84 -= temp_r31->unk_88 * minimumVcountf;
}
if (temp_r31->motion_attr & HU3D_MOTATTR_SHIFT_LOOP) {
if (temp_r31->unk_84 < temp_r31->unk_8C) {
temp_r31->unk_84 = temp_r31->unk_90;
- } else if (temp_r31->unk_84 >= temp_r31->unk_90) {
+ }
+ else if (temp_r31->unk_84 >= temp_r31->unk_90) {
temp_r31->unk_84 = temp_r31->unk_8C;
}
- } else if (temp_r31->unk_84 < temp_r31->unk_8C) {
+ }
+ else if (temp_r31->unk_84 < temp_r31->unk_8C) {
temp_r31->unk_84 = temp_r31->unk_8C;
- } else if (temp_r31->unk_84 >= temp_r31->unk_90) {
+ }
+ else if (temp_r31->unk_84 >= temp_r31->unk_90) {
temp_r31->unk_84 = temp_r31->unk_90;
}
}
}
if (temp_r31->unk_0E != -1 && !(temp_r28 & HU3D_MOTATTR_SHAPE_PAUSE)) {
temp_r27 = &Hu3DMotion[temp_r31->unk_0E];
- temp_r29 = temp_r27->unk_04->motion;
+ temp_r29 = temp_r27->hsfData->motion;
if (!(temp_r28 & HU3D_MOTATTR_SHAPE_REV)) {
temp_r31->unk_94 += temp_r31->unk_98 * minimumVcountf;
- } else {
+ }
+ else {
temp_r31->unk_94 -= temp_r31->unk_98 * minimumVcountf;
}
if (temp_r28 & HU3D_MOTATTR_SHAPE_LOOP) {
if (temp_r31->unk_94 < temp_r31->unk_9C) {
temp_r31->unk_94 = temp_r31->unk_A0;
- } else if (temp_r31->unk_94 >= temp_r31->unk_A0) {
+ }
+ else if (temp_r31->unk_94 >= temp_r31->unk_A0) {
temp_r31->unk_94 = temp_r31->unk_9C;
}
- } else if (temp_r31->unk_94 < temp_r31->unk_9C) {
+ }
+ else if (temp_r31->unk_94 < temp_r31->unk_9C) {
temp_r31->unk_94 = temp_r31->unk_9C;
- } else if (temp_r31->unk_94 >= temp_r31->unk_A0) {
+ }
+ else if (temp_r31->unk_94 >= temp_r31->unk_A0) {
temp_r31->unk_94 = temp_r31->unk_A0;
}
}
@@ -593,21 +658,25 @@ void Hu3DMotionNext(s16 arg0) {
for (i = 0; i < 4; i++) {
if (temp_r31->unk_10[i] != -1 && !(temp_r31->cluster_attr[i] & HU3D_CLUSTER_ATTR_PAUSE)) {
temp_r27 = &Hu3DMotion[temp_r31->unk_10[i]];
- temp_r29 = temp_r27->unk_04->motion;
+ temp_r29 = temp_r27->hsfData->motion;
if (!(temp_r31->cluster_attr[i] & HU3D_CLUSTER_ATTR_REV)) {
temp_r31->unk_A4[i] += temp_r31->unk_B4[i] * minimumVcountf;
- } else {
+ }
+ else {
temp_r31->unk_A4[i] -= temp_r31->unk_B4[i] * minimumVcountf;
}
if (temp_r31->cluster_attr[i] & HU3D_CLUSTER_ATTR_LOOP) {
if (temp_r31->unk_A4[i] < 0.0f) {
temp_r31->unk_A4[i] = temp_r29->len;
- } else if (temp_r31->unk_A4[i] >= temp_r29->len) {
+ }
+ else if (temp_r31->unk_A4[i] >= temp_r29->len) {
temp_r31->unk_A4[i] = 0.0f;
}
- } else if (temp_r31->unk_A4[i] < 0.0f) {
+ }
+ else if (temp_r31->unk_A4[i] < 0.0f) {
temp_r31->unk_A4[i] = 0.0f;
- } else if (temp_r31->unk_A4[i] >= temp_r29->len) {
+ }
+ else if (temp_r31->unk_A4[i] >= temp_r29->len) {
temp_r31->unk_A4[i] = temp_r29->len;
}
}
@@ -615,7 +684,8 @@ void Hu3DMotionNext(s16 arg0) {
}
}
-void Hu3DMotionExec(s16 arg0, s16 arg1, float arg2, s32 arg3) {
+void Hu3DMotionExec(s16 arg0, s16 arg1, float arg2, s32 arg3)
+{
MotionData *sp18;
HsfData *sp14;
HsfTrack *sp10;
@@ -625,7 +695,7 @@ void Hu3DMotionExec(s16 arg0, s16 arg1, float arg2, s32 arg3) {
HsfObject *temp_r31;
HsfObject *var_r19;
HsfCluster *var_r23;
- HsfTrack *var_r30;
+ HsfTrack *track;
HsfTrack *temp_r25;
HsfTrack *temp_r22;
HsfTrack *var_r26;
@@ -637,9 +707,9 @@ void Hu3DMotionExec(s16 arg0, s16 arg1, float arg2, s32 arg3) {
temp_r27 = &Hu3DData[arg0];
sp18 = &Hu3DMotion[arg1];
temp_r29 = temp_r27->hsfData;
- sp14 = sp18->unk_04;
+ sp14 = sp18->hsfData;
temp_r21 = sp14->motion;
- var_r30 = temp_r21->track;
+ track = temp_r21->track;
var_r19 = temp_r29->object;
if (arg3 == 0) {
for (var_r18 = 0; var_r18 < temp_r29->objectCnt; var_r19++, var_r18++) {
@@ -666,83 +736,92 @@ void Hu3DMotionExec(s16 arg0, s16 arg1, float arg2, s32 arg3) {
if (!(temp_r24 & 0x200)) {
temp_r31->data.curr.rot.z = temp_r31->data.base.rot.z;
}
- } else {
+ }
+ else {
temp_r31->data.curr = temp_r31->data.base;
}
- } else {
+ }
+ else {
temp_r31->data.curr = temp_r31->data.base;
}
}
}
- sp10 = &var_r30[temp_r21->numTracks];
- for (; var_r30 < sp10; var_r30++) {
- switch (var_r30->type) {
- case 2:
- if (var_r30->target < temp_r29->objectCnt && var_r30->target != -1) {
- temp_r31 = &temp_r29->object[var_r30->target];
- if (var_r30->channel == 0x28) {
- temp_r31->data.mesh.baseMorph = GetCurve(var_r30, arg2);
- } else if (temp_r31->type == 7) {
+ sp10 = &track[temp_r21->numTracks];
+ for (; track < sp10; track++) {
+ switch (track->type) {
+ case HSF_TRACK_TRANSFORM:
+ if (track->target < temp_r29->objectCnt && track->target != -1) {
+ temp_r31 = &temp_r29->object[track->target];
+ if (track->channel == 0x28) {
+ temp_r31->data.mesh.baseMorph = GetCurve(track, arg2);
+ }
+ else if (temp_r31->type == 7) {
if (temp_r27->attr & HU3D_ATTR_CAMERA_MOTON) {
- SetObjCameraMotion(arg0, var_r30, GetCurve(var_r30, arg2));
+ SetObjCameraMotion(arg0, track, GetCurve(track, arg2));
}
- } else if (temp_r31->type == 8) {
- SetObjLightMotion(arg0, var_r30, GetCurve(var_r30, arg2));
- } else if (var_r30->channel == 0x18) {
+ }
+ else if (temp_r31->type == 8) {
+ SetObjLightMotion(arg0, track, GetCurve(track, arg2));
+ }
+ else if (track->channel == 0x18) {
if (temp_r31->constData) {
temp_r28 = temp_r31->constData;
- if (GetCurve(var_r30, arg2) == 1.0f) {
+ if (GetCurve(track, arg2) == 1.0f) {
temp_r28->flags &= ~0x1000;
- } else {
+ }
+ else {
temp_r28->flags |= 0x1000;
}
}
- } else if (var_r30->channel == 0x1A) {
+ }
+ else if (track->channel == 0x1A) {
if (temp_r31->constData) {
temp_r28 = temp_r31->constData;
- if (GetCurve(var_r30, arg2) == 1.0f) {
+ if (GetCurve(track, arg2) == 1.0f) {
temp_r28->flags &= ~0x2000;
- } else {
+ }
+ else {
temp_r28->flags |= 0x2000;
}
}
- } else {
- temp_r17 = GetObjTRXPtr(temp_r31, var_r30->channel);
- if (temp_r17 != (float*) -1) {
- *temp_r17 = GetCurve(var_r30, arg2);
+ }
+ else {
+ temp_r17 = GetObjTRXPtr(temp_r31, track->channel);
+ if (temp_r17 != (float *)-1) {
+ *temp_r17 = GetCurve(track, arg2);
}
}
}
break;
- case 3:
- temp_r25 = var_r30;
+ case HSF_TRACK_MORPH:
+ temp_r25 = track;
if (temp_r25->target < temp_r29->objectCnt) {
temp_r31 = &temp_r29->object[temp_r25->target];
temp_r31->data.mesh.morphWeight[temp_r25->channel_s16] = GetCurve(temp_r25, arg2);
}
break;
- case 9:
+ case HSF_TRACK_MATERIAL:
if (!(temp_r27->attr & HU3D_ATTR_CURVE_MOTOFF)) {
- if (var_r30->param < temp_r29->materialCnt) {
- SetObjMatMotion(arg0, var_r30, GetCurve(var_r30, arg2));
+ if (track->param < temp_r29->materialCnt) {
+ SetObjMatMotion(arg0, track, GetCurve(track, arg2));
}
}
break;
- case 5:
+ case HSF_TRACK_CLUSTER:
if (!(temp_r27->attr & HU3D_ATTR_CURVE_MOTOFF)) {
- var_r23 = &temp_r29->cluster[var_r30->target_s16];
- var_r23->unk10 = GetClusterCurve(var_r30, arg2);
+ var_r23 = &temp_r29->cluster[track->target_s16];
+ var_r23->index = GetClusterCurve(track, arg2);
}
break;
- case 6:
+ case HSF_TRACK_CLUSTER_WEIGHT:
if (!(temp_r27->attr & HU3D_ATTR_CURVE_MOTOFF)) {
- temp_r22 = var_r30;
+ temp_r22 = track;
var_r23 = &temp_r29->cluster[temp_r22->target_s16];
- var_r23->unk14[temp_r22->unk04] = GetClusterWeightCurve(temp_r22, arg2);
+ var_r23->weight[temp_r22->unk04] = GetClusterWeightCurve(temp_r22, arg2);
}
break;
- case 10:
- var_r26 = var_r30;
+ case HSF_TRACK_ATTRIBUTE:
+ var_r26 = track;
if (var_r26->target_s16 != -1 || !(temp_r27->attr & HU3D_ATTR_CURVE_MOTOFF)) {
if (var_r26->param != -1 && var_r26->param < temp_r29->attributeCnt) {
SetObjAttrMotion(arg0, var_r26, GetCurve(var_r26, arg2));
@@ -753,36 +832,38 @@ void Hu3DMotionExec(s16 arg0, s16 arg1, float arg2, s32 arg3) {
}
}
-void Hu3DCameraMotionExec(s16 arg0) {
+void Hu3DCameraMotionExec(s16 arg0)
+{
ModelData *temp_r30;
MotionData *temp_r28;
HsfData *temp_r27;
- HsfMotion *temp_r29;
- HsfTrack *var_r31;
+ HsfMotion *motion;
+ HsfTrack *track;
HsfTrack *temp_r26;
temp_r30 = &Hu3DData[arg0];
temp_r28 = &Hu3DMotion[temp_r30->unk_08];
- temp_r27 = temp_r28->unk_04;
- temp_r29 = temp_r27->motion;
- var_r31 = temp_r29->track;
+ temp_r27 = temp_r28->hsfData;
+ motion = temp_r27->motion;
+ track = motion->track;
if (temp_r30->attr & HU3D_ATTR_CAMERA_MOTON) {
- temp_r26 = &var_r31[temp_r29->numTracks];
- for (; var_r31 < temp_r26; var_r31++) {
- if (var_r31->type == 2 && var_r31->param_u16 == 7) {
- SetObjCameraMotion(arg0, var_r31, GetCurve(var_r31, temp_r30->unk_64));
+ temp_r26 = &track[motion->numTracks];
+ for (; track < temp_r26; track++) {
+ if (track->type == HSF_TRACK_TRANSFORM && track->param_u16 == 7) {
+ SetObjCameraMotion(arg0, track, GetCurve(track, temp_r30->unk_64));
}
}
}
}
-void Hu3DSubMotionExec(s16 arg0) {
+void Hu3DSubMotionExec(s16 arg0)
+{
ModelData *temp_r30;
MotionData *temp_r22;
HsfData *temp_r28;
HsfData *temp_r21;
- HsfMotion *temp_r25;
- HsfTrack *var_r29;
+ HsfMotion *motion;
+ HsfTrack *track;
HsfObject *var_r23;
HsfObject *temp_r26;
float *temp_r31;
@@ -794,9 +875,9 @@ void Hu3DSubMotionExec(s16 arg0) {
temp_r30 = &Hu3DData[arg0];
temp_r22 = &Hu3DMotion[temp_r30->unk_0C];
temp_r28 = temp_r30->hsfData;
- temp_r21 = temp_r22->unk_04;
- temp_r25 = temp_r21->motion;
- var_r29 = temp_r25->track;
+ temp_r21 = temp_r22->hsfData;
+ motion = temp_r21->motion;
+ track = motion->track;
var_r23 = temp_r28->object;
if (temp_r30->unk_08 == -1) {
for (var_r27 = 0; var_r27 < temp_r28->objectCnt; var_r23++, var_r27++) {
@@ -806,19 +887,20 @@ void Hu3DSubMotionExec(s16 arg0) {
}
if (temp_r30->unk_80) {
var_f30 = temp_r30->unk_7C / temp_r30->unk_80;
- } else {
+ }
+ else {
var_f30 = 1.0f;
}
- for (var_r27 = 0; var_r27 < temp_r25->numTracks; var_r27++, var_r29++) {
- switch (var_r29->type) {
- case 2:
- if (var_r29->target < temp_r28->objectCnt && var_r29->target != -1) {
- temp_r26 = &temp_r28->object[var_r29->target];
- temp_r24 = var_r29->channel;
+ for (var_r27 = 0; var_r27 < motion->numTracks; var_r27++, track++) {
+ switch (track->type) {
+ case HSF_TRACK_TRANSFORM:
+ if (track->target < temp_r28->objectCnt && track->target != -1) {
+ temp_r26 = &temp_r28->object[track->target];
+ temp_r24 = track->channel;
temp_r31 = GetObjTRXPtr(temp_r26, temp_r24);
- if (temp_r31 != (float*) -1) {
+ if (temp_r31 != (float *)-1) {
if (temp_r24 == 0x1C || temp_r24 == 0x1D || temp_r24 == 0x1E) {
- var_f31 = GetCurve(var_r29, temp_r30->unk_84);
+ var_f31 = GetCurve(track, temp_r30->unk_84);
if (var_f31 < 0.0f) {
var_f31 += 360.0f;
}
@@ -829,12 +911,14 @@ void Hu3DSubMotionExec(s16 arg0) {
if (*temp_r31 > (180.0f + var_f31)) {
*temp_r31 -= 360.0f;
}
- } else if (*temp_r31 < (var_f31 - 180.0f)) {
+ }
+ else if (*temp_r31 < (var_f31 - 180.0f)) {
var_f31 -= 360.0f;
}
*temp_r31 = (1.0f - var_f30) * *temp_r31 + var_f30 * var_f31;
- } else {
- *temp_r31 = (1.0f - var_f30) * *temp_r31 + var_f30 * GetCurve(var_r29, temp_r30->unk_84);
+ }
+ else {
+ *temp_r31 = (1.0f - var_f30) * *temp_r31 + var_f30 * GetCurve(track, temp_r30->unk_84);
}
}
}
@@ -844,41 +928,43 @@ void Hu3DSubMotionExec(s16 arg0) {
}
#ifdef __MWERKS__
-__declspec(weak) float *GetObjTRXPtr(HsfObject *arg0, u16 arg1) {
+__declspec(weak) float *GetObjTRXPtr(HsfObject *arg0, u16 arg1)
+{
#else
-float *GetObjTRXPtr(HsfObject *arg0, u16 arg1) {
+float *GetObjTRXPtr(HsfObject *arg0, u16 arg1)
+{
#endif
HsfConstData *temp_r31 = arg0->constData;
switch (arg1) {
case 8:
if (temp_r31 && (temp_r31->flags & 0x10)) {
- return (float*) -1;
+ return (float *)-1;
}
return &arg0->data.curr.pos.x;
case 9:
if (temp_r31 && (temp_r31->flags & 0x20)) {
- return (float*) -1;
+ return (float *)-1;
}
return &arg0->data.curr.pos.y;
case 10:
if (temp_r31 && (temp_r31->flags & 0x40)) {
- return (float*) -1;
+ return (float *)-1;
}
return &arg0->data.curr.pos.z;
case 28:
if (temp_r31 && (temp_r31->flags & 0x80)) {
- return (float*) -1;
+ return (float *)-1;
}
return &arg0->data.curr.rot.x;
case 29:
if (temp_r31 && (temp_r31->flags & 0x100)) {
- return (float*) -1;
+ return (float *)-1;
}
return &arg0->data.curr.rot.y;
case 30:
if (temp_r31 && (temp_r31->flags & 0x200)) {
- return (float*) -1;
+ return (float *)-1;
}
return &arg0->data.curr.rot.z;
case 31:
@@ -888,11 +974,12 @@ float *GetObjTRXPtr(HsfObject *arg0, u16 arg1) {
case 33:
return &arg0->data.curr.scale.z;
default:
- return (float*) -1;
+ return (float *)-1;
}
}
-void SetObjMatMotion(s16 arg0, HsfTrack *arg1, float arg2) {
+void SetObjMatMotion(s16 arg0, HsfTrack *arg1, float arg2)
+{
HsfMaterial *temp_r31;
HsfData *temp_r29;
ModelData *temp_r30;
@@ -904,7 +991,8 @@ void SetObjMatMotion(s16 arg0, HsfTrack *arg1, float arg2) {
var_f31 = arg2;
if (arg2 > 1.0f) {
var_f31 = 1.0f;
- } else if (arg2 < 0.0f) {
+ }
+ else if (arg2 < 0.0f) {
var_f31 = 0.0f;
}
switch (arg1->channel) {
@@ -946,7 +1034,8 @@ void SetObjMatMotion(s16 arg0, HsfTrack *arg1, float arg2) {
}
}
-void SetObjAttrMotion(s16 arg0, HsfTrack *arg1, float arg2) {
+void SetObjAttrMotion(s16 arg0, HsfTrack *arg1, float arg2)
+{
ModelData *temp_r28;
HsfData *temp_r27;
HsfAttribute *temp_r30;
@@ -959,7 +1048,8 @@ void SetObjAttrMotion(s16 arg0, HsfTrack *arg1, float arg2) {
var_f30 = arg2;
if (arg2 > 1.0f) {
var_f30 = 1.0f;
- } else if (arg2 < 0.0f) {
+ }
+ else if (arg2 < 0.0f) {
var_f30 = 0.0f;
}
switch (arg1->channel) {
@@ -974,18 +1064,20 @@ void SetObjAttrMotion(s16 arg0, HsfTrack *arg1, float arg2) {
case 0x21:
case 0x43:
if (temp_r30->unk04 == 0) {
- var_r31 = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfdrawStruct01), (u32) Hu3DData[arg0].unk_48);
+ var_r31 = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfdrawStruct01), (u32)Hu3DData[arg0].unk_48);
temp_r30->unk04 = var_r31;
var_r31->unk00 = 0;
var_r31->unk08 = var_r31->unk0C = var_r31->unk10 = 0.0f;
var_r31->unk14 = var_r31->unk18 = var_r31->unk1C = 0.0f;
var_r31->unk20 = var_r31->unk24 = var_r31->unk28 = 1.0f;
- } else {
+ }
+ else {
var_r31 = temp_r30->unk04;
}
if (arg1->channel != 0x43) {
var_r31->unk00 |= 4;
- } else {
+ }
+ else {
var_r31->unk00 |= 8;
}
break;
@@ -1033,7 +1125,8 @@ void SetObjAttrMotion(s16 arg0, HsfTrack *arg1, float arg2) {
}
}
-void SetObjCameraMotion(s16 arg0, HsfTrack *arg1, float arg2) {
+void SetObjCameraMotion(s16 arg0, HsfTrack *arg1, float arg2)
+{
ModelData *temp_r29;
Vec sp18;
Vec spC;
@@ -1049,7 +1142,8 @@ void SetObjCameraMotion(s16 arg0, HsfTrack *arg1, float arg2) {
var_f31 = arg2;
if (arg2 > 1.0f) {
var_f31 = 1.0f;
- } else if (arg2 < 0.0f) {
+ }
+ else if (arg2 < 0.0f) {
var_f31 = 0.0f;
}
switch (arg1->channel) {
@@ -1125,7 +1219,8 @@ void SetObjCameraMotion(s16 arg0, HsfTrack *arg1, float arg2) {
}
}
-void SetObjLightMotion(s16 arg0, HsfTrack *arg1, float arg2) {
+void SetObjLightMotion(s16 arg0, HsfTrack *arg1, float arg2)
+{
s16 var_r29;
ModelData *temp_r30;
HsfData *temp_r28;
@@ -1140,10 +1235,11 @@ void SetObjLightMotion(s16 arg0, HsfTrack *arg1, float arg2) {
var_r26 = temp_r28->object;
for (i = var_r29 = 0; i < temp_r28->objectCnt; i++, var_r26++) {
var_r24 = var_r26;
- if (var_r24->type == 8) {
+ if (var_r24->type == HSF_OBJ_NONE2) {
if (i != arg1->target) {
var_r29++;
- } else {
+ }
+ else {
break;
}
}
@@ -1153,7 +1249,8 @@ void SetObjLightMotion(s16 arg0, HsfTrack *arg1, float arg2) {
var_f30 = arg2;
if (arg2 > 1.0f) {
var_f30 = 1.0f;
- } else if (arg2 < 0.0f) {
+ }
+ else if (arg2 < 0.0f) {
var_f30 = 0.0f;
}
switch (arg1->channel) {
@@ -1182,27 +1279,29 @@ void SetObjLightMotion(s16 arg0, HsfTrack *arg1, float arg2) {
}
}
-float GetCurve(HsfTrack *arg0, float arg1) {
+float GetCurve(HsfTrack *track, float arg1)
+{
float *var_r30;
- switch (arg0->curveType) {
- case 1:
- return GetLinear(arg0->numKeyframes, arg0->data, arg1);
- case 2:
- return GetBezier(arg0->numKeyframes, arg0, arg1);
- case 3:
- bitMapPtr = GetBitMap(arg0->numKeyframes, arg0->data, arg1);
+ switch (track->curveType) {
+ case HSF_CURVE_LINEAR:
+ return GetLinear(track->numKeyframes, track->data, arg1);
+ case HSF_CURVE_BEZIER:
+ return GetBezier(track->numKeyframes, track, arg1);
+ case HSF_CURVE_BITMAP:
+ bitMapPtr = GetBitMap(track->numKeyframes, track->data, arg1);
break;
- case 4:
- var_r30 = &arg0->value;
+ case HSF_CURVE_CONST:
+ var_r30 = &track->value;
return *var_r30;
- case 0:
- return GetConstant(arg0->numKeyframes, arg0->data, arg1);
+ case HSF_CURVE_STEP:
+ return GetConstant(track->numKeyframes, track->data, arg1);
}
return 0.0f;
}
-float GetConstant(s32 arg0, float *arg1, float arg2) {
+float GetConstant(s32 arg0, float *arg1, float arg2)
+{
float *var_r31;
s16 i;
@@ -1218,7 +1317,8 @@ float GetConstant(s32 arg0, float *arg1, float arg2) {
return var_r31[-1];
}
-float GetLinear(s32 arg0, float arg1[][2], float arg2) {
+float GetLinear(s32 arg0, float arg1[][2], float arg2)
+{
float var_f31;
float var_f30;
s16 temp_r30;
@@ -1239,9 +1339,11 @@ float GetLinear(s32 arg0, float arg1[][2], float arg2) {
}
#ifdef __MWERKS__
-__declspec(weak) float GetBezier(s32 arg0, HsfTrack *arg1, float arg2) {
+__declspec(weak) float GetBezier(s32 arg0, HsfTrack *arg1, float arg2)
+{
#else
-float GetBezier(s32 arg0, HsfTrack *arg1, float arg2) {
+float GetBezier(s32 arg0, HsfTrack *arg1, float arg2)
+{
#endif
float temp_f24;
float temp_f29;
@@ -1251,8 +1353,8 @@ float GetBezier(s32 arg0, HsfTrack *arg1, float arg2) {
float temp_f25;
float temp_f30;
float temp_f31;
- float (*var_r31)[4];
- float (*var_r29)[4];
+ float(*var_r31)[4];
+ float(*var_r29)[4];
s32 i;
var_r31 = arg1->data;
@@ -1264,7 +1366,7 @@ float GetBezier(s32 arg0, HsfTrack *arg1, float arg2) {
i = 0;
}
if (i == -1) {
- var_r31 = (float(*)[4]) arg1->data + arg1->start;
+ var_r31 = (float(*)[4])arg1->data + arg1->start;
var_r29 = var_r31 - 1;
for (i = arg1->start; i < arg0; i++, var_r31++) {
if (arg2 >= var_r29[0][0] && arg2 < var_r31[0][0]) {
@@ -1294,13 +1396,12 @@ float GetBezier(s32 arg0, HsfTrack *arg1, float arg2) {
temp_f27 = 3.0f * temp_f30;
temp_f26 = temp_f31 * temp_f30;
temp_f25 = temp_f31 * temp_f28;
- return var_r31[0][1] * (temp_f25 - temp_f27 + 1.0f)
- + var_r31[1][1] * (-temp_f25 + temp_f27)
- + var_r31[0][2] * (temp_f26 - temp_f28 + temp_f31)
+ return var_r31[0][1] * (temp_f25 - temp_f27 + 1.0f) + var_r31[1][1] * (-temp_f25 + temp_f27) + var_r31[0][2] * (temp_f26 - temp_f28 + temp_f31)
+ var_r31[1][3] * (temp_f26 - temp_f30);
}
-HsfBitmap *GetBitMap(s32 arg0, UnknownHsfMotionStruct01 *arg1, float arg2) {
+HsfBitmap *GetBitMap(s32 arg0, UnknownHsfMotionStruct01 *arg1, float arg2)
+{
s16 var_r31;
if (arg2 == 0.0f || arg0 == 1) {
@@ -1314,7 +1415,8 @@ HsfBitmap *GetBitMap(s32 arg0, UnknownHsfMotionStruct01 *arg1, float arg2) {
return arg1[-1].unk04;
}
-s16 Hu3DJointMotion(s16 arg0, void *arg1) {
+s16 Hu3DJointMotion(s16 arg0, void *arg1)
+{
s16 var_r29;
var_r29 = Hu3DMotionCreate(arg1);
@@ -1322,13 +1424,14 @@ s16 Hu3DJointMotion(s16 arg0, void *arg1) {
return var_r29;
}
-void JointModel_Motion(s16 arg0, s16 arg1) {
+void JointModel_Motion(s16 arg0, s16 arg1)
+{
ModelData *temp_r24;
MotionData *temp_r23;
HsfData *temp_r26;
HsfData *temp_r22;
- HsfMotion *temp_r29;
- HsfTrack *var_r30;
+ HsfMotion *motion;
+ HsfTrack *track;
HsfTrack *var_r28;
HsfTrack *var_r27;
HsfTrack *var_r31;
@@ -1338,26 +1441,27 @@ void JointModel_Motion(s16 arg0, s16 arg1) {
temp_r24 = &Hu3DData[arg0];
temp_r23 = &Hu3DMotion[arg1];
temp_r26 = temp_r24->hsfData;
- temp_r22 = temp_r23->unk_04;
- temp_r29 = temp_r22->motion;
- var_r30 = temp_r29->track;
- for (i = 0; i < temp_r29->numTracks; i++, var_r30++) {
- switch (var_r30->type) {
- case 2:
- var_r28 = var_r30;
+ temp_r22 = temp_r23->hsfData;
+ motion = temp_r22->motion;
+ track = motion->track;
+ for (i = 0; i < motion->numTracks; i++, track++) {
+ switch (track->type) {
+ case HSF_TRACK_TRANSFORM:
+ var_r28 = track;
var_r28->target = SearchObjectIndex(temp_r26, var_r28->target);
break;
- case 3:
- var_r27 = var_r30;
+ case HSF_TRACK_MORPH:
+ var_r27 = track;
var_r27->target = SearchObjectIndex(temp_r26, var_r27->target);
break;
- case 10:
- var_r31 = var_r30;
+ case HSF_TRACK_ATTRIBUTE:
+ var_r31 = track;
if (var_r31->param == -1) {
temp_r21 = SearchAttributeIndex(temp_r26, var_r31->target_s16);
if (temp_r21 != -1) {
var_r31->param = temp_r21;
- } else {
+ }
+ else {
var_r31->param = -1;
}
}
@@ -1366,7 +1470,8 @@ void JointModel_Motion(s16 arg0, s16 arg1) {
}
}
-void Hu3DMotionCalc(s16 arg0) {
+void Hu3DMotionCalc(s16 arg0)
+{
ModelData *temp_r31 = &Hu3DData[arg0];
if ((temp_r31->attr & HU3D_ATTR_DISPOFF) || (temp_r31->attr & HU3D_ATTR_HOOK)) {
@@ -1387,11 +1492,12 @@ void Hu3DMotionCalc(s16 arg0) {
if (temp_r31->unk_0E != -1) {
if (temp_r31->unk_08 == -1) {
Hu3DMotionExec(arg0, temp_r31->unk_0E, temp_r31->unk_94, 0);
- } else {
+ }
+ else {
Hu3DMotionExec(arg0, temp_r31->unk_0E, temp_r31->unk_94, 1);
}
}
- if (!(temp_r31->attr & (HU3D_ATTR_ENVELOPE_OFF|HU3D_ATTR_HOOKFUNC)) || !(temp_r31->motion_attr & HU3D_MOTATTR_PAUSE)) {
+ if (!(temp_r31->attr & (HU3D_ATTR_ENVELOPE_OFF | HU3D_ATTR_HOOKFUNC)) || !(temp_r31->motion_attr & HU3D_MOTATTR_PAUSE)) {
InitVtxParm(temp_r31->hsfData);
if (temp_r31->unk_0E != -1) {
ShapeProc(temp_r31->hsfData);
@@ -1407,7 +1513,8 @@ void Hu3DMotionCalc(s16 arg0) {
temp_r31->attr |= HU3D_ATTR_MOT_EXEC;
}
-static s32 SearchObjectIndex(HsfData *arg0, u32 arg1) {
+static s32 SearchObjectIndex(HsfData *arg0, u32 arg1)
+{
s32 i;
char *temp_r28;
HsfObject *var_r30;
@@ -1422,7 +1529,8 @@ static s32 SearchObjectIndex(HsfData *arg0, u32 arg1) {
return -1;
}
-static s32 SearchAttributeIndex(HsfData *arg0, u32 arg1) {
+static s32 SearchAttributeIndex(HsfData *arg0, u32 arg1)
+{
HsfAttribute *var_r31;
size_t temp_r28;
char *temp_r27;
diff --git a/src/game/malloc.c b/src/game/malloc.c
index 9ed38e20..f5d747bf 100644
--- a/src/game/malloc.c
+++ b/src/game/malloc.c
@@ -59,7 +59,7 @@ void *HuMemDirectMalloc(HeapID heap, s32 size)
return HuMemMemoryAlloc(HeapTbl[heap], size, retaddr);
}
-void *HuMemDirectMallocNum(HeapID heap, s32 size, u32 num)
+void *HuMemDirectMallocNum(HeapID heap, s32 size, uintptr_t num)
{
#ifdef TARGET_PC
u32 retaddr = 0;
@@ -86,7 +86,7 @@ void HuMemDirectFree(void *ptr)
HuMemMemoryFree(ptr, retaddr);
}
-void HuMemDirectFreeNum(HeapID heap, u32 num)
+void HuMemDirectFreeNum(HeapID heap, uintptr_t num)
{
#ifdef TARGET_PC
u32 retaddr = 0;
diff --git a/src/game/memory.c b/src/game/memory.c
index 03f793b4..766af202 100644
--- a/src/game/memory.c
+++ b/src/game/memory.c
@@ -12,11 +12,11 @@ struct memory_block {
u8 flag;
struct memory_block *prev;
struct memory_block *next;
- u32 num;
+ uintptr_t num;
uintptr_t retaddr;
};
-static void *HuMemMemoryAlloc2(void *heap_ptr, s32 size, u32 num, uintptr_t retaddr);
+static void *HuMemMemoryAlloc2(void *heap_ptr, s32 size, uintptr_t num, uintptr_t retaddr);
void *HuMemHeapInit(void *ptr, s32 size)
{
@@ -31,7 +31,7 @@ void *HuMemHeapInit(void *ptr, s32 size)
return block;
}
-void *HuMemMemoryAllocNum(void *heap_ptr, s32 size, u32 num, uintptr_t retaddr)
+void *HuMemMemoryAllocNum(void *heap_ptr, s32 size, uintptr_t num, uintptr_t retaddr)
{
return HuMemMemoryAlloc2(heap_ptr, size, num, retaddr);
}
@@ -41,7 +41,7 @@ void *HuMemMemoryAlloc(void *heap_ptr, s32 size, uintptr_t retaddr)
return HuMemMemoryAlloc2(heap_ptr, size, -256, retaddr);
}
-static void *HuMemMemoryAlloc2(void *heap_ptr, s32 size, u32 num, uintptr_t retaddr)
+static void *HuMemMemoryAlloc2(void *heap_ptr, s32 size, uintptr_t num, uintptr_t retaddr)
{
s32 alloc_size = MEM_ALLOC_SIZE(size);
struct memory_block *block = heap_ptr;
@@ -76,7 +76,7 @@ static void *HuMemMemoryAlloc2(void *heap_ptr, s32 size, u32 num, uintptr_t reta
return NULL;
}
-void HuMemMemoryFreeNum(void *heap_ptr, u32 num, uintptr_t retaddr)
+void HuMemMemoryFreeNum(void *heap_ptr, uintptr_t num, uintptr_t retaddr)
{
struct memory_block *block = heap_ptr;
do {
diff --git a/src/port/byteswap.cpp b/src/port/byteswap.cpp
index 027978a2..1a19aa87 100644
--- a/src/port/byteswap.cpp
+++ b/src/port/byteswap.cpp
@@ -1,3 +1,4 @@
+#include "game/hsfformat.h"
#include
#include
#include
@@ -5,8 +6,7 @@
#include
#include
-extern "C"
-{
+extern "C" {
#include "port/byteswap.h"
typedef struct AnimData32b {
@@ -45,7 +45,6 @@ typedef struct AnimBmpData32b {
u32 palData;
u32 data;
} AnimBmpData32b;
-
}
template [[nodiscard]] constexpr T bswap16(T val) noexcept
@@ -54,7 +53,7 @@ template [[nodiscard]] constexpr T bswap16(T val) noexcept
union {
u16 u;
T t;
- } v{.t = val};
+ } v { .t = val };
#if __GNUC__
v.u = __builtin_bswap16(v.u);
#elif _WIN32
@@ -71,14 +70,13 @@ template [[nodiscard]] constexpr T bswap32(T val) noexcept
union {
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;
}
@@ -104,14 +102,11 @@ 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);
@@ -122,15 +117,12 @@ template void bswap(B &base, P *&ptr)
template void bswap(B &base, T *&ptr, s32 count)
{
ptr = bswap32(ptr);
- if (ptr == nullptr)
- {
+ if (ptr == nullptr) {
return;
}
T *objBase = offset_ptr(base, ptr);
- for (s32 i = 0; i < count; ++i)
- {
- if (sVisitedPtrs.contains(objBase))
- {
+ for (s32 i = 0; i < count; ++i) {
+ if (sVisitedPtrs.contains(objBase)) {
continue;
}
sVisitedPtrs.insert(objBase);
@@ -141,13 +133,11 @@ template void bswap(B &base, T *&ptr, s32 count)
template void bswap_list(B &base, T **&ptr)
{
ptr = bswap32(ptr);
- if (ptr == nullptr)
- {
+ if (ptr == nullptr) {
return;
}
T **objBase = offset_ptr(base, ptr);
- while (*objBase != nullptr)
- {
+ while (*objBase != nullptr) {
bswap(base, *objBase, 1);
++objBase;
}
@@ -155,8 +145,7 @@ template void bswap_list(B &base, T **&ptr)
template void bswap_list(B &base, T *(&ptr)[])
{
T **objBase = ptr;
- while (*objBase != nullptr)
- {
+ while (*objBase != nullptr) {
bswap(base, *objBase, 1);
++objBase;
}
@@ -164,8 +153,7 @@ template void bswap_list(B &base, T *(&ptr)[])
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]);
}
}
@@ -219,6 +207,13 @@ template void bswap(B &base, Vec2f &vec)
bswap(base, vec.y);
}
+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);
@@ -342,6 +337,427 @@ template void bswap(B &base, HsfHeader &obj)
bswap(base, obj.string);
}
+template void bswap(B &base, HsfCluster32b &obj, HsfCluster &dest)
+{
+ bswap(base, obj.name[0]);
+ bswap(base, obj.name[1]);
+ bswap(base, obj.targetName);
+ bswap(base, obj.part);
+ bswap(base, obj.index);
+ bswap_flat(base, obj.weight, sizeof(obj.weight) / sizeof(float));
+ bswap(base, obj.type);
+ bswap(base, obj.vertexCnt);
+ bswap(base, obj.vertex);
+
+ dest.name[0] = reinterpret_cast(obj.name[0]);
+ dest.name[1] = reinterpret_cast(obj.name[1]);
+
+ dest.targetName = reinterpret_cast(obj.targetName);
+ dest.index = obj.index;
+ std::copy(std::begin(obj.weight), std::end(obj.weight), dest.weight);
+
+ dest.adjusted = obj.adjusted;
+ dest.unk95 = obj.unk95;
+ dest.type = obj.type;
+ dest.vertexCnt = obj.vertexCnt;
+ dest.vertex = reinterpret_cast(obj.vertex);
+}
+
+template void bswap(B &base, HsfAttribute32b &obj, HsfAttribute &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.unk04);
+ bswap(base, obj.unk0C);
+ bswap(base, obj.unk14);
+ bswap(base, obj.unk20);
+ bswap(base, obj.unk28);
+ bswap(base, obj.unk2C);
+ bswap(base, obj.unk30);
+ bswap(base, obj.unk34);
+ bswap(base, obj.wrap_s);
+ bswap(base, obj.wrap_t);
+ bswap(base, obj.unk78);
+ bswap(base, obj.flag);
+ bswap(base, obj.bitmap);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.unk04 = reinterpret_cast(obj.unk04);
+ std::copy(std::begin(obj.unk8), std::end(obj.unk8), dest.unk8);
+ dest.unk0C = obj.unk0C;
+ std::copy(std::begin(obj.unk10), std::end(obj.unk10), dest.unk10);
+ dest.unk14 = obj.unk14;
+ std::copy(std::begin(obj.unk18), std::end(obj.unk18), dest.unk18);
+ dest.unk20 = obj.unk20;
+ std::copy(std::begin(obj.unk24), std::end(obj.unk24), dest.unk24);
+ dest.unk28 = obj.unk28;
+ dest.unk2C = obj.unk2C;
+ dest.unk30 = obj.unk30;
+ dest.unk34 = obj.unk34;
+ std::copy(std::begin(obj.unk38), std::end(obj.unk38), dest.unk38);
+ dest.wrap_s = obj.wrap_s;
+ dest.wrap_t = obj.wrap_t;
+ std::copy(std::begin(obj.unk6C), std::end(obj.unk6C), dest.unk6C);
+ dest.unk78 = obj.unk78;
+ dest.flag = obj.flag;
+ dest.bitmap = reinterpret_cast(obj.bitmap);
+}
+
+template void bswap(B &base, HsfMaterial32b &obj, HsfMaterial &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.pass);
+ bswap(base, obj.hilite_scale);
+ bswap(base, obj.unk18);
+ bswap(base, obj.invAlpha);
+ bswap_flat(base, obj.unk20, sizeof(obj.unk20) / sizeof(float));
+ bswap(base, obj.refAlpha);
+ bswap(base, obj.unk2C);
+ bswap(base, obj.flags);
+ bswap(base, obj.numAttrs);
+ bswap(base, obj.attrs);
+
+ dest.name = reinterpret_cast(obj.name);
+ std::copy(std::begin(obj.unk4), std::end(obj.unk4), dest.unk4);
+ dest.pass = obj.pass;
+ dest.vtxMode = obj.vtxMode;
+ std::copy(std::begin(obj.litColor), std::end(obj.litColor), dest.litColor);
+ std::copy(std::begin(obj.color), std::end(obj.color), dest.color);
+ std::copy(std::begin(obj.shadowColor), std::end(obj.shadowColor), dest.shadowColor);
+ dest.hilite_scale = obj.hilite_scale;
+ dest.unk18 = obj.unk18;
+ dest.invAlpha = obj.invAlpha;
+ std::copy(std::begin(obj.unk20), std::end(obj.unk20), dest.unk20);
+ dest.refAlpha = obj.refAlpha;
+ dest.unk2C = obj.unk2C;
+ dest.flags = obj.flags;
+ dest.numAttrs = obj.numAttrs;
+ dest.attrs = reinterpret_cast(obj.attrs);
+}
+
+template void bswap(B &base, HsfScene &obj)
+{
+ u32 fogType = static_cast(obj.fogType);
+ fogType = bswap32(fogType);
+ obj.fogType = static_cast(fogType);
+ bswap(base, obj.start);
+ bswap(base, obj.end);
+}
+
+template void bswap(B &base, HsfBuffer32b &obj, HsfBuffer &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.count);
+ bswap(base, obj.data);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.count = obj.count;
+ dest.data = reinterpret_cast(obj.data);
+}
+
+template void bswap(B &base, HsfMatrix &obj)
+{
+ bswap(base, obj.base_idx);
+ bswap(base, obj.count);
+
+ obj.data = (Mtx *)((uintptr_t)&obj + sizeof(0xC)); // hardcoded for 64 bit support
+ for (s32 i = 0; i < obj.count; i++) {
+ for (s32 j = 0; j < 3; j++) {
+ bswap_flat(base, obj.data[i][j], 4);
+ }
+ }
+}
+
+template void bswap(B &base, HsfPalette32b &obj, HsfPalette &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.unk);
+ bswap(base, obj.palSize);
+ bswap(base, obj.data);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.unk = obj.unk;
+ dest.palSize = obj.palSize;
+ dest.data = reinterpret_cast(obj.data);
+}
+
+template void bswap(B &base, HsfPart32b &obj, HsfPart &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.count);
+ bswap(base, obj.vertex);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.count = obj.count;
+ dest.vertex = reinterpret_cast(obj.vertex);
+}
+
+template void bswap(B &base, HsfBitmap32b &obj, HsfBitmap &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.maxLod);
+ bswap(base, obj.sizeX);
+ bswap(base, obj.sizeY);
+ bswap(base, obj.palSize);
+ bswap(base, obj.palData);
+ bswap(base, obj.unk);
+ bswap(base, obj.data);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.maxLod = obj.maxLod;
+ dest.dataFmt = obj.dataFmt;
+ dest.pixSize = obj.pixSize;
+ dest.sizeX = obj.sizeX;
+ dest.sizeY = obj.sizeY;
+ dest.palSize = obj.palSize;
+ dest.tint = obj.tint;
+ dest.palData = reinterpret_cast(obj.palData);
+ dest.unk = obj.unk;
+ dest.data = reinterpret_cast(obj.data);
+}
+
+template void bswap(B &base, HsfMapAttr32b &obj, HsfMapAttr &dest)
+{
+ bswap(base, obj.minX);
+ bswap(base, obj.minZ);
+ bswap(base, obj.maxX);
+ bswap(base, obj.maxZ);
+ bswap(base, obj.data);
+ bswap(base, obj.dataLen);
+
+ dest.minX = obj.minX;
+ dest.minZ = obj.minZ;
+ dest.maxX = obj.maxZ;
+ dest.data = reinterpret_cast(obj.data);
+ dest.dataLen = obj.dataLen;
+}
+
+template void bswap(B &base, HsfTransform &obj)
+{
+ bswap(base, obj.pos);
+ bswap(base, obj.rot);
+ bswap(base, obj.scale);
+}
+
+template void bswap(B &base, HsfSkeleton32b &obj, HsfSkeleton &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.transform);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.transform = obj.transform;
+}
+
+template void bswap(B &base, HsfShape32b &obj, HsfShape &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.vertex);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.vertex = reinterpret_cast(obj.vertex);
+}
+
+template void bswap(B &base, HsfCenvSingle &obj)
+{
+ bswap(base, obj.target);
+ bswap(base, obj.pos);
+ bswap(base, obj.posCnt);
+ bswap(base, obj.normal);
+ bswap(base, obj.normalCnt);
+}
+
+template void bswap(B &base, HsfCenv32b &obj, HsfCenv &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.singleData);
+ bswap(base, obj.dualData);
+ bswap(base, obj.multiData);
+ bswap(base, obj.singleCount);
+ bswap(base, obj.dualCount);
+ bswap(base, obj.multiCount);
+ bswap(base, obj.vtxCount);
+ bswap(base, obj.copyCount);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.singleData = reinterpret_cast(obj.singleData);
+ dest.dualData = reinterpret_cast(obj.dualData);
+ dest.multiData = reinterpret_cast(obj.multiData);
+ dest.singleCount = obj.singleCount;
+ dest.dualCount = obj.dualCount;
+ dest.multiCount = obj.multiCount;
+ dest.vtxCount = obj.vtxCount;
+ dest.copyCount = obj.copyCount;
+}
+
+template void bswap(B &base, HsfObjectData32b &obj, HsfObjectData &dest, u32 type)
+{
+ bswap(base, obj.parent);
+ bswap(base, obj.childrenCount);
+ bswap(base, obj.children);
+ bswap(base, obj.base);
+ bswap(base, obj.curr);
+ bswap(base, obj.face);
+ bswap(base, obj.vertex);
+ bswap(base, obj.normal);
+ bswap(base, obj.color);
+ bswap(base, obj.st);
+ bswap(base, obj.material);
+ bswap(base, obj.attribute);
+ bswap(base, obj.vertexShapeCnt);
+ bswap(base, obj.vertexShape);
+ bswap(base, obj.clusterCnt);
+ bswap(base, obj.cluster);
+ bswap(base, obj.cenvCnt);
+ bswap(base, obj.cenv);
+ bswap_flat(base, obj.file, sizeof(obj.file) / sizeof(u32));
+
+ dest.parent = reinterpret_cast(obj.parent);
+ dest.childrenCount = obj.childrenCount;
+ dest.children = reinterpret_cast(obj.children);
+ dest.base = obj.base;
+ dest.curr = obj.curr;
+ dest.face = reinterpret_cast(obj.face);
+ dest.vertex = reinterpret_cast(obj.vertex);
+ dest.normal = reinterpret_cast(obj.normal);
+ dest.color = reinterpret_cast(obj.color);
+ dest.st = reinterpret_cast(obj.st);
+ dest.material = reinterpret_cast(obj.material);
+ dest.attribute = reinterpret_cast(obj.attribute);
+ std::copy(std::begin(obj.unk120), std::end(obj.unk120), dest.unk120);
+ dest.shapeType = obj.shapeType;
+ dest.unk123 = obj.unk123;
+ dest.vertexShapeCnt = obj.vertexShapeCnt;
+ dest.vertexShape = reinterpret_cast(obj.vertexShape);
+ dest.clusterCnt = obj.clusterCnt;
+ dest.cluster = reinterpret_cast(obj.cluster);
+ dest.cenvCnt = obj.cenvCnt;
+ dest.cenv = reinterpret_cast(obj.cenv);
+ dest.file[0] = reinterpret_cast(obj.file[0]);
+ dest.file[1] = reinterpret_cast(obj.file[1]);
+
+ switch (type) {
+ case HSF_OBJ_MESH:
+ bswap(base, obj.mesh.min);
+ bswap(base, obj.mesh.max);
+ bswap(base, obj.mesh.baseMorph);
+ bswap_flat(base, obj.mesh.morphWeight, std::size(obj.mesh.morphWeight));
+
+ dest.mesh.min = obj.mesh.min;
+ dest.mesh.max = obj.mesh.max;
+ dest.mesh.baseMorph = obj.mesh.baseMorph;
+ std::copy(std::begin(obj.mesh.morphWeight), std::end(obj.mesh.morphWeight), dest.mesh.morphWeight);
+ break;
+ case HSF_OBJ_REPLICA:
+ bswap(base, obj.replica);
+
+ dest.replica = obj.replica;
+ break;
+ default:
+ break;
+ }
+}
+
+template void bswap(B &base, HsfObject32b &obj, HsfObject &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.type);
+ bswap(base, obj.constData);
+ bswap(base, obj.flags);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.type = obj.type;
+ dest.constData = reinterpret_cast(obj.constData);
+ dest.flags = obj.flags;
+
+ bswap(base, obj.data, dest.data, obj.type);
+}
+
+template void bswap(B &base, HsfBitmapKey32b &obj, HsfBitmapKey &dest)
+{
+ bswap(base, obj.time);
+ bswap(base, obj.data);
+
+ dest.time = obj.time;
+ dest.data = reinterpret_cast(obj.data);
+}
+
+template void bswap(B &base, HsfTrack32b &obj, HsfTrack &dest)
+{
+ bswap(base, obj.type);
+ bswap(base, obj.start);
+ bswap(base, obj.curveType);
+ bswap(base, obj.numKeyframes);
+ bswap(base, obj.data); // this byteswaps "value" too
+
+ dest.type = obj.type;
+ dest.start = obj.start;
+ dest.curveType = obj.curveType;
+ dest.numKeyframes = obj.numKeyframes;
+ dest.data = reinterpret_cast(obj.data); // this correctly sets "value" too
+
+ if (obj.type = HSF_TRACK_CLUSTER_WEIGHT) {
+ bswap(base, obj.unk04);
+
+ dest.unk04 = obj.unk04;
+ }
+ else {
+ bswap(base, obj.param);
+ bswap(base, obj.channel);
+
+ dest.param = obj.param;
+ dest.channel = obj.channel;
+ }
+}
+
+template void bswap(B &base, HsfMotion32b &obj, HsfMotion &dest)
+{
+ bswap(base, obj.name);
+ bswap(base, obj.numTracks);
+ bswap(base, obj.track);
+ bswap(base, obj.len);
+
+ dest.name = reinterpret_cast(obj.name);
+ dest.numTracks = obj.numTracks;
+ dest.track = reinterpret_cast(obj.track);
+ dest.len = obj.len;
+}
+
+template void bswap(B &base, HsfFace32b &obj, HsfFace &dest)
+{
+ bswap(base, obj.type);
+ bswap(base, obj.mat);
+ bswap(base, obj.nbt);
+
+ dest.type = obj.type;
+ dest.mat = obj.mat;
+ dest.nbt = obj.nbt;
+
+ if (obj.type == 4) {
+ bswap(base, obj.strip.count);
+ bswap(base, obj.strip.data);
+ bswap_flat(base, obj.strip.indices[0], 3 * 4);
+
+ dest.strip.count = obj.strip.count;
+ dest.strip.data = reinterpret_cast(obj.strip.data);
+ std::copy(&obj.strip.indices[0][0], &obj.strip.indices[0][0] + 3 * 4, &dest.strip.indices[0][0]);
+ }
+ else {
+ bswap_flat(base, obj.indices[0], 4 * 4);
+ std::copy(&obj.indices[0][0], &obj.indices[0][0] + 4 * 4, &dest.indices[0][0]);
+ }
+}
+
+void byteswap_u16(u16 *src)
+{
+ bswap(*src, *src);
+ sVisitedPtrs.clear();
+}
+
+void byteswap_s16(s16 *src)
+{
+ bswap(*src, *src);
+ sVisitedPtrs.clear();
+}
+
void byteswap_u32(u32 *src)
{
bswap(*src, *src);
@@ -354,6 +770,19 @@ void byteswap_s32(s32 *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);
@@ -399,3 +828,119 @@ void byteswap_hsfheader(HsfHeader *src)
bswap(*src, *src);
sVisitedPtrs.clear();
}
+
+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();
+}
\ No newline at end of file
diff --git a/src/port/stubs.c b/src/port/stubs.c
index 70a901f2..1fe4509f 100644
--- a/src/port/stubs.c
+++ b/src/port/stubs.c
@@ -198,27 +198,27 @@ s32 CARDWriteAsync(CARDFileInfo *fileInfo, const void *addr, s32 length, s32 off
void DCFlushRange(void *addr, u32 nBytes)
{
- puts("DCFlushRange is a stub");
+ //puts("DCFlushRange is a stub");
}
void DCFlushRangeNoSync(void *addr, u32 nBytes)
{
- puts("DCFlushRangeNoSync is a stub");
+ //puts("DCFlushRangeNoSync is a stub");
}
void DCInvalidateRange(void *addr, u32 nBytes)
{
- puts("DCInvalidateRange is a stub");
+ //puts("DCInvalidateRange is a stub");
}
void DCStoreRange(void *addr, u32 nBytes)
{
- puts("DCStoreRange is a stub");
+ //puts("DCStoreRange is a stub");
}
void DCStoreRangeNoSync(void *addr, u32 nBytes)
{
- puts("DCStoreRangeNoSync is a stub");
+ //puts("DCStoreRangeNoSync is a stub");
}
void DEMOUpdateStats(unsigned char inc)
@@ -603,7 +603,7 @@ GXDrawSyncCallback GXSetDrawSyncCallback(GXDrawSyncCallback cb)
void PPCSync(void)
{
- puts("PPCSync is a stub");
+ //puts("PPCSync is a stub");
}
void GXUnknownu16(const u16 x)