commit
a61f4f7f62
|
@ -286,7 +286,7 @@ static int database_cursor_iterate(libretrodb_cursor_t *cur,
|
|||
db_info->size = val->uint_;
|
||||
break;
|
||||
case DB_CURSOR_CHECKSUM_CRC32:
|
||||
db_info->crc32 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len);
|
||||
db_info->crc32 = swap_if_little32(*(uint32_t*)val->binary.buff);
|
||||
break;
|
||||
case DB_CURSOR_CHECKSUM_SHA1:
|
||||
db_info->sha1 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len);
|
||||
|
@ -512,8 +512,6 @@ void database_info_list_free(database_info_list_t *database_info_list)
|
|||
free(info->esrb_rating);
|
||||
if (info->bbfc_rating)
|
||||
free(info->bbfc_rating);
|
||||
if (info->crc32)
|
||||
free(info->crc32);
|
||||
if (info->sha1)
|
||||
free(info->sha1);
|
||||
if (info->md5)
|
||||
|
|
|
@ -75,7 +75,7 @@ typedef struct
|
|||
char *pegi_rating;
|
||||
char *cero_rating;
|
||||
char *enhancement_hw;
|
||||
char *crc32;
|
||||
uint32_t crc32;
|
||||
char *sha1;
|
||||
char *md5;
|
||||
unsigned size;
|
||||
|
|
|
@ -26,17 +26,24 @@
|
|||
#include <retro_inline.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define SWAP16(x) ((uint16_t)( \
|
||||
(((uint16_t)(x) & 0x00ff) << 8) | \
|
||||
#if defined(__llvm__) || (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 403)
|
||||
#define SWAP16 __builtin_bswap16
|
||||
#define SWAP32 __builtin_bswap32
|
||||
#elif if defined(_MSC_VER)
|
||||
#define SWAP16 _byteswap_ushort
|
||||
#define SWAP32 _byteswap_ulong
|
||||
#else
|
||||
#define SWAP16(x) ((uint16_t)( \
|
||||
(((uint16_t)(x) & 0x00ff) << 8) | \
|
||||
(((uint16_t)(x) & 0xff00) >> 8) \
|
||||
))
|
||||
|
||||
#define SWAP32(x) ((uint32_t)( \
|
||||
(((uint32_t)(x) & 0x000000ff) << 24) | \
|
||||
(((uint32_t)(x) & 0x0000ff00) << 8) | \
|
||||
(((uint32_t)(x) & 0x00ff0000) >> 8) | \
|
||||
(((uint32_t)(x) & 0xff000000) >> 24) \
|
||||
))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* is_little_endian:
|
||||
|
@ -48,6 +55,11 @@
|
|||
**/
|
||||
static INLINE uint8_t is_little_endian(void)
|
||||
{
|
||||
#if defined(__x86_64) || defined(__i386) || defined(_M_IX86) || defined(_M_X64)
|
||||
return 1;
|
||||
#elif defined(MSB_FIRST)
|
||||
return 0;
|
||||
#else
|
||||
union
|
||||
{
|
||||
uint16_t x;
|
||||
|
@ -56,25 +68,7 @@ static INLINE uint8_t is_little_endian(void)
|
|||
|
||||
u.x = 1;
|
||||
return u.y[0];
|
||||
}
|
||||
|
||||
static INLINE uint32_t swap_little32(uint32_t val)
|
||||
{
|
||||
return
|
||||
(val >> 24)
|
||||
| ((val >> 8) & 0xFF00)
|
||||
| ((val << 8) & 0xFF0000)
|
||||
| (val << 24);
|
||||
}
|
||||
|
||||
static INLINE uint16_t swap_big16(uint16_t val)
|
||||
{
|
||||
return (val >> 8) | (val << 8);
|
||||
}
|
||||
|
||||
static INLINE uint16_t swap_little16(uint16_t val)
|
||||
{
|
||||
return (val >> 8) | (val << 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,7 +84,7 @@ static INLINE uint32_t swap_if_big32(uint32_t val)
|
|||
{
|
||||
if (is_little_endian())
|
||||
return val;
|
||||
return swap_little32(val);
|
||||
return SWAP32(val);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,7 +99,7 @@ static INLINE uint32_t swap_if_big32(uint32_t val)
|
|||
static INLINE uint32_t swap_if_little32(uint32_t val)
|
||||
{
|
||||
if (is_little_endian())
|
||||
return swap_little32(val);
|
||||
return SWAP32(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -122,7 +116,7 @@ static INLINE uint16_t swap_if_big16(uint16_t val)
|
|||
{
|
||||
if (is_little_endian())
|
||||
return val;
|
||||
return swap_big16(val);
|
||||
return SWAP16(val);
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,7 +132,7 @@ static INLINE uint16_t swap_if_big16(uint16_t val)
|
|||
static INLINE uint16_t swap_if_little16(uint16_t val)
|
||||
{
|
||||
if (is_little_endian())
|
||||
return swap_little16(val);
|
||||
return SWAP16(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -152,7 +146,7 @@ static INLINE uint16_t swap_if_little16(uint16_t val)
|
|||
**/
|
||||
static INLINE void store32be(uint32_t *addr, uint32_t data)
|
||||
{
|
||||
*addr = is_little_endian() ? SWAP32(data) : data;
|
||||
*addr = swap_if_little32(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,7 +159,7 @@ static INLINE void store32be(uint32_t *addr, uint32_t data)
|
|||
**/
|
||||
static INLINE uint32_t load32be(const uint32_t *addr)
|
||||
{
|
||||
return is_little_endian() ? SWAP32(*addr) : *addr;
|
||||
return swap_if_little32(*addr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -945,11 +945,14 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
|
|||
for (i = 0; i < db_info->count; i++)
|
||||
{
|
||||
char tmp[PATH_MAX_LENGTH];
|
||||
char crc_str[20] = {0};
|
||||
database_info_t *db_info_entry = &db_info->list[i];
|
||||
|
||||
if (!db_info_entry)
|
||||
continue;
|
||||
|
||||
snprintf(crc_str, sizeof(crc_str), "%08X", db_info_entry->crc32);
|
||||
|
||||
if (playlist)
|
||||
{
|
||||
for (j = 0; j < playlist->size; j++)
|
||||
|
@ -973,7 +976,7 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
|
|||
switch (hash_value)
|
||||
{
|
||||
case MENU_VALUE_CRC:
|
||||
if (!strcmp(db_info_entry->crc32, elem0))
|
||||
if (!strcmp(crc_str, elem0))
|
||||
match_found = true;
|
||||
break;
|
||||
case MENU_VALUE_SHA1:
|
||||
|
@ -1147,7 +1150,7 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
|
|||
if (db_info_entry->crc32)
|
||||
{
|
||||
if (create_string_list_rdb_entry_string("CRC32 Checksum",
|
||||
"rdb_entry_crc32", db_info_entry->crc32,
|
||||
"rdb_entry_crc32", crc_str,
|
||||
info->path, info->list) == -1)
|
||||
goto error;
|
||||
}
|
||||
|
@ -1165,7 +1168,6 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
|
|||
info->path, info->list) == -1)
|
||||
goto error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (db_info->count < 1)
|
||||
|
|
|
@ -177,7 +177,7 @@ static int database_info_list_iterate_found_match(
|
|||
playlist = content_playlist_init(db_playlist_path, 1000);
|
||||
|
||||
|
||||
snprintf(db_crc, sizeof(db_crc), "%s|crc", db_info_entry->crc32);
|
||||
snprintf(db_crc, sizeof(db_crc), "%08X|crc", db_info_entry->crc32);
|
||||
|
||||
strlcpy(entry_path_str, entry_path, sizeof(entry_path_str));
|
||||
if (zip_name && zip_name[0] != '\0')
|
||||
|
@ -236,18 +236,13 @@ static int database_info_iterate_crc_lookup(
|
|||
{
|
||||
database_info_t *db_info_entry = &db_state->info->list[db_state->entry_index];
|
||||
|
||||
if (db_info_entry && db_info_entry->crc32 && db_info_entry->crc32[0] != '\0')
|
||||
if (db_info_entry && db_info_entry->crc32)
|
||||
{
|
||||
char entry_state_crc[PATH_MAX_LENGTH];
|
||||
/* Check if the CRC matches with the current entry. */
|
||||
snprintf(entry_state_crc, sizeof(entry_state_crc), "%x", db_state->crc);
|
||||
|
||||
#if 0
|
||||
RARCH_LOG("CRC32: 0x%s , entry CRC32: 0x%s (%s).\n",
|
||||
entry_state_crc, db_info_entry->crc32, db_info_entry->name);
|
||||
RARCH_LOG("CRC32: 0x%08X , entry CRC32: 0x%08X (%s).\n",
|
||||
db_state->crc, db_info_entry->crc32, db_info_entry->name);
|
||||
#endif
|
||||
|
||||
if (strcasestr(entry_state_crc, db_info_entry->crc32))
|
||||
if (db_state->crc == db_info_entry->crc32)
|
||||
database_info_list_iterate_found_match(db_state, db, zip_entry);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue