Mercurial > repos > blastem
comparison blastem.c @ 978:34b811ea1e7c
Disable refresh emulation with some ifdefs for now as it currently is not accurate enough to actually improve overall accuracy/compatibility and in fact makes things that work right on real hardware break
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 23 Apr 2016 18:14:01 -0700 |
parents | c6b19939da7b |
children | 902c53d9c16f |
comparison
equal
deleted
inserted
replaced
977:4cbc349a82a9 | 978:34b811ea1e7c |
---|---|
237 ym_run(gen->ym, target); | 237 ym_run(gen->ym, target); |
238 | 238 |
239 //printf("Target: %d, YM bufferpos: %d, PSG bufferpos: %d\n", target, gen->ym->buffer_pos, gen->psg->buffer_pos * 2); | 239 //printf("Target: %d, YM bufferpos: %d, PSG bufferpos: %d\n", target, gen->ym->buffer_pos, gen->psg->buffer_pos * 2); |
240 } | 240 } |
241 | 241 |
242 uint32_t last_frame_num; | |
243 | |
244 //My refresh emulation isn't currently good enough and causes more problems than it solves | |
245 #ifdef REFRESH_EMULATION | |
242 #define REFRESH_INTERVAL 128 | 246 #define REFRESH_INTERVAL 128 |
243 #define REFRESH_DELAY 2 | 247 #define REFRESH_DELAY 2 |
244 uint32_t last_frame_num; | |
245 uint32_t last_sync_cycle; | 248 uint32_t last_sync_cycle; |
246 uint32_t refresh_counter; | 249 uint32_t refresh_counter; |
250 #endif | |
251 | |
247 m68k_context * sync_components(m68k_context * context, uint32_t address) | 252 m68k_context * sync_components(m68k_context * context, uint32_t address) |
248 { | 253 { |
249 genesis_context * gen = context->system; | 254 genesis_context * gen = context->system; |
250 vdp_context * v_context = gen->vdp; | 255 vdp_context * v_context = gen->vdp; |
251 z80_context * z_context = gen->z80; | 256 z80_context * z_context = gen->z80; |
257 #ifdef REFRESH_EMULATION | |
252 //lame estimation of refresh cycle delay | 258 //lame estimation of refresh cycle delay |
253 if (!gen->bus_busy) { | 259 if (!gen->bus_busy) { |
254 refresh_counter += context->current_cycle - last_sync_cycle; | 260 refresh_counter += context->current_cycle - last_sync_cycle; |
255 context->current_cycle += REFRESH_DELAY * MCLKS_PER_68K * (refresh_counter / (MCLKS_PER_68K * REFRESH_INTERVAL)); | 261 context->current_cycle += REFRESH_DELAY * MCLKS_PER_68K * (refresh_counter / (MCLKS_PER_68K * REFRESH_INTERVAL)); |
256 refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); | 262 refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); |
257 } | 263 } |
264 #endif | |
258 | 265 |
259 uint32_t mclks = context->current_cycle; | 266 uint32_t mclks = context->current_cycle; |
260 sync_z80(z_context, mclks); | 267 sync_z80(z_context, mclks); |
261 sync_sound(gen, mclks); | 268 sync_sound(gen, mclks); |
262 vdp_run_context(v_context, mclks); | 269 vdp_run_context(v_context, mclks); |
326 } | 333 } |
327 } else if(gen->save_state) { | 334 } else if(gen->save_state) { |
328 context->sync_cycle = context->current_cycle + 1; | 335 context->sync_cycle = context->current_cycle + 1; |
329 } | 336 } |
330 } | 337 } |
338 #ifdef REFRESH_EMULATION | |
331 last_sync_cycle = context->current_cycle; | 339 last_sync_cycle = context->current_cycle; |
340 #endif | |
332 return context; | 341 return context; |
333 } | 342 } |
334 | 343 |
335 m68k_context * vdp_port_write(uint32_t vdp_port, m68k_context * context, uint16_t value) | 344 m68k_context * vdp_port_write(uint32_t vdp_port, m68k_context * context, uint16_t value) |
336 { | 345 { |
386 } else { | 395 } else { |
387 fatal_error("Illegal write to HV Counter port %X\n", vdp_port); | 396 fatal_error("Illegal write to HV Counter port %X\n", vdp_port); |
388 } | 397 } |
389 if (v_context->cycles != before_cycle) { | 398 if (v_context->cycles != before_cycle) { |
390 //printf("68K paused for %d (%d) cycles at cycle %d (%d) for write\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 write\n", v_context->cycles - context->current_cycle, v_context->cycles - before_cycle, context->current_cycle, before_cycle); |
391 last_sync_cycle = context->current_cycle = v_context->cycles; | 400 context->current_cycle = v_context->cycles; |
401 #ifdef REFRESH_EMULATION | |
402 last_sync_cycle = context->current_cycle; | |
403 #endif | |
392 //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 |
393 gen->bus_busy = 1; | 405 gen->bus_busy = 1; |
394 sync_z80(gen->z80, v_context->cycles); | 406 sync_z80(gen->z80, v_context->cycles); |
395 gen->bus_busy = 0; | 407 gen->bus_busy = 0; |
396 } | 408 } |
459 } else { | 471 } else { |
460 value = vdp_test_port_read(v_context); | 472 value = vdp_test_port_read(v_context); |
461 } | 473 } |
462 if (v_context->cycles != before_cycle) { | 474 if (v_context->cycles != before_cycle) { |
463 //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); | 475 //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); |
464 last_sync_cycle = context->current_cycle = v_context->cycles; | 476 context->current_cycle = v_context->cycles; |
477 #ifdef REFRES_EMULATION | |
478 last_sync_cycle = context->current_cycle; | |
479 #endif | |
465 //Lock the Z80 out of the bus until the VDP access is complete | 480 //Lock the Z80 out of the bus until the VDP access is complete |
466 genesis_context *gen = context->system; | 481 genesis_context *gen = context->system; |
467 gen->bus_busy = 1; | 482 gen->bus_busy = 1; |
468 sync_z80(gen->z80, v_context->cycles); | 483 sync_z80(gen->z80, v_context->cycles); |
469 gen->bus_busy = 0; | 484 gen->bus_busy = 0; |