- 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() void GameInfo::populate()
{ {
const char *regions[] = { "JPFSEODIRKHX", const char *regions[] = { "JPFSEODIRKHXWVU",
"JPN", "JPN", // J
"EUR", "EUR", // P
"FRA", "FRA", // F
"ESP", "ESP", // S
"USA", "USA", // E
"USA", "INT", // O
"NOE", "NOE", // D
"ITA", "ITA", // I
"RUS", "RUS", // R
"KOR", "KOR", // K
"HOL", "HOL", // H
"EUU", "EUU", // X
"EUU", // V
"EUU", // W
"AUS", // U
}; };
@ -404,11 +407,16 @@ void GameInfo::populate()
} }
else else
{ {
if (isDSiEnhanced())
strcpy(ROMserial,"TWL- -");
else
strcpy(ROMserial,"NTR- -"); strcpy(ROMserial,"NTR- -");
memcpy(ROMserial+4, header.gameCode, 4); 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)); 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]); strcat(ROMserial, regions[region]);
else else
strcat(ROMserial, "Unknown"); strcat(ROMserial, "Unknown");
@ -646,7 +654,8 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi
{ {
u8 sv = advsc.getSaveType(); u8 sv = advsc.getSaveType();
printf("Found in game database by %s:\n", advsc.getIdMethod()); printf("Found in game database by %s:\n", advsc.getIdMethod());
printf("\t* ROM save type: "); printf("\t* ROM serial:\t\t%s\n", advsc.getSerial());
printf("\t* ROM save type:\t");
if (sv == 0xFF) if (sv == 0xFF)
printf("Unknown"); printf("Unknown");
else else
@ -658,7 +667,7 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi
if (CommonSettings.autodetectBackupMethod == 1) if (CommonSettings.autodetectBackupMethod == 1)
backup_setManualBackupType(sv + 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"); printf("\n");

View File

@ -31,7 +31,7 @@ ADVANsCEne advsc;
#define _ADVANsCEne_BASE_VERSION_MINOR 0 #define _ADVANsCEne_BASE_VERSION_MINOR 0
#define _ADVANsCEne_BASE_NAME "ADVANsCEne Nintendo DS Collection" #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; loaded = false;
FILE *fp = fopen(database_path.c_str(), "rb"); 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; 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)); u32 dbcrc = LE_TO_LOCAL_32(*(u32*)(buf+8));
bool crcFound = (crc == dbcrc); bool crcFound = (crc == dbcrc);
@ -67,7 +67,8 @@ u8 ADVANsCEne::checkDB(const char *serial, u32 crc)
foundAsCrc = crcFound; foundAsCrc = crcFound;
foundAsSerial = serialFound; foundAsSerial = serialFound;
memcpy(&crc32, &buf[8], 4); 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]; saveType = buf[12];
fclose(fp); fclose(fp);
loaded = true; loaded = true;

View File

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