Memory Breakpoint - phase #1

This commit is contained in:
tudnai 2022-11-17 13:17:52 -08:00
parent d6f49abbb4
commit fdd46f6773
2 changed files with 10 additions and 8 deletions

View File

@ -186,9 +186,9 @@ int m6502_dbg_bp_get_empty() {
/// Get first not empty slot in the bp storage
/// @return Index of the empty breakpoint or -1 if error
int m6502_dbg_bp_get_not_empty() {
for (int i = 0; i < DEBUG_MAX_BREAKPOINTS; i++) {
if ( breakpoints[i] ) {
int m6502_dbg_bp_get_not_empty(uint16_t * bp) {
for (int i = 1; i < DEBUG_MAX_BREAKPOINTS; i++) {
if ( bp[i] ) {
return i;
}
}
@ -201,9 +201,11 @@ int m6502_dbg_bp_get_not_empty() {
/// @note: Array must be sorted before this!
/// @return last index
int m6502_dbg_bp_compact(uint16_t * bp) {
int i = m6502_dbg_bp_get_not_empty();
memcpy(bp, bp + i, LAST_IDX(bp) * sizeof(uint16_t));
memset(bp + LAST_IDX(bp) - i + 1, 0, (DEBUG_MAX_BREAKPOINTS - LAST_IDX(bp) + i - 1) * sizeof(uint16_t));
int i = m6502_dbg_bp_get_not_empty(bp);
if ( i > 1 ) {
memcpy(bp + 1, bp + i, LAST_IDX(bp) * sizeof(uint16_t));
}
memset(bp + i + 1, 0, (DEBUG_MAX_BREAKPOINTS - i - 2) * sizeof(uint16_t));
return m6502_dbg_bp_get_last(bp, LAST_IDX(bp));
}

View File

@ -190,8 +190,6 @@ void m6502_Debug(void) {
if ( m6502_dbg_bp_exists(breakpoints, m6502.PC) ) {
cpuState = cpuState_halted;
// m6502.debugger.wMask = 0;
// m6502.debugger.on = 0;
m6502.interrupt = BREAKPOINT;
return;
}
@ -227,6 +225,8 @@ void m6502_dbg_init(void) {
m6502.debugger.mask.inv = 1;
m6502.debugger.SP = 0xFF;
m6502_dbg_bp_del_all(breakpoints);
m6502_dbg_bp_del_all(mem_read_breakpoints);
m6502_dbg_bp_del_all(mem_write_breakpoints);
}