mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-08 15:20:45 +01:00
Eliminate hacky setup states
There still probably needs to be another state for CMD0 or such, but that can be handled separately.
This commit is contained in:
parent
bb432b6a9e
commit
acb4a4be64
@ -59,49 +59,24 @@ CEXISD::CEXISD(Core::System& system, int channel_num) : IEXIDevice(system)
|
||||
|
||||
void CEXISD::ImmWrite(u32 data, u32 size)
|
||||
{
|
||||
if (state == State::Uninitialized || state == State::GetId)
|
||||
while (size--)
|
||||
{
|
||||
// Get ID command
|
||||
INFO_LOG_FMT(EXPANSIONINTERFACE, "SD: EXI_GetID detected (size = {:x}, data = {:x})", size,
|
||||
data);
|
||||
state = State::GetId;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (size--)
|
||||
{
|
||||
u8 byte = data >> 24;
|
||||
WriteByte(byte);
|
||||
data <<= 8;
|
||||
}
|
||||
u8 byte = data >> 24;
|
||||
WriteByte(byte);
|
||||
data <<= 8;
|
||||
}
|
||||
}
|
||||
|
||||
u32 CEXISD::ImmRead(u32 size)
|
||||
{
|
||||
if (state == State::Uninitialized)
|
||||
u32 res = 0;
|
||||
u32 position = 0;
|
||||
while (size--)
|
||||
{
|
||||
// ?
|
||||
return 0;
|
||||
}
|
||||
else if (state == State::GetId)
|
||||
{
|
||||
INFO_LOG_FMT(EXPANSIONINTERFACE, "SD: EXI_GetID finished (size = {:x})", size);
|
||||
state = State::ReadyForCommand;
|
||||
// Same signed/unsigned mismatch in libogc; it wants -1
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 res = 0;
|
||||
u32 position = 0;
|
||||
while (size--)
|
||||
{
|
||||
u8 byte = ReadByte();
|
||||
res |= byte << (24 - (position++ * 8));
|
||||
}
|
||||
return res;
|
||||
u8 byte = ReadByte();
|
||||
res |= byte << (24 - (position++ * 8));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void CEXISD::ImmReadWrite(u32& data, u32 size)
|
||||
@ -490,7 +465,8 @@ u8 CEXISD::ReadByte()
|
||||
{
|
||||
if (response.empty())
|
||||
{
|
||||
// WARN_LOG_FMT(EXPANSIONINTERFACE, "Attempted to read from empty SD queue");
|
||||
// Note that SD cards are detected by trying to read a device ID, and getting 0xffffffff back;
|
||||
// this behavior is required for correct handling.
|
||||
return 0xff;
|
||||
}
|
||||
else
|
||||
|
@ -173,10 +173,6 @@ private:
|
||||
|
||||
enum class State
|
||||
{
|
||||
// Hacky setup
|
||||
Uninitialized,
|
||||
GetId,
|
||||
// Actual states for transmiting and receiving
|
||||
ReadyForCommand,
|
||||
ReadyForAppCommand,
|
||||
SingleBlockRead,
|
||||
@ -232,7 +228,7 @@ private:
|
||||
File::IOFile m_card;
|
||||
|
||||
// STATE_TO_SAVE
|
||||
State state = State::Uninitialized;
|
||||
State state = State::ReadyForCommand;
|
||||
BlockState block_state = BlockState::Nothing;
|
||||
u32 command_position = 0;
|
||||
u32 block_position = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user