Justifier: Handle byte 4 IRQ enable flag

Fixes games with two justifiers connected concurrently.
This commit is contained in:
Stenzek 2025-04-24 21:20:42 +10:00
parent 740758fdda
commit 589b8f5139
No known key found for this signature in database
3 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
#include "justifier.h"
@ -89,6 +89,7 @@ bool Justifier::DoState(StateWrapper& sw, bool apply_input_state)
m_position_valid = position_valid;
}
sw.DoEx(&m_irq_enabled, 82, true);
sw.Do(&m_transfer_state);
if (sw.IsReading())
@ -178,6 +179,13 @@ bool Justifier::Transfer(const u8 data_in, u8* data_out)
case TransferState::ButtonsLSB:
{
const bool new_irq_enabled = ((data_in & 0x10) == 0x10);
if (new_irq_enabled != m_irq_enabled)
{
m_irq_enabled = new_irq_enabled;
UpdateIRQEvent();
}
*data_out = Truncate8(m_button_state);
m_transfer_state = TransferState::ButtonsMSB;
return true;
@ -251,7 +259,7 @@ void Justifier::UpdateIRQEvent()
// TODO: Avoid deactivate and event sort.
m_irq_event.Deactivate();
if (!m_position_valid)
if (!m_position_valid || !m_irq_enabled)
return;
u32 current_tick, current_line;

View File

@ -94,6 +94,7 @@ private:
u16 m_button_state = UINT16_C(0xFFFF);
u8 m_shoot_offscreen = 0;
bool m_position_valid = false;
bool m_irq_enabled = false;
TransferState m_transfer_state = TransferState::Idle;

View File

@ -6,7 +6,7 @@
#include "common/types.h"
static constexpr u32 SAVE_STATE_MAGIC = 0x43435544;
static constexpr u32 SAVE_STATE_VERSION = 81;
static constexpr u32 SAVE_STATE_VERSION = 82;
static constexpr u32 SAVE_STATE_MINIMUM_VERSION = 42;
static_assert(SAVE_STATE_VERSION >= SAVE_STATE_MINIMUM_VERSION);