From 25dbca891be038ff2b432b1c9dd43b50529d5b9c Mon Sep 17 00:00:00 2001 From: tomch Date: Sun, 2 Jul 2006 17:52:23 +0000 Subject: [PATCH] Fix for step in debugger from reset (1st step would just do the CPU reset): . Removed CPU reset processing from InternalCpuExecute(). This is now done in CpuReset(). Removed the now redundant regs.bRESET member. . CpuReset() now also clears regs.bJammed. --- source/CPU.cpp | 33 +++++++-------------------------- source/CPU.h | 1 - 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/source/CPU.cpp b/source/CPU.cpp index 1ebede06..07bfd728 100644 --- a/source/CPU.cpp +++ b/source/CPU.cpp @@ -855,17 +855,6 @@ static DWORD InternalCpuExecute (DWORD totalcycles) nInternalCyclesLeft = (totalcycles<<8) - (cycles<<8); USHORT uExtraCycles = 0; - if (regs.bRESET) - { - regs.bRESET = 0; - EF_TO_AF - regs.ps = (regs.ps | AF_INTERRUPT) & ~AF_DECIMAL; - regs.pc = * (WORD*) (mem+0xFFFC); - regs.sp = 0x0100 | ((regs.sp - 3) & 0xFF); - CYC(7); - continue; - } - BYTE iOpcode = *(mem+regs.pc); if (CheckDebugBreak( iOpcode )) break; @@ -1172,17 +1161,6 @@ static DWORD InternalCpuExecute (DWORD totalcycles) nInternalCyclesLeft = (totalcycles<<8) - (cycles<<8); USHORT uExtraCycles = 0; - if (regs.bRESET) - { - regs.bRESET = 0; - EF_TO_AF - regs.ps = regs.ps | AF_INTERRUPT; - regs.pc = * (WORD*) (mem+0xFFFC); - regs.sp = 0x0100 | ((regs.sp - 3) & 0xFF); - CYC(7); - continue; - } - BYTE iOpcode = *(mem+regs.pc); if (CheckDebugBreak( iOpcode )) break; @@ -1614,9 +1592,7 @@ void CpuInitialize () { CpuDestroy(); regs.a = regs.x = regs.y = regs.ps = 0xFF; regs.sp = 0x01FF; - regs.pc=*(LPWORD)(mem+0xFFFC); - regs.bRESET = 1; - regs.bJammed = 0; + CpuReset(); // Init's ps & pc. Updates sp InitializeCriticalSection(&g_CriticalSection); g_bCritSectionValid = true; @@ -1776,7 +1752,12 @@ void CpuNmiDeassert(eIRQSRC Device) //=========================================================================== void CpuReset() { - regs.bRESET = 1; + // 7 cycles + regs.ps = (regs.ps | AF_INTERRUPT) & ~AF_DECIMAL; + regs.pc = * (WORD*) (mem+0xFFFC); + regs.sp = 0x0100 | ((regs.sp - 3) & 0xFF); + + regs.bJammed = 0; } //=========================================================================== diff --git a/source/CPU.h b/source/CPU.h index 89df0b25..159d1773 100644 --- a/source/CPU.h +++ b/source/CPU.h @@ -11,7 +11,6 @@ typedef struct _regsrec { BYTE ps; // processor status WORD pc; // program counter WORD sp; // stack pointer - BYTE bRESET; // RESET asserted flag BYTE bJammed; // CPU has crashed (NMOS 6502 only) } regsrec, *regsptr;