Added tool for detecting save type

spacy51
Senior Member
Posts: 371
Joined: Tue Mar 18, 2008 4:59 pm

Added tool for detecting save type

Post 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 );
}
Last edited by spacy51 on Thu Aug 20, 2009 5:04 pm, edited 1 time in total.
Squall Leonhart
Posting Freak
Posts: 1223
Joined: Tue Mar 18, 2008 9:21 am

Added tool for detecting save type

Post by Squall Leonhart »

would it work as an auto detect?

aceloop
Junior Member
Posts: 35
Joined: Tue May 27, 2008 8:39 am

Added tool for detecting save type

Post 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?

Last edited by aceloop on Wed Aug 19, 2009 9:50 pm, edited 1 time in total.
Squall Leonhart
Posting Freak
Posts: 1223
Joined: Tue Mar 18, 2008 9:21 am

Added tool for detecting save type

Post 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" />

Squall Leonhart
Posting Freak
Posts: 1223
Joined: Tue Mar 18, 2008 9:21 am

Added tool for detecting save type

Post by Squall Leonhart »

doesn't work on KH-CoM or Iridion II

spacy51
Senior Member
Posts: 371
Joined: Tue Mar 18, 2008 4:59 pm

Added tool for detecting save type

Post 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.

Squall Leonhart
Posting Freak
Posts: 1223
Joined: Tue Mar 18, 2008 9:21 am

Added tool for detecting save type

Post 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" />

spacy51
Senior Member
Posts: 371
Joined: Tue Mar 18, 2008 4:59 pm

Added tool for detecting save type

Post by spacy51 »

But Iridion really doesn't save, there's even a password system in it.

spacy51
Senior Member
Posts: 371
Joined: Tue Mar 18, 2008 4:59 pm

Added tool for detecting save type

Post 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.

spacy51
Senior Member
Posts: 371
Joined: Tue Mar 18, 2008 4:59 pm

Added tool for detecting save type

Post 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.

Last edited by spacy51 on Fri Aug 21, 2009 6:13 pm, edited 1 time in total.
Post Reply