diff --git a/HISTORY.txt b/HISTORY.txt index 333f3b5..3ff047c 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -160,6 +160,7 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke) * improved H-Counter accuracy in H32 mode * improved VDP status timing accuracy * improved HBLANK flag timing accuracy (verified on real hardware by Nemesis) +* improved VINT timing accuracy in H32 mode (verified on real hardware by Nemesis) * improved DMA timing accuracy during blanking (verified on real hardware by Mask of Destiny) * improved accuracy of Master System color palette brightness range (verified against real hardware) * fixed misaligned buffer writes in Mode 4 when -DALIGN_LONG option is used diff --git a/builds/genesis_plus_gx_libretro.dll b/builds/genesis_plus_gx_libretro.dll index 8284d8a..4fa5c36 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 ffa1c57..03c0f3c 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 43275cc..c0e40d8 100644 Binary files a/builds/genplus_wii.dol and b/builds/genplus_wii.dol differ diff --git a/core/system.c b/core/system.c index 00c7275..20843aa 100644 --- a/core/system.c +++ b/core/system.c @@ -462,14 +462,14 @@ void system_frame_gen(int do_skip) v_counter = bitmap.viewport.h; /* delay between VBLANK flag & Vertical Interrupt (Dracula, OutRunners, VR Troopers) */ - m68k_run(788); + m68k_run(vint_cycle); if (zstate == 1) { - z80_run(788); + z80_run(vint_cycle); } /* set VINT flag */ - status |= 0x80; + status |= 0x80; /* Vertical Interrupt */ vint_pending = 0x20; @@ -802,14 +802,14 @@ void system_frame_scd(int do_skip) v_counter = bitmap.viewport.h; /* delay between VBLANK flag & Vertical Interrupt (Dracula, OutRunners, VR Troopers) */ - m68k_run(788); + m68k_run(vint_cycle); if (zstate == 1) { - z80_run(788); + z80_run(vint_cycle); } /* set VINT flag */ - status |= 0x80; + status |= 0x80; /* Vertical Interrupt */ vint_pending = 0x20; diff --git a/core/vdp_ctrl.c b/core/vdp_ctrl.c index 8ff18f9..6d4aea0 100644 --- a/core/vdp_ctrl.c +++ b/core/vdp_ctrl.c @@ -52,6 +52,9 @@ } \ bg_name_dirty[name] |= (1 << ((addr >> 2) & 7)); \ } +/* VINT timings */ +#define VINT_H32_MCYCLE (770) +#define VINT_H40_MCYCLE (788) /* HBLANK flag timings */ #define HBLANK_H32_START_MCYCLE (280) @@ -96,6 +99,7 @@ uint16 max_sprite_pixels; /* Max. sprites pixels per line (parsing & ren int32 fifo_write_cnt; /* VDP FIFO write count */ uint32 fifo_slots; /* VDP FIFO access slot count */ uint32 hvc_latch; /* latched HV counter */ +uint32 vint_cycle; /* VINT occurence cycle */ const uint8 *hctab; /* pointer to H Counter table */ /* Function pointers */ @@ -331,6 +335,9 @@ void vdp_reset(void) /* default FIFO access slots timings */ fifo_timing = (int *)fifo_timing_h32; + /* default VINT timing */ + vint_cycle = VINT_H32_MCYCLE; + /* default HBLANK flag timings */ hblank_start_cycle = HBLANK_H32_START_MCYCLE; hblank_end_cycle = HBLANK_H32_END_MCYCLE; @@ -1196,9 +1203,9 @@ unsigned int vdp_68k_ctrl_r(unsigned int cycles) /* Adjust cycle count relatively to start of line */ cycles -= mcycles_vdp; - /* Cycle-accurate VINT flag (Ex-Mutants, Tyrant / Mega-Lo-Mania, Marvel Land) */ + /* Cycle-accurate VINT flag (Ex-Mutants, Tyrant / Mega-Lo-Mania, Marvel Land, Pacman 2 - New Adventures / Pac-Jr minigame) */ /* this allows VINT flag to be read just before vertical interrupt is being triggered */ - if ((v_counter == bitmap.viewport.h) && (cycles >= 788)) + if ((v_counter == bitmap.viewport.h) && (cycles >= vint_cycle)) { /* check Z80 interrupt state to assure VINT has not already been triggered (and flag cleared) */ if (Z80.irq_state != ASSERT_LINE) @@ -1985,6 +1992,9 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) /* FIFO access slots timings */ fifo_timing = (int *)fifo_timing_h40; + /* VINT timing */ + vint_cycle = VINT_H40_MCYCLE; + /* HBLANK flag timings */ hblank_start_cycle = HBLANK_H40_START_MCYCLE; hblank_end_cycle = HBLANK_H40_END_MCYCLE; @@ -2009,6 +2019,9 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) /* FIFO access slots timings */ fifo_timing = (int *)fifo_timing_h32; + /* VINT timing */ + vint_cycle = VINT_H32_MCYCLE; + /* HBLANK flag timings */ hblank_start_cycle = HBLANK_H32_START_MCYCLE; hblank_end_cycle = HBLANK_H32_END_MCYCLE; diff --git a/core/vdp_ctrl.h b/core/vdp_ctrl.h index 42a8d3b..6f7be19 100644 --- a/core/vdp_ctrl.h +++ b/core/vdp_ctrl.h @@ -79,6 +79,7 @@ extern uint16 max_sprite_pixels; extern int32 fifo_write_cnt; extern uint32 fifo_slots; extern uint32 hvc_latch; +extern uint32 vint_cycle; extern const uint8 *hctab; /* Function pointers */