Speed & detection improvement for save type detection tool.

This commit is contained in:
spacy51 2009-08-20 21:04:34 +00:00
parent 25fc661f12
commit d1dd74f65b
2 changed files with 11 additions and 6 deletions

View File

@ -121,6 +121,7 @@ struct {
{ "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR },
{ "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K },
{ "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M },
{ "OptionsEmulatorSaveDetectNow", ID_OPTIONS_EMULATOR_SAVETYPE_DETECTNOW },
{ "OptionsEmulatorAutoApplyPatchFiles", ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES },
{ "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT },
{ "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK },

View File

@ -791,10 +791,14 @@ void MainWnd::OnOptionsEmulatorSavetypeDetectNow()
char temp[11]; temp[10] = '\0';
CString answer( _T( "This cartridge has probably no backup media." ) );
for( int address = 0; address < address_max; address += 4 ) {
const u8 check = rom[address];
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 );
if( 'E' == check ) {
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." );
@ -802,15 +806,15 @@ void MainWnd::OnOptionsEmulatorSavetypeDetectNow()
}
}
if( 'S' == check ) {
if( SRAM == check ) {
memcpy( temp, &rom[address], 10 );
if( 0 == strncmp( temp, "SRAM_V", 6 ) ) {
if( ( 0 == strncmp( temp, "SRAM_V", 6 ) ) || ( 0 == strncmp( temp, "SRAM_F_V", 8 ) ) ) {
answer = _T( "This cartridge uses SRAM." );
break;
}
}
if( 'F' == check ) {
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)." );