Re-enable the save type auto-detect code instead of enabling all save types.
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1245 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
b56e1edc45
commit
e831c2d6cb
14
src/Util.cpp
14
src/Util.cpp
|
@ -634,10 +634,10 @@ long utilGzMemTell(gzFile file)
|
|||
return memtell(file);
|
||||
}
|
||||
|
||||
void utilGBAFindSave(const u8 *data, const int size)
|
||||
void utilGBAFindSave(const int size)
|
||||
{
|
||||
u32 *p = (u32 *)data;
|
||||
u32 *end = (u32 *)(data + size);
|
||||
u32 *p = (u32 *)&rom[0];
|
||||
u32 *end = (u32 *)(&rom[0] + size);
|
||||
int saveType = 0;
|
||||
int flashSize = 0x10000;
|
||||
bool rtcFound = false;
|
||||
|
@ -648,22 +648,22 @@ void utilGBAFindSave(const u8 *data, const int size)
|
|||
if(d == 0x52504545) {
|
||||
if(memcmp(p, "EEPROM_", 7) == 0) {
|
||||
if(saveType == 0)
|
||||
saveType = 3;
|
||||
saveType = 1;
|
||||
}
|
||||
} else if (d == 0x4D415253) {
|
||||
if(memcmp(p, "SRAM_", 5) == 0) {
|
||||
if(saveType == 0)
|
||||
saveType = 1;
|
||||
saveType = 2;
|
||||
}
|
||||
} else if (d == 0x53414C46) {
|
||||
if(memcmp(p, "FLASH1M_", 8) == 0) {
|
||||
if(saveType == 0) {
|
||||
saveType = 2;
|
||||
saveType = 3;
|
||||
flashSize = 0x20000;
|
||||
}
|
||||
} else if(memcmp(p, "FLASH", 5) == 0) {
|
||||
if(saveType == 0) {
|
||||
saveType = 2;
|
||||
saveType = 3;
|
||||
flashSize = 0x10000;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ int utilGzRead(gzFile file, voidp buffer, unsigned int len);
|
|||
int utilGzClose(gzFile file);
|
||||
z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence);
|
||||
long utilGzMemTell(gzFile file);
|
||||
void utilGBAFindSave(const u8 *, const int);
|
||||
void utilGBAFindSave(const int);
|
||||
void utilUpdateSystemColorMaps(bool lcd = false);
|
||||
bool utilFileExists( const char *filename );
|
||||
|
||||
|
|
|
@ -521,6 +521,9 @@ bool MainWnd::FileRun()
|
|||
rtcEnable(theApp.winRtcEnable);
|
||||
cpuSaveType = theApp.winSaveType;
|
||||
|
||||
if (cpuSaveType == 0)
|
||||
utilGBAFindSave(theApp.romSize);
|
||||
|
||||
GetModuleFileName(NULL, tempName, 2048);
|
||||
|
||||
char *p = strrchr(tempName, '\\');
|
||||
|
|
|
@ -797,44 +797,32 @@ void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI* pCmdUI)
|
|||
void MainWnd::OnOptionsEmulatorSavetypeDetectNow()
|
||||
{
|
||||
if( theApp.cartridgeType != IMAGE_GBA ) return;
|
||||
|
||||
const int address_max = theApp.romSize - 10;
|
||||
char temp[11]; temp[10] = '\0';
|
||||
CString answer( _T( "This cartridge has probably no backup media." ) );
|
||||
|
||||
const u32 EEPR = 'E' | ( 'E' << 8 ) | ( 'P' << 16 ) | ( 'R' << 24 );
|
||||
const u32 SRAM = 'S' | ( 'R' << 8 ) | ( 'A' << 16 ) | ( 'M' << 24 );
|
||||
const u32 FLAS = 'F' | ( 'L' << 8 ) | ( 'A' << 16 ) | ( 'S' << 24 );
|
||||
|
||||
for( int address = 0; address < address_max; address += 4 ) {
|
||||
const u32 check = *((u32*)&rom[address]);
|
||||
|
||||
if( EEPR == check ) {
|
||||
memcpy( temp, &rom[address], 10 );
|
||||
if( 0 == strncmp( temp, "EEPROM_V", 8 ) ) {
|
||||
answer = _T( "This cartridge uses EEPROM." );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( SRAM == check ) {
|
||||
memcpy( temp, &rom[address], 10 );
|
||||
if( ( 0 == strncmp( temp, "SRAM_V", 6 ) ) || ( 0 == strncmp( temp, "SRAM_F_V", 8 ) ) ) {
|
||||
answer = _T( "This cartridge uses SRAM." );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( FLAS == check ) {
|
||||
memcpy( temp, &rom[address], 10 );
|
||||
if( ( 0 == strncmp( temp, "FLASH_V", 7 ) ) || ( 0 == strncmp( temp, "FLASH512_V", 10 ) ) ) {
|
||||
answer = _T( "This cartridge uses FLASH (64 KiB)." );
|
||||
break;
|
||||
}
|
||||
if( 0 == strncmp( temp, "FLASH1M_V", 9 ) ) {
|
||||
answer = _T( "This cartridge uses FLASH (128 KiB)." );
|
||||
break;
|
||||
}
|
||||
}
|
||||
utilGBAFindSave(theApp.romSize);
|
||||
switch (cpuSaveType)
|
||||
{
|
||||
case 0:
|
||||
answer = _T("This cartridge has probably no backup media.");
|
||||
break;
|
||||
case 1:
|
||||
answer = _T( "This cartridge uses SRAM." );
|
||||
break;
|
||||
case 2:
|
||||
if (flashSize == 0x10000)
|
||||
answer = _T( "This cartridge uses FLASH (64 KiB)." );
|
||||
else if (flashSize = 0x20000)
|
||||
answer = _T( "This cartridge uses FLASH (128 KiB)." );
|
||||
break;
|
||||
case 3:
|
||||
answer = _T("This cartridge uses EEPROM.");
|
||||
break;
|
||||
default:
|
||||
answer = _T("This cartridge has probably no backup media.");
|
||||
break;
|
||||
}
|
||||
|
||||
MessageBox( answer );
|
||||
|
|
Loading…
Reference in New Issue