[Core/VDP] improved VINT timing accuracy in H32 mode (verified on real hardware by Nemesis)

This commit is contained in:
ekeeke 2024-02-23 14:08:57 +01:00
parent 0ca78b897e
commit 5f2f0ce89f
7 changed files with 23 additions and 8 deletions

View File

@ -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

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 MiB

After

Width:  |  Height:  |  Size: 4.0 MiB

View File

@ -462,10 +462,10 @@ 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 */
@ -802,10 +802,10 @@ 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 */

View File

@ -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;

View File

@ -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 */