apply r7371 from bizhawk to mmc5 IRQ handling to fix metal slader glory credits. this may have impact in other MMC5 programs; not tested

This commit is contained in:
zeromus 2014-07-24 06:25:53 +00:00
parent 20d0e3d6c2
commit 6e3567ad16
2 changed files with 30 additions and 11 deletions

View File

@ -512,21 +512,40 @@ void MMC5Synco(void) {
}
void MMC5_hb(int scanline) {
if (scanline == 240) {
//zero 24-jul-2014 - revised for newer understanding, to fix metal slader glory credits. see r7371 in bizhawk
int sl = scanline + 1;
int ppuon = (PPU[1] & 0x18);
if (!ppuon || sl >= 241)
{
// whenever rendering is off for any reason (vblank or forced disable
// the irq counter resets, as well as the inframe flag (easily verifiable from software)
MMC5IRQR &= ~0x40;
MMC5IRQR &= ~0x80;
MMC5LineCounter = 0;
MMC5IRQR = 0x40;
X6502_IRQEnd(FCEU_IQEXT);
return;
}
if (MMC5LineCounter < 240) {
if (MMC5LineCounter == IRQScanline) {
if (!(MMC5IRQR&0x40))
{
MMC5IRQR |= 0x40;
MMC5IRQR &= ~0x80;
MMC5LineCounter = 0;
X6502_IRQEnd(FCEU_IQEXT);
}
else
{
MMC5LineCounter++;
if (MMC5LineCounter == IRQScanline)
{
MMC5IRQR |= 0x80;
if (IRQEnable & 0x80)
X6502_IRQBegin(FCEU_IQEXT);
}
MMC5LineCounter++;
}
if (MMC5LineCounter == 240)
MMC5IRQR = 0;
}
void MMC5_StateRestore(int version) {

View File

@ -1221,7 +1221,7 @@ static void DoLine(void) {
int x;
uint8 *target = XBuf + (scanline << 8);
if (MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline);
if (MMC5Hack) MMC5_hb(scanline);
X6502_Run(256);
EndRL();
@ -1790,7 +1790,7 @@ int FCEUPPU_Loop(int skip) {
DEBUG(FCEUD_UpdatePPUView(scanline, 1));
DoLine();
}
if (MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline);
if (MMC5Hack) MMC5_hb(scanline);
for (x = 1, max = 0, maxref = 0; x < 7; x++) {
if (deempcnt[x] > max) {
max = deempcnt[x];
@ -2033,7 +2033,7 @@ int FCEUX_PPU_Loop(int skip) {
DEBUG(FCEUD_UpdateNTView(scanline = yp, 1));
}
if (sl != 0) if (MMC5Hack && PPUON) MMC5_hb(yp);
if (MMC5Hack) MMC5_hb(yp);
//twiddle the oam buffers
@ -2303,7 +2303,7 @@ int FCEUX_PPU_Loop(int skip) {
runppu(1);
} //scanline loop
if (MMC5Hack && PPUON) MMC5_hb(240);
if (MMC5Hack) MMC5_hb(240);
//idle for one line
runppu(kLineTime);