From e70f155054dc56fdf610e6fa8a0dd5f6cae76235 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 31 May 2024 21:08:21 +1000 Subject: [PATCH] MemoryCard: Implement GetID command --- src/core/memory_card.cpp | 14 +++++++++++++- src/core/memory_card.h | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/core/memory_card.cpp b/src/core/memory_card.cpp index 4bd68724c..229aa5756 100644 --- a/src/core/memory_card.cpp +++ b/src/core/memory_card.cpp @@ -209,6 +209,16 @@ bool MemoryCard::Transfer(const u8 data_in, u8* data_out) FIXED_REPLY_STATE(State::WriteACK2, 0x5D, true, State::WriteEnd); FIXED_REPLY_STATE(State::WriteEnd, 0x47, false, State::Idle); + // TODO: This really needs a proper buffer system... + FIXED_REPLY_STATE(State::GetIDCardID1, 0x5A, true, State::GetIDCardID2); + FIXED_REPLY_STATE(State::GetIDCardID2, 0x5D, true, State::GetIDACK1); + FIXED_REPLY_STATE(State::GetIDACK1, 0x5C, true, State::GetIDACK2); + FIXED_REPLY_STATE(State::GetIDACK2, 0x5D, true, State::GetID1); + FIXED_REPLY_STATE(State::GetID1, 0x04, true, State::GetID2); + FIXED_REPLY_STATE(State::GetID2, 0x00, true, State::GetID3); + FIXED_REPLY_STATE(State::GetID3, 0x00, true, State::GetID4); + FIXED_REPLY_STATE(State::GetID4, 0x80, true, State::Command); + // new command case State::Idle: { @@ -244,7 +254,9 @@ bool MemoryCard::Transfer(const u8 data_in, u8* data_out) case 0x53: // get id { - Panic("implement me"); + *data_out = m_FLAG.bits; + ack = true; + m_state = State::GetIDCardID1; } break; diff --git a/src/core/memory_card.h b/src/core/memory_card.h index 314547645..41403219b 100644 --- a/src/core/memory_card.h +++ b/src/core/memory_card.h @@ -80,6 +80,15 @@ private: WriteACK1, WriteACK2, WriteEnd, + + GetIDCardID1, + GetIDCardID2, + GetIDACK1, + GetIDACK2, + GetID1, + GetID2, + GetID3, + GetID4, }; static TickCount GetSaveDelayInTicks();