Start Decompiling hsfload.c
This commit is contained in:
parent
d61508e344
commit
5d9586c9cd
4 changed files with 499 additions and 2 deletions
|
|
@ -5399,7 +5399,8 @@ HuSprOrder = .bss:0x8015AE90; // type:object size:0x1800
|
|||
bmpNoCC = .bss:0x8015C690; // type:object size:0x20 scope:local
|
||||
HuSprLayerDrawNo = .bss:0x8015C6B0; // type:object size:0x10 scope:local
|
||||
Model = .bss:0x8015C6C0; // type:object size:0x80
|
||||
head = .bss:0x8015C740; // type:object size:0x240
|
||||
head = .bss:0x8015C740; // type:object size:0xB0
|
||||
rgba = .bss:0x8015C7F0; // type:object size:0x190
|
||||
lbl_8015C980 = .bss:0x8015C980; // type:object size:0x300 scope:local data:byte
|
||||
DrawObjData = .bss:0x8015CC80; // type:object size:0x9000 scope:local
|
||||
BmpPtrBak = .bss:0x80165C80; // type:object size:0x20 scope:local data:4byte
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ config.libs = [
|
|||
Object(Matching, "game/process.c"),
|
||||
Object(Matching, "game/sprman.c"),
|
||||
Object(Matching, "game/sprput.c"),
|
||||
Object(NonMatching, "game/hsfload.c"),
|
||||
Object(Matching, "game/hsfload.c"),
|
||||
Object(NonMatching, "game/hsfdraw.c"),
|
||||
Object(NonMatching, "game/hsfman.c"),
|
||||
Object(NonMatching, "game/hsfmotion.c"),
|
||||
|
|
|
|||
249
include/game/hsfformat.h
Normal file
249
include/game/hsfformat.h
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
#ifndef _HSF_FORMAT_H
|
||||
#define _HSF_FORMAT_H
|
||||
|
||||
#include "dolphin.h"
|
||||
|
||||
typedef struct hsf_section {
|
||||
s32 ofs;
|
||||
s32 count;
|
||||
} HsfSection;
|
||||
|
||||
typedef struct hsf_header {
|
||||
char magic[8];
|
||||
HsfSection scene;
|
||||
HsfSection color;
|
||||
HsfSection material;
|
||||
HsfSection attribute;
|
||||
HsfSection vertex;
|
||||
HsfSection normal;
|
||||
HsfSection st;
|
||||
HsfSection face;
|
||||
HsfSection object;
|
||||
HsfSection bitmap;
|
||||
HsfSection palette;
|
||||
HsfSection motion;
|
||||
HsfSection cenv;
|
||||
HsfSection skeleton;
|
||||
HsfSection part;
|
||||
HsfSection cluster;
|
||||
HsfSection shape;
|
||||
HsfSection mapAttr;
|
||||
HsfSection matrix;
|
||||
HsfSection symbol;
|
||||
HsfSection string;
|
||||
} HsfHeader;
|
||||
|
||||
typedef struct hsf_scene {
|
||||
GXColor unk0;
|
||||
f32 unk4;
|
||||
f32 unk8;
|
||||
u32 unkC;
|
||||
} HsfScene;
|
||||
|
||||
typedef struct hsf_bitmap {
|
||||
char *name;
|
||||
s32 maxLod;
|
||||
u8 dataFmt;
|
||||
u8 pixSize;
|
||||
u16 w;
|
||||
u16 h;
|
||||
u16 palSize;
|
||||
GXColor tint;
|
||||
void *palData;
|
||||
u32 unk;
|
||||
void *data;
|
||||
} HsfBitmap;
|
||||
|
||||
typedef struct hsf_palette {
|
||||
char *name;
|
||||
int unk;
|
||||
int palSize;
|
||||
void *data;
|
||||
} HsfPalette;
|
||||
|
||||
typedef struct hsf_attribute {
|
||||
char *name;
|
||||
u8 unk[124];
|
||||
HsfBitmap *bitmap;
|
||||
} HsfAttribute;
|
||||
|
||||
typedef struct hsf_material {
|
||||
char *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;
|
||||
HsfAttribute **attrs;
|
||||
} HsfMaterial;
|
||||
|
||||
typedef struct hsf_vertex_buf {
|
||||
char *name;
|
||||
u32 count;
|
||||
void *data;
|
||||
} HsfVertexBuf;
|
||||
|
||||
typedef struct hsf_face {
|
||||
u16 type;
|
||||
u16 mat;
|
||||
u16 indices[12];
|
||||
union {
|
||||
struct {
|
||||
u32 count;
|
||||
u16 *data;
|
||||
} strip;
|
||||
u16 ext_indices[4];
|
||||
};
|
||||
} HSFFace;
|
||||
|
||||
typedef struct hsf_face_buf {
|
||||
char *name;
|
||||
u32 count;
|
||||
HSFFace *data;
|
||||
} HsfFaceBuf;
|
||||
|
||||
typedef struct hsf_const_data {
|
||||
u32 flags;
|
||||
u8 unk[64];
|
||||
} HsfConstData;
|
||||
|
||||
typedef struct hsf_transform {
|
||||
Vec pos;
|
||||
Vec rot;
|
||||
Vec scale;
|
||||
} HsfTransform;
|
||||
|
||||
typedef struct hsf_object {
|
||||
char *name;
|
||||
u32 type;
|
||||
HsfConstData *constData;
|
||||
u32 flags;
|
||||
u32 idx;
|
||||
u32 childrenCount;
|
||||
struct hsf_object **children;
|
||||
HsfTransform base;
|
||||
HsfTransform curr;
|
||||
Vec min;
|
||||
Vec max;
|
||||
u8 unk[136];
|
||||
HsfFaceBuf *face;
|
||||
HsfVertexBuf *vertex;
|
||||
HsfVertexBuf *normal;
|
||||
HsfVertexBuf *st;
|
||||
HsfVertexBuf *color;
|
||||
HsfMaterial *material;
|
||||
HsfAttribute *attribute;
|
||||
u8 unk2[36];
|
||||
} HsfObject;
|
||||
|
||||
typedef struct hsf_cenv {
|
||||
u8 unk[36];
|
||||
} HsfCenv;
|
||||
|
||||
typedef struct hsf_part {
|
||||
char *name;
|
||||
u32 count;
|
||||
u16 *data;
|
||||
} HsfPart;
|
||||
|
||||
typedef struct hsf_cluster {
|
||||
char *name[3];
|
||||
HsfPart *part;
|
||||
u8 unk[144];
|
||||
} HsfCluster;
|
||||
|
||||
typedef struct hsf_shape {
|
||||
char *name;
|
||||
u16 count1;
|
||||
u16 morphTargetCnt;
|
||||
HsfVertexBuf **morphTargets;
|
||||
} HsfShape;
|
||||
|
||||
typedef struct hsf_skeleton {
|
||||
char *name;
|
||||
HsfTransform transform;
|
||||
} HsfSkeleton;
|
||||
|
||||
typedef struct hsf_track {
|
||||
u8 mode;
|
||||
u8 value;
|
||||
s16 idx;
|
||||
s16 type;
|
||||
s16 effect;
|
||||
s16 curveType;
|
||||
s16 numKeyframes;
|
||||
void *data;
|
||||
} HsfTrack;
|
||||
|
||||
typedef struct hsf_motion {
|
||||
char *name;
|
||||
u32 numTracks;
|
||||
HsfTrack *track;
|
||||
float len;
|
||||
} HsfMotion;
|
||||
|
||||
typedef struct hsf_map_attr {
|
||||
u8 unk[16];
|
||||
void *unk10;
|
||||
u8 unk2[4];
|
||||
} HsfMapAttr;
|
||||
|
||||
typedef struct hsf_matrix {
|
||||
u32 base_idx;
|
||||
u32 count;
|
||||
Mtx *data;
|
||||
} HsfMatrix;
|
||||
|
||||
typedef struct hsf_data {
|
||||
u8 magic[8];
|
||||
HsfScene *scene;
|
||||
HsfAttribute *attribute;
|
||||
HsfMaterial *material;
|
||||
HsfVertexBuf *vertex;
|
||||
HsfVertexBuf *normal;
|
||||
HsfVertexBuf *st;
|
||||
HsfVertexBuf *color;
|
||||
HsfFaceBuf *face;
|
||||
HsfBitmap *bitmap;
|
||||
HsfPalette *palette;
|
||||
HsfObject *root;
|
||||
HsfCenv *cenv;
|
||||
HsfSkeleton *skeleton;
|
||||
HsfCluster *cluster;
|
||||
HsfPart *part;
|
||||
HsfShape *shape;
|
||||
HsfMotion *motion;
|
||||
HsfObject *object;
|
||||
HsfMapAttr *mapAttr;
|
||||
HsfMatrix *matrix;
|
||||
s16 sceneCnt;
|
||||
s16 attributeCnt;
|
||||
s16 materialCnt;
|
||||
s16 vertexCnt;
|
||||
s16 normalCnt;
|
||||
s16 stCnt;
|
||||
s16 colorCnt;
|
||||
s16 faceCnt;
|
||||
s16 bitmapCnt;
|
||||
s16 paletteCnt;
|
||||
s16 objectCnt;
|
||||
s16 cenvCnt;
|
||||
s16 skeletonCnt;
|
||||
s16 clusterCnt;
|
||||
s16 partCnt;
|
||||
s16 shapeCnt;
|
||||
s16 mapAttrCnt;
|
||||
s16 motionCnt;
|
||||
s16 matrixCnt;
|
||||
} HsfData;
|
||||
|
||||
#endif
|
||||
247
src/game/hsfload.c
Normal file
247
src/game/hsfload.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
#include "game/hsfformat.h"
|
||||
|
||||
GXColor rgba[400];
|
||||
HsfHeader head;
|
||||
HsfData Model;
|
||||
|
||||
static BOOL MotionOnly;
|
||||
static HsfData *MotionModel;
|
||||
static HsfVertexBuf *VertexDataTop;
|
||||
static HsfVertexBuf *NormalDataTop;
|
||||
void *fileptr;
|
||||
char *StringTable;
|
||||
char *DicStringTable;
|
||||
void **NSymIndex;
|
||||
HsfObject *objtop;
|
||||
HsfVertexBuf *vtxtop;
|
||||
HsfCluster *ClusterTop;
|
||||
HsfAttribute *AttributeTop;
|
||||
HsfMaterial *MaterialTop;
|
||||
|
||||
static void FileLoad(void *data);
|
||||
static HsfData *SetHsfModel(void);
|
||||
static void MaterialLoad(void);
|
||||
static void AttributeLoad(void);
|
||||
static void SceneLoad(void);
|
||||
static void ColorLoad(void);
|
||||
static void VertexLoad(void);
|
||||
static void NormalLoad(void);
|
||||
static void STLoad(void);
|
||||
static void FaceLoad(void);
|
||||
static void ObjectLoad(void);
|
||||
static void CenvLoad(void);
|
||||
static void SkeletonLoad(void);
|
||||
static void PartLoad(void);
|
||||
static void ClusterLoad(void);
|
||||
static void ShapeLoad(void);
|
||||
static void MapAttrLoad(void);
|
||||
static void PaletteLoad(void);
|
||||
static void BitmapLoad(void);
|
||||
static void MotionLoad(void);
|
||||
static void MatrixLoad(void);
|
||||
|
||||
static HsfBitmap *SearchBitmapPtr(s32 id);
|
||||
static char *GetString(u32 *str_ofs);
|
||||
|
||||
HsfData *LoadHSF(void *data)
|
||||
{
|
||||
HsfData *hsf;
|
||||
Model.root = NULL;
|
||||
objtop = NULL;
|
||||
FileLoad(data);
|
||||
SceneLoad();
|
||||
ColorLoad();
|
||||
PaletteLoad();
|
||||
BitmapLoad();
|
||||
MaterialLoad();
|
||||
AttributeLoad();
|
||||
VertexLoad();
|
||||
NormalLoad();
|
||||
STLoad();
|
||||
FaceLoad();
|
||||
ObjectLoad();
|
||||
CenvLoad();
|
||||
SkeletonLoad();
|
||||
PartLoad();
|
||||
ClusterLoad();
|
||||
ShapeLoad();
|
||||
MapAttrLoad();
|
||||
MotionLoad();
|
||||
MatrixLoad();
|
||||
hsf = SetHsfModel();
|
||||
InitEnvelope(hsf);
|
||||
objtop = NULL;
|
||||
return hsf;
|
||||
|
||||
}
|
||||
|
||||
static void FileLoad(void *data)
|
||||
{
|
||||
fileptr = data;
|
||||
memcpy(&head, fileptr, sizeof(HsfHeader));
|
||||
memset(&Model, 0, sizeof(HsfData));
|
||||
NSymIndex = (void **)((u32)fileptr+head.symbol.ofs);
|
||||
StringTable = (char *)((u32)fileptr+head.string.ofs);
|
||||
ClusterTop = (HsfCluster *)((u32)fileptr+head.cluster.ofs);
|
||||
AttributeTop = (HsfAttribute *)((u32)fileptr+head.attribute.ofs);
|
||||
MaterialTop = (HsfMaterial *)((u32)fileptr+head.material.ofs);
|
||||
}
|
||||
|
||||
static HsfData *SetHsfModel(void)
|
||||
{
|
||||
HsfData *data = fileptr;
|
||||
data->scene = Model.scene;
|
||||
data->sceneCnt = Model.sceneCnt;
|
||||
data->attribute = Model.attribute;
|
||||
data->attributeCnt = Model.attributeCnt;
|
||||
data->bitmap = Model.bitmap;
|
||||
data->bitmapCnt = Model.bitmapCnt;
|
||||
data->cenv = Model.cenv;
|
||||
data->cenvCnt = Model.cenvCnt;
|
||||
data->skeleton = Model.skeleton;
|
||||
data->skeletonCnt = Model.skeletonCnt;
|
||||
data->face = Model.face;
|
||||
data->faceCnt = Model.faceCnt;
|
||||
data->material = Model.material;
|
||||
data->materialCnt = Model.materialCnt;
|
||||
data->motion = Model.motion;
|
||||
data->motionCnt = Model.motionCnt;
|
||||
data->normal = Model.normal;
|
||||
data->normalCnt = Model.normalCnt;
|
||||
data->root = Model.root;
|
||||
data->objectCnt = Model.objectCnt;
|
||||
data->object = objtop;
|
||||
data->matrix = Model.matrix;
|
||||
data->matrixCnt = Model.matrixCnt;
|
||||
data->palette = Model.palette;
|
||||
data->paletteCnt = Model.paletteCnt;
|
||||
data->st = Model.st;
|
||||
data->stCnt = Model.stCnt;
|
||||
data->vertex = Model.vertex;
|
||||
data->vertexCnt = Model.vertexCnt;
|
||||
data->cenv = Model.cenv;
|
||||
data->cenvCnt = Model.cenvCnt;
|
||||
data->cluster = Model.cluster;
|
||||
data->clusterCnt = Model.clusterCnt;
|
||||
data->part = Model.part;
|
||||
data->partCnt = Model.partCnt;
|
||||
data->shape = Model.shape;
|
||||
data->shapeCnt = Model.shapeCnt;
|
||||
data->mapAttr = Model.mapAttr;
|
||||
data->mapAttrCnt = Model.mapAttrCnt;
|
||||
return data;
|
||||
}
|
||||
|
||||
char *SetName(u32 *str_ofs)
|
||||
{
|
||||
char *ret = GetString(str_ofs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void MaterialLoad(void)
|
||||
{
|
||||
s32 i;
|
||||
s32 j;
|
||||
if(head.material.count) {
|
||||
HsfMaterial *file_mat = (HsfMaterial *)((u32)fileptr+head.material.ofs);
|
||||
HsfMaterial *curr_mat;
|
||||
HsfMaterial *new_mat;
|
||||
for(i=0; i<head.material.count; i++) {
|
||||
curr_mat = &file_mat[i];
|
||||
}
|
||||
new_mat = file_mat;
|
||||
Model.material = new_mat;
|
||||
Model.materialCnt = head.material.count;
|
||||
file_mat = (HsfMaterial *)((u32)fileptr+head.material.ofs);
|
||||
for(i=0; i<head.material.count; i++, new_mat++) {
|
||||
curr_mat = &file_mat[i];
|
||||
new_mat->name = SetName((u32 *)&curr_mat->name);
|
||||
new_mat->pass = curr_mat->pass;
|
||||
new_mat->vtxMode = curr_mat->vtxMode;
|
||||
new_mat->litColor[0] = curr_mat->litColor[0];
|
||||
new_mat->litColor[1] = curr_mat->litColor[1];
|
||||
new_mat->litColor[2] = curr_mat->litColor[2];
|
||||
new_mat->color[0] = curr_mat->color[0];
|
||||
new_mat->color[1] = curr_mat->color[1];
|
||||
new_mat->color[2] = curr_mat->color[2];
|
||||
new_mat->shadowColor[0] = curr_mat->shadowColor[0];
|
||||
new_mat->shadowColor[1] = curr_mat->shadowColor[1];
|
||||
new_mat->shadowColor[2] = curr_mat->shadowColor[2];
|
||||
new_mat->hilite_scale = curr_mat->hilite_scale;
|
||||
new_mat->unk18 = curr_mat->unk18;
|
||||
new_mat->invAlpha = curr_mat->invAlpha;
|
||||
new_mat->unk20[0] = curr_mat->unk20[0];
|
||||
new_mat->unk20[1] = curr_mat->unk20[1];
|
||||
new_mat->refAlpha = curr_mat->refAlpha;
|
||||
new_mat->unk2C = curr_mat->unk2C;
|
||||
new_mat->numAttrs = curr_mat->numAttrs;
|
||||
new_mat->attrs = (HsfAttribute **)(NSymIndex+((u32)curr_mat->attrs));
|
||||
rgba[i].r = new_mat->litColor[0];
|
||||
rgba[i].g = new_mat->litColor[1];
|
||||
rgba[i].b = new_mat->litColor[2];
|
||||
rgba[i].a = 255;
|
||||
for(j=0; j<new_mat->numAttrs; j++) {
|
||||
new_mat->attrs[j] = new_mat->attrs[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void AttributeLoad(void)
|
||||
{
|
||||
HsfAttribute *file_attr;
|
||||
HsfAttribute *new_attr;
|
||||
HsfAttribute *temp_attr;
|
||||
s32 i;
|
||||
if(head.attribute.count) {
|
||||
temp_attr = file_attr = (HsfAttribute *)((u32)fileptr+head.attribute.ofs);
|
||||
new_attr = temp_attr;
|
||||
Model.attribute = new_attr;
|
||||
Model.attributeCnt = head.attribute.count;
|
||||
for(i=0; i<head.attribute.count; i++, new_attr++) {
|
||||
if((u32)file_attr[i].name != -1) {
|
||||
new_attr->name = SetName((u32 *)&file_attr[i].name);
|
||||
} else {
|
||||
new_attr->name = NULL;
|
||||
}
|
||||
new_attr->bitmap = SearchBitmapPtr((s32)file_attr[i].bitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void SceneLoad(void)
|
||||
{
|
||||
HsfScene *file_scene;
|
||||
HsfScene *new_scene;
|
||||
if(head.scene.count) {
|
||||
file_scene = (HsfScene *)((u32)fileptr+head.scene.ofs);
|
||||
new_scene = file_scene;
|
||||
new_scene->unk8 = file_scene->unk8;
|
||||
new_scene->unk4 = file_scene->unk4;
|
||||
Model.scene = new_scene;
|
||||
Model.sceneCnt = head.scene.count;
|
||||
}
|
||||
}
|
||||
|
||||
static HsfBitmap *SearchBitmapPtr(s32 id)
|
||||
{
|
||||
HsfBitmap *bitmap;
|
||||
if(id == -1) {
|
||||
return NULL;
|
||||
}
|
||||
bitmap = (HsfBitmap *)((u32)fileptr+head.bitmap.ofs);
|
||||
bitmap += id;
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
static char *GetString(u32 *str_ofs)
|
||||
{
|
||||
char *ret = &StringTable[*str_ofs];
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *GetMotionString(u16 *str_ofs)
|
||||
{
|
||||
char *ret = &StringTable[*str_ofs];
|
||||
return ret;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue