Refactor cheevos_is_nes_game

This commit is contained in:
twinaphex 2017-05-06 18:47:16 +02:00
parent 637e8d76ab
commit 03db246f88
1 changed files with 15 additions and 8 deletions

View File

@ -2848,7 +2848,6 @@ static unsigned cheevos_is_nes_game(
struct nes_header *header,
size_t *bytes, size_t *offset)
{
size_t rom_size = 256;
int mapper_no = 0;
bool round = false;
@ -2858,9 +2857,6 @@ static unsigned cheevos_is_nes_game(
|| header->id[3] != 0x1a)
return false;
if (header->rom_size)
rom_size = next_pow2(header->rom_size);
/* from FCEU core - compute size using the cart mapper */
mapper_no = (header->rom_type >> 4) | (header->rom_type2 & 0xF0);
@ -2870,7 +2866,18 @@ static unsigned cheevos_is_nes_game(
* so instead if not to power of 2, we just use head.ROM_size when
* we use FCEU_read. */
round = mapper_no != 53 && mapper_no != 198 && mapper_no != 228;
*bytes = (round) ? rom_size : header->rom_size;
*bytes = header->rom_size;
if (round)
{
size_t rom_size = 256;
if (header->rom_size)
rom_size = next_pow2(header->rom_size);
*bytes = rom_size;
}
/* from FCEU core - check if Trainer included in ROM data */
*offset = sizeof(struct nes_header) +