From 4d24f160e300adadc94ad9491f24f43d82ee3847 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 10 Nov 2019 08:12:31 -0600 Subject: [PATCH] WiimoteEmu: Minor accuracy fixes. --- .../Core/HW/WiimoteCommon/WiimoteConstants.h | 12 +++++++++--- .../Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h b/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h index 02313ac048..99cf0e04e7 100644 --- a/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h +++ b/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h @@ -62,16 +62,22 @@ enum class AddressSpace : u8 // FYI: The EEPROM address space is offset 0x0070 on i2c slave 0x50. // However attempting to access this device directly results in an error. EEPROM = 0x00, - // 0x01 is never used but it does function on a real wiimote: - I2CBusAlt = 0x01, - I2CBus = 0x02, + // I2CBusAlt is never used by games but it does function on a real wiimote. + I2CBus = 0x01, + I2CBusAlt = 0x02, }; enum class ErrorCode : u8 { + // Normal result. Success = 0, + // Produced by read/write attempts during an active read. + Busy = 4, + // Produced by using something other than the above AddressSpace values. InvalidSpace = 6, + // Produced by an i2c read/write with a non-responding slave address. Nack = 7, + // Produced by accessing invalid regions of EEPROM or the EEPROM directly over i2c. InvalidAddress = 8, }; diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp index 5a11782d63..76d5848336 100644 --- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp @@ -258,7 +258,12 @@ void Wiimote::HandleRequestStatus(const OutputReportRequestStatus&) void Wiimote::HandleWriteData(const OutputReportWriteData& wd) { - // TODO: Are writes ignored during an active read request? + if (m_read_request.size) + { + // FYI: Writes during an active read will occasionally produce a "busy" (0x4) ack. + // We won't simulate that as it often does work. Poorly programmed games may rely on it. + WARN_LOG(WIIMOTE, "WriteData: write during active read request."); + } u16 address = Common::swap16(wd.address); @@ -416,9 +421,11 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd) { if (m_read_request.size) { - // There is already an active read request. - // A real wiimote ignores the new one. - WARN_LOG(WIIMOTE, "ReadData: ignoring read during active request."); + // There is already an active read being processed. + WARN_LOG(WIIMOTE, "ReadData: attempting read during active request."); + + // A real wm+ sends a busy ack in this situation. + SendAck(OutputReportID::ReadData, ErrorCode::Busy); return; } @@ -437,7 +444,7 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd) // TODO: should this be removed and let Update() take care of it? ProcessReadDataRequest(); - // FYI: No "ACK" is sent. + // FYI: No "ACK" is sent under normal situations. } bool Wiimote::ProcessReadDataRequest()