comparison genesis.c @ 2305:6aca1734d573

Merge
author Michael Pavone <pavone@retrodev.com>
date Wed, 15 Mar 2023 19:28:11 -0700
parents 0343f0d5add0
children 9dd27530c570
comparison
equal deleted inserted replaced
2304:b3832f73444f 2305:6aca1734d573
416 if (gen->enter_z80_debugger && !z_context->reset && !z_context->busack) { 416 if (gen->enter_z80_debugger && !z_context->reset && !z_context->busack) {
417 while (!z_context->pc) { 417 while (!z_context->pc) {
418 z80_run(z_context, z_context->current_cycle + 4); 418 z80_run(z_context, z_context->current_cycle + 4);
419 } 419 }
420 gen->enter_z80_debugger = 0; 420 gen->enter_z80_debugger = 0;
421 #ifndef IS_LIB
421 zdebugger(z_context, z_context->pc); 422 zdebugger(z_context, z_context->pc);
423 #endif
422 } 424 }
423 z80_run(z_context, mclks); 425 z80_run(z_context, mclks);
424 } else 426 } else
425 #endif 427 #endif
426 { 428 {
483 gen->reset_requested = 1; 485 gen->reset_requested = 1;
484 context->should_return = 1; 486 context->should_return = 1;
485 gen->reset_cycle = CYCLE_NEVER; 487 gen->reset_cycle = CYCLE_NEVER;
486 } 488 }
487 if (v_context->frame != gen->last_frame) { 489 if (v_context->frame != gen->last_frame) {
490 #ifndef IS_LIB
488 if (gen->ym->scope) { 491 if (gen->ym->scope) {
489 scope_render(gen->ym->scope); 492 scope_render(gen->ym->scope);
490 } 493 }
494 #endif
491 //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); 495 //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);
492 uint32_t elapsed = v_context->frame - gen->last_frame; 496 uint32_t elapsed = v_context->frame - gen->last_frame;
493 gen->last_frame = v_context->frame; 497 gen->last_frame = v_context->frame;
494 event_flush(mclks); 498 event_flush(mclks);
495 gen->last_flush_cycle = mclks; 499 gen->last_flush_cycle = mclks;
554 context->target_cycle = gen->reset_cycle; 558 context->target_cycle = gen->reset_cycle;
555 } 559 }
556 if (address) { 560 if (address) {
557 if (gen->header.enter_debugger) { 561 if (gen->header.enter_debugger) {
558 gen->header.enter_debugger = 0; 562 gen->header.enter_debugger = 0;
563 #ifndef IS_LIB
559 if (gen->header.debugger_type == DEBUGGER_NATIVE) { 564 if (gen->header.debugger_type == DEBUGGER_NATIVE) {
560 debugger(context, address); 565 debugger(context, address);
561 } else { 566 } else {
562 gdb_debug_enter(context, address); 567 gdb_debug_enter(context, address);
563 } 568 }
569 #endif
564 } 570 }
565 #ifdef NEW_CORE 571 #ifdef NEW_CORE
566 if (gen->header.save_state) { 572 if (gen->header.save_state) {
567 #else 573 #else
568 if (gen->header.save_state && (z_context->pc || !z_context->native_pc || z_context->reset || !z_context->busreq)) { 574 if (gen->header.save_state && (z_context->pc || !z_context->native_pc || z_context->reset || !z_context->busreq)) {
1481 } 1487 }
1482 } 1488 }
1483 printf("Loaded %s\n", statefile); 1489 printf("Loaded %s\n", statefile);
1484 if (gen->header.enter_debugger) { 1490 if (gen->header.enter_debugger) {
1485 gen->header.enter_debugger = 0; 1491 gen->header.enter_debugger = 0;
1492 #ifndef IS_LIB
1486 insert_breakpoint(gen->m68k, pc, gen->header.debugger_type == DEBUGGER_NATIVE ? debugger : gdb_debug_enter); 1493 insert_breakpoint(gen->m68k, pc, gen->header.debugger_type == DEBUGGER_NATIVE ? debugger : gdb_debug_enter);
1494 #endif
1487 } 1495 }
1488 adjust_int_cycle(gen->m68k, gen->vdp); 1496 adjust_int_cycle(gen->m68k, gen->vdp);
1489 start_68k_context(gen->m68k, pc); 1497 start_68k_context(gen->m68k, pc);
1490 } else { 1498 } else {
1491 if (gen->header.enter_debugger) { 1499 if (gen->header.enter_debugger) {
1492 gen->header.enter_debugger = 0; 1500 gen->header.enter_debugger = 0;
1501 #ifndef IS_LIB
1493 uint32_t address = read_word(4, (void **)gen->m68k->mem_pointers, &gen->m68k->options->gen, gen->m68k) << 16 1502 uint32_t address = read_word(4, (void **)gen->m68k->mem_pointers, &gen->m68k->options->gen, gen->m68k) << 16
1494 | read_word(6, (void **)gen->m68k->mem_pointers, &gen->m68k->options->gen, gen->m68k); 1503 | read_word(6, (void **)gen->m68k->mem_pointers, &gen->m68k->options->gen, gen->m68k);
1495 insert_breakpoint(gen->m68k, address, gen->header.debugger_type == DEBUGGER_NATIVE ? debugger : gdb_debug_enter); 1504 insert_breakpoint(gen->m68k, address, gen->header.debugger_type == DEBUGGER_NATIVE ? debugger : gdb_debug_enter);
1505 #endif
1496 } 1506 }
1497 m68k_reset(gen->m68k); 1507 m68k_reset(gen->m68k);
1498 } 1508 }
1499 handle_reset_requests(gen); 1509 handle_reset_requests(gen);
1500 return; 1510 return;
1771 gen->header.vgm_logging = 0; 1781 gen->header.vgm_logging = 0;
1772 } 1782 }
1773 1783
1774 static void toggle_debug_view(system_header *system, uint8_t debug_view) 1784 static void toggle_debug_view(system_header *system, uint8_t debug_view)
1775 { 1785 {
1786 #ifndef IS_LIB
1776 genesis_context *gen = (genesis_context *)system; 1787 genesis_context *gen = (genesis_context *)system;
1777 if (debug_view < DEBUG_OSCILLOSCOPE) { 1788 if (debug_view < DEBUG_OSCILLOSCOPE) {
1778 vdp_toggle_debug_view(gen->vdp, debug_view); 1789 vdp_toggle_debug_view(gen->vdp, debug_view);
1779 } else if (debug_view == DEBUG_OSCILLOSCOPE) { 1790 } else if (debug_view == DEBUG_OSCILLOSCOPE) {
1780 if (gen->ym->scope) { 1791 if (gen->ym->scope) {
1796 } 1807 }
1797 } 1808 }
1798 } else if (debug_view == DEBUG_CD_GRAPHICS && gen->expansion) { 1809 } else if (debug_view == DEBUG_CD_GRAPHICS && gen->expansion) {
1799 scd_toggle_graphics_debug(gen->expansion); 1810 scd_toggle_graphics_debug(gen->expansion);
1800 } 1811 }
1812 #endif
1801 } 1813 }
1802 1814
1803 static void *tmss_rom_write_16(uint32_t address, void *context, uint16_t value) 1815 static void *tmss_rom_write_16(uint32_t address, void *context, uint16_t value)
1804 { 1816 {
1805 m68k_context *m68k = context; 1817 m68k_context *m68k = context;