From 7f0831a5429b7f0acfadb29945a062a2526c734d Mon Sep 17 00:00:00 2001 From: Sour Date: Thu, 26 Dec 2024 11:52:29 +0900 Subject: [PATCH] GBA/SMS/WS: Fixed broken lag counter Also make counter reset to 0 when game is reset on all consoles --- Core/GBA/GbaControlManager.cpp | 1 + Core/NES/NesControlManager.cpp | 2 -- Core/SMS/SmsControlManager.cpp | 2 ++ Core/Shared/Emulator.cpp | 1 + Core/WS/WsMemoryManager.cpp | 6 +++++- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Core/GBA/GbaControlManager.cpp b/Core/GBA/GbaControlManager.cpp index 19a8eb984..caf95fccb 100644 --- a/Core/GBA/GbaControlManager.cpp +++ b/Core/GBA/GbaControlManager.cpp @@ -99,6 +99,7 @@ uint8_t GbaControlManager::ReadInputPort(uint32_t addr) return BitUtilities::GetBits<8>(_state.KeyControl); } } else { + SetInputReadFlag(); return (addr & 0x01) ? (_state.ActiveKeys >> 8) : (uint8_t)_state.ActiveKeys; } } diff --git a/Core/NES/NesControlManager.cpp b/Core/NES/NesControlManager.cpp index 966b9ce2c..e554b1c6c 100644 --- a/Core/NES/NesControlManager.cpp +++ b/Core/NES/NesControlManager.cpp @@ -274,13 +274,11 @@ void NesControlManager::ProcessWrites() void NesControlManager::Reset(bool softReset) { - ResetLagCounter(); } void NesControlManager::Serialize(Serializer& s) { BaseControlManager::Serialize(s); - SV(_lagCounter); SV(_writeAddr); SV(_writeValue); SV(_writePending); diff --git a/Core/SMS/SmsControlManager.cpp b/Core/SMS/SmsControlManager.cpp index fd34b6fec..7290072e6 100644 --- a/Core/SMS/SmsControlManager.cpp +++ b/Core/SMS/SmsControlManager.cpp @@ -89,6 +89,8 @@ uint8_t SmsControlManager::InternalReadPort(uint8_t port) uint8_t SmsControlManager::ReadPort(uint8_t port) { + SetInputReadFlag(); + if(_console->GetModel() == SmsModel::ColecoVision) { return ReadColecoVisionPort(port); } diff --git a/Core/Shared/Emulator.cpp b/Core/Shared/Emulator.cpp index fc9826dfe..f864ec16b 100644 --- a/Core/Shared/Emulator.cpp +++ b/Core/Shared/Emulator.cpp @@ -326,6 +326,7 @@ void Emulator::Reset() _systemActionManager->ResetState(); _console->GetControlManager()->UpdateInputState(); + _console->GetControlManager()->ResetLagCounter(); _videoRenderer->ClearFrame(); diff --git a/Core/WS/WsMemoryManager.cpp b/Core/WS/WsMemoryManager.cpp index f7fde0e9f..75b59b45c 100644 --- a/Core/WS/WsMemoryManager.cpp +++ b/Core/WS/WsMemoryManager.cpp @@ -261,7 +261,11 @@ uint8_t WsMemoryManager::InternalReadPort(uint16_t port, bool isWordAccess) case 0xB2: return _state.EnabledIrqs; case 0xB3: return _serial->Read(port); case 0xB4: return GetActiveIrqs(); - case 0xB5: return _controlManager->Read(); + + case 0xB5: + _controlManager->SetInputReadFlag(); + return _controlManager->Read(); + case 0xB7: return _state.EnableLowBatteryNmi ? 0x10 : 0; default: //TODOWS open bus