Skip to content

Commit

Permalink
made most things build on linux again
Browse files Browse the repository at this point in the history
  • Loading branch information
aap committed Jan 10, 2016
1 parent 79c89eb commit 0aadf8c
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 179 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
4 changes: 2 additions & 2 deletions args.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/anim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
18 changes: 14 additions & 4 deletions src/d3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -472,6 +481,7 @@ static void*
destroyNativeRaster(void *object, int32 offset, int32)
{
// TODO:
(void)offset;
return object;
}

Expand Down
1 change: 0 additions & 1 deletion src/d3d9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions src/gtaplg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,21 +1154,21 @@ 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;
dst[4] = 0xFF;
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;
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#include "rwxbox.h"
#include "rwd3d8.h"

#ifdef _WIN32
/* srsly? */
#define strdup _strdup
#endif

using namespace std;

namespace rw {
Expand Down Expand Up @@ -113,7 +118,7 @@ void
Texture::decRef(void)
{
this->refCount--;
if(this->refCount == NULL)
if(this->refCount == 0)
delete this;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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];
Expand Down
Loading

0 comments on commit 0aadf8c

Please sign in to comment.