Port most of hsfload to PC (#581)
* Port some of hsfload.c * More byteswaps in hsfload.c * Finish hsfload besides cenv * hsfload fixes
This commit is contained in:
parent
909c743527
commit
bc19d2263b
21 changed files with 1662 additions and 402 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -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++) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include "game/hsfformat.h"
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
|
@ -5,8 +6,7 @@
|
|||
#include <ext_math.h>
|
||||
#include <unordered_set>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include "port/byteswap.h"
|
||||
|
||||
typedef struct AnimData32b {
|
||||
|
|
@ -45,7 +45,6 @@ typedef struct AnimBmpData32b {
|
|||
u32 palData;
|
||||
u32 data;
|
||||
} AnimBmpData32b;
|
||||
|
||||
}
|
||||
|
||||
template <typename T> [[nodiscard]] constexpr T bswap16(T val) noexcept
|
||||
|
|
@ -54,7 +53,7 @@ template <typename T> [[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 <typename T> [[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<void *> sVisitedPtrs;
|
|||
|
||||
template <typename B, typename T> T *offset_ptr(B &base, T *ptr)
|
||||
{
|
||||
return reinterpret_cast<T *>(reinterpret_cast<uintptr_t>(&base) +
|
||||
reinterpret_cast<uintptr_t>(ptr));
|
||||
return reinterpret_cast<T *>(reinterpret_cast<uintptr_t>(&base) + reinterpret_cast<uintptr_t>(ptr));
|
||||
}
|
||||
template <typename B, typename T> T *offset_ptr(B &base, T *ptr, void *extra)
|
||||
{
|
||||
return reinterpret_cast<T *>(reinterpret_cast<uintptr_t>(&base) +
|
||||
reinterpret_cast<uintptr_t>(ptr) +
|
||||
reinterpret_cast<uintptr_t>(extra));
|
||||
return reinterpret_cast<T *>(reinterpret_cast<uintptr_t>(&base) + reinterpret_cast<uintptr_t>(ptr) + reinterpret_cast<uintptr_t>(extra));
|
||||
}
|
||||
|
||||
template <typename B, typename T> static inline void bswap(B &base, T &data);
|
||||
|
|
@ -122,15 +117,12 @@ template <typename B, typename P> void bswap(B &base, P *&ptr)
|
|||
template <typename B, typename T> 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 <typename B, typename T> void bswap(B &base, T *&ptr, s32 count)
|
|||
template <typename B, typename T> 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 <typename B, typename T> void bswap_list(B &base, T **&ptr)
|
|||
template <typename B, typename T> void bswap_list(B &base, T *(&ptr)[])
|
||||
{
|
||||
T **objBase = ptr;
|
||||
while (*objBase != nullptr)
|
||||
{
|
||||
while (*objBase != nullptr) {
|
||||
bswap(base, *objBase, 1);
|
||||
++objBase;
|
||||
}
|
||||
|
|
@ -164,8 +153,7 @@ template <typename B, typename T> void bswap_list(B &base, T *(&ptr)[])
|
|||
template <typename B, typename T> 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 <typename B> void bswap(B &base, Vec2f &vec)
|
|||
bswap(base, vec.y);
|
||||
}
|
||||
|
||||
template <typename B> void bswap(B &base, HsfVector3f &vec)
|
||||
{
|
||||
bswap(base, vec.x);
|
||||
bswap(base, vec.y);
|
||||
bswap(base, vec.z);
|
||||
}
|
||||
|
||||
template <typename B> void bswap(B &base, AnimData32b &obj, AnimData &dest)
|
||||
{
|
||||
bswap(base, obj.bankNum);
|
||||
|
|
@ -342,6 +337,427 @@ template <typename B> void bswap(B &base, HsfHeader &obj)
|
|||
bswap(base, obj.string);
|
||||
}
|
||||
|
||||
template <typename B> 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<char *>(obj.name[0]);
|
||||
dest.name[1] = reinterpret_cast<char *>(obj.name[1]);
|
||||
|
||||
dest.targetName = reinterpret_cast<char *>(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<HsfBuffer **>(obj.vertex);
|
||||
}
|
||||
|
||||
template <typename B> 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<char *>(obj.name);
|
||||
dest.unk04 = reinterpret_cast<struct hsfdraw_struct_01 *>(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<HsfBitmap *>(obj.bitmap);
|
||||
}
|
||||
|
||||
template <typename B> 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<char *>(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<s32 *>(obj.attrs);
|
||||
}
|
||||
|
||||
template <typename B> void bswap(B &base, HsfScene &obj)
|
||||
{
|
||||
u32 fogType = static_cast<u32>(obj.fogType);
|
||||
fogType = bswap32(fogType);
|
||||
obj.fogType = static_cast<GXFogType>(fogType);
|
||||
bswap(base, obj.start);
|
||||
bswap(base, obj.end);
|
||||
}
|
||||
|
||||
template <typename B> void bswap(B &base, HsfBuffer32b &obj, HsfBuffer &dest)
|
||||
{
|
||||
bswap(base, obj.name);
|
||||
bswap(base, obj.count);
|
||||
bswap(base, obj.data);
|
||||
|
||||
dest.name = reinterpret_cast<char *>(obj.name);
|
||||
dest.count = obj.count;
|
||||
dest.data = reinterpret_cast<void *>(obj.data);
|
||||
}
|
||||
|
||||
template <typename B> 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 <typename B> 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<char *>(obj.name);
|
||||
dest.unk = obj.unk;
|
||||
dest.palSize = obj.palSize;
|
||||
dest.data = reinterpret_cast<u16 *>(obj.data);
|
||||
}
|
||||
|
||||
template <typename B> void bswap(B &base, HsfPart32b &obj, HsfPart &dest)
|
||||
{
|
||||
bswap(base, obj.name);
|
||||
bswap(base, obj.count);
|
||||
bswap(base, obj.vertex);
|
||||
|
||||
dest.name = reinterpret_cast<char *>(obj.name);
|
||||
dest.count = obj.count;
|
||||
dest.vertex = reinterpret_cast<u16 *>(obj.vertex);
|
||||
}
|
||||
|
||||
template <typename B> 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<char *>(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<void *>(obj.palData);
|
||||
dest.unk = obj.unk;
|
||||
dest.data = reinterpret_cast<void *>(obj.data);
|
||||
}
|
||||
|
||||
template <typename B> 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<u16 *>(obj.data);
|
||||
dest.dataLen = obj.dataLen;
|
||||
}
|
||||
|
||||
template <typename B> void bswap(B &base, HsfTransform &obj)
|
||||
{
|
||||
bswap(base, obj.pos);
|
||||
bswap(base, obj.rot);
|
||||
bswap(base, obj.scale);
|
||||
}
|
||||
|
||||
template <typename B> void bswap(B &base, HsfSkeleton32b &obj, HsfSkeleton &dest)
|
||||
{
|
||||
bswap(base, obj.name);
|
||||
bswap(base, obj.transform);
|
||||
|
||||
dest.name = reinterpret_cast<char *>(obj.name);
|
||||
dest.transform = obj.transform;
|
||||
}
|
||||
|
||||
template <typename B> void bswap(B &base, HsfShape32b &obj, HsfShape &dest)
|
||||
{
|
||||
bswap(base, obj.name);
|
||||
bswap(base, obj.vertex);
|
||||
|
||||
dest.name = reinterpret_cast<char *>(obj.name);
|
||||
dest.vertex = reinterpret_cast<HsfBuffer **>(obj.vertex);
|
||||
}
|
||||
|
||||
template <typename B> 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 <typename B> 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<char *>(obj.name);
|
||||
dest.singleData = reinterpret_cast<HsfCenvSingle *>(obj.singleData);
|
||||
dest.dualData = reinterpret_cast<HsfCenvDual *>(obj.dualData);
|
||||
dest.multiData = reinterpret_cast<HsfCenvMulti *>(obj.multiData);
|
||||
dest.singleCount = obj.singleCount;
|
||||
dest.dualCount = obj.dualCount;
|
||||
dest.multiCount = obj.multiCount;
|
||||
dest.vtxCount = obj.vtxCount;
|
||||
dest.copyCount = obj.copyCount;
|
||||
}
|
||||
|
||||
template <typename B> 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<struct hsf_object *>(obj.parent);
|
||||
dest.childrenCount = obj.childrenCount;
|
||||
dest.children = reinterpret_cast<struct hsf_object **>(obj.children);
|
||||
dest.base = obj.base;
|
||||
dest.curr = obj.curr;
|
||||
dest.face = reinterpret_cast<HsfBuffer *>(obj.face);
|
||||
dest.vertex = reinterpret_cast<HsfBuffer *>(obj.vertex);
|
||||
dest.normal = reinterpret_cast<HsfBuffer *>(obj.normal);
|
||||
dest.color = reinterpret_cast<HsfBuffer *>(obj.color);
|
||||
dest.st = reinterpret_cast<HsfBuffer *>(obj.st);
|
||||
dest.material = reinterpret_cast<HsfMaterial *>(obj.material);
|
||||
dest.attribute = reinterpret_cast<HsfAttribute *>(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<HsfBuffer **>(obj.vertexShape);
|
||||
dest.clusterCnt = obj.clusterCnt;
|
||||
dest.cluster = reinterpret_cast<HsfCluster **>(obj.cluster);
|
||||
dest.cenvCnt = obj.cenvCnt;
|
||||
dest.cenv = reinterpret_cast<HsfCenv *>(obj.cenv);
|
||||
dest.file[0] = reinterpret_cast<void *>(obj.file[0]);
|
||||
dest.file[1] = reinterpret_cast<void *>(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 <typename B> 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<char *>(obj.name);
|
||||
dest.type = obj.type;
|
||||
dest.constData = reinterpret_cast<void *>(obj.constData);
|
||||
dest.flags = obj.flags;
|
||||
|
||||
bswap(base, obj.data, dest.data, obj.type);
|
||||
}
|
||||
|
||||
template <typename B> void bswap(B &base, HsfBitmapKey32b &obj, HsfBitmapKey &dest)
|
||||
{
|
||||
bswap(base, obj.time);
|
||||
bswap(base, obj.data);
|
||||
|
||||
dest.time = obj.time;
|
||||
dest.data = reinterpret_cast<HsfBitmap *>(obj.data);
|
||||
}
|
||||
|
||||
template <typename B> 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<void *>(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 <typename B> 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<char *>(obj.name);
|
||||
dest.numTracks = obj.numTracks;
|
||||
dest.track = reinterpret_cast<HsfTrack *>(obj.track);
|
||||
dest.len = obj.len;
|
||||
}
|
||||
|
||||
template <typename B> 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<s16 *>(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<Vec2f *>(src);
|
||||
bswap(*vec, *vec);
|
||||
sVisitedPtrs.clear();
|
||||
}
|
||||
|
||||
void byteswap_animdata(void *src, AnimData *dest)
|
||||
{
|
||||
auto *anim = reinterpret_cast<AnimData32b *>(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();
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue