diff --git a/Makefile b/Makefile index 59cbcb9..b026ea3 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,8 @@ BUILD=null BUILDDEF:=$(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/') BUILDDIR=build-$(BUILD) SRCDIR=src -SRC := $(patsubst %.cpp,$(SRCDIR)/%.cpp, rwbase.cpp clump.cpp\ - geometry.cpp plugins.cpp pipeline.cpp\ - ps2.cpp ogl.cpp xbox.cpp\ - image.cpp gtaplg.cpp) +#SRC := $(patsubst %.cpp,$(SRCDIR)/%.cpp, $(wildcard *.cpp)) +SRC := $(wildcard $(SRCDIR)/*.cpp) OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC)) DEP := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.d,$(SRC)) INC := -I/usr/local/include @@ -27,6 +25,7 @@ $(BUILDDIR)/%.d: $(SRCDIR)/%.cpp $(CXX) -MM -MT '$(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$<)' $(CFLAGS) $(INC) $< > $@ clean: + echo $(SRC) rm -f $(BUILDDIR)/*.[od] -include $(DEP) diff --git a/args.h b/args.h index 308339c..0e666c1 100644 --- a/args.h +++ b/args.h @@ -15,9 +15,9 @@ extern char *argv0; while(*_args && (_argc = *_args++))\ switch(_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)) -#define EARGF(x) (_argt=_args, _args="",\ +#define EARGF(x) (_argt=_args, _args=(char*)"",\ (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0))) #define ARGC() _argc diff --git a/src/anim.cpp b/src/anim.cpp index 1e50c96..038b191 100644 --- a/src/anim.cpp +++ b/src/anim.cpp @@ -263,6 +263,7 @@ destroyUVAnim(void *object, int32 offset, int32) UVAnim *uvanim; uvanim = PLUGINOFFSET(UVAnim, object, offset); // TODO: ref counts &c. + (void)uvanim; return object; } diff --git a/src/d3d.cpp b/src/d3d.cpp index 45792e3..fe3a577 100644 --- a/src/d3d.cpp +++ b/src/d3d.cpp @@ -205,6 +205,9 @@ lockIndices(void *indexBuffer, uint32 offset, uint32 size, uint32 flags) ibuf->Lock(offset, size, (void**)&indices, flags); return indices; #else + (void)offset; + (void)size; + (void)flags; return (uint16*)indexBuffer; #endif } @@ -228,6 +231,8 @@ createVertexBuffer(uint32 length, uint32 fvf, int32 pool) device->CreateVertexBuffer(length, D3DUSAGE_WRITEONLY, fvf, (D3DPOOL)pool, &vbuf, 0); return vbuf; #else + (void)fvf; + (void)pool; return new uint8[length]; #endif } @@ -243,6 +248,9 @@ lockVertices(void *vertexBuffer, uint32 offset, uint32 size, uint32 flags) vertbuf->Lock(offset, size, (void**)&verts, flags); return verts; #else + (void)offset; + (void)size; + (void)flags; return (uint8*)vertexBuffer; #endif } @@ -316,6 +324,8 @@ lockTexture(void *texture, int32 level) void unlockTexture(void *texture, int32 level) { + (void)texture; + (void)level; #ifdef RW_D3D9 IDirect3DTexture9 *tex = (IDirect3DTexture9*)texture; tex->UnlockRect(level); @@ -383,19 +393,19 @@ D3dRaster::create(Raster *raster) } uint8* -D3dRaster::lock(Raster *raster, int32 level) +D3dRaster::lock(Raster*, int32 level) { return lockTexture(this->texture, level); } void -D3dRaster::unlock(Raster *raster, int32 level) +D3dRaster::unlock(Raster*, int32 level) { unlockTexture(this->texture, level); } int32 -D3dRaster::getNumLevels(Raster *raster) +D3dRaster::getNumLevels(Raster*) { #ifdef RW_D3D9 IDirect3DTexture9 *tex = (IDirect3DTexture9*)this->texture; @@ -450,7 +460,6 @@ setPalette(Raster *raster, void *palette, int32 size) void setTexels(Raster *raster, void *texels, int32 level) { - D3dRaster *ras = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset); uint8 *dst = raster->lock(level); memcpy(dst, texels, getLevelSize(raster, level)); raster->unlock(level); @@ -472,6 +481,7 @@ static void* destroyNativeRaster(void *object, int32 offset, int32) { // TODO: + (void)offset; return object; } diff --git a/src/d3d9.cpp b/src/d3d9.cpp index 96cee7b..aff7519 100644 --- a/src/d3d9.cpp +++ b/src/d3d9.cpp @@ -435,7 +435,6 @@ void defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header) { VertexElement dcl[NUMDECLELT]; - uint32 numElt = getDeclaration(header->vertexDeclaration, dcl); uint8 *verts[2]; verts[0] = lockVertices(header->vertexStream[0].vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK); diff --git a/src/gtaplg.cpp b/src/gtaplg.cpp index c9a8612..23fdb3e 100644 --- a/src/gtaplg.cpp +++ b/src/gtaplg.cpp @@ -1154,10 +1154,10 @@ instanceSADualColors(Geometry *g, Mesh *m, uint8 *dst) for(uint32 i = 0; i < m->numIndices; i++){ j = m->indices[i]; if(c0){ - dst[0] = c0[i*4+0]; - dst[2] = c0[i*4+1]; - dst[4] = c0[i*4+2]; - dst[6] = c0[i*4+3]; + dst[0] = c0[j*4+0]; + dst[2] = c0[j*4+1]; + dst[4] = c0[j*4+2]; + dst[6] = c0[j*4+3]; }else{ dst[0] = 0xFF; dst[2] = 0xFF; @@ -1165,10 +1165,10 @@ instanceSADualColors(Geometry *g, Mesh *m, uint8 *dst) dst[6] = 0xFF; } if(c1){ - dst[1] = c1[i*4+0]; - dst[3] = c1[i*4+1]; - dst[6] = c1[i*4+2]; - dst[7] = c1[i*4+3]; + dst[1] = c1[j*4+0]; + dst[3] = c1[j*4+1]; + dst[6] = c1[j*4+2]; + dst[7] = c1[j*4+3]; }else{ dst[1] = 0xFF; dst[3] = 0xFF; @@ -1207,7 +1207,7 @@ saInstanceCB(MatPipeline *pipe, Geometry *g, Mesh *m, uint8 **data) vertScale = 1024.0f; 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]; if(a == &saXYZADC) instanceSAPositions(g, m, adc->adcFormatted ? adc->adcBits : NULL, diff --git a/src/image.cpp b/src/image.cpp index 2ee80a7..3e1f273 100755 --- a/src/image.cpp +++ b/src/image.cpp @@ -14,6 +14,11 @@ #include "rwxbox.h" #include "rwd3d8.h" +#ifdef _WIN32 +/* srsly? */ +#define strdup _strdup +#endif + using namespace std; namespace rw { @@ -113,7 +118,7 @@ void Texture::decRef(void) { this->refCount--; - if(this->refCount == NULL) + if(this->refCount == 0) delete this; } @@ -323,7 +328,7 @@ Image::setSearchPath(const char *path) ::free(searchPaths); numSearchPaths = 0; if(path) - searchPaths = p = _strdup(path); + searchPaths = p = strdup(path); else{ searchPaths = NULL; return; @@ -358,7 +363,7 @@ Image::getFilename(const char *name) if(f){ fclose(f); printf("found %s\n", name); - return _strdup(name); + return strdup(name); } return NULL; }else diff --git a/src/pipeline.cpp b/src/pipeline.cpp index 80c2c33..961b4d5 100644 --- a/src/pipeline.cpp +++ b/src/pipeline.cpp @@ -155,10 +155,6 @@ instColor(int type, uint8 *dst, uint8 *src, uint32 numVertices, uint32 stride) assert(type == VERT_ARGB); bool32 hasAlpha = 0; 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[1] = src[1]; dst[2] = src[0]; @@ -173,7 +169,6 @@ void uninstColor(int type, uint8 *dst, uint8 *src, uint32 numVertices, uint32 stride) { assert(type == VERT_ARGB); - bool32 hasAlpha = 0; for(uint32 i = 0; i < numVertices; i++){ dst[0] = src[2]; dst[1] = src[1]; diff --git a/src/ps2.cpp b/src/ps2.cpp index 564ee2f..bb224a2 100644 --- a/src/ps2.cpp +++ b/src/ps2.cpp @@ -761,7 +761,7 @@ insertVertex(Geometry *geo, int32 i, uint32 mask, Vertex *v) } 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 *texcoords = (float32*)data[AT_UV]; @@ -775,15 +775,14 @@ defaultUninstanceCB(MatPipeline *pipe, Geometry *geo, uint32 flags[], Mesh *mesh if(geo->numTexCoordSets > 0) mask |= 0x1000; - float32 n[3]; Vertex v; for(uint32 i = 0; i < mesh->numIndices; i++){ if(mask & 0x1) memcpy(&v.p, verts, 12); if(mask & 0x10){ - n[0] = norms[0]/127.0f; - n[1] = norms[1]/127.0f; - n[2] = norms[2]/127.0f; + v.n[0] = norms[0]/127.0f; + v.n[1] = norms[1]/127.0f; + v.n[2] = norms[2]/127.0f; } if(mask & 0x100) memcpy(&v.c, colors, 4); @@ -966,7 +965,7 @@ getSizeNativeSkin(void *object, int32 offset) } void -instanceSkinData(Geometry *g, Mesh *m, Skin *skin, uint32 *data) +instanceSkinData(Geometry*, Mesh *m, Skin *skin, uint32 *data) { uint16 j; float32 *weights = (float32*)data; @@ -1052,7 +1051,7 @@ insertVertexSkin(Geometry *geo, int32 i, uint32 mask, SkinVertex *v) } 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 *texcoords = (float32*)data[AT_UV]; @@ -1127,91 +1126,9 @@ skinPostCB(MatPipeline*, Geometry *geo) 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 void -convertADC(Geometry *g) +convertADC(Geometry*) { } @@ -1260,8 +1177,8 @@ unconvertADC(Geometry *g) g->meshHeader = h; adc->adcFormatted = 0; delete[] adc->adcBits; - adc->adcBits = 0; - adc->numBits = NULL; + adc->adcBits = NULL; + adc->numBits = 0; } void @@ -1322,22 +1239,6 @@ readADC(Stream *stream, int32, void *object, int32 offset, int32) int32 size = adc->numBits+3 & ~3; adc->adcBits = new int8[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 @@ -1673,7 +1574,7 @@ Ps2Raster::create(Raster *raster) }else{ ras->flags |= 1; // include GIF packets 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 ras->flags |= 2; // TODO: stuff @@ -1800,12 +1701,18 @@ Ps2Raster::create(Raster *raster) uint8* Ps2Raster::lock(Raster *raster, int32 level) { + // TODO + (void)raster; + (void)level; return NULL; } void Ps2Raster::unlock(Raster *raster, int32 level) { + // TODO + (void)raster; + (void)level; } int32 @@ -1845,6 +1752,8 @@ createNativeRaster(void *object, int32 offset, int32) static void* destroyNativeRaster(void *object, int32 offset, int32) { + // TODO + (void)offset; return object; } @@ -1858,27 +1767,27 @@ copyNativeRaster(void *dst, void *src, int32 offset, int32) } 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(); Texture *tex = (Texture*)object; if(tex->raster == NULL) return; - Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, nativeRasterOffset); + Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, offset); SETKL(raster, val); } 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; assert(tex->raster); - Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, nativeRasterOffset); + Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, offset); stream->writeI32(raster->tex1[1]&0xFFFF); } static int32 -getSizeMipmap(void *object, int32 offset, int32) +getSizeMipmap(void*, int32, int32) { return rw::platform == PLATFORM_PS2 ? 4 : 0; } diff --git a/src/rwobjects.h b/src/rwobjects.h index 9f119df..f5f9157 100644 --- a/src/rwobjects.h +++ b/src/rwobjects.h @@ -155,10 +155,14 @@ struct Raster : PluginBase struct NativeRaster { - virtual void create(Raster *raster) { assert(IGNORERASTERIMP && "unimplemented"); }; - virtual uint8 *lock(Raster *raster, int32 level) { assert(IGNORERASTERIMP && "unimplemented"); return NULL; }; - virtual void unlock(Raster *raster, int32 level) { assert(IGNORERASTERIMP && "unimplemented"); }; - virtual int32 getNumLevels(Raster *raster) { assert(IGNORERASTERIMP && "unimplemented"); return 0; }; + virtual void create(Raster*) + { assert(IGNORERASTERIMP && "unimplemented"); }; + virtual uint8 *lock(Raster*, int32) + { 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 diff --git a/src/rwpipeline.h b/src/rwpipeline.h index 2f31fcf..6785f9b 100644 --- a/src/rwpipeline.h +++ b/src/rwpipeline.h @@ -13,7 +13,7 @@ class Pipeline public: uint32 pluginID; uint32 pluginData; - uint32 platform; + int32 platform; Pipeline(uint32 platform); Pipeline(Pipeline *p); diff --git a/src/xbox.cpp b/src/xbox.cpp index 010cfa0..ec4dbe6 100644 --- a/src/xbox.cpp +++ b/src/xbox.cpp @@ -25,7 +25,7 @@ destroyNativeData(void *object, int32, int32) InstanceDataHeader *header = (InstanceDataHeader*)geometry->instData; geometry->instData = NULL; - delete[] header->vertexBuffer; + delete[] (uint8*)header->vertexBuffer; delete[] header->begin; delete[] header->data; delete header; @@ -241,7 +241,6 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header) *vertexFmt = makeVertexFmt(geo->geoflags, geo->numTexCoordSets); header->stride = getVertexFmtStride(*vertexFmt); header->vertexBuffer = new uint8[header->stride*header->numVertices]; - uint32 offset = 0; uint8 *dst = (uint8*)header->vertexBuffer; uint32 fmt = *vertexFmt; @@ -282,7 +281,6 @@ defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header) uint32 *vertexFmt = getVertexFmt(geo); uint32 fmt = *vertexFmt; assert(fmt != 0); - uint32 offset = 0; uint8 *src = (uint8*)header->vertexBuffer; uint32 sel = fmt & 0xF; @@ -795,19 +793,19 @@ XboxRaster::create(Raster *raster) } uint8* -XboxRaster::lock(Raster *raster, int32 level) +XboxRaster::lock(Raster*, int32 level) { RasterLevels *levels = (RasterLevels*)this->texture; return levels->levels[level].data; } void -XboxRaster::unlock(Raster *raster, int32 level) +XboxRaster::unlock(Raster*, int32) { } int32 -XboxRaster::getNumLevels(Raster *raster) +XboxRaster::getNumLevels(Raster*) { RasterLevels *levels = (RasterLevels*)this->texture; return levels->numlevels; @@ -835,7 +833,7 @@ createNativeRaster(void *object, int32 offset, int32) } static void* -destroyNativeRaster(void *object, int32 offset, int32) +destroyNativeRaster(void *object, int32, int32) { // TODO: return object; diff --git a/tools/dumprwtree/Makefile b/tools/dumprwtree/Makefile new file mode 100644 index 0000000..46c5f75 --- /dev/null +++ b/tools/dumprwtree/Makefile @@ -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) diff --git a/tools/insttest/Makefile b/tools/insttest/Makefile new file mode 100644 index 0000000..e48cb77 --- /dev/null +++ b/tools/insttest/Makefile @@ -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) diff --git a/tools/insttest/insttest.cpp b/tools/insttest/insttest.cpp index 469bb54..6009db6 100644 --- a/tools/insttest/insttest.cpp +++ b/tools/insttest/insttest.cpp @@ -11,7 +11,7 @@ using namespace std; using namespace rw; -struct { +static struct { char *str; uint32 val; } platforms[] = { diff --git a/tools/rsltest/Makefile b/tools/rsltest/Makefile new file mode 100644 index 0000000..ad55777 --- /dev/null +++ b/tools/rsltest/Makefile @@ -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) diff --git a/tools/rsltest/rsl.cpp b/tools/rsltest/rsl.cpp index 91027d0..b232135 100644 --- a/tools/rsltest/rsl.cpp +++ b/tools/rsltest/rsl.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -12,9 +13,8 @@ using namespace std; using namespace rw; #include "rsl.h" -void rslMaterialListStreamRead(Stream *stream, RslMaterialList *matlist); -void hanimRead(Stream *stream, RslFrame *f); -void matfxRead(Stream *stream, RslMaterial *mat); +static void matfxRead(Stream *stream, RslMaterial *mat); +static void hanimRead(Stream *stream, RslFrame *f); void RslMatrixSetIdentity(RslMatrix *matrix) @@ -315,6 +315,8 @@ RslSkinStreamRead(Stream *stream, RslGeometry *g) skin->numUsedBones = info; skin->invMatrices = new float[skin->numBones*16]; stream->read(skin->invMatrices, skin->numBones*16*4); + // TODO: allocate...if we'd really care + (void)g; return skin; } @@ -440,7 +442,10 @@ RslMaterialCreate(void) { RslMaterial *mat = new RslMaterial; 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->matfx = NULL; return mat; @@ -489,7 +494,7 @@ RslMatFXMaterialSetEffects(RslMaterial *mat, int32 effect) } } -void +static void matfxRead(Stream *stream, RslMaterial *mat) { int32 effect = stream->readI32(); @@ -506,6 +511,7 @@ matfxRead(Stream *stream, RslMaterial *mat) case MatFX::ENVMAP: coef = stream->readF32(); fbalpha = stream->readI32(); + (void)fbalpha; mfx->env.frame = NULL; mfx->env.texture = RslTextureStreamRead(stream); mfx->env.intensity = coef; diff --git a/tools/rsltest/rsl.h b/tools/rsltest/rsl.h index d821c9d..08c23ac 100644 --- a/tools/rsltest/rsl.h +++ b/tools/rsltest/rsl.h @@ -257,6 +257,8 @@ struct RslMaterialList { int32 space; }; +void rslMaterialListStreamRead(Stream *stream, RslMaterialList *matlist); + struct RslGeometry { RslObject object; int16 refCount; @@ -467,4 +469,4 @@ struct World { uint32 numTextures; RslStreamHeader *textures; // stream headers -}; \ No newline at end of file +}; diff --git a/tools/rsltest/rsltest.cpp b/tools/rsltest/rsltest.cpp index 8098891..c96d857 100644 --- a/tools/rsltest/rsltest.cpp +++ b/tools/rsltest/rsltest.cpp @@ -17,7 +17,7 @@ char *argv0; void RslStream::relocate(void) { - uint32 off = (uint32)this->data; + uint32 off = (uint32)(uintptr)this->data; off -= 0x20; *(uint32*)&this->reloc += off; *(uint32*)&this->hashTab += off; @@ -44,7 +44,7 @@ RslMaterial *dumpMaterialCB(RslMaterial *material, void*) material->texname, material->refCount); if(material->matfx){ RslMatFX *fx = material->matfx; - printf(" matfx: ", fx->effectType); + printf(" matfx: %d", fx->effectType); if(fx->effectType == 2) printf("env[%s %f] ", fx->env.texname, fx->env.intensity); printf("\n"); @@ -176,18 +176,9 @@ convertMesh(Geometry *rwg, RslGeometry *g, int32 ii) mask |= 0x10; if(rwg->geoflags & Geometry::PRELIT) 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); - if(skin){ - indices = &skin->indices[rwg->numVertices*4]; - weights = &skin->weights[rwg->numVertices*4]; + if(skin) mask |= 0x10000; - } int16 *vuVerts = NULL; int8 *vuNorms = NULL; @@ -198,7 +189,6 @@ convertMesh(Geometry *rwg, RslGeometry *g, int32 ii) uint32 *w = (uint32*)p; uint32 *end = (uint32*)(p + ((w[0] & 0xFFFF) + 1)*0x10); w += 4; - int flags = 0; int32 nvert; bool first = 1; 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 w = 1 << (f & 0x3F); @@ -651,7 +641,7 @@ convertTexturePS2(RslTexture *texture, void *pData) uint32 w = 1 << (f & 0x3F); uint32 h = 1 << (f>>6 & 0x3F); uint32 d = f>>12 & 0xFF; - uint32 mip = f>>20 & 0xF; + //uint32 mip = f>>20 & 0xF; uint32 swizmask = f>>24; uint8 *palette = getPalettePS2(texture->raster); uint8 *texels = getTexelPS2(texture->raster, 0); @@ -824,14 +814,16 @@ main(int argc, char *argv[]) goto writeDff; } - RslStream *rslstr = new RslStream; + RslStream *rslstr; + rslstr = new RslStream; stream.read(rslstr, 0x20); rslstr->data = new uint8[rslstr->fileSize-0x20]; stream.read(rslstr->data, rslstr->fileSize-0x20); stream.close(); rslstr->relocate(); - int largefile = rslstr->dataSize > 0x100000; + bool32 largefile; + largefile = rslstr->dataSize > 0x100000; if(rslstr->ident == WRLD_IDENT && largefile){ // hack 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]); } }else if(rslstr->ident == MDL_IDENT){ - uint8 *p = *rslstr->hashTab; + uint8 *p; + p = *rslstr->hashTab; p -= 0x24; atomic = (RslAtomic*)p; clump = atomic->clump;