From 8c14475c86f78ddd74fb163a205328a2849b2fa2 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Mon, 4 Dec 2023 14:48:53 -0600 Subject: [PATCH] Decompile up to BitmapLoad --- include/game/hsfformat.h | 42 +++++++++---- src/game/hsfload.c | 126 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 154 insertions(+), 14 deletions(-) diff --git a/include/game/hsfformat.h b/include/game/hsfformat.h index f9f87513..505ab6ba 100644 --- a/include/game/hsfformat.h +++ b/include/game/hsfformat.h @@ -134,7 +134,7 @@ typedef struct hsf_face { typedef struct hsf_const_data { u32 flags; - u8 unk[64]; + u8 unk4[64]; } HsfConstData; typedef struct hsf_transform { @@ -195,20 +195,31 @@ typedef struct hsf_cenv { typedef struct hsf_part { char *name; u32 count; - u16 *data; + u16 *vertex; } HsfPart; typedef struct hsf_cluster { - char *name[3]; + char *name[2]; + union { + char *targetName; + u32 target; + }; HsfPart *part; - u8 unk[144]; + u8 unk10[132]; + u8 adjusted; + u8 unk95; + u16 type; + u32 vertexCnt; + HsfBuffer **vertex; } HsfCluster; typedef struct hsf_shape { char *name; - u16 count1; - u16 morphTargetCnt; - HsfBuffer **morphTargets; + union { + u16 count16[2]; + u32 vertexCnt; + }; + HsfBuffer **vertex; } HsfShape; typedef struct hsf_object_data { @@ -221,9 +232,10 @@ typedef struct hsf_object_data { struct { HsfVector3f min; HsfVector3f max; - u8 unk[136]; + float baseMorph; + float *morphWeight[33]; } mesh; - struct hsf_object *unk64; + struct hsf_object *replica; }; HsfBuffer *face; @@ -233,7 +245,8 @@ typedef struct hsf_object_data { HsfBuffer *st; HsfMaterial *material; HsfAttribute *attribute; - u8 unk2[4]; + u8 unk120[2]; + u8 shapeType; u32 vertexShapeCnt; HsfBuffer **vertexShape; u32 clusterCnt; @@ -275,9 +288,12 @@ typedef struct hsf_motion { } HsfMotion; typedef struct hsf_map_attr { - u8 unk[16]; - void *unk10; - u8 unk2[4]; + float min_x; + float min_z; + float max_x; + float max_z; + s16 *data; + u32 dataLen; } HsfMapAttr; typedef struct hsf_matrix { diff --git a/src/game/hsfload.c b/src/game/hsfload.c index 27762064..94b1b915 100644 --- a/src/game/hsfload.c +++ b/src/game/hsfload.c @@ -41,6 +41,7 @@ static void BitmapLoad(void); static void MotionLoad(void); static void MatrixLoad(void); +static s32 SearchObjectSetName(HsfData *data, char *name); static HsfBuffer *SearchVertexPtr(s32 id); static HsfBuffer *SearchNormalPtr(s32 id); static HsfBuffer *SearchStPtr(s32 id); @@ -85,6 +86,27 @@ HsfData *LoadHSF(void *data) } +void ClusterAdjustObject(HsfData *src_model, HsfData *model) +{ + HsfCluster *cluster; + s32 i; + if(!model) { + return; + } + if(model->clusterCnt == 0) { + return; + } + cluster = model->cluster; + if(cluster->adjusted) { + return; + } + cluster->adjusted = 1; + for(i=0; iclusterCnt; i++, cluster++) { + char *name = cluster->targetName; + cluster->target = SearchObjectSetName(src_model, name); + } +} + static void FileLoad(void *data) { fileptr = data; @@ -516,7 +538,7 @@ static void DispObject(HsfObject *parent, HsfObject *object) if(Model.root == NULL) { Model.root = temp_object; } - new_object->data.unk64 = &objtop[(u32)new_object->data.unk64]; + new_object->data.replica = &objtop[(u32)new_object->data.replica]; for(i=0; ichildrenCount; i++) { DispObject(new_object, new_object->data.children[i]); } @@ -773,6 +795,108 @@ static void SkeletonLoad(void) } } +static void PartLoad(void) +{ + HsfPart *part_file; + HsfPart *part_new; + + u16 *data; + s32 i, j; + + if(head.part.count) { + part_new = part_file = (HsfPart *)((u32)fileptr+head.part.ofs); + Model.partCnt = head.part.count; + Model.part = part_file; + data = (u16 *)&part_file[head.part.count]; + 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]; + for(j=0; jcount; j++) { + part_new->vertex[j] = part_new->vertex[j]; + } + } + } +} + +static void ClusterLoad(void) +{ + HsfCluster *cluster_file; + HsfCluster *cluster_new; + + s32 i, j; + + if(head.cluster.count) { + cluster_new = cluster_file = (HsfCluster *)((u32)fileptr+head.cluster.ofs); + Model.clusterCnt = head.cluster.count; + Model.cluster = cluster_file; + for(i=0; idata = &data[(u32)mapattr_file->data]; + } + } +} + static s32 SearchObjectSetName(HsfData *data, char *name) { HsfObject *object = data->object;