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