- fix ROM serial info for DSi Enhanced ROMs;
- add some new country codes;
This commit is contained in:
mtabachenko 2013-10-28 07:53:17 +00:00
parent b782e366e2
commit cc923dc444
3 changed files with 41 additions and 26 deletions

View File

@ -351,19 +351,22 @@ const RomBanner& GameInfo::getRomBanner()
void GameInfo::populate()
{
const char *regions[] = { "JPFSEODIRKHX",
"JPN",
"EUR",
"FRA",
"ESP",
"USA",
"USA",
"NOE",
"ITA",
"RUS",
"KOR",
"HOL",
"EUU",
const char *regions[] = { "JPFSEODIRKHXWVU",
"JPN", // J
"EUR", // P
"FRA", // F
"ESP", // S
"USA", // E
"INT", // O
"NOE", // D
"ITA", // I
"RUS", // R
"KOR", // K
"HOL", // H
"EUU", // X
"EUU", // V
"EUU", // W
"AUS", // U
};
@ -404,11 +407,16 @@ void GameInfo::populate()
}
else
{
strcpy(ROMserial,"NTR- -");
if (isDSiEnhanced())
strcpy(ROMserial,"TWL- -");
else
strcpy(ROMserial,"NTR- -");
memcpy(ROMserial+4, header.gameCode, 4);
u32 regions_num = ARRAY_SIZE(regions);
u32 region = (u32)(std::max<s32>(strchr(regions[0],header.gameCode[3]) - regions[0] + 1, 0));
if (region > 0 && region < 12)
if (region < regions_num)
strcat(ROMserial, regions[region]);
else
strcat(ROMserial, "Unknown");
@ -645,8 +653,9 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi
if (advsc.checkDB(buf, gameInfo.crc))
{
u8 sv = advsc.getSaveType();
printf("Found in game database by %s:\n",advsc.getIdMethod());
printf("\t* ROM save type: ");
printf("Found in game database by %s:\n", advsc.getIdMethod());
printf("\t* ROM serial:\t\t%s\n", advsc.getSerial());
printf("\t* ROM save type:\t");
if (sv == 0xFF)
printf("Unknown");
else
@ -658,7 +667,7 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi
if (CommonSettings.autodetectBackupMethod == 1)
backup_setManualBackupType(sv + 1);
}
printf("\n\t* ROM crc: %08X\n", advsc.getCRC32());
printf("\n\t* ROM crc:\t\t%08X\n", advsc.getCRC32());
}
printf("\n");

View File

@ -31,7 +31,7 @@ ADVANsCEne advsc;
#define _ADVANsCEne_BASE_VERSION_MINOR 0
#define _ADVANsCEne_BASE_NAME "ADVANsCEne Nintendo DS Collection"
u8 ADVANsCEne::checkDB(const char *serial, u32 crc)
u8 ADVANsCEne::checkDB(const char *ROMserial, u32 crc)
{
loaded = false;
FILE *fp = fopen(database_path.c_str(), "rb");
@ -58,7 +58,7 @@ u8 ADVANsCEne::checkDB(const char *serial, u32 crc)
{
if (fread(buf, 1, 21, fp) != 21) break;
bool serialFound = (memcmp(&buf[4], serial, 4) == 0);
bool serialFound = (memcmp(&buf[4], ROMserial, 4) == 0);
u32 dbcrc = LE_TO_LOCAL_32(*(u32*)(buf+8));
bool crcFound = (crc == dbcrc);
@ -67,7 +67,8 @@ u8 ADVANsCEne::checkDB(const char *serial, u32 crc)
foundAsCrc = crcFound;
foundAsSerial = serialFound;
memcpy(&crc32, &buf[8], 4);
//printf("%s founded: crc32=%04X, save type %02X\n", serial, crc32, buf[12]);
memcpy(&serial[0], &buf[4], 4);
//printf("%s founded: crc32=%04X, save type %02X\n", ROMserial, crc32, buf[12]);
saveType = buf[12];
fclose(fp);
loaded = true;

View File

@ -22,11 +22,13 @@ class ADVANsCEne
{
private:
std::string database_path; // DeSmuME save types
u8 versionBase[2];
char version[4];
time_t createTime;
u8 saveType;
u32 crc32;
char serial[6];
char version[4];
u8 versionBase[2];
u8 saveType;
bool loaded;
bool foundAsCrc, foundAsSerial;
@ -45,16 +47,19 @@ public:
{
memset(versionBase, 0, sizeof(versionBase));
memset(version, 0, sizeof(version));
memset(serial, 0, sizeof(serial));
}
void setDatabase(const char *path) { loaded = false; database_path = path; }
u32 convertDB(const char *in_filaname);
u8 checkDB(const char *serial, u32 crc);
u8 checkDB(const char *ROMserial, u32 crc);
u32 getSaveType() { return saveType; }
u32 getCRC32() { return crc32; }
char *getSerial() { return serial; }
bool isLoaded() { return loaded; }
const char* getIdMethod() {
if(foundAsCrc) return "CRC";
if(foundAsSerial && foundAsCrc) return "Serial/CRC";
if(foundAsSerial) return "Serial";
if(foundAsCrc) return "CRC";
return "";
}
std::string lastImportErrorMessage;