mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-07-11 01:24:01 +02:00
3rdParty: add small64 signature to open_rom()
This commit is contained in:
+6
-1
@@ -76,12 +76,16 @@ static const uint8_t Z64_SIGNATURE[4] = { 0x80, 0x37, 0x12, 0x40 };
|
||||
static const uint8_t V64_SIGNATURE[4] = { 0x37, 0x80, 0x40, 0x12 };
|
||||
static const uint8_t N64_SIGNATURE[4] = { 0x40, 0x12, 0x37, 0x80 };
|
||||
|
||||
static const uint8_t ALT_Z64_SIGNATURE[4] = { 0x31, 0x37, 0x12, 0x40 };
|
||||
|
||||
/* Tests if a file is a valid N64 rom by checking the first 4 bytes and size */
|
||||
static int is_valid_rom(const unsigned char *buffer, unsigned int size)
|
||||
{
|
||||
printf("rom signature: 0x%02X, 0x%02X, 0x%02X, 0x%02X\n", buffer[0], buffer[1], buffer[2], buffer[3]);
|
||||
if ((memcmp(buffer, Z64_SIGNATURE, sizeof(Z64_SIGNATURE)) == 0)
|
||||
|| (memcmp(buffer, V64_SIGNATURE, sizeof(V64_SIGNATURE)) == 0 && size % 2 == 0)
|
||||
|| (memcmp(buffer, N64_SIGNATURE, sizeof(N64_SIGNATURE)) == 0 && size % 4 == 0))
|
||||
|| (memcmp(buffer, N64_SIGNATURE, sizeof(N64_SIGNATURE)) == 0 && size % 4 == 0)
|
||||
|| (memcmp(buffer, ALT_Z64_SIGNATURE, sizeof(ALT_Z64_SIGNATURE)) == 0))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
@@ -149,6 +153,7 @@ m64p_error open_rom(const unsigned char* romimage, unsigned int size)
|
||||
if (romimage == NULL || !is_valid_rom(romimage, size))
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "open_rom(): not a valid ROM image");
|
||||
printf("fail\n");
|
||||
return M64ERR_INPUT_INVALID;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user