Quiet some compile warnings (gcc likes to make sure you know operator precedence...)

This commit is contained in:
shuffle2 2010-03-16 23:19:54 +00:00
parent eca4821498
commit b9c5ff1ba3
4 changed files with 67 additions and 36 deletions

View File

@ -73,7 +73,7 @@ bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
return false;
}
if(setjmp(png_ptr->jmpbuf)) {
if(setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr,NULL);
fclose(fp);
return false;

View File

@ -308,7 +308,7 @@ unsigned char *,
unsigned char *pOut, unsigned int dstPitch,
int Xres, int Yres )
{
unsigned int yuv[10]; // yuv[0] not used
unsigned int yuv[10] = {0}; // yuv[0] not used
// yuv[1-9] allows reusage of calculated YUV values
int x, y;
unsigned int linePlus, lineMinus;

View File

@ -1573,14 +1573,30 @@ u8 gbReadOpcode(register u16 address)
if (address < 0xa000)
{
// A lot of 'ugly' checks... But only way to emulate this particular behaviour...
if (((gbHardware & 0xa) && ((gbLcdModeDelayed !=3) || ((register_LY == 0) &&
(gbScreenOn==false) && (register_LCDC & 0x80)) &&
(gbLcdLYIncrementTicksDelayed ==(GBLY_INCREMENT_CLOCK_TICKS-GBLCD_MODE_2_CLOCK_TICKS)))) ||
((gbHardware & 0x5) && (gbLcdModeDelayed !=3) &&
((gbLcdMode !=3) || ((register_LY == 0) && ((gbScreenOn==false) &&
(register_LCDC & 0x80)) &&
(gbLcdLYIncrementTicks ==(GBLY_INCREMENT_CLOCK_TICKS-GBLCD_MODE_2_CLOCK_TICKS))))))
if (
(
(gbHardware & 0xa) &&
(
(gbLcdModeDelayed != 3) ||
(
((register_LY == 0) && (gbScreenOn == false) && (register_LCDC & 0x80)) &&
(gbLcdLYIncrementTicksDelayed == (GBLY_INCREMENT_CLOCK_TICKS - GBLCD_MODE_2_CLOCK_TICKS))
)
)
)
||
(
(gbHardware & 0x5) &&
(gbLcdModeDelayed != 3) &&
(
(gbLcdMode != 3) ||
((register_LY == 0) && ((gbScreenOn == false) && (register_LCDC & 0x80)) &&
(gbLcdLYIncrementTicks == (GBLY_INCREMENT_CLOCK_TICKS - GBLCD_MODE_2_CLOCK_TICKS)))
)
)
)
return gbMemoryMap[address >> 12][address & 0x0fff];
return 0xff;
}
@ -1624,7 +1640,7 @@ u8 gbReadOpcode(register u16 address)
case 0x41:
// This is a GB/C only bug (ie. not GBA/SP).
if ((gbHardware & 7) && (gbLcdMode == 2) && (gbLcdModeDelayed == 1) && (!gbSpeed))
return (0x80 | gbMemory[0xff41] & 0xFC);
return (0x80 | (gbMemory[0xff41] & 0xFC));
else
return (0x80 | gbMemory[0xff41]);
case 0x42:
@ -1720,17 +1736,34 @@ u8 gbReadMemory(register u16 address)
if(address < 0x8000)
return gbMemoryMap[address>>12][address&0x0fff];
if (address < 0xa000)
{
// A lot of 'ugly' checks... But only way to emulate this particular behaviour...
if (((gbHardware & 0xa) && ((gbLcdModeDelayed !=3) || ((register_LY == 0) &&
(gbScreenOn==false) && (register_LCDC & 0x80)) &&
(gbLcdLYIncrementTicksDelayed ==(GBLY_INCREMENT_CLOCK_TICKS-GBLCD_MODE_2_CLOCK_TICKS)))) ||
((gbHardware & 0x5) && (gbLcdModeDelayed !=3) &&
((gbLcdMode !=3) || ((register_LY == 0) && ((gbScreenOn==false) &&
(register_LCDC & 0x80)) &&
(gbLcdLYIncrementTicks ==(GBLY_INCREMENT_CLOCK_TICKS-GBLCD_MODE_2_CLOCK_TICKS))))))
if (
(
(gbHardware & 0xa) &&
(
(gbLcdModeDelayed != 3) ||
(
((register_LY == 0) && (gbScreenOn == false) && (register_LCDC & 0x80)) &&
(gbLcdLYIncrementTicksDelayed == (GBLY_INCREMENT_CLOCK_TICKS - GBLCD_MODE_2_CLOCK_TICKS))
)
)
)
||
(
(gbHardware & 0x5) &&
(gbLcdModeDelayed != 3) &&
(
(gbLcdMode != 3) ||
((register_LY == 0) && ((gbScreenOn == false) && (register_LCDC & 0x80)) &&
(gbLcdLYIncrementTicks == (GBLY_INCREMENT_CLOCK_TICKS - GBLCD_MODE_2_CLOCK_TICKS)))
)
)
)
return gbMemoryMap[address >> 12][address & 0x0fff];
return 0xff;
}
@ -1887,7 +1920,7 @@ u8 gbReadMemory(register u16 address)
case 0x41:
// This is a GB/C only bug (ie. not GBA/SP).
if ((gbHardware & 7) && (gbLcdMode == 2) && (gbLcdModeDelayed == 1) && (!gbSpeed))
return (0x80 | gbMemory[0xff41] & 0xFC);
return (0x80 | (gbMemory[0xff41] & 0xFC));
else
return (0x80 | gbMemory[0xff41]);
case 0x42:
@ -1952,8 +1985,8 @@ u8 gbReadMemory(register u16 address)
}
// OAM not accessible during mode 2 & 3.
if(((address >= 0xfe00) && (address<0xfea0)) &&
(((gbLcdMode | gbLcdModeDelayed) &2) &&
(!(gbSpeed && (gbHardware & 0x2) && !(gbLcdModeDelayed & 2) && (gbLcdMode == 2))) ||
((((gbLcdMode | gbLcdModeDelayed) & 2) &&
(!(gbSpeed && (gbHardware & 0x2) && !(gbLcdModeDelayed & 2) && (gbLcdMode == 2)))) ||
(gbSpeed && (gbHardware & 0x2) && (gbLcdModeDelayed == 0) && (gbLcdTicksDelayed == (GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299])))))
return 0xff;

View File

@ -910,24 +910,24 @@ int cheatsCheckKeys(u32 keys, u32 extended)
}
break;
case GSA_8_BIT_POINTER :
if ((CPUReadMemory(cheatsList[i].address)>=0x02000000) && (CPUReadMemory(cheatsList[i].address)<0x02040000) ||
(CPUReadMemory(cheatsList[i].address)>=0x03000000) && (CPUReadMemory(cheatsList[i].address)<0x03008000))
if (((CPUReadMemory(cheatsList[i].address)>=0x02000000) && (CPUReadMemory(cheatsList[i].address)<0x02040000)) ||
((CPUReadMemory(cheatsList[i].address)>=0x03000000) && (CPUReadMemory(cheatsList[i].address)<0x03008000)))
{
CPUWriteByte(CPUReadMemory(cheatsList[i].address)+((cheatsList[i].value & 0xFFFFFF00) >> 8),
cheatsList[i].value & 0xFF);
}
break;
case GSA_16_BIT_POINTER :
if ((CPUReadMemory(cheatsList[i].address)>=0x02000000) && (CPUReadMemory(cheatsList[i].address)<0x02040000) ||
(CPUReadMemory(cheatsList[i].address)>=0x03000000) && (CPUReadMemory(cheatsList[i].address)<0x03008000))
if (((CPUReadMemory(cheatsList[i].address)>=0x02000000) && (CPUReadMemory(cheatsList[i].address)<0x02040000)) ||
((CPUReadMemory(cheatsList[i].address)>=0x03000000) && (CPUReadMemory(cheatsList[i].address)<0x03008000)))
{
CPUWriteHalfWord(CPUReadMemory(cheatsList[i].address)+((cheatsList[i].value & 0xFFFF0000) >> 15),
cheatsList[i].value & 0xFFFF);
}
break;
case GSA_32_BIT_POINTER :
if ((CPUReadMemory(cheatsList[i].address)>=0x02000000) && (CPUReadMemory(cheatsList[i].address)<0x02040000) ||
(CPUReadMemory(cheatsList[i].address)>=0x03000000) && (CPUReadMemory(cheatsList[i].address)<0x03008000))
if (((CPUReadMemory(cheatsList[i].address)>=0x02000000) && (CPUReadMemory(cheatsList[i].address)<0x02040000)) ||
((CPUReadMemory(cheatsList[i].address)>=0x03000000) && (CPUReadMemory(cheatsList[i].address)<0x03008000)))
{
CPUWriteMemory(CPUReadMemory(cheatsList[i].address),
cheatsList[i].value);
@ -935,15 +935,15 @@ int cheatsCheckKeys(u32 keys, u32 extended)
break;
case GSA_8_BIT_ADD :
CPUWriteByte(cheatsList[i].address,
(cheatsList[i].value & 0xFF) + CPUReadMemory(cheatsList[i].address) & 0xFF);
((cheatsList[i].value & 0xFF) + CPUReadMemory(cheatsList[i].address)) & 0xFF);
break;
case GSA_16_BIT_ADD :
CPUWriteHalfWord(cheatsList[i].address,
(cheatsList[i].value & 0xFFFF) + CPUReadMemory(cheatsList[i].address) & 0xFFFF);
((cheatsList[i].value & 0xFFFF) + CPUReadMemory(cheatsList[i].address)) & 0xFFFF);
break;
case GSA_32_BIT_ADD :
CPUWriteMemory(cheatsList[i].address ,
cheatsList[i].value + CPUReadMemory(cheatsList[i].address) & 0xFFFFFFFF);
(cheatsList[i].value + CPUReadMemory(cheatsList[i].address)) & 0xFFFFFFFF);
break;
case GSA_8_BIT_IF_LOWER_U:
if (!(CPUReadByte(cheatsList[i].address) < (cheatsList[i].value & 0xFF))) {
@ -2678,8 +2678,6 @@ void cheatsReadGameSkip( gzFile file, int version )
utilGzSeek( file, sizeof( cheatsList ), SEEK_CUR );
}
bool firstCodeBreaker = true;
for( int i = 0; i < nCheats; i++ ) {
if( version < 9 ) {
utilGzSeek( file, ( 7 * sizeof(int) ) + ( 52 * sizeof(char) ), SEEK_CUR );