482 lines
12 KiB
C
Raw Normal View History

2015-12-23 23:23:46 +01:00
enum {
TEX_IDENT = 0x00746578,
MDL_IDENT = 0x006D646C,
WRLD_IDENT = 0x57524C44
};
2015-12-21 20:11:55 +01:00
struct RslStream {
2015-12-23 23:23:46 +01:00
uint32 ident;
2015-12-21 20:11:55 +01:00
bool32 isMulti;
uint32 fileSize;
uint32 dataSize;
uint8 ***reloc;
uint32 relocSize;
uint8 **hashTab; // ??
uint16 hashTabSize;
uint16 numAtomics;
uint8 *data;
void relocate(void);
};
2015-12-22 12:11:10 +01:00
struct RslObject;
2015-12-21 20:11:55 +01:00
struct RslObjectHasFrame;
struct RslClump;
struct RslAtomic;
struct RslFrame;
struct RslNativeGeometry;
struct RslNativeMesh;
struct RslGeometry;
struct RslSkin;
struct RslMaterial;
struct RslHAnimHierarchy;
struct RslHAnimNode;
struct RslPS2ResEntryHeader;
struct RslPS2InstanceData;
2015-12-27 18:45:37 +01:00
struct RslTexDictionary;
struct RslTexture;
2015-12-21 20:11:55 +01:00
2015-12-21 21:56:47 +01:00
typedef RslFrame *(*RslFrameCallBack)(RslFrame *frame, void *data);
2015-12-21 20:11:55 +01:00
typedef RslClump *(*RslClumpCallBack)(RslClump *clump, void *data);
typedef RslAtomic *(*RslAtomicCallBack)(RslAtomic *atomic, void *data);
typedef RslMaterial *(*RslMaterialCallBack)(RslMaterial *material, void *data);
2015-12-27 18:45:37 +01:00
typedef RslTexture *(*RslTextureCallBack)(RslTexture *texture, void *pData);
2015-12-21 20:11:55 +01:00
2016-01-09 22:01:21 +01:00
struct RslV3d
{
float32 x, y, z;
};
struct RslMatrix
{
2016-01-10 18:18:03 +01:00
RslV3d right;
uint32 flags;
RslV3d up;
uint32 pad1;
RslV3d at;
uint32 pad2;
RslV3d pos;
2016-01-09 22:01:21 +01:00
uint32 pad3;
};
void RslMatrixSetIdentity(RslMatrix *matrix);
struct RslLLLink
{
2015-12-22 12:11:10 +01:00
RslLLLink *next;
RslLLLink *prev;
2015-12-21 20:11:55 +01:00
};
2016-01-11 11:23:26 +01:00
#define rslLLLinkGetData(linkvar,type,entry) \
((type*)(((uint8*)(linkvar))-offsetof(type,entry)))
#define rslLLLinkGetNext(linkvar) \
((linkvar)->next)
#define rslLLLinkGetPrevious(linkvar) \
((linkvar)->prev)
#define rslLLLinkInitialize(linkvar) \
((linkvar)->prev = (RslLLLink*)NULL, \
(linkvar)->next = (RslLLLink*)NULL)
#define rslLLLinkAttached(linkvar) \
((linkvar)->next)
2016-01-09 22:01:21 +01:00
struct RslLinkList
{
2015-12-22 12:11:10 +01:00
RslLLLink link;
2015-12-21 20:11:55 +01:00
};
2016-01-11 11:23:26 +01:00
#define rslLinkListInitialize(list) \
((list)->link.next = ((RslLLLink*)(list)), \
(list)->link.prev = ((RslLLLink*)(list)))
#define rslLinkListEmpty(list) \
(((list)->link.next) == (&(list)->link))
#define rslLinkListAddLLLink(list, linkvar) \
((linkvar)->next = (list)->link.next, \
(linkvar)->prev = (&(list)->link), \
((list)->link.next)->prev = (linkvar), \
(list)->link.next = (linkvar) )
#define rslLinkListRemoveLLLink(linkvar) \
(((linkvar)->prev)->next = (linkvar)->next, \
((linkvar)->next)->prev = (linkvar)->prev)
#define rslLinkListGetFirstLLLink(list) \
((list)->link.next)
#define rslLinkListGetLastLLLink(list) \
((list)->link.prev)
#define rslLinkListGetTerminator(list) \
(&((list)->link))
2015-12-22 12:11:10 +01:00
struct RslObject {
2016-01-09 22:01:21 +01:00
uint8 type;
uint8 subType;
uint8 flags;
uint8 privateFlags;
void *parent;
2015-12-22 12:11:10 +01:00
};
2016-01-10 18:18:03 +01:00
#define rslObjectInitialize(o, t, s) \
{ \
((RslObject*)(o))->type = (uint8)(t); \
((RslObject*)(o))->subType = (uint8)(s); \
((RslObject*)(o))->flags = 0; \
((RslObject*)(o))->privateFlags = 0; \
((RslObject*)(o))->parent = NULL; \
2016-01-09 22:01:21 +01:00
}
2016-01-10 18:18:03 +01:00
#define rslObjectGetParent(object) (((RslObject*)(object))->parent)
#define rslObjectSetParent(c,p) (((RslObject*)(c))->parent) = (void*)(p)
2016-01-09 22:01:21 +01:00
2015-12-22 12:11:10 +01:00
struct RslObjectHasFrame {
RslObject object;
RslLLLink lFrame;
void (*sync)();
};
2016-01-09 22:01:21 +01:00
void rslObjectHasFrameSetFrame(RslObjectHasFrame *object, RslFrame *f);
2015-12-22 12:11:10 +01:00
struct RslRasterPS2 {
uint8 *data;
uint32 flags;
};
struct RslRasterPSP {
uint32 unk1;
uint8 *data;
2015-12-27 18:45:37 +01:00
uint16 flags1;
uint8 width; // log of width
uint8 height; // log of height
uint32 flags2;
};
struct RslPs2StreamRaster {
uint32 width;
uint32 height;
uint32 depth;
uint32 mipmaps;
uint32 unused;
2015-12-22 12:11:10 +01:00
};
union RslRaster {
RslRasterPS2 ps2;
RslRasterPSP psp;
};
2016-01-09 22:01:21 +01:00
RslRaster *RslCreateRasterPS2(uint32 w, uint32 h, uint32 d, uint32 mipmaps);
2015-12-22 12:11:10 +01:00
struct RslTexDictionary {
RslObject object;
RslLinkList texturesInDict;
RslLLLink lInInstance;
};
2015-12-27 18:45:37 +01:00
RslTexDictionary *RslTexDictionaryStreamRead(Stream *stream);
RslTexDictionary *RslTexDictionaryCreate(void);
RslTexture *RslTexDictionaryAddTexture(RslTexDictionary *dict, RslTexture *tex);
2016-01-09 22:01:21 +01:00
RslTexDictionary *RslTexDictionaryForAllTextures(RslTexDictionary *dict, RslTextureCallBack fpCallBack, void *pData);
2015-12-27 18:45:37 +01:00
2015-12-22 12:11:10 +01:00
struct RslTexture {
RslRaster *raster;
RslTexDictionary *dict;
RslLLLink lInDictionary;
char name[32];
char mask[32];
};
2015-12-27 18:45:37 +01:00
RslTexture *RslTextureCreate(RslRaster *raster);
2016-01-09 22:01:21 +01:00
void RslTextureDestroy(RslTexture *texture);
RslTexture *RslTextureStreamRead(Stream *stream);
RslTexture *RslReadNativeTexturePS2(Stream *stream);
2015-12-27 18:45:37 +01:00
2015-12-21 21:56:47 +01:00
struct RslFrame {
2016-01-09 22:01:21 +01:00
RslObject object;
RslLinkList objectList;
2015-12-21 21:56:47 +01:00
2016-01-09 22:01:21 +01:00
RslMatrix modelling;
RslMatrix ltm;
2015-12-21 21:56:47 +01:00
RslFrame *child;
RslFrame *next;
RslFrame *root;
// RwHAnimFrameExtension
int32 nodeId;
RslHAnimHierarchy *hier;
// R* Node name
char *name;
// R* Visibility
int32 hierId;
2015-12-22 12:11:10 +01:00
};
2015-12-21 20:11:55 +01:00
2016-01-09 22:01:21 +01:00
RslFrame *RslFrameCreate(void);
RslFrame *RslFrameAddChild(RslFrame *parent, RslFrame *child);
2016-01-10 18:18:03 +01:00
int32 RslFrameCount(RslFrame *f);
2016-01-09 22:01:21 +01:00
RslFrame *RslFrameForAllChildren(RslFrame *frame, RslFrameCallBack callBack, void *data);
struct rslFrameList
{
RslFrame **frames;
int32 numFrames;
};
2016-01-10 18:18:03 +01:00
void rslFrameListStreamRead(Stream *stream, rslFrameList *framelist);
void rslFrameListInitialize(rslFrameList *frameList, RslFrame *root);
2015-12-21 20:11:55 +01:00
struct RslClump {
RslObject object;
RslLinkList atomicList;
};
2015-12-22 12:11:10 +01:00
#define RslClumpGetFrame(_clump) \
2016-01-10 18:18:03 +01:00
((RslFrame*)rslObjectGetParent(_clump))
#define RslClumpSetFrame(_clump, _frame) \
(rslObjectSetParent(_clump, _frame), \
(_clump))
2015-12-21 21:56:47 +01:00
2016-01-10 18:18:03 +01:00
RslClump *RslClumpCreate(void);
2016-01-09 22:01:21 +01:00
RslClump *RslClumpStreamRead(Stream *stream);
RslClump *RslClumpAddAtomic(RslClump *clump, RslAtomic *a);
2016-01-10 18:18:03 +01:00
int32 RslClumpGetNumAtomics(RslClump *clump);
2016-01-09 22:01:21 +01:00
RslClump *RslClumpForAllAtomics(RslClump *clump, RslAtomicCallBack callback, void *pData);
2015-12-21 20:11:55 +01:00
struct RslAtomic {
RslObjectHasFrame object;
RslGeometry *geometry;
RslClump *clump;
RslLLLink inClumpLink;
2015-12-21 21:56:47 +01:00
// what's this? rpWorldObj?
2015-12-21 20:11:55 +01:00
uint32 unk1;
uint16 unk2;
uint16 unk3;
2015-12-21 21:56:47 +01:00
// RpSkin
2015-12-21 20:11:55 +01:00
RslHAnimHierarchy *hier;
2015-12-21 21:56:47 +01:00
// what about visibility? matfx?
2015-12-21 20:11:55 +01:00
int32 pad; // 0xAAAAAAAA
};
2015-12-22 12:11:10 +01:00
#define RslAtomicGetFrame(_atomic) \
2016-01-10 18:18:03 +01:00
((RslFrame*)rslObjectGetParent(_atomic))
2015-12-21 20:11:55 +01:00
2016-01-09 22:01:21 +01:00
RslAtomic *RslAtomicCreate(void);
RslAtomic *RslAtomicSetFrame(RslAtomic *atomic, RslFrame *frame);
RslAtomic *RslAtomicStreamRead(Stream *stream, rslFrameList *framelist);
2015-12-21 20:11:55 +01:00
struct RslMaterialList {
RslMaterial **materials;
int32 numMaterials;
int32 space;
};
2016-01-10 20:10:53 +01:00
void rslMaterialListStreamRead(Stream *stream, RslMaterialList *matlist);
2015-12-21 20:11:55 +01:00
struct RslGeometry {
RslObject object;
2015-12-22 12:11:10 +01:00
int16 refCount;
int16 pad1;
2015-12-21 20:11:55 +01:00
RslMaterialList matList;
RslSkin *skin;
2015-12-22 12:11:10 +01:00
uint32 pad2; // 0xAAAAAAAA
2015-12-21 20:11:55 +01:00
};
2016-01-09 22:01:21 +01:00
RslGeometry *RslGeometryCreatePS2(uint32 sz);
RslGeometry *RslGeometryForAllMaterials(RslGeometry *geometry, RslMaterialCallBack fpCallBack, void *pData);
2015-12-21 20:11:55 +01:00
struct RslMatFXEnv {
RslFrame *frame;
2016-01-09 22:01:21 +01:00
union {
char *texname;
RslTexture *texture;
};
2015-12-21 20:11:55 +01:00
float32 intensity;
};
struct RslMatFX {
union {
RslMatFXEnv env;
};
int32 effectType;
};
struct RslMaterial {
2016-01-09 22:01:21 +01:00
union {
char *texname;
RslTexture *texture;
};
2016-01-13 08:58:15 +01:00
RGBA color;
2015-12-22 12:11:10 +01:00
uint32 refCount;
2015-12-21 20:11:55 +01:00
RslMatFX *matfx;
};
2016-01-09 22:01:21 +01:00
RslMaterial *RslMaterialCreate(void);
RslMaterial *RslMaterialStreamRead(Stream *stream);
2015-12-21 20:11:55 +01:00
struct RslHAnimNodeInfo {
int8 id;
int8 index;
int8 flags;
RslFrame *frame;
};
2015-12-22 12:11:10 +01:00
struct RslHAnimHierarchy {
int32 flags;
int32 numNodes;
void *pCurrentAnim;
float32 currentTime;
void *pNextFrame;
void (*pAnimCallBack)();
void *pAnimCallBackData;
float32 animCallBackTime;
void (*pAnimLoopCallBack)();
void *pAnimLoopCallBackData;
float32 *pMatrixArray;
void *pMatrixArrayUnaligned;
RslHAnimNodeInfo *pNodeInfo;
RslFrame *parentFrame;
int32 maxKeyFrameSize;
int32 currentKeyFrameSize;
void (*keyFrameToMatrixCB)();
void (*keyFrameBlendCB)();
void (*keyFrameInterpolateCB)();
void (*keyFrameAddCB)();
RslHAnimHierarchy *parentHierarchy;
int32 offsetInParent;
int32 rootParentOffset;
};
2015-12-21 20:11:55 +01:00
struct RslSkin {
uint32 numBones;
uint32 numUsedBones; // == numBones
uint8 *usedBones; // NULL
float32 *invMatrices;
int32 numWeights; // 0
uint8 *indices; // NULL
float32 *weights; // NULL
uint32 unk1; // 0
uint32 unk2; // 0
uint32 unk3; // 0
uint32 unk4; // 0
uint32 unk5; // 0
void *data; // NULL
};
2016-01-09 22:01:21 +01:00
RslSkin *RslSkinStreamRead(Stream *stream, RslGeometry *g);
2015-12-21 20:11:55 +01:00
struct RslPS2ResEntryHeader {
2015-12-22 12:11:10 +01:00
float32 bound[4];
uint32 size; // and numMeshes
int32 flags;
uint32 unk1;
uint32 unk2;
uint32 unk3;
uint32 unk4;
float32 scale[3];
2015-12-21 20:11:55 +01:00
float32 pos[3];
};
struct RslPS2InstanceData {
2016-01-09 22:01:21 +01:00
float32 bound[4];
2015-12-22 12:11:10 +01:00
float32 uvScale[2];
2016-01-09 22:01:21 +01:00
int32 unknown;
2015-12-23 23:23:46 +01:00
uint32 dmaPacket;
2015-12-22 12:11:10 +01:00
uint16 numTriangles;
int16 matID;
2015-12-23 23:23:46 +01:00
int16 min[3]; // bounding box
int16 max[3];
};
struct RslStreamHeader {
uint32 ident;
uint32 unk;
uint32 fileEnd; //
uint32 dataEnd; // relative to beginning of header
uint32 reloc; //
uint32 relocSize;
uint32 root; // absolute
uint16 zero;
uint16 numAtomics;
};
struct RslWorldGeometry {
uint16 numMeshes;
uint16 size;
// array of numMeshes RslWorldMesh
// dma data
2015-12-21 20:11:55 +01:00
};
2015-12-23 23:23:46 +01:00
struct RslWorldMesh {
uint16 texID; // index into resource table
uint16 dmaSize;
uint16 uvScale[2]; // half precision float
uint16 unk1;
int16 min[3]; // bounding box
int16 max[3];
};
struct Resource {
union {
RslRaster *raster;
RslWorldGeometry *geometry;
uint8 *raw;
};
uint32 *dma;
};
struct OverlayResource {
int32 id;
union {
RslRaster *raster;
RslWorldGeometry *geometry;
uint8 *raw;
};
};
struct Placement {
uint16 id;
uint16 resId;
int16 bound[4];
int32 pad;
float matrix[16];
};
struct Sector {
OverlayResource *resources;
uint16 numResources;
uint16 unk1;
Placement *sectionA;
Placement *sectionB;
Placement *sectionC;
Placement *sectionD;
Placement *sectionE;
Placement *sectionF;
Placement *sectionG;
Placement *sectionEnd;
uint16 unk2;
uint16 unk3;
uint32 unk4;
};
struct SectorEntry {
RslStreamHeader *sector;
uint32 num;
};
struct World {
Resource *resources;
SectorEntry sectors[47];
uint32 numResources;
uint8 pad[0x180];
uint32 numX;
void *tabX; // size 0x4
uint32 numY;
void *tabY; // size 0x30
uint32 numZ;
void *tabZ; // size 0x6
uint32 numTextures;
RslStreamHeader *textures; // stream headers
2016-01-10 20:10:53 +01:00
};