comparison genesis.c @ 2021:270a4c875e0a

Backed out changeset 96971b673f51 This optimization caused a regression in Overdrive 2 due to the impact of Z80 access to the 68K bus
author Michael Pavone <pavone@retrodev.com>
date Tue, 24 Nov 2020 20:23:38 -0800
parents b05295c2ad04
children e7a516f08cec
comparison
equal deleted inserted replaced
2020:e42c45ff06d5 2021:270a4c875e0a
642 refresh_counter += context->current_cycle - 4*MCLKS_PER_68K - last_sync_cycle; 642 refresh_counter += context->current_cycle - 4*MCLKS_PER_68K - last_sync_cycle;
643 context->current_cycle += REFRESH_DELAY * MCLKS_PER_68K * (refresh_counter / (MCLKS_PER_68K * REFRESH_INTERVAL)); 643 context->current_cycle += REFRESH_DELAY * MCLKS_PER_68K * (refresh_counter / (MCLKS_PER_68K * REFRESH_INTERVAL));
644 refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); 644 refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL);
645 last_sync_cycle = context->current_cycle; 645 last_sync_cycle = context->current_cycle;
646 #endif 646 #endif
647 sync_components(context, 0);
647 genesis_context *gen = context->system; 648 genesis_context *gen = context->system;
648 vdp_context * v_context = gen->vdp; 649 vdp_context * v_context = gen->vdp;
650 uint32_t before_cycle = v_context->cycles;
649 if (vdp_port < 0x10) { 651 if (vdp_port < 0x10) {
650 if (vdp_port < 4) { 652 if (vdp_port < 4) {
651 sync_components(context, 0);
652 uint32_t before_cycle = v_context->cycles;
653 value = vdp_data_port_read(v_context); 653 value = vdp_data_port_read(v_context);
654 if (v_context->cycles != before_cycle) {
655 //printf("68K paused for %d (%d) cycles at cycle %d (%d) for read\n", v_context->cycles - context->current_cycle, v_context->cycles - before_cycle, context->current_cycle, before_cycle);
656 context->current_cycle = v_context->cycles;
657 //Lock the Z80 out of the bus until the VDP access is complete
658 genesis_context *gen = context->system;
659 gen->bus_busy = 1;
660 sync_z80(gen->z80, v_context->cycles);
661 gen->bus_busy = 0;
662 }
663 } else if(vdp_port < 8) { 654 } else if(vdp_port < 8) {
664 vdp_run_context(v_context, context->current_cycle);
665 value = vdp_control_port_read(v_context); 655 value = vdp_control_port_read(v_context);
666 } else { 656 } else {
667 vdp_run_context(v_context, context->current_cycle);
668 value = vdp_hv_counter_read(v_context); 657 value = vdp_hv_counter_read(v_context);
669 //printf("HV Counter: %X at cycle %d\n", value, v_context->cycles); 658 //printf("HV Counter: %X at cycle %d\n", value, v_context->cycles);
670 } 659 }
671 } else if (vdp_port < 0x18){ 660 } else if (vdp_port < 0x18){
672 fatal_error("Illegal read from PSG port %X\n", vdp_port); 661 fatal_error("Illegal read from PSG port %X\n", vdp_port);
673 } else { 662 } else {
674 value = get_open_bus_value(&gen->header); 663 value = get_open_bus_value(&gen->header);
664 }
665 if (v_context->cycles != before_cycle) {
666 //printf("68K paused for %d (%d) cycles at cycle %d (%d) for read\n", v_context->cycles - context->current_cycle, v_context->cycles - before_cycle, context->current_cycle, before_cycle);
667 context->current_cycle = v_context->cycles;
668 //Lock the Z80 out of the bus until the VDP access is complete
669 genesis_context *gen = context->system;
670 gen->bus_busy = 1;
671 sync_z80(gen->z80, v_context->cycles);
672 gen->bus_busy = 0;
675 } 673 }
676 #ifdef REFRESH_EMULATION 674 #ifdef REFRESH_EMULATION
677 last_sync_cycle -= 4 * MCLKS_PER_68K; 675 last_sync_cycle -= 4 * MCLKS_PER_68K;
678 //refresh may have happened while we were waiting on the VDP, 676 //refresh may have happened while we were waiting on the VDP,
679 //so advance refresh_counter but don't add any delays 677 //so advance refresh_counter but don't add any delays