nes-fix bug in base board class wram functionality (forgot to add masking to wram size configured in the Cart struct by the derived board Configure method)

This commit is contained in:
zeromus 2012-05-27 07:42:13 +00:00
parent 2553ac50bb
commit c5a2d0f8f0
2 changed files with 13 additions and 1 deletions

View File

@ -14,8 +14,12 @@ namespace BizHawk.Emulation.Consoles.Nintendo
{
public interface INESBoard : IDisposable
{
//base class pre-configuration
void Create(NES nes);
//one-time inherited classes configuration
bool Configure(NES.EDetectionOrigin origin);
//one-time base class configuration (which can take advantage of any information setup by the more-informed Configure() method)
void PostConfigure();
//gets called once per PPU clock, for boards with complex behaviour which must be monitoring clock (i.e. mmc3 irq counter)
void ClockPPU();
@ -132,9 +136,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo
if(wram != null)
wram[addr] = value;
}
private int wram_mask;
public virtual void PostConfigure()
{
wram_mask = (Cart.wram_size * 1024) - 1;
}
public virtual byte ReadWRAM(int addr) {
if (wram != null)
return wram[addr];
return wram[addr & wram_mask];
else return 0xFF;
}

View File

@ -530,6 +530,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
cart = choice;
board.Create(this);
board.Configure(origin);
board.PostConfigure();
if (origin == EDetectionOrigin.BootGodDB)
{