Skip to content

Commit

Permalink
GBHawk: Fix Pinball Fantasies
Browse files Browse the repository at this point in the history
  • Loading branch information
alyosha-tas committed May 25, 2018
1 parent e5516b4 commit d6a9d69
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion BizHawk.Emulation.Cores/CPUs/LR35902/Interrupts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ private void INTERRUPT_()
IDLE,
WR, SPl, SPh, PCh,
IDLE,
INT_GET, W,// NOTE: here is where we check for a cancelled IRQ
DEC16, SPl, SPh,
INT_GET, W,// NOTE: here is where we check for a cancelled IRQ
WR, SPl, SPh, PCl,
IDLE,
IDLE,
Expand Down
29 changes: 18 additions & 11 deletions BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,6 @@ public override void tick()
cycle = 0;
LY += LY_inc;
Core.cpu.LY = LY;
// here is where LY = LYC gets cleared (but only if LY isnt 0 as that's a special case)
if (LY_inc == 1)
{
LYC_INT = false;
STAT &= 0xFB;
}

no_scan = false;

Expand Down Expand Up @@ -444,7 +438,7 @@ public override void tick()
//if (STAT.Bit(5)) { OAM_INT = true; }
}

if ((LY == 153) && (cycle == 8))
if ((LY == 153) && (cycle == 6))
{
LY = 0;
LY_inc = 0;
Expand Down Expand Up @@ -505,7 +499,11 @@ public override void tick()
{
if (cycle < 80)
{
if (cycle == 4)
if (cycle == 2)
{
if (LY != 0) { if (STAT.Bit(5)) { OAM_INT = true; } }
}
else if (cycle == 4)
{
// apparently, writes can make it to OAM one cycle longer then reads
OAM_access_write = false;
Expand All @@ -514,7 +512,7 @@ public override void tick()
STAT &= 0xFC;
STAT |= 0x2;

if (STAT.Bit(5)) { OAM_INT = true; }
if (LY == 0) { if (STAT.Bit(5)) { OAM_INT = true; } }

HBL_INT = false;
// DMG exits VBlank into mode 0, but not GBC, so this line is needed
Expand Down Expand Up @@ -565,8 +563,17 @@ public override void tick()
//if (cycle == 92) { OAM_INT = false; }
}

// here LY=LYC will be asserted
if ((cycle == 4) && (LY != 0))
// here LY=LYC will be asserted or cleared (but only if LY isnt 0 as that's a special case)
if ((cycle == 2) && (LY != 0))
{
if (LY_inc == 1)
{
LYC_INT = false;
STAT &= 0xFB;
}

}
else if ((cycle == 4) && (LY != 0))
{
if ((LY == LYC) && !STAT.Bit(2))
{
Expand Down
30 changes: 19 additions & 11 deletions BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ public override void tick()

LY += LY_inc;
Core.cpu.LY = LY;
// here is where LY = LYC gets cleared (but only if LY isnt 0 as that's a special case)
if (LY_inc == 1)
{
LYC_INT = false;
STAT &= 0xFB;
}

no_scan = false;

Expand Down Expand Up @@ -218,7 +212,7 @@ public override void tick()
if (STAT.Bit(5)) { OAM_INT = true; }
}

if ((LY == 153) && (cycle == 8))
if ((LY == 153) && (cycle == 6))
{
LY = 0;
LY_inc = 0;
Expand Down Expand Up @@ -280,15 +274,20 @@ public override void tick()
{
if (cycle < 80)
{
if (cycle == 4)
if (cycle == 2)
{
if (LY != 0) { if (STAT.Bit(5)) { OAM_INT = true; } }
}
else if (cycle == 4)
{
// apparently, writes can make it to OAM one cycle longer then reads
OAM_access_write = false;

// here mode 2 will be set to true and interrupts fired if enabled
STAT &= 0xFC;
STAT |= 0x2;
if (STAT.Bit(5)) { OAM_INT = true; }

if (LY == 0) { if (STAT.Bit(5)) { OAM_INT = true; } }

HBL_INT = false;
}
Expand Down Expand Up @@ -335,8 +334,17 @@ public override void tick()
if (cycle == 92) { OAM_INT = false; }
}

// here LY=LYC will be asserted
if ((cycle == 4) && (LY != 0))
// here LY=LYC will be asserted or cleared (but only if LY isnt 0 as that's a special case)
if ((cycle == 2) && (LY != 0))
{
if (LY_inc == 1)
{
LYC_INT = false;
STAT &= 0xFB;
}

}
else if ((cycle == 4) && (LY != 0))
{
if ((LY == LYC) && !STAT.Bit(2))
{
Expand Down

0 comments on commit d6a9d69

Please sign in to comment.