Mercurial > repos > blastem
comparison debug.c @ 2198:0dcb9e4dee7f
Give SMS debugger a bit more parity to the Genesis one
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 22 Aug 2022 19:44:59 -0700 |
parents | d00fb9c6a6a2 |
children | 3809a0bd680e |
comparison
equal
deleted
inserted
replaced
2197:74b92e20e2ef | 2198:0dcb9e4dee7f |
---|---|
12 #endif | 12 #endif |
13 #include "render.h" | 13 #include "render.h" |
14 #include "util.h" | 14 #include "util.h" |
15 #include "terminal.h" | 15 #include "terminal.h" |
16 #include "z80inst.h" | 16 #include "z80inst.h" |
17 #ifndef NO_Z80 | |
18 #include "sms.h" | |
19 #endif | |
17 | 20 |
18 #ifdef NEW_CORE | 21 #ifdef NEW_CORE |
19 #define Z80_OPTS opts | 22 #define Z80_OPTS opts |
20 #else | 23 #else |
21 #define Z80_OPTS options | 24 #define Z80_OPTS options |
2453 gen->header.enter_debugger = 1; | 2456 gen->header.enter_debugger = 1; |
2454 return 0; | 2457 return 0; |
2455 } | 2458 } |
2456 } | 2459 } |
2457 | 2460 |
2461 static uint8_t cmd_vdp_sprites_sms(debug_root *root, parsed_command *cmd) | |
2462 { | |
2463 z80_context *context = root->cpu_context; | |
2464 sms_context * sms = context->system; | |
2465 vdp_print_sprite_table(sms->vdp); | |
2466 return 1; | |
2467 } | |
2468 | |
2469 static uint8_t cmd_vdp_regs_sms(debug_root *root, parsed_command *cmd) | |
2470 { | |
2471 z80_context *context = root->cpu_context; | |
2472 sms_context * sms = context->system; | |
2473 vdp_print_reg_explain(sms->vdp); | |
2474 return 1; | |
2475 } | |
2476 | |
2458 command_def z80_commands[] = { | 2477 command_def z80_commands[] = { |
2459 { | 2478 { |
2460 .names = (const char *[]){ | 2479 .names = (const char *[]){ |
2461 "breakpoint", "b", NULL | 2480 "breakpoint", "b", NULL |
2462 }, | 2481 }, |
2543 .raw_args = 1 | 2562 .raw_args = 1 |
2544 } | 2563 } |
2545 }; | 2564 }; |
2546 | 2565 |
2547 #define NUM_GEN_Z80 (sizeof(gen_z80_commands)/sizeof(*gen_z80_commands)) | 2566 #define NUM_GEN_Z80 (sizeof(gen_z80_commands)/sizeof(*gen_z80_commands)) |
2567 | |
2568 command_def sms_commands[] = { | |
2569 { | |
2570 .names = (const char *[]){ | |
2571 "vdpsprites", "vs", NULL | |
2572 }, | |
2573 .usage = "vdpsprites", | |
2574 .desc = "Print the VDP sprite table", | |
2575 .impl = cmd_vdp_sprites_sms, | |
2576 .min_args = 0, | |
2577 .max_args = 0 | |
2578 }, | |
2579 { | |
2580 .names = (const char *[]){ | |
2581 "vdpsregs", "vr", NULL | |
2582 }, | |
2583 .usage = "vdpregs", | |
2584 .desc = "Print VDP register values with a short description", | |
2585 .impl = cmd_vdp_regs_sms, | |
2586 .min_args = 0, | |
2587 .max_args = 0 | |
2588 } | |
2589 }; | |
2590 | |
2591 #define NUM_SMS (sizeof(sms_commands)/sizeof(*sms_commands)) | |
2548 | 2592 |
2549 #endif | 2593 #endif |
2550 | 2594 |
2551 void add_commands(debug_root *root, command_def *defs, uint32_t num_commands) | 2595 void add_commands(debug_root *root, command_def *defs, uint32_t num_commands) |
2552 { | 2596 { |
2665 case 'c': | 2709 case 'c': |
2666 if (!name[1]) { | 2710 if (!name[1]) { |
2667 *out = context->regs[Z80_C]; | 2711 *out = context->regs[Z80_C]; |
2668 } else if (name[1] == '\'' && !name[2]) { | 2712 } else if (name[1] == '\'' && !name[2]) { |
2669 *out = context->alt_regs[Z80_C]; | 2713 *out = context->alt_regs[Z80_C]; |
2714 } else if (!strcmp(name + 1, "ycle")) { | |
2715 *out = context->current_cycle; | |
2670 } else { | 2716 } else { |
2671 return 0; | 2717 return 0; |
2672 } | 2718 } |
2673 break; | 2719 break; |
2674 case 'd': | 2720 case 'd': |
2837 break; | 2883 break; |
2838 default: | 2884 default: |
2839 return 0; | 2885 return 0; |
2840 } | 2886 } |
2841 return 1; | 2887 return 1; |
2888 } | |
2889 | |
2890 static uint8_t resolve_sms(debug_root *root, const char *name, uint32_t *out) | |
2891 { | |
2892 if (resolve_z80(root, name, out)) { | |
2893 return 1; | |
2894 } | |
2895 z80_context *z80 = root->cpu_context; | |
2896 sms_context *sms = z80->system; | |
2897 if (!strcmp(name, "f") || !strcmp(name, "frame")) { | |
2898 *out = sms->vdp->frame; | |
2899 return 1; | |
2900 } | |
2901 return 0; | |
2842 } | 2902 } |
2843 | 2903 |
2844 static uint8_t set_z80(debug_root *root, const char *name, uint32_t value) | 2904 static uint8_t set_z80(debug_root *root, const char *name, uint32_t value) |
2845 { | 2905 { |
2846 z80_context *context = root->cpu_context; | 2906 z80_context *context = root->cpu_context; |
3070 { | 3130 { |
3071 debug_root *root = find_root(context); | 3131 debug_root *root = find_root(context); |
3072 if (root && !root->commands) { | 3132 if (root && !root->commands) { |
3073 add_commands(root, common_commands, NUM_COMMON); | 3133 add_commands(root, common_commands, NUM_COMMON); |
3074 add_commands(root, z80_commands, NUM_Z80); | 3134 add_commands(root, z80_commands, NUM_Z80); |
3075 if (current_system->type == SYSTEM_GENESIS || current_system->type == SYSTEM_SEGACD) { | 3135 switch (current_system->type) |
3136 { | |
3137 case SYSTEM_GENESIS: | |
3138 case SYSTEM_SEGACD: | |
3076 add_commands(root, gen_z80_commands, NUM_GEN_Z80); | 3139 add_commands(root, gen_z80_commands, NUM_GEN_Z80); |
3140 root->resolve = resolve_z80; | |
3141 break; | |
3142 case SYSTEM_SMS: | |
3143 root->resolve = resolve_sms; | |
3144 add_commands(root, sms_commands, NUM_SMS); | |
3145 break; | |
3146 default: | |
3147 root->resolve = resolve_z80; | |
3077 } | 3148 } |
3078 root->read_mem = read_z80; | 3149 root->read_mem = read_z80; |
3079 root->write_mem = write_z80; | 3150 root->write_mem = write_z80; |
3080 root->set = set_z80; | 3151 root->set = set_z80; |
3081 root->resolve = resolve_z80; | |
3082 } | 3152 } |
3083 return root; | 3153 return root; |
3084 } | 3154 } |
3085 | 3155 |
3086 z80_context * zdebugger(z80_context * context, uint16_t address) | 3156 z80_context * zdebugger(z80_context * context, uint16_t address) |