comparison genesis.c @ 1286:ca0383656a82

Basic refresh emulation that doesn't break direct color DMA demos. Fixes sound after entering pause menu in Pacman 2: The New Adventures
author Michael Pavone <pavone@retrodev.com>
date Sat, 18 Mar 2017 23:18:37 -0700
parents 76e47254596b
children 94f32d534bed
comparison
equal deleted inserted replaced
1285:76e47254596b 1286:ca0383656a82
142 142
143 //TODO: move this inside the system context 143 //TODO: move this inside the system context
144 static uint32_t last_frame_num; 144 static uint32_t last_frame_num;
145 145
146 //My refresh emulation isn't currently good enough and causes more problems than it solves 146 //My refresh emulation isn't currently good enough and causes more problems than it solves
147 #define REFRESH_EMULATION
147 #ifdef REFRESH_EMULATION 148 #ifdef REFRESH_EMULATION
148 #define REFRESH_INTERVAL 128 149 #define REFRESH_INTERVAL 128
149 #define REFRESH_DELAY 2 150 #define REFRESH_DELAY 2
150 uint32_t last_sync_cycle; 151 uint32_t last_sync_cycle;
151 uint32_t refresh_counter; 152 uint32_t refresh_counter;
320 m68k_cycle_diff += MCLKS_PER_68K; 321 m68k_cycle_diff += MCLKS_PER_68K;
321 } 322 }
322 context->current_cycle += m68k_cycle_diff; 323 context->current_cycle += m68k_cycle_diff;
323 #ifdef REFRESH_EMULATION 324 #ifdef REFRESH_EMULATION
324 last_sync_cycle = context->current_cycle; 325 last_sync_cycle = context->current_cycle;
326 refresh_counter = 0;
325 #endif 327 #endif
326 //Lock the Z80 out of the bus until the VDP access is complete 328 //Lock the Z80 out of the bus until the VDP access is complete
327 gen->bus_busy = 1; 329 gen->bus_busy = 1;
328 sync_z80(gen->z80, v_context->cycles); 330 sync_z80(gen->z80, v_context->cycles);
329 gen->bus_busy = 0; 331 gen->bus_busy = 0;
394 value = vdp_test_port_read(v_context); 396 value = vdp_test_port_read(v_context);
395 } 397 }
396 if (v_context->cycles != before_cycle) { 398 if (v_context->cycles != before_cycle) {
397 //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); 399 //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);
398 context->current_cycle = v_context->cycles; 400 context->current_cycle = v_context->cycles;
399 #ifdef REFRES_EMULATION 401 #ifdef REFRESH_EMULATION
400 last_sync_cycle = context->current_cycle; 402 last_sync_cycle = context->current_cycle;
401 #endif 403 #endif
402 //Lock the Z80 out of the bus until the VDP access is complete 404 //Lock the Z80 out of the bus until the VDP access is complete
403 genesis_context *gen = context->system; 405 genesis_context *gen = context->system;
404 gen->bus_busy = 1; 406 gen->bus_busy = 1;