Merge pull request #8464 from jordan-woyak/wm-emu-errorcode

WiimoteEmu: Minor accuracy fixes.
This commit is contained in:
Léo Lam 2019-11-17 10:39:18 +01:00 committed by GitHub
commit 97f9f252cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 8 deletions

View File

@ -62,16 +62,22 @@ enum class AddressSpace : u8
// FYI: The EEPROM address space is offset 0x0070 on i2c slave 0x50. // FYI: The EEPROM address space is offset 0x0070 on i2c slave 0x50.
// However attempting to access this device directly results in an error. // However attempting to access this device directly results in an error.
EEPROM = 0x00, EEPROM = 0x00,
// 0x01 is never used but it does function on a real wiimote: // I2CBusAlt is never used by games but it does function on a real wiimote.
I2CBusAlt = 0x01, I2CBus = 0x01,
I2CBus = 0x02, I2CBusAlt = 0x02,
}; };
enum class ErrorCode : u8 enum class ErrorCode : u8
{ {
// Normal result.
Success = 0, 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, InvalidSpace = 6,
// Produced by an i2c read/write with a non-responding slave address.
Nack = 7, Nack = 7,
// Produced by accessing invalid regions of EEPROM or the EEPROM directly over i2c.
InvalidAddress = 8, InvalidAddress = 8,
}; };

View File

@ -258,7 +258,12 @@ void Wiimote::HandleRequestStatus(const OutputReportRequestStatus&)
void Wiimote::HandleWriteData(const OutputReportWriteData& wd) 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); u16 address = Common::swap16(wd.address);
@ -416,9 +421,11 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
{ {
if (m_read_request.size) if (m_read_request.size)
{ {
// There is already an active read request. // There is already an active read being processed.
// A real wiimote ignores the new one. WARN_LOG(WIIMOTE, "ReadData: attempting read during active request.");
WARN_LOG(WIIMOTE, "ReadData: ignoring read during active request.");
// A real wm+ sends a busy ack in this situation.
SendAck(OutputReportID::ReadData, ErrorCode::Busy);
return; return;
} }
@ -437,7 +444,7 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
// TODO: should this be removed and let Update() take care of it? // TODO: should this be removed and let Update() take care of it?
ProcessReadDataRequest(); ProcessReadDataRequest();
// FYI: No "ACK" is sent. // FYI: No "ACK" is sent under normal situations.
} }
bool Wiimote::ProcessReadDataRequest() bool Wiimote::ProcessReadDataRequest()