fix breakpoints in stack triggering once when theyre fresh, or something like that

This commit is contained in:
zeromus 2017-04-30 06:39:27 +00:00
parent a85a840f36
commit 96997ddf95
2 changed files with 12 additions and 5 deletions

View File

@ -569,7 +569,7 @@ void BreakHit(int bp_num, bool force)
#endif #endif
} }
uint8 StackAddrBackup = X.S; int StackAddrBackup;
uint16 StackNextIgnorePC = 0xFFFF; uint16 StackNextIgnorePC = 0xFFFF;
///fires a breakpoint ///fires a breakpoint
@ -744,7 +744,7 @@ static void breakpoint(uint8 *opcode, uint16 A, int size) {
StackNextIgnorePC = 0xFFFF; StackNextIgnorePC = 0xFFFF;
} else } else
{ {
if ((X.S < StackAddrBackup) && (stackop==0)) if (StackAddrBackup != -1 && (X.S < StackAddrBackup) && (stackop==0))
{ {
// Unannounced stack mem breaks // Unannounced stack mem breaks
// Pushes to stack // 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 // Pulls from stack
if (watchpoint[i].flags & WP_R) if (watchpoint[i].flags & WP_R)
@ -790,11 +790,16 @@ static void breakpoint(uint8 *opcode, uint16 A, int size) {
} //loop across all breakpoints } //loop across all breakpoints
STOPCHECKING: 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) if(breakHit != -1)
BreakHit(i); BreakHit(i);
//Update the stack address with the current one, now that changes have registered. ////Update the stack address with the current one, now that changes have registered.
StackAddrBackup = X.S; //StackAddrBackup = X.S;
} }
//bbit edited: this is the end of the inserted code //bbit edited: this is the end of the inserted code

View File

@ -406,12 +406,14 @@ void X6502_Init(void)
} }
} }
extern int StackAddrBackup;
void X6502_Power(void) void X6502_Power(void)
{ {
_count=_tcount=_IRQlow=_PC=_A=_X=_Y=_P=_PI=_DB=_jammed=0; _count=_tcount=_IRQlow=_PC=_A=_X=_Y=_P=_PI=_DB=_jammed=0;
_S=0xFD; _S=0xFD;
timestamp=soundtimestamp=0; timestamp=soundtimestamp=0;
X6502_Reset(); X6502_Reset();
StackAddrBackup = -1;
} }
void X6502_Run(int32 cycles) void X6502_Run(int32 cycles)