[Core/VDP] improved HVC latch behavior when not locked in hardware but forced for gun emulation ("Gunfight - 3 in 1" randomization issues when Justifier is enabled)

This commit is contained in:
EkeEke 2013-06-27 23:32:27 +02:00
parent dbdae3bf3e
commit 49d22ce6ed
3 changed files with 16 additions and 7 deletions

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Sega Light Phaser, Menacer & Konami Justifiers support * Sega Light Phaser, Menacer & Konami Justifiers support
* *
* Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -135,7 +135,7 @@ void lightgun_refresh(int port)
m68k_update_irq(2); m68k_update_irq(2);
} }
/* force HV Counter Latch (some games does not lock HV Counter but instead use larger offset value) */ /* HACK: force HV Counter latch (some games does not lock HV Counter but instead use larger offset value) */
hvc_latch = 0x10000 | (y << 8); hvc_latch = 0x10000 | (y << 8);
if (reg[12] & 1) if (reg[12] & 1)
{ {

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Sega Light Phaser, Menacer & Konami Justifiers support * Sega Light Phaser, Menacer & Konami Justifiers support
* *
* Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:

View File

@ -1370,17 +1370,26 @@ unsigned int vdp_hvc_r(unsigned int cycles)
} }
else else
{ {
/* Mode 5: HV counters are frozen (cf. lightgun games & Sunset Riders) */
if (reg[1] & 4) if (reg[1] & 4)
{ {
/* Mode 5: both counters are frozen (Lightgun games, Sunset Riders) */ /* check if HVC is really locked or is read within INT2 callback (HVC latch is forced for lightgun emulation, cf. lightgun.c) */
if ((reg[0] & 0x02) || (m68k.int_mask == 0x0200))
{
#ifdef LOGVDP #ifdef LOGVDP
error("[%d(%d)][%d(%d)] HVC read -> 0x%x (%x)\n", v_counter, (cycles/MCYCLES_PER_LINE-1)%lines_per_frame, cycles, cycles%MCYCLES_PER_LINE, hvc_latch & 0xffff, m68k_get_reg(M68K_REG_PC)); error("[%d(%d)][%d(%d)] HVC read -> 0x%x (%x)\n", v_counter, (cycles/MCYCLES_PER_LINE-1)%lines_per_frame, cycles, cycles%MCYCLES_PER_LINE, data & 0xffff, m68k_get_reg(M68K_REG_PC));
#endif #endif
/* return latched HVC value */
return (data & 0xffff); return (data & 0xffff);
} }
/* HV counters should be free-running (fixes "Gunfight - 3 in 1" randomization when Justifiers are enabled) */
hvc_latch = 0;
data = hctab[cycles % MCYCLES_PER_LINE];
}
else else
{ {
/* Mode 4: VCounter runs normally, HCounter is frozen */ /* Mode 4: V counter runs normally, H counter is frozen */
data &= 0xff; data &= 0xff;
} }
} }