From 461633fabc464c938f898a5a79053c8daaa7e635 Mon Sep 17 00:00:00 2001 From: daco65 Date: Tue, 14 Oct 2008 11:19:59 +0000 Subject: [PATCH] added support for raw memory card backups. for now only the 251 blocks and 59 blocks cards are supported. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@862 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp index 692d46af69..af470dc2b0 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp @@ -61,18 +61,31 @@ CEXIMemoryCard::CEXIMemoryCard(const std::string& _rName, const std::string& _rF //0x00000020 Memory Card 507 32Mb //0x00000040 Memory Card 1019 64Mb //0x00000080 Memory Card 2043 128Mb - nintendo_card_id = 0x00000010; card_id = 0xc221; - //nintendo_card_id = 0x00000510; // 16Mb "bigben" card //card_id = 0xc243; - - memory_card_size = 2 * 1024 * 1024; //16Mb - memory_card_content = new u8[memory_card_size]; - - memset(memory_card_content, 0xFF, memory_card_size); - FILE* pFile = NULL; pFile = fopen(m_strFilename.c_str(), "rb"); + fseek( pFile, 0L, SEEK_END ); + long MemFileSize = ftell( pFile ); + //the switch is based on the size of the memory cards depending on their size !IN BYTES! + //by default they will be 2MB mem cards + switch (MemFileSize) + { + case 524288: + //the 59 block mem card, 512KB big + nintendo_card_id = 0x00000004; + memory_card_size = 512 * 1024; + break; + default: + //Default = 2MB mem cards that are 251 blocks + nintendo_card_id = 0x00000010; + memory_card_size = 2 * 1024 * 1024; + } + memory_card_content = new u8[memory_card_size]; + memset(memory_card_content, 0xFF, memory_card_size); + + //return to start otherwise the mem card is "corrupt" + fseek( pFile,0L,SEEK_SET); if (pFile) { LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_strFilename.c_str());