mirror of
https://github.com/aap/librw.git
synced 2024-11-25 13:15:43 +00:00
Some fixes for PS2.
This commit is contained in:
parent
fd017a69ef
commit
e9819e9f8a
@ -12,13 +12,14 @@ SRC := $(patsubst %.cpp,$(SRCDIR)/%.cpp, rwbase.cpp clump.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
|
||||
|
||||
$(LIB): $(OBJ)
|
||||
ar scr $@ $(OBJ)
|
||||
|
||||
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp
|
||||
$(CXX) $(CFLAGS) -c $< -o $@
|
||||
$(CXX) $(CFLAGS) $(INCPATH) -c $< -o $@
|
||||
|
||||
$(BUILDDIR)/%.d: $(SRCDIR)/%.cpp
|
||||
$(CXX) -MM -MT '$(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$<)' $(CFLAGS) $< > $@
|
||||
|
3
TODO
3
TODO
@ -1,3 +1,6 @@
|
||||
BUGS:
|
||||
- fseek with negative offset on ps2 over ps2link messes up the current position
|
||||
|
||||
Clump & related:
|
||||
- make pointer arrays into lists
|
||||
- work on ref counts, destruction, copying etc.
|
||||
|
@ -21,6 +21,7 @@ main(int argc, char *argv[])
|
||||
registerNodeNamePlugin();
|
||||
registerBreakableModelPlugin();
|
||||
registerNativeDataPlugin();
|
||||
// registerNativeDataPS2Plugin();
|
||||
registerMeshPlugin();
|
||||
Rw::Clump *c;
|
||||
|
||||
@ -32,9 +33,9 @@ main(int argc, char *argv[])
|
||||
assert(c != NULL);
|
||||
in.close();
|
||||
|
||||
Rw::Image *tga = Rw::readTGA("b.tga");
|
||||
assert(tga != NULL);
|
||||
Rw::writeTGA(tga, "out.tga");
|
||||
// Rw::Image *tga = Rw::readTGA("b.tga");
|
||||
// assert(tga != NULL);
|
||||
// Rw::writeTGA(tga, "out.tga");
|
||||
|
||||
// for(Rw::int32 i = 0; i < c->numAtomics; i++)
|
||||
// Rw::Gl::Instance(c->atomicList[i]);
|
||||
|
@ -149,7 +149,6 @@ Clump::streamRead(Stream *stream)
|
||||
uint32 length, version;
|
||||
int32 buf[3];
|
||||
Clump *clump;
|
||||
printf("- before chunk: %X\n", stream->tell());
|
||||
assert(FindChunk(stream, ID_STRUCT, &length, &version));
|
||||
clump = new Clump;
|
||||
stream->read(buf, length);
|
||||
@ -161,14 +160,12 @@ printf("- before chunk: %X\n", stream->tell());
|
||||
clump->numCameras = buf[2];
|
||||
}
|
||||
|
||||
printf("- frame list: %X\n", stream->tell());
|
||||
// Frame list
|
||||
Frame **frameList;
|
||||
int32 numFrames;
|
||||
clump->frameListStreamRead(stream, &frameList, &numFrames);
|
||||
clump->parent = (void*)frameList[0];
|
||||
|
||||
printf("- geometry list: %X\n", stream->tell());
|
||||
// Geometry list
|
||||
int32 numGeometries = 0;
|
||||
assert(FindChunk(stream, ID_GEOMETRYLIST, NULL, NULL));
|
||||
@ -182,7 +179,6 @@ printf("- geometry list: %X\n", stream->tell());
|
||||
geometryList[i] = Geometry::streamRead(stream);
|
||||
}
|
||||
|
||||
printf("- atomics: %X\n", stream->tell());
|
||||
// Atomics
|
||||
if(clump->numAtomics)
|
||||
clump->atomicList = new Atomic*[clump->numAtomics];
|
||||
|
@ -270,6 +270,17 @@ registerNativeDataPlugin(void)
|
||||
(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
|
||||
|
||||
// TODO: put this in a header
|
||||
@ -290,6 +301,13 @@ struct Breakable
|
||||
float32 (*surfaceProps)[3];
|
||||
};
|
||||
|
||||
static void*
|
||||
createBreakableModel(void *object, int32 offset, int32)
|
||||
{
|
||||
*PLUGINOFFSET(uint8*, object, offset) = 0;
|
||||
return object;
|
||||
}
|
||||
|
||||
static void*
|
||||
destroyBreakableModel(void *object, int32 offset, int32)
|
||||
{
|
||||
@ -371,7 +389,8 @@ getSizeBreakableModel(void *object, int32 offset, int32)
|
||||
void
|
||||
registerBreakableModelPlugin(void)
|
||||
{
|
||||
Geometry::registerPlugin(sizeof(Breakable*), ID_BREAKABLE, NULL,
|
||||
Geometry::registerPlugin(sizeof(Breakable*), ID_BREAKABLE,
|
||||
createBreakableModel,
|
||||
destroyBreakableModel, NULL);
|
||||
Geometry::registerPluginStream(ID_BREAKABLE,
|
||||
(StreamRead)readBreakableModel,
|
||||
|
@ -129,13 +129,14 @@ StreamFile::close(void)
|
||||
uint32
|
||||
StreamFile::write(const void *data, uint32 length)
|
||||
{
|
||||
//printf("write %d bytes @ %x\n", length, this->tell());
|
||||
return fwrite(data, length, 1, this->file);
|
||||
}
|
||||
|
||||
uint32
|
||||
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);
|
||||
}
|
||||
|
||||
@ -164,6 +165,7 @@ WriteChunkHeader(Stream *s, int32 type, int32 size)
|
||||
int32 type, size;
|
||||
uint32 id;
|
||||
} buf = { type, size, LibraryIDPack(Version, Build) };
|
||||
//printf("- write chunk %x @ %x\n", buf.type, s->tell());
|
||||
s->write(&buf, 12);
|
||||
return true;
|
||||
}
|
||||
@ -198,6 +200,7 @@ FindChunk(Stream *s, uint32 type, uint32 *length, uint32 *version)
|
||||
*length = header.length;
|
||||
if(version)
|
||||
*version = header.version;
|
||||
//printf("- chunk %x @ %x\n", header.type, s->tell()-12);
|
||||
return true;
|
||||
}
|
||||
s->seek(header.length);
|
||||
|
@ -230,4 +230,5 @@ private:
|
||||
void registerNodeNamePlugin(void);
|
||||
void registerMeshPlugin(void);
|
||||
void registerNativeDataPlugin(void);
|
||||
void registerNativeDataPS2Plugin(void);
|
||||
void registerBreakableModelPlugin(void);
|
||||
|
Loading…
Reference in New Issue
Block a user