nes: sxrom: decrease speed by 1%, also fix overflow possibility

This commit is contained in:
goyuken 2012-11-02 19:52:02 +00:00
parent 3eda4a90a6
commit 323caaaff7
1 changed files with 13 additions and 5 deletions

View File

@ -207,19 +207,26 @@ namespace BizHawk.Emulation.Consoles.Nintendo
//configuration
protected int prg_mask, chr_mask;
protected int vram_mask;
const int pputimeout = 4; // i don't know if this is right, but anything lower will not boot Bill & Ted
bool disablemirror = false; // mapper 171: mmc1 without mirroring control
//state
public MMC1 mmc1;
/// <summary>cpu cyle when the last MMC1 serial write occured</summary>
int lastwritecycle;
/// <summary>number of cycles since last WritePRG()</summary>
uint ppuclock;
public override void ClockPPU()
{
if (ppuclock < pputimeout)
ppuclock++;
}
public override void WritePRG(int addr, byte value)
{
// mmc1 ignores subsequent writes that are very close together
if (NES.cpu.TotalExecutedCycles - lastwritecycle != 1)
if (ppuclock >= pputimeout)
{
lastwritecycle = NES.cpu.TotalExecutedCycles;
ppuclock = 0;
mmc1.Write(addr, value);
if (!disablemirror)
SetMirrorType(mmc1.mirror); //often redundant, but gets the job done
@ -265,7 +272,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
{
base.SyncState(ser);
mmc1.SyncState(ser);
ser.Sync("lastwritecycle", ref lastwritecycle);
ser.Sync("ppuclock", ref ppuclock);
}
public override bool Configure(NES.EDetectionOrigin origin)
@ -359,6 +366,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
chr_mask = (Cart.chr_size / 8 * 2) - 1;
if (!disablemirror)
SetMirrorType(mmc1.mirror);
ppuclock = pputimeout;
}
} //class SxROM