GBHAWk: PPU work (Fixes ken griffy Jr presents)

This commit is contained in:
alyosha-tas 2018-07-03 08:58:12 -04:00
parent da15b64eca
commit 704e560d59
2 changed files with 34 additions and 46 deletions

View File

@ -120,6 +120,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
STAT = (byte)((value & 0xF8) | (STAT & 7) | 0x80); STAT = (byte)((value & 0xF8) | (STAT & 7) | 0x80);
if (!STAT.Bit(6)) { LYC_INT = false; }
if (!STAT.Bit(4)) { VBL_INT = false; }
break; break;
case 0xFF42: // SCY case 0xFF42: // SCY
scroll_y = value; scroll_y = value;
@ -360,20 +363,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
LY_inc = 1; LY_inc = 1;
Core.in_vblank = false; Core.in_vblank = false;
/*
VBL_INT = false;
if (STAT.Bit(3)) { HBL_INT = true; }
STAT &= 0xFC;
*/
// special note here, the y coordiate of the window is kept if the window is deactivated // special note here, the y coordiate of the window is kept if the window is deactivated
// meaning it will pick up where it left off if re-enabled later // meaning it will pick up where it left off if re-enabled later
// so we don't reset it in the scanline loop // so we don't reset it in the scanline loop
window_y_tile = 0; window_y_tile = 0;
window_y_tile_inc = 0; window_y_tile_inc = 0;
window_started = false; window_started = false;
if (!LCDC.Bit(5)) { window_is_reset = true; } if (!LCDC.Bit(5)) { window_is_reset = true; }
} }
// Automatically restore access to VRAM at this time (force end drawing) // Automatically restore access to VRAM at this time (force end drawing)
@ -424,6 +420,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
HBL_INT = false; HBL_INT = false;
// there is an edge case where a VBL INT is triggered if STAT bit 5 is set
if (STAT.Bit(5)) { VBL_INT = true; }
// set STAT mode to 1 (VBlank) and interrupt flag if it is enabled // set STAT mode to 1 (VBlank) and interrupt flag if it is enabled
STAT &= 0xFC; STAT &= 0xFC;
STAT |= 0x01; STAT |= 0x01;
@ -432,12 +431,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
Core.REG_FF0F |= 0x01; Core.REG_FF0F |= 0x01;
} }
if ((LY >= 144) && (cycle == 4))
{
// a special case of OAM mode 2 IRQ assertion, even though PPU Mode still is 1
//if (STAT.Bit(5)) { OAM_INT = true; }
}
if ((LY == 153) && (cycle == 6)) if ((LY == 153) && (cycle == 6))
{ {
LY = 0; LY = 0;
@ -501,7 +494,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{ {
if (cycle == 2) if (cycle == 2)
{ {
if (LY != 0) { if (STAT.Bit(5)) { OAM_INT = true; } } if (LY != 0)
{
HBL_INT = false;
if (STAT.Bit(5)) { OAM_INT = true; }
}
} }
else if (cycle == 4) else if (cycle == 4)
{ {
@ -512,12 +509,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
STAT &= 0xFC; STAT &= 0xFC;
STAT |= 0x2; STAT |= 0x2;
if (LY == 0) { if (STAT.Bit(5)) { OAM_INT = true; } } if (LY == 0)
{
HBL_INT = false; VBL_INT = false;
// DMG exits VBlank into mode 0, but not GBC, so this line is needed if (STAT.Bit(5)) { OAM_INT = true; }
// (This is important for Wacky Racers and Altered Space) }
VBL_INT = false;
} }
// here OAM scanning is performed // here OAM scanning is performed
@ -555,12 +551,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
STAT |= 0x04; STAT |= 0x04;
if (STAT.Bit(6)) { LYC_INT = true; } if (STAT.Bit(6)) { LYC_INT = true; }
} }
// also a special case of OAM mode 2 IRQ assertion, even though PPU Mode still is 1
//if (STAT.Bit(5)) { OAM_INT = true; }
} }
//if (cycle == 92) { OAM_INT = false; }
} }
// here LY=LYC will be asserted or cleared (but only if LY isnt 0 as that's a special case) // here LY=LYC will be asserted or cleared (but only if LY isnt 0 as that's a special case)
@ -571,7 +562,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
LYC_INT = false; LYC_INT = false;
STAT &= 0xFB; STAT &= 0xFB;
} }
} }
else if ((cycle == 4) && (LY != 0)) else if ((cycle == 4) && (LY != 0))
{ {

View File

@ -61,6 +61,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
STAT = (byte)((value & 0xF8) | (STAT & 7) | 0x80); STAT = (byte)((value & 0xF8) | (STAT & 7) | 0x80);
if (!STAT.Bit(6)) { LYC_INT = false; }
if (!STAT.Bit(4)) { VBL_INT = false; }
break; break;
case 0xFF42: // SCY case 0xFF42: // SCY
scroll_y = value; scroll_y = value;
@ -136,9 +139,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
LY_inc = 1; LY_inc = 1;
Core.in_vblank = false; Core.in_vblank = false;
VBL_INT = false;
if (STAT.Bit(3)) { HBL_INT = true; }
STAT &= 0xFC; STAT &= 0xFC;
// special note here, the y coordiate of the window is kept if the window is deactivated // special note here, the y coordiate of the window is kept if the window is deactivated
@ -198,6 +198,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
HBL_INT = false; HBL_INT = false;
// there is an edge case where a VBL INT is triggered if STAT bit 5 is set
if (STAT.Bit(5)) { VBL_INT = true; }
// set STAT mode to 1 (VBlank) and interrupt flag if it is enabled // set STAT mode to 1 (VBlank) and interrupt flag if it is enabled
STAT &= 0xFC; STAT &= 0xFC;
STAT |= 0x01; STAT |= 0x01;
@ -206,12 +209,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
Core.REG_FF0F |= 0x01; Core.REG_FF0F |= 0x01;
} }
if ((LY >= 144) && (cycle == 4))
{
// a special case of OAM mode 2 IRQ assertion, even though PPU Mode still is 1
if (STAT.Bit(5)) { OAM_INT = true; }
}
if ((LY == 153) && (cycle == 6)) if ((LY == 153) && (cycle == 6))
{ {
LY = 0; LY = 0;
@ -275,8 +272,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
if (cycle < 80) if (cycle < 80)
{ {
if (cycle == 2) if (cycle == 2)
{ {
if (LY != 0) { if (STAT.Bit(5)) { OAM_INT = true; } } if (LY != 0)
{
HBL_INT = false;
if (STAT.Bit(5)) { OAM_INT = true; }
}
} }
else if (cycle == 4) else if (cycle == 4)
{ {
@ -287,9 +288,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
STAT &= 0xFC; STAT &= 0xFC;
STAT |= 0x2; STAT |= 0x2;
if (LY == 0) { if (STAT.Bit(5)) { OAM_INT = true; } } if (LY == 0)
{
HBL_INT = false; VBL_INT = false;
if (STAT.Bit(5)) { OAM_INT = true; }
}
} }
// here OAM scanning is performed // here OAM scanning is performed
@ -326,12 +329,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
STAT |= 0x04; STAT |= 0x04;
if (STAT.Bit(6)) { LYC_INT = true; } if (STAT.Bit(6)) { LYC_INT = true; }
} }
// also a special case of OAM mode 2 IRQ assertion, even though PPU Mode still is 1
if (STAT.Bit(5)) { OAM_INT = true; }
} }
if (cycle == 92) { OAM_INT = false; }
} }
// here LY=LYC will be asserted or cleared (but only if LY isnt 0 as that's a special case) // here LY=LYC will be asserted or cleared (but only if LY isnt 0 as that's a special case)