made most things build on linux again

This commit is contained in:
aap 2016-01-10 20:10:53 +01:00
parent 79c89ebbba
commit 0aadf8c3c9
19 changed files with 148 additions and 179 deletions

View File

@ -5,10 +5,8 @@ BUILD=null
BUILDDEF:=$(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/') BUILDDEF:=$(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/')
BUILDDIR=build-$(BUILD) BUILDDIR=build-$(BUILD)
SRCDIR=src SRCDIR=src
SRC := $(patsubst %.cpp,$(SRCDIR)/%.cpp, rwbase.cpp clump.cpp\ #SRC := $(patsubst %.cpp,$(SRCDIR)/%.cpp, $(wildcard *.cpp))
geometry.cpp plugins.cpp pipeline.cpp\ SRC := $(wildcard $(SRCDIR)/*.cpp)
ps2.cpp ogl.cpp xbox.cpp\
image.cpp gtaplg.cpp)
OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC)) OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC))
DEP := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.d,$(SRC)) DEP := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.d,$(SRC))
INC := -I/usr/local/include INC := -I/usr/local/include
@ -27,6 +25,7 @@ $(BUILDDIR)/%.d: $(SRCDIR)/%.cpp
$(CXX) -MM -MT '$(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$<)' $(CFLAGS) $(INC) $< > $@ $(CXX) -MM -MT '$(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$<)' $(CFLAGS) $(INC) $< > $@
clean: clean:
echo $(SRC)
rm -f $(BUILDDIR)/*.[od] rm -f $(BUILDDIR)/*.[od]
-include $(DEP) -include $(DEP)

4
args.h
View File

@ -15,9 +15,9 @@ extern char *argv0;
while(*_args && (_argc = *_args++))\ while(*_args && (_argc = *_args++))\
switch(_argc) switch(_argc)
#define ARGEND SET(_argt);USED(_argt);USED(_argc);USED(_args);}USED(argv);USED(argc); #define ARGEND SET(_argt);USED(_argt);USED(_argc);USED(_args);}USED(argv);USED(argc);
#define ARGF() (_argt=_args, _args="",\ #define ARGF() (_argt=_args, _args=(char*)"",\
(*_argt? _argt: argv[1]? (argc--, *++argv): 0)) (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
#define EARGF(x) (_argt=_args, _args="",\ #define EARGF(x) (_argt=_args, _args=(char*)"",\
(*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0))) (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
#define ARGC() _argc #define ARGC() _argc

View File

@ -263,6 +263,7 @@ destroyUVAnim(void *object, int32 offset, int32)
UVAnim *uvanim; UVAnim *uvanim;
uvanim = PLUGINOFFSET(UVAnim, object, offset); uvanim = PLUGINOFFSET(UVAnim, object, offset);
// TODO: ref counts &c. // TODO: ref counts &c.
(void)uvanim;
return object; return object;
} }

View File

@ -205,6 +205,9 @@ lockIndices(void *indexBuffer, uint32 offset, uint32 size, uint32 flags)
ibuf->Lock(offset, size, (void**)&indices, flags); ibuf->Lock(offset, size, (void**)&indices, flags);
return indices; return indices;
#else #else
(void)offset;
(void)size;
(void)flags;
return (uint16*)indexBuffer; return (uint16*)indexBuffer;
#endif #endif
} }
@ -228,6 +231,8 @@ createVertexBuffer(uint32 length, uint32 fvf, int32 pool)
device->CreateVertexBuffer(length, D3DUSAGE_WRITEONLY, fvf, (D3DPOOL)pool, &vbuf, 0); device->CreateVertexBuffer(length, D3DUSAGE_WRITEONLY, fvf, (D3DPOOL)pool, &vbuf, 0);
return vbuf; return vbuf;
#else #else
(void)fvf;
(void)pool;
return new uint8[length]; return new uint8[length];
#endif #endif
} }
@ -243,6 +248,9 @@ lockVertices(void *vertexBuffer, uint32 offset, uint32 size, uint32 flags)
vertbuf->Lock(offset, size, (void**)&verts, flags); vertbuf->Lock(offset, size, (void**)&verts, flags);
return verts; return verts;
#else #else
(void)offset;
(void)size;
(void)flags;
return (uint8*)vertexBuffer; return (uint8*)vertexBuffer;
#endif #endif
} }
@ -316,6 +324,8 @@ lockTexture(void *texture, int32 level)
void void
unlockTexture(void *texture, int32 level) unlockTexture(void *texture, int32 level)
{ {
(void)texture;
(void)level;
#ifdef RW_D3D9 #ifdef RW_D3D9
IDirect3DTexture9 *tex = (IDirect3DTexture9*)texture; IDirect3DTexture9 *tex = (IDirect3DTexture9*)texture;
tex->UnlockRect(level); tex->UnlockRect(level);
@ -383,19 +393,19 @@ D3dRaster::create(Raster *raster)
} }
uint8* uint8*
D3dRaster::lock(Raster *raster, int32 level) D3dRaster::lock(Raster*, int32 level)
{ {
return lockTexture(this->texture, level); return lockTexture(this->texture, level);
} }
void void
D3dRaster::unlock(Raster *raster, int32 level) D3dRaster::unlock(Raster*, int32 level)
{ {
unlockTexture(this->texture, level); unlockTexture(this->texture, level);
} }
int32 int32
D3dRaster::getNumLevels(Raster *raster) D3dRaster::getNumLevels(Raster*)
{ {
#ifdef RW_D3D9 #ifdef RW_D3D9
IDirect3DTexture9 *tex = (IDirect3DTexture9*)this->texture; IDirect3DTexture9 *tex = (IDirect3DTexture9*)this->texture;
@ -450,7 +460,6 @@ setPalette(Raster *raster, void *palette, int32 size)
void void
setTexels(Raster *raster, void *texels, int32 level) setTexels(Raster *raster, void *texels, int32 level)
{ {
D3dRaster *ras = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset);
uint8 *dst = raster->lock(level); uint8 *dst = raster->lock(level);
memcpy(dst, texels, getLevelSize(raster, level)); memcpy(dst, texels, getLevelSize(raster, level));
raster->unlock(level); raster->unlock(level);
@ -472,6 +481,7 @@ static void*
destroyNativeRaster(void *object, int32 offset, int32) destroyNativeRaster(void *object, int32 offset, int32)
{ {
// TODO: // TODO:
(void)offset;
return object; return object;
} }

View File

@ -435,7 +435,6 @@ void
defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header) defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header)
{ {
VertexElement dcl[NUMDECLELT]; VertexElement dcl[NUMDECLELT];
uint32 numElt = getDeclaration(header->vertexDeclaration, dcl);
uint8 *verts[2]; uint8 *verts[2];
verts[0] = lockVertices(header->vertexStream[0].vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK); verts[0] = lockVertices(header->vertexStream[0].vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK);

View File

@ -1154,10 +1154,10 @@ instanceSADualColors(Geometry *g, Mesh *m, uint8 *dst)
for(uint32 i = 0; i < m->numIndices; i++){ for(uint32 i = 0; i < m->numIndices; i++){
j = m->indices[i]; j = m->indices[i];
if(c0){ if(c0){
dst[0] = c0[i*4+0]; dst[0] = c0[j*4+0];
dst[2] = c0[i*4+1]; dst[2] = c0[j*4+1];
dst[4] = c0[i*4+2]; dst[4] = c0[j*4+2];
dst[6] = c0[i*4+3]; dst[6] = c0[j*4+3];
}else{ }else{
dst[0] = 0xFF; dst[0] = 0xFF;
dst[2] = 0xFF; dst[2] = 0xFF;
@ -1165,10 +1165,10 @@ instanceSADualColors(Geometry *g, Mesh *m, uint8 *dst)
dst[6] = 0xFF; dst[6] = 0xFF;
} }
if(c1){ if(c1){
dst[1] = c1[i*4+0]; dst[1] = c1[j*4+0];
dst[3] = c1[i*4+1]; dst[3] = c1[j*4+1];
dst[6] = c1[i*4+2]; dst[6] = c1[j*4+2];
dst[7] = c1[i*4+3]; dst[7] = c1[j*4+3];
}else{ }else{
dst[1] = 0xFF; dst[1] = 0xFF;
dst[3] = 0xFF; dst[3] = 0xFF;
@ -1207,7 +1207,7 @@ saInstanceCB(MatPipeline *pipe, Geometry *g, Mesh *m, uint8 **data)
vertScale = 1024.0f; vertScale = 1024.0f;
ADCData *adc = PLUGINOFFSET(ADCData, g, adcOffset); ADCData *adc = PLUGINOFFSET(ADCData, g, adcOffset);
for(int i = 0; i < nelem(pipe->attribs); i++){ for(uint32 i = 0; i < nelem(pipe->attribs); i++){
rw::PipeAttribute *a = pipe->attribs[i]; rw::PipeAttribute *a = pipe->attribs[i];
if(a == &saXYZADC) if(a == &saXYZADC)
instanceSAPositions(g, m, adc->adcFormatted ? adc->adcBits : NULL, instanceSAPositions(g, m, adc->adcFormatted ? adc->adcBits : NULL,

View File

@ -14,6 +14,11 @@
#include "rwxbox.h" #include "rwxbox.h"
#include "rwd3d8.h" #include "rwd3d8.h"
#ifdef _WIN32
/* srsly? */
#define strdup _strdup
#endif
using namespace std; using namespace std;
namespace rw { namespace rw {
@ -113,7 +118,7 @@ void
Texture::decRef(void) Texture::decRef(void)
{ {
this->refCount--; this->refCount--;
if(this->refCount == NULL) if(this->refCount == 0)
delete this; delete this;
} }
@ -323,7 +328,7 @@ Image::setSearchPath(const char *path)
::free(searchPaths); ::free(searchPaths);
numSearchPaths = 0; numSearchPaths = 0;
if(path) if(path)
searchPaths = p = _strdup(path); searchPaths = p = strdup(path);
else{ else{
searchPaths = NULL; searchPaths = NULL;
return; return;
@ -358,7 +363,7 @@ Image::getFilename(const char *name)
if(f){ if(f){
fclose(f); fclose(f);
printf("found %s\n", name); printf("found %s\n", name);
return _strdup(name); return strdup(name);
} }
return NULL; return NULL;
}else }else

View File

@ -155,10 +155,6 @@ instColor(int type, uint8 *dst, uint8 *src, uint32 numVertices, uint32 stride)
assert(type == VERT_ARGB); assert(type == VERT_ARGB);
bool32 hasAlpha = 0; bool32 hasAlpha = 0;
for(uint32 i = 0; i < numVertices; i++){ for(uint32 i = 0; i < numVertices; i++){
// uint32 col = COLOR_ARGB(src[3], src[0], src[1], src[2]);
// if(src[3] < 0xFF)
// hasAlpha = 1;
// memcpy(dst, &col, 4);
dst[0] = src[2]; dst[0] = src[2];
dst[1] = src[1]; dst[1] = src[1];
dst[2] = src[0]; dst[2] = src[0];
@ -173,7 +169,6 @@ void
uninstColor(int type, uint8 *dst, uint8 *src, uint32 numVertices, uint32 stride) uninstColor(int type, uint8 *dst, uint8 *src, uint32 numVertices, uint32 stride)
{ {
assert(type == VERT_ARGB); assert(type == VERT_ARGB);
bool32 hasAlpha = 0;
for(uint32 i = 0; i < numVertices; i++){ for(uint32 i = 0; i < numVertices; i++){
dst[0] = src[2]; dst[0] = src[2];
dst[1] = src[1]; dst[1] = src[1];

View File

@ -761,7 +761,7 @@ insertVertex(Geometry *geo, int32 i, uint32 mask, Vertex *v)
} }
void void
defaultUninstanceCB(MatPipeline *pipe, Geometry *geo, uint32 flags[], Mesh *mesh, uint8 *data[]) defaultUninstanceCB(MatPipeline*, Geometry *geo, uint32 flags[], Mesh *mesh, uint8 *data[])
{ {
float32 *verts = (float32*)data[AT_XYZ]; float32 *verts = (float32*)data[AT_XYZ];
float32 *texcoords = (float32*)data[AT_UV]; float32 *texcoords = (float32*)data[AT_UV];
@ -775,15 +775,14 @@ defaultUninstanceCB(MatPipeline *pipe, Geometry *geo, uint32 flags[], Mesh *mesh
if(geo->numTexCoordSets > 0) if(geo->numTexCoordSets > 0)
mask |= 0x1000; mask |= 0x1000;
float32 n[3];
Vertex v; Vertex v;
for(uint32 i = 0; i < mesh->numIndices; i++){ for(uint32 i = 0; i < mesh->numIndices; i++){
if(mask & 0x1) if(mask & 0x1)
memcpy(&v.p, verts, 12); memcpy(&v.p, verts, 12);
if(mask & 0x10){ if(mask & 0x10){
n[0] = norms[0]/127.0f; v.n[0] = norms[0]/127.0f;
n[1] = norms[1]/127.0f; v.n[1] = norms[1]/127.0f;
n[2] = norms[2]/127.0f; v.n[2] = norms[2]/127.0f;
} }
if(mask & 0x100) if(mask & 0x100)
memcpy(&v.c, colors, 4); memcpy(&v.c, colors, 4);
@ -966,7 +965,7 @@ getSizeNativeSkin(void *object, int32 offset)
} }
void void
instanceSkinData(Geometry *g, Mesh *m, Skin *skin, uint32 *data) instanceSkinData(Geometry*, Mesh *m, Skin *skin, uint32 *data)
{ {
uint16 j; uint16 j;
float32 *weights = (float32*)data; float32 *weights = (float32*)data;
@ -1052,7 +1051,7 @@ insertVertexSkin(Geometry *geo, int32 i, uint32 mask, SkinVertex *v)
} }
static void static void
skinUninstanceCB(MatPipeline *pipe, Geometry *geo, uint32 flags[], Mesh *mesh, uint8 *data[]) skinUninstanceCB(MatPipeline*, Geometry *geo, uint32 flags[], Mesh *mesh, uint8 *data[])
{ {
float32 *verts = (float32*)data[AT_XYZ]; float32 *verts = (float32*)data[AT_XYZ];
float32 *texcoords = (float32*)data[AT_UV]; float32 *texcoords = (float32*)data[AT_UV];
@ -1127,91 +1126,9 @@ skinPostCB(MatPipeline*, Geometry *geo)
int32 adcOffset; int32 adcOffset;
// TODO: look at PC SA rccam.dff bloodrb.dff, Xbox csbigbear.dff
static void
rotateface(int f[])
{
int tmp;
while(f[0] > f[1] || f[0] > f[2]){
tmp = f[0];
f[0] = f[1];
f[1] = f[2];
f[2] = tmp;
}
/*
if(f[0] > f[1]){
tmp = f[0];
f[0] = f[1];
f[1] = tmp;
}
if(f[0] > f[2]){
tmp = f[0];
f[0] = f[2];
f[2] = tmp;
}
if(f[1] > f[2]){
tmp = f[1];
f[1] = f[2];
f[2] = tmp;
}
*/
}
static int
validFace(Geometry *g, uint16 *f, int j, int m)
{
int f1[3], f2[3];
f1[0] = f[j+0 + (j%2)];
f1[1] = f[j+1 - (j%2)];
f1[2] = f[j+2];
//printf("-> %d %d %d\n", f1[0], f1[1], f1[2]);
rotateface(f1);
uint16 *fs = g->triangles;
for(int i = 0; i < g->numTriangles; i++, fs += 4){
if(fs[2] != m)
continue;
f2[0] = fs[1];
f2[1] = fs[0];
f2[2] = fs[3];
//printf("<- %d %d %d\n", f2[0], f2[1], f2[2]);
rotateface(f2);
if(f1[0] == f2[0] &&
f1[1] == f2[1] &&
f1[2] == f2[2])
return 1;
}
return 0;
}
static int
isdegenerate(uint16 *f)
{
return f[0] == f[1] ||
f[0] == f[2] ||
f[1] == f[2];
}
static int
debugadc(Geometry *g, MeshHeader *mh, ADCData *adc)
{
int n = 0;
for(uint32 i = 0; i < mh->numMeshes; i++){
uint16 *idx = mh->mesh[i].indices;
for(uint32 j = 0; j < mh->mesh[i].numIndices-2; j++){
if(!validFace(g, idx, j, i) && !isdegenerate(idx+j)){
n++;
// printf("> %d %d %d %d\n", i, idx[j+0], idx[j+1], idx[j+2]);
}
}
}
return n;
}
// TODO // TODO
void void
convertADC(Geometry *g) convertADC(Geometry*)
{ {
} }
@ -1260,8 +1177,8 @@ unconvertADC(Geometry *g)
g->meshHeader = h; g->meshHeader = h;
adc->adcFormatted = 0; adc->adcFormatted = 0;
delete[] adc->adcBits; delete[] adc->adcBits;
adc->adcBits = 0; adc->adcBits = NULL;
adc->numBits = NULL; adc->numBits = 0;
} }
void void
@ -1322,22 +1239,6 @@ readADC(Stream *stream, int32, void *object, int32 offset, int32)
int32 size = adc->numBits+3 & ~3; int32 size = adc->numBits+3 & ~3;
adc->adcBits = new int8[size]; adc->adcBits = new int8[size];
stream->read(adc->adcBits, size); stream->read(adc->adcBits, size);
/*
Geometry *geometry = (Geometry*)object;
int ones = 0, zeroes = 0;
for(int i = 0; i < adc->numBits; i++)
if(adc->adcBits[i])
ones++;
else
zeroes++;
MeshHeader *meshHeader = geometry->meshHeader;
int n = debugadc(geometry, meshHeader, adc);
printf("%X %X | %X %X %X\n",
meshHeader->totalIndices,
meshHeader->totalIndices + n,
adc->numBits, zeroes, ones);
*/
} }
static void static void
@ -1673,7 +1574,7 @@ Ps2Raster::create(Raster *raster)
}else{ }else{
ras->flags |= 1; // include GIF packets ras->flags |= 1; // include GIF packets
int32 psm = ras->tex0[0]>>20 & 0x3F; int32 psm = ras->tex0[0]>>20 & 0x3F;
int32 cpsm = ras->tex0[1]>>19 & 0x3F; //int32 cpsm = ras->tex0[1]>>19 & 0x3F;
if(psm == 0x13){ // PSMT8 if(psm == 0x13){ // PSMT8
ras->flags |= 2; ras->flags |= 2;
// TODO: stuff // TODO: stuff
@ -1800,12 +1701,18 @@ Ps2Raster::create(Raster *raster)
uint8* uint8*
Ps2Raster::lock(Raster *raster, int32 level) Ps2Raster::lock(Raster *raster, int32 level)
{ {
// TODO
(void)raster;
(void)level;
return NULL; return NULL;
} }
void void
Ps2Raster::unlock(Raster *raster, int32 level) Ps2Raster::unlock(Raster *raster, int32 level)
{ {
// TODO
(void)raster;
(void)level;
} }
int32 int32
@ -1845,6 +1752,8 @@ createNativeRaster(void *object, int32 offset, int32)
static void* static void*
destroyNativeRaster(void *object, int32 offset, int32) destroyNativeRaster(void *object, int32 offset, int32)
{ {
// TODO
(void)offset;
return object; return object;
} }
@ -1858,27 +1767,27 @@ copyNativeRaster(void *dst, void *src, int32 offset, int32)
} }
static void static void
readMipmap(Stream *stream, int32 len, void *object, int32 offset, int32) readMipmap(Stream *stream, int32, void *object, int32 offset, int32)
{ {
uint16 val = stream->readI32(); uint16 val = stream->readI32();
Texture *tex = (Texture*)object; Texture *tex = (Texture*)object;
if(tex->raster == NULL) if(tex->raster == NULL)
return; return;
Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, nativeRasterOffset); Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, offset);
SETKL(raster, val); SETKL(raster, val);
} }
static void static void
writeMipmap(Stream *stream, int32 len, void *object, int32 offset, int32) writeMipmap(Stream *stream, int32, void *object, int32 offset, int32)
{ {
Texture *tex = (Texture*)object; Texture *tex = (Texture*)object;
assert(tex->raster); assert(tex->raster);
Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, nativeRasterOffset); Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, offset);
stream->writeI32(raster->tex1[1]&0xFFFF); stream->writeI32(raster->tex1[1]&0xFFFF);
} }
static int32 static int32
getSizeMipmap(void *object, int32 offset, int32) getSizeMipmap(void*, int32, int32)
{ {
return rw::platform == PLATFORM_PS2 ? 4 : 0; return rw::platform == PLATFORM_PS2 ? 4 : 0;
} }

View File

@ -155,10 +155,14 @@ struct Raster : PluginBase<Raster>
struct NativeRaster struct NativeRaster
{ {
virtual void create(Raster *raster) { assert(IGNORERASTERIMP && "unimplemented"); }; virtual void create(Raster*)
virtual uint8 *lock(Raster *raster, int32 level) { assert(IGNORERASTERIMP && "unimplemented"); return NULL; }; { assert(IGNORERASTERIMP && "unimplemented"); };
virtual void unlock(Raster *raster, int32 level) { assert(IGNORERASTERIMP && "unimplemented"); }; virtual uint8 *lock(Raster*, int32)
virtual int32 getNumLevels(Raster *raster) { assert(IGNORERASTERIMP && "unimplemented"); return 0; }; { assert(IGNORERASTERIMP && "unimplemented"); return NULL; };
virtual void unlock(Raster*, int32)
{ assert(IGNORERASTERIMP && "unimplemented"); };
virtual int32 getNumLevels(Raster*)
{ assert(IGNORERASTERIMP && "unimplemented"); return 0; };
}; };
// TODO: link into texdict // TODO: link into texdict

View File

@ -13,7 +13,7 @@ class Pipeline
public: public:
uint32 pluginID; uint32 pluginID;
uint32 pluginData; uint32 pluginData;
uint32 platform; int32 platform;
Pipeline(uint32 platform); Pipeline(uint32 platform);
Pipeline(Pipeline *p); Pipeline(Pipeline *p);

View File

@ -25,7 +25,7 @@ destroyNativeData(void *object, int32, int32)
InstanceDataHeader *header = InstanceDataHeader *header =
(InstanceDataHeader*)geometry->instData; (InstanceDataHeader*)geometry->instData;
geometry->instData = NULL; geometry->instData = NULL;
delete[] header->vertexBuffer; delete[] (uint8*)header->vertexBuffer;
delete[] header->begin; delete[] header->begin;
delete[] header->data; delete[] header->data;
delete header; delete header;
@ -241,7 +241,6 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header)
*vertexFmt = makeVertexFmt(geo->geoflags, geo->numTexCoordSets); *vertexFmt = makeVertexFmt(geo->geoflags, geo->numTexCoordSets);
header->stride = getVertexFmtStride(*vertexFmt); header->stride = getVertexFmtStride(*vertexFmt);
header->vertexBuffer = new uint8[header->stride*header->numVertices]; header->vertexBuffer = new uint8[header->stride*header->numVertices];
uint32 offset = 0;
uint8 *dst = (uint8*)header->vertexBuffer; uint8 *dst = (uint8*)header->vertexBuffer;
uint32 fmt = *vertexFmt; uint32 fmt = *vertexFmt;
@ -282,7 +281,6 @@ defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header)
uint32 *vertexFmt = getVertexFmt(geo); uint32 *vertexFmt = getVertexFmt(geo);
uint32 fmt = *vertexFmt; uint32 fmt = *vertexFmt;
assert(fmt != 0); assert(fmt != 0);
uint32 offset = 0;
uint8 *src = (uint8*)header->vertexBuffer; uint8 *src = (uint8*)header->vertexBuffer;
uint32 sel = fmt & 0xF; uint32 sel = fmt & 0xF;
@ -795,19 +793,19 @@ XboxRaster::create(Raster *raster)
} }
uint8* uint8*
XboxRaster::lock(Raster *raster, int32 level) XboxRaster::lock(Raster*, int32 level)
{ {
RasterLevels *levels = (RasterLevels*)this->texture; RasterLevels *levels = (RasterLevels*)this->texture;
return levels->levels[level].data; return levels->levels[level].data;
} }
void void
XboxRaster::unlock(Raster *raster, int32 level) XboxRaster::unlock(Raster*, int32)
{ {
} }
int32 int32
XboxRaster::getNumLevels(Raster *raster) XboxRaster::getNumLevels(Raster*)
{ {
RasterLevels *levels = (RasterLevels*)this->texture; RasterLevels *levels = (RasterLevels*)this->texture;
return levels->numlevels; return levels->numlevels;
@ -835,7 +833,7 @@ createNativeRaster(void *object, int32 offset, int32)
} }
static void* static void*
destroyNativeRaster(void *object, int32 offset, int32) destroyNativeRaster(void *object, int32, int32)
{ {
// TODO: // TODO:
return object; return object;

16
tools/dumprwtree/Makefile Normal file
View File

@ -0,0 +1,16 @@
# null, opengl
BUILD=null
# e.g. null -> -DRW_NULL
BUILDDEF:=$(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/')
SRC := dumprwtree.cpp
OUT := dumprwtree
INC := -I/usr/local/include -I../..
CFLAGS=-Wall -Wextra -g $(BUILDDEF) -Wno-parentheses -Wno-write-strings #-Wconversion
LIB=../../librw-$(BUILD).a
$(OUT): $(SRC) $(LIB)
$(CXX) $(CFLAGS) $(INC) $(SRC) $(LIB) -o $(OUT)
clean:
rm -f $(OUT)

16
tools/insttest/Makefile Normal file
View File

@ -0,0 +1,16 @@
# null, opengl
BUILD=null
# e.g. null -> -DRW_NULL
BUILDDEF:=$(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/')
SRC := insttest.cpp
OUT := insttest
INC := -I/usr/local/include -I../..
CFLAGS=-Wall -Wextra -g $(BUILDDEF) -Wno-parentheses -Wno-write-strings #-Wconversion
LIB=../../librw-$(BUILD).a
$(OUT): $(SRC) $(LIB)
$(CXX) $(CFLAGS) $(INC) $(SRC) $(LIB) -o $(OUT)
clean:
rm -f $(OUT)

View File

@ -11,7 +11,7 @@
using namespace std; using namespace std;
using namespace rw; using namespace rw;
struct { static struct {
char *str; char *str;
uint32 val; uint32 val;
} platforms[] = { } platforms[] = {

16
tools/rsltest/Makefile Normal file
View File

@ -0,0 +1,16 @@
# null, opengl
BUILD=null
# e.g. null -> -DRW_NULL
BUILDDEF:=$(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/')
SRC := rsl.cpp rsltest.cpp
OUT := rsltest
INC := -I/usr/local/include -I../..
CFLAGS=-Wall -Wextra -g $(BUILDDEF) -Wno-parentheses -Wno-write-strings #-Wconversion
LIB=../../librw-$(BUILD).a
$(OUT): $(SRC) $(LIB)
$(CXX) $(CFLAGS) $(INC) $(SRC) $(LIB) -o $(OUT)
clean:
rm -f $(OUT)

View File

@ -3,6 +3,7 @@
#include <cstring> #include <cstring>
#include <cassert> #include <cassert>
#include <new> #include <new>
#include <stddef.h>
#include <args.h> #include <args.h>
#include <rw.h> #include <rw.h>
@ -12,9 +13,8 @@ using namespace std;
using namespace rw; using namespace rw;
#include "rsl.h" #include "rsl.h"
void rslMaterialListStreamRead(Stream *stream, RslMaterialList *matlist); static void matfxRead(Stream *stream, RslMaterial *mat);
void hanimRead(Stream *stream, RslFrame *f); static void hanimRead(Stream *stream, RslFrame *f);
void matfxRead(Stream *stream, RslMaterial *mat);
void void
RslMatrixSetIdentity(RslMatrix *matrix) RslMatrixSetIdentity(RslMatrix *matrix)
@ -315,6 +315,8 @@ RslSkinStreamRead(Stream *stream, RslGeometry *g)
skin->numUsedBones = info; skin->numUsedBones = info;
skin->invMatrices = new float[skin->numBones*16]; skin->invMatrices = new float[skin->numBones*16];
stream->read(skin->invMatrices, skin->numBones*16*4); stream->read(skin->invMatrices, skin->numBones*16*4);
// TODO: allocate...if we'd really care
(void)g;
return skin; return skin;
} }
@ -440,7 +442,10 @@ RslMaterialCreate(void)
{ {
RslMaterial *mat = new RslMaterial; RslMaterial *mat = new RslMaterial;
mat->texture = NULL; mat->texture = NULL;
mat->color = RslRGBA{255, 255, 255, 255}; mat->color.red = 255;
mat->color.green = 255;
mat->color.blue = 255;
mat->color.alpha = 255;
mat->refCount = 1; mat->refCount = 1;
mat->matfx = NULL; mat->matfx = NULL;
return mat; return mat;
@ -489,7 +494,7 @@ RslMatFXMaterialSetEffects(RslMaterial *mat, int32 effect)
} }
} }
void static void
matfxRead(Stream *stream, RslMaterial *mat) matfxRead(Stream *stream, RslMaterial *mat)
{ {
int32 effect = stream->readI32(); int32 effect = stream->readI32();
@ -506,6 +511,7 @@ matfxRead(Stream *stream, RslMaterial *mat)
case MatFX::ENVMAP: case MatFX::ENVMAP:
coef = stream->readF32(); coef = stream->readF32();
fbalpha = stream->readI32(); fbalpha = stream->readI32();
(void)fbalpha;
mfx->env.frame = NULL; mfx->env.frame = NULL;
mfx->env.texture = RslTextureStreamRead(stream); mfx->env.texture = RslTextureStreamRead(stream);
mfx->env.intensity = coef; mfx->env.intensity = coef;

View File

@ -257,6 +257,8 @@ struct RslMaterialList {
int32 space; int32 space;
}; };
void rslMaterialListStreamRead(Stream *stream, RslMaterialList *matlist);
struct RslGeometry { struct RslGeometry {
RslObject object; RslObject object;
int16 refCount; int16 refCount;
@ -467,4 +469,4 @@ struct World {
uint32 numTextures; uint32 numTextures;
RslStreamHeader *textures; // stream headers RslStreamHeader *textures; // stream headers
}; };

View File

@ -17,7 +17,7 @@ char *argv0;
void void
RslStream::relocate(void) RslStream::relocate(void)
{ {
uint32 off = (uint32)this->data; uint32 off = (uint32)(uintptr)this->data;
off -= 0x20; off -= 0x20;
*(uint32*)&this->reloc += off; *(uint32*)&this->reloc += off;
*(uint32*)&this->hashTab += off; *(uint32*)&this->hashTab += off;
@ -44,7 +44,7 @@ RslMaterial *dumpMaterialCB(RslMaterial *material, void*)
material->texname, material->refCount); material->texname, material->refCount);
if(material->matfx){ if(material->matfx){
RslMatFX *fx = material->matfx; RslMatFX *fx = material->matfx;
printf(" matfx: ", fx->effectType); printf(" matfx: %d", fx->effectType);
if(fx->effectType == 2) if(fx->effectType == 2)
printf("env[%s %f] ", fx->env.texname, fx->env.intensity); printf("env[%s %f] ", fx->env.texname, fx->env.intensity);
printf("\n"); printf("\n");
@ -176,18 +176,9 @@ convertMesh(Geometry *rwg, RslGeometry *g, int32 ii)
mask |= 0x10; mask |= 0x10;
if(rwg->geoflags & Geometry::PRELIT) if(rwg->geoflags & Geometry::PRELIT)
mask |= 0x100; mask |= 0x100;
float32 *verts = &rwg->morphTargets[0].vertices[rwg->numVertices*3];
float32 *norms = &rwg->morphTargets[0].normals[rwg->numVertices*3];
uint8 *cols = &rwg->colors[rwg->numVertices*4];
float32 *texCoords = &rwg->texCoords[0][rwg->numVertices*2];
uint8 *indices = NULL;
float32 *weights = NULL;
Skin *skin = *PLUGINOFFSET(Skin*, rwg, skinGlobals.offset); Skin *skin = *PLUGINOFFSET(Skin*, rwg, skinGlobals.offset);
if(skin){ if(skin)
indices = &skin->indices[rwg->numVertices*4];
weights = &skin->weights[rwg->numVertices*4];
mask |= 0x10000; mask |= 0x10000;
}
int16 *vuVerts = NULL; int16 *vuVerts = NULL;
int8 *vuNorms = NULL; int8 *vuNorms = NULL;
@ -198,7 +189,6 @@ convertMesh(Geometry *rwg, RslGeometry *g, int32 ii)
uint32 *w = (uint32*)p; uint32 *w = (uint32*)p;
uint32 *end = (uint32*)(p + ((w[0] & 0xFFFF) + 1)*0x10); uint32 *end = (uint32*)(p + ((w[0] & 0xFFFF) + 1)*0x10);
w += 4; w += 4;
int flags = 0;
int32 nvert; int32 nvert;
bool first = 1; bool first = 1;
while(w < end){ while(w < end){
@ -613,7 +603,7 @@ convertTo32(uint8 *out, uint8 *pal, uint8 *tex,
} }
} }
RslTexture *dumpTextureCB(RslTexture *texture, void *pData) RslTexture *dumpTextureCB(RslTexture *texture, void*)
{ {
uint32 f = texture->raster->ps2.flags; uint32 f = texture->raster->ps2.flags;
uint32 w = 1 << (f & 0x3F); uint32 w = 1 << (f & 0x3F);
@ -651,7 +641,7 @@ convertTexturePS2(RslTexture *texture, void *pData)
uint32 w = 1 << (f & 0x3F); uint32 w = 1 << (f & 0x3F);
uint32 h = 1 << (f>>6 & 0x3F); uint32 h = 1 << (f>>6 & 0x3F);
uint32 d = f>>12 & 0xFF; uint32 d = f>>12 & 0xFF;
uint32 mip = f>>20 & 0xF; //uint32 mip = f>>20 & 0xF;
uint32 swizmask = f>>24; uint32 swizmask = f>>24;
uint8 *palette = getPalettePS2(texture->raster); uint8 *palette = getPalettePS2(texture->raster);
uint8 *texels = getTexelPS2(texture->raster, 0); uint8 *texels = getTexelPS2(texture->raster, 0);
@ -824,14 +814,16 @@ main(int argc, char *argv[])
goto writeDff; goto writeDff;
} }
RslStream *rslstr = new RslStream; RslStream *rslstr;
rslstr = new RslStream;
stream.read(rslstr, 0x20); stream.read(rslstr, 0x20);
rslstr->data = new uint8[rslstr->fileSize-0x20]; rslstr->data = new uint8[rslstr->fileSize-0x20];
stream.read(rslstr->data, rslstr->fileSize-0x20); stream.read(rslstr->data, rslstr->fileSize-0x20);
stream.close(); stream.close();
rslstr->relocate(); rslstr->relocate();
int largefile = rslstr->dataSize > 0x100000; bool32 largefile;
largefile = rslstr->dataSize > 0x100000;
if(rslstr->ident == WRLD_IDENT && largefile){ // hack if(rslstr->ident == WRLD_IDENT && largefile){ // hack
world = (World*)rslstr->data; world = (World*)rslstr->data;
@ -893,7 +885,8 @@ main(int argc, char *argv[])
printf(" %d, %d, %f %f %f\n", p->id &0x7FFF, p->resId, p->matrix[12], p->matrix[13], p->matrix[14]); printf(" %d, %d, %f %f %f\n", p->id &0x7FFF, p->resId, p->matrix[12], p->matrix[13], p->matrix[14]);
} }
}else if(rslstr->ident == MDL_IDENT){ }else if(rslstr->ident == MDL_IDENT){
uint8 *p = *rslstr->hashTab; uint8 *p;
p = *rslstr->hashTab;
p -= 0x24; p -= 0x24;
atomic = (RslAtomic*)p; atomic = (RslAtomic*)p;
clump = atomic->clump; clump = atomic->clump;