Pad: Update status after ACK

This commit is contained in:
Connor McLaughlin 2019-12-07 00:02:47 +10:00
parent c1e9617c77
commit 54277dc24f

View file

@ -91,6 +91,7 @@ bool Pad::DoState(StateWrapper& sw)
sw.Do(&m_transmit_buffer); sw.Do(&m_transmit_buffer);
sw.Do(&m_receive_buffer_full); sw.Do(&m_receive_buffer_full);
sw.Do(&m_transmit_buffer_full); sw.Do(&m_transmit_buffer_full);
return !sw.HasError(); return !sw.HasError();
} }
@ -100,11 +101,17 @@ u32 Pad::ReadRegister(u32 offset)
{ {
case 0x00: // JOY_DATA case 0x00: // JOY_DATA
{ {
u8 value;
if (!m_receive_buffer_full) if (!m_receive_buffer_full)
{
Log_DevPrintf("Read from RX fifo when empty"); Log_DevPrintf("Read from RX fifo when empty");
value = 0xFF;
const u8 value = m_receive_buffer; }
m_receive_buffer_full = false; else
{
value = m_receive_buffer;
m_receive_buffer_full = false;
}
UpdateJoyStat(); UpdateJoyStat();
Log_DebugPrintf("JOY_DATA (R) -> 0x%02X", ZeroExtend32(value)); Log_DebugPrintf("JOY_DATA (R) -> 0x%02X", ZeroExtend32(value));
@ -244,7 +251,7 @@ void Pad::SoftReset()
void Pad::UpdateJoyStat() void Pad::UpdateJoyStat()
{ {
m_JOY_STAT.RXFIFONEMPTY = m_receive_buffer_full; m_JOY_STAT.RXFIFONEMPTY = m_receive_buffer_full;
m_JOY_STAT.TXDONE = !m_transmit_buffer_full && m_state == State::Idle; m_JOY_STAT.TXDONE = !m_transmit_buffer_full && m_state != State::Transmitting;
m_JOY_STAT.TXRDY = !m_transmit_buffer_full; m_JOY_STAT.TXRDY = !m_transmit_buffer_full;
} }
@ -377,6 +384,7 @@ void Pad::DoACK()
} }
EndTransfer(); EndTransfer();
UpdateJoyStat();
if (CanTransfer()) if (CanTransfer())
BeginTransfer(); BeginTransfer();