diff --git a/builds/genesis_plus_gx_libretro.dll b/builds/genesis_plus_gx_libretro.dll index e11d84e..26c19f5 100644 Binary files a/builds/genesis_plus_gx_libretro.dll and b/builds/genesis_plus_gx_libretro.dll differ diff --git a/builds/genplus_cube.dol b/builds/genplus_cube.dol index 9d3f5fc..af73aa7 100644 Binary files a/builds/genplus_cube.dol and b/builds/genplus_cube.dol differ diff --git a/builds/genplus_wii.dol b/builds/genplus_wii.dol index 24550d0..ce10f5f 100644 Binary files a/builds/genplus_wii.dol and b/builds/genplus_wii.dol differ diff --git a/core/m68k/m68k.h b/core/m68k/m68k.h index 078cbdf..7c84334 100644 --- a/core/m68k/m68k.h +++ b/core/m68k/m68k.h @@ -356,6 +356,10 @@ extern void s68k_pulse_reset(void); extern void m68k_run(unsigned int cycles); extern void s68k_run(unsigned int cycles); +/* Get current instruction execution time */ +extern int m68k_cycles(void); +extern int s68k_cycles(void); + /* Set the IPL0-IPL2 pins on the CPU (IRQ). * A transition from < 7 to 7 will cause a non-maskable interrupt (NMI). * Setting IRQ to 0 will clear an interrupt request. diff --git a/core/m68k/m68kcpu.c b/core/m68k/m68kcpu.c index 4c81a9e..e7d762e 100644 --- a/core/m68k/m68kcpu.c +++ b/core/m68k/m68kcpu.c @@ -280,7 +280,7 @@ void m68k_run(unsigned int cycles) #ifdef LOGVDP error("[%d][%d] m68k run to %d cycles (%x), irq mask = %x (%x)\n", v_counter, m68k.cycles, cycles, m68k.pc,FLAG_INT_MASK, CPU_INT_LEVEL); #endif - + while (m68k.cycles < cycles) { /* Set tracing accodring to T1. */ @@ -291,7 +291,7 @@ void m68k_run(unsigned int cycles) /* Decode next instruction */ REG_IR = m68ki_read_imm_16(); - + /* Execute instruction */ m68ki_instruction_jump_table[REG_IR](); USE_CYCLES(CYC_INSTRUCTION[REG_IR]); @@ -301,6 +301,11 @@ void m68k_run(unsigned int cycles) } } +int m68k_cycles(void) +{ + return CYC_INSTRUCTION[REG_IR]; +} + void m68k_init(void) { #ifdef BUILD_TABLES diff --git a/core/m68k/s68kcpu.c b/core/m68k/s68kcpu.c index 0df6054..7de4652 100644 --- a/core/m68k/s68kcpu.c +++ b/core/m68k/s68kcpu.c @@ -265,6 +265,12 @@ void s68k_run(unsigned int cycles) } } + +int s68k_cycles(void) +{ + return CYC_INSTRUCTION[REG_IR]; +} + void s68k_init(void) { #ifdef BUILD_TABLES diff --git a/core/vdp_ctrl.c b/core/vdp_ctrl.c index d0b7857..8143026 100644 --- a/core/vdp_ctrl.c +++ b/core/vdp_ctrl.c @@ -1151,8 +1151,8 @@ unsigned int vdp_68k_ctrl_r(unsigned int cycles) { unsigned int temp; - /* Cycle-accurate VDP status read (68k read cycle takes four CPU cycles i.e 28 Mcycles) */ - cycles += 4 * 7; + /* Cycle-accurate VDP status read (adjust CPU time with current instruction execution time) */ + cycles += m68k_cycles(); /* Update FIFO status flags if not empty */ if (fifo_write_cnt) @@ -1186,7 +1186,7 @@ unsigned int vdp_68k_ctrl_r(unsigned int cycles) temp |= 0x08; } - /* Cycle-accurate VINT flag (Ex-Mutants, Tyrant / Mega-Lo-Mania) */ + /* Cycle-accurate VINT flag (Ex-Mutants, Tyrant / Mega-Lo-Mania, Marvel Land) */ /* this allows VINT flag to be read just before vertical interrupt is being triggered */ if ((v_counter == bitmap.viewport.h) && (cycles >= (mcycles_vdp + 788))) {