Skip to content

Commit

Permalink
GBA/SMS/WS: Fixed broken lag counter
Browse files Browse the repository at this point in the history
Also make counter reset to 0 when game is reset on all consoles
  • Loading branch information
SourMesen committed Dec 26, 2024
1 parent e0dd12b commit 7f0831a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions Core/GBA/GbaControlManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 0 additions & 2 deletions Core/NES/NesControlManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Core/SMS/SmsControlManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions Core/Shared/Emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ void Emulator::Reset()
_systemActionManager->ResetState();

_console->GetControlManager()->UpdateInputState();
_console->GetControlManager()->ResetLagCounter();

_videoRenderer->ClearFrame();

Expand Down
6 changes: 5 additions & 1 deletion Core/WS/WsMemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f0831a

Please sign in to comment.