Adjust SD getid thing

This commit is contained in:
Pokechu22 2020-08-21 17:52:29 -07:00
parent 333636d404
commit fcb86ce1c1
2 changed files with 41 additions and 19 deletions

View File

@ -6,6 +6,7 @@
#include <string>
#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)
{
}

View File

@ -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