2015-01-25 22:27:03 +01:00
|
|
|
namespace rw {
|
|
|
|
namespace ps2 {
|
2014-12-20 15:05:34 +01:00
|
|
|
|
2014-12-30 17:39:39 +01:00
|
|
|
struct InstanceData
|
2014-12-20 15:05:34 +01:00
|
|
|
{
|
2014-12-30 19:30:13 +01:00
|
|
|
// 0 - addresses in ref tags need fixing
|
|
|
|
// 1 - no ref tags, so no fixing
|
|
|
|
// set by the program:
|
|
|
|
// 2 - ref tags are fixed, need to unfix before stream write
|
|
|
|
uint32 arePointersFixed;
|
2014-12-20 15:05:34 +01:00
|
|
|
uint32 dataSize;
|
|
|
|
uint8 *data;
|
|
|
|
Material *material;
|
2014-12-20 18:13:45 +01:00
|
|
|
};
|
2014-12-20 15:05:34 +01:00
|
|
|
|
2015-01-25 22:27:03 +01:00
|
|
|
struct InstanceDataHeader : rw::InstanceDataHeader
|
2014-12-20 15:05:34 +01:00
|
|
|
{
|
|
|
|
uint32 numMeshes;
|
2014-12-30 17:39:39 +01:00
|
|
|
InstanceData *instanceMeshes;
|
2014-12-20 15:05:34 +01:00
|
|
|
};
|
|
|
|
|
2015-07-11 23:48:11 +02:00
|
|
|
enum {
|
|
|
|
VU_Lights = 0x3d0
|
|
|
|
};
|
|
|
|
|
2015-12-16 20:25:22 +01:00
|
|
|
enum PS2Attribs {
|
|
|
|
AT_V2_32 = 0x64000000,
|
|
|
|
AT_V2_16 = 0x65000000,
|
|
|
|
AT_V2_8 = 0x66000000,
|
|
|
|
AT_V3_32 = 0x68000000,
|
|
|
|
AT_V3_16 = 0x69000000,
|
|
|
|
AT_V3_8 = 0x6A000000,
|
|
|
|
AT_V4_32 = 0x6C000000,
|
|
|
|
AT_V4_16 = 0x6D000000,
|
|
|
|
AT_V4_8 = 0x6E000000,
|
|
|
|
AT_UNSGN = 0x00004000,
|
|
|
|
|
|
|
|
AT_RW = 0x6
|
|
|
|
};
|
|
|
|
|
|
|
|
enum PS2AttibTypes {
|
|
|
|
AT_XYZ = 0,
|
|
|
|
AT_UV = 1,
|
|
|
|
AT_RGBA = 2,
|
|
|
|
AT_NORMAL = 3
|
|
|
|
};
|
|
|
|
|
2015-01-25 22:27:03 +01:00
|
|
|
void *destroyNativeData(void *object, int32, int32);
|
|
|
|
void readNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
|
|
|
void writeNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
|
|
|
int32 getSizeNativeData(void *object, int32, int32);
|
|
|
|
void registerNativeDataPlugin(void);
|
2015-01-06 23:17:05 +01:00
|
|
|
|
2015-07-12 22:57:05 +02:00
|
|
|
void printDMA(InstanceData *inst);
|
2015-01-06 23:17:05 +01:00
|
|
|
void sizedebug(InstanceData *inst);
|
2014-12-20 18:13:45 +01:00
|
|
|
|
2014-12-30 19:30:13 +01:00
|
|
|
// only RW_PS2
|
|
|
|
void fixDmaOffsets(InstanceData *inst);
|
|
|
|
void unfixDmaOffsets(InstanceData *inst);
|
2015-07-11 23:48:11 +02:00
|
|
|
//
|
|
|
|
|
2016-02-14 00:52:45 +01:00
|
|
|
struct PipeAttribute
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
uint32 attrib;
|
|
|
|
};
|
|
|
|
|
2015-08-01 23:03:10 +02:00
|
|
|
class MatPipeline : public rw::Pipeline
|
2015-07-11 23:48:11 +02:00
|
|
|
{
|
2015-08-01 23:03:10 +02:00
|
|
|
public:
|
2015-07-11 23:48:11 +02:00
|
|
|
uint32 vifOffset;
|
|
|
|
uint32 inputStride;
|
|
|
|
uint32 triStripCount, triListCount;
|
2015-08-01 23:03:10 +02:00
|
|
|
PipeAttribute *attribs[10];
|
2015-12-24 16:43:10 +01:00
|
|
|
void (*instanceCB)(MatPipeline*, Geometry*, Mesh*, uint8**);
|
2015-12-14 18:52:50 +01:00
|
|
|
void (*uninstanceCB)(MatPipeline*, Geometry*, uint32*, Mesh*, uint8**);
|
2015-12-16 20:25:22 +01:00
|
|
|
void (*preUninstCB)(MatPipeline*, Geometry*);
|
|
|
|
void (*postUninstCB)(MatPipeline*, Geometry*);
|
2016-02-14 00:52:45 +01:00
|
|
|
// RW has more:
|
|
|
|
// instanceTestCB()
|
|
|
|
// resEntryAllocCB()
|
|
|
|
// bridgeCB()
|
|
|
|
// postMeshCB()
|
|
|
|
// vu1code
|
|
|
|
// primtype
|
2015-07-11 23:48:11 +02:00
|
|
|
|
|
|
|
static uint32 getVertCount(uint32 top, uint32 inAttribs,
|
|
|
|
uint32 outAttribs, uint32 outBufs) {
|
|
|
|
return (top-outBufs)/(inAttribs*2+outAttribs*outBufs);
|
|
|
|
}
|
|
|
|
|
2015-08-01 23:03:10 +02:00
|
|
|
MatPipeline(uint32 platform);
|
2016-02-14 00:52:45 +01:00
|
|
|
void dump(void);
|
2015-08-01 23:03:10 +02:00
|
|
|
void setTriBufferSizes(uint32 inputStride, uint32 stripCount);
|
2015-08-02 19:31:01 +02:00
|
|
|
void instance(Geometry *g, InstanceData *inst, Mesh *m);
|
2015-12-14 18:52:50 +01:00
|
|
|
uint8 *collectData(Geometry *g, InstanceData *inst, Mesh *m, uint8 *data[]);
|
2015-08-01 23:03:10 +02:00
|
|
|
};
|
|
|
|
|
2015-08-02 19:31:01 +02:00
|
|
|
class ObjPipeline : public rw::ObjPipeline
|
2015-08-01 23:03:10 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MatPipeline *groupPipeline;
|
2016-02-14 00:52:45 +01:00
|
|
|
// RW has more:
|
|
|
|
// setupCB()
|
|
|
|
// finalizeCB()
|
|
|
|
// lightOffset
|
|
|
|
// lightSize
|
2015-08-01 23:03:10 +02:00
|
|
|
|
|
|
|
ObjPipeline(uint32 platform);
|
2015-07-11 23:48:11 +02:00
|
|
|
};
|
|
|
|
|
2015-12-24 16:43:10 +01:00
|
|
|
struct Vertex {
|
|
|
|
float32 p[3];
|
|
|
|
float32 t[2];
|
2016-02-06 18:11:31 +01:00
|
|
|
float32 t1[2];
|
2015-12-24 16:43:10 +01:00
|
|
|
uint8 c[4];
|
|
|
|
float32 n[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
void insertVertex(Geometry *geo, int32 i, uint32 mask, Vertex *v);
|
2015-12-16 20:25:22 +01:00
|
|
|
|
2015-08-01 23:03:10 +02:00
|
|
|
extern ObjPipeline *defaultObjPipe;
|
|
|
|
extern MatPipeline *defaultMatPipe;
|
|
|
|
|
|
|
|
ObjPipeline *makeDefaultPipeline(void);
|
|
|
|
ObjPipeline *makeSkinPipeline(void);
|
|
|
|
ObjPipeline *makeMatFXPipeline(void);
|
2015-07-11 23:48:11 +02:00
|
|
|
void dumpPipeline(rw::Pipeline *pipe);
|
2014-12-30 19:30:13 +01:00
|
|
|
|
2015-01-07 23:06:44 +01:00
|
|
|
// Skin plugin
|
|
|
|
|
2015-12-24 16:43:10 +01:00
|
|
|
struct SkinVertex : Vertex {
|
|
|
|
float32 w[4];
|
|
|
|
uint8 i[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
void insertVertexSkin(Geometry *geo, int32 i, uint32 mask, SkinVertex *v);
|
|
|
|
int32 findVertexSkin(Geometry *g, uint32 flags[], uint32 mask, SkinVertex *v);
|
|
|
|
|
2015-01-25 22:27:03 +01:00
|
|
|
void readNativeSkin(Stream *stream, int32, void *object, int32 offset);
|
|
|
|
void writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset);
|
|
|
|
int32 getSizeNativeSkin(void *object, int32 offset);
|
2015-01-07 23:06:44 +01:00
|
|
|
|
2015-12-24 16:43:10 +01:00
|
|
|
void instanceSkinData(Geometry *g, Mesh *m, Skin *skin, uint32 *data);
|
|
|
|
|
2015-12-16 20:25:22 +01:00
|
|
|
void skinPreCB(MatPipeline*, Geometry*);
|
|
|
|
void skinPostCB(MatPipeline*, Geometry*);
|
|
|
|
|
2015-01-06 23:17:05 +01:00
|
|
|
// ADC plugin
|
|
|
|
|
2015-08-16 16:44:59 +02:00
|
|
|
// Each element in adcBits corresponds to an index in Mesh->indices,
|
|
|
|
// this assumes the Mesh indices are ADC formatted.
|
2015-08-16 23:23:41 +02:00
|
|
|
// ADCData->numBits != Mesh->numIndices. ADCData->numBits is probably
|
|
|
|
// equal to Mesh->numIndices before the Mesh gets ADC formatted.
|
|
|
|
//
|
|
|
|
// Can't convert between ADC-formatted and non-ADC-formatted yet :(
|
2015-01-06 23:17:05 +01:00
|
|
|
|
|
|
|
struct ADCData
|
|
|
|
{
|
2015-08-16 16:44:59 +02:00
|
|
|
bool32 adcFormatted;
|
|
|
|
int8 *adcBits;
|
|
|
|
int32 numBits;
|
2015-01-06 23:17:05 +01:00
|
|
|
};
|
2015-12-16 20:25:22 +01:00
|
|
|
extern int32 adcOffset;
|
2015-01-25 22:27:03 +01:00
|
|
|
void registerADCPlugin(void);
|
2015-01-06 23:17:05 +01:00
|
|
|
|
2015-12-24 23:31:36 +01:00
|
|
|
void convertADC(Geometry *g);
|
2015-12-20 13:05:32 +01:00
|
|
|
void unconvertADC(Geometry *geo);
|
2015-12-16 20:25:22 +01:00
|
|
|
void allocateADC(Geometry *geo);
|
|
|
|
|
2015-08-01 23:03:10 +02:00
|
|
|
// PDS plugin
|
|
|
|
|
2015-12-16 20:25:22 +01:00
|
|
|
Pipeline *getPDSPipe(uint32 data);
|
|
|
|
void registerPDSPipe(Pipeline *pipe);
|
|
|
|
void registerPDSPlugin(int32 n);
|
2016-02-06 18:11:31 +01:00
|
|
|
void registerPluginPDSPipes(void);
|
2015-08-01 23:03:10 +02:00
|
|
|
|
2015-09-19 19:28:23 +02:00
|
|
|
// Native Texture and Raster
|
|
|
|
|
|
|
|
struct Ps2Raster : NativeRaster
|
|
|
|
{
|
2016-01-24 01:42:51 +01:00
|
|
|
uint32 tex0[2];
|
|
|
|
uint32 tex1[2];
|
|
|
|
uint32 miptbp1[2];
|
|
|
|
uint32 miptbp2[2];
|
|
|
|
uint32 texelSize;
|
|
|
|
uint32 paletteSize;
|
|
|
|
uint32 gsSize;
|
2016-01-03 19:45:51 +01:00
|
|
|
int8 flags;
|
|
|
|
|
|
|
|
uint8 *data; //tmp
|
|
|
|
uint32 dataSize;
|
|
|
|
|
|
|
|
virtual void create(Raster *raster);
|
|
|
|
virtual uint8 *lock(Raster *raster, int32 level);
|
|
|
|
virtual void unlock(Raster *raster, int32 level);
|
|
|
|
virtual int32 getNumLevels(Raster *raster);
|
2015-09-19 19:28:23 +02:00
|
|
|
};
|
2015-09-11 12:32:06 +02:00
|
|
|
|
|
|
|
extern int32 nativeRasterOffset;
|
|
|
|
void registerNativeRaster(void);
|
|
|
|
|
2016-01-03 19:45:51 +01:00
|
|
|
Texture *readNativeTexture(Stream *stream);
|
|
|
|
void writeNativeTexture(Texture *tex, Stream *stream);
|
|
|
|
uint32 getSizeNativeTexture(Texture *tex);
|
|
|
|
|
2014-12-20 15:05:34 +01:00
|
|
|
}
|
2014-12-30 17:39:39 +01:00
|
|
|
}
|