mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-03-04 17:39:53 +00:00
Serial lookup for psx scanning
This commit is contained in:
parent
21ab9bbeee
commit
0e7018c27d
@ -44,7 +44,7 @@ enum database_type
|
||||
DATABASE_TYPE_NONE = 0,
|
||||
DATABASE_TYPE_ITERATE,
|
||||
DATABASE_TYPE_ITERATE_ZIP,
|
||||
DATABASE_TYPE_ITERATE_CUE,
|
||||
DATABASE_TYPE_SERIAL_LOOKUP,
|
||||
DATABASE_TYPE_CRC_LOOKUP
|
||||
};
|
||||
|
||||
|
@ -47,7 +47,7 @@ typedef struct database_state_handle
|
||||
uint32_t crc;
|
||||
uint8_t *buf;
|
||||
char zip_name[PATH_MAX_LENGTH];
|
||||
char *ps1_id;
|
||||
char serial[4096];
|
||||
} database_state_handle_t;
|
||||
|
||||
typedef struct db_handle
|
||||
@ -121,6 +121,38 @@ static int database_info_iterate_start
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cue_get_serial(database_state_handle_t *db_state,
|
||||
database_info_handle_t *db, const char *name, char* serial)
|
||||
{
|
||||
int rv;
|
||||
char track_path[PATH_MAX_LENGTH];
|
||||
int32_t offset = 0;
|
||||
const char* system_name = NULL;
|
||||
|
||||
rv = find_first_data_track(name, &offset, track_path, PATH_MAX_LENGTH);
|
||||
if (rv < 0)
|
||||
{
|
||||
RARCH_LOG("Could not find valid data track: %s\n", strerror(-rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
RARCH_LOG("Reading 1st data track...\n");
|
||||
|
||||
if ((rv = detect_system(track_path, offset, &system_name)) < 0)
|
||||
return rv;
|
||||
|
||||
RARCH_LOG("Detected %s media\n", system_name);
|
||||
|
||||
if (strcmp(system_name, "ps1") == 0)
|
||||
{
|
||||
if (detect_ps1_game(track_path, serial) == 0)
|
||||
return 0;
|
||||
RARCH_LOG("Found disk label '%s'\n", serial);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int database_info_iterate_playlist(
|
||||
database_state_handle_t *db_state,
|
||||
database_info_handle_t *db, const char *name)
|
||||
@ -144,7 +176,8 @@ static int database_info_iterate_playlist(
|
||||
return 1;
|
||||
#endif
|
||||
case HASH_EXTENSION_CUE:
|
||||
db->type = DATABASE_TYPE_ITERATE_CUE;
|
||||
cue_get_serial(db_state, db, name, db_state->serial);
|
||||
db->type = DATABASE_TYPE_SERIAL_LOOKUP;
|
||||
return 1;
|
||||
default:
|
||||
{
|
||||
@ -342,37 +375,50 @@ static int database_info_iterate_playlist_zip(
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int database_info_iterate_playlist_cue(
|
||||
static int database_info_iterate_serial_lookup(
|
||||
database_state_handle_t *db_state,
|
||||
database_info_handle_t *db, const char *name)
|
||||
{
|
||||
int rv;
|
||||
char track_path[PATH_MAX_LENGTH];
|
||||
int32_t offset = 0;
|
||||
const char* system_name = NULL;
|
||||
char game_id[4096];
|
||||
if (!db_state->list || (unsigned)db_state->list_index == (unsigned)db_state->list->size)
|
||||
return database_info_list_iterate_end_no_match(db_state);
|
||||
|
||||
rv = find_first_data_track(name, &offset, track_path, PATH_MAX_LENGTH);
|
||||
if (rv < 0)
|
||||
if (db_state->entry_index == 0)
|
||||
{
|
||||
RARCH_LOG("Could not find valid data track: %s\n", strerror(-rv));
|
||||
return rv;
|
||||
char query[50] = {0};
|
||||
snprintf(query, sizeof(query), "{'serial': '%s'}", db_state->serial);
|
||||
|
||||
database_info_list_iterate_new(db_state, query);
|
||||
}
|
||||
|
||||
RARCH_LOG("Reading 1st data track...\n");
|
||||
|
||||
if ((rv = detect_system(track_path, offset, &system_name)) < 0)
|
||||
return rv;
|
||||
|
||||
RARCH_LOG("Detected %s media\n", system_name);
|
||||
|
||||
if (strcmp(system_name, "ps1") == 0)
|
||||
if (db_state->info)
|
||||
{
|
||||
if (detect_ps1_game(track_path, game_id) == 0)
|
||||
return 0;
|
||||
RARCH_LOG("Found disk label '%s'\n", game_id);
|
||||
database_info_t *db_info_entry = &db_state->info->list[db_state->entry_index];
|
||||
|
||||
if (db_info_entry && db_info_entry->serial)
|
||||
{
|
||||
#if 1
|
||||
RARCH_LOG("serial: %s , entry serial: %s (%s).\n",
|
||||
db_state->serial, db_info_entry->serial, db_info_entry->name);
|
||||
#endif
|
||||
if (db_state->serial == db_info_entry->serial)
|
||||
database_info_list_iterate_found_match(db_state, db, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
db_state->entry_index++;
|
||||
|
||||
if (db_state->entry_index >= db_state->info->count)
|
||||
return database_info_list_iterate_next(db_state);
|
||||
|
||||
if (db_state->list_index < db_state->list->size)
|
||||
{
|
||||
/* Didn't reach the end of the database list yet,
|
||||
* continue iterating. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (db_state->info)
|
||||
database_info_list_free(db_state->info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -394,8 +440,8 @@ static int database_info_iterate(database_state_handle_t *db_state, database_inf
|
||||
return database_info_iterate_playlist(db_state, db, name);
|
||||
case DATABASE_TYPE_ITERATE_ZIP:
|
||||
return database_info_iterate_playlist_zip(db_state, db, name);
|
||||
case DATABASE_TYPE_ITERATE_CUE:
|
||||
return database_info_iterate_playlist_cue(db_state, db, name);
|
||||
case DATABASE_TYPE_SERIAL_LOOKUP:
|
||||
return database_info_iterate_serial_lookup(db_state, db, name);
|
||||
case DATABASE_TYPE_CRC_LOOKUP:
|
||||
return database_info_iterate_crc_lookup(db_state, db, NULL);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user