mirror of https://github.com/aap/librw.git
fix raster bugs
This commit is contained in:
parent
65c619b3e7
commit
cc550ff69c
|
@ -742,7 +742,7 @@ rasterFromImage(Raster *raster, Image *image)
|
||||||
}
|
}
|
||||||
|
|
||||||
D3dRaster *natras = GETD3DRASTEREXT(raster);
|
D3dRaster *natras = GETD3DRASTEREXT(raster);
|
||||||
int32 format = raster->format&0xF00;
|
int32 format = raster->format&(Raster::PAL8 | Raster::PAL4 | 0xF00);
|
||||||
switch(image->depth){
|
switch(image->depth){
|
||||||
case 32:
|
case 32:
|
||||||
if(format == Raster::C8888)
|
if(format == Raster::C8888)
|
||||||
|
@ -781,6 +781,7 @@ rasterFromImage(Raster *raster, Image *image)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err:
|
err:
|
||||||
|
fprintf(stderr, "%d %x\n", image->depth, format); fflush(stdout);
|
||||||
RWERROR((ERR_INVRASTER));
|
RWERROR((ERR_INVRASTER));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -883,8 +883,8 @@ readNativeTexture(Stream *stream)
|
||||||
RWERROR((ERR_PLATFORM, platform));
|
RWERROR((ERR_PLATFORM, platform));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if(version < 0x34001){
|
if(vers < 0x34001){
|
||||||
RWERROR((ERR_VERSION, version));
|
RWERROR((ERR_VERSION, vers));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
Texture *tex = Texture::create(nil);
|
Texture *tex = Texture::create(nil);
|
||||||
|
|
|
@ -792,7 +792,7 @@ rasterCreateTexture(Raster *raster)
|
||||||
int32 palettePagewidth, palettePageheight;
|
int32 palettePagewidth, palettePageheight;
|
||||||
|
|
||||||
|
|
||||||
Ps2Raster *ras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *ras = GETPS2RASTEREXT(raster);
|
||||||
pixelformat = raster->format & 0xF00;
|
pixelformat = raster->format & 0xF00;
|
||||||
palformat = raster->format & 0x6000;
|
palformat = raster->format & 0x6000;
|
||||||
width = raster->width;
|
width = raster->width;
|
||||||
|
@ -1375,7 +1375,7 @@ unswizzleRaster(Raster *raster)
|
||||||
int32 x, y, w, h;
|
int32 x, y, w, h;
|
||||||
int32 i;
|
int32 i;
|
||||||
int32 logw;
|
int32 logw;
|
||||||
Ps2Raster *natras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *natras = GETPS2RASTEREXT(raster);
|
||||||
uint8 *px;
|
uint8 *px;
|
||||||
|
|
||||||
if((raster->format & (Raster::PAL4|Raster::PAL8)) == 0)
|
if((raster->format & (Raster::PAL4|Raster::PAL8)) == 0)
|
||||||
|
@ -1422,7 +1422,7 @@ swizzleRaster(Raster *raster)
|
||||||
int32 x, y, w, h;
|
int32 x, y, w, h;
|
||||||
int32 i;
|
int32 i;
|
||||||
int32 logw;
|
int32 logw;
|
||||||
Ps2Raster *natras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *natras = GETPS2RASTEREXT(raster);
|
||||||
uint8 *px;
|
uint8 *px;
|
||||||
|
|
||||||
if((raster->format & (Raster::PAL4|Raster::PAL8)) == 0)
|
if((raster->format & (Raster::PAL4|Raster::PAL8)) == 0)
|
||||||
|
@ -1464,7 +1464,7 @@ swizzleRaster(Raster *raster)
|
||||||
uint8*
|
uint8*
|
||||||
rasterLock(Raster *raster, int32 level, int32 lockMode)
|
rasterLock(Raster *raster, int32 level, int32 lockMode)
|
||||||
{
|
{
|
||||||
Ps2Raster *natras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *natras = GETPS2RASTEREXT(raster);
|
||||||
assert(raster->depth != 24);
|
assert(raster->depth != 24);
|
||||||
|
|
||||||
if(level > 0){
|
if(level > 0){
|
||||||
|
@ -1490,7 +1490,7 @@ rasterLock(Raster *raster, int32 level, int32 lockMode)
|
||||||
void
|
void
|
||||||
rasterUnlock(Raster *raster, int32 level)
|
rasterUnlock(Raster *raster, int32 level)
|
||||||
{
|
{
|
||||||
Ps2Raster *natras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *natras = GETPS2RASTEREXT(raster);
|
||||||
if(raster->format & (Raster::PAL4 | Raster::PAL8))
|
if(raster->format & (Raster::PAL4 | Raster::PAL8))
|
||||||
swizzleRaster(raster);
|
swizzleRaster(raster);
|
||||||
|
|
||||||
|
@ -1615,7 +1615,7 @@ imageFindRasterFormat(Image *img, int32 type,
|
||||||
bool32
|
bool32
|
||||||
rasterFromImage(Raster *raster, Image *image)
|
rasterFromImage(Raster *raster, Image *image)
|
||||||
{
|
{
|
||||||
Ps2Raster *natras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *natras = GETPS2RASTEREXT(raster);
|
||||||
|
|
||||||
int32 pallength = 0;
|
int32 pallength = 0;
|
||||||
switch(image->depth){
|
switch(image->depth){
|
||||||
|
@ -1708,7 +1708,7 @@ rasterToImage(Raster *raster)
|
||||||
{
|
{
|
||||||
Image *image;
|
Image *image;
|
||||||
int depth;
|
int depth;
|
||||||
Ps2Raster *natras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *natras = GETPS2RASTEREXT(raster);
|
||||||
|
|
||||||
int32 rasterFormat = raster->format & 0xF00;
|
int32 rasterFormat = raster->format & 0xF00;
|
||||||
switch(rasterFormat){
|
switch(rasterFormat){
|
||||||
|
@ -1812,7 +1812,7 @@ rasterToImage(Raster *raster)
|
||||||
int32
|
int32
|
||||||
rasterNumLevels(Raster *raster)
|
rasterNumLevels(Raster *raster)
|
||||||
{
|
{
|
||||||
Ps2Raster *ras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *ras = GETPS2RASTEREXT(raster);
|
||||||
if(raster->pixels == nil) return 0;
|
if(raster->pixels == nil) return 0;
|
||||||
if(raster->format & Raster::MIPMAP)
|
if(raster->format & Raster::MIPMAP)
|
||||||
return MAXLEVEL(ras)+1;
|
return MAXLEVEL(ras)+1;
|
||||||
|
@ -1822,7 +1822,7 @@ rasterNumLevels(Raster *raster)
|
||||||
static void*
|
static void*
|
||||||
createNativeRaster(void *object, int32 offset, int32)
|
createNativeRaster(void *object, int32 offset, int32)
|
||||||
{
|
{
|
||||||
Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, object, offset);
|
Ps2Raster *raster = GETPS2RASTEREXT(object);
|
||||||
raster->tex0 = 0;
|
raster->tex0 = 0;
|
||||||
raster->paletteBase = 0;
|
raster->paletteBase = 0;
|
||||||
raster->kl = defaultMipMapKL;
|
raster->kl = defaultMipMapKL;
|
||||||
|
@ -1843,7 +1843,7 @@ createNativeRaster(void *object, int32 offset, int32)
|
||||||
static void*
|
static void*
|
||||||
destroyNativeRaster(void *object, int32 offset, int32)
|
destroyNativeRaster(void *object, int32 offset, int32)
|
||||||
{
|
{
|
||||||
Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, object, offset);
|
Ps2Raster *raster = GETPS2RASTEREXT(object);
|
||||||
freealign(raster->data);
|
freealign(raster->data);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
@ -1851,8 +1851,8 @@ destroyNativeRaster(void *object, int32 offset, int32)
|
||||||
static void*
|
static void*
|
||||||
copyNativeRaster(void *dst, void *src, int32 offset, int32)
|
copyNativeRaster(void *dst, void *src, int32 offset, int32)
|
||||||
{
|
{
|
||||||
Ps2Raster *dstraster = PLUGINOFFSET(Ps2Raster, dst, offset);
|
Ps2Raster *dstraster = GETPS2RASTEREXT(dst);
|
||||||
Ps2Raster *srcraster = PLUGINOFFSET(Ps2Raster, src, offset);
|
Ps2Raster *srcraster = GETPS2RASTEREXT(src);
|
||||||
*dstraster = *srcraster;
|
*dstraster = *srcraster;
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
@ -1864,7 +1864,7 @@ readMipmap(Stream *stream, int32, void *object, int32 offset, int32)
|
||||||
Texture *tex = (Texture*)object;
|
Texture *tex = (Texture*)object;
|
||||||
if(tex->raster == nil)
|
if(tex->raster == nil)
|
||||||
return stream;
|
return stream;
|
||||||
Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, offset);
|
Ps2Raster *raster = GETPS2RASTEREXT(tex->raster);
|
||||||
raster->kl = val;
|
raster->kl = val;
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
@ -1877,7 +1877,7 @@ writeMipmap(Stream *stream, int32, void *object, int32 offset, int32)
|
||||||
stream->writeI32(defaultMipMapKL);
|
stream->writeI32(defaultMipMapKL);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
Ps2Raster *raster = PLUGINOFFSET(Ps2Raster, tex->raster, offset);
|
Ps2Raster *raster = GETPS2RASTEREXT(tex->raster);
|
||||||
stream->writeI32(raster->kl);
|
stream->writeI32(raster->kl);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
@ -1947,7 +1947,7 @@ calcTEX1(Raster *raster, uint64 *tex1, int32 filter)
|
||||||
LINEAR_MIPMAP_NEAREST,
|
LINEAR_MIPMAP_NEAREST,
|
||||||
LINEAR_MIPMAP_LINEAR,
|
LINEAR_MIPMAP_LINEAR,
|
||||||
};
|
};
|
||||||
Ps2Raster *natras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *natras = GETPS2RASTEREXT(raster);
|
||||||
uint64 t1 = natras->tex1low;
|
uint64 t1 = natras->tex1low;
|
||||||
uint64 k = natras->kl & 0xFFF;
|
uint64 k = natras->kl & 0xFFF;
|
||||||
uint64 l = (natras->kl >> 12) & 0x3;
|
uint64 l = (natras->kl >> 12) & 0x3;
|
||||||
|
@ -2071,7 +2071,7 @@ streamExt.mipmapVal);
|
||||||
noNewStyleRasters = 0;
|
noNewStyleRasters = 0;
|
||||||
rw::version = oldversion;
|
rw::version = oldversion;
|
||||||
tex->raster = raster;
|
tex->raster = raster;
|
||||||
natras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
natras = GETPS2RASTEREXT(raster);
|
||||||
//printf("%X %X\n", natras->paletteBase, natras->tex1low);
|
//printf("%X %X\n", natras->paletteBase, natras->tex1low);
|
||||||
// printf("%08X%08X %08X%08X %08X%08X\n",
|
// printf("%08X%08X %08X%08X %08X%08X\n",
|
||||||
// (uint32)natras->tex0, (uint32)(natras->tex0>>32),
|
// (uint32)natras->tex0, (uint32)(natras->tex0>>32),
|
||||||
|
@ -2176,7 +2176,7 @@ void
|
||||||
writeNativeTexture(Texture *tex, Stream *stream)
|
writeNativeTexture(Texture *tex, Stream *stream)
|
||||||
{
|
{
|
||||||
Raster *raster = tex->raster;
|
Raster *raster = tex->raster;
|
||||||
Ps2Raster *ras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
|
Ps2Raster *ras = GETPS2RASTEREXT(raster);
|
||||||
writeChunkHeader(stream, ID_STRUCT, 8);
|
writeChunkHeader(stream, ID_STRUCT, 8);
|
||||||
stream->writeU32(FOURCC_PS2);
|
stream->writeU32(FOURCC_PS2);
|
||||||
stream->writeU32(tex->filterAddressing);
|
stream->writeU32(tex->filterAddressing);
|
||||||
|
@ -2229,7 +2229,7 @@ getSizeNativeTexture(Texture *tex)
|
||||||
size += 12 + strlen(tex->mask)+4 & ~3;
|
size += 12 + strlen(tex->mask)+4 & ~3;
|
||||||
size += 12;
|
size += 12;
|
||||||
size += 12 + 64;
|
size += 12 + 64;
|
||||||
Ps2Raster *ras = PLUGINOFFSET(Ps2Raster, tex->raster, nativeRasterOffset);
|
Ps2Raster *ras = GETPS2RASTEREXT(tex->raster);
|
||||||
size += 12 + ras->pixelSize + ras->paletteSize;
|
size += 12 + ras->pixelSize + ras->paletteSize;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,6 +248,7 @@ struct Ps2Raster
|
||||||
|
|
||||||
extern int32 nativeRasterOffset;
|
extern int32 nativeRasterOffset;
|
||||||
void registerNativeRaster(void);
|
void registerNativeRaster(void);
|
||||||
|
#define GETPS2RASTEREXT(raster) PLUGINOFFSET(rw::ps2::Ps2Raster, raster, rw::ps2::nativeRasterOffset)
|
||||||
|
|
||||||
Texture *readNativeTexture(Stream *stream);
|
Texture *readNativeTexture(Stream *stream);
|
||||||
void writeNativeTexture(Texture *tex, Stream *stream);
|
void writeNativeTexture(Texture *tex, Stream *stream);
|
||||||
|
|
|
@ -391,7 +391,6 @@ copyPal8(uint8 *dst, uint32 dststride, uint8 *src, uint32 srcstride, int32 w, in
|
||||||
static rw::Raster*
|
static rw::Raster*
|
||||||
xbox_to_d3d(rw::Raster *ras)
|
xbox_to_d3d(rw::Raster *ras)
|
||||||
{
|
{
|
||||||
#ifdef RW_D3D9
|
|
||||||
using namespace rw;
|
using namespace rw;
|
||||||
|
|
||||||
int dxt = 0;
|
int dxt = 0;
|
||||||
|
@ -420,9 +419,6 @@ xbox_to_d3d(rw::Raster *ras)
|
||||||
}
|
}
|
||||||
|
|
||||||
return newras;
|
return newras;
|
||||||
#else
|
|
||||||
return nil;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static rw::Raster*
|
static rw::Raster*
|
||||||
|
|
|
@ -486,11 +486,12 @@ public:
|
||||||
|
|
||||||
class StreamMemory : public Stream
|
class StreamMemory : public Stream
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
uint32 length;
|
uint32 length;
|
||||||
uint32 capacity;
|
uint32 capacity;
|
||||||
uint32 position;
|
uint32 position;
|
||||||
public:
|
|
||||||
void close(void);
|
void close(void);
|
||||||
uint32 write8(const void *data, uint32 length);
|
uint32 write8(const void *data, uint32 length);
|
||||||
uint32 read8(void *data, uint32 length);
|
uint32 read8(void *data, uint32 length);
|
||||||
|
@ -507,8 +508,9 @@ public:
|
||||||
|
|
||||||
class StreamFile : public Stream
|
class StreamFile : public Stream
|
||||||
{
|
{
|
||||||
FILE *file;
|
|
||||||
public:
|
public:
|
||||||
|
FILE *file;
|
||||||
|
|
||||||
StreamFile(void) { file = nil; }
|
StreamFile(void) { file = nil; }
|
||||||
void close(void);
|
void close(void);
|
||||||
uint32 write8(const void *data, uint32 length);
|
uint32 write8(const void *data, uint32 length);
|
||||||
|
|
Loading…
Reference in New Issue