Page 1 of 2
Added tool for detecting save type
Posted: Wed Aug 19, 2009 5:15 pm
by spacy51
SVN895, 896
Â
Options->Emulator->Save Type->Detect now...
Â
I tested about 20 commercial games with that and the results always matched up with the GBAtemp release list: http://www.gbatemp.net/newgon/?dat=gba
Â
Â
Code: Select all
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;
}
}
}
MessageBox( answer );
}
Added tool for detecting save type
Posted: Wed Aug 19, 2009 8:50 pm
by Squall Leonhart
would it work as an auto detect?
Added tool for detecting save type
Posted: Wed Aug 19, 2009 9:46 pm
by aceloop
this is a great tool, soon ill test it with my library. Spacy have u tested firered because i remember that being problematic? and could this work with the Classic NES Series as an auto detect as Squall said?
Added tool for detecting save type
Posted: Wed Aug 19, 2009 10:02 pm
by Squall Leonhart
GBA pokemon require a 128K save type
DBZ are slightly wierd... they use Fram, but... they aren't normal fram size... [img]<fileStore.core_Emoticons>/emoticons/huh.png[/img]/emoticons/huh@2x.png 2x" width="20" height="20" />
Added tool for detecting save type
Posted: Thu Aug 20, 2009 1:56 am
by Squall Leonhart
doesn't work on KH-CoM or Iridion II
Added tool for detecting save type
Posted: Thu Aug 20, 2009 4:12 am
by spacy51
Well, for MY ORIGINAL ROM of Iridion II it works by saying there is probably no backup media, which is right, because there really is none in the real thing.
Added tool for detecting save type
Posted: Thu Aug 20, 2009 5:05 am
by Squall Leonhart
lol, Also does it for Zoids Legacy.
Â
Â
and all of them save fine [img]<fileStore.core_Emoticons>/emoticons/tongue.png[/img]/emoticons/tongue@2x.png 2x" width="20" height="20" />
Added tool for detecting save type
Posted: Thu Aug 20, 2009 5:40 am
by spacy51
But Iridion really doesn't save, there's even a password system in it.
Added tool for detecting save type
Posted: Thu Aug 20, 2009 5:00 pm
by spacy51
I found a game which uses a little different string:
Â
Lufia - The Ruins of Lore (USA)
String is "SRAM_F_V102"
Something like that is not even documented in GBATEK. There mgiht be more games like that. Maybe I should write a tool to test all my games and see what the tool is good for.
Added tool for detecting save type
Posted: Fri Aug 21, 2009 5:30 pm
by spacy51
I made the detection into a command line tool and checked some ROMs with it. The tool is attached. Just drag & drop some ROMs on it and it will create a .txt file in the tool's dir with the output info.
Â
My code is actually quite fast:
500 files -> 56 seconds
Keep in mind this also includes the time to read every file into memory
Â
Â
Edit:
This forum destroys all my 7z+zip uploads by leaving out bytes at the end of the file [img]<fileStore.core_Emoticons>/emoticons/huh.png[/img]/emoticons/huh@2x.png 2x" width="20" height="20" />
Â
http://spacy51.sp.funpic.de/VBA-M/gbaSaveTypeDetect/
Â
Â
Please tell me if a game was not detected correctly.
If everything works fine, we could use this algorithm for the VBA-M core.