Hello -- I'm having some problems with RBI Baseball and SMB3 in my emulator. The title screen of RBI Baseball is ok, but as soon as I go to the team selection, everything is messed up:
Super Mario Bros. 3 also has some problems. There's some glitching at the title screen, and the status bar scrolls along with playfield vertical scrolling:
I suspect my MMC3 implementation might be a bit messed up, since these are the only games I'm currently having problems with. Here is my MMC3 code -- any glaring errors?
Thanks for any help/suggestions!
James
Super Mario Bros. 3 also has some problems. There's some glitching at the title screen, and the status bar scrolls along with playfield vertical scrolling:
I suspect my MMC3 implementation might be a bit messed up, since these are the only games I'm currently having problems with. Here is my MMC3 code -- any glaring errors?
Code:
#include "StdAfx.h"
#include ".\mapper4.h"
CMapper4::CMapper4(void)
{
mapperName = "MMC3";
}
CMapper4::~CMapper4(void)
{
}
void CMapper4::WriteByte(WORD Address, BYTE Value)
{
unsigned char *c, *p;
switch (Address)
{
case 0x8000:
commandNumber = Value & 0x07;
prgSelect = Value & 0x40 ? true : false;
chrXor = Value & 0x80 ? true : false;
if (prgSelect)
prgBank[PRG_8000] = pPrgRom + (Header->PrgRomPageCount - 1) * 0x4000;
else
prgBank[PRG_C000] = pPrgRom + (Header->PrgRomPageCount - 1) * 0x4000;
break;
case 0x8001:
c = pChrRom + 0x400 * Value;
p = pPrgRom + 0x2000 * Value;
switch (commandNumber)
{
case 0:
if (chrXor)
{
chrBank[CHR_1000] = c;
chrBank[CHR_1400] = c + 0x400;
}
else
{
chrBank[CHR_0000] = c;
chrBank[CHR_0400] = c + 0x400;
}
break;
case 1:
if (chrXor)
{
chrBank[CHR_1800] = c;
chrBank[CHR_1C00] = c + 0x400;
}
else
{
chrBank[CHR_0800] = c;
chrBank[CHR_0C00] = c + 0x400;
}
break;
case 2:
if (chrXor)
chrBank[CHR_0000] = c;
else
chrBank[CHR_1000] = c;
break;
case 3:
if (chrXor)
chrBank[CHR_0400] = c;
else
chrBank[CHR_1400] = c;
break;
case 4:
if (chrXor)
chrBank[CHR_0800] = c;
else
chrBank[CHR_1800] = c;
break;
case 5:
if (chrXor)
chrBank[CHR_0C00] = c;
else
chrBank[CHR_1C00] = c;
break;
case 6:
if (prgSelect)
prgBank[PRG_C000] = p;
else
prgBank[PRG_8000] = p;
break;
case 7:
prgBank[PRG_A000] = p;
break;
}
break;
case 0xa000:
Mirroring = Value & 0x01 ? MIRRORING_HORIZONTAL : MIRRORING_VERTICAL;
break;
case 0xa001:
writeProtectSram = Value & 0x40 ? true : false;
break;
case 0xc000:
irqReload = Value;
break;
case 0xc001:
irqCounter = 0;
reloadIrq = true;
break;
case 0xe000:
irqEnabled = false;
break;
case 0xe001:
irqEnabled = true;
break;
default:
break;
}
}
bool CMapper4::HBlank(void)
{
if (reloadIrq)
{
reloadIrq = false;
irqCounter = irqReload;
}
else if (--irqCounter == 0)
{
irqCounter = irqReload;
if (irqEnabled)
{
return true;
}
}
return false;
}
void CMapper4::Initialize(void)
{
unsigned char *x = pPrgRom + (Header->PrgRomPageCount - 1) * 0x4000;
prgBank[PRG_C000] = x;
prgBank[PRG_E000] = x + 0x2000;
irq = false;
irqCounter = 0;
irqReload = 0;
irqEnabled = false;
reloadIrq = false;
}
#include ".\mapper4.h"
CMapper4::CMapper4(void)
{
mapperName = "MMC3";
}
CMapper4::~CMapper4(void)
{
}
void CMapper4::WriteByte(WORD Address, BYTE Value)
{
unsigned char *c, *p;
switch (Address)
{
case 0x8000:
commandNumber = Value & 0x07;
prgSelect = Value & 0x40 ? true : false;
chrXor = Value & 0x80 ? true : false;
if (prgSelect)
prgBank[PRG_8000] = pPrgRom + (Header->PrgRomPageCount - 1) * 0x4000;
else
prgBank[PRG_C000] = pPrgRom + (Header->PrgRomPageCount - 1) * 0x4000;
break;
case 0x8001:
c = pChrRom + 0x400 * Value;
p = pPrgRom + 0x2000 * Value;
switch (commandNumber)
{
case 0:
if (chrXor)
{
chrBank[CHR_1000] = c;
chrBank[CHR_1400] = c + 0x400;
}
else
{
chrBank[CHR_0000] = c;
chrBank[CHR_0400] = c + 0x400;
}
break;
case 1:
if (chrXor)
{
chrBank[CHR_1800] = c;
chrBank[CHR_1C00] = c + 0x400;
}
else
{
chrBank[CHR_0800] = c;
chrBank[CHR_0C00] = c + 0x400;
}
break;
case 2:
if (chrXor)
chrBank[CHR_0000] = c;
else
chrBank[CHR_1000] = c;
break;
case 3:
if (chrXor)
chrBank[CHR_0400] = c;
else
chrBank[CHR_1400] = c;
break;
case 4:
if (chrXor)
chrBank[CHR_0800] = c;
else
chrBank[CHR_1800] = c;
break;
case 5:
if (chrXor)
chrBank[CHR_0C00] = c;
else
chrBank[CHR_1C00] = c;
break;
case 6:
if (prgSelect)
prgBank[PRG_C000] = p;
else
prgBank[PRG_8000] = p;
break;
case 7:
prgBank[PRG_A000] = p;
break;
}
break;
case 0xa000:
Mirroring = Value & 0x01 ? MIRRORING_HORIZONTAL : MIRRORING_VERTICAL;
break;
case 0xa001:
writeProtectSram = Value & 0x40 ? true : false;
break;
case 0xc000:
irqReload = Value;
break;
case 0xc001:
irqCounter = 0;
reloadIrq = true;
break;
case 0xe000:
irqEnabled = false;
break;
case 0xe001:
irqEnabled = true;
break;
default:
break;
}
}
bool CMapper4::HBlank(void)
{
if (reloadIrq)
{
reloadIrq = false;
irqCounter = irqReload;
}
else if (--irqCounter == 0)
{
irqCounter = irqReload;
if (irqEnabled)
{
return true;
}
}
return false;
}
void CMapper4::Initialize(void)
{
unsigned char *x = pPrgRom + (Header->PrgRomPageCount - 1) * 0x4000;
prgBank[PRG_C000] = x;
prgBank[PRG_E000] = x + 0x2000;
irq = false;
irqCounter = 0;
irqReload = 0;
irqEnabled = false;
reloadIrq = false;
}
Thanks for any help/suggestions!
James