mirror of https://github.com/aap/librw.git
made (most of) streaming work on big endian
This commit is contained in:
parent
3010dad0cc
commit
e4b4bf9d16
|
@ -128,8 +128,8 @@ Animation::streamReadLegacy(Stream *stream)
|
||||||
anim = Animation::create(interpInfo, numFrames, flags, duration);
|
anim = Animation::create(interpInfo, numFrames, flags, duration);
|
||||||
HAnimKeyFrame *frames = (HAnimKeyFrame*)anim->keyframes;
|
HAnimKeyFrame *frames = (HAnimKeyFrame*)anim->keyframes;
|
||||||
for(int32 i = 0; i < anim->numFrames; i++){
|
for(int32 i = 0; i < anim->numFrames; i++){
|
||||||
stream->read(&frames[i].q, 4*4);
|
stream->read32(&frames[i].q, 4*4);
|
||||||
stream->read(&frames[i].t, 3*4);
|
stream->read32(&frames[i].t, 3*4);
|
||||||
frames[i].time = stream->readF32();
|
frames[i].time = stream->readF32();
|
||||||
int32 prev = stream->readI32();
|
int32 prev = stream->readI32();
|
||||||
frames[i].prevFrame = &frames[prev];
|
frames[i].prevFrame = &frames[prev];
|
||||||
|
@ -159,8 +159,8 @@ Animation::streamWriteLegacy(Stream *stream)
|
||||||
assert(interpInfo->id == 1);
|
assert(interpInfo->id == 1);
|
||||||
HAnimKeyFrame *frames = (HAnimKeyFrame*)this->keyframes;
|
HAnimKeyFrame *frames = (HAnimKeyFrame*)this->keyframes;
|
||||||
for(int32 i = 0; i < this->numFrames; i++){
|
for(int32 i = 0; i < this->numFrames; i++){
|
||||||
stream->write(&frames[i].q, 4*4);
|
stream->write32(&frames[i].q, 4*4);
|
||||||
stream->write(&frames[i].t, 3*4);
|
stream->write32(&frames[i].t, 3*4);
|
||||||
stream->writeF32(frames[i].time);
|
stream->writeF32(frames[i].time);
|
||||||
stream->writeI32(frames[i].prevFrame - frames);
|
stream->writeI32(frames[i].prevFrame - frames);
|
||||||
}
|
}
|
||||||
|
|
153
src/base.cpp
153
src/base.cpp
|
@ -692,53 +692,166 @@ makePath(char *filename)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
memNative32_func(void *data, uint32 size)
|
||||||
|
{
|
||||||
|
uint8 *bytes = (uint8*)data;
|
||||||
|
uint32 *words = (uint32*)data;
|
||||||
|
size >>= 2;
|
||||||
|
while(size--){
|
||||||
|
*words++ = (uint32)bytes[0] | (uint32)bytes[1]<<8 |
|
||||||
|
(uint32)bytes[2]<<16 | (uint32)bytes[3]<<24;
|
||||||
|
bytes += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
memNative16_func(void *data, uint32 size)
|
||||||
|
{
|
||||||
|
uint8 *bytes = (uint8*)data;
|
||||||
|
uint16 *words = (uint16*)data;
|
||||||
|
size >>= 1;
|
||||||
|
while(size--){
|
||||||
|
*words++ = (uint16)bytes[0] | (uint16)bytes[1]<<8;
|
||||||
|
bytes += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
memLittle32_func(void *data, uint32 size)
|
||||||
|
{
|
||||||
|
uint32 w;
|
||||||
|
uint8 *bytes = (uint8*)data;
|
||||||
|
uint32 *words = (uint32*)data;
|
||||||
|
size >>= 2;
|
||||||
|
while(size--){
|
||||||
|
w = *words++;
|
||||||
|
*bytes++ = w;
|
||||||
|
*bytes++ = w >> 8;
|
||||||
|
*bytes++ = w >> 16;
|
||||||
|
*bytes++ = w >> 24;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
memLittle16_func(void *data, uint32 size)
|
||||||
|
{
|
||||||
|
uint16 w;
|
||||||
|
uint8 *bytes = (uint8*)data;
|
||||||
|
uint16 *words = (uint16*)data;
|
||||||
|
size >>= 1;
|
||||||
|
while(size--){
|
||||||
|
w = *words++;
|
||||||
|
*bytes++ = w;
|
||||||
|
*bytes++ = w >> 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32
|
||||||
|
Stream::write32(const void *data, uint32 length)
|
||||||
|
{
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
uint8 *src = (uint8*)data;
|
||||||
|
uint32 buf[256];
|
||||||
|
int32 n, len;
|
||||||
|
for(len = length >>= 2; len > 0; len -= 256){
|
||||||
|
n = len < 256 ? len : 256;
|
||||||
|
memcpy(buf, src, n*4);
|
||||||
|
memLittle16(buf, n*4);
|
||||||
|
write8(buf, n*4);
|
||||||
|
src += n*4;
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
#else
|
||||||
|
return write8(data, length);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32
|
||||||
|
Stream::write16(const void *data, uint32 length)
|
||||||
|
{
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
uint8 *src = (uint8*)data;
|
||||||
|
uint16 buf[256];
|
||||||
|
int32 n, len;
|
||||||
|
for(len = length >>= 1; len > 0; len -= 256){
|
||||||
|
n = len < 256 ? len : 256;
|
||||||
|
memcpy(buf, src, n*2);
|
||||||
|
memLittle16(buf, n*2);
|
||||||
|
write8(buf, n*2);
|
||||||
|
src += n*2;
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
#else
|
||||||
|
return write8(data, length);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32
|
||||||
|
Stream::read32(void *data, uint32 length)
|
||||||
|
{
|
||||||
|
uint32 ret;
|
||||||
|
ret = read8(data, length);
|
||||||
|
memNative32(data, length);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32
|
||||||
|
Stream::read16(void *data, uint32 length)
|
||||||
|
{
|
||||||
|
uint32 ret;
|
||||||
|
ret = read8(data, length);
|
||||||
|
memNative16(data, length);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Stream::writeI8(int8 val)
|
Stream::writeI8(int8 val)
|
||||||
{
|
{
|
||||||
return write(&val, sizeof(int8));
|
return write8(&val, sizeof(int8));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Stream::writeU8(uint8 val)
|
Stream::writeU8(uint8 val)
|
||||||
{
|
{
|
||||||
return write(&val, sizeof(uint8));
|
return write8(&val, sizeof(uint8));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Stream::writeI16(int16 val)
|
Stream::writeI16(int16 val)
|
||||||
{
|
{
|
||||||
return write(&val, sizeof(int16));
|
return write16(&val, sizeof(int16));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Stream::writeU16(uint16 val)
|
Stream::writeU16(uint16 val)
|
||||||
{
|
{
|
||||||
return write(&val, sizeof(uint16));
|
return write16(&val, sizeof(uint16));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Stream::writeI32(int32 val)
|
Stream::writeI32(int32 val)
|
||||||
{
|
{
|
||||||
return write(&val, sizeof(int32));
|
return write32(&val, sizeof(int32));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Stream::writeU32(uint32 val)
|
Stream::writeU32(uint32 val)
|
||||||
{
|
{
|
||||||
return write(&val, sizeof(uint32));
|
return write32(&val, sizeof(uint32));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Stream::writeF32(float32 val)
|
Stream::writeF32(float32 val)
|
||||||
{
|
{
|
||||||
return write(&val, sizeof(float32));
|
return write32(&val, sizeof(float32));
|
||||||
}
|
}
|
||||||
|
|
||||||
int8
|
int8
|
||||||
Stream::readI8(void)
|
Stream::readI8(void)
|
||||||
{
|
{
|
||||||
int8 tmp;
|
int8 tmp;
|
||||||
read(&tmp, sizeof(int8));
|
read8(&tmp, sizeof(int8));
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,7 +859,7 @@ uint8
|
||||||
Stream::readU8(void)
|
Stream::readU8(void)
|
||||||
{
|
{
|
||||||
uint8 tmp;
|
uint8 tmp;
|
||||||
read(&tmp, sizeof(uint8));
|
read8(&tmp, sizeof(uint8));
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +867,7 @@ int16
|
||||||
Stream::readI16(void)
|
Stream::readI16(void)
|
||||||
{
|
{
|
||||||
int16 tmp;
|
int16 tmp;
|
||||||
read(&tmp, sizeof(int16));
|
read16(&tmp, sizeof(int16));
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,7 +875,7 @@ uint16
|
||||||
Stream::readU16(void)
|
Stream::readU16(void)
|
||||||
{
|
{
|
||||||
uint16 tmp;
|
uint16 tmp;
|
||||||
read(&tmp, sizeof(uint16));
|
read16(&tmp, sizeof(uint16));
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,7 +883,7 @@ int32
|
||||||
Stream::readI32(void)
|
Stream::readI32(void)
|
||||||
{
|
{
|
||||||
int32 tmp;
|
int32 tmp;
|
||||||
read(&tmp, sizeof(int32));
|
read32(&tmp, sizeof(int32));
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,7 +891,7 @@ uint32
|
||||||
Stream::readU32(void)
|
Stream::readU32(void)
|
||||||
{
|
{
|
||||||
uint32 tmp;
|
uint32 tmp;
|
||||||
read(&tmp, sizeof(uint32));
|
read32(&tmp, sizeof(uint32));
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,7 +899,7 @@ float32
|
||||||
Stream::readF32(void)
|
Stream::readF32(void)
|
||||||
{
|
{
|
||||||
float32 tmp;
|
float32 tmp;
|
||||||
read(&tmp, sizeof(float32));
|
read32(&tmp, sizeof(float32));
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -798,7 +911,7 @@ StreamMemory::close(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
StreamMemory::write(const void *data, uint32 len)
|
StreamMemory::write8(const void *data, uint32 len)
|
||||||
{
|
{
|
||||||
if(this->eof())
|
if(this->eof())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -816,7 +929,7 @@ StreamMemory::write(const void *data, uint32 len)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
StreamMemory::read(void *data, uint32 len)
|
StreamMemory::read8(void *data, uint32 len)
|
||||||
{
|
{
|
||||||
if(this->eof())
|
if(this->eof())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -900,13 +1013,13 @@ StreamFile::close(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
StreamFile::write(const void *data, uint32 length)
|
StreamFile::write8(const void *data, uint32 length)
|
||||||
{
|
{
|
||||||
return (uint32)fwrite(data, 1, length, this->file);
|
return (uint32)fwrite(data, 1, length, this->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
StreamFile::read(void *data, uint32 length)
|
StreamFile::read8(void *data, uint32 length)
|
||||||
{
|
{
|
||||||
return (uint32)fread(data, 1, length, this->file);
|
return (uint32)fread(data, 1, length, this->file);
|
||||||
}
|
}
|
||||||
|
@ -936,7 +1049,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) };
|
||||||
s->write(&buf, 12);
|
s->write32(&buf, 12);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,7 +1060,7 @@ readChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header)
|
||||||
int32 type, size;
|
int32 type, size;
|
||||||
uint32 id;
|
uint32 id;
|
||||||
} buf;
|
} buf;
|
||||||
s->read(&buf, 12);
|
s->read32(&buf, 12);
|
||||||
if(s->eof())
|
if(s->eof())
|
||||||
return false;
|
return false;
|
||||||
assert(header != nil);
|
assert(header != nil);
|
||||||
|
|
|
@ -75,6 +75,7 @@ BMPheader::write(Stream *stream)
|
||||||
Image*
|
Image*
|
||||||
readBMP(const char *afilename)
|
readBMP(const char *afilename)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Image *image;
|
Image *image;
|
||||||
char *filename;
|
char *filename;
|
||||||
uint32 length;
|
uint32 length;
|
||||||
|
@ -99,7 +100,7 @@ readBMP(const char *afilename)
|
||||||
DIBheader dib;
|
DIBheader dib;
|
||||||
if(!bmp.read(&file))
|
if(!bmp.read(&file))
|
||||||
goto lose;
|
goto lose;
|
||||||
file.read(&dib, sizeof(dib));
|
file.read8(&dib, sizeof(dib));
|
||||||
file.seek(dib.headerSize-sizeof(dib)); // skip the part of the header we're ignoring
|
file.seek(dib.headerSize-sizeof(dib)); // skip the part of the header we're ignoring
|
||||||
if(dib.headerSize <= 16){
|
if(dib.headerSize <= 16){
|
||||||
dib.compression = 0;
|
dib.compression = 0;
|
||||||
|
@ -205,6 +206,7 @@ lose:
|
||||||
void
|
void
|
||||||
writeBMP(Image *image, const char *filename)
|
writeBMP(Image *image, const char *filename)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
uint8 *p;
|
uint8 *p;
|
||||||
StreamFile file;
|
StreamFile file;
|
||||||
if(!file.open(filename, "wb")){
|
if(!file.open(filename, "wb")){
|
||||||
|
@ -239,7 +241,7 @@ writeBMP(Image *image, const char *filename)
|
||||||
dib.vres = 2835; // 72dpi
|
dib.vres = 2835; // 72dpi
|
||||||
dib.paletteLen = 0;
|
dib.paletteLen = 0;
|
||||||
dib.numImportant = 0;
|
dib.numImportant = 0;
|
||||||
file.write(&dib, dib.headerSize);
|
file.write8(&dib, dib.headerSize);
|
||||||
|
|
||||||
for(int i = 0; i < pallen; i++){
|
for(int i = 0; i < pallen; i++){
|
||||||
file.writeU8(image->palette[i*4+2]);
|
file.writeU8(image->palette[i*4+2]);
|
||||||
|
|
|
@ -455,7 +455,7 @@ Camera::streamRead(Stream *stream)
|
||||||
RWERROR((ERR_CHUNK, "STRUCT"));
|
RWERROR((ERR_CHUNK, "STRUCT"));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
stream->read(&buf, sizeof(CameraChunkData));
|
stream->read32(&buf, sizeof(CameraChunkData));
|
||||||
Camera *cam = Camera::create();
|
Camera *cam = Camera::create();
|
||||||
cam->viewWindow = buf.viewWindow;
|
cam->viewWindow = buf.viewWindow;
|
||||||
cam->viewOffset = buf.viewOffset;
|
cam->viewOffset = buf.viewOffset;
|
||||||
|
@ -481,7 +481,7 @@ Camera::streamWrite(Stream *stream)
|
||||||
buf.farPlane = this->farPlane;
|
buf.farPlane = this->farPlane;
|
||||||
buf.fogPlane = this->fogPlane;
|
buf.fogPlane = this->fogPlane;
|
||||||
buf.projection = this->projection;
|
buf.projection = this->projection;
|
||||||
stream->write(&buf, sizeof(CameraChunkData));
|
stream->write32(&buf, sizeof(CameraChunkData));
|
||||||
s_plglist.streamWrite(stream, this);
|
s_plglist.streamWrite(stream, this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ Clump::streamRead(Stream *stream)
|
||||||
RWERROR((ERR_CHUNK, "STRUCT"));
|
RWERROR((ERR_CHUNK, "STRUCT"));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
stream->read(buf, length);
|
stream->read32(buf, length);
|
||||||
int32 numAtomics = buf[0];
|
int32 numAtomics = buf[0];
|
||||||
int32 numLights = 0;
|
int32 numLights = 0;
|
||||||
int32 numCameras = 0;
|
int32 numCameras = 0;
|
||||||
|
@ -292,10 +292,10 @@ Clump::streamWrite(Stream *stream)
|
||||||
int32 numAtomics = this->countAtomics();
|
int32 numAtomics = this->countAtomics();
|
||||||
int32 numLights = this->countLights();
|
int32 numLights = this->countLights();
|
||||||
int32 numCameras = this->countCameras();
|
int32 numCameras = this->countCameras();
|
||||||
int buf[3] = { numAtomics, numLights, numCameras };
|
int32 buf[3] = { numAtomics, numLights, numCameras };
|
||||||
size = version > 0x33000 ? 12 : 4;
|
size = version > 0x33000 ? 12 : 4;
|
||||||
writeChunkHeader(stream, ID_STRUCT, size);
|
writeChunkHeader(stream, ID_STRUCT, size);
|
||||||
stream->write(buf, size);
|
stream->write32(buf, size);
|
||||||
|
|
||||||
FrameList_ frmlst;
|
FrameList_ frmlst;
|
||||||
frmlst.numFrames = this->getFrame()->count();
|
frmlst.numFrames = this->getFrame()->count();
|
||||||
|
@ -519,7 +519,7 @@ Atomic::streamReadClump(Stream *stream,
|
||||||
RWERROR((ERR_CHUNK, "STRUCT"));
|
RWERROR((ERR_CHUNK, "STRUCT"));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
stream->read(buf, version < 0x30400 ? 12 : 16);
|
stream->read32(buf, version < 0x30400 ? 12 : 16);
|
||||||
Atomic *atomic = Atomic::create();
|
Atomic *atomic = Atomic::create();
|
||||||
if(atomic == nil)
|
if(atomic == nil)
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -564,7 +564,7 @@ Atomic::streamWriteClump(Stream *stream, FrameList_ *frmlst)
|
||||||
|
|
||||||
if(version < 0x30400){
|
if(version < 0x30400){
|
||||||
buf[1] = this->object.object.flags;
|
buf[1] = this->object.object.flags;
|
||||||
stream->write(buf, sizeof(int[3]));
|
stream->write32(buf, sizeof(int32[3]));
|
||||||
this->geometry->streamWrite(stream);
|
this->geometry->streamWrite(stream);
|
||||||
}else{
|
}else{
|
||||||
buf[1] = 0;
|
buf[1] = 0;
|
||||||
|
@ -576,7 +576,7 @@ Atomic::streamWriteClump(Stream *stream, FrameList_ *frmlst)
|
||||||
return false;
|
return false;
|
||||||
foundgeo:
|
foundgeo:
|
||||||
buf[2] = this->object.object.flags;
|
buf[2] = this->object.object.flags;
|
||||||
stream->write(buf, sizeof(buf));
|
stream->write32(buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
s_plglist.streamWrite(stream, this);
|
s_plglist.streamWrite(stream, this);
|
||||||
|
@ -632,7 +632,7 @@ Atomic::defaultRenderCB(Atomic *atomic)
|
||||||
static Stream*
|
static Stream*
|
||||||
readAtomicRights(Stream *stream, int32, void *, int32, int32)
|
readAtomicRights(Stream *stream, int32, void *, int32, int32)
|
||||||
{
|
{
|
||||||
stream->read(atomicRights, 8);
|
stream->read32(atomicRights, 8);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ writeAtomicRights(Stream *stream, int32, void *object, int32, int32)
|
||||||
uint32 buffer[2];
|
uint32 buffer[2];
|
||||||
buffer[0] = atomic->pipeline->pluginID;
|
buffer[0] = atomic->pipeline->pluginID;
|
||||||
buffer[1] = atomic->pipeline->pluginData;
|
buffer[1] = atomic->pipeline->pluginData;
|
||||||
stream->write(buffer, 8);
|
stream->write32(buffer, 8);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ destroyNativeData(void *object, int32, int32)
|
||||||
Stream*
|
Stream*
|
||||||
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
uint32 platform;
|
uint32 platform;
|
||||||
if(!findChunk(stream, ID_STRUCT, nil, nil)){
|
if(!findChunk(stream, ID_STRUCT, nil, nil)){
|
||||||
|
@ -118,7 +119,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
|
|
||||||
int32 size = stream->readI32();
|
int32 size = stream->readI32();
|
||||||
uint8 *data = rwNewT(uint8, size, MEMDUR_FUNCTION | ID_GEOMETRY);
|
uint8 *data = rwNewT(uint8, size, MEMDUR_FUNCTION | ID_GEOMETRY);
|
||||||
stream->read(data, size);
|
stream->read8(data, size);
|
||||||
uint8 *p = data;
|
uint8 *p = data;
|
||||||
header->serialNumber = *(uint16*)p; p += 2;
|
header->serialNumber = *(uint16*)p; p += 2;
|
||||||
header->numMeshes = *(uint16*)p; p += 2;
|
header->numMeshes = *(uint16*)p; p += 2;
|
||||||
|
@ -149,14 +150,14 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
assert(inst->indexBuffer == nil);
|
assert(inst->indexBuffer == nil);
|
||||||
inst->indexBuffer = createIndexBuffer(inst->numIndices*2, false);
|
inst->indexBuffer = createIndexBuffer(inst->numIndices*2, false);
|
||||||
uint16 *indices = lockIndices(inst->indexBuffer, 0, 0, 0);
|
uint16 *indices = lockIndices(inst->indexBuffer, 0, 0, 0);
|
||||||
stream->read(indices, 2*inst->numIndices);
|
stream->read8(indices, 2*inst->numIndices);
|
||||||
unlockIndices(inst->indexBuffer);
|
unlockIndices(inst->indexBuffer);
|
||||||
|
|
||||||
inst->managed = 1;
|
inst->managed = 1;
|
||||||
assert(inst->vertexBuffer == nil);
|
assert(inst->vertexBuffer == nil);
|
||||||
inst->vertexBuffer = createVertexBuffer(inst->stride*inst->numVertices, 0, false);
|
inst->vertexBuffer = createVertexBuffer(inst->stride*inst->numVertices, 0, false);
|
||||||
uint8 *verts = lockVertices(inst->vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK);
|
uint8 *verts = lockVertices(inst->vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK);
|
||||||
stream->read(verts, inst->stride*inst->numVertices);
|
stream->read8(verts, inst->stride*inst->numVertices);
|
||||||
unlockVertices(inst->vertexBuffer);
|
unlockVertices(inst->vertexBuffer);
|
||||||
|
|
||||||
inst++;
|
inst++;
|
||||||
|
@ -167,6 +168,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
Stream*
|
Stream*
|
||||||
writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
writeChunkHeader(stream, ID_STRUCT, len-12);
|
writeChunkHeader(stream, ID_STRUCT, len-12);
|
||||||
if(geometry->instData == nil ||
|
if(geometry->instData == nil ||
|
||||||
|
@ -200,17 +202,17 @@ writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
*p++ = inst->remapped;
|
*p++ = inst->remapped;
|
||||||
inst++;
|
inst++;
|
||||||
}
|
}
|
||||||
stream->write(data, size);
|
stream->write8(data, size);
|
||||||
rwFree(data);
|
rwFree(data);
|
||||||
|
|
||||||
inst = header->inst;
|
inst = header->inst;
|
||||||
for(uint32 i = 0; i < header->numMeshes; i++){
|
for(uint32 i = 0; i < header->numMeshes; i++){
|
||||||
uint16 *indices = lockIndices(inst->indexBuffer, 0, 0, 0);
|
uint16 *indices = lockIndices(inst->indexBuffer, 0, 0, 0);
|
||||||
stream->write(indices, 2*inst->numIndices);
|
stream->write8(indices, 2*inst->numIndices);
|
||||||
unlockIndices(inst->indexBuffer);
|
unlockIndices(inst->indexBuffer);
|
||||||
|
|
||||||
uint8 *verts = lockVertices(inst->vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK);
|
uint8 *verts = lockVertices(inst->vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK);
|
||||||
stream->write(verts, inst->stride*inst->numVertices);
|
stream->write8(verts, inst->stride*inst->numVertices);
|
||||||
unlockVertices(inst->vertexBuffer);
|
unlockVertices(inst->vertexBuffer);
|
||||||
inst++;
|
inst++;
|
||||||
}
|
}
|
||||||
|
@ -448,10 +450,10 @@ readAsImage(Stream *stream, int32 width, int32 height, int32 depth, int32 format
|
||||||
|
|
||||||
if(format & Raster::PAL4){
|
if(format & Raster::PAL4){
|
||||||
pallen = 16;
|
pallen = 16;
|
||||||
stream->read(palette, 4*32);
|
stream->read8(palette, 4*32);
|
||||||
}else if(format & Raster::PAL8){
|
}else if(format & Raster::PAL8){
|
||||||
pallen = 256;
|
pallen = 256;
|
||||||
stream->read(palette, 4*256);
|
stream->read8(palette, 4*256);
|
||||||
}
|
}
|
||||||
if(!Raster::formatHasAlpha(format))
|
if(!Raster::formatHasAlpha(format))
|
||||||
for(int32 i = 0; i < pallen; i++)
|
for(int32 i = 0; i < pallen; i++)
|
||||||
|
@ -462,7 +464,7 @@ readAsImage(Stream *stream, int32 width, int32 height, int32 depth, int32 format
|
||||||
uint32 size = stream->readU32();
|
uint32 size = stream->readU32();
|
||||||
if(i == 0){
|
if(i == 0){
|
||||||
data = rwNewT(uint8, size, MEMDUR_FUNCTION | ID_IMAGE);
|
data = rwNewT(uint8, size, MEMDUR_FUNCTION | ID_IMAGE);
|
||||||
stream->read(data, size);
|
stream->read8(data, size);
|
||||||
}else
|
}else
|
||||||
stream->seek(size);
|
stream->seek(size);
|
||||||
}
|
}
|
||||||
|
@ -509,8 +511,8 @@ readNativeTexture(Stream *stream)
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
tex->filterAddressing = stream->readU32();
|
tex->filterAddressing = stream->readU32();
|
||||||
stream->read(tex->name, 32);
|
stream->read8(tex->name, 32);
|
||||||
stream->read(tex->mask, 32);
|
stream->read8(tex->mask, 32);
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
uint32 format = stream->readU32();
|
uint32 format = stream->readU32();
|
||||||
|
@ -547,7 +549,7 @@ readNativeTexture(Stream *stream)
|
||||||
// TODO: check if format supported and convert if necessary
|
// TODO: check if format supported and convert if necessary
|
||||||
|
|
||||||
if(pallength != 0)
|
if(pallength != 0)
|
||||||
stream->read(ras->palette, 4*pallength);
|
stream->read8(ras->palette, 4*pallength);
|
||||||
|
|
||||||
uint32 size;
|
uint32 size;
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
|
@ -555,7 +557,7 @@ readNativeTexture(Stream *stream)
|
||||||
size = stream->readU32();
|
size = stream->readU32();
|
||||||
if(i < raster->getNumLevels()){
|
if(i < raster->getNumLevels()){
|
||||||
data = raster->lock(i, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
data = raster->lock(i, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
||||||
stream->read(data, size);
|
stream->read8(data, size);
|
||||||
raster->unlock(i);
|
raster->unlock(i);
|
||||||
}else
|
}else
|
||||||
stream->seek(size);
|
stream->seek(size);
|
||||||
|
@ -572,8 +574,8 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
stream->writeU32(tex->filterAddressing);
|
stream->writeU32(tex->filterAddressing);
|
||||||
stream->write(tex->name, 32);
|
stream->write8(tex->name, 32);
|
||||||
stream->write(tex->mask, 32);
|
stream->write8(tex->mask, 32);
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
Raster *raster = tex->raster;
|
Raster *raster = tex->raster;
|
||||||
|
@ -608,9 +610,9 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
stream->writeU8(compression);
|
stream->writeU8(compression);
|
||||||
|
|
||||||
if(raster->format & Raster::PAL4)
|
if(raster->format & Raster::PAL4)
|
||||||
stream->write(ras->palette, 4*32);
|
stream->write8(ras->palette, 4*32);
|
||||||
else if(raster->format & Raster::PAL8)
|
else if(raster->format & Raster::PAL8)
|
||||||
stream->write(ras->palette, 4*256);
|
stream->write8(ras->palette, 4*256);
|
||||||
|
|
||||||
uint32 size;
|
uint32 size;
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
|
@ -618,7 +620,7 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
size = getLevelSize(raster, i);
|
size = getLevelSize(raster, i);
|
||||||
stream->writeU32(size);
|
stream->writeU32(size);
|
||||||
data = raster->lock(i, Raster::LOCKREAD);
|
data = raster->lock(i, Raster::LOCKREAD);
|
||||||
stream->write(data, size);
|
stream->write8(data, size);
|
||||||
raster->unlock(i);
|
raster->unlock(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,7 @@ destroyNativeData(void *object, int32, int32)
|
||||||
Stream*
|
Stream*
|
||||||
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
uint32 platform;
|
uint32 platform;
|
||||||
if(!findChunk(stream, ID_STRUCT, nil, nil)){
|
if(!findChunk(stream, ID_STRUCT, nil, nil)){
|
||||||
|
@ -166,7 +167,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
|
|
||||||
int32 size = stream->readI32();
|
int32 size = stream->readI32();
|
||||||
uint8 *data = rwNewT(uint8, size, MEMDUR_FUNCTION | ID_GEOMETRY);
|
uint8 *data = rwNewT(uint8, size, MEMDUR_FUNCTION | ID_GEOMETRY);
|
||||||
stream->read(data, size);
|
stream->read8(data, size);
|
||||||
uint8 *p = data;
|
uint8 *p = data;
|
||||||
header->serialNumber = *(uint32*)p; p += 4;
|
header->serialNumber = *(uint32*)p; p += 4;
|
||||||
header->numMeshes = *(uint32*)p; p += 4;
|
header->numMeshes = *(uint32*)p; p += 4;
|
||||||
|
@ -196,19 +197,19 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
|
|
||||||
VertexElement elements[NUMDECLELT];
|
VertexElement elements[NUMDECLELT];
|
||||||
uint32 numDeclarations = stream->readU32();
|
uint32 numDeclarations = stream->readU32();
|
||||||
stream->read(elements, numDeclarations*8);
|
stream->read8(elements, numDeclarations*8);
|
||||||
header->vertexDeclaration = createVertexDeclaration(elements);
|
header->vertexDeclaration = createVertexDeclaration(elements);
|
||||||
|
|
||||||
assert(header->indexBuffer == nil);
|
assert(header->indexBuffer == nil);
|
||||||
header->indexBuffer = createIndexBuffer(header->totalNumIndex*2, false);
|
header->indexBuffer = createIndexBuffer(header->totalNumIndex*2, false);
|
||||||
uint16 *indices = lockIndices(header->indexBuffer, 0, 0, 0);
|
uint16 *indices = lockIndices(header->indexBuffer, 0, 0, 0);
|
||||||
stream->read(indices, 2*header->totalNumIndex);
|
stream->read8(indices, 2*header->totalNumIndex);
|
||||||
unlockIndices(header->indexBuffer);
|
unlockIndices(header->indexBuffer);
|
||||||
|
|
||||||
VertexStream *s;
|
VertexStream *s;
|
||||||
p = data;
|
p = data;
|
||||||
for(int i = 0; i < 2; i++){
|
for(int i = 0; i < 2; i++){
|
||||||
stream->read(p, 16);
|
stream->read8(p, 16);
|
||||||
s = &header->vertexStream[i];
|
s = &header->vertexStream[i];
|
||||||
s->vertexBuffer = (void*)(uintptr)*(uint32*)p; p += 4;
|
s->vertexBuffer = (void*)(uintptr)*(uint32*)p; p += 4;
|
||||||
s->offset = 0; p += 4;
|
s->offset = 0; p += 4;
|
||||||
|
@ -223,7 +224,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
assert(s->vertexBuffer == nil);
|
assert(s->vertexBuffer == nil);
|
||||||
s->vertexBuffer = createVertexBuffer(s->stride*header->totalNumVertex, 0, false);
|
s->vertexBuffer = createVertexBuffer(s->stride*header->totalNumVertex, 0, false);
|
||||||
uint8 *verts = lockVertices(s->vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK);
|
uint8 *verts = lockVertices(s->vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK);
|
||||||
stream->read(verts, s->stride*header->totalNumVertex);
|
stream->read8(verts, s->stride*header->totalNumVertex);
|
||||||
unlockVertices(s->vertexBuffer);
|
unlockVertices(s->vertexBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,6 +242,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
Stream*
|
Stream*
|
||||||
writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
writeChunkHeader(stream, ID_STRUCT, len-12);
|
writeChunkHeader(stream, ID_STRUCT, len-12);
|
||||||
if(geometry->instData == nil ||
|
if(geometry->instData == nil ||
|
||||||
|
@ -277,15 +279,15 @@ writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
*(uint32*)p = inst->numPrimitives; p += 4;
|
*(uint32*)p = inst->numPrimitives; p += 4;
|
||||||
inst++;
|
inst++;
|
||||||
}
|
}
|
||||||
stream->write(data, size);
|
stream->write8(data, size);
|
||||||
|
|
||||||
VertexElement elements[NUMDECLELT];
|
VertexElement elements[NUMDECLELT];
|
||||||
uint32 numElt = getDeclaration(header->vertexDeclaration, elements);
|
uint32 numElt = getDeclaration(header->vertexDeclaration, elements);
|
||||||
stream->writeU32(numElt);
|
stream->writeU32(numElt);
|
||||||
stream->write(elements, 8*numElt);
|
stream->write8(elements, 8*numElt);
|
||||||
|
|
||||||
uint16 *indices = lockIndices(header->indexBuffer, 0, 0, 0);
|
uint16 *indices = lockIndices(header->indexBuffer, 0, 0, 0);
|
||||||
stream->write(indices, 2*header->totalNumIndex);
|
stream->write8(indices, 2*header->totalNumIndex);
|
||||||
unlockIndices(header->indexBuffer);
|
unlockIndices(header->indexBuffer);
|
||||||
|
|
||||||
VertexStream *s;
|
VertexStream *s;
|
||||||
|
@ -298,12 +300,12 @@ writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
*(uint16*)p = s->geometryFlags; p += 2;
|
*(uint16*)p = s->geometryFlags; p += 2;
|
||||||
*p++ = s->managed;
|
*p++ = s->managed;
|
||||||
*p++ = s->dynamicLock;
|
*p++ = s->dynamicLock;
|
||||||
stream->write(data, 16);
|
stream->write8(data, 16);
|
||||||
|
|
||||||
if(s->vertexBuffer == nil)
|
if(s->vertexBuffer == nil)
|
||||||
continue;
|
continue;
|
||||||
uint8 *verts = lockVertices(s->vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK);
|
uint8 *verts = lockVertices(s->vertexBuffer, 0, 0, D3DLOCK_NOSYSLOCK);
|
||||||
stream->write(verts, s->stride*header->totalNumVertex);
|
stream->write8(verts, s->stride*header->totalNumVertex);
|
||||||
unlockVertices(s->vertexBuffer);
|
unlockVertices(s->vertexBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,8 +710,8 @@ readNativeTexture(Stream *stream)
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
tex->filterAddressing = stream->readU32();
|
tex->filterAddressing = stream->readU32();
|
||||||
stream->read(tex->name, 32);
|
stream->read8(tex->name, 32);
|
||||||
stream->read(tex->mask, 32);
|
stream->read8(tex->mask, 32);
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
int32 format = stream->readI32();
|
int32 format = stream->readI32();
|
||||||
|
@ -756,9 +758,9 @@ readNativeTexture(Stream *stream)
|
||||||
// TODO: check if format supported and convert if necessary
|
// TODO: check if format supported and convert if necessary
|
||||||
|
|
||||||
if(raster->format & Raster::PAL4)
|
if(raster->format & Raster::PAL4)
|
||||||
stream->read(ext->palette, 4*32);
|
stream->read8(ext->palette, 4*32);
|
||||||
else if(raster->format & Raster::PAL8)
|
else if(raster->format & Raster::PAL8)
|
||||||
stream->read(ext->palette, 4*256);
|
stream->read8(ext->palette, 4*256);
|
||||||
|
|
||||||
uint32 size;
|
uint32 size;
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
|
@ -766,7 +768,7 @@ readNativeTexture(Stream *stream)
|
||||||
size = stream->readU32();
|
size = stream->readU32();
|
||||||
if(i < raster->getNumLevels()){
|
if(i < raster->getNumLevels()){
|
||||||
data = raster->lock(i, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
data = raster->lock(i, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
||||||
stream->read(data, size);
|
stream->read8(data, size);
|
||||||
raster->unlock(i);
|
raster->unlock(i);
|
||||||
}else
|
}else
|
||||||
stream->seek(size);
|
stream->seek(size);
|
||||||
|
@ -783,8 +785,8 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
stream->writeU32(tex->filterAddressing);
|
stream->writeU32(tex->filterAddressing);
|
||||||
stream->write(tex->name, 32);
|
stream->write8(tex->name, 32);
|
||||||
stream->write(tex->mask, 32);
|
stream->write8(tex->mask, 32);
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
Raster *raster = tex->raster;
|
Raster *raster = tex->raster;
|
||||||
|
@ -806,9 +808,9 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
stream->writeU8(flags);
|
stream->writeU8(flags);
|
||||||
|
|
||||||
if(raster->format & Raster::PAL4)
|
if(raster->format & Raster::PAL4)
|
||||||
stream->write(ext->palette, 4*32);
|
stream->write8(ext->palette, 4*32);
|
||||||
else if(raster->format & Raster::PAL8)
|
else if(raster->format & Raster::PAL8)
|
||||||
stream->write(ext->palette, 4*256);
|
stream->write8(ext->palette, 4*256);
|
||||||
|
|
||||||
uint32 size;
|
uint32 size;
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
|
@ -816,7 +818,7 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
size = getLevelSize(raster, i);
|
size = getLevelSize(raster, i);
|
||||||
stream->writeU32(size);
|
stream->writeU32(size);
|
||||||
data = raster->lock(i, Raster::LOCKREAD);
|
data = raster->lock(i, Raster::LOCKREAD);
|
||||||
stream->write(data, size);
|
stream->write8(data, size);
|
||||||
raster->unlock(i);
|
raster->unlock(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ destroyNativeData(void *object, int32, int32)
|
||||||
Stream*
|
Stream*
|
||||||
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
uint32 vers;
|
uint32 vers;
|
||||||
uint32 platform;
|
uint32 platform;
|
||||||
|
@ -92,7 +93,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
// We don't have it but it's used for alignment.
|
// We don't have it but it's used for alignment.
|
||||||
header->data = rwNewT(uint8, size + 0x18, MEMDUR_EVENT | ID_GEOMETRY);
|
header->data = rwNewT(uint8, size + 0x18, MEMDUR_EVENT | ID_GEOMETRY);
|
||||||
uint8 *p = header->data+0x18+4;
|
uint8 *p = header->data+0x18+4;
|
||||||
stream->read(p, size-4);
|
stream->read8(p, size-4);
|
||||||
|
|
||||||
header->size = size;
|
header->size = size;
|
||||||
header->serialNumber = *(uint16*)p; p += 2;
|
header->serialNumber = *(uint16*)p; p += 2;
|
||||||
|
@ -120,13 +121,14 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
header->end = inst;
|
header->end = inst;
|
||||||
|
|
||||||
header->vertexBuffer = rwNewT(uint8, header->stride*header->numVertices, MEMDUR_EVENT | ID_GEOMETRY);
|
header->vertexBuffer = rwNewT(uint8, header->stride*header->numVertices, MEMDUR_EVENT | ID_GEOMETRY);
|
||||||
stream->read(header->vertexBuffer, header->stride*header->numVertices);
|
stream->read8(header->vertexBuffer, header->stride*header->numVertices);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream*
|
Stream*
|
||||||
writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
writeChunkHeader(stream, ID_STRUCT, len-12);
|
writeChunkHeader(stream, ID_STRUCT, len-12);
|
||||||
if(geometry->instData == nil ||
|
if(geometry->instData == nil ||
|
||||||
|
@ -160,8 +162,8 @@ writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
inst++;
|
inst++;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->write(header->data+0x18, header->size);
|
stream->write8(header->data+0x18, header->size);
|
||||||
stream->write(header->vertexBuffer, header->stride*header->numVertices);
|
stream->write8(header->vertexBuffer, header->stride*header->numVertices);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,8 +825,8 @@ readNativeTexture(Stream *stream)
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
tex->filterAddressing = stream->readU32();
|
tex->filterAddressing = stream->readU32();
|
||||||
stream->read(tex->name, 32);
|
stream->read8(tex->name, 32);
|
||||||
stream->read(tex->mask, 32);
|
stream->read8(tex->mask, 32);
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
int32 format = stream->readI32();
|
int32 format = stream->readI32();
|
||||||
|
@ -856,13 +858,13 @@ readNativeTexture(Stream *stream)
|
||||||
tex->raster = raster;
|
tex->raster = raster;
|
||||||
|
|
||||||
if(raster->format & Raster::PAL4)
|
if(raster->format & Raster::PAL4)
|
||||||
stream->read(ras->palette, 4*32);
|
stream->read8(ras->palette, 4*32);
|
||||||
else if(raster->format & Raster::PAL8)
|
else if(raster->format & Raster::PAL8)
|
||||||
stream->read(ras->palette, 4*256);
|
stream->read8(ras->palette, 4*256);
|
||||||
|
|
||||||
// exploit the fact that mipmaps are allocated consecutively
|
// exploit the fact that mipmaps are allocated consecutively
|
||||||
uint8 *data = raster->lock(0, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
uint8 *data = raster->lock(0, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
||||||
stream->read(data, totalSize);
|
stream->read8(data, totalSize);
|
||||||
raster->unlock(0);
|
raster->unlock(0);
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
|
@ -877,8 +879,8 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
stream->writeU32(tex->filterAddressing);
|
stream->writeU32(tex->filterAddressing);
|
||||||
stream->write(tex->name, 32);
|
stream->write8(tex->name, 32);
|
||||||
stream->write(tex->mask, 32);
|
stream->write8(tex->mask, 32);
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
Raster *raster = tex->raster;
|
Raster *raster = tex->raster;
|
||||||
|
@ -901,13 +903,13 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
stream->writeI32(totalSize);
|
stream->writeI32(totalSize);
|
||||||
|
|
||||||
if(raster->format & Raster::PAL4)
|
if(raster->format & Raster::PAL4)
|
||||||
stream->write(ras->palette, 4*32);
|
stream->write8(ras->palette, 4*32);
|
||||||
else if(raster->format & Raster::PAL8)
|
else if(raster->format & Raster::PAL8)
|
||||||
stream->write(ras->palette, 4*256);
|
stream->write8(ras->palette, 4*256);
|
||||||
|
|
||||||
// exploit the fact that mipmaps are allocated consecutively
|
// exploit the fact that mipmaps are allocated consecutively
|
||||||
uint8 *data = raster->lock(0, Raster::LOCKREAD);
|
uint8 *data = raster->lock(0, Raster::LOCKREAD);
|
||||||
stream->write(data, totalSize);
|
stream->write8(data, totalSize);
|
||||||
raster->unlock(0);
|
raster->unlock(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct NativeSkin
|
||||||
Stream*
|
Stream*
|
||||||
readNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
readNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
uint32 vers, platform;
|
uint32 vers, platform;
|
||||||
if(!findChunk(stream, ID_STRUCT, nil, &vers)){
|
if(!findChunk(stream, ID_STRUCT, nil, &vers)){
|
||||||
|
@ -53,16 +54,16 @@ readNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||||
skin->init(numBones, 0, 0);
|
skin->init(numBones, 0, 0);
|
||||||
NativeSkin *natskin = rwNewT(NativeSkin, 1, MEMDUR_EVENT | ID_SKIN);
|
NativeSkin *natskin = rwNewT(NativeSkin, 1, MEMDUR_EVENT | ID_SKIN);
|
||||||
skin->platformData = natskin;
|
skin->platformData = natskin;
|
||||||
stream->read(natskin->table1, 256*sizeof(int32));
|
stream->read32(natskin->table1, 256*sizeof(int32));
|
||||||
stream->read(natskin->table2, 256*sizeof(int32));
|
stream->read32(natskin->table2, 256*sizeof(int32));
|
||||||
natskin->numUsedBones = stream->readI32();
|
natskin->numUsedBones = stream->readI32();
|
||||||
skin->numWeights = stream->readI32();
|
skin->numWeights = stream->readI32();
|
||||||
stream->seek(4); // skip pointer to vertexBuffer
|
stream->seek(4); // skip pointer to vertexBuffer
|
||||||
natskin->stride = stream->readI32();
|
natskin->stride = stream->readI32();
|
||||||
int32 size = geometry->numVertices*natskin->stride;
|
int32 size = geometry->numVertices*natskin->stride;
|
||||||
natskin->vertexBuffer = rwNewT(uint8, size, MEMDUR_EVENT | ID_SKIN);
|
natskin->vertexBuffer = rwNewT(uint8, size, MEMDUR_EVENT | ID_SKIN);
|
||||||
stream->read(natskin->vertexBuffer, size);
|
stream->read8(natskin->vertexBuffer, size);
|
||||||
stream->read(skin->inverseMatrices, skin->numBones*64);
|
stream->read32(skin->inverseMatrices, skin->numBones*64);
|
||||||
|
|
||||||
readSkinSplitData(stream, skin);
|
readSkinSplitData(stream, skin);
|
||||||
return stream;
|
return stream;
|
||||||
|
@ -71,6 +72,7 @@ readNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||||
Stream*
|
Stream*
|
||||||
writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
|
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
|
||||||
assert(skin->platformData);
|
assert(skin->platformData);
|
||||||
|
@ -80,15 +82,15 @@ writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||||
writeChunkHeader(stream, ID_STRUCT, len-12);
|
writeChunkHeader(stream, ID_STRUCT, len-12);
|
||||||
stream->writeU32(PLATFORM_XBOX);
|
stream->writeU32(PLATFORM_XBOX);
|
||||||
stream->writeI32(skin->numBones);
|
stream->writeI32(skin->numBones);
|
||||||
stream->write(natskin->table1, 256*sizeof(int32));
|
stream->write32(natskin->table1, 256*sizeof(int32));
|
||||||
stream->write(natskin->table2, 256*sizeof(int32));
|
stream->write32(natskin->table2, 256*sizeof(int32));
|
||||||
stream->writeI32(natskin->numUsedBones);
|
stream->writeI32(natskin->numUsedBones);
|
||||||
stream->writeI32(skin->numWeights);
|
stream->writeI32(skin->numWeights);
|
||||||
stream->writeU32(0xBADEAFFE); // pointer to vertexBuffer
|
stream->writeU32(0xBADEAFFE); // pointer to vertexBuffer
|
||||||
stream->writeI32(natskin->stride);
|
stream->writeI32(natskin->stride);
|
||||||
stream->write(natskin->vertexBuffer,
|
stream->write8(natskin->vertexBuffer,
|
||||||
geometry->numVertices*natskin->stride);
|
geometry->numVertices*natskin->stride);
|
||||||
stream->write(skin->inverseMatrices, skin->numBones*64);
|
stream->write32(skin->inverseMatrices, skin->numBones*64);
|
||||||
|
|
||||||
writeSkinSplitData(stream, skin);
|
writeSkinSplitData(stream, skin);
|
||||||
return stream;
|
return stream;
|
||||||
|
|
|
@ -380,7 +380,7 @@ FrameList_::streamRead(Stream *stream)
|
||||||
}
|
}
|
||||||
for(int32 i = 0; i < this->numFrames; i++){
|
for(int32 i = 0; i < this->numFrames; i++){
|
||||||
Frame *f;
|
Frame *f;
|
||||||
stream->read(&buf, sizeof(buf));
|
stream->read32(&buf, sizeof(buf));
|
||||||
this->frames[i] = f = Frame::create();
|
this->frames[i] = f = Frame::create();
|
||||||
if(f == nil){
|
if(f == nil){
|
||||||
// TODO: clean up frames?
|
// TODO: clean up frames?
|
||||||
|
@ -425,7 +425,7 @@ FrameList_::streamWrite(Stream *stream)
|
||||||
buf.parent = findPointer(f->getParent(), (void**)this->frames,
|
buf.parent = findPointer(f->getParent(), (void**)this->frames,
|
||||||
this->numFrames);
|
this->numFrames);
|
||||||
buf.matflag = 0; //f->matflag;
|
buf.matflag = 0; //f->matflag;
|
||||||
stream->write(&buf, sizeof(buf));
|
stream->write32(&buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
for(int32 i = 0; i < this->numFrames; i++)
|
for(int32 i = 0; i < this->numFrames; i++)
|
||||||
Frame::s_plglist.streamWrite(stream, this->frames[i]);
|
Frame::s_plglist.streamWrite(stream, this->frames[i]);
|
||||||
|
|
|
@ -143,24 +143,24 @@ Geometry::streamRead(Stream *stream)
|
||||||
RWERROR((ERR_CHUNK, "STRUCT"));
|
RWERROR((ERR_CHUNK, "STRUCT"));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
stream->read(&buf, sizeof(buf));
|
stream->read32(&buf, sizeof(buf));
|
||||||
Geometry *geo = Geometry::create(buf.numVertices,
|
Geometry *geo = Geometry::create(buf.numVertices,
|
||||||
buf.numTriangles, buf.flags);
|
buf.numTriangles, buf.flags);
|
||||||
if(geo == nil)
|
if(geo == nil)
|
||||||
return nil;
|
return nil;
|
||||||
geo->addMorphTargets(buf.numMorphTargets-1);
|
geo->addMorphTargets(buf.numMorphTargets-1);
|
||||||
if(version < 0x34000)
|
if(version < 0x34000)
|
||||||
stream->read(&surfProps, 12);
|
stream->read32(&surfProps, 12);
|
||||||
|
|
||||||
if(!(geo->flags & NATIVE)){
|
if(!(geo->flags & NATIVE)){
|
||||||
if(geo->flags & PRELIT)
|
if(geo->flags & PRELIT)
|
||||||
stream->read(geo->colors, 4*geo->numVertices);
|
stream->read8(geo->colors, 4*geo->numVertices);
|
||||||
for(int32 i = 0; i < geo->numTexCoordSets; i++)
|
for(int32 i = 0; i < geo->numTexCoordSets; i++)
|
||||||
stream->read(geo->texCoords[i],
|
stream->read32(geo->texCoords[i],
|
||||||
2*geo->numVertices*4);
|
2*geo->numVertices*4);
|
||||||
for(int32 i = 0; i < geo->numTriangles; i++){
|
for(int32 i = 0; i < geo->numTriangles; i++){
|
||||||
uint32 tribuf[2];
|
uint32 tribuf[2];
|
||||||
stream->read(tribuf, 8);
|
stream->read32(tribuf, 8);
|
||||||
geo->triangles[i].v[0] = tribuf[0] >> 16;
|
geo->triangles[i].v[0] = tribuf[0] >> 16;
|
||||||
geo->triangles[i].v[1] = tribuf[0];
|
geo->triangles[i].v[1] = tribuf[0];
|
||||||
geo->triangles[i].v[2] = tribuf[1] >> 16;
|
geo->triangles[i].v[2] = tribuf[1] >> 16;
|
||||||
|
@ -170,13 +170,13 @@ Geometry::streamRead(Stream *stream)
|
||||||
|
|
||||||
for(int32 i = 0; i < geo->numMorphTargets; i++){
|
for(int32 i = 0; i < geo->numMorphTargets; i++){
|
||||||
MorphTarget *m = &geo->morphTargets[i];
|
MorphTarget *m = &geo->morphTargets[i];
|
||||||
stream->read(&m->boundingSphere, 4*4);
|
stream->read32(&m->boundingSphere, 4*4);
|
||||||
int32 hasVertices = stream->readI32();
|
int32 hasVertices = stream->readI32();
|
||||||
int32 hasNormals = stream->readI32();
|
int32 hasNormals = stream->readI32();
|
||||||
if(hasVertices)
|
if(hasVertices)
|
||||||
stream->read(m->vertices, 3*geo->numVertices*4);
|
stream->read32(m->vertices, 3*geo->numVertices*4);
|
||||||
if(hasNormals)
|
if(hasNormals)
|
||||||
stream->read(m->normals, 3*geo->numVertices*4);
|
stream->read32(m->normals, 3*geo->numVertices*4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!findChunk(stream, ID_MATLIST, nil, nil)){
|
if(!findChunk(stream, ID_MATLIST, nil, nil)){
|
||||||
|
@ -239,15 +239,15 @@ Geometry::streamWrite(Stream *stream)
|
||||||
buf.numTriangles = this->numTriangles;
|
buf.numTriangles = this->numTriangles;
|
||||||
buf.numVertices = this->numVertices;
|
buf.numVertices = this->numVertices;
|
||||||
buf.numMorphTargets = this->numMorphTargets;
|
buf.numMorphTargets = this->numMorphTargets;
|
||||||
stream->write(&buf, sizeof(buf));
|
stream->write32(&buf, sizeof(buf));
|
||||||
if(version < 0x34000)
|
if(version < 0x34000)
|
||||||
stream->write(fbuf, sizeof(fbuf));
|
stream->write32(fbuf, sizeof(fbuf));
|
||||||
|
|
||||||
if(!(this->flags & NATIVE)){
|
if(!(this->flags & NATIVE)){
|
||||||
if(this->flags & PRELIT)
|
if(this->flags & PRELIT)
|
||||||
stream->write(this->colors, 4*this->numVertices);
|
stream->write8(this->colors, 4*this->numVertices);
|
||||||
for(int32 i = 0; i < this->numTexCoordSets; i++)
|
for(int32 i = 0; i < this->numTexCoordSets; i++)
|
||||||
stream->write(this->texCoords[i],
|
stream->write32(this->texCoords[i],
|
||||||
2*this->numVertices*4);
|
2*this->numVertices*4);
|
||||||
for(int32 i = 0; i < this->numTriangles; i++){
|
for(int32 i = 0; i < this->numTriangles; i++){
|
||||||
uint32 tribuf[2];
|
uint32 tribuf[2];
|
||||||
|
@ -255,21 +255,21 @@ Geometry::streamWrite(Stream *stream)
|
||||||
this->triangles[i].v[1];
|
this->triangles[i].v[1];
|
||||||
tribuf[1] = this->triangles[i].v[2] << 16 |
|
tribuf[1] = this->triangles[i].v[2] << 16 |
|
||||||
this->triangles[i].matId;
|
this->triangles[i].matId;
|
||||||
stream->write(tribuf, 8);
|
stream->write32(tribuf, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int32 i = 0; i < this->numMorphTargets; i++){
|
for(int32 i = 0; i < this->numMorphTargets; i++){
|
||||||
MorphTarget *m = &this->morphTargets[i];
|
MorphTarget *m = &this->morphTargets[i];
|
||||||
stream->write(&m->boundingSphere, 4*4);
|
stream->write32(&m->boundingSphere, 4*4);
|
||||||
if(!(this->flags & NATIVE)){
|
if(!(this->flags & NATIVE)){
|
||||||
stream->writeI32(m->vertices != nil);
|
stream->writeI32(m->vertices != nil);
|
||||||
stream->writeI32(m->normals != nil);
|
stream->writeI32(m->normals != nil);
|
||||||
if(m->vertices)
|
if(m->vertices)
|
||||||
stream->write(m->vertices,
|
stream->write32(m->vertices,
|
||||||
3*this->numVertices*4);
|
3*this->numVertices*4);
|
||||||
if(m->normals)
|
if(m->normals)
|
||||||
stream->write(m->normals,
|
stream->write32(m->normals,
|
||||||
3*this->numVertices*4);
|
3*this->numVertices*4);
|
||||||
}else{
|
}else{
|
||||||
stream->writeI32(0);
|
stream->writeI32(0);
|
||||||
|
@ -780,7 +780,7 @@ MaterialList::streamRead(Stream *stream, MaterialList *matlist)
|
||||||
matlist->space = numMat;
|
matlist->space = numMat;
|
||||||
|
|
||||||
indices = (int32*)rwMalloc(numMat*4, MEMDUR_FUNCTION | ID_MATERIAL);
|
indices = (int32*)rwMalloc(numMat*4, MEMDUR_FUNCTION | ID_MATERIAL);
|
||||||
stream->read(indices, numMat*4);
|
stream->read32(indices, numMat*4);
|
||||||
|
|
||||||
Material *m;
|
Material *m;
|
||||||
for(int32 i = 0; i < numMat; i++){
|
for(int32 i = 0; i < numMat; i++){
|
||||||
|
@ -931,7 +931,7 @@ Material::streamRead(Stream *stream)
|
||||||
RWERROR((ERR_CHUNK, "STRUCT"));
|
RWERROR((ERR_CHUNK, "STRUCT"));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
stream->read(&buf, sizeof(buf));
|
stream->read32(&buf, sizeof(buf));
|
||||||
Material *mat = Material::create();
|
Material *mat = Material::create();
|
||||||
if(mat == nil)
|
if(mat == nil)
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -939,7 +939,7 @@ Material::streamRead(Stream *stream)
|
||||||
if(version < 0x30400)
|
if(version < 0x30400)
|
||||||
mat->surfaceProps = defaultSurfaceProps;
|
mat->surfaceProps = defaultSurfaceProps;
|
||||||
else
|
else
|
||||||
stream->read(&mat->surfaceProps, sizeof(SurfaceProperties));
|
stream->read32(&mat->surfaceProps, sizeof(SurfaceProperties));
|
||||||
if(buf.textured){
|
if(buf.textured){
|
||||||
if(!findChunk(stream, ID_TEXTURE, &length, nil)){
|
if(!findChunk(stream, ID_TEXTURE, &length, nil)){
|
||||||
RWERROR((ERR_CHUNK, "TEXTURE"));
|
RWERROR((ERR_CHUNK, "TEXTURE"));
|
||||||
|
@ -973,14 +973,14 @@ Material::streamWrite(Stream *stream)
|
||||||
buf.flags = 0;
|
buf.flags = 0;
|
||||||
buf.unused = 0;
|
buf.unused = 0;
|
||||||
buf.textured = this->texture != nil;
|
buf.textured = this->texture != nil;
|
||||||
stream->write(&buf, sizeof(buf));
|
stream->write32(&buf, sizeof(buf));
|
||||||
|
|
||||||
if(rw::version >= 0x30400){
|
if(rw::version >= 0x30400){
|
||||||
float32 surfaceProps[3];
|
float32 surfaceProps[3];
|
||||||
surfaceProps[0] = this->surfaceProps.ambient;
|
surfaceProps[0] = this->surfaceProps.ambient;
|
||||||
surfaceProps[1] = this->surfaceProps.specular;
|
surfaceProps[1] = this->surfaceProps.specular;
|
||||||
surfaceProps[2] = this->surfaceProps.diffuse;
|
surfaceProps[2] = this->surfaceProps.diffuse;
|
||||||
stream->write(surfaceProps, sizeof(surfaceProps));
|
stream->write32(surfaceProps, sizeof(surfaceProps));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->texture)
|
if(this->texture)
|
||||||
|
@ -1008,7 +1008,7 @@ Material::streamGetSize(void)
|
||||||
static Stream*
|
static Stream*
|
||||||
readMaterialRights(Stream *stream, int32, void *, int32, int32)
|
readMaterialRights(Stream *stream, int32, void *, int32, int32)
|
||||||
{
|
{
|
||||||
stream->read(materialRights, 8);
|
stream->read32(materialRights, 8);
|
||||||
// printf("materialrights: %X %X\n", materialRights[0], materialRights[1]);
|
// printf("materialrights: %X %X\n", materialRights[0], materialRights[1]);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
@ -1020,7 +1020,7 @@ writeMaterialRights(Stream *stream, int32, void *object, int32, int32)
|
||||||
uint32 buffer[2];
|
uint32 buffer[2];
|
||||||
buffer[0] = material->pipeline->pluginID;
|
buffer[0] = material->pipeline->pluginID;
|
||||||
buffer[1] = material->pipeline->pluginData;
|
buffer[1] = material->pipeline->pluginData;
|
||||||
stream->write(buffer, 8);
|
stream->write32(buffer, 8);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ readMesh(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
uint16 *indices;
|
uint16 *indices;
|
||||||
Geometry *geo = (Geometry*)object;
|
Geometry *geo = (Geometry*)object;
|
||||||
|
|
||||||
stream->read(&mhs, sizeof(MeshHeaderStream));
|
stream->read32(&mhs, sizeof(MeshHeaderStream));
|
||||||
// Have to do this dance for War Drum's meshes
|
// Have to do this dance for War Drum's meshes
|
||||||
bool32 hasData = len > sizeof(MeshHeaderStream)+mhs.numMeshes*sizeof(MeshStream);
|
bool32 hasData = len > sizeof(MeshHeaderStream)+mhs.numMeshes*sizeof(MeshStream);
|
||||||
assert(geo->meshHeader == nil);
|
assert(geo->meshHeader == nil);
|
||||||
|
@ -128,7 +128,7 @@ readMesh(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
mesh = mh->getMeshes();
|
mesh = mh->getMeshes();
|
||||||
indices = mesh->indices;
|
indices = mesh->indices;
|
||||||
for(uint32 i = 0; i < mh->numMeshes; i++){
|
for(uint32 i = 0; i < mh->numMeshes; i++){
|
||||||
stream->read(&ms, sizeof(MeshStream));
|
stream->read32(&ms, sizeof(MeshStream));
|
||||||
mesh->numIndices = ms.numIndices;
|
mesh->numIndices = ms.numIndices;
|
||||||
mesh->material = geo->matList.materials[ms.matIndex];
|
mesh->material = geo->matList.materials[ms.matIndex];
|
||||||
if(geo->flags & Geometry::NATIVE){
|
if(geo->flags & Geometry::NATIVE){
|
||||||
|
@ -136,7 +136,7 @@ readMesh(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
if(hasData){
|
if(hasData){
|
||||||
mesh->indices = indices;
|
mesh->indices = indices;
|
||||||
indices += mesh->numIndices;
|
indices += mesh->numIndices;
|
||||||
stream->read(mesh->indices,
|
stream->read16(mesh->indices,
|
||||||
mesh->numIndices*2);
|
mesh->numIndices*2);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -146,7 +146,7 @@ readMesh(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
int32 numIndices = mesh->numIndices;
|
int32 numIndices = mesh->numIndices;
|
||||||
for(; numIndices > 0; numIndices -= 256){
|
for(; numIndices > 0; numIndices -= 256){
|
||||||
int32 n = numIndices < 256 ? numIndices : 256;
|
int32 n = numIndices < 256 ? numIndices : 256;
|
||||||
stream->read(indbuf, n*4);
|
stream->read32(indbuf, n*4);
|
||||||
for(int32 j = 0; j < n; j++)
|
for(int32 j = 0; j < n; j++)
|
||||||
ind[j] = indbuf[j];
|
ind[j] = indbuf[j];
|
||||||
ind += n;
|
ind += n;
|
||||||
|
@ -167,16 +167,16 @@ writeMesh(Stream *stream, int32, void *object, int32, int32)
|
||||||
mhs.flags = geo->meshHeader->flags;
|
mhs.flags = geo->meshHeader->flags;
|
||||||
mhs.numMeshes = geo->meshHeader->numMeshes;
|
mhs.numMeshes = geo->meshHeader->numMeshes;
|
||||||
mhs.totalIndices = geo->meshHeader->totalIndices;
|
mhs.totalIndices = geo->meshHeader->totalIndices;
|
||||||
stream->write(&mhs, sizeof(MeshHeaderStream));
|
stream->write32(&mhs, sizeof(MeshHeaderStream));
|
||||||
Mesh *mesh = geo->meshHeader->getMeshes();
|
Mesh *mesh = geo->meshHeader->getMeshes();
|
||||||
for(uint32 i = 0; i < geo->meshHeader->numMeshes; i++){
|
for(uint32 i = 0; i < geo->meshHeader->numMeshes; i++){
|
||||||
ms.numIndices = mesh->numIndices;
|
ms.numIndices = mesh->numIndices;
|
||||||
ms.matIndex = geo->matList.findIndex(mesh->material);
|
ms.matIndex = geo->matList.findIndex(mesh->material);
|
||||||
stream->write(&ms, sizeof(MeshStream));
|
stream->write32(&ms, sizeof(MeshStream));
|
||||||
if(geo->flags & Geometry::NATIVE){
|
if(geo->flags & Geometry::NATIVE){
|
||||||
assert(geo->instData != nil);
|
assert(geo->instData != nil);
|
||||||
if(geo->instData->platform == PLATFORM_WDGL)
|
if(geo->instData->platform == PLATFORM_WDGL)
|
||||||
stream->write(mesh->indices,
|
stream->write16(mesh->indices,
|
||||||
mesh->numIndices*2);
|
mesh->numIndices*2);
|
||||||
}else{
|
}else{
|
||||||
uint16 *ind = mesh->indices;
|
uint16 *ind = mesh->indices;
|
||||||
|
@ -185,7 +185,7 @@ writeMesh(Stream *stream, int32, void *object, int32, int32)
|
||||||
int32 n = numIndices < 256 ? numIndices : 256;
|
int32 n = numIndices < 256 ? numIndices : 256;
|
||||||
for(int32 j = 0; j < n; j++)
|
for(int32 j = 0; j < n; j++)
|
||||||
indbuf[j] = ind[j];
|
indbuf[j] = ind[j];
|
||||||
stream->write(indbuf, n*4);
|
stream->write32(indbuf, n*4);
|
||||||
ind += n;
|
ind += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,8 +450,8 @@ readNativeTexture(Stream *stream)
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
tex->filterAddressing = stream->readU32();
|
tex->filterAddressing = stream->readU32();
|
||||||
stream->read(tex->name, 32);
|
stream->read8(tex->name, 32);
|
||||||
stream->read(tex->mask, 32);
|
stream->read8(tex->mask, 32);
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
uint32 format = stream->readU32();
|
uint32 format = stream->readU32();
|
||||||
|
@ -473,7 +473,7 @@ readNativeTexture(Stream *stream)
|
||||||
size = stream->readU32();
|
size = stream->readU32();
|
||||||
if(i < raster->getNumLevels()){
|
if(i < raster->getNumLevels()){
|
||||||
data = raster->lock(i, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
data = raster->lock(i, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
||||||
stream->read(data, size);
|
stream->read8(data, size);
|
||||||
raster->unlock(i);
|
raster->unlock(i);
|
||||||
}else
|
}else
|
||||||
stream->seek(size);
|
stream->seek(size);
|
||||||
|
@ -493,8 +493,8 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
stream->writeU32(tex->filterAddressing);
|
stream->writeU32(tex->filterAddressing);
|
||||||
stream->write(tex->name, 32);
|
stream->write8(tex->name, 32);
|
||||||
stream->write(tex->mask, 32);
|
stream->write8(tex->mask, 32);
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
int32 numLevels = raster->getNumLevels();
|
int32 numLevels = raster->getNumLevels();
|
||||||
|
@ -511,7 +511,7 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
size = getLevelSize(raster, i);
|
size = getLevelSize(raster, i);
|
||||||
stream->writeU32(size);
|
stream->writeU32(size);
|
||||||
data = raster->lock(i, Raster::LOCKREAD);
|
data = raster->lock(i, Raster::LOCKREAD);
|
||||||
stream->write(data, size);
|
stream->write8(data, size);
|
||||||
raster->unlock(i);
|
raster->unlock(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,11 +257,12 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
header->ibo = 0;
|
header->ibo = 0;
|
||||||
header->numAttribs = stream->readU32();
|
header->numAttribs = stream->readU32();
|
||||||
header->attribs = rwNewT(AttribDesc, header->numAttribs, MEMDUR_EVENT | ID_GEOMETRY);
|
header->attribs = rwNewT(AttribDesc, header->numAttribs, MEMDUR_EVENT | ID_GEOMETRY);
|
||||||
stream->read(header->attribs,
|
stream->read32(header->attribs,
|
||||||
header->numAttribs*sizeof(AttribDesc));
|
header->numAttribs*sizeof(AttribDesc));
|
||||||
header->dataSize = header->attribs[0].stride*geometry->numVertices;
|
header->dataSize = header->attribs[0].stride*geometry->numVertices;
|
||||||
header->data = rwNewT(uint8, header->dataSize, MEMDUR_EVENT | ID_GEOMETRY);
|
header->data = rwNewT(uint8, header->dataSize, MEMDUR_EVENT | ID_GEOMETRY);
|
||||||
stream->read(header->data, header->dataSize);
|
ASSERTLITTLE;
|
||||||
|
stream->read8(header->data, header->dataSize);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,8 +275,9 @@ writeNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
return stream;
|
return stream;
|
||||||
InstanceDataHeader *header = (InstanceDataHeader*)geometry->instData;
|
InstanceDataHeader *header = (InstanceDataHeader*)geometry->instData;
|
||||||
stream->writeU32(header->numAttribs);
|
stream->writeU32(header->numAttribs);
|
||||||
stream->write(header->attribs, header->numAttribs*sizeof(AttribDesc));
|
stream->write32(header->attribs, header->numAttribs*sizeof(AttribDesc));
|
||||||
stream->write(header->data, header->dataSize);
|
ASSERTLITTLE;
|
||||||
|
stream->write8(header->data, header->dataSize);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,7 +557,7 @@ readNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||||
|
|
||||||
int32 numBones = stream->readI32();
|
int32 numBones = stream->readI32();
|
||||||
skin->init(numBones, 0, 0);
|
skin->init(numBones, 0, 0);
|
||||||
stream->read(skin->inverseMatrices, skin->numBones*64);
|
stream->read32(skin->inverseMatrices, skin->numBones*64);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,7 +568,7 @@ writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||||
stream->writeU32(PLATFORM_GL);
|
stream->writeU32(PLATFORM_GL);
|
||||||
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
|
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
|
||||||
stream->writeI32(skin->numBones);
|
stream->writeI32(skin->numBones);
|
||||||
stream->write(skin->inverseMatrices, skin->numBones*64);
|
stream->write32(skin->inverseMatrices, skin->numBones*64);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,8 +314,8 @@ hAnimFrameRead(Stream *stream, Animation *anim)
|
||||||
HAnimKeyFrame *frames = (HAnimKeyFrame*)anim->keyframes;
|
HAnimKeyFrame *frames = (HAnimKeyFrame*)anim->keyframes;
|
||||||
for(int32 i = 0; i < anim->numFrames; i++){
|
for(int32 i = 0; i < anim->numFrames; i++){
|
||||||
frames[i].time = stream->readF32();
|
frames[i].time = stream->readF32();
|
||||||
stream->read(&frames[i].q, 4*4);
|
stream->read32(&frames[i].q, 4*4);
|
||||||
stream->read(&frames[i].t, 3*4);
|
stream->read32(&frames[i].t, 3*4);
|
||||||
int32 prev = stream->readI32()/0x24;
|
int32 prev = stream->readI32()/0x24;
|
||||||
frames[i].prevFrame = &frames[prev];
|
frames[i].prevFrame = &frames[prev];
|
||||||
}
|
}
|
||||||
|
@ -327,8 +327,8 @@ hAnimFrameWrite(Stream *stream, Animation *anim)
|
||||||
HAnimKeyFrame *frames = (HAnimKeyFrame*)anim->keyframes;
|
HAnimKeyFrame *frames = (HAnimKeyFrame*)anim->keyframes;
|
||||||
for(int32 i = 0; i < anim->numFrames; i++){
|
for(int32 i = 0; i < anim->numFrames; i++){
|
||||||
stream->writeF32(frames[i].time);
|
stream->writeF32(frames[i].time);
|
||||||
stream->write(&frames[i].q, 4*4);
|
stream->write32(&frames[i].q, 4*4);
|
||||||
stream->write(&frames[i].t, 3*4);
|
stream->write32(&frames[i].t, 3*4);
|
||||||
stream->writeI32((frames[i].prevFrame - frames)*0x24);
|
stream->writeI32((frames[i].prevFrame - frames)*0x24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,8 +99,7 @@ struct LightChunkData
|
||||||
float32 radius;
|
float32 radius;
|
||||||
float32 red, green, blue;
|
float32 red, green, blue;
|
||||||
float32 minusCosAngle;
|
float32 minusCosAngle;
|
||||||
uint16 flags;
|
uint32 type_flags;
|
||||||
uint16 type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Light*
|
Light*
|
||||||
|
@ -113,8 +112,8 @@ Light::streamRead(Stream *stream)
|
||||||
RWERROR((ERR_CHUNK, "STRUCT"));
|
RWERROR((ERR_CHUNK, "STRUCT"));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
stream->read(&buf, sizeof(LightChunkData));
|
stream->read32(&buf, sizeof(LightChunkData));
|
||||||
Light *light = Light::create(buf.type);
|
Light *light = Light::create(buf.type_flags>>16);
|
||||||
if(light == nil)
|
if(light == nil)
|
||||||
return nil;
|
return nil;
|
||||||
light->radius = buf.radius;
|
light->radius = buf.radius;
|
||||||
|
@ -125,7 +124,7 @@ Light::streamRead(Stream *stream)
|
||||||
else
|
else
|
||||||
// tan -> -cos
|
// tan -> -cos
|
||||||
light->minusCosAngle = -1.0f/sqrt(a*a+1.0f);
|
light->minusCosAngle = -1.0f/sqrt(a*a+1.0f);
|
||||||
light->object.object.flags = (uint8)buf.flags;
|
light->object.object.flags = (uint8)buf.type_flags;
|
||||||
if(s_plglist.streamRead(stream, light))
|
if(s_plglist.streamRead(stream, light))
|
||||||
return light;
|
return light;
|
||||||
light->destroy();
|
light->destroy();
|
||||||
|
@ -146,9 +145,9 @@ Light::streamWrite(Stream *stream)
|
||||||
buf.minusCosAngle = this->minusCosAngle;
|
buf.minusCosAngle = this->minusCosAngle;
|
||||||
else
|
else
|
||||||
buf.minusCosAngle = tan(acos(-this->minusCosAngle));
|
buf.minusCosAngle = tan(acos(-this->minusCosAngle));
|
||||||
buf.flags = this->object.object.flags;
|
buf.type_flags = (uint32)this->object.object.flags |
|
||||||
buf.type = this->object.object.subType;
|
(uint32)this->object.object.subType << 16;
|
||||||
stream->write(&buf, sizeof(LightChunkData));
|
stream->write32(&buf, sizeof(LightChunkData));
|
||||||
|
|
||||||
s_plglist.streamWrite(stream, this);
|
s_plglist.streamWrite(stream, this);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -79,6 +79,7 @@ destroyNativeData(void *object, int32, int32)
|
||||||
Stream*
|
Stream*
|
||||||
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
uint32 platform;
|
uint32 platform;
|
||||||
if(!findChunk(stream, ID_STRUCT, nil, nil)){
|
if(!findChunk(stream, ID_STRUCT, nil, nil)){
|
||||||
|
@ -100,7 +101,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
for(uint32 i = 0; i < header->numMeshes; i++){
|
for(uint32 i = 0; i < header->numMeshes; i++){
|
||||||
InstanceData *instance = &header->instanceMeshes[i];
|
InstanceData *instance = &header->instanceMeshes[i];
|
||||||
uint32 buf[2];
|
uint32 buf[2];
|
||||||
stream->read(buf, 8);
|
stream->read32(buf, 8);
|
||||||
instance->dataSize = buf[0];
|
instance->dataSize = buf[0];
|
||||||
instance->dataRaw = rwNewT(uint8, instance->dataSize+0x7F, MEMDUR_EVENT | ID_GEOMETRY);
|
instance->dataRaw = rwNewT(uint8, instance->dataSize+0x7F, MEMDUR_EVENT | ID_GEOMETRY);
|
||||||
instance->data = ALIGNPTR(instance->dataRaw, 0x80);
|
instance->data = ALIGNPTR(instance->dataRaw, 0x80);
|
||||||
|
@ -108,7 +109,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
uint32 a = (uint32)instance->data;
|
uint32 a = (uint32)instance->data;
|
||||||
assert(a % 0x10 == 0);
|
assert(a % 0x10 == 0);
|
||||||
#endif
|
#endif
|
||||||
stream->read(instance->data, instance->dataSize);
|
stream->read8(instance->data, instance->dataSize);
|
||||||
#ifdef RW_PS2
|
#ifdef RW_PS2
|
||||||
if(!buf[1])
|
if(!buf[1])
|
||||||
fixDmaOffsets(instance);
|
fixDmaOffsets(instance);
|
||||||
|
@ -123,6 +124,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||||
Stream*
|
Stream*
|
||||||
writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
writeChunkHeader(stream, ID_STRUCT, len-12);
|
writeChunkHeader(stream, ID_STRUCT, len-12);
|
||||||
if(geometry->instData == nil ||
|
if(geometry->instData == nil ||
|
||||||
|
@ -135,8 +137,8 @@ writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
uint32 buf[2];
|
uint32 buf[2];
|
||||||
buf[0] = instance->dataSize;
|
buf[0] = instance->dataSize;
|
||||||
buf[1] = unfixDmaOffsets(instance);
|
buf[1] = unfixDmaOffsets(instance);
|
||||||
stream->write(buf, 8);
|
stream->write32(buf, 8);
|
||||||
stream->write(instance->data, instance->dataSize);
|
stream->write8(instance->data, instance->dataSize);
|
||||||
#ifdef RW_PS2
|
#ifdef RW_PS2
|
||||||
if(!buf[1])
|
if(!buf[1])
|
||||||
fixDmaOffsets(instance);
|
fixDmaOffsets(instance);
|
||||||
|
@ -1243,7 +1245,7 @@ readADC(Stream *stream, int32, void *object, int32 offset, int32)
|
||||||
}
|
}
|
||||||
int32 size = adc->numBits+3 & ~3;
|
int32 size = adc->numBits+3 & ~3;
|
||||||
adc->adcBits = rwNewT(int8, size, MEMDUR_EVENT | ID_ADC);
|
adc->adcBits = rwNewT(int8, size, MEMDUR_EVENT | ID_ADC);
|
||||||
stream->read(adc->adcBits, size);
|
stream->read8(adc->adcBits, size);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1259,7 +1261,7 @@ writeADC(Stream *stream, int32 len, void *object, int32 offset, int32)
|
||||||
}
|
}
|
||||||
stream->writeI32(adc->numBits);
|
stream->writeI32(adc->numBits);
|
||||||
int32 size = adc->numBits+3 & ~3;
|
int32 size = adc->numBits+3 & ~3;
|
||||||
stream->write(adc->adcBits, size);
|
stream->write8(adc->adcBits, size);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2056,12 +2056,12 @@ readNativeTexture(Stream *stream)
|
||||||
RWERROR((ERR_CHUNK, "STRING"));
|
RWERROR((ERR_CHUNK, "STRING"));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
stream->read(tex->name, length);
|
stream->read8(tex->name, length);
|
||||||
if(!findChunk(stream, ID_STRING, &length, nil)){
|
if(!findChunk(stream, ID_STRING, &length, nil)){
|
||||||
RWERROR((ERR_CHUNK, "STRING"));
|
RWERROR((ERR_CHUNK, "STRING"));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
stream->read(tex->mask, length);
|
stream->read8(tex->mask, length);
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
StreamRasterExt streamExt;
|
StreamRasterExt streamExt;
|
||||||
|
@ -2074,7 +2074,8 @@ readNativeTexture(Stream *stream)
|
||||||
RWERROR((ERR_CHUNK, "STRUCT"));
|
RWERROR((ERR_CHUNK, "STRUCT"));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
stream->read(&streamExt, 0x40);
|
ASSERTLITTLE;
|
||||||
|
stream->read8(&streamExt, 0x40);
|
||||||
/*
|
/*
|
||||||
printf("%X %X %X %X %X %016llX %X %X %016llX %016llX %X %X %X %X\n",
|
printf("%X %X %X %X %X %016llX %X %X %016llX %016llX %X %X %X %X\n",
|
||||||
streamExt.width,
|
streamExt.width,
|
||||||
|
@ -2154,10 +2155,10 @@ streamExt.mipmapVal);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if(streamExt.type < 2){
|
if(streamExt.type < 2){
|
||||||
stream->read(raster->pixels, length);
|
stream->read8(raster->pixels, length);
|
||||||
}else{
|
}else{
|
||||||
stream->read(((Ps2Raster::PixelPtr*)raster->originalPixels)->pixels, natras->pixelSize);
|
stream->read8(((Ps2Raster::PixelPtr*)raster->originalPixels)->pixels, natras->pixelSize);
|
||||||
stream->read(raster->palette-0x50, natras->paletteSize);
|
stream->read8(raster->palette-0x50, natras->paletteSize);
|
||||||
}
|
}
|
||||||
//printf("\n");
|
//printf("\n");
|
||||||
return tex;
|
return tex;
|
||||||
|
@ -2177,10 +2178,10 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
stream->writeU32(tex->filterAddressing);
|
stream->writeU32(tex->filterAddressing);
|
||||||
int32 len = strlen(tex->name)+4 & ~3;
|
int32 len = strlen(tex->name)+4 & ~3;
|
||||||
writeChunkHeader(stream, ID_STRING, len);
|
writeChunkHeader(stream, ID_STRING, len);
|
||||||
stream->write(tex->name, len);
|
stream->write8(tex->name, len);
|
||||||
len = strlen(tex->mask)+4 & ~3;
|
len = strlen(tex->mask)+4 & ~3;
|
||||||
writeChunkHeader(stream, ID_STRING, len);
|
writeChunkHeader(stream, ID_STRING, len);
|
||||||
stream->write(tex->mask, len);
|
stream->write8(tex->mask, len);
|
||||||
|
|
||||||
int32 sz = ras->pixelSize + ras->paletteSize;
|
int32 sz = ras->pixelSize + ras->paletteSize;
|
||||||
writeChunkHeader(stream, ID_STRUCT, 12 + 64 + 12 + sz);
|
writeChunkHeader(stream, ID_STRUCT, 12 + 64 + 12 + sz);
|
||||||
|
@ -2204,14 +2205,15 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
streamExt.paletteSize = ras->paletteSize;
|
streamExt.paletteSize = ras->paletteSize;
|
||||||
streamExt.totalSize = ras->totalSize;
|
streamExt.totalSize = ras->totalSize;
|
||||||
streamExt.mipmapVal = ras->kl;
|
streamExt.mipmapVal = ras->kl;
|
||||||
stream->write(&streamExt, 64);
|
ASSERTLITTLE;
|
||||||
|
stream->write8(&streamExt, 64);
|
||||||
|
|
||||||
writeChunkHeader(stream, ID_STRUCT, sz);
|
writeChunkHeader(stream, ID_STRUCT, sz);
|
||||||
if(streamExt.type < 2){
|
if(streamExt.type < 2){
|
||||||
stream->write(raster->pixels, sz);
|
stream->write8(raster->pixels, sz);
|
||||||
}else{
|
}else{
|
||||||
stream->write(((Ps2Raster::PixelPtr*)raster->originalPixels)->pixels, ras->pixelSize);
|
stream->write8(((Ps2Raster::PixelPtr*)raster->originalPixels)->pixels, ras->pixelSize);
|
||||||
stream->write(raster->palette-0x50, ras->paletteSize);
|
stream->write8(raster->palette-0x50, ras->paletteSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ readNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||||
RWERROR((ERR_PLATFORM, platform));
|
RWERROR((ERR_PLATFORM, platform));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
stream->read(header, 4);
|
stream->read8(header, 4);
|
||||||
Skin *skin = rwNewT(Skin, 1, MEMDUR_EVENT | ID_SKIN);
|
Skin *skin = rwNewT(Skin, 1, MEMDUR_EVENT | ID_SKIN);
|
||||||
*PLUGINOFFSET(Skin*, geometry, offset) = skin;
|
*PLUGINOFFSET(Skin*, geometry, offset) = skin;
|
||||||
|
|
||||||
|
@ -98,9 +98,9 @@ readNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||||
skin->numWeights = header[2];
|
skin->numWeights = header[2];
|
||||||
|
|
||||||
if(!oldFormat)
|
if(!oldFormat)
|
||||||
stream->read(skin->usedBones, skin->numUsedBones);
|
stream->read8(skin->usedBones, skin->numUsedBones);
|
||||||
if(skin->numBones)
|
if(skin->numBones)
|
||||||
stream->read(skin->inverseMatrices, skin->numBones*64);
|
stream->read32(skin->inverseMatrices, skin->numBones*64);
|
||||||
|
|
||||||
// dummy data in case we need to write data in the new format
|
// dummy data in case we need to write data in the new format
|
||||||
if(oldFormat){
|
if(oldFormat){
|
||||||
|
@ -137,14 +137,14 @@ writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||||
header[2] = skin->numWeights;
|
header[2] = skin->numWeights;
|
||||||
}
|
}
|
||||||
header[3] = 0;
|
header[3] = 0;
|
||||||
stream->write(header, 4);
|
stream->write8(header, 4);
|
||||||
|
|
||||||
if(!oldFormat)
|
if(!oldFormat)
|
||||||
stream->write(skin->usedBones, skin->numUsedBones);
|
stream->write8(skin->usedBones, skin->numUsedBones);
|
||||||
stream->write(skin->inverseMatrices, skin->numBones*64);
|
stream->write32(skin->inverseMatrices, skin->numBones*64);
|
||||||
if(!oldFormat){
|
if(!oldFormat){
|
||||||
uint32 buffer[4] = { 0, 0, 0, 0, };
|
uint32 buffer[4] = { 0, 0, 0, 0, };
|
||||||
stream->write(buffer, 4*4);
|
stream->write32(buffer, 4*4);
|
||||||
|
|
||||||
writeSkinSplitData(stream, skin);
|
writeSkinSplitData(stream, skin);
|
||||||
}
|
}
|
||||||
|
|
42
src/rwbase.h
42
src/rwbase.h
|
@ -404,6 +404,29 @@ enum PrimitiveType
|
||||||
PRIMTYPEPOINTLIST
|
PRIMTYPEPOINTLIST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Memory
|
||||||
|
*/
|
||||||
|
|
||||||
|
void memNative32_func(void *data, uint32 size);
|
||||||
|
void memNative16_func(void *data, uint32 size);
|
||||||
|
void memLittle32_func(void *data, uint32 size);
|
||||||
|
void memLittle16_func(void *data, uint32 size);
|
||||||
|
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
inline void memNative32(void *data, uint32 size) { memNative32_func(data, size); }
|
||||||
|
inline void memNative16(void *data, uint32 size) { memNative16_func(data, size); }
|
||||||
|
inline void memLittle32(void *data, uint32 size) { memLittle32_func(data, size); }
|
||||||
|
inline void memLittle16(void *data, uint32 size) { memLittle16_func(data, size); }
|
||||||
|
#define ASSERTLITTLE assert(0 && "unsafe code on big-endian")
|
||||||
|
#else
|
||||||
|
inline void memNative32(void *data, uint32 size) { }
|
||||||
|
inline void memNative16(void *data, uint32 size) { }
|
||||||
|
inline void memLittle32(void *data, uint32 size) { }
|
||||||
|
inline void memLittle16(void *data, uint32 size) { }
|
||||||
|
#define ASSERTLITTLE
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Streams
|
* Streams
|
||||||
*/
|
*/
|
||||||
|
@ -413,12 +436,17 @@ void makePath(char *filename);
|
||||||
class Stream
|
class Stream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void close(void) = 0;
|
virtual ~Stream(void) { close(); }
|
||||||
virtual uint32 write(const void *data, uint32 length) = 0;
|
virtual void close(void) {}
|
||||||
virtual uint32 read(void *data, uint32 length) = 0;
|
virtual uint32 write8(const void *data, uint32 length) = 0;
|
||||||
|
virtual uint32 read8(void *data, uint32 length) = 0;
|
||||||
virtual void seek(int32 offset, int32 whence = 1) = 0;
|
virtual void seek(int32 offset, int32 whence = 1) = 0;
|
||||||
virtual uint32 tell(void) = 0;
|
virtual uint32 tell(void) = 0;
|
||||||
virtual bool eof(void) = 0;
|
virtual bool eof(void) = 0;
|
||||||
|
uint32 write32(const void *data, uint32 length);
|
||||||
|
uint32 write16(const void *data, uint32 length);
|
||||||
|
uint32 read32(void *data, uint32 length);
|
||||||
|
uint32 read16(void *data, uint32 length);
|
||||||
int32 writeI8(int8 val);
|
int32 writeI8(int8 val);
|
||||||
int32 writeU8(uint8 val);
|
int32 writeU8(uint8 val);
|
||||||
int32 writeI16(int16 val);
|
int32 writeI16(int16 val);
|
||||||
|
@ -443,8 +471,8 @@ class StreamMemory : public Stream
|
||||||
uint32 position;
|
uint32 position;
|
||||||
public:
|
public:
|
||||||
void close(void);
|
void close(void);
|
||||||
uint32 write(const void *data, uint32 length);
|
uint32 write8(const void *data, uint32 length);
|
||||||
uint32 read(void *data, uint32 length);
|
uint32 read8(void *data, uint32 length);
|
||||||
void seek(int32 offset, int32 whence = 1);
|
void seek(int32 offset, int32 whence = 1);
|
||||||
uint32 tell(void);
|
uint32 tell(void);
|
||||||
bool eof(void);
|
bool eof(void);
|
||||||
|
@ -462,8 +490,8 @@ class StreamFile : public Stream
|
||||||
public:
|
public:
|
||||||
StreamFile(void) { file = nil; }
|
StreamFile(void) { file = nil; }
|
||||||
void close(void);
|
void close(void);
|
||||||
uint32 write(const void *data, uint32 length);
|
uint32 write8(const void *data, uint32 length);
|
||||||
uint32 read(void *data, uint32 length);
|
uint32 read8(void *data, uint32 length);
|
||||||
void seek(int32 offset, int32 whence = 1);
|
void seek(int32 offset, int32 whence = 1);
|
||||||
uint32 tell(void);
|
uint32 tell(void);
|
||||||
bool eof(void);
|
bool eof(void);
|
||||||
|
|
24
src/skin.cpp
24
src/skin.cpp
|
@ -84,7 +84,7 @@ readSkinSplitData(Stream *stream, Skin *skin)
|
||||||
if(skin->numMeshes){
|
if(skin->numMeshes){
|
||||||
sz = skin->numBones + 2*(skin->numMeshes+skin->rleSize);
|
sz = skin->numBones + 2*(skin->numMeshes+skin->rleSize);
|
||||||
data = (int8*)rwMalloc(sz, MEMDUR_EVENT | ID_SKIN);
|
data = (int8*)rwMalloc(sz, MEMDUR_EVENT | ID_SKIN);
|
||||||
stream->read(data, sz);
|
stream->read8(data, sz);
|
||||||
skin->remapIndices = data;
|
skin->remapIndices = data;
|
||||||
skin->rleCount = (Skin::RLEcount*)(data + skin->numBones);
|
skin->rleCount = (Skin::RLEcount*)(data + skin->numBones);
|
||||||
skin->rle = (Skin::RLE*)(data + skin->numBones + 2*skin->numMeshes);
|
skin->rle = (Skin::RLE*)(data + skin->numBones + 2*skin->numMeshes);
|
||||||
|
@ -99,7 +99,7 @@ writeSkinSplitData(Stream *stream, Skin *skin)
|
||||||
stream->writeI32(skin->numMeshes);
|
stream->writeI32(skin->numMeshes);
|
||||||
stream->writeI32(skin->rleSize);
|
stream->writeI32(skin->rleSize);
|
||||||
if(skin->numMeshes)
|
if(skin->numMeshes)
|
||||||
stream->write(skin->remapIndices,
|
stream->write8(skin->remapIndices,
|
||||||
skin->numBones + 2*(skin->numMeshes+skin->rleSize));
|
skin->numBones + 2*(skin->numMeshes+skin->rleSize));
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ readSkin(Stream *stream, int32 len, void *object, int32 offset, int32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->read(header, 4); // numBones, numUsedBones,
|
stream->read8(header, 4); // numBones, numUsedBones,
|
||||||
// numWeights, unused
|
// numWeights, unused
|
||||||
Skin *skin = rwNewT(Skin, 1, MEMDUR_EVENT | ID_SKIN);
|
Skin *skin = rwNewT(Skin, 1, MEMDUR_EVENT | ID_SKIN);
|
||||||
*PLUGINOFFSET(Skin*, geometry, offset) = skin;
|
*PLUGINOFFSET(Skin*, geometry, offset) = skin;
|
||||||
|
@ -150,15 +150,15 @@ readSkin(Stream *stream, int32 len, void *object, int32 offset, int32)
|
||||||
skin->numWeights = header[2];
|
skin->numWeights = header[2];
|
||||||
|
|
||||||
if(!oldFormat)
|
if(!oldFormat)
|
||||||
stream->read(skin->usedBones, skin->numUsedBones);
|
stream->read8(skin->usedBones, skin->numUsedBones);
|
||||||
if(skin->indices)
|
if(skin->indices)
|
||||||
stream->read(skin->indices, geometry->numVertices*4);
|
stream->read8(skin->indices, geometry->numVertices*4);
|
||||||
if(skin->weights)
|
if(skin->weights)
|
||||||
stream->read(skin->weights, geometry->numVertices*16);
|
stream->read32(skin->weights, geometry->numVertices*16);
|
||||||
for(int32 i = 0; i < skin->numBones; i++){
|
for(int32 i = 0; i < skin->numBones; i++){
|
||||||
if(oldFormat)
|
if(oldFormat)
|
||||||
stream->seek(4); // skip 0xdeaddead
|
stream->seek(4); // skip 0xdeaddead
|
||||||
stream->read(&skin->inverseMatrices[i*16], 64);
|
stream->read32(&skin->inverseMatrices[i*16], 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(oldFormat){
|
if(oldFormat){
|
||||||
|
@ -203,15 +203,15 @@ writeSkin(Stream *stream, int32 len, void *object, int32 offset, int32)
|
||||||
header[2] = skin->numWeights;
|
header[2] = skin->numWeights;
|
||||||
}
|
}
|
||||||
header[3] = 0;
|
header[3] = 0;
|
||||||
stream->write(header, 4);
|
stream->write8(header, 4);
|
||||||
if(!oldFormat)
|
if(!oldFormat)
|
||||||
stream->write(skin->usedBones, skin->numUsedBones);
|
stream->write8(skin->usedBones, skin->numUsedBones);
|
||||||
stream->write(skin->indices, geometry->numVertices*4);
|
stream->write8(skin->indices, geometry->numVertices*4);
|
||||||
stream->write(skin->weights, geometry->numVertices*16);
|
stream->write32(skin->weights, geometry->numVertices*16);
|
||||||
for(int32 i = 0; i < skin->numBones; i++){
|
for(int32 i = 0; i < skin->numBones; i++){
|
||||||
if(oldFormat)
|
if(oldFormat)
|
||||||
stream->writeU32(0xdeaddead);
|
stream->writeU32(0xdeaddead);
|
||||||
stream->write(&skin->inverseMatrices[i*16], 64);
|
stream->write32(&skin->inverseMatrices[i*16], 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!oldFormat)
|
if(!oldFormat)
|
||||||
|
|
|
@ -379,13 +379,13 @@ Texture::streamRead(Stream *stream)
|
||||||
RWERROR((ERR_CHUNK, "STRING"));
|
RWERROR((ERR_CHUNK, "STRING"));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
stream->read(name, length);
|
stream->read8(name, length);
|
||||||
|
|
||||||
if(!findChunk(stream, ID_STRING, &length, nil)){
|
if(!findChunk(stream, ID_STRING, &length, nil)){
|
||||||
RWERROR((ERR_CHUNK, "STRING"));
|
RWERROR((ERR_CHUNK, "STRING"));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
stream->read(mask, length);
|
stream->read8(mask, length);
|
||||||
|
|
||||||
Texture *tex = Texture::read(name, mask);
|
Texture *tex = Texture::read(name, mask);
|
||||||
if(tex == nil){
|
if(tex == nil){
|
||||||
|
@ -415,13 +415,13 @@ Texture::streamWrite(Stream *stream)
|
||||||
strncpy(buf, this->name, 32);
|
strncpy(buf, this->name, 32);
|
||||||
size = strlen(buf)+4 & ~3;
|
size = strlen(buf)+4 & ~3;
|
||||||
writeChunkHeader(stream, ID_STRING, size);
|
writeChunkHeader(stream, ID_STRING, size);
|
||||||
stream->write(buf, size);
|
stream->write8(buf, size);
|
||||||
|
|
||||||
memset(buf, 0, 36);
|
memset(buf, 0, 36);
|
||||||
strncpy(buf, this->mask, 32);
|
strncpy(buf, this->mask, 32);
|
||||||
size = strlen(buf)+4 & ~3;
|
size = strlen(buf)+4 & ~3;
|
||||||
writeChunkHeader(stream, ID_STRING, size);
|
writeChunkHeader(stream, ID_STRING, size);
|
||||||
stream->write(buf, size);
|
stream->write8(buf, size);
|
||||||
|
|
||||||
s_plglist.streamWrite(stream, this);
|
s_plglist.streamWrite(stream, this);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -47,6 +47,7 @@ struct PACKED_STRUCT TGAHeader
|
||||||
Image*
|
Image*
|
||||||
readTGA(const char *afilename)
|
readTGA(const char *afilename)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
TGAHeader header;
|
TGAHeader header;
|
||||||
Image *image;
|
Image *image;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
@ -60,7 +61,7 @@ readTGA(const char *afilename)
|
||||||
rwFree(filename);
|
rwFree(filename);
|
||||||
StreamMemory file;
|
StreamMemory file;
|
||||||
file.open(data, length);
|
file.open(data, length);
|
||||||
file.read(&header, sizeof(header));
|
file.read8(&header, sizeof(header));
|
||||||
|
|
||||||
assert(header.imageType == 1 || header.imageType == 2);
|
assert(header.imageType == 1 || header.imageType == 2);
|
||||||
file.seek(header.IDlen);
|
file.seek(header.IDlen);
|
||||||
|
@ -125,6 +126,7 @@ readTGA(const char *afilename)
|
||||||
void
|
void
|
||||||
writeTGA(Image *image, const char *filename)
|
writeTGA(Image *image, const char *filename)
|
||||||
{
|
{
|
||||||
|
ASSERTLITTLE;
|
||||||
TGAHeader header;
|
TGAHeader header;
|
||||||
StreamFile file;
|
StreamFile file;
|
||||||
if(!file.open(filename, "wb")){
|
if(!file.open(filename, "wb")){
|
||||||
|
@ -144,7 +146,7 @@ writeTGA(Image *image, const char *filename)
|
||||||
header.height = image->height;
|
header.height = image->height;
|
||||||
header.depth = image->depth == 4 ? 8 : image->depth;
|
header.depth = image->depth == 4 ? 8 : image->depth;
|
||||||
header.descriptor = 0x20 | (image->depth == 32 ? 8 : 0);
|
header.descriptor = 0x20 | (image->depth == 32 ? 8 : 0);
|
||||||
file.write(&header, sizeof(header));
|
file.write8(&header, sizeof(header));
|
||||||
|
|
||||||
uint8 *palette = header.colorMapType ? image->palette : nil;
|
uint8 *palette = header.colorMapType ? image->palette : nil;
|
||||||
uint8 (*color)[4] = (uint8(*)[4])palette;;
|
uint8 (*color)[4] = (uint8(*)[4])palette;;
|
||||||
|
|
|
@ -126,17 +126,17 @@ readUserData(Stream *stream, int32, void *object, int32 offset, int32)
|
||||||
for(i = 0; i < ext->numArrays; i++){
|
for(i = 0; i < ext->numArrays; i++){
|
||||||
int32 len = stream->readI32();
|
int32 len = stream->readI32();
|
||||||
a->name = (char*)udMalloc(len);
|
a->name = (char*)udMalloc(len);
|
||||||
stream->read(a->name, len);
|
stream->read8(a->name, len);
|
||||||
a->datatype = stream->readU32();
|
a->datatype = stream->readU32();
|
||||||
a->numElements = stream->readI32();
|
a->numElements = stream->readI32();
|
||||||
switch(a->datatype){
|
switch(a->datatype){
|
||||||
case USERDATAINT:
|
case USERDATAINT:
|
||||||
a->data = (int32*)udMalloc(sizeof(int32)*a->numElements);
|
a->data = (int32*)udMalloc(sizeof(int32)*a->numElements);
|
||||||
stream->read(a->data, sizeof(int32)*a->numElements);
|
stream->read32(a->data, sizeof(int32)*a->numElements);
|
||||||
break;
|
break;
|
||||||
case USERDATAFLOAT:
|
case USERDATAFLOAT:
|
||||||
a->data = (float32*)udMalloc(sizeof(float32)*a->numElements);
|
a->data = (float32*)udMalloc(sizeof(float32)*a->numElements);
|
||||||
stream->read(a->data, sizeof(float32)*a->numElements);
|
stream->read32(a->data, sizeof(float32)*a->numElements);
|
||||||
break;
|
break;
|
||||||
case USERDATASTRING:
|
case USERDATASTRING:
|
||||||
strar = (char**)udMalloc(sizeof(char*)*a->numElements);
|
strar = (char**)udMalloc(sizeof(char*)*a->numElements);
|
||||||
|
@ -144,7 +144,7 @@ readUserData(Stream *stream, int32, void *object, int32 offset, int32)
|
||||||
for(j = 0; j < a->numElements; j++){
|
for(j = 0; j < a->numElements; j++){
|
||||||
len = stream->readI32();
|
len = stream->readI32();
|
||||||
strar[j] = (char*)udMalloc(len);
|
strar[j] = (char*)udMalloc(len);
|
||||||
stream->read(strar[j], len);
|
stream->read8(strar[j], len);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -166,22 +166,22 @@ writeUserData(Stream *stream, int32, void *object, int32 offset, int32)
|
||||||
for(i = 0; i < ext->numArrays; i++){
|
for(i = 0; i < ext->numArrays; i++){
|
||||||
len = (int32)strlen(a->name)+1;
|
len = (int32)strlen(a->name)+1;
|
||||||
stream->writeI32(len);
|
stream->writeI32(len);
|
||||||
stream->write(a->name, len);
|
stream->write8(a->name, len);
|
||||||
stream->writeU32(a->datatype);
|
stream->writeU32(a->datatype);
|
||||||
stream->writeI32(a->numElements);
|
stream->writeI32(a->numElements);
|
||||||
switch(a->datatype){
|
switch(a->datatype){
|
||||||
case USERDATAINT:
|
case USERDATAINT:
|
||||||
stream->write(a->data, sizeof(int32)*a->numElements);
|
stream->write32(a->data, sizeof(int32)*a->numElements);
|
||||||
break;
|
break;
|
||||||
case USERDATAFLOAT:
|
case USERDATAFLOAT:
|
||||||
stream->write(a->data, sizeof(float32)*a->numElements);
|
stream->write32(a->data, sizeof(float32)*a->numElements);
|
||||||
break;
|
break;
|
||||||
case USERDATASTRING:
|
case USERDATASTRING:
|
||||||
strar = (char**)a->data;
|
strar = (char**)a->data;
|
||||||
for(j = 0; j < a->numElements; j++){
|
for(j = 0; j < a->numElements; j++){
|
||||||
len = (int32)strlen(strar[j])+1;
|
len = (int32)strlen(strar[j])+1;
|
||||||
stream->writeI32(len);
|
stream->writeI32(len);
|
||||||
stream->write(strar[j], len);
|
stream->write8(strar[j], len);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,13 +134,13 @@ uvAnimStreamRead(Stream *stream, Animation *anim)
|
||||||
UVAnimCustomData *custom = UVAnimCustomData::get(anim);
|
UVAnimCustomData *custom = UVAnimCustomData::get(anim);
|
||||||
UVAnimKeyFrame *frames = (UVAnimKeyFrame*)anim->keyframes;
|
UVAnimKeyFrame *frames = (UVAnimKeyFrame*)anim->keyframes;
|
||||||
stream->readI32();
|
stream->readI32();
|
||||||
stream->read(custom->name, 32);
|
stream->read8(custom->name, 32);
|
||||||
stream->read(custom->nodeToUVChannel, 8*4);
|
stream->read32(custom->nodeToUVChannel, 8*4);
|
||||||
custom->refCount = 1;
|
custom->refCount = 1;
|
||||||
|
|
||||||
for(int32 i = 0; i < anim->numFrames; i++){
|
for(int32 i = 0; i < anim->numFrames; i++){
|
||||||
frames[i].time = stream->readF32();
|
frames[i].time = stream->readF32();
|
||||||
stream->read(frames[i].uv, 6*4);
|
stream->read32(frames[i].uv, 6*4);
|
||||||
int32 prev = stream->readI32();
|
int32 prev = stream->readI32();
|
||||||
frames[i].prev = &frames[prev];
|
frames[i].prev = &frames[prev];
|
||||||
}
|
}
|
||||||
|
@ -152,12 +152,12 @@ uvAnimStreamWrite(Stream *stream, Animation *anim)
|
||||||
UVAnimCustomData *custom = UVAnimCustomData::get(anim);
|
UVAnimCustomData *custom = UVAnimCustomData::get(anim);
|
||||||
UVAnimKeyFrame *frames = (UVAnimKeyFrame*)anim->keyframes;
|
UVAnimKeyFrame *frames = (UVAnimKeyFrame*)anim->keyframes;
|
||||||
stream->writeI32(0);
|
stream->writeI32(0);
|
||||||
stream->write(custom->name, 32);
|
stream->write8(custom->name, 32);
|
||||||
stream->write(custom->nodeToUVChannel, 8*4);
|
stream->write32(custom->nodeToUVChannel, 8*4);
|
||||||
|
|
||||||
for(int32 i = 0; i < anim->numFrames; i++){
|
for(int32 i = 0; i < anim->numFrames; i++){
|
||||||
stream->writeF32(frames[i].time);
|
stream->writeF32(frames[i].time);
|
||||||
stream->write(frames[i].uv, 6*4);
|
stream->write32(frames[i].uv, 6*4);
|
||||||
stream->writeI32(frames[i].prev - frames);
|
stream->writeI32(frames[i].prev - frames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ readUVAnim(Stream *stream, int32, void *object, int32 offset, int32)
|
||||||
uint32 bit = 1;
|
uint32 bit = 1;
|
||||||
for(int32 i = 0; i < 8; i++){
|
for(int32 i = 0; i < 8; i++){
|
||||||
if(mask & bit){
|
if(mask & bit){
|
||||||
stream->read(name, 32);
|
stream->read8(name, 32);
|
||||||
Animation *anim = nil;
|
Animation *anim = nil;
|
||||||
if(currentUVAnimDictionary)
|
if(currentUVAnimDictionary)
|
||||||
anim = currentUVAnimDictionary->find(name);
|
anim = currentUVAnimDictionary->find(name);
|
||||||
|
@ -413,7 +413,7 @@ writeUVAnim(Stream *stream, int32 size, void *object, int32 offset, int32)
|
||||||
if(uvanim->interp[i]){
|
if(uvanim->interp[i]){
|
||||||
UVAnimCustomData *custom =
|
UVAnimCustomData *custom =
|
||||||
UVAnimCustomData::get(uvanim->interp[i]->currentAnim);
|
UVAnimCustomData::get(uvanim->interp[i]->currentAnim);
|
||||||
stream->write(custom->name, 32);
|
stream->write8(custom->name, 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stream;
|
return stream;
|
||||||
|
|
Loading…
Reference in New Issue