mirror of https://github.com/aap/librw.git
Fix some warnings on gcc/clang
This commit is contained in:
parent
9c578580ec
commit
c26386c112
|
@ -665,7 +665,7 @@ correctPathCase(char *filename)
|
||||||
sofar[2] = '\0';
|
sofar[2] = '\0';
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
while(dir = strtok(arg, PSEP_S)){
|
while((dir = strtok(arg, PSEP_S))){
|
||||||
arg = nil;
|
arg = nil;
|
||||||
if(direct = opendir(sofar), dir == nil)
|
if(direct = opendir(sofar), dir == nil)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -247,7 +247,7 @@ writeBMP(Image *image, const char *filename)
|
||||||
for(int x = 0; x < image->width; x++){
|
for(int x = 0; x < image->width; x++){
|
||||||
switch(image->depth){
|
switch(image->depth){
|
||||||
case 4:
|
case 4:
|
||||||
file.writeU8((p[0]&0xF)<<4 | p[1]&0xF);
|
file.writeU8((p[0]&0xF)<<4 | (p[1]&0xF));
|
||||||
p += 2;
|
p += 2;
|
||||||
x++;
|
x++;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -278,7 +278,7 @@ struct RasterFormatInfo
|
||||||
|
|
||||||
// indexed directly by RW format
|
// indexed directly by RW format
|
||||||
static RasterFormatInfo formatInfoRW[16] = {
|
static RasterFormatInfo formatInfoRW[16] = {
|
||||||
{ 0, 0, 0},
|
{ 0, 0, 0, 0},
|
||||||
{ D3DFMT_A1R5G5B5, 16, 1, Raster::C1555 },
|
{ D3DFMT_A1R5G5B5, 16, 1, Raster::C1555 },
|
||||||
{ D3DFMT_R5G6B5, 16, 0, Raster::C565 },
|
{ D3DFMT_R5G6B5, 16, 0, Raster::C565 },
|
||||||
{ D3DFMT_A4R4G4B4, 16, 1, Raster::C4444 },
|
{ D3DFMT_A4R4G4B4, 16, 1, Raster::C4444 },
|
||||||
|
@ -345,7 +345,7 @@ findFormatInfoD3D(uint32 d3dformat)
|
||||||
{
|
{
|
||||||
static RasterFormatInfo fake = { 0, 0, 0, 0 };
|
static RasterFormatInfo fake = { 0, 0, 0, 0 };
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < nelem(formatInfoFull); i++)
|
for(i = 0; i < (int)nelem(formatInfoFull); i++)
|
||||||
if(formatInfoFull[i].d3dformat == d3dformat)
|
if(formatInfoFull[i].d3dformat == d3dformat)
|
||||||
return &formatInfoFull[i];
|
return &formatInfoFull[i];
|
||||||
return &fake;
|
return &fake;
|
||||||
|
|
|
@ -532,7 +532,7 @@ struct RasterFormatInfo
|
||||||
|
|
||||||
// indexed directly by RW format
|
// indexed directly by RW format
|
||||||
static RasterFormatInfo formatInfoRW[16] = {
|
static RasterFormatInfo formatInfoRW[16] = {
|
||||||
{ 0, 0, 0},
|
{ 0, 0, 0, 0},
|
||||||
{ D3DFMT_A1R5G5B5, 16, 1, Raster::C1555 },
|
{ D3DFMT_A1R5G5B5, 16, 1, Raster::C1555 },
|
||||||
{ D3DFMT_R5G6B5, 16, 0, Raster::C565 },
|
{ D3DFMT_R5G6B5, 16, 0, Raster::C565 },
|
||||||
{ D3DFMT_A4R4G4B4, 16, 1, Raster::C4444 },
|
{ D3DFMT_A4R4G4B4, 16, 1, Raster::C4444 },
|
||||||
|
@ -789,7 +789,7 @@ rasterToImage(Raster *raster)
|
||||||
uint8 *pixels = raster->pixels;
|
uint8 *pixels = raster->pixels;
|
||||||
|
|
||||||
// NB:
|
// NB:
|
||||||
assert(image->bpp == natras->bpp);
|
assert(image->bpp == (int)natras->bpp);
|
||||||
assert(image->stride == raster->stride);
|
assert(image->stride == raster->stride);
|
||||||
unswizzle(imgpixels, pixels, image->width, image->height, image->bpp);
|
unswizzle(imgpixels, pixels, image->width, image->height, image->bpp);
|
||||||
// Fix RGB order
|
// Fix RGB order
|
||||||
|
|
|
@ -130,7 +130,7 @@ printleaks(void)
|
||||||
{
|
{
|
||||||
FORLIST(lnk, allocations){
|
FORLIST(lnk, allocations){
|
||||||
MemoryBlock *mem = LLLinkGetData(lnk, MemoryBlock, inAllocList);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,6 +527,7 @@ deviceSystem(DeviceReq req, void *arg0, int32 n)
|
||||||
return 0;
|
return 0;
|
||||||
case DEVICEGETSUBSSYSTEMINFO:
|
case DEVICEGETSUBSSYSTEMINFO:
|
||||||
return 0;
|
return 0;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,7 +472,7 @@ Geometry::generateTriangles(int8 *adc)
|
||||||
int32 matid = this->matList.findIndex(m->material);
|
int32 matid = this->matList.findIndex(m->material);
|
||||||
if(header->flags == MeshHeader::TRISTRIP)
|
if(header->flags == MeshHeader::TRISTRIP)
|
||||||
for(uint32 j = 0; j < m->numIndices-2; j++){
|
for(uint32 j = 0; j < m->numIndices-2; j++){
|
||||||
if(adc && adcbits[j+2] ||
|
if((adc && adcbits[j+2]) ||
|
||||||
isDegenerate(&m->indices[j]))
|
isDegenerate(&m->indices[j]))
|
||||||
continue;
|
continue;
|
||||||
tri->v[0] = m->indices[j+0];
|
tri->v[0] = m->indices[j+0];
|
||||||
|
|
|
@ -307,7 +307,7 @@ getSizeHAnim(void *object, int32 offset, int32)
|
||||||
{
|
{
|
||||||
HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset);
|
HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset);
|
||||||
if(!hAnimDoStream ||
|
if(!hAnimDoStream ||
|
||||||
version >= 0x35000 && hanim->id == -1 && hanim->hierarchy == nil)
|
(version >= 0x35000 && hanim->id == -1 && hanim->hierarchy == nil))
|
||||||
return 0;
|
return 0;
|
||||||
if(hanim->hierarchy)
|
if(hanim->hierarchy)
|
||||||
return 12 + 8 + hanim->hierarchy->numNodes*12;
|
return 12 + 8 + hanim->hierarchy->numNodes*12;
|
||||||
|
|
|
@ -1036,7 +1036,7 @@ bool32
|
||||||
Image::registerFileFormat(const char *ext, fileRead read, fileWrite write)
|
Image::registerFileFormat(const char *ext, fileRead read, fileWrite write)
|
||||||
{
|
{
|
||||||
ImageGlobals *g = PLUGINOFFSET(ImageGlobals, engine, imageModuleOffset);
|
ImageGlobals *g = PLUGINOFFSET(ImageGlobals, engine, imageModuleOffset);
|
||||||
if(g->numFileFormats >= nelem(g->fileFormats))
|
if(g->numFileFormats >= (int)nelem(g->fileFormats))
|
||||||
return 0;
|
return 0;
|
||||||
g->fileFormats[g->numFileFormats].extension = rwstrdup(ext);
|
g->fileFormats[g->numFileFormats].extension = rwstrdup(ext);
|
||||||
g->fileFormats[g->numFileFormats].read = read;
|
g->fileFormats[g->numFileFormats].read = read;
|
||||||
|
|
|
@ -69,7 +69,7 @@ getSizeAtomicMatFX(void *object, int32 offset, int32)
|
||||||
|
|
||||||
// Material
|
// Material
|
||||||
|
|
||||||
MatFXGlobals matFXGlobals = { 0, 0, { nil } };
|
MatFXGlobals matFXGlobals = { 0, 0, { nil }, nil };
|
||||||
|
|
||||||
// TODO: Frames and Matrices?
|
// TODO: Frames and Matrices?
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace rw {
|
||||||
Image*
|
Image*
|
||||||
readPNG(const char *filename)
|
readPNG(const char *filename)
|
||||||
{
|
{
|
||||||
Image *image;
|
Image *image = nil;
|
||||||
uint32 length;
|
uint32 length;
|
||||||
uint8 *data = getFileContents(filename, &length);
|
uint8 *data = getFileContents(filename, &length);
|
||||||
assert(data != nil);
|
assert(data != nil);
|
||||||
|
|
|
@ -588,13 +588,14 @@ getInstMeshInfo(MatPipeline *pipe, Geometry *g, Mesh *m)
|
||||||
im.numBrokenAttribs = 0;
|
im.numBrokenAttribs = 0;
|
||||||
im.vertexSize = 0;
|
im.vertexSize = 0;
|
||||||
for(uint i = 0; i < nelem(pipe->attribs); i++)
|
for(uint i = 0; i < nelem(pipe->attribs); i++)
|
||||||
if(a = pipe->attribs[i])
|
if((a = pipe->attribs[i])) {
|
||||||
if(a->attrib & AT_RW)
|
if(a->attrib & AT_RW)
|
||||||
im.numBrokenAttribs++;
|
im.numBrokenAttribs++;
|
||||||
else{
|
else{
|
||||||
im.vertexSize += attribSize(a->attrib);
|
im.vertexSize += attribSize(a->attrib);
|
||||||
im.numAttribs++;
|
im.numAttribs++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(g->meshHeader->flags == MeshHeader::TRISTRIP){
|
if(g->meshHeader->flags == MeshHeader::TRISTRIP){
|
||||||
im.numBatches = (m->numIndices-2) / (pipe->triStripCount-2);
|
im.numBatches = (m->numIndices-2) / (pipe->triStripCount-2);
|
||||||
im.batchVertCount = pipe->triStripCount;
|
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 *raw = rwNewT(uint8, im.vertexSize*m->numIndices, MEMDUR_EVENT | ID_GEOMETRY);
|
||||||
uint8 *dp = raw;
|
uint8 *dp = raw;
|
||||||
for(uint i = 0; i < nelem(this->attribs); i++)
|
for(uint i = 0; i < nelem(this->attribs); i++)
|
||||||
if(a = this->attribs[i])
|
if((a = this->attribs[i])) {
|
||||||
if(a->attrib & AT_RW){
|
if(a->attrib & AT_RW){
|
||||||
data[i] = inst->data + im.attribPos[i]*0x10;
|
data[i] = inst->data + im.attribPos[i]*0x10;
|
||||||
}else{
|
}else{
|
||||||
data[i] = dp;
|
data[i] = dp;
|
||||||
dp += m->numIndices*attribSize(a->attrib);
|
dp += m->numIndices*attribSize(a->attrib);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8 *datap[nelem(this->attribs)];
|
uint8 *datap[nelem(this->attribs)];
|
||||||
memcpy(datap, data, sizeof(datap));
|
memcpy(datap, data, sizeof(datap));
|
||||||
|
@ -965,8 +967,8 @@ void
|
||||||
genericPreCB(MatPipeline *pipe, Geometry *geo)
|
genericPreCB(MatPipeline *pipe, Geometry *geo)
|
||||||
{
|
{
|
||||||
PipeAttribute *a;
|
PipeAttribute *a;
|
||||||
for(int32 i = 0; i < nelem(pipe->attribs); i++)
|
for(int32 i = 0; i < (int)nelem(pipe->attribs); i++)
|
||||||
if(a = pipe->attribs[i])
|
if((a = pipe->attribs[i]))
|
||||||
if(a == &attribXYZW){
|
if(a == &attribXYZW){
|
||||||
allocateADC(geo);
|
allocateADC(geo);
|
||||||
break;
|
break;
|
||||||
|
@ -988,8 +990,8 @@ genericUninstanceCB(MatPipeline *pipe, Geometry *geo, uint32 flags[], Mesh *mesh
|
||||||
skin = Skin::get(geo);
|
skin = Skin::get(geo);
|
||||||
|
|
||||||
PipeAttribute *a;
|
PipeAttribute *a;
|
||||||
for(int32 i = 0; i < nelem(pipe->attribs); i++)
|
for(int32 i = 0; i < (int)nelem(pipe->attribs); i++)
|
||||||
if(a = pipe->attribs[i]){
|
if((a = pipe->attribs[i])){
|
||||||
if(a == &attribXYZ) xyz = (float32*)data[i];
|
if(a == &attribXYZ) xyz = (float32*)data[i];
|
||||||
else if(a == &attribXYZW) xyzw = (float32*)data[i];
|
else if(a == &attribXYZW) xyzw = (float32*)data[i];
|
||||||
else if(a == &attribUV) uv = (float32*)data[i];
|
else if(a == &attribUV) uv = (float32*)data[i];
|
||||||
|
|
|
@ -129,8 +129,8 @@ getRasterFormat(Raster *raster)
|
||||||
}
|
}
|
||||||
raster->depth = cameraZDepth;
|
raster->depth = cameraZDepth;
|
||||||
if(pixelformat){
|
if(pixelformat){
|
||||||
if(raster->depth == 16 && pixelformat != Raster::D16 ||
|
if((raster->depth == 16 && pixelformat != Raster::D16) ||
|
||||||
raster->depth == 32 && pixelformat != Raster::D32){
|
(raster->depth == 32 && pixelformat != Raster::D32)){
|
||||||
RWERROR((ERR_INVRASTER));
|
RWERROR((ERR_INVRASTER));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -668,29 +668,29 @@ calcOffsets(int32 width_Px, int32 height_Px, int32 psm, uint64 *bufferBase_B, ui
|
||||||
case PSMT4HL:
|
case PSMT4HL:
|
||||||
case PSMT4HH:
|
case PSMT4HH:
|
||||||
// ABCDE -> CADBE
|
// 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;
|
break;
|
||||||
case PSMT4:
|
case PSMT4:
|
||||||
case PSMCT16:
|
case PSMCT16:
|
||||||
// ABCDE -> ADBEC
|
// 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;
|
break;
|
||||||
case PSMCT16S:
|
case PSMCT16S:
|
||||||
// ABCDE -> DBAEC
|
// 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;
|
break;
|
||||||
case PSMZ32:
|
case PSMZ32:
|
||||||
case PSMZ24:
|
case PSMZ24:
|
||||||
// ABCDE -> ~C~ADBE
|
// 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;
|
break;
|
||||||
case PSMZ16:
|
case PSMZ16:
|
||||||
// ABCDE -> ~A~DBEC
|
// 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;
|
break;
|
||||||
case PSMZ16S:
|
case PSMZ16S:
|
||||||
// ABCDE -> ~D~BAEC
|
// 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;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -712,24 +712,24 @@ calcOffsets(int32 width_Px, int32 height_Px, int32 psm, uint64 *bufferBase_B, ui
|
||||||
case PSMT8H:
|
case PSMT8H:
|
||||||
case PSMT4HL:
|
case PSMT4HL:
|
||||||
case PSMT4HH:
|
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;
|
break;
|
||||||
case PSMT4:
|
case PSMT4:
|
||||||
case PSMCT16:
|
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;
|
break;
|
||||||
case PSMCT16S:
|
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;
|
break;
|
||||||
case PSMZ32:
|
case PSMZ32:
|
||||||
case PSMZ24:
|
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;
|
break;
|
||||||
case PSMZ16:
|
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;
|
break;
|
||||||
case PSMZ16S:
|
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;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -915,8 +915,8 @@ rasterCreateTexture(Raster *raster)
|
||||||
|
|
||||||
// If buffer width changes, align next address to page
|
// If buffer width changes, align next address to page
|
||||||
if(bufferWidth[n] != lastBufferWidth){
|
if(bufferWidth[n] != lastBufferWidth){
|
||||||
nPagW = ((width >> n-1) + pageWidth-1)/pageWidth;
|
nPagW = ((width >> (n-1)) + pageWidth-1)/pageWidth;
|
||||||
nPagH = ((height >> n-1) + pageHeight-1)/pageHeight;
|
nPagH = ((height >> (n-1)) + pageHeight-1)/pageHeight;
|
||||||
nextaddress = (lastaddress + nPagW*nPagH*WD2PG) & ~(WD2PG-1);
|
nextaddress = (lastaddress + nPagW*nPagH*WD2PG) & ~(WD2PG-1);
|
||||||
}
|
}
|
||||||
lastBufferWidth = bufferWidth[n];
|
lastBufferWidth = bufferWidth[n];
|
||||||
|
@ -1052,8 +1052,8 @@ rasterCreateTexture(Raster *raster)
|
||||||
ras->flags |= Ps2Raster::SWIZZLED8;
|
ras->flags |= Ps2Raster::SWIZZLED8;
|
||||||
if(cpsm == PSMCT32 && bufferWidth[numLevels-1] == 2){ // one page
|
if(cpsm == PSMCT32 && bufferWidth[numLevels-1] == 2){ // one page
|
||||||
// unswizzle the starting block of the last buffer and palette
|
// 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 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 palbase_B = (ras->paletteBase&~0x1F) | (uint64)blockmaprev_PSMCT32[ras->paletteBase&0x1F];
|
||||||
// find start of page of last level (16,16 are PSMT8 block dimensions)
|
// find start of page of last level (16,16 are PSMT8 block dimensions)
|
||||||
uint32 page_B = bufbase_B - 8*(dsay/16) - dsax/16;
|
uint32 page_B = bufbase_B - 8*(dsay/16) - dsax/16;
|
||||||
// find palette DSAX/Y (in PSMCT32!)
|
// find palette DSAX/Y (in PSMCT32!)
|
||||||
|
@ -1072,8 +1072,8 @@ rasterCreateTexture(Raster *raster)
|
||||||
// Looks like they wanted to swizzle palettes too...
|
// Looks like they wanted to swizzle palettes too...
|
||||||
if(cpsm == PSMCT16){
|
if(cpsm == PSMCT16){
|
||||||
// unswizzle the starting block of the last buffer and palette
|
// 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 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 palbase_B = (ras->paletteBase&~0x1F) | (uint64)blockmaprev_PSMCT16[ras->paletteBase&0x1F];
|
||||||
// find start of page of last level (32,16 are PSMT4 block dimensions)
|
// find start of page of last level (32,16 are PSMT4 block dimensions)
|
||||||
uint32 page_B = bufbase_B - 4*(dsay/32) - dsax/16;
|
uint32 page_B = bufbase_B - 4*(dsay/32) - dsax/16;
|
||||||
// find palette DSAX/Y (in PSMCT16!)
|
// find palette DSAX/Y (in PSMCT16!)
|
||||||
|
@ -1149,8 +1149,8 @@ rasterCreateTexture(Raster *raster)
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
|
||||||
// TRXPOS
|
// TRXPOS
|
||||||
if(ras->flags & Ps2Raster::SWIZZLED8 && psm == PSMT8 ||
|
if((ras->flags & Ps2Raster::SWIZZLED8 && psm == PSMT8) ||
|
||||||
ras->flags & Ps2Raster::SWIZZLED4 && psm == PSMT4){
|
(ras->flags & Ps2Raster::SWIZZLED4 && psm == PSMT4)){
|
||||||
*p++ = 0; // SSAX/Y is always 0
|
*p++ = 0; // SSAX/Y is always 0
|
||||||
*p++ = (trxpos_hi[n] & ~0x10001)/2; // divide both DSAX/Y by 2
|
*p++ = (trxpos_hi[n] & ~0x10001)/2; // divide both DSAX/Y by 2
|
||||||
}else{
|
}else{
|
||||||
|
@ -1161,8 +1161,8 @@ rasterCreateTexture(Raster *raster)
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
|
||||||
// TRXREG
|
// TRXREG
|
||||||
if(ras->flags & Ps2Raster::SWIZZLED8 && psm == PSMT8 ||
|
if((ras->flags & Ps2Raster::SWIZZLED8 && psm == PSMT8) ||
|
||||||
ras->flags & Ps2Raster::SWIZZLED4 && psm == PSMT4){
|
(ras->flags & Ps2Raster::SWIZZLED4 && psm == PSMT4)){
|
||||||
*p++ = mipw/2;
|
*p++ = mipw/2;
|
||||||
*p++ = miph/2;
|
*p++ = miph/2;
|
||||||
}else{
|
}else{
|
||||||
|
@ -1361,10 +1361,10 @@ swizzle(uint32 x, uint32 y, uint32 logw)
|
||||||
|
|
||||||
uint32 nx, ny, n;
|
uint32 nx, ny, n;
|
||||||
x ^= (Y(1)^Y(2))<<2;
|
x ^= (Y(1)^Y(2))<<2;
|
||||||
nx = x&7 | (x>>1)&~7;
|
nx = (x&7) | ((x>>1)&~7);
|
||||||
ny = y&1 | (y>>1)&~1;
|
ny = (y&1) | ((y>>1)&~1);
|
||||||
n = Y(1) | X(3)<<1;
|
n = Y(1) | X(3)<<1;
|
||||||
return n | nx<<2 | ny<<logw-1+2;
|
return n | nx<<2 | ny<<(logw-1+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1388,17 +1388,17 @@ unswizzleRaster(Raster *raster)
|
||||||
px = raster->pixels;
|
px = raster->pixels;
|
||||||
logw = 0;
|
logw = 0;
|
||||||
for(i = 1; i < w; i *= 2) logw++;
|
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){
|
if(raster->format & Raster::PAL4 && natras->flags & Ps2Raster::SWIZZLED4){
|
||||||
for(y = 0; y < h; y += 4){
|
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(i = 0; i < 4; i++)
|
||||||
for(x = 0; x < w; x++){
|
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;
|
uint32 s = swizzle(x, y+i, logw)&mask;
|
||||||
uint8 c = s & 1 ? tmpbuf[s>>1] >> 4 : tmpbuf[s>>1] & 0xF;
|
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){
|
}else if(raster->format & Raster::PAL8 && natras->flags & Ps2Raster::SWIZZLED8){
|
||||||
|
@ -1406,7 +1406,7 @@ unswizzleRaster(Raster *raster)
|
||||||
memcpy(tmpbuf, &px[y<<logw], 4*w);
|
memcpy(tmpbuf, &px[y<<logw], 4*w);
|
||||||
for(i = 0; i < 4; i++)
|
for(i = 0; i < 4; i++)
|
||||||
for(x = 0; x < w; x++){
|
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;
|
uint32 s = swizzle(x, y+i, logw)&mask;
|
||||||
px[a] = tmpbuf[s];
|
px[a] = tmpbuf[s];
|
||||||
}
|
}
|
||||||
|
@ -1435,24 +1435,24 @@ swizzleRaster(Raster *raster)
|
||||||
px = raster->pixels;
|
px = raster->pixels;
|
||||||
logw = 0;
|
logw = 0;
|
||||||
for(i = 1; i < raster->width; i *= 2) logw++;
|
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){
|
if(raster->format & Raster::PAL4 && natras->flags & Ps2Raster::SWIZZLED4){
|
||||||
for(y = 0; y < h; y += 4){
|
for(y = 0; y < h; y += 4){
|
||||||
for(i = 0; i < 4; i++)
|
for(i = 0; i < 4; i++)
|
||||||
for(x = 0; x < w; x++){
|
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;
|
uint32 s = swizzle(x, y+i, logw)&mask;
|
||||||
uint8 c = a & 1 ? px[a>>1] >> 4 : px[a>>1] & 0xF;
|
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){
|
}else if(raster->format & Raster::PAL8 && natras->flags & Ps2Raster::SWIZZLED8){
|
||||||
for(y = 0; y < h; y += 4){
|
for(y = 0; y < h; y += 4){
|
||||||
for(i = 0; i < 4; i++)
|
for(i = 0; i < 4; i++)
|
||||||
for(x = 0; x < w; x++){
|
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;
|
uint32 s = swizzle(x, y+i, logw)&mask;
|
||||||
tmpbuf[s] = px[a];
|
tmpbuf[s] = px[a];
|
||||||
}
|
}
|
||||||
|
@ -1904,7 +1904,7 @@ registerNativeRaster(void)
|
||||||
void
|
void
|
||||||
printTEX0(uint64 tex0)
|
printTEX0(uint64 tex0)
|
||||||
{
|
{
|
||||||
printf("%016llX ", tex0);
|
printf("%016lX ", tex0);
|
||||||
uint32 tbp0 = tex0 & 0x3FFF; tex0 >>= 14;
|
uint32 tbp0 = tex0 & 0x3FFF; tex0 >>= 14;
|
||||||
uint32 tbw = tex0 & 0x3F; tex0 >>= 6;
|
uint32 tbw = tex0 & 0x3F; tex0 >>= 6;
|
||||||
uint32 psm = tex0 & 0x3F; tex0 >>= 6;
|
uint32 psm = tex0 & 0x3F; tex0 >>= 6;
|
||||||
|
@ -1924,7 +1924,7 @@ printTEX0(uint64 tex0)
|
||||||
void
|
void
|
||||||
printTEX1(uint64 tex1)
|
printTEX1(uint64 tex1)
|
||||||
{
|
{
|
||||||
printf("%016llX ", tex1);
|
printf("%016lX ", tex1);
|
||||||
uint32 lcm = tex1 & 0x1; tex1 >>= 2;
|
uint32 lcm = tex1 & 0x1; tex1 >>= 2;
|
||||||
uint32 mxl = tex1 & 0x7; tex1 >>= 3;
|
uint32 mxl = tex1 & 0x7; tex1 >>= 3;
|
||||||
uint32 mmag = tex1 & 0x1; tex1 >>= 1;
|
uint32 mmag = tex1 & 0x1; tex1 >>= 1;
|
||||||
|
|
|
@ -37,7 +37,7 @@ rasterOpen(void *object, int32 offset, int32 size)
|
||||||
int i;
|
int i;
|
||||||
rasterModuleOffset = offset;
|
rasterModuleOffset = offset;
|
||||||
RASTERGLOBAL(sp) = -1;
|
RASTERGLOBAL(sp) = -1;
|
||||||
for(i = 0; i < nelem(RASTERGLOBAL(stack)); i++)
|
for(i = 0; i < (int)nelem(RASTERGLOBAL(stack)); i++)
|
||||||
RASTERGLOBAL(stack)[i] = nil;
|
RASTERGLOBAL(stack)[i] = nil;
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ conv_RGBA5551_from_ARGB1555(uint8 *out, uint8 *in)
|
||||||
uint32 r, g, b, a;
|
uint32 r, g, b, a;
|
||||||
a = (in[1]>>7) & 1;
|
a = (in[1]>>7) & 1;
|
||||||
r = (in[1]>>2) & 0x1F;
|
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;
|
b = in[0] & 0x1F;
|
||||||
out[0] = a | b<<1 | g<<6;
|
out[0] = a | b<<1 | g<<6;
|
||||||
out[1] = g>>2 | r<<3;
|
out[1] = g>>2 | r<<3;
|
||||||
|
@ -307,7 +307,7 @@ conv_RGBA8888_from_ARGB1555(uint8 *out, uint8 *in)
|
||||||
uint32 r, g, b, a;
|
uint32 r, g, b, a;
|
||||||
a = (in[1]>>7) & 1;
|
a = (in[1]>>7) & 1;
|
||||||
r = (in[1]>>2) & 0x1F;
|
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;
|
b = in[0] & 0x1F;
|
||||||
out[0] = r*0xFF/0x1f;
|
out[0] = r*0xFF/0x1f;
|
||||||
out[1] = g*0xFF/0x1f;
|
out[1] = g*0xFF/0x1f;
|
||||||
|
@ -321,8 +321,8 @@ conv_ABGR1555_from_ARGB1555(uint8 *out, uint8 *in)
|
||||||
uint32 r, b;
|
uint32 r, b;
|
||||||
r = (in[1]>>2) & 0x1F;
|
r = (in[1]>>2) & 0x1F;
|
||||||
b = in[0] & 0x1F;
|
b = in[0] & 0x1F;
|
||||||
out[1] = in[1]&0x83 | b<<2;
|
out[1] = (in[1]&0x83) | b<<2;
|
||||||
out[0] = in[0]&0xE0 | r;
|
out[0] = (in[0]&0xE0) | r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -496,8 +496,8 @@ Raster::convertTexToCurrentPlatform(rw::Raster *ras)
|
||||||
if(ras->platform == rw::platform)
|
if(ras->platform == rw::platform)
|
||||||
return ras;
|
return ras;
|
||||||
// compatible platforms
|
// compatible platforms
|
||||||
if(ras->platform == PLATFORM_D3D8 && rw::platform == PLATFORM_D3D9 ||
|
if((ras->platform == PLATFORM_D3D8 && rw::platform == PLATFORM_D3D9) ||
|
||||||
ras->platform == PLATFORM_D3D9 && rw::platform == PLATFORM_D3D8)
|
(ras->platform == PLATFORM_D3D9 && rw::platform == PLATFORM_D3D8))
|
||||||
return ras;
|
return ras;
|
||||||
|
|
||||||
// special cased conversion for DXT
|
// special cased conversion for DXT
|
||||||
|
|
|
@ -305,7 +305,7 @@ struct RawMatrix
|
||||||
V3d at;
|
V3d at;
|
||||||
float32 atw;
|
float32 atw;
|
||||||
V3d pos;
|
V3d pos;
|
||||||
float32 posw;;
|
float32 posw;
|
||||||
|
|
||||||
static void mult(RawMatrix *dst, RawMatrix *src1, RawMatrix *src2);
|
static void mult(RawMatrix *dst, RawMatrix *src1, RawMatrix *src2);
|
||||||
static void transpose(RawMatrix *dst, RawMatrix *src);
|
static void transpose(RawMatrix *dst, RawMatrix *src);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
|
|
||||||
SkinGlobals skinGlobals = { 0, 0, { nil } };
|
SkinGlobals skinGlobals = { 0, 0, { nil }, nil };
|
||||||
|
|
||||||
static void*
|
static void*
|
||||||
createSkin(void *object, int32 offset, int32)
|
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++){
|
for(k = 0; k < geo->numTriangles; k++){
|
||||||
t = &geo->triangles[k];
|
t = &geo->triangles[k];
|
||||||
if(seen[k] || t->matId != m) continue;
|
if(seen[k] || t->matId != m) continue;
|
||||||
if(t->v[0] == a && t->v[1] == b && t->v[2] == 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[1] == a && t->v[2] == b && t->v[0] == c) ||
|
||||||
t->v[2] == a && t->v[0] == b && t->v[1] == c){
|
(t->v[2] == a && t->v[0] == b && t->v[1] == c)){
|
||||||
seen[k] = 1;
|
seen[k] = 1;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue