diff --git a/mednafen/src/drivers/debugger.cpp b/mednafen/src/drivers/debugger.cpp index 942d22e..7c33268 100644 --- a/mednafen/src/drivers/debugger.cpp +++ b/mednafen/src/drivers/debugger.cpp @@ -31,6 +31,9 @@ #include "prompt.h" #include "video.h" +bool DebugHSyncFlag = false; +bool DebugVSyncFlag = false; + static MemDebugger* memdbg = NULL; static std::unique_ptr TraceLog; static std::string TraceLogSpec; @@ -47,6 +50,8 @@ static bool NeedPCBPToggle; static int NeedStep; // 0 =, 1 = , 2 = static int NeedRun; static bool InSteppingMode; +static bool WaitForVSYNC = false; +static bool WaitForHSYNC = false; static std::vector PCBreakPoints; static std::string ReadBreakpoints, IOReadBreakpoints, AuxReadBreakpoints; @@ -164,7 +169,7 @@ static void UpdateCoreHooks(void) HaltOnAltD = MDFN_GetSettingB("debugger.haltondebug"); bool BPInUse = PCBreakPoints.size() || ReadBreakpoints.size() || WriteBreakpoints.size() || IOReadBreakpoints.size() || - IOWriteBreakpoints.size() || AuxReadBreakpoints.size() || AuxWriteBreakpoints.size() || OpBreakpoints.size() || HaltOnAltD; + IOWriteBreakpoints.size() || AuxReadBreakpoints.size() || AuxWriteBreakpoints.size() || OpBreakpoints.size() || HaltOnAltD || WaitForHSYNC || WaitForVSYNC; bool CPUCBNeeded = BPInUse || TraceLog || InSteppingMode || (NeedStep == 2); CurGame->Debugger->EnableBranchTrace(BPInUse || TraceLog || IsActive); @@ -182,7 +187,29 @@ static void UpdatePCBreakpoints(void) UpdateCoreHooks(); } -static INLINE bool IsPCBreakPoint(uint32 A) +bool IsVSYNCBreakPoint() +{ + bool VSync_Trigger = Debugger_GT_VSyncIsSet(); + Debugger_GT_ResetVSync(); + + if (WaitForVSYNC && VSync_Trigger) + return(true); + else + return(false); +} + +bool IsHSYNCBreakPoint() +{ + bool HSync_Trigger = Debugger_GT_HSyncIsSet(); + Debugger_GT_ResetHSync(); + + if (WaitForHSYNC && HSync_Trigger) + return(true); + else + return(false); +} + +INLINE bool IsPCBreakPoint(uint32 A) { unsigned int max = PCBreakPoints.size(); @@ -1479,6 +1506,13 @@ static void CPUCallback(uint32 PC, bool bpoint) DoTraceLog(PC); } +INLINE void Debugger_GT_SetHSync(void) { DebugHSyncFlag = true; } +INLINE void Debugger_GT_ResetHSync(void) { DebugHSyncFlag = false; } +INLINE bool Debugger_GT_HSyncIsSet(void) { return(DebugHSyncFlag); } + +INLINE void Debugger_GT_SetVSync(void) { DebugVSyncFlag = true; } +INLINE void Debugger_GT_ResetVSync(void) { DebugVSyncFlag = false; }; +INLINE bool Debugger_GT_VSyncIsSet(void) { return(DebugVSyncFlag); } // Function called from game thread, input driver code. void Debugger_GT_ForceStepIfStepping(void) @@ -1810,8 +1844,29 @@ void Debugger_GT_Event(const SDL_Event *event) break; case SDLK_s: - NeedStep = 2; - UpdateCoreHooks(); + if(event->key.keysym.mod & KMOD_SHIFT) + { + Debugger_GT_ResetVSync(); + Debugger_GT_ResetHSync(); + WaitForHSYNC = true; + WaitForVSYNC = false; + NeedRun = true; + } + else if(event->key.keysym.mod & KMOD_CTRL) + { + Debugger_GT_ResetVSync(); + Debugger_GT_ResetHSync(); + WaitForHSYNC = false; + WaitForVSYNC = true; + NeedRun = true; + } + else + { + WaitForHSYNC = false; + WaitForVSYNC = false; + NeedStep = 2; + UpdateCoreHooks(); + } break; case SDLK_w: @@ -1869,7 +1924,11 @@ void Debugger_GT_Event(const SDL_Event *event) PromptTAKC = event->key.keysym.sym; } else if(InSteppingMode) + { + WaitForHSYNC = false; + WaitForVSYNC = false; NeedRun = true; + } break; case SDLK_l: diff --git a/mednafen/src/drivers/debugger.h b/mednafen/src/drivers/debugger.h index 096ef7f..588f6dd 100644 --- a/mednafen/src/drivers/debugger.h +++ b/mednafen/src/drivers/debugger.h @@ -36,6 +36,17 @@ void Debugger_GT_ForceSteppingMode(void); void Debugger_GT_ForceStepIfStepping(void); // For synchronizations with save state loading and reset/power toggles. void Debugger_GT_SyncDisToPC(void); // Synch disassembly address to current PC/IP/whatever. +void Debugger_GT_SetHSync(void); +void Debugger_GT_ResetHSync(void); +bool Debugger_GT_HSyncIsSet(void); + +void Debugger_GT_SetVSync(void); +void Debugger_GT_ResetVSync(void); +bool Debugger_GT_VSyncIsSet(void); + +bool IsVSYNCBreakPoint(void); +bool IsHSYNCBreakPoint(void); + // Must be called in a specific place in the game thread's execution path. void Debugger_GTR_PassBlit(void); @@ -57,6 +68,18 @@ static INLINE bool Debugger_GT_IsInSteppingMode(void) { return(false); } static INLINE void Debugger_GT_ForceSteppingMode(void) { } static INLINE void Debugger_GT_ForceStepIfStepping(void) { } static INLINE void Debugger_GT_SyncDisToPC(void) { } + +static INLINE void Debugger_GT_SetHSync(void) { } +static INLINE void Debugger_GT_ResetHSync(void) { } +static INLINE bool Debugger_GT_HSyncSet(void) { return(false); } + +static INLINE void Debugger_GT_SetVSync(void) { } +static INLINE void Debugger_GT_ResetVSync(void) { } +static INLINE bool Debugger_GT_VSyncSet(void) { return(false); } + +static INLINE bool IsVSYNCBreakPoint(void) { } +static INLINE bool IsHSYNCBreakPoint(void) { } + static INLINE void Debugger_GTR_PassBlit(void) { } static INLINE void Debugger_MT_DrawToScreen(const MDFN_PixelFormat& pf, signed screen_w, signed screen_h) { } static INLINE bool Debugger_IsActive(void) { return(false); } diff --git a/mednafen/src/hw_video/huc6270/vdc.h b/mednafen/src/hw_video/huc6270/vdc.h index 827fd15..afec3cb 100755 --- a/mednafen/src/hw_video/huc6270/vdc.h +++ b/mednafen/src/hw_video/huc6270/vdc.h @@ -517,7 +517,7 @@ class VDC int HPhase, VPhase; int HNextEvent; int32 HPhaseCounter, VPhaseCounter; - int32 Scanline_from_VSYNC; + uint32 Scanline_from_VSYNC; int32 sprite_cg_fetch_counter; diff --git a/mednafen/src/pce/debug.cpp b/mednafen/src/pce/debug.cpp index b278628..18d18ab 100644 --- a/mednafen/src/pce/debug.cpp +++ b/mednafen/src/pce/debug.cpp @@ -63,6 +63,10 @@ #define EX_GETFNT 0xE060 #define EX_VSYNC 0xE07B +extern bool IsHSYNCBreakPoint(); +extern bool IsVSYNCBreakPoint(); + + namespace MDFN_IEN_PCE { @@ -378,7 +382,7 @@ static bool CPUHandler(uint32 PC) PCE_InDebug++; - FoundBPoint = TestPCBP(PC) | TestOpBP(HuCPU.PeekLogical(PC)); + FoundBPoint = TestPCBP(PC) | TestOpBP(HuCPU.PeekLogical(PC)) | IsVSYNCBreakPoint() | IsHSYNCBreakPoint(); if(NeedExecSimu) TestRWBP(); diff --git a/mednafen/src/pce/vce.cpp b/mednafen/src/pce/vce.cpp index 2877f66..4263c69 100644 --- a/mednafen/src/pce/vce.cpp +++ b/mednafen/src/pce/vce.cpp @@ -32,6 +32,9 @@ #include "pcecd.h" #include +extern bool DebugHSyncFlag; +extern bool DebugVSyncFlag; + namespace MDFN_IEN_PCE { @@ -482,9 +485,13 @@ INLINE void VCE::SyncSub(int32 clocks) { scanline = 0; framenum++; + DebugVSyncFlag = true; } else + { scanline++; + DebugHSyncFlag = true; + } if(scanline == 14 + 240) // does this need to be 242 as well? FrameDone = true;