MusyX 1 compatibility fixes, Rogue Squadron N64 decoding confirmed

This commit is contained in:
Jack Andersen
2016-05-28 18:31:58 -10:00
parent 3ba25fd06a
commit 80cc9f7c94
9 changed files with 121 additions and 156 deletions

View File

@@ -518,19 +518,16 @@ static bool ValidateRS1N64(FILE* fp)
if (endPos > 32 * 1024 * 1024)
return false; /* N64 ROM definitely won't exceed 32MB */
FSeek(fp, 59, SEEK_SET);
uint32_t gameId;
fread(&gameId, 1, 4, fp);
if (gameId != 0x4e525345 && gameId != 0x4553524e)
return false; /* GameId not 'NRSE' */
FSeek(fp, 0, SEEK_SET);
std::unique_ptr<uint8_t[]> data(new uint8_t[endPos]);
fread(data.get(), 1, endPos, fp);
if ((data[0] & 0x80) != 0x80 && (data[3] & 0x80) == 0x80)
SwapN64Rom(data.get(), endPos);
const uint32_t* gameId = reinterpret_cast<const uint32_t*>(&data[59]);
if (*gameId != 0x4e525345 && *gameId != 0x4553524e)
return false; /* GameId not 'NRSE' */
const uint8_t* dataSeg = reinterpret_cast<const uint8_t*>(memmem(data.get(), endPos,
"dbg_data\0\0\0\0\0\0\0\0", 16));
if (dataSeg)