Merge pull request #9268 from leoetlino/devicememcard-minor-cleanup

EXI_DeviceMemoryCard: Medium cleanup
This commit is contained in:
Léo Lam
2020-11-25 10:07:44 +01:00
committed by GitHub
2 changed files with 195 additions and 191 deletions
File diff suppressed because it is too large Load Diff
+34 -33
View File
@@ -4,6 +4,7 @@
#pragma once
#include <array>
#include <functional>
#include <memory>
#include <string>
@@ -30,16 +31,16 @@ enum class AllowMovieFolder
class CEXIMemoryCard : public IEXIDevice
{
public:
CEXIMemoryCard(const int index, bool gciFolder, const Memcard::HeaderData& header_data);
virtual ~CEXIMemoryCard();
CEXIMemoryCard(int index, bool gci_folder, const Memcard::HeaderData& header_data);
~CEXIMemoryCard() override;
void SetCS(int cs) override;
bool IsInterruptSet() override;
bool UseDelayedTransferCompletion() const override;
bool IsPresent() const override;
void DoState(PointerWrap& p) override;
IEXIDevice* FindDevice(TEXIDevices device_type, int customIndex = -1) override;
void DMARead(u32 _uAddr, u32 _uSize) override;
void DMAWrite(u32 _uAddr, u32 _uSize) override;
IEXIDevice* FindDevice(TEXIDevices device_type, int custom_index) override;
void DMARead(u32 addr, u32 size) override;
void DMAWrite(u32 addr, u32 size) override;
// CoreTiming events need to be registered during boot since CoreTiming is DoState()-ed
// before ExpansionInterface so we'll lose the save stated events if the callbacks are
@@ -52,7 +53,7 @@ public:
private:
void SetupGciFolder(const Memcard::HeaderData& header_data);
void SetupRawMemcard(u16 sizeMb);
void SetupRawMemcard(u16 size_mb);
static void EventCompleteFindInstance(u64 userdata,
std::function<void(CEXIMemoryCard*)> callback);
@@ -71,40 +72,40 @@ 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 card_index;
int m_card_index;
//! memory card state
// STATE_TO_SAVE
int interruptSwitch;
bool m_bInterruptSet;
int command;
int status;
u32 m_uPosition;
u8 programming_buffer[128];
int m_interrupt_switch;
bool m_interrupt_set;
Command m_command;
int m_status;
u32 m_position;
std::array<u8, 128> m_programming_buffer;
//! memory card parameters
unsigned int card_id;
unsigned int address;
u32 memory_card_size;
std::unique_ptr<MemoryCardBase> memorycard;
unsigned int m_card_id;
unsigned int m_address;
u32 m_memory_card_size;
std::unique_ptr<MemoryCardBase> m_memory_card;
protected:
void TransferByte(u8& byte) override;