fix for memcards. the default is 128Mb now too. (shouldn't be a hassle, if there's a bunch of repeated data inside, they still compress nicely :) )

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@866 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2008-10-14 17:42:59 +00:00
parent e1ca5de156
commit 5157e69211
1 changed files with 27 additions and 25 deletions

View File

@ -45,7 +45,7 @@ CEXIMemoryCard::CEXIMemoryCard(const std::string& _rName, const std::string& _rF
this->card_index = _card_index; this->card_index = _card_index;
cards[_card_index] = this; cards[_card_index] = this;
et_this_card = CoreTiming::RegisterEvent(_rName.c_str(), FlushCallback); et_this_card = CoreTiming::RegisterEvent(_rName.c_str(), FlushCallback);
interruptSwitch = 0; interruptSwitch = 0;
m_bInterruptSet = 0; m_bInterruptSet = 0;
command = 0; command = 0;
@ -53,7 +53,7 @@ CEXIMemoryCard::CEXIMemoryCard(const std::string& _rName, const std::string& _rF
m_uPosition = 0; m_uPosition = 0;
memset(programming_buffer, 0, sizeof(programming_buffer)); memset(programming_buffer, 0, sizeof(programming_buffer));
formatDelay = 0; formatDelay = 0;
//Nintendo Memory Card EXI IDs //Nintendo Memory Card EXI IDs
//0x00000004 Memory Card 59 4Mbit //0x00000004 Memory Card 59 4Mbit
//0x00000008 Memory Card 123 8Mb //0x00000008 Memory Card 123 8Mb
@ -61,65 +61,67 @@ 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
card_id = 0xc221;
//0x00000510 16Mb "bigben" card
//card_id = 0xc243; //card_id = 0xc243;
card_id = 0xc221; // It's a nintendo brand memcard
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 ); if (pFile)
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 / (8 * 1024))-5) // Convert the filesize in bytes to the "nintendo-size"
{ {
fseek( pFile, 0L, SEEK_END );
long MemFileSize = ftell( pFile );
switch ((MemFileSize / (8 * 1024))-5) // Convert the filesize in bytes to the "nintendo-size"
{
case 59: case 59:
//4Mb or 512KB size
nintendo_card_id = 0x00000004; nintendo_card_id = 0x00000004;
memory_card_size = 512 * 1024; memory_card_size = 512 * 1024;
break; break;
case 123: case 123:
//8Mb or 1MB size
nintendo_card_id = 0x00000008; nintendo_card_id = 0x00000008;
memory_card_size = 1024 * 1024; memory_card_size = 1024 * 1024;
break; break;
case 251: case 251:
//16Mb or 2MB size
nintendo_card_id = 0x00000010; nintendo_card_id = 0x00000010;
memory_card_size = 2 * 1024 * 1024; memory_card_size = 2 * 1024 * 1024;
break; break;
case 507: case 507:
//32Mb or 4MB size
nintendo_card_id = 0x00000020; nintendo_card_id = 0x00000020;
memory_card_size = 4 * 1024 * 1024; memory_card_size = 4 * 1024 * 1024;
break; break;
case 1019: case 1019:
//64Mb or 8MB size
nintendo_card_id = 0x00000040; nintendo_card_id = 0x00000040;
memory_card_size = 8 * 1024 * 1024; memory_card_size = 8 * 1024 * 1024;
break; break;
case 2043: case 2043:
//128Mb or 16MB size
nintendo_card_id = 0x00000080; nintendo_card_id = 0x00000080;
memory_card_size = 16 * 1024 * 1024; memory_card_size = 16 * 1024 * 1024;
break; break;
default: default:
// Perhaps default behavior should be changed? // Because everyone wants the biggest memcard :}
nintendo_card_id = 0x00000010; nintendo_card_id = 0x00000080;
memory_card_size = 2 * 1024 * 1024; memory_card_size = 16 * 1024 * 1024;
break; break;
} }
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);
//return to start otherwise the mem card is "corrupt"
fseek( pFile,0L,SEEK_SET); memory_card_content = new u8[memory_card_size];
if (pFile) memset(memory_card_content, 0xFF, memory_card_size);
{
LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_strFilename.c_str()); LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_strFilename.c_str());
fread(memory_card_content, 1, memory_card_size, pFile); fread(memory_card_content, 1, memory_card_size, pFile);
fclose(pFile); fclose(pFile);
} }
else else
{ {
nintendo_card_id = 0x00000080;
memory_card_size = 16 * 1024 * 1024;
LOG(EXPANSIONINTERFACE, "No memory card found. Will create new."); LOG(EXPANSIONINTERFACE, "No memory card found. Will create new.");
Flush(); Flush();
Core::DisplayMessage(StringFromFormat("Wrote memory card contents to %s", m_strFilename.c_str()), 4000); Core::DisplayMessage(StringFromFormat("Wrote memory card contents to %s", m_strFilename.c_str()), 4000);