mirror of
https://github.com/aap/librw.git
synced 2024-11-24 20:55:41 +00:00
Merge branch 'master' into stencil-fix
This commit is contained in:
commit
5408e70227
@ -665,7 +665,7 @@ correctPathCase(char *filename)
|
||||
sofar[2] = '\0';
|
||||
arg++;
|
||||
}
|
||||
while(dir = strtok(arg, PSEP_S)){
|
||||
while((dir = strtok(arg, PSEP_S))){
|
||||
arg = nil;
|
||||
if(direct = opendir(sofar), dir == nil)
|
||||
return;
|
||||
|
@ -247,7 +247,7 @@ writeBMP(Image *image, const char *filename)
|
||||
for(int x = 0; x < image->width; x++){
|
||||
switch(image->depth){
|
||||
case 4:
|
||||
file.writeU8((p[0]&0xF)<<4 | p[1]&0xF);
|
||||
file.writeU8((p[0]&0xF)<<4 | (p[1]&0xF));
|
||||
p += 2;
|
||||
x++;
|
||||
break;
|
||||
|
@ -278,7 +278,7 @@ struct RasterFormatInfo
|
||||
|
||||
// indexed directly by RW format
|
||||
static RasterFormatInfo formatInfoRW[16] = {
|
||||
{ 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ D3DFMT_A1R5G5B5, 16, 1, Raster::C1555 },
|
||||
{ D3DFMT_R5G6B5, 16, 0, Raster::C565 },
|
||||
{ D3DFMT_A4R4G4B4, 16, 1, Raster::C4444 },
|
||||
@ -345,7 +345,7 @@ findFormatInfoD3D(uint32 d3dformat)
|
||||
{
|
||||
static RasterFormatInfo fake = { 0, 0, 0, 0 };
|
||||
int i;
|
||||
for(i = 0; i < nelem(formatInfoFull); i++)
|
||||
for(i = 0; i < (int)nelem(formatInfoFull); i++)
|
||||
if(formatInfoFull[i].d3dformat == d3dformat)
|
||||
return &formatInfoFull[i];
|
||||
return &fake;
|
||||
|
@ -532,7 +532,7 @@ struct RasterFormatInfo
|
||||
|
||||
// indexed directly by RW format
|
||||
static RasterFormatInfo formatInfoRW[16] = {
|
||||
{ 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ D3DFMT_A1R5G5B5, 16, 1, Raster::C1555 },
|
||||
{ D3DFMT_R5G6B5, 16, 0, Raster::C565 },
|
||||
{ D3DFMT_A4R4G4B4, 16, 1, Raster::C4444 },
|
||||
@ -789,7 +789,7 @@ rasterToImage(Raster *raster)
|
||||
uint8 *pixels = raster->pixels;
|
||||
|
||||
// NB:
|
||||
assert(image->bpp == natras->bpp);
|
||||
assert(image->bpp == (int)natras->bpp);
|
||||
assert(image->stride == raster->stride);
|
||||
unswizzle(imgpixels, pixels, image->width, image->height, image->bpp);
|
||||
// Fix RGB order
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <new>
|
||||
|
||||
@ -130,7 +131,7 @@ printleaks(void)
|
||||
{
|
||||
FORLIST(lnk, allocations){
|
||||
MemoryBlock *mem = LLLinkGetData(lnk, MemoryBlock, inAllocList);
|
||||
printf("sz %d hint %X\n %s\n", mem->sz, mem->hint, mem->codeline);
|
||||
printf("sz %zu hint %X\n %s\n", mem->sz, mem->hint, mem->codeline);
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,6 +157,15 @@ void *mustrealloc_h(void *p, size_t sz, uint32 hint)
|
||||
return nil;
|
||||
}
|
||||
|
||||
char *strdup_LOC(const char *s, uint32 hint, const char *here) {
|
||||
char *t;
|
||||
size_t sz = strlen(s)+1;
|
||||
t = (char*)malloc_LOC(sz, hint, here);
|
||||
if(t)
|
||||
memcpy(t, s, sz);
|
||||
return t;
|
||||
}
|
||||
|
||||
MemoryFunctions defaultMemfuncs = {
|
||||
malloc_h,
|
||||
realloc_h,
|
||||
@ -527,6 +537,7 @@ deviceSystem(DeviceReq req, void *arg0, int32 n)
|
||||
return 0;
|
||||
case DEVICEGETSUBSSYSTEMINFO:
|
||||
return 0;
|
||||
default: break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ Geometry::generateTriangles(int8 *adc)
|
||||
int32 matid = this->matList.findIndex(m->material);
|
||||
if(header->flags == MeshHeader::TRISTRIP)
|
||||
for(uint32 j = 0; j < m->numIndices-2; j++){
|
||||
if(adc && adcbits[j+2] ||
|
||||
if((adc && adcbits[j+2]) ||
|
||||
isDegenerate(&m->indices[j]))
|
||||
continue;
|
||||
tri->v[0] = m->indices[j+0];
|
||||
|
@ -33,7 +33,7 @@ registerUniform(const char *name)
|
||||
assert(0 && "no space for uniform");
|
||||
return -1;
|
||||
}
|
||||
uniformRegistry.uniformNames[uniformRegistry.numUniforms] = strdup(name);
|
||||
uniformRegistry.uniformNames[uniformRegistry.numUniforms] = rwStrdup(name, MEMDUR_EVENT);
|
||||
return uniformRegistry.numUniforms++;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ registerBlock(const char *name)
|
||||
// TODO: print error
|
||||
if(uniformRegistry.numBlocks+1 >= MAX_BLOCKS)
|
||||
return -1;
|
||||
uniformRegistry.blockNames[uniformRegistry.numBlocks] = strdup(name);
|
||||
uniformRegistry.blockNames[uniformRegistry.numBlocks] = rwStrdup(name, MEMDUR_EVENT);
|
||||
return uniformRegistry.numBlocks++;
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ getSizeHAnim(void *object, int32 offset, int32)
|
||||
{
|
||||
HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset);
|
||||
if(!hAnimDoStream ||
|
||||
version >= 0x35000 && hanim->id == -1 && hanim->hierarchy == nil)
|
||||
(version >= 0x35000 && hanim->id == -1 && hanim->hierarchy == nil))
|
||||
return 0;
|
||||
if(hanim->hierarchy)
|
||||
return 12 + 8 + hanim->hierarchy->numNodes*12;
|
||||
|
@ -894,17 +894,6 @@ Image::extractMask(void)
|
||||
return img;
|
||||
}
|
||||
|
||||
static char*
|
||||
rwstrdup(const char *s)
|
||||
{
|
||||
char *t;
|
||||
size_t len = strlen(s)+1;
|
||||
t = (char*)rwMalloc(len, MEMDUR_EVENT);
|
||||
if(t)
|
||||
memcpy(t, s, len);
|
||||
return t;
|
||||
}
|
||||
|
||||
void
|
||||
Image::setSearchPath(const char *path)
|
||||
{
|
||||
@ -913,7 +902,7 @@ Image::setSearchPath(const char *path)
|
||||
rwFree(g->searchPaths);
|
||||
g->numSearchPaths = 0;
|
||||
if(path)
|
||||
g->searchPaths = p = rwstrdup(path);
|
||||
g->searchPaths = p = rwStrdup(path, MEMDUR_EVENT);
|
||||
else{
|
||||
g->searchPaths = nil;
|
||||
return;
|
||||
@ -946,7 +935,7 @@ Image::getFilename(const char *name)
|
||||
char *s, *p = g->searchPaths;
|
||||
size_t len = strlen(name)+1;
|
||||
if(g->numSearchPaths == 0){
|
||||
s = rwstrdup(name);
|
||||
s = rwStrdup(name, MEMDUR_EVENT);
|
||||
makePath(s);
|
||||
f = fopen(s, "rb");
|
||||
if(f){
|
||||
@ -1036,9 +1025,9 @@ bool32
|
||||
Image::registerFileFormat(const char *ext, fileRead read, fileWrite write)
|
||||
{
|
||||
ImageGlobals *g = PLUGINOFFSET(ImageGlobals, engine, imageModuleOffset);
|
||||
if(g->numFileFormats >= nelem(g->fileFormats))
|
||||
if(g->numFileFormats >= (int)nelem(g->fileFormats))
|
||||
return 0;
|
||||
g->fileFormats[g->numFileFormats].extension = rwstrdup(ext);
|
||||
g->fileFormats[g->numFileFormats].extension = rwStrdup(ext, MEMDUR_EVENT);
|
||||
g->fileFormats[g->numFileFormats].read = read;
|
||||
g->fileFormats[g->numFileFormats].write = write;
|
||||
g->numFileFormats++;
|
||||
|
@ -69,7 +69,7 @@ getSizeAtomicMatFX(void *object, int32 offset, int32)
|
||||
|
||||
// Material
|
||||
|
||||
MatFXGlobals matFXGlobals = { 0, 0, { nil } };
|
||||
MatFXGlobals matFXGlobals = { 0, 0, { nil }, nil };
|
||||
|
||||
// TODO: Frames and Matrices?
|
||||
static void
|
||||
|
@ -12,11 +12,6 @@
|
||||
|
||||
#include "lodepng/lodepng.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
/* srsly? */
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
|
||||
#define PLUGIN_ID 0
|
||||
|
||||
namespace rw {
|
||||
@ -25,7 +20,7 @@ namespace rw {
|
||||
Image*
|
||||
readPNG(const char *filename)
|
||||
{
|
||||
Image *image;
|
||||
Image *image = nil;
|
||||
uint32 length;
|
||||
uint8 *data = getFileContents(filename, &length);
|
||||
assert(data != nil);
|
||||
|
@ -588,13 +588,14 @@ getInstMeshInfo(MatPipeline *pipe, Geometry *g, Mesh *m)
|
||||
im.numBrokenAttribs = 0;
|
||||
im.vertexSize = 0;
|
||||
for(uint i = 0; i < nelem(pipe->attribs); i++)
|
||||
if(a = pipe->attribs[i])
|
||||
if((a = pipe->attribs[i])) {
|
||||
if(a->attrib & AT_RW)
|
||||
im.numBrokenAttribs++;
|
||||
else{
|
||||
im.vertexSize += attribSize(a->attrib);
|
||||
im.numAttribs++;
|
||||
}
|
||||
}
|
||||
if(g->meshHeader->flags == MeshHeader::TRISTRIP){
|
||||
im.numBatches = (m->numIndices-2) / (pipe->triStripCount-2);
|
||||
im.batchVertCount = pipe->triStripCount;
|
||||
@ -758,13 +759,14 @@ MatPipeline::collectData(Geometry *g, InstanceData *inst, Mesh *m, uint8 *data[]
|
||||
uint8 *raw = rwNewT(uint8, im.vertexSize*m->numIndices, MEMDUR_EVENT | ID_GEOMETRY);
|
||||
uint8 *dp = raw;
|
||||
for(uint i = 0; i < nelem(this->attribs); i++)
|
||||
if(a = this->attribs[i])
|
||||
if((a = this->attribs[i])) {
|
||||
if(a->attrib & AT_RW){
|
||||
data[i] = inst->data + im.attribPos[i]*0x10;
|
||||
}else{
|
||||
data[i] = dp;
|
||||
dp += m->numIndices*attribSize(a->attrib);
|
||||
}
|
||||
}
|
||||
|
||||
uint8 *datap[nelem(this->attribs)];
|
||||
memcpy(datap, data, sizeof(datap));
|
||||
@ -965,8 +967,8 @@ void
|
||||
genericPreCB(MatPipeline *pipe, Geometry *geo)
|
||||
{
|
||||
PipeAttribute *a;
|
||||
for(int32 i = 0; i < nelem(pipe->attribs); i++)
|
||||
if(a = pipe->attribs[i])
|
||||
for(int32 i = 0; i < (int)nelem(pipe->attribs); i++)
|
||||
if((a = pipe->attribs[i]))
|
||||
if(a == &attribXYZW){
|
||||
allocateADC(geo);
|
||||
break;
|
||||
@ -988,8 +990,8 @@ genericUninstanceCB(MatPipeline *pipe, Geometry *geo, uint32 flags[], Mesh *mesh
|
||||
skin = Skin::get(geo);
|
||||
|
||||
PipeAttribute *a;
|
||||
for(int32 i = 0; i < nelem(pipe->attribs); i++)
|
||||
if(a = pipe->attribs[i]){
|
||||
for(int32 i = 0; i < (int)nelem(pipe->attribs); i++)
|
||||
if((a = pipe->attribs[i])){
|
||||
if(a == &attribXYZ) xyz = (float32*)data[i];
|
||||
else if(a == &attribXYZW) xyzw = (float32*)data[i];
|
||||
else if(a == &attribUV) uv = (float32*)data[i];
|
||||
|
@ -129,8 +129,8 @@ getRasterFormat(Raster *raster)
|
||||
}
|
||||
raster->depth = cameraZDepth;
|
||||
if(pixelformat){
|
||||
if(raster->depth == 16 && pixelformat != Raster::D16 ||
|
||||
raster->depth == 32 && pixelformat != Raster::D32){
|
||||
if((raster->depth == 16 && pixelformat != Raster::D16) ||
|
||||
(raster->depth == 32 && pixelformat != Raster::D32)){
|
||||
RWERROR((ERR_INVRASTER));
|
||||
return 0;
|
||||
}
|
||||
@ -668,29 +668,29 @@ calcOffsets(int32 width_Px, int32 height_Px, int32 psm, uint64 *bufferBase_B, ui
|
||||
case PSMT4HL:
|
||||
case PSMT4HH:
|
||||
// ABCDE -> CADBE
|
||||
bufferBase_B[n] = bufferBase_B[n]&~0x1F | (uint64)blockmap_PSMCT32[bufferBase_B[n]&0x1F];
|
||||
bufferBase_B[n] = (bufferBase_B[n]&~0x1F) | (uint64)blockmap_PSMCT32[bufferBase_B[n]&0x1F];
|
||||
break;
|
||||
case PSMT4:
|
||||
case PSMCT16:
|
||||
// ABCDE -> ADBEC
|
||||
bufferBase_B[n] = bufferBase_B[n]&~0x1F | (uint64)blockmap_PSMCT16[bufferBase_B[n]&0x1F];
|
||||
bufferBase_B[n] = (bufferBase_B[n]&~0x1F) | (uint64)blockmap_PSMCT16[bufferBase_B[n]&0x1F];
|
||||
break;
|
||||
case PSMCT16S:
|
||||
// ABCDE -> DBAEC
|
||||
bufferBase_B[n] = bufferBase_B[n]&~0x1F | (uint64)blockmap_PSMCT16S[bufferBase_B[n]&0x1F];
|
||||
bufferBase_B[n] = (bufferBase_B[n]&~0x1F) | (uint64)blockmap_PSMCT16S[bufferBase_B[n]&0x1F];
|
||||
break;
|
||||
case PSMZ32:
|
||||
case PSMZ24:
|
||||
// ABCDE -> ~C~ADBE
|
||||
bufferBase_B[n] = bufferBase_B[n]&~0x1F | (uint64)blockmap_PSMZ32[bufferBase_B[n]&0x1F];
|
||||
bufferBase_B[n] = (bufferBase_B[n]&~0x1F) | (uint64)blockmap_PSMZ32[bufferBase_B[n]&0x1F];
|
||||
break;
|
||||
case PSMZ16:
|
||||
// ABCDE -> ~A~DBEC
|
||||
bufferBase_B[n] = bufferBase_B[n]&~0x1F | (uint64)blockmap_PSMZ16[bufferBase_B[n]&0x1F];
|
||||
bufferBase_B[n] = (bufferBase_B[n]&~0x1F) | (uint64)blockmap_PSMZ16[bufferBase_B[n]&0x1F];
|
||||
break;
|
||||
case PSMZ16S:
|
||||
// ABCDE -> ~D~BAEC
|
||||
bufferBase_B[n] = bufferBase_B[n]&~0x1F | (uint64)blockmap_PSMZ16S[bufferBase_B[n]&0x1F];
|
||||
bufferBase_B[n] = (bufferBase_B[n]&~0x1F) | (uint64)blockmap_PSMZ16S[bufferBase_B[n]&0x1F];
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
@ -712,24 +712,24 @@ calcOffsets(int32 width_Px, int32 height_Px, int32 psm, uint64 *bufferBase_B, ui
|
||||
case PSMT8H:
|
||||
case PSMT4HL:
|
||||
case PSMT4HH:
|
||||
paletteBase_B = paletteBase_B&~0x1F | (uint64)blockmap_PSMCT32[paletteBase_B&0x1F];
|
||||
paletteBase_B = (paletteBase_B&~0x1F) | (uint64)blockmap_PSMCT32[paletteBase_B&0x1F];
|
||||
break;
|
||||
case PSMT4:
|
||||
case PSMCT16:
|
||||
paletteBase_B = paletteBase_B&~0x1F | (uint64)blockmap_PSMCT16[paletteBase_B&0x1F];
|
||||
paletteBase_B = (paletteBase_B&~0x1F) | (uint64)blockmap_PSMCT16[paletteBase_B&0x1F];
|
||||
break;
|
||||
case PSMCT16S:
|
||||
paletteBase_B = paletteBase_B&~0x1F | (uint64)blockmap_PSMCT16S[paletteBase_B&0x1F];
|
||||
paletteBase_B = (paletteBase_B&~0x1F) | (uint64)blockmap_PSMCT16S[paletteBase_B&0x1F];
|
||||
break;
|
||||
case PSMZ32:
|
||||
case PSMZ24:
|
||||
paletteBase_B = paletteBase_B&~0x1F | (uint64)blockmap_PSMZ32[paletteBase_B&0x1F];
|
||||
paletteBase_B = (paletteBase_B&~0x1F) | (uint64)blockmap_PSMZ32[paletteBase_B&0x1F];
|
||||
break;
|
||||
case PSMZ16:
|
||||
paletteBase_B = paletteBase_B&~0x1F | (uint64)blockmap_PSMZ16[paletteBase_B&0x1F];
|
||||
paletteBase_B = (paletteBase_B&~0x1F) | (uint64)blockmap_PSMZ16[paletteBase_B&0x1F];
|
||||
break;
|
||||
case PSMZ16S:
|
||||
paletteBase_B = paletteBase_B&~0x1F | (uint64)blockmap_PSMZ16S[paletteBase_B&0x1F];
|
||||
paletteBase_B = (paletteBase_B&~0x1F) | (uint64)blockmap_PSMZ16S[paletteBase_B&0x1F];
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
@ -915,8 +915,8 @@ rasterCreateTexture(Raster *raster)
|
||||
|
||||
// If buffer width changes, align next address to page
|
||||
if(bufferWidth[n] != lastBufferWidth){
|
||||
nPagW = ((width >> n-1) + pageWidth-1)/pageWidth;
|
||||
nPagH = ((height >> n-1) + pageHeight-1)/pageHeight;
|
||||
nPagW = ((width >> (n-1)) + pageWidth-1)/pageWidth;
|
||||
nPagH = ((height >> (n-1)) + pageHeight-1)/pageHeight;
|
||||
nextaddress = (lastaddress + nPagW*nPagH*WD2PG) & ~(WD2PG-1);
|
||||
}
|
||||
lastBufferWidth = bufferWidth[n];
|
||||
@ -1052,8 +1052,8 @@ rasterCreateTexture(Raster *raster)
|
||||
ras->flags |= Ps2Raster::SWIZZLED8;
|
||||
if(cpsm == PSMCT32 && bufferWidth[numLevels-1] == 2){ // one page
|
||||
// unswizzle the starting block of the last buffer and palette
|
||||
uint32 bufbase_B = bufferBase[numLevels-1]&~0x1F | (uint64)blockmaprev_PSMCT32[bufferBase[numLevels-1]&0x1F];
|
||||
uint32 palbase_B = ras->paletteBase&~0x1F | (uint64)blockmaprev_PSMCT32[ras->paletteBase&0x1F];
|
||||
uint32 bufbase_B = (bufferBase[numLevels-1]&~0x1F) | (uint64)blockmaprev_PSMCT32[bufferBase[numLevels-1]&0x1F];
|
||||
uint32 palbase_B = (ras->paletteBase&~0x1F) | (uint64)blockmaprev_PSMCT32[ras->paletteBase&0x1F];
|
||||
// find start of page of last level (16,16 are PSMT8 block dimensions)
|
||||
uint32 page_B = bufbase_B - 8*(dsay/16) - dsax/16;
|
||||
// find palette DSAX/Y (in PSMCT32!)
|
||||
@ -1072,8 +1072,8 @@ rasterCreateTexture(Raster *raster)
|
||||
// Looks like they wanted to swizzle palettes too...
|
||||
if(cpsm == PSMCT16){
|
||||
// unswizzle the starting block of the last buffer and palette
|
||||
uint32 bufbase_B = bufferBase[numLevels-1]&~0x1F | (uint64)blockmaprev_PSMCT16[bufferBase[numLevels-1]&0x1F];
|
||||
uint32 palbase_B = ras->paletteBase&~0x1F | (uint64)blockmaprev_PSMCT16[ras->paletteBase&0x1F];
|
||||
uint32 bufbase_B = (bufferBase[numLevels-1]&~0x1F) | (uint64)blockmaprev_PSMCT16[bufferBase[numLevels-1]&0x1F];
|
||||
uint32 palbase_B = (ras->paletteBase&~0x1F) | (uint64)blockmaprev_PSMCT16[ras->paletteBase&0x1F];
|
||||
// find start of page of last level (32,16 are PSMT4 block dimensions)
|
||||
uint32 page_B = bufbase_B - 4*(dsay/32) - dsax/16;
|
||||
// find palette DSAX/Y (in PSMCT16!)
|
||||
@ -1149,8 +1149,8 @@ rasterCreateTexture(Raster *raster)
|
||||
*p++ = 0;
|
||||
|
||||
// TRXPOS
|
||||
if(ras->flags & Ps2Raster::SWIZZLED8 && psm == PSMT8 ||
|
||||
ras->flags & Ps2Raster::SWIZZLED4 && psm == PSMT4){
|
||||
if((ras->flags & Ps2Raster::SWIZZLED8 && psm == PSMT8) ||
|
||||
(ras->flags & Ps2Raster::SWIZZLED4 && psm == PSMT4)){
|
||||
*p++ = 0; // SSAX/Y is always 0
|
||||
*p++ = (trxpos_hi[n] & ~0x10001)/2; // divide both DSAX/Y by 2
|
||||
}else{
|
||||
@ -1161,8 +1161,8 @@ rasterCreateTexture(Raster *raster)
|
||||
*p++ = 0;
|
||||
|
||||
// TRXREG
|
||||
if(ras->flags & Ps2Raster::SWIZZLED8 && psm == PSMT8 ||
|
||||
ras->flags & Ps2Raster::SWIZZLED4 && psm == PSMT4){
|
||||
if((ras->flags & Ps2Raster::SWIZZLED8 && psm == PSMT8) ||
|
||||
(ras->flags & Ps2Raster::SWIZZLED4 && psm == PSMT4)){
|
||||
*p++ = mipw/2;
|
||||
*p++ = miph/2;
|
||||
}else{
|
||||
@ -1361,10 +1361,10 @@ swizzle(uint32 x, uint32 y, uint32 logw)
|
||||
|
||||
uint32 nx, ny, n;
|
||||
x ^= (Y(1)^Y(2))<<2;
|
||||
nx = x&7 | (x>>1)&~7;
|
||||
ny = y&1 | (y>>1)&~1;
|
||||
nx = (x&7) | ((x>>1)&~7);
|
||||
ny = (y&1) | ((y>>1)&~1);
|
||||
n = Y(1) | X(3)<<1;
|
||||
return n | nx<<2 | ny<<logw-1+2;
|
||||
return n | nx<<2 | ny<<(logw-1+2);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1388,17 +1388,17 @@ unswizzleRaster(Raster *raster)
|
||||
px = raster->pixels;
|
||||
logw = 0;
|
||||
for(i = 1; i < w; i *= 2) logw++;
|
||||
mask = (1<<logw+2)-1;
|
||||
mask = (1<<(logw+2))-1;
|
||||
|
||||
if(raster->format & Raster::PAL4 && natras->flags & Ps2Raster::SWIZZLED4){
|
||||
for(y = 0; y < h; y += 4){
|
||||
memcpy(tmpbuf, &px[y<<logw-1], 2*w);
|
||||
memcpy(tmpbuf, &px[y<<(logw-1)], 2*w);
|
||||
for(i = 0; i < 4; i++)
|
||||
for(x = 0; x < w; x++){
|
||||
uint32 a = (y+i<<logw)+x;
|
||||
uint32 a = ((y+i)<<logw)+x;
|
||||
uint32 s = swizzle(x, y+i, logw)&mask;
|
||||
uint8 c = s & 1 ? tmpbuf[s>>1] >> 4 : tmpbuf[s>>1] & 0xF;
|
||||
px[a>>1] = a & 1 ? px[a>>1]&0xF | c<<4 : px[a>>1]&0xF0 | c;
|
||||
px[a>>1] = a & 1 ? (px[a>>1]&0xF) | c<<4 : (px[a>>1]&0xF0) | c;
|
||||
}
|
||||
}
|
||||
}else if(raster->format & Raster::PAL8 && natras->flags & Ps2Raster::SWIZZLED8){
|
||||
@ -1406,7 +1406,7 @@ unswizzleRaster(Raster *raster)
|
||||
memcpy(tmpbuf, &px[y<<logw], 4*w);
|
||||
for(i = 0; i < 4; i++)
|
||||
for(x = 0; x < w; x++){
|
||||
uint32 a = (y+i<<logw)+x;
|
||||
uint32 a = ((y+i)<<logw)+x;
|
||||
uint32 s = swizzle(x, y+i, logw)&mask;
|
||||
px[a] = tmpbuf[s];
|
||||
}
|
||||
@ -1435,24 +1435,24 @@ swizzleRaster(Raster *raster)
|
||||
px = raster->pixels;
|
||||
logw = 0;
|
||||
for(i = 1; i < raster->width; i *= 2) logw++;
|
||||
mask = (1<<logw+2)-1;
|
||||
mask = (1<<(logw+2))-1;
|
||||
|
||||
if(raster->format & Raster::PAL4 && natras->flags & Ps2Raster::SWIZZLED4){
|
||||
for(y = 0; y < h; y += 4){
|
||||
for(i = 0; i < 4; i++)
|
||||
for(x = 0; x < w; x++){
|
||||
uint32 a = (y+i<<logw)+x;
|
||||
uint32 a = ((y+i)<<logw)+x;
|
||||
uint32 s = swizzle(x, y+i, logw)&mask;
|
||||
uint8 c = a & 1 ? px[a>>1] >> 4 : px[a>>1] & 0xF;
|
||||
tmpbuf[s>>1] = s & 1 ? tmpbuf[s>>1]&0xF | c<<4 : tmpbuf[s>>1]&0xF0 | c;
|
||||
tmpbuf[s>>1] = s & 1 ? (tmpbuf[s>>1]&0xF) | c<<4 : (tmpbuf[s>>1]&0xF0) | c;
|
||||
}
|
||||
memcpy(&px[y<<logw-1], tmpbuf, 2*w);
|
||||
memcpy(&px[y<<(logw-1)], tmpbuf, 2*w);
|
||||
}
|
||||
}else if(raster->format & Raster::PAL8 && natras->flags & Ps2Raster::SWIZZLED8){
|
||||
for(y = 0; y < h; y += 4){
|
||||
for(i = 0; i < 4; i++)
|
||||
for(x = 0; x < w; x++){
|
||||
uint32 a = (y+i<<logw)+x;
|
||||
uint32 a = ((y+i)<<logw)+x;
|
||||
uint32 s = swizzle(x, y+i, logw)&mask;
|
||||
tmpbuf[s] = px[a];
|
||||
}
|
||||
@ -1904,7 +1904,7 @@ registerNativeRaster(void)
|
||||
void
|
||||
printTEX0(uint64 tex0)
|
||||
{
|
||||
printf("%016llX ", tex0);
|
||||
printf("%016lX ", tex0);
|
||||
uint32 tbp0 = tex0 & 0x3FFF; tex0 >>= 14;
|
||||
uint32 tbw = tex0 & 0x3F; tex0 >>= 6;
|
||||
uint32 psm = tex0 & 0x3F; tex0 >>= 6;
|
||||
@ -1924,7 +1924,7 @@ printTEX0(uint64 tex0)
|
||||
void
|
||||
printTEX1(uint64 tex1)
|
||||
{
|
||||
printf("%016llX ", tex1);
|
||||
printf("%016lX ", tex1);
|
||||
uint32 lcm = tex1 & 0x1; tex1 >>= 2;
|
||||
uint32 mxl = tex1 & 0x7; tex1 >>= 3;
|
||||
uint32 mmag = tex1 & 0x1; tex1 >>= 1;
|
||||
|
@ -37,7 +37,7 @@ rasterOpen(void *object, int32 offset, int32 size)
|
||||
int i;
|
||||
rasterModuleOffset = offset;
|
||||
RASTERGLOBAL(sp) = -1;
|
||||
for(i = 0; i < nelem(RASTERGLOBAL(stack)); i++)
|
||||
for(i = 0; i < (int)nelem(RASTERGLOBAL(stack)); i++)
|
||||
RASTERGLOBAL(stack)[i] = nil;
|
||||
return object;
|
||||
}
|
||||
@ -295,7 +295,7 @@ conv_RGBA5551_from_ARGB1555(uint8 *out, uint8 *in)
|
||||
uint32 r, g, b, a;
|
||||
a = (in[1]>>7) & 1;
|
||||
r = (in[1]>>2) & 0x1F;
|
||||
g = (in[1]&3)<<3 | (in[0]>>5)&7;
|
||||
g = (in[1]&3)<<3 | ((in[0]>>5)&7);
|
||||
b = in[0] & 0x1F;
|
||||
out[0] = a | b<<1 | g<<6;
|
||||
out[1] = g>>2 | r<<3;
|
||||
@ -307,7 +307,7 @@ conv_RGBA8888_from_ARGB1555(uint8 *out, uint8 *in)
|
||||
uint32 r, g, b, a;
|
||||
a = (in[1]>>7) & 1;
|
||||
r = (in[1]>>2) & 0x1F;
|
||||
g = (in[1]&3)<<3 | (in[0]>>5)&7;
|
||||
g = (in[1]&3)<<3 | ((in[0]>>5)&7);
|
||||
b = in[0] & 0x1F;
|
||||
out[0] = r*0xFF/0x1f;
|
||||
out[1] = g*0xFF/0x1f;
|
||||
@ -321,8 +321,8 @@ conv_ABGR1555_from_ARGB1555(uint8 *out, uint8 *in)
|
||||
uint32 r, b;
|
||||
r = (in[1]>>2) & 0x1F;
|
||||
b = in[0] & 0x1F;
|
||||
out[1] = in[1]&0x83 | b<<2;
|
||||
out[0] = in[0]&0xE0 | r;
|
||||
out[1] = (in[1]&0x83) | b<<2;
|
||||
out[0] = (in[0]&0xE0) | r;
|
||||
}
|
||||
|
||||
void
|
||||
@ -496,8 +496,8 @@ Raster::convertTexToCurrentPlatform(rw::Raster *ras)
|
||||
if(ras->platform == rw::platform)
|
||||
return ras;
|
||||
// compatible platforms
|
||||
if(ras->platform == PLATFORM_D3D8 && rw::platform == PLATFORM_D3D9 ||
|
||||
ras->platform == PLATFORM_D3D9 && rw::platform == PLATFORM_D3D8)
|
||||
if((ras->platform == PLATFORM_D3D8 && rw::platform == PLATFORM_D3D9) ||
|
||||
(ras->platform == PLATFORM_D3D9 && rw::platform == PLATFORM_D3D8))
|
||||
return ras;
|
||||
|
||||
// special cased conversion for DXT
|
||||
|
@ -305,7 +305,7 @@ struct RawMatrix
|
||||
V3d at;
|
||||
float32 atw;
|
||||
V3d pos;
|
||||
float32 posw;;
|
||||
float32 posw;
|
||||
|
||||
static void mult(RawMatrix *dst, RawMatrix *src1, RawMatrix *src2);
|
||||
static void transpose(RawMatrix *dst, RawMatrix *src);
|
||||
|
@ -206,6 +206,8 @@ inline void *realloc_LOC(void *p, size_t sz, uint32 hint, const char *here) { al
|
||||
inline void *mustmalloc_LOC(size_t sz, uint32 hint, const char *here) { allocLocation = here; return rw::Engine::memfuncs.rwmustmalloc(sz,hint); }
|
||||
inline void *mustrealloc_LOC(void *p, size_t sz, uint32 hint, const char *here) { allocLocation = here; return rw::Engine::memfuncs.rwmustrealloc(p,sz,hint); }
|
||||
|
||||
char *strdup_LOC(const char *s, uint32 hint, const char *here);
|
||||
|
||||
#define rwMalloc(s, h) rw::malloc_LOC(s,h,RWHERE)
|
||||
#define rwMallocT(t, s, h) (t*)rw::malloc_LOC((s)*sizeof(t),h,RWHERE)
|
||||
#define rwRealloc(p, s, h) rw::realloc_LOC(p,s,h,RWHERE)
|
||||
@ -215,6 +217,7 @@ inline void *mustrealloc_LOC(void *p, size_t sz, uint32 hint, const char *here)
|
||||
#define rwNewT(t, s, h) (t*)rw::mustmalloc_LOC((s)*sizeof(t),h,RWHERE)
|
||||
#define rwResize(p, s, h) rw::mustrealloc_LOC(p,s,h,RWHERE)
|
||||
#define rwResizeT(t, p, s, h) (t*)rw::mustrealloc_LOC(p,(s)*sizeof(t),h,RWHERE)
|
||||
#define rwStrdup(s, h) rw::strdup_LOC(s,h,RWHERE)
|
||||
|
||||
extern MemoryFunctions defaultMemfuncs;
|
||||
extern MemoryFunctions managedMemfuncs;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
namespace rw {
|
||||
|
||||
SkinGlobals skinGlobals = { 0, 0, { nil } };
|
||||
SkinGlobals skinGlobals = { 0, 0, { nil }, nil };
|
||||
|
||||
static void*
|
||||
createSkin(void *object, int32 offset, int32)
|
||||
|
@ -655,9 +655,9 @@ trace("%d %d %d\n", a, b, c);
|
||||
for(k = 0; k < geo->numTriangles; k++){
|
||||
t = &geo->triangles[k];
|
||||
if(seen[k] || t->matId != m) continue;
|
||||
if(t->v[0] == a && t->v[1] == b && t->v[2] == c ||
|
||||
t->v[1] == a && t->v[2] == b && t->v[0] == c ||
|
||||
t->v[2] == a && t->v[0] == b && t->v[1] == c){
|
||||
if((t->v[0] == a && t->v[1] == b && t->v[2] == c) ||
|
||||
(t->v[1] == a && t->v[2] == b && t->v[0] == c) ||
|
||||
(t->v[2] == a && t->v[0] == b && t->v[1] == c)){
|
||||
seen[k] = 1;
|
||||
goto found;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user