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
This commit is contained in:
daco65 2008-10-14 11:19:59 +00:00
parent d3cbb81f0c
commit 461633fabc
1 changed files with 21 additions and 8 deletions

View File

@ -61,18 +61,31 @@ CEXIMemoryCard::CEXIMemoryCard(const std::string& _rName, const std::string& _rF
//0x00000020 Memory Card 507 32Mb //0x00000020 Memory Card 507 32Mb
//0x00000040 Memory Card 1019 64Mb //0x00000040 Memory Card 1019 64Mb
//0x00000080 Memory Card 2043 128Mb //0x00000080 Memory Card 2043 128Mb
nintendo_card_id = 0x00000010;
card_id = 0xc221; card_id = 0xc221;
//nintendo_card_id = 0x00000510; // 16Mb "bigben" card
//card_id = 0xc243; //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; FILE* pFile = NULL;
pFile = fopen(m_strFilename.c_str(), "rb"); 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) if (pFile)
{ {
LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_strFilename.c_str()); LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_strFilename.c_str());