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; return false;
} }
if(setjmp(png_ptr->jmpbuf)) { if(setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr,NULL); png_destroy_write_struct(&png_ptr,NULL);
fclose(fp); fclose(fp);
return false; return false;

View File

@ -308,7 +308,7 @@ unsigned char *,
unsigned char *pOut, unsigned int dstPitch, unsigned char *pOut, unsigned int dstPitch,
int Xres, int Yres ) 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 // yuv[1-9] allows reusage of calculated YUV values
int x, y; int x, y;
unsigned int linePlus, lineMinus; unsigned int linePlus, lineMinus;

View File

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

View File

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