nes-fix soft reset functionality which had got broken when i upgraded the cpu core

This commit is contained in:
zeromus 2012-03-18 03:46:06 +00:00
parent 5883401ab1
commit 471b3ffb98
5 changed files with 40 additions and 12 deletions

View File

@ -283,12 +283,13 @@ namespace BizHawk.Emulation.CPUs.M6502
//0x100 //0x100
/*VOP_Fetch1*/ new Uop[] { Uop.Fetch1 }, /*VOP_Fetch1*/ new Uop[] { Uop.Fetch1 },
/*VOP_RelativeStuff*/ new Uop[] { Uop.RelBranch_Stage3, Uop.End }, /*VOP_RelativeStuff*/ new Uop[] { Uop.RelBranch_Stage3, Uop.End },
/*VOP_RelativeStuff2*/ new Uop[] { Uop.RelBranch_Stage4, Uop.End },
//i assume these are dummy fetches.... maybe theyre just nops? supposedly these take 7 cycles so thats the only way i can make sense of it //i assume these are dummy fetches.... maybe theyre just nops? supposedly these take 7 cycles so thats the only way i can make sense of it
//one of them might be the next instruction's fetch, and whatever fetch follows it. //one of them might be the next instruction's fetch, and whatever fetch follows it.
//the interrupt would then take place if necessary, using a cached PC. but im not so sure about that. //the interrupt would then take place if necessary, using a cached PC. but im not so sure about that.
/*VOP_NMI*/ new Uop[] { Uop.FetchDummy, Uop.FetchDummy, Uop.PushPCH, Uop.PushPCL, Uop.PushP_NMI, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End }, /*VOP_NMI*/ new Uop[] { Uop.FetchDummy, Uop.FetchDummy, Uop.PushPCH, Uop.PushPCL, Uop.PushP_NMI, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End },
/*VOP_IRQ*/ new Uop[] { Uop.FetchDummy, Uop.FetchDummy, Uop.PushPCH, Uop.PushPCL, Uop.PushP_IRQ, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End }, /*VOP_IRQ*/ new Uop[] { Uop.FetchDummy, Uop.FetchDummy, Uop.PushPCH, Uop.PushPCL, Uop.PushP_IRQ, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End },
/*VOP_RelativeStuff2*/ new Uop[] { Uop.RelBranch_Stage4, Uop.End }, /*VOP_RESET*/ new Uop[] { Uop.FetchDummy, Uop.FetchDummy, Uop.PushDummy, Uop.PushDummy, Uop.PushP_Reset, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End },
}; };
enum Uop enum Uop
@ -354,7 +355,7 @@ namespace BizHawk.Emulation.CPUs.M6502
IncS, DecS, IncS, DecS,
PushPCL, PushPCH, PushPCH_B, PushP, PullP, PullPCL, PullPCH_NoInc, PushA, PullA_NoInc, PullP_NoInc, PushPCL, PushPCH, PushPCH_B, PushP, PullP, PullPCL, PullPCH_NoInc, PushA, PullA_NoInc, PullP_NoInc,
PushP_BRK, PushP_NMI, PushP_IRQ, PushP_BRK, PushP_NMI, PushP_IRQ, PushP_Reset, PushDummy,
FetchPCLVector, FetchPCHVector, //todo - may not need these ?? can reuse fetch2 and fetch3? FetchPCLVector, FetchPCHVector, //todo - may not need these ?? can reuse fetch2 and fetch3?
//[implied] and [accumulator] //[implied] and [accumulator]
@ -388,9 +389,10 @@ namespace BizHawk.Emulation.CPUs.M6502
const int VOP_Fetch1 = 256; const int VOP_Fetch1 = 256;
const int VOP_RelativeStuff = 257; const int VOP_RelativeStuff = 257;
const int VOP_NMI = 258; const int VOP_RelativeStuff2 = 258;
const int VOP_IRQ = 259; const int VOP_NMI = 259;
const int VOP_RelativeStuff2 = 260; const int VOP_IRQ = 260;
const int VOP_RESET = 261;
int opcode; int opcode;
byte opcode2, opcode3; //opcode bytes.. theoretically redundant with the temp variables? who knows. byte opcode2, opcode3; //opcode bytes.. theoretically redundant with the temp variables? who knows.
@ -515,6 +517,14 @@ namespace BizHawk.Emulation.CPUs.M6502
FlagI = true; //is this right? FlagI = true; //is this right?
ea = NMIVector; ea = NMIVector;
break; break;
case Uop.PushP_Reset:
ea = ResetVector;
S--;
FlagI = true;
break;
case Uop.PushDummy:
S--;
break;
case Uop.FetchPCLVector: case Uop.FetchPCLVector:
alu_temp = ReadMemory((ushort)ea); alu_temp = ReadMemory((ushort)ea);
break; break;
@ -1225,12 +1235,12 @@ namespace BizHawk.Emulation.CPUs.M6502
break; break;
case Uop.End_ISpecial: case Uop.End_ISpecial:
opcode = 256; opcode = VOP_Fetch1;
mi = 0; mi = 0;
goto RETRY; goto RETRY;
case Uop.End: case Uop.End:
opcode = 256; opcode = VOP_Fetch1;
mi = 0; mi = 0;
iflag_pending = FlagI; iflag_pending = FlagI;
goto RETRY; goto RETRY;

View File

@ -29,6 +29,14 @@ namespace BizHawk.Emulation.CPUs.M6502
iflag_pending = true; iflag_pending = true;
} }
public void NESSoftReset()
{
opcode = VOP_RESET;
mi = 0;
iflag_pending = true;
FlagI = true;
}
public string State() public string State()
{ {
int notused; int notused;

View File

@ -68,9 +68,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
lagged = true; lagged = true;
if (resetSignal) if (resetSignal)
{ {
cpu.PC = cpu.ReadWord(MOS6502.ResetVector); cpu.NESSoftReset();
apu.WriteReg(0x4015, 0); //need to study what happens to ppu and apu and stuff..
cpu.FlagI = true;
} }
Controller.UpdateControls(Frame++); Controller.UpdateControls(Frame++);

View File

@ -59,6 +59,19 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public PPU(NES nes) public PPU(NES nes)
{ {
this.nes = nes; this.nes = nes;
OAM = new byte[0x100];
PALRAM = new byte[0x20];
//power-up palette verified by blargg's power_up_palette test.
//he speculates that these may differ depending on the system tested..
//and I don't see why the ppu would waste any effort setting these..
//but for the sake of uniformity, we'll do it.
Array.Copy(new byte[] {
0x09,0x01,0x00,0x01,0x00,0x02,0x02,0x0D,0x08,0x10,0x08,0x24,0x00,0x00,0x04,0x2C,
0x09,0x01,0x34,0x03,0x00,0x04,0x00,0x14,0x08,0x3A,0x00,0x02,0x00,0x20,0x2C,0x08
}, PALRAM, 0x20);
Reset(); Reset();
} }

View File

@ -330,8 +330,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
Reg2002_vblank_active = false; Reg2002_vblank_active = false;
PPUGenLatch = 0; PPUGenLatch = 0;
reg_2003 = 0; reg_2003 = 0;
OAM = new byte[0x100];
PALRAM = new byte[0x20];
vtoggle = false; vtoggle = false;
VRAMBuffer = 0; VRAMBuffer = 0;
} }