From 96997ddf95b2464cd2171c23c739067ad36f160f Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 30 Apr 2017 06:39:27 +0000 Subject: [PATCH] fix breakpoints in stack triggering once when theyre fresh, or something like that --- trunk/src/debug.cpp | 15 ++++++++++----- trunk/src/x6502.cpp | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/trunk/src/debug.cpp b/trunk/src/debug.cpp index 50426e71..c1c6e2bc 100644 --- a/trunk/src/debug.cpp +++ b/trunk/src/debug.cpp @@ -569,7 +569,7 @@ void BreakHit(int bp_num, bool force) #endif } -uint8 StackAddrBackup = X.S; +int StackAddrBackup; uint16 StackNextIgnorePC = 0xFFFF; ///fires a breakpoint @@ -744,7 +744,7 @@ static void breakpoint(uint8 *opcode, uint16 A, int size) { StackNextIgnorePC = 0xFFFF; } else { - if ((X.S < StackAddrBackup) && (stackop==0)) + if (StackAddrBackup != -1 && (X.S < StackAddrBackup) && (stackop==0)) { // Unannounced stack mem breaks // Pushes to stack @@ -763,7 +763,7 @@ static void breakpoint(uint8 *opcode, uint16 A, int size) { } } } - } else if ((StackAddrBackup < X.S) && (stackop==0)) + } else if (StackAddrBackup != -1 && (StackAddrBackup < X.S) && (stackop==0)) { // Pulls from stack if (watchpoint[i].flags & WP_R) @@ -790,11 +790,16 @@ static void breakpoint(uint8 *opcode, uint16 A, int size) { } //loop across all breakpoints STOPCHECKING: + + //Update the stack address with the current one, now that changes have registered. + //ZEROMUS THINKS IT MAKES MORE SENSE HERE + StackAddrBackup = X.S; + if(breakHit != -1) BreakHit(i); - //Update the stack address with the current one, now that changes have registered. - StackAddrBackup = X.S; + ////Update the stack address with the current one, now that changes have registered. + //StackAddrBackup = X.S; } //bbit edited: this is the end of the inserted code diff --git a/trunk/src/x6502.cpp b/trunk/src/x6502.cpp index 0564073e..c167adc8 100644 --- a/trunk/src/x6502.cpp +++ b/trunk/src/x6502.cpp @@ -406,12 +406,14 @@ void X6502_Init(void) } } +extern int StackAddrBackup; void X6502_Power(void) { _count=_tcount=_IRQlow=_PC=_A=_X=_Y=_P=_PI=_DB=_jammed=0; _S=0xFD; timestamp=soundtimestamp=0; X6502_Reset(); + StackAddrBackup = -1; } void X6502_Run(int32 cycles)