spacy51 3 Posted August 19, 2009 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 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 ); } Share this post Link to post Share on other sites
Squall Leonhart 17 Posted August 20, 2009 would it work as an auto detect? Share this post Link to post Share on other sites
aceloop 0 Posted August 20, 2009 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? Share this post Link to post Share on other sites
Squall Leonhart 17 Posted August 20, 2009 GBA pokemon require a 128K save type DBZ are slightly wierd... they use Fram, but... they aren't normal fram size... Share this post Link to post Share on other sites
Squall Leonhart 17 Posted August 20, 2009 doesn't work on KH-CoM or Iridion II Share this post Link to post Share on other sites
spacy51 3 Posted August 20, 2009 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. Share this post Link to post Share on other sites
Squall Leonhart 17 Posted August 20, 2009 lol, Also does it for Zoids Legacy. and all of them save fine Share this post Link to post Share on other sites
spacy51 3 Posted August 20, 2009 But Iridion really doesn't save, there's even a password system in it. Share this post Link to post Share on other sites
spacy51 3 Posted August 20, 2009 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. Share this post Link to post Share on other sites
spacy51 3 Posted August 21, 2009 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 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. Share this post Link to post Share on other sites
aceloop 0 Posted August 23, 2009 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. \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"?? Share this post Link to post Share on other sites
spacy51 3 Posted August 23, 2009 I am interested if there are mroe games that use strings I do not know of yet. These will get falsely be detected as no backup media present. Share this post Link to post Share on other sites
aceloop 0 Posted August 23, 2009 im not too sure but wouldn't the vba-over.ini floating about the net be a help? wasnt the vba-over.ini file the way of fixing save problems? Share this post Link to post Share on other sites
spacy51 3 Posted August 23, 2009 vba-over.ini is more like a work-around if you ask me. We wouldn#t need that if we had a better auto-detection mechanism. vba-ove.rini might still be useful for homebrew that can not be detected right with this code. Share this post Link to post Share on other sites
Squall Leonhart 17 Posted August 23, 2009 vba-over is for more then save types, its also for bios per rom, rtc, and mirroring to fix nes classics. Share this post Link to post Share on other sites
spacy51 3 Posted September 4, 2009 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. 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); } Share this post Link to post Share on other sites
Squall Leonhart 17 Posted September 4, 2009 It probably corresponded with the enhanced detection function, that apparently didn't work right...... Share this post Link to post Share on other sites
bobthetaru 0 Posted March 8, 2010 i dont know how to add that code to vba, but the list says tactics advance uses 64k flash, i set it to that and it still says error in backup memory when i try to save. I'll try starting a new game.. again.. Otherwise, can anyone help me get my tactics advanced roms to save? Share this post Link to post Share on other sites
spacy51 3 Posted March 9, 2010 Is your save path correct? Try to move your current save file out of it and start VBA-M without a save file. Share this post Link to post Share on other sites