From fcb86ce1c160ac1a8441073fd773a071096b2b39 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 21 Aug 2020 17:52:29 -0700 Subject: [PATCH] Adjust SD getid thing --- Source/Core/Core/HW/EXI/EXI_DeviceSD.cpp | 47 ++++++++++++++++-------- Source/Core/Core/HW/EXI/EXI_DeviceSD.h | 13 +++++-- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSD.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceSD.cpp index 8a9e093234..945418aeaa 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSD.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSD.cpp @@ -6,6 +6,7 @@ #include +#include "Common/ChunkFile.h" #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" @@ -17,25 +18,33 @@ CEXISD::CEXISD(Core::System& system) : IEXIDevice(system) void CEXISD::ImmWrite(u32 data, u32 size) { - INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI SD ImmWrite: {:08x}", data); + if (inited) + { + IEXIDevice::ImmWrite(data, size); + } + else if (size == 2 && data == 0) + { + // Get ID command + INFO_LOG_FMT(EXPANSIONINTERFACE, "SD: EXI_GetID detected (size = {:x}, data = {:x})", size, data); + get_id = true; + } } u32 CEXISD::ImmRead(u32 size) { - INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI SD ImmRead"); - return -1; -} - -void CEXISD::DMAWrite(u32 address, u32 size) -{ - INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI SD DMAWrite: {:08x} bytes, from {:08x} to device", size, - address); -} - -void CEXISD::DMARead(u32 address, u32 size) -{ - INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI SD DMARead: {:08x} bytes, from device to {:08x}", size, - address); + if (get_id) + { + // This is not a good way of handling state + inited = true; + get_id = false; + INFO_LOG_FMT(EXPANSIONINTERFACE, "SD: EXI_GetID finished (size = {:x})", size); + // Same signed/unsigned mismatch in libogc; it wants -1 + return -1; + } + else + { + return IEXIDevice::ImmRead(size); + } } void CEXISD::SetCS(int cs) @@ -48,6 +57,14 @@ bool CEXISD::IsPresent() const return true; } +void CEXISD::DoState(PointerWrap& p) +{ + p.Do(inited); + p.Do(get_id); + p.Do(command); + p.Do(m_uPosition); +} + void CEXISD::TransferByte(u8& byte) { } diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSD.h b/Source/Core/Core/HW/EXI/EXI_DeviceSD.h index 6bf0c36d1c..8de986eb7b 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSD.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSD.h @@ -9,6 +9,8 @@ #include "Common/CommonTypes.h" #include "Core/HW/EXI/EXI_Device.h" +class PointerWrap; + namespace ExpansionInterface { // EXI-SD adapter (DOL-019) @@ -19,15 +21,18 @@ public: void ImmWrite(u32 data, u32 size) override; u32 ImmRead(u32 size) override; - - void DMAWrite(u32 address, u32 size) override; - void DMARead(u32 address, u32 size) override; - void SetCS(int cs) override; bool IsPresent() const override; + void DoState(PointerWrap& p) override; private: void TransferByte(u8& byte) override; + + // STATE_TO_SAVE + bool inited = false; + bool get_id = false; + int command = 0; + u32 m_uPosition = 0; }; } // namespace ExpansionInterface