mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-11-04 18:05:06 +01:00
[Core/Input] cleaner fix for lightgun emulation when HVC latch is disabled
(better not make VDP core hackish)
This commit is contained in:
parent
49d22ce6ed
commit
75ac3317ed
@ -129,14 +129,25 @@ void lightgun_refresh(int port)
|
||||
}
|
||||
}
|
||||
|
||||
/* External Interrupt ? */
|
||||
/* External Interrupt enabled ? */
|
||||
if (reg[11] & 0x08)
|
||||
{
|
||||
m68k_update_irq(2);
|
||||
}
|
||||
|
||||
/* 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 enabled ? */
|
||||
if (reg[0] & 0x02)
|
||||
{
|
||||
/* line accurate V-Counter value */
|
||||
hvc_latch = 0x10000 | (y << 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* HACK: force HVC latch even when disabled (a few games does not lock HV Counter but instead applies larger offset value) */
|
||||
hvc_latch = 0x20000 | (y << 8);
|
||||
}
|
||||
|
||||
/* pixel accurate H-Counter value */
|
||||
if (reg[12] & 1)
|
||||
{
|
||||
hvc_latch |= hc_320[((x / 2) + input.x_offset) % 210];
|
||||
@ -147,6 +158,11 @@ void lightgun_refresh(int port)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (hvc_latch & 0x20000)
|
||||
{
|
||||
/* HVC should be free-running on other lines when latch is disabled (fixes "Gunfight - 3 in 1" randomization) */
|
||||
hvc_latch = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1362,7 +1362,7 @@ unsigned int vdp_hvc_r(unsigned int cycles)
|
||||
int vc;
|
||||
unsigned int data = hvc_latch;
|
||||
|
||||
/* Check if HVC is frozen */
|
||||
/* Check if HVC latch is enabled */
|
||||
if (!data)
|
||||
{
|
||||
/* Cycle-accurate HCounter (Striker, Mickey Mania, Skitchin, Road Rash I,II,III, Sonic 3D Blast...) */
|
||||
@ -1370,26 +1370,18 @@ unsigned int vdp_hvc_r(unsigned int cycles)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mode 5: HV counters are frozen (cf. lightgun games & Sunset Riders) */
|
||||
if (reg[1] & 4)
|
||||
/* Mode 5: H & V counters are frozen (cf. lightgun games, Sunset Riders logo) */
|
||||
if (reg[1] & 0x04)
|
||||
{
|
||||
/* 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
|
||||
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));
|
||||
error("[%d(%d)][%d(%d)] HVC latch 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
|
||||
/* return latched HVC value */
|
||||
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];
|
||||
/* return latched HVC value */
|
||||
return (data & 0xffff);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mode 4: V counter runs normally, H counter is frozen */
|
||||
/* Mode 4: by default, V counter runs normally & H counter is frozen */
|
||||
data &= 0xff;
|
||||
}
|
||||
}
|
||||
@ -1413,6 +1405,7 @@ unsigned int vdp_hvc_r(unsigned int cycles)
|
||||
vc = (vc & ~1) | ((vc >> 8) & 1);
|
||||
}
|
||||
|
||||
/* return HCounter in LSB & VCounter in MSB */
|
||||
data |= ((vc & 0xff) << 8);
|
||||
|
||||
#ifdef LOGVDP
|
||||
|
Loading…
Reference in New Issue
Block a user