spacy51
VBA-M Developer
      
Posts: 457
Joined: Mar 2008
Reputation: 3
Thanks: 0
1 thank was given in 1 posts
|
Added tool for detecting save type
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:
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 );
}
(This post was last modified: 08-21-2009 07:04 AM by spacy51. Edit Reason: N/A)
|
|
| 08-20-2009 07:15 AM |
|
Thank given by |
|
spacy51
VBA-M Developer
      
Posts: 457
Joined: Mar 2008
Reputation: 3
Thanks: 0
1 thank was given in 1 posts
|
RE: Added tool for detecting save type
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 o.o
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.
(This post was last modified: 08-22-2009 08:13 AM by spacy51. Edit Reason: N/A)
|
|
| 08-22-2009 07:30 AM |
|
Thank given by |
|
aceloop
Junior Member
 
Posts: 37
Joined: May 2008
Reputation: 0
Thanks: 0
0 thank was given in 0 posts
|
RE: Added tool for detecting save type
spacy i tested all the popular games, and checked GBAtemp release list with the save types. All the save types where correct. ill test more later.
Code:
\Advance Wars 2 - Black Hole Rising (U).gba
Result: This cartridge uses FLASH (64 KiB).
\Advance Wars (U) (v1.1).gba
Result: This cartridge uses FLASH (64 KiB).
\Astro Boy - Omega Factor (U).gba
Result: This cartridge uses EEPROM.
\Castlevania - Aria of Sorrow (E) .gba
Result: This cartridge uses SRAM.
\Castlevania - Circle of the Moon (U).gba
Result: This cartridge uses SRAM.
\Castlevania - Harmony of Dissonance (E).gba
Result: This cartridge uses SRAM.
\Final Fantasy I & II - Dawn of Souls (E) .gba
Result: This cartridge uses SRAM.
\Final Fantasy IV Advance (E) .gba
Result: This cartridge uses SRAM.
\Final Fantasy Tactics Advance (E).gba
Result: This cartridge uses FLASH (64 KiB).
\Final Fantasy V (E).gba
Result: This cartridge uses SRAM.
\Final Fantasy VI Advance (U).gba
Result: This cartridge uses SRAM.
\Fire Emblem - The Sacred Stones (U).gba
Result: This cartridge uses SRAM.
\Fire Emblem (U).gba
Result: This cartridge uses SRAM.
\F-Zero - Maximum Velocity (UE).gba
Result: This cartridge uses SRAM.
\Golden Sun - The Lost Age (UE).gba
Result: This cartridge uses FLASH (64 KiB).
\Golden Sun (UE).gba
Result: This cartridge uses FLASH (64 KiB).
\Gunstar Super Heroes.gba
Result: This cartridge uses EEPROM.
\Harvest Moon - Friends of Mineral Town (U).gba
Result: This cartridge uses SRAM.
\Harvest Moon - More Friends of Mineral Town (U).gba
Result: This cartridge uses SRAM.
\Kingdom Hearts - Chain of Memories (U).gba
Result: This cartridge uses SRAM.
\Legend of Zelda, The - A Link to the Past & Four Swords (U).gba
Result: This cartridge uses EEPROM.
\Mario & Luigi - Superstar Saga (E).gba
Result: This cartridge uses EEPROM.
\Mario Golf - Advance Tour (U).gba
Result: This cartridge uses SRAM.
\Mario Kart - Super Circuit (U).gba
Result: This cartridge uses FLASH (64 KiB).
\Mario Tennis Power Tour (U).gba
Result: This cartridge uses SRAM.
\Metroid - Zero Mission (E).gba
Result: This cartridge uses SRAM.
\Metroid Fusion (E) .gba
Result: This cartridge uses SRAM.
\Mortal Kombat - Deadly Alliance (UE).gba
Result: This cartridge uses EEPROM.
\Mother 3 (J).gba
Result: This cartridge uses FLASH (64 KiB).
\Pokemon Emerald (U).gba
Result: This cartridge uses FLASH (128 KiB).
\Pokemon Fire Red.gba
Result: This cartridge uses FLASH (128 KiB).
\Pokemon Mystery Dungeon - Red Rescue Team.gba
Result: This cartridge uses FLASH (128 KiB).
\Pokemon Video Volume 1.gba
Result: This cartridge has probably no backup media.
\Riviera - The Promised Land (U).gba
Result: This cartridge uses SRAM.
\Sonic Advance 2 (E) .gba
Result: This cartridge uses FLASH (64 KiB).
\Sonic Advance 3 (E).gba
Result: This cartridge uses FLASH (64 KiB).
\Sonic Advance (E).gba
Result: This cartridge uses FLASH (64 KiB).
\Super Mario Advance 3 - Yoshi's Island (U).gba
Result: This cartridge uses EEPROM.
\Super Mario Advance 4 - Super Mario Bros. 3 (E) (v1.1).gba
Result: This cartridge uses FLASH (128 KiB).
\Super Mario Advance (UE).gba
Result: This cartridge uses EEPROM.
\Super Street Fighter II Turbo - Revival (E).gba
Result: This cartridge uses EEPROM.
\Tactics Ogre - The Knight of Lodis (U).gba
Result: This cartridge uses FLASH (64 KiB).
\The Legend of Zelda - The Minish Cap.gba
Result: This cartridge uses EEPROM.
\Wario Land 4 (UE).gba
Result: This cartridge uses SRAM.
\WarioWare - Twisted! (U).gba
Result: This cartridge uses SRAM.
\WarioWare, Inc. - Mega Microgames! (U).gba
Result: This cartridge uses SRAM.
\Street Fighter Alpha 3 Upper (E).gba
Result: This cartridge uses EEPROM.
\Super Mario Advance 2 - Super Mario World (U).gba
Result: This cartridge uses EEPROM.
i think, i found a little bug with svn896. when you have no game loaded its says "This cartridge has probably no backup media.". shouldnt it be like some like "no cartridge loaded"??
(This post was last modified: 08-24-2009 02:49 AM by aceloop. Edit Reason: )
|
|
| 08-24-2009 01:03 AM |
|
Thank given by |
|
spacy51
VBA-M Developer
      
Posts: 457
Joined: Mar 2008
Reputation: 3
Thanks: 0
1 thank was given in 1 posts
|
RE: Added tool for detecting save type
Lol, I just found out VBA already has that kind of code in Util.cpp.
It also looks like a real time clock can be identified by the string: "SIIRTC_V"
However, this code is not used anywhere in VBA.
Quote:void utilGBAFindSave(const u8 *data, const int size)
{
u32 *p = (u32 *)data;
u32 *end = (u32 *)(data + size);
int saveType = 0;
int flashSize = 0x10000;
bool rtcFound = false;
while(p < end) {
u32 d = READ32LE(p);
if(d == 0x52504545) {
if(memcmp(p, "EEPROM_", 7) == 0) {
if(saveType == 0)
saveType = 3;
}
} else if (d == 0x4D415253) {
if(memcmp(p, "SRAM_", 5) == 0) {
if(saveType == 0)
saveType = 1;
}
} else if (d == 0x53414C46) {
if(memcmp(p, "FLASH1M_", 8) == 0) {
if(saveType == 0) {
saveType = 2;
flashSize = 0x20000;
}
} else if(memcmp(p, "FLASH", 5) == 0) {
if(saveType == 0) {
saveType = 2;
flashSize = 0x10000;
}
}
} else if (d == 0x52494953) {
if(memcmp(p, "SIIRTC_V", 8) == 0)
rtcFound = true;
}
p++;
}
// if no matches found, then set it to NONE
if(saveType == 0) {
saveType = 5;
}
rtcEnable(rtcFound);
cpuSaveType = saveType;
flashSetSize(flashSize);
}
(This post was last modified: 09-05-2009 04:41 AM by spacy51. Edit Reason: )
|
|
| 09-05-2009 04:36 AM |
|
Thank given by |
|