EXI_DeviceMemoryCard: Use enum class for Command
This commit is contained in:
parent
b2f00be637
commit
f81062f561
|
@ -118,7 +118,7 @@ CEXIMemoryCard::CEXIMemoryCard(const int index, bool gci_folder,
|
||||||
|
|
||||||
m_interrupt_switch = 0;
|
m_interrupt_switch = 0;
|
||||||
m_interrupt_set = false;
|
m_interrupt_set = false;
|
||||||
m_command = 0;
|
m_command = Command::NintendoID;
|
||||||
m_status = MC_STATUS_BUSY | MC_STATUS_UNLOCKED | MC_STATUS_READY;
|
m_status = MC_STATUS_BUSY | MC_STATUS_UNLOCKED | MC_STATUS_READY;
|
||||||
m_position = 0;
|
m_position = 0;
|
||||||
memset(m_programming_buffer, 0, sizeof(m_programming_buffer));
|
memset(m_programming_buffer, 0, sizeof(m_programming_buffer));
|
||||||
|
@ -289,7 +289,7 @@ void CEXIMemoryCard::SetCS(int cs)
|
||||||
{
|
{
|
||||||
switch (m_command)
|
switch (m_command)
|
||||||
{
|
{
|
||||||
case cmdSectorErase:
|
case Command::SectorErase:
|
||||||
if (m_position > 2)
|
if (m_position > 2)
|
||||||
{
|
{
|
||||||
m_memory_card->ClearBlock(m_address & (m_memory_card_size - 1));
|
m_memory_card->ClearBlock(m_address & (m_memory_card_size - 1));
|
||||||
|
@ -302,7 +302,7 @@ void CEXIMemoryCard::SetCS(int cs)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdChipErase:
|
case Command::ChipErase:
|
||||||
if (m_position > 2)
|
if (m_position > 2)
|
||||||
{
|
{
|
||||||
// TODO: Investigate on HW, I (LPFaint99) believe that this only
|
// TODO: Investigate on HW, I (LPFaint99) believe that this only
|
||||||
|
@ -312,7 +312,7 @@ void CEXIMemoryCard::SetCS(int cs)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdPageProgram:
|
case Command::PageProgram:
|
||||||
if (m_position >= 5)
|
if (m_position >= 5)
|
||||||
{
|
{
|
||||||
int count = m_position - 5;
|
int count = m_position - 5;
|
||||||
|
@ -329,6 +329,9 @@ void CEXIMemoryCard::SetCS(int cs)
|
||||||
CmdDoneLater(5000);
|
CmdDoneLater(5000);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,26 +348,26 @@ void CEXIMemoryCard::TransferByte(u8& byte)
|
||||||
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: > {:02x}", byte);
|
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: > {:02x}", byte);
|
||||||
if (m_position == 0)
|
if (m_position == 0)
|
||||||
{
|
{
|
||||||
m_command = byte; // first byte is command
|
m_command = static_cast<Command>(byte); // first byte is command
|
||||||
byte = 0xFF; // would be tristate, but we don't care.
|
byte = 0xFF; // would be tristate, but we don't care.
|
||||||
|
|
||||||
switch (m_command) // This seems silly, do we really need it?
|
switch (m_command) // This seems silly, do we really need it?
|
||||||
{
|
{
|
||||||
case cmdNintendoID:
|
case Command::NintendoID:
|
||||||
case cmdReadArray:
|
case Command::ReadArray:
|
||||||
case cmdArrayToBuffer:
|
case Command::ArrayToBuffer:
|
||||||
case cmdSetInterrupt:
|
case Command::SetInterrupt:
|
||||||
case cmdWriteBuffer:
|
case Command::WriteBuffer:
|
||||||
case cmdReadStatus:
|
case Command::ReadStatus:
|
||||||
case cmdReadID:
|
case Command::ReadID:
|
||||||
case cmdReadErrorBuffer:
|
case Command::ReadErrorBuffer:
|
||||||
case cmdWakeUp:
|
case Command::WakeUp:
|
||||||
case cmdSleep:
|
case Command::Sleep:
|
||||||
case cmdClearStatus:
|
case Command::ClearStatus:
|
||||||
case cmdSectorErase:
|
case Command::SectorErase:
|
||||||
case cmdPageProgram:
|
case Command::PageProgram:
|
||||||
case cmdExtraByteProgram:
|
case Command::ExtraByteProgram:
|
||||||
case cmdChipErase:
|
case Command::ChipErase:
|
||||||
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0. seems normal.",
|
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0. seems normal.",
|
||||||
m_command);
|
m_command);
|
||||||
break;
|
break;
|
||||||
|
@ -372,7 +375,7 @@ void CEXIMemoryCard::TransferByte(u8& byte)
|
||||||
WARN_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0", m_command);
|
WARN_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0", m_command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (m_command == cmdClearStatus)
|
if (m_command == Command::ClearStatus)
|
||||||
{
|
{
|
||||||
m_status &= ~MC_STATUS_PROGRAMEERROR;
|
m_status &= ~MC_STATUS_PROGRAMEERROR;
|
||||||
m_status &= ~MC_STATUS_ERASEERROR;
|
m_status &= ~MC_STATUS_ERASEERROR;
|
||||||
|
@ -389,7 +392,7 @@ void CEXIMemoryCard::TransferByte(u8& byte)
|
||||||
{
|
{
|
||||||
switch (m_command)
|
switch (m_command)
|
||||||
{
|
{
|
||||||
case cmdNintendoID:
|
case Command::NintendoID:
|
||||||
//
|
//
|
||||||
// Nintendo card:
|
// Nintendo card:
|
||||||
// 00 | 80 00 00 00 10 00 00 00
|
// 00 | 80 00 00 00 10 00 00 00
|
||||||
|
@ -402,7 +405,7 @@ void CEXIMemoryCard::TransferByte(u8& byte)
|
||||||
byte = static_cast<u8>(m_memory_card->GetCardId() >> (24 - (((m_position - 2) & 3) * 8)));
|
byte = static_cast<u8>(m_memory_card->GetCardId() >> (24 - (((m_position - 2) & 3) * 8)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdReadArray:
|
case Command::ReadArray:
|
||||||
switch (m_position)
|
switch (m_position)
|
||||||
{
|
{
|
||||||
case 1: // AD1
|
case 1: // AD1
|
||||||
|
@ -429,19 +432,19 @@ void CEXIMemoryCard::TransferByte(u8& byte)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdReadStatus:
|
case Command::ReadStatus:
|
||||||
// (unspecified for byte 1)
|
// (unspecified for byte 1)
|
||||||
byte = m_status;
|
byte = m_status;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdReadID:
|
case Command::ReadID:
|
||||||
if (m_position == 1) // (unspecified)
|
if (m_position == 1) // (unspecified)
|
||||||
byte = static_cast<u8>(m_card_id >> 8);
|
byte = static_cast<u8>(m_card_id >> 8);
|
||||||
else
|
else
|
||||||
byte = static_cast<u8>((m_position & 1) ? (m_card_id) : (m_card_id >> 8));
|
byte = static_cast<u8>((m_position & 1) ? (m_card_id) : (m_card_id >> 8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdSectorErase:
|
case Command::SectorErase:
|
||||||
switch (m_position)
|
switch (m_position)
|
||||||
{
|
{
|
||||||
case 1: // AD1
|
case 1: // AD1
|
||||||
|
@ -454,7 +457,7 @@ void CEXIMemoryCard::TransferByte(u8& byte)
|
||||||
byte = 0xFF;
|
byte = 0xFF;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdSetInterrupt:
|
case Command::SetInterrupt:
|
||||||
if (m_position == 1)
|
if (m_position == 1)
|
||||||
{
|
{
|
||||||
m_interrupt_switch = byte;
|
m_interrupt_switch = byte;
|
||||||
|
@ -462,11 +465,11 @@ void CEXIMemoryCard::TransferByte(u8& byte)
|
||||||
byte = 0xFF;
|
byte = 0xFF;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdChipErase:
|
case Command::ChipErase:
|
||||||
byte = 0xFF;
|
byte = 0xFF;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdPageProgram:
|
case Command::PageProgram:
|
||||||
switch (m_position)
|
switch (m_position)
|
||||||
{
|
{
|
||||||
case 1: // AD1
|
case 1: // AD1
|
||||||
|
|
|
@ -71,23 +71,23 @@ private:
|
||||||
// Variant of CmdDone which schedules an event later in the future to complete the command.
|
// Variant of CmdDone which schedules an event later in the future to complete the command.
|
||||||
void CmdDoneLater(u64 cycles);
|
void CmdDoneLater(u64 cycles);
|
||||||
|
|
||||||
enum
|
enum class Command
|
||||||
{
|
{
|
||||||
cmdNintendoID = 0x00,
|
NintendoID = 0x00,
|
||||||
cmdReadArray = 0x52,
|
ReadArray = 0x52,
|
||||||
cmdArrayToBuffer = 0x53,
|
ArrayToBuffer = 0x53,
|
||||||
cmdSetInterrupt = 0x81,
|
SetInterrupt = 0x81,
|
||||||
cmdWriteBuffer = 0x82,
|
WriteBuffer = 0x82,
|
||||||
cmdReadStatus = 0x83,
|
ReadStatus = 0x83,
|
||||||
cmdReadID = 0x85,
|
ReadID = 0x85,
|
||||||
cmdReadErrorBuffer = 0x86,
|
ReadErrorBuffer = 0x86,
|
||||||
cmdWakeUp = 0x87,
|
WakeUp = 0x87,
|
||||||
cmdSleep = 0x88,
|
Sleep = 0x88,
|
||||||
cmdClearStatus = 0x89,
|
ClearStatus = 0x89,
|
||||||
cmdSectorErase = 0xF1,
|
SectorErase = 0xF1,
|
||||||
cmdPageProgram = 0xF2,
|
PageProgram = 0xF2,
|
||||||
cmdExtraByteProgram = 0xF3,
|
ExtraByteProgram = 0xF3,
|
||||||
cmdChipErase = 0xF4,
|
ChipErase = 0xF4,
|
||||||
};
|
};
|
||||||
|
|
||||||
int m_card_index;
|
int m_card_index;
|
||||||
|
@ -96,7 +96,7 @@ private:
|
||||||
// STATE_TO_SAVE
|
// STATE_TO_SAVE
|
||||||
int m_interrupt_switch;
|
int m_interrupt_switch;
|
||||||
bool m_interrupt_set;
|
bool m_interrupt_set;
|
||||||
int m_command;
|
Command m_command;
|
||||||
int m_status;
|
int m_status;
|
||||||
u32 m_position;
|
u32 m_position;
|
||||||
u8 m_programming_buffer[128];
|
u8 m_programming_buffer[128];
|
||||||
|
|
Loading…
Reference in New Issue