Skip to content

Commit

Permalink
Merge pull request dolphin-emu#8464 from jordan-woyak/wm-emu-errorcode
Browse files Browse the repository at this point in the history
WiimoteEmu: Minor accuracy fixes.
  • Loading branch information
leoetlino authored Nov 17, 2019
2 parents bc1aa36 + 4d24f16 commit 97f9f25
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
12 changes: 9 additions & 3 deletions Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
17 changes: 12 additions & 5 deletions Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

Expand All @@ -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()
Expand Down

0 comments on commit 97f9f25

Please sign in to comment.