comparison m68k_util.c @ 2676:7e86ec94c899

Implement breakpoints in new 68K core
author Michael Pavone <pavone@retrodev.com>
date Sat, 15 Mar 2025 23:15:05 -0700
parents 38c281ef57b0
children
comparison
equal deleted inserted replaced
2675:dbff641a33df 2676:7e86ec94c899
1 #include <string.h> 1 #include <string.h>
2 #ifdef DEBUG_DISASM
3 #include "68kinst.h"
4 #endif
2 5
3 void m68k_read_8(m68k_context *context) 6 void m68k_read_8(m68k_context *context)
4 { 7 {
5 context->cycles += 4 * context->opts->gen.clock_divider; 8 context->cycles += 4 * context->opts->gen.clock_divider;
6 #ifdef DEBUG_DISASM 9 #ifdef DEBUG_DISASM
12 #ifdef DEBUG_DISASM 15 #ifdef DEBUG_DISASM
13 printf("Read.b %05X: %02X\n", tmp, context->scratch1); 16 printf("Read.b %05X: %02X\n", tmp, context->scratch1);
14 #endif 17 #endif
15 } 18 }
16 19
17 #ifdef DEBUG_DISASM 20 uint16_t m68k_instruction_fetch(uint32_t address, void *vcontext)
18 #include "68kinst.h"
19 static uint16_t debug_disasm_fetch(uint32_t address, void *vcontext)
20 { 21 {
21 m68k_context *context = vcontext; 22 m68k_context *context = vcontext;
22 return read_word(address, (void**)context->mem_pointers, &context->opts->gen, context); 23 return read_word(address, (void **)context->mem_pointers, &context->opts->gen, context);
23 } 24 }
24 #endif 25
25 void m68k_read_16(m68k_context *context) 26 void m68k_read_16(m68k_context *context)
26 { 27 {
27 context->cycles += 4 * context->opts->gen.clock_divider; 28 context->cycles += 4 * context->opts->gen.clock_divider;
28 #ifdef DEBUG_DISASM 29 #ifdef DEBUG_DISASM
29 uint32_t tmp = context->scratch1; 30 uint32_t tmp = context->scratch1;
370 context->scratch1 = context->pc = pc; 371 context->scratch1 = context->pc = pc;
371 m68k_read_16(context); 372 m68k_read_16(context);
372 context->prefetch = context->scratch1; 373 context->prefetch = context->scratch1;
373 context->pc += 2; 374 context->pc += 2;
374 } 375 }
376
377 void insert_breakpoint(m68k_context *context, uint32_t address, debug_handler handler)
378 {
379 char buf[6];
380 address &= context->opts->gen.address_mask;
381 context->breakpoints = tern_insert_ptr(context->breakpoints, tern_int_key(address, buf), handler);
382 }
383
384 void remove_breakpoint(m68k_context *context, uint32_t address)
385 {
386 char buf[6];
387 address &= context->opts->gen.address_mask;
388 tern_delete(&context->breakpoints, tern_int_key(address, buf), NULL);
389 }