diff --git a/Make.common b/Make.common new file mode 100644 index 0000000..bafdc12 --- /dev/null +++ b/Make.common @@ -0,0 +1,28 @@ +BUILDDIR=build-$(BUILD) +SRCDIR=src +SRC := $(wildcard $(SRCDIR)/*.cpp $(SRCDIR)/*/*.cpp) +OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC)) +DEP := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.d,$(SRC)) +INC := $(INC) -I/usr/local/include +# define render target, e.g. null -> -DRW_NULL +BUILDDEF := $(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/') +CFLAGS := $(CFLAGS) $(BUILDDEF) + +default: $(TARGET) + +$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp + @mkdir -p $(@D) + $(CXX) $(CFLAGS) $(INC) -c $< -o $@ + +$(BUILDDIR)/%.d: $(SRCDIR)/%.cpp + @mkdir -p $(@D) + $(CXX) -MM -MT '$(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$<)' $(CFLAGS) $(INC) $< > $@ + +clean: + rm -rf $(BUILDDIR) + +cleanall: + rm -rf $(BUILDDIR) + rm $(TARGET) + +-include $(DEP) diff --git a/Makefile.ps2 b/Makefile.ps2 index c67f116..4895640 100644 --- a/Makefile.ps2 +++ b/Makefile.ps2 @@ -1,33 +1,10 @@ CXX=ee-g++ -# null, opengl -BUILD=ps2 +BUILD := ps2 +TARGET := librw-$(BUILD).a +CFLAGS := -Wall -g +INC := -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -# e.g. null -> -DRW_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) -OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC)) -DEP := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.d,$(SRC)) -CFLAGS=-Wall -g $(BUILDDEF) -Wno-parentheses #-Wconversion -INCPATH=-I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -LIB=librw-$(BUILD).a +include Make.common -$(LIB): $(OBJ) +$(TARGET): $(OBJ) ar scr $@ $(OBJ) - -$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp - @mkdir -p $(@D) - $(CXX) $(CFLAGS) $(INCPATH) -c $< -o $@ - -$(BUILDDIR)/%.d: $(SRCDIR)/%.cpp - @mkdir -p $(@D) - $(CXX) -MM -MT '$(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$<)' $(CFLAGS) $< > $@ - -clean: - rm -f $(BUILDDIR)/*.[od] - --include $(DEP) diff --git a/src/base.cpp b/src/base.cpp index abc03fa..818ac5d 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -35,16 +35,16 @@ char *debugFile = nil; // TODO: comparison tolerances static Matrix identMat = { - { 1.0f, 0.0f, 0.0f}, 0.0f, - { 0.0f, 1.0f, 0.0f}, 0.0f, - { 0.0f, 0.0f, 1.0f}, 0.0f, - { 0.0f, 0.0f, 0.0f}, 1.0f + V3d( 1.0f, 0.0f, 0.0f), 0.0f, + V3d( 0.0f, 1.0f, 0.0f), 0.0f, + V3d( 0.0f, 0.0f, 1.0f), 0.0f, + V3d( 0.0f, 0.0f, 0.0f), 1.0f }; static Matrix3 identMat3 = { - { 1.0f, 0.0f, 0.0f}, - { 0.0f, 1.0f, 0.0f}, - { 0.0f, 0.0f, 1.0f} + V3d( 1.0f, 0.0f, 0.0f), + V3d( 0.0f, 1.0f, 0.0f), + V3d( 0.0f, 0.0f, 1.0f) }; // lazy implementation diff --git a/src/clump.cpp b/src/clump.cpp index bef94d7..031b1b0 100644 --- a/src/clump.cpp +++ b/src/clump.cpp @@ -61,7 +61,7 @@ Clump::destroy(void) Light::fromClump(lnk)->destroy(); FORLIST(lnk, this->cameras) Camera::fromClump(lnk)->destroy(); - if(f = this->getFrame()) + if(f = this->getFrame(), f) f->destroyHierarchy(); free(this); } diff --git a/src/d3d/d3d9.cpp b/src/d3d/d3d9.cpp index 41af218..2b1d9fe 100644 --- a/src/d3d/d3d9.cpp +++ b/src/d3d/d3d9.cpp @@ -22,7 +22,8 @@ using namespace d3d; // TODO: move to header, but not as #define #ifndef RW_D3D9 -#define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0} +static VertexElement _d3ddec_end = {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0}; +#define D3DDECL_END() _d3ddec_end #endif #define NUMDECLELT 12 diff --git a/src/d3d/rwxbox.h b/src/d3d/rwxbox.h index bc78bcf..6f59c31 100644 --- a/src/d3d/rwxbox.h +++ b/src/d3d/rwxbox.h @@ -93,7 +93,7 @@ Texture *readNativeTexture(Stream *stream); void writeNativeTexture(Texture *tex, Stream *stream); uint32 getSizeNativeTexture(Texture *tex); -enum : rw::uint32 { +enum { D3DFMT_UNKNOWN = 0xFFFFFFFF, /* Swizzled formats */ diff --git a/src/engine.cpp b/src/engine.cpp index e8f2b79..833277e 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -24,9 +24,10 @@ void Engine::init(void) { engine = new Engine; + PluginList init = { sizeof(Driver), sizeof(Driver), nil, nil }; for(uint i = 0; i < NUM_PLATFORMS; i++) - Driver::s_plglist[i] = { sizeof(Driver), sizeof(Driver), nil, nil }; + Driver::s_plglist[i] = init; Frame::dirtyList.init(); diff --git a/src/geometry.cpp b/src/geometry.cpp index 3989222..d03adbb 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -817,7 +817,7 @@ Material::streamRead(Stream *stream) if(version < 0x30400) mat->surfaceProps = defaultSurfaceProps; else - stream->read(&mat->surfaceProps, sizeof(surfaceProps)); + stream->read(&mat->surfaceProps, sizeof(SurfaceProperties)); if(buf.textured){ if(!findChunk(stream, ID_TEXTURE, &length, nil)){ RWERROR((ERR_CHUNK, "TEXTURE")); diff --git a/src/image.cpp b/src/image.cpp index f296a57..574b432 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -229,7 +229,7 @@ Texture::read(const char *name, const char *mask) Raster *raster = nil; Texture *tex; - if(tex = Texture::findCB(name)){ + if(tex = Texture::findCB(name), tex){ tex->refCount++; return tex; } @@ -452,11 +452,11 @@ decompressDXT1(uint8 *adst, int32 w, int32 h, uint8 *src) { /* j loops through old texels * x and y loop through new texels */ - uint32 x = 0, y = 0; + int32 x = 0, y = 0; uint32 c[4][4]; uint8 idx[16]; uint8 (*dst)[4] = (uint8(*)[4])adst; - for(uint32 j = 0; j < w*h/2; j += 8){ + for(int32 j = 0; j < w*h/2; j += 8){ /* calculate colors */ uint32 col0 = *((uint16*)&src[j+0]); uint32 col1 = *((uint16*)&src[j+2]); @@ -519,12 +519,12 @@ decompressDXT3(uint8 *adst, int32 w, int32 h, uint8 *src) { /* j loops through old texels * x and y loop through new texels */ - uint32 x = 0, y = 0; + int32 x = 0, y = 0; uint32 c[4][4]; uint8 idx[16]; uint8 a[16]; uint8 (*dst)[4] = (uint8(*)[4])adst; - for(uint32 j = 0; j < w*h; j += 16){ + for(int32 j = 0; j < w*h; j += 16){ /* calculate colors */ uint32 col0 = *((uint16*)&src[j+8]); uint32 col1 = *((uint16*)&src[j+10]); @@ -577,13 +577,13 @@ decompressDXT5(uint8 *adst, int32 w, int32 h, uint8 *src) { /* j loops through old texels * x and y loop through new texels */ - uint32 x = 0, y = 0; + int32 x = 0, y = 0; uint32 c[4][4]; uint32 a[8]; uint8 idx[16]; uint8 aidx[16]; uint8 (*dst)[4] = (uint8(*)[4])adst; - for(uint32 j = 0; j < w*h; j += 16){ + for(int32 j = 0; j < w*h; j += 16){ /* calculate colors */ uint32 col0 = *((uint16*)&src[j+8]); uint32 col1 = *((uint16*)&src[j+10]); diff --git a/src/rwengine.h b/src/rwengine.h index de4d9d4..aa88f9a 100644 --- a/src/rwengine.h +++ b/src/rwengine.h @@ -98,10 +98,10 @@ struct Driver extern Driver *driver[NUM_PLATFORMS]; #define DRIVER driver[rw::platform] -inline void setRenderState(int32 state, uint32 value){ +inline void SetRenderState(int32 state, uint32 value){ engine->setRenderState(state, value); } -inline uint32 getRenderState(int32 state){ +inline uint32 GetRenderState(int32 state){ return engine->getRenderState(state); } namespace null { diff --git a/src/rwobjects.h b/src/rwobjects.h index 508ae31..84f602c 100644 --- a/src/rwobjects.h +++ b/src/rwobjects.h @@ -16,7 +16,7 @@ struct LLLink } }; -#define LLLinkGetData(linkvar,type,entry) \ +#define LLLinkGetData(linkvar,type,entry) \ ((type*)(((uint8*)(linkvar))-offsetof(type,entry))) // Have to be careful since the link might be deleted. diff --git a/src/skin.cpp b/src/skin.cpp index 0eb4bd6..b99097f 100644 --- a/src/skin.cpp +++ b/src/skin.cpp @@ -353,8 +353,8 @@ Skin::init(int32 numBones, int32 numUsedBones, int32 numVertices) -static_assert(sizeof(Skin::RLEcount) == 2, "RLEcount size"); -static_assert(sizeof(Skin::RLE) == 2, "RLE size"); +//static_assert(sizeof(Skin::RLEcount) == 2, "RLEcount size"); +//static_assert(sizeof(Skin::RLE) == 2, "RLE size"); void Skin::findNumWeights(int32 numVertices) diff --git a/src/world.cpp b/src/world.cpp index b3c6baa..f63c618 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -16,9 +16,9 @@ namespace rw { World* World::create(void) { - World *world = (World*)malloc(PluginBase::s_plglist.size); + World *world = (World*)malloc(s_plglist.size); if(world == nil){ - RWERROR((ERR_ALLOC, PluginBase::s_plglist.size)); + RWERROR((ERR_ALLOC, s_plglist.size)); return nil; } world->object.init(World::ID, 0);