mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 07:39:26 +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)
|
void CEXISD::ImmWrite(u32 data, u32 size)
|
||||||
{
|
{
|
||||||
if (state == State::Uninitialized || state == State::GetId)
|
while (size--)
|
||||||
{
|
{
|
||||||
// Get ID command
|
u8 byte = data >> 24;
|
||||||
INFO_LOG_FMT(EXPANSIONINTERFACE, "SD: EXI_GetID detected (size = {:x}, data = {:x})", size,
|
WriteByte(byte);
|
||||||
data);
|
data <<= 8;
|
||||||
state = State::GetId;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (size--)
|
|
||||||
{
|
|
||||||
u8 byte = data >> 24;
|
|
||||||
WriteByte(byte);
|
|
||||||
data <<= 8;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CEXISD::ImmRead(u32 size)
|
u32 CEXISD::ImmRead(u32 size)
|
||||||
{
|
{
|
||||||
if (state == State::Uninitialized)
|
u32 res = 0;
|
||||||
|
u32 position = 0;
|
||||||
|
while (size--)
|
||||||
{
|
{
|
||||||
// ?
|
u8 byte = ReadByte();
|
||||||
return 0;
|
res |= byte << (24 - (position++ * 8));
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEXISD::ImmReadWrite(u32& data, u32 size)
|
void CEXISD::ImmReadWrite(u32& data, u32 size)
|
||||||
@ -490,7 +465,8 @@ u8 CEXISD::ReadByte()
|
|||||||
{
|
{
|
||||||
if (response.empty())
|
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;
|
return 0xff;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -173,10 +173,6 @@ private:
|
|||||||
|
|
||||||
enum class State
|
enum class State
|
||||||
{
|
{
|
||||||
// Hacky setup
|
|
||||||
Uninitialized,
|
|
||||||
GetId,
|
|
||||||
// Actual states for transmiting and receiving
|
|
||||||
ReadyForCommand,
|
ReadyForCommand,
|
||||||
ReadyForAppCommand,
|
ReadyForAppCommand,
|
||||||
SingleBlockRead,
|
SingleBlockRead,
|
||||||
@ -232,7 +228,7 @@ private:
|
|||||||
File::IOFile m_card;
|
File::IOFile m_card;
|
||||||
|
|
||||||
// STATE_TO_SAVE
|
// STATE_TO_SAVE
|
||||||
State state = State::Uninitialized;
|
State state = State::ReadyForCommand;
|
||||||
BlockState block_state = BlockState::Nothing;
|
BlockState block_state = BlockState::Nothing;
|
||||||
u32 command_position = 0;
|
u32 command_position = 0;
|
||||||
u32 block_position = 0;
|
u32 block_position = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user