Mercurial > repos > blastem
comparison segacd.c @ 2104:ff32a90260c9
Initial support for using debugger on sub CPU
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 11 Feb 2022 23:21:10 -0800 |
parents | b92c998c6742 |
children | d2989e32c026 |
comparison
equal
deleted
inserted
replaced
2103:522d04e2adcd | 2104:ff32a90260c9 |
---|---|
1 #include <stdlib.h> | 1 #include <stdlib.h> |
2 #include <string.h> | 2 #include <string.h> |
3 #include "cd_graphics.h" | 3 #include "cd_graphics.h" |
4 #include "genesis.h" | 4 #include "genesis.h" |
5 #include "util.h" | 5 #include "util.h" |
6 #include "debug.h" | |
7 #include "gdb_remote.h" | |
6 | 8 |
7 #define SCD_MCLKS 50000000 | 9 #define SCD_MCLKS 50000000 |
8 #define SCD_PERIPH_RESET_CLKS (SCD_MCLKS / 10) | 10 #define SCD_PERIPH_RESET_CLKS (SCD_MCLKS / 10) |
9 #define TIMER_TICK_CLKS 1536 | 11 #define TIMER_TICK_CLKS 1536 |
10 | 12 |
873 | 875 |
874 static m68k_context *sync_components(m68k_context * context, uint32_t address) | 876 static m68k_context *sync_components(m68k_context * context, uint32_t address) |
875 { | 877 { |
876 segacd_context *cd = context->system; | 878 segacd_context *cd = context->system; |
877 scd_peripherals_run(cd, context->current_cycle); | 879 scd_peripherals_run(cd, context->current_cycle); |
878 if (context->int_ack) { | 880 if (address && cd->enter_debugger) { |
879 printf("int ack %d\n", context->int_ack); | 881 genesis_context *gen = cd->genesis; |
882 if (gen->header.debugger_type == DEBUGGER_NATIVE) { | |
883 debugger(context, address); | |
884 } else { | |
885 gdb_debug_enter(context, address); | |
886 } | |
880 } | 887 } |
881 switch (context->int_ack) | 888 switch (context->int_ack) |
882 { | 889 { |
883 case 1: | 890 case 1: |
884 cd->graphics_int_cycle = CYCLE_NEVER; | 891 cd->graphics_int_cycle = CYCLE_NEVER; |
905 { | 912 { |
906 uint8_t m68k_run = !can_main_access_prog(cd); | 913 uint8_t m68k_run = !can_main_access_prog(cd); |
907 while (cycle > cd->m68k->current_cycle) { | 914 while (cycle > cd->m68k->current_cycle) { |
908 if (m68k_run) { | 915 if (m68k_run) { |
909 uint32_t start = cd->m68k->current_cycle; | 916 uint32_t start = cd->m68k->current_cycle; |
910 cd->m68k->sync_cycle = cycle; | 917 cd->m68k->sync_cycle = cd->enter_debugger ? cd->m68k->current_cycle + 1 : cycle; |
911 if (cd->need_reset) { | 918 if (cd->need_reset) { |
912 cd->need_reset = 0; | 919 cd->need_reset = 0; |
913 m68k_reset(cd->m68k); | 920 m68k_reset(cd->m68k); |
914 } else { | 921 } else { |
915 calculate_target_cycle(cd->m68k); | 922 calculate_target_cycle(cd->m68k); |