improve code quality
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@902 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
b18b0c6d13
commit
38e95d00b5
|
@ -2437,7 +2437,7 @@ void gbReset()
|
|||
gbTimerOn = false;
|
||||
|
||||
if(gbCgbMode) {
|
||||
for (int i = 0; i<0x20; i++)
|
||||
for (i = 0; i<0x20; i++)
|
||||
gbPalette[i] = 0x7fff;
|
||||
|
||||
// This is just to show that the starting values of the OBJ palettes are different
|
||||
|
@ -2555,11 +2555,11 @@ void gbReset()
|
|||
}
|
||||
} else {
|
||||
if(gbSgbMode) {
|
||||
for(int i = 0; i < 8; i++)
|
||||
for(i = 0; i < 8; i++)
|
||||
gbPalette[i] = systemGbPalette[gbPaletteOption*8+i];
|
||||
|
||||
}
|
||||
for(int i = 0; i < 8; i++)
|
||||
for(i = 0; i < 8; i++)
|
||||
gbPalette[i] = systemGbPalette[gbPaletteOption*8+i];
|
||||
}
|
||||
|
||||
|
@ -4079,7 +4079,9 @@ bool gbUpdateSizes()
|
|||
}
|
||||
|
||||
if(gbRomSize < gbRomSizes[gbRom[0x148]]) {
|
||||
gbRom = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]);
|
||||
u8 *gbRomNew = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]);
|
||||
if( !gbRomNew ) { assert( false ); return false; };
|
||||
gbRom = gbRomNew;
|
||||
for (int i = gbRomSize; i<gbRomSizes[gbRom[0x148]]; i++)
|
||||
gbRom[i] = 0x00; // Not sure if it's 0x00, 0xff or random data...
|
||||
}
|
||||
|
@ -4097,7 +4099,9 @@ bool gbUpdateSizes()
|
|||
}
|
||||
gbRom[0x148]++;
|
||||
}
|
||||
gbRom = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]);
|
||||
u8 *gbRomNew = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]);
|
||||
if( !gbRomNew ) { assert( false ); return false; };
|
||||
gbRom = gbRomNew;
|
||||
}
|
||||
gbRomSize = gbRomSizes[gbRom[0x148]];
|
||||
gbRomSizeMask = gbRomSizesMasks[gbRom[0x148]];
|
||||
|
@ -4305,36 +4309,36 @@ bool gbUpdateSizes()
|
|||
return true;
|
||||
}
|
||||
|
||||
int gbGetNextEvent (int clockTicks)
|
||||
int gbGetNextEvent (int _clockTicks)
|
||||
{
|
||||
if (register_LCDC & 0x80)
|
||||
{
|
||||
if(gbLcdTicks < clockTicks)
|
||||
clockTicks = gbLcdTicks;
|
||||
if(gbLcdTicks < _clockTicks)
|
||||
_clockTicks = gbLcdTicks;
|
||||
|
||||
if(gbLcdTicksDelayed < clockTicks)
|
||||
clockTicks = gbLcdTicksDelayed;
|
||||
if(gbLcdTicksDelayed < _clockTicks)
|
||||
_clockTicks = gbLcdTicksDelayed;
|
||||
|
||||
if(gbLcdLYIncrementTicksDelayed < clockTicks)
|
||||
clockTicks = gbLcdLYIncrementTicksDelayed;
|
||||
if(gbLcdLYIncrementTicksDelayed < _clockTicks)
|
||||
_clockTicks = gbLcdLYIncrementTicksDelayed;
|
||||
}
|
||||
|
||||
if(gbLcdLYIncrementTicks < clockTicks)
|
||||
clockTicks = gbLcdLYIncrementTicks;
|
||||
if(gbLcdLYIncrementTicks < _clockTicks)
|
||||
_clockTicks = gbLcdLYIncrementTicks;
|
||||
|
||||
if(gbSerialOn && (gbSerialTicks < clockTicks))
|
||||
clockTicks = gbSerialTicks;
|
||||
if(gbSerialOn && (gbSerialTicks < _clockTicks))
|
||||
_clockTicks = gbSerialTicks;
|
||||
|
||||
if(gbTimerOn && (((gbInternalTimer) & gbTimerMask[gbTimerMode])+1 < clockTicks))
|
||||
clockTicks = ((gbInternalTimer) & gbTimerMask[gbTimerMode])+1;
|
||||
if(gbTimerOn && (((gbInternalTimer) & gbTimerMask[gbTimerMode])+1 < _clockTicks))
|
||||
_clockTicks = ((gbInternalTimer) & gbTimerMask[gbTimerMode])+1;
|
||||
|
||||
//if(soundTicks && (soundTicks < clockTicks))
|
||||
// clockTicks = soundTicks;
|
||||
//if(soundTicks && (soundTicks < _clockTicks))
|
||||
// _clockTicks = soundTicks;
|
||||
|
||||
if ((clockTicks<=0) || (gbInterruptWait))
|
||||
clockTicks = 1;
|
||||
if ((_clockTicks<=0) || (gbInterruptWait))
|
||||
_clockTicks = 1;
|
||||
|
||||
return clockTicks;
|
||||
return _clockTicks;
|
||||
}
|
||||
|
||||
void gbDrawLine()
|
||||
|
|
|
@ -245,22 +245,22 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
|||
else
|
||||
xxx = 7 - xx;
|
||||
|
||||
u16 c;
|
||||
u16 cc;
|
||||
if (color) {
|
||||
c = gbPalette[palette + color];
|
||||
cc = gbPalette[palette + color];
|
||||
} else {
|
||||
c = gbPalette[0];
|
||||
cc = gbPalette[0];
|
||||
}
|
||||
|
||||
switch(systemColorDepth) {
|
||||
case 16:
|
||||
gbSgbDraw16Bit(dest + yyy*(256+2) + xxx, c);
|
||||
gbSgbDraw16Bit(dest + yyy*(256+2) + xxx, cc);
|
||||
break;
|
||||
case 24:
|
||||
gbSgbDraw24Bit(dest8 + (yyy*256+xxx)*3, c);
|
||||
gbSgbDraw24Bit(dest8 + (yyy*256+xxx)*3, cc);
|
||||
break;
|
||||
case 32:
|
||||
gbSgbDraw32Bit(dest32 + yyy*(256+1)+xxx, c);
|
||||
gbSgbDraw32Bit(dest32 + yyy*(256+1)+xxx, cc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -454,7 +454,7 @@ static inline void CPUWriteMemory(u32 address, u32 value)
|
|||
}
|
||||
goto unwritable;
|
||||
case 0x0E:
|
||||
if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) {
|
||||
if((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled) {
|
||||
(*cpuSaveGameFunc)(address, (u8)value);
|
||||
break;
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ static inline void CPUWriteHalfWord(u32 address, u16 value)
|
|||
}
|
||||
goto unwritable;
|
||||
case 14:
|
||||
if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) {
|
||||
if((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled) {
|
||||
(*cpuSaveGameFunc)(address, (u8)value);
|
||||
break;
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ static inline void CPUWriteByte(u32 address, u8 b)
|
|||
}
|
||||
goto unwritable;
|
||||
case 14:
|
||||
if (!(saveType == 5) && (!eepromInUse | cpuSramEnabled | cpuFlashEnabled)) {
|
||||
if ((saveType != 5) && ((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled)) {
|
||||
|
||||
//if(!cpuEEPROMEnabled && (cpuSramEnabled | cpuFlashEnabled)) {
|
||||
|
||||
|
|
|
@ -696,7 +696,7 @@ void BIOS_LZ77UnCompVram()
|
|||
int length = (data >> 12) + 3;
|
||||
int offset = (data & 0x0FFF);
|
||||
u32 windowOffset = dest + byteCount - offset - 1;
|
||||
for(int i = 0; i < length; i++) {
|
||||
for(int i2 = 0; i2 < length; i2++) {
|
||||
writeValue |= (CPUReadByte(windowOffset++) << byteShift);
|
||||
byteShift += 8;
|
||||
byteCount++;
|
||||
|
@ -781,7 +781,7 @@ void BIOS_LZ77UnCompWram()
|
|||
int length = (data >> 12) + 3;
|
||||
int offset = (data & 0x0FFF);
|
||||
u32 windowOffset = dest - offset - 1;
|
||||
for(int i = 0; i < length; i++) {
|
||||
for(int i2 = 0; i2 < length; i2++) {
|
||||
CPUWriteByte(dest++, CPUReadByte(windowOffset++));
|
||||
len--;
|
||||
if(len == 0)
|
||||
|
|
|
@ -968,7 +968,7 @@ void systemDrawScreen()
|
|||
theApp.aviRecorder = NULL;
|
||||
theApp.aviRecording = false;
|
||||
}
|
||||
delete bmp;
|
||||
delete [] bmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2141,7 +2141,7 @@ void VBA::updatePriority()
|
|||
bool VBA::detectMMX()
|
||||
{
|
||||
bool support = false;
|
||||
char brand[13];
|
||||
char brand[12]; // not zero terminated
|
||||
|
||||
// check for Intel chip
|
||||
__try {
|
||||
|
|
|
@ -211,6 +211,7 @@ bool XAudio2_Output::init(long sampleRate)
|
|||
ASSERT( hr == S_OK );
|
||||
float *matrix = NULL;
|
||||
matrix = (float*)malloc( sizeof( float ) * 2 * dd.OutputFormat.Format.nChannels );
|
||||
if( matrix == NULL ) return false;
|
||||
bool matrixAvailable = true;
|
||||
switch( dd.OutputFormat.Format.nChannels ) {
|
||||
case 4: // 4.0
|
||||
|
|
Loading…
Reference in New Issue