1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Fix code analizer warnings.

This commit is contained in:
Sergey Lipskiy 2014-11-28 11:12:18 +06:00
parent 663b5d1f5e
commit fbe21ef07d
7 changed files with 98 additions and 93 deletions

View File

@ -40,22 +40,22 @@ void Texture2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch
uint32 nWidth = width;
uint32 nHeight = height;
uint32 b1;
uint32 g1;
uint32 r1;
uint32 a1;
uint32 b2;
uint32 g2;
uint32 r2;
uint32 a2;
uint32 b3;
uint32 g3;
uint32 r3;
uint32 a3;
uint32 b4;
uint32 g4;
uint32 r4;
uint32 a4;
uint32 b1 = 0;
uint32 g1 = 0;
uint32 r1 = 0;
uint32 a1 = 0;
uint32 b2 = 0;
uint32 g2 = 0;
uint32 r2 = 0;
uint32 a2 = 0;
uint32 b3 = 0;
uint32 g3 = 0;
uint32 r3 = 0;
uint32 a3 = 0;
uint32 b4 = 0;
uint32 g4 = 0;
uint32 r4 = 0;
uint32 a4 = 0;
uint32 xSrc;
uint32 ySrc;

View File

@ -221,84 +221,85 @@ TxCache::get(uint64 checksum, GHQTexInfo *info)
boolean
TxCache::save(const wchar_t *path, const wchar_t *filename, int config)
{
if (!_cache.empty()) {
/* dump cache to disk */
char cbuf[MAX_PATH];
if (_cache.empty())
return true;
boost::filesystem::wpath cachepath(path);
boost::filesystem::create_directory(cachepath);
/* dump cache to disk */
char cbuf[MAX_PATH];
/* Ugly hack to enable fopen/gzopen in Win9x */
boost::filesystem::wpath cachepath(path);
boost::filesystem::create_directory(cachepath);
/* Ugly hack to enable fopen/gzopen in Win9x */
#ifdef WIN32
wchar_t curpath[MAX_PATH];
GETCWD(MAX_PATH, curpath);
CHDIR(cachepath.wstring().c_str());
wchar_t curpath[MAX_PATH];
GETCWD(MAX_PATH, curpath);
CHDIR(cachepath.wstring().c_str());
#else
char curpath[MAX_PATH];
wcstombs(cbuf, cachepath.string().c_str(), MAX_PATH);
GETCWD(MAX_PATH, curpath);
CHDIR(cbuf);
char curpath[MAX_PATH];
wcstombs(cbuf, cachepath.string().c_str(), MAX_PATH);
GETCWD(MAX_PATH, curpath);
CHDIR(cbuf);
#endif
wcstombs(cbuf, filename, MAX_PATH);
wcstombs(cbuf, filename, MAX_PATH);
gzFile gzfp = gzopen(cbuf, "wb1");
DBG_INFO(80, L"gzfp:%x file:%ls\n", gzfp, filename);
if (gzfp) {
/* write header to determine config match */
gzwrite(gzfp, &config, 4);
gzFile gzfp = gzopen(cbuf, "wb1");
DBG_INFO(80, L"gzfp:%x file:%ls\n", gzfp, filename);
if (gzfp) {
/* write header to determine config match */
gzwrite(gzfp, &config, 4);
std::map<uint64, TXCACHE*>::iterator itMap = _cache.begin();
int total = 0;
while (itMap != _cache.end()) {
uint8 *dest = (*itMap).second->info.data;
uint32 destLen = (*itMap).second->size;
uint32 format = (*itMap).second->info.format;
std::map<uint64, TXCACHE*>::iterator itMap = _cache.begin();
int total = 0;
while (itMap != _cache.end()) {
uint8 *dest = (*itMap).second->info.data;
uint32 destLen = (*itMap).second->size;
uint32 format = (*itMap).second->info.format;
/* to keep things simple, we save the texture data in a zlib uncompressed state. */
/* sigh... for those who cannot wait the extra few seconds. changed to keep
* texture data in a zlib compressed state. if the GZ_TEXCACHE or GZ_HIRESTEXCACHE
* option is toggled, the cache will need to be rebuilt.
*/
/*if (format & GL_TEXFMT_GZ) {
dest = _gzdest0;
destLen = _gzdestLen;
if (dest && destLen) {
if (uncompress(dest, &destLen, (*itMap).second->info.data, (*itMap).second->size) != Z_OK) {
dest = NULL;
destLen = 0;
/* to keep things simple, we save the texture data in a zlib uncompressed state. */
/* sigh... for those who cannot wait the extra few seconds. changed to keep
* texture data in a zlib compressed state. if the GZ_TEXCACHE or GZ_HIRESTEXCACHE
* option is toggled, the cache will need to be rebuilt.
*/
/*if (format & GL_TEXFMT_GZ) {
dest = _gzdest0;
destLen = _gzdestLen;
if (dest && destLen) {
if (uncompress(dest, &destLen, (*itMap).second->info.data, (*itMap).second->size) != Z_OK) {
dest = NULL;
destLen = 0;
}
format &= ~GL_TEXFMT_GZ;
}
}*/
if (dest && destLen) {
/* texture checksum */
gzwrite(gzfp, &((*itMap).first), 8);
/* other texture info */
gzwrite(gzfp, &((*itMap).second->info.width), 4);
gzwrite(gzfp, &((*itMap).second->info.height), 4);
gzwrite(gzfp, &format, 4);
gzwrite(gzfp, &((*itMap).second->info.texture_format), 2);
gzwrite(gzfp, &((*itMap).second->info.pixel_type), 2);
gzwrite(gzfp, &((*itMap).second->info.is_hires_tex), 1);
gzwrite(gzfp, &destLen, 4);
gzwrite(gzfp, dest, destLen);
}
format &= ~GL_TEXFMT_GZ;
}
}*/
if (dest && destLen) {
/* texture checksum */
gzwrite(gzfp, &((*itMap).first), 8);
itMap++;
/* other texture info */
gzwrite(gzfp, &((*itMap).second->info.width), 4);
gzwrite(gzfp, &((*itMap).second->info.height), 4);
gzwrite(gzfp, &format, 4);
gzwrite(gzfp, &((*itMap).second->info.texture_format), 2);
gzwrite(gzfp, &((*itMap).second->info.pixel_type), 2);
gzwrite(gzfp, &((*itMap).second->info.is_hires_tex), 1);
gzwrite(gzfp, &destLen, 4);
gzwrite(gzfp, dest, destLen);
}
itMap++;
if (_callback)
(*_callback)(L"Total textures saved to HDD: %d\n", ++total);
}
gzclose(gzfp);
if (_callback)
(*_callback)(L"Total textures saved to HDD: %d\n", ++total);
}
CHDIR(curpath);
gzclose(gzfp);
}
CHDIR(curpath);
return _cache.empty();
}

View File

@ -246,13 +246,13 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format)
boolean
TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, uint16 format, uint8 *palette)
{
png_structp png_ptr;
png_infop info_ptr;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
png_color_8 sig_bit;
png_colorp palette_ptr;
png_bytep trans_ptr;//, tex_ptr;
int bit_depth, color_type, row_bytes, num_palette;
int i;
png_colorp palette_ptr = NULL;
png_bytep trans_ptr = NULL;//, tex_ptr;
int bit_depth = 0, color_type = 0, row_bytes = 0, num_palette = 0;
int i = 0;
//uint16 srcfmt, destfmt;
if (!src || !fp)

View File

@ -620,8 +620,10 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
bpl = gSP.bgImage.width << gSP.bgImage.size >> 1;
numBytes = bpl * gSP.bgImage.height;
pSwapped = (u8*)malloc( numBytes );
assert(pSwapped != NULL);
UnswapCopy( &RDRAM[gSP.bgImage.address], pSwapped, numBytes );
pDest = (u32*)malloc( pTexture->textureBytes );
assert(pDest != NULL);
clampSClamp = pTexture->width - 1;
clampTClamp = pTexture->height - 1;

View File

@ -92,7 +92,7 @@ void Turbo3D_LoadGlobState(u32 pgstate)
static
void Turbo3D_LoadObject(u32 pstate, u32 pvtx, u32 ptri)
{
const u32 addr = RSP_SegmentToPhysical(pstate);
u32 addr = RSP_SegmentToPhysical(pstate);
T3DState *ostate = (T3DState*)&RDRAM[addr];
const u32 tile = (ostate->textureState)&7;
gSP.texture.tile = tile;
@ -119,7 +119,7 @@ void Turbo3D_LoadObject(u32 pstate, u32 pvtx, u32 ptri)
Turbo3D_ProcessRDP(ostate->rdpCmds);
if (ptri != 0) {
u32 addr = RSP_SegmentToPhysical(ptri);
addr = RSP_SegmentToPhysical(ptri);
for (int t = 0; t < ostate->triCount; ++t) {
T3DTriN * tri = (T3DTriN*)&RDRAM[addr];
addr += 4;

View File

@ -105,7 +105,7 @@ int Calc_invw (int _w) {
static
void ZSort_DrawObject (u8 * _addr, u32 _type)
{
u32 textured, vnum, vsize;
u32 textured = 0, vnum = 0, vsize = 0;
switch (_type) {
case ZH_NULL:
textured = vnum = vsize = 0;
@ -329,8 +329,8 @@ void ZSort_MTXRNSP( u32, u32 )
void ZSort_MTXCAT(u32 _w0, u32 _w1)
{
M44 *s;
M44 *t;
M44 *s = NULL;
M44 *t = NULL;
u32 S = _SHIFTR(_w0, 0, 4);
u32 T = _SHIFTR(_w1, 16, 4);
u32 D = _SHIFTR(_w1, 0, 4);
@ -356,7 +356,7 @@ void ZSort_MTXCAT(u32 _w0, u32 _w1)
t = (M44*)gSP.matrix.combined;
break;
}
assert(s != NULL && t != NULL);
f32 m[4][4];
MultMatrix(*s, *t, m);

View File

@ -883,6 +883,7 @@ void gSPLookAt( u32 _l, u32 _n )
#endif
return;
}
assert(_n < 2);
Light *light = (Light*)&RDRAM[address];
@ -1651,6 +1652,7 @@ void gSPCoordMod(u32 _w0, u32 _w1)
gSP.vertexCoordMod[0+idx] = (f32)(s16)_SHIFTR(_w1, 16, 16);
gSP.vertexCoordMod[1+idx] = (f32)(s16)_SHIFTR(_w1, 0, 16);
} else if (pos == 0x10) {
assert(idx < 3);
gSP.vertexCoordMod[4+idx] = _SHIFTR(_w1, 16, 16)/65536.0f;
gSP.vertexCoordMod[5+idx] = _SHIFTR(_w1, 0, 16)/65536.0f;
gSP.vertexCoordMod[12+idx] = gSP.vertexCoordMod[0+idx] + gSP.vertexCoordMod[4+idx];
@ -2308,8 +2310,8 @@ void gSPSprite2DBase(u32 base)
const f32 z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
const f32 w = 1.0f;
f32 scaleX, scaleY;
u32 flipX, flipY;
f32 scaleX = 1.0f, scaleY = 1.0f;
u32 flipX = 0, flipY = 0;
do {
u32 w0 = *(u32*)&RDRAM[RSP.PC[RSP.PCi]];
u32 w1 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];