Some fixes for PS2.

This commit is contained in:
Angelo Papenhoff 2014-12-28 12:06:19 +01:00
parent fd017a69ef
commit e9819e9f8a
7 changed files with 34 additions and 10 deletions

View File

@ -12,13 +12,14 @@ SRC := $(patsubst %.cpp,$(SRCDIR)/%.cpp, rwbase.cpp clump.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))
CFLAGS=-Wall -g $(BUILDDEF) #-Wno-parentheses #-Wconversion CFLAGS=-Wall -g $(BUILDDEF) #-Wno-parentheses #-Wconversion
INCPATH=-I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include
LIB=librw-$(BUILD).a LIB=librw-$(BUILD).a
$(LIB): $(OBJ) $(LIB): $(OBJ)
ar scr $@ $(OBJ) ar scr $@ $(OBJ)
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp $(BUILDDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) $(CFLAGS) -c $< -o $@ $(CXX) $(CFLAGS) $(INCPATH) -c $< -o $@
$(BUILDDIR)/%.d: $(SRCDIR)/%.cpp $(BUILDDIR)/%.d: $(SRCDIR)/%.cpp
$(CXX) -MM -MT '$(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$<)' $(CFLAGS) $< > $@ $(CXX) -MM -MT '$(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$<)' $(CFLAGS) $< > $@

3
TODO
View File

@ -1,3 +1,6 @@
BUGS:
- fseek with negative offset on ps2 over ps2link messes up the current position
Clump & related: Clump & related:
- make pointer arrays into lists - make pointer arrays into lists
- work on ref counts, destruction, copying etc. - work on ref counts, destruction, copying etc.

View File

@ -21,6 +21,7 @@ main(int argc, char *argv[])
registerNodeNamePlugin(); registerNodeNamePlugin();
registerBreakableModelPlugin(); registerBreakableModelPlugin();
registerNativeDataPlugin(); registerNativeDataPlugin();
// registerNativeDataPS2Plugin();
registerMeshPlugin(); registerMeshPlugin();
Rw::Clump *c; Rw::Clump *c;
@ -32,9 +33,9 @@ main(int argc, char *argv[])
assert(c != NULL); assert(c != NULL);
in.close(); in.close();
Rw::Image *tga = Rw::readTGA("b.tga"); // Rw::Image *tga = Rw::readTGA("b.tga");
assert(tga != NULL); // assert(tga != NULL);
Rw::writeTGA(tga, "out.tga"); // Rw::writeTGA(tga, "out.tga");
// for(Rw::int32 i = 0; i < c->numAtomics; i++) // for(Rw::int32 i = 0; i < c->numAtomics; i++)
// Rw::Gl::Instance(c->atomicList[i]); // Rw::Gl::Instance(c->atomicList[i]);

View File

@ -149,7 +149,6 @@ Clump::streamRead(Stream *stream)
uint32 length, version; uint32 length, version;
int32 buf[3]; int32 buf[3];
Clump *clump; Clump *clump;
printf("- before chunk: %X\n", stream->tell());
assert(FindChunk(stream, ID_STRUCT, &length, &version)); assert(FindChunk(stream, ID_STRUCT, &length, &version));
clump = new Clump; clump = new Clump;
stream->read(buf, length); stream->read(buf, length);
@ -161,14 +160,12 @@ printf("- before chunk: %X\n", stream->tell());
clump->numCameras = buf[2]; clump->numCameras = buf[2];
} }
printf("- frame list: %X\n", stream->tell());
// Frame list // Frame list
Frame **frameList; Frame **frameList;
int32 numFrames; int32 numFrames;
clump->frameListStreamRead(stream, &frameList, &numFrames); clump->frameListStreamRead(stream, &frameList, &numFrames);
clump->parent = (void*)frameList[0]; clump->parent = (void*)frameList[0];
printf("- geometry list: %X\n", stream->tell());
// Geometry list // Geometry list
int32 numGeometries = 0; int32 numGeometries = 0;
assert(FindChunk(stream, ID_GEOMETRYLIST, NULL, NULL)); assert(FindChunk(stream, ID_GEOMETRYLIST, NULL, NULL));
@ -182,7 +179,6 @@ printf("- geometry list: %X\n", stream->tell());
geometryList[i] = Geometry::streamRead(stream); geometryList[i] = Geometry::streamRead(stream);
} }
printf("- atomics: %X\n", stream->tell());
// Atomics // Atomics
if(clump->numAtomics) if(clump->numAtomics)
clump->atomicList = new Atomic*[clump->numAtomics]; clump->atomicList = new Atomic*[clump->numAtomics];

View File

@ -270,6 +270,17 @@ registerNativeDataPlugin(void)
(StreamGetSize)getSizeNativeData); (StreamGetSize)getSizeNativeData);
} }
void
registerNativeDataPS2Plugin(void)
{
Geometry::registerPlugin(0, ID_NATIVEDATA,
NULL, DestroyNativeDataPS2, NULL);
Geometry::registerPluginStream(ID_NATIVEDATA,
(StreamRead)ReadNativeDataPS2,
(StreamWrite)WriteNativeDataPS2,
(StreamGetSize)GetSizeNativeDataPS2);
}
// Breakable Model // Breakable Model
// TODO: put this in a header // TODO: put this in a header
@ -290,6 +301,13 @@ struct Breakable
float32 (*surfaceProps)[3]; float32 (*surfaceProps)[3];
}; };
static void*
createBreakableModel(void *object, int32 offset, int32)
{
*PLUGINOFFSET(uint8*, object, offset) = 0;
return object;
}
static void* static void*
destroyBreakableModel(void *object, int32 offset, int32) destroyBreakableModel(void *object, int32 offset, int32)
{ {
@ -371,7 +389,8 @@ getSizeBreakableModel(void *object, int32 offset, int32)
void void
registerBreakableModelPlugin(void) registerBreakableModelPlugin(void)
{ {
Geometry::registerPlugin(sizeof(Breakable*), ID_BREAKABLE, NULL, Geometry::registerPlugin(sizeof(Breakable*), ID_BREAKABLE,
createBreakableModel,
destroyBreakableModel, NULL); destroyBreakableModel, NULL);
Geometry::registerPluginStream(ID_BREAKABLE, Geometry::registerPluginStream(ID_BREAKABLE,
(StreamRead)readBreakableModel, (StreamRead)readBreakableModel,

View File

@ -129,13 +129,14 @@ StreamFile::close(void)
uint32 uint32
StreamFile::write(const void *data, uint32 length) StreamFile::write(const void *data, uint32 length)
{ {
//printf("write %d bytes @ %x\n", length, this->tell());
return fwrite(data, length, 1, this->file); return fwrite(data, length, 1, this->file);
} }
uint32 uint32
StreamFile::read(void *data, uint32 length) StreamFile::read(void *data, uint32 length)
{ {
printf("read %d bytes @ %x\n", length, this->tell()); //printf("read %d bytes @ %x\n", length, this->tell());
return fread(data, length, 1, this->file); return fread(data, length, 1, this->file);
} }
@ -164,6 +165,7 @@ WriteChunkHeader(Stream *s, int32 type, int32 size)
int32 type, size; int32 type, size;
uint32 id; uint32 id;
} buf = { type, size, LibraryIDPack(Version, Build) }; } buf = { type, size, LibraryIDPack(Version, Build) };
//printf("- write chunk %x @ %x\n", buf.type, s->tell());
s->write(&buf, 12); s->write(&buf, 12);
return true; return true;
} }
@ -198,6 +200,7 @@ FindChunk(Stream *s, uint32 type, uint32 *length, uint32 *version)
*length = header.length; *length = header.length;
if(version) if(version)
*version = header.version; *version = header.version;
//printf("- chunk %x @ %x\n", header.type, s->tell()-12);
return true; return true;
} }
s->seek(header.length); s->seek(header.length);

View File

@ -230,4 +230,5 @@ private:
void registerNodeNamePlugin(void); void registerNodeNamePlugin(void);
void registerMeshPlugin(void); void registerMeshPlugin(void);
void registerNativeDataPlugin(void); void registerNativeDataPlugin(void);
void registerNativeDataPS2Plugin(void);
void registerBreakableModelPlugin(void); void registerBreakableModelPlugin(void);