diff --git a/src/core/justifier.cpp b/src/core/justifier.cpp index 211b394c7..dd91644cd 100644 --- a/src/core/justifier.cpp +++ b/src/core/justifier.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin // 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; diff --git a/src/core/justifier.h b/src/core/justifier.h index 27de367d8..05ad8953b 100644 --- a/src/core/justifier.h +++ b/src/core/justifier.h @@ -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; diff --git a/src/core/save_state_version.h b/src/core/save_state_version.h index 103ab4f01..36ed7393b 100644 --- a/src/core/save_state_version.h +++ b/src/core/save_state_version.h @@ -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);