comparison genesis.c @ 2179:9a8dd4ba2753

Implement frame advance debugger command
author Michael Pavone <pavone@retrodev.com>
date Sat, 13 Aug 2022 19:37:17 -0700
parents 4fbe1e7c4a73
children 408fb8a7e990
comparison
equal deleted inserted replaced
2178:f6d5bde4d07f 2179:9a8dd4ba2753
458 context->should_return = 1; 458 context->should_return = 1;
459 gen->reset_cycle = CYCLE_NEVER; 459 gen->reset_cycle = CYCLE_NEVER;
460 } 460 }
461 if (v_context->frame != gen->last_frame) { 461 if (v_context->frame != gen->last_frame) {
462 //printf("reached frame end %d | MCLK Cycles: %d, Target: %d, VDP cycles: %d, vcounter: %d, hslot: %d\n", gen->last_frame, mclks, gen->frame_end, v_context->cycles, v_context->vcounter, v_context->hslot); 462 //printf("reached frame end %d | MCLK Cycles: %d, Target: %d, VDP cycles: %d, vcounter: %d, hslot: %d\n", gen->last_frame, mclks, gen->frame_end, v_context->cycles, v_context->vcounter, v_context->hslot);
463 uint32_t elapsed = v_context->frame - gen->last_frame;
463 gen->last_frame = v_context->frame; 464 gen->last_frame = v_context->frame;
464 event_flush(mclks); 465 event_flush(mclks);
465 gen->last_flush_cycle = mclks; 466 gen->last_flush_cycle = mclks;
467 if (gen->header.enter_debugger_frames) {
468 if (elapsed >= gen->header.enter_debugger_frames) {
469 gen->header.enter_debugger_frames = 0;
470 gen->header.enter_debugger = 1;
471 } else {
472 gen->header.enter_debugger_frames -= elapsed;
473 }
474 }
466 475
467 if(exit_after){ 476 if(exit_after){
468 --exit_after; 477 if (elapsed >= exit_after) {
469 if (!exit_after) {
470 exit(0); 478 exit(0);
479 } else {
480 exit_after -= elapsed;
471 } 481 }
472 } 482 }
473 if (context->current_cycle > MAX_NO_ADJUST) { 483 if (context->current_cycle > MAX_NO_ADJUST) {
474 uint32_t deduction = mclks - ADJUST_BUFFER; 484 uint32_t deduction = mclks - ADJUST_BUFFER;
475 vdp_adjust_cycles(v_context, deduction); 485 vdp_adjust_cycles(v_context, deduction);