Colorised games should now work. This patch hasn't been fully tested.
It is based on a few differences between releases r60 and r61 that broke colorised game support, along with much trial and error.
This commit is contained in:
Carl.Kenner 2009-03-11 22:34:22 +00:00
parent 28f2f392bd
commit afec8200f8

View File

@ -1435,10 +1435,12 @@ void gbWriteMemory(register u16 address, register u8 value)
int paletteHiLo = (v & 0x01); int paletteHiLo = (v & 0x01);
// No access to gbPalette during mode 3 (Color Panel Demo) // No access to gbPalette during mode 3 (Color Panel Demo)
if (((gbLcdModeDelayed != 3) && (!((gbLcdMode == 0) && (gbLcdTicks>=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-1)))) && (!gbSpeed)) || // CAK - The following check has to be commented out for
(gbSpeed && ((gbLcdMode == 1) || (gbLcdMode == 2) || // colourised roms like Metroid 2 DX
((gbLcdMode == 3) && (gbLcdTicks>(GBLCD_MODE_3_CLOCK_TICKS-2))) || //if (((gbLcdModeDelayed != 3) && (!((gbLcdMode == 0) && (gbLcdTicks>=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-1)))) && (!gbSpeed)) ||
((gbLcdMode == 0) && (gbLcdTicks<=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-2)))))) // (gbSpeed && ((gbLcdMode == 1) || (gbLcdMode == 2) ||
// ((gbLcdMode == 3) && (gbLcdTicks>(GBLCD_MODE_3_CLOCK_TICKS-2))) ||
// ((gbLcdMode == 0) && (gbLcdTicks<=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-2))))))
{ {
gbMemory[0xff69] = value; gbMemory[0xff69] = value;
gbPalette[paletteIndex] = (paletteHiLo ? gbPalette[paletteIndex] = (paletteHiLo ?
@ -1489,10 +1491,12 @@ void gbWriteMemory(register u16 address, register u8 value)
paletteIndex += 32; paletteIndex += 32;
// No access to gbPalette during mode 3 (Color Panel Demo) // No access to gbPalette during mode 3 (Color Panel Demo)
if (((gbLcdModeDelayed != 3) && (!((gbLcdMode == 0) && (gbLcdTicks>=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-1)))) && (!gbSpeed)) || // CAK - The following check has to be commented out for
(gbSpeed && ((gbLcdMode == 1) || (gbLcdMode == 2) || // colourised roms like Metroid 2 DX
((gbLcdMode == 3) && (gbLcdTicks>(GBLCD_MODE_3_CLOCK_TICKS-2))) || //if (((gbLcdModeDelayed != 3) && (!((gbLcdMode == 0) && (gbLcdTicks>=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-1)))) && (!gbSpeed)) ||
((gbLcdMode == 0) && (gbLcdTicks<=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-2)))))) // (gbSpeed && ((gbLcdMode == 1) || (gbLcdMode == 2) ||
// ((gbLcdMode == 3) && (gbLcdTicks>(GBLCD_MODE_3_CLOCK_TICKS-2))) ||
// ((gbLcdMode == 0) && (gbLcdTicks<=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-2))))))
{ {
gbMemory[0xff6b] = value; gbMemory[0xff6b] = value;
gbPalette[paletteIndex] = (paletteHiLo ? gbPalette[paletteIndex] = (paletteHiLo ?
@ -1669,13 +1673,13 @@ u8 gbReadOpcode(register u16 address)
if (gbCgbMode) if (gbCgbMode)
{ {
// No access to gbPalette during mode 3 (Color Panel Demo) // No access to gbPalette during mode 3 (Color Panel Demo)
if (((gbLcdModeDelayed != 3) && (!((gbLcdMode == 0) && (gbLcdTicks>=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-1)))) && (!gbSpeed)) || //if (((gbLcdModeDelayed != 3) && (!((gbLcdMode == 0) && (gbLcdTicks>=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-1)))) && (!gbSpeed)) ||
(gbSpeed && ((gbLcdMode == 1) || (gbLcdMode == 2) || // (gbSpeed && ((gbLcdMode == 1) || (gbLcdMode == 2) ||
((gbLcdMode == 3) && (gbLcdTicks>(GBLCD_MODE_3_CLOCK_TICKS-2))) || // ((gbLcdMode == 3) && (gbLcdTicks>(GBLCD_MODE_3_CLOCK_TICKS-2))) ||
((gbLcdMode == 0) && (gbLcdTicks<=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-2)))))) // ((gbLcdMode == 0) && (gbLcdTicks<=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-2))))))
return (gbMemory[address]); return (gbMemory[address]);
else //else
return 0xff; // return 0xff;
} }
else else
return 0xff; return 0xff;
@ -1930,13 +1934,13 @@ u8 gbReadMemory(register u16 address)
if (gbCgbMode) if (gbCgbMode)
{ {
// No access to gbPalette during mode 3 (Color Panel Demo) // No access to gbPalette during mode 3 (Color Panel Demo)
if (((gbLcdModeDelayed != 3) && (!((gbLcdMode == 0) && (gbLcdTicks>=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-1)))) && (!gbSpeed)) || //if (((gbLcdModeDelayed != 3) && (!((gbLcdMode == 0) && (gbLcdTicks>=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-1)))) && (!gbSpeed)) ||
(gbSpeed && ((gbLcdMode == 1) || (gbLcdMode == 2) || // (gbSpeed && ((gbLcdMode == 1) || (gbLcdMode == 2) ||
((gbLcdMode == 3) && (gbLcdTicks>(GBLCD_MODE_3_CLOCK_TICKS-2))) || // ((gbLcdMode == 3) && (gbLcdTicks>(GBLCD_MODE_3_CLOCK_TICKS-2))) ||
((gbLcdMode == 0) && (gbLcdTicks<=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-2)))))) // ((gbLcdMode == 0) && (gbLcdTicks<=(GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]-2))))))
return (gbMemory[address]); return (gbMemory[address]);
else //else
return 0xff; // return 0xff;
} }
else else
return 0xff; return 0xff;
@ -4585,9 +4589,9 @@ void gbEmulate(int ticksToStop)
if (register_LCDCBusy) if (register_LCDCBusy)
{ {
register_LCDCBusy-=clockTicks; //register_LCDCBusy-=clockTicks;
if (register_LCDCBusy<0) //if (register_LCDCBusy<0)
register_LCDCBusy = 0; // register_LCDCBusy = 0;
} }
@ -4843,7 +4847,7 @@ void gbEmulate(int ticksToStop)
framesToSkip = 9; // try 6 FPS during speedup framesToSkip = 9; // try 6 FPS during speedup
//gbLcdTicksDelayed = gbLcdTicks+1; //gbLcdTicksDelayed = gbLcdTicks+1;
gbLCDChangeHappened = false; gbLCDChangeHappened = false;
switch(gbLcdModeDelayed) { switch(gbLcdMode) {
case 0: case 0:
{ {
// H-Blank // H-Blank
@ -4874,7 +4878,7 @@ void gbEmulate(int ticksToStop)
} }
gbLcdTicksDelayed += GBLCD_MODE_1_CLOCK_TICKS; gbLcdTicksDelayed += GBLCD_MODE_1_CLOCK_TICKS;
gbLcdModeDelayed = 1; gbLcdMode = 1;
gbFrameCount++; gbFrameCount++;
systemFrame(); systemFrame();
@ -4947,7 +4951,7 @@ void gbEmulate(int ticksToStop)
} else { } else {
// go the the OAM being accessed mode // go the the OAM being accessed mode
gbLcdTicksDelayed += GBLCD_MODE_2_CLOCK_TICKS; gbLcdTicksDelayed += GBLCD_MODE_2_CLOCK_TICKS;
gbLcdModeDelayed = 2; gbLcdMode = 2;
gbInt48Signal &= ~3; gbInt48Signal &= ~3;
} }
} }
@ -4962,7 +4966,7 @@ void gbEmulate(int ticksToStop)
oldRegister_WY = register_WY; oldRegister_WY = register_WY;
gbLcdTicksDelayed += GBLCD_MODE_2_CLOCK_TICKS; gbLcdTicksDelayed += GBLCD_MODE_2_CLOCK_TICKS;
gbLcdModeDelayed = 2; gbLcdMode = 2;
// reset the window line // reset the window line
gbWindowLine = -1; gbWindowLine = -1;
@ -4973,7 +4977,7 @@ void gbEmulate(int ticksToStop)
// OAM being accessed mode // OAM being accessed mode
// next mode is OAM and VRAM in use // next mode is OAM and VRAM in use
gbLcdTicksDelayed += GBLCD_MODE_3_CLOCK_TICKS+gbSpritesTicks[299]; gbLcdTicksDelayed += GBLCD_MODE_3_CLOCK_TICKS+gbSpritesTicks[299];
gbLcdModeDelayed = 3; gbLcdMode = 3;
} }
break; break;
case 3: case 3:
@ -5006,7 +5010,7 @@ void gbEmulate(int ticksToStop)
} }
} }
gbLcdTicksDelayed += GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299]; gbLcdTicksDelayed += GBLCD_MODE_0_CLOCK_TICKS-gbSpritesTicks[299];
gbLcdModeDelayed = 0; gbLcdMode = 0;
} }
break; break;
} }
@ -5033,7 +5037,7 @@ void gbEmulate(int ticksToStop)
} }
gbLcdLYIncrementTicksDelayed += GBLY_INCREMENT_CLOCK_TICKS; gbLcdLYIncrementTicksDelayed += GBLY_INCREMENT_CLOCK_TICKS;
if (gbLcdModeDelayed == 1) if (gbLcdMode == 1)
{ {
if(register_LY == 153) if(register_LY == 153)