mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-07-11 09:34:00 +02:00
Compare commits
2 Commits
master
...
small64-test
| Author | SHA1 | Date | |
|---|---|---|---|
| f6b41187cc | |||
| 5696153e34 |
+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;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#else // Unix
|
||||
#include <arpa/inet.h>
|
||||
#endif // _WIN32
|
||||
#include <cstring>
|
||||
|
||||
#define CORE_INTERNAL
|
||||
#include "ConvertStringEncoding.hpp"
|
||||
@@ -168,13 +169,19 @@ CORE_EXPORT bool CoreGetCurrentRomHeader(CoreRomHeader& header)
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("header name len: %i\n", strlen((char*)m64p_header.Name));
|
||||
|
||||
header.CRC1 = ntohl(m64p_header.CRC1);
|
||||
header.CRC2 = ntohl(m64p_header.CRC2);
|
||||
header.CountryCode = m64p_header.Country_code;
|
||||
header.Name = CoreConvertStringEncoding(std::string(reinterpret_cast<char*>(m64p_header.Name), 20), CoreStringEncoding::Shift_JIS);
|
||||
header.Name = CoreConvertStringEncoding(std::string(reinterpret_cast<char*>(m64p_header.Name),
|
||||
std::min(std::strlen(reinterpret_cast<char*>(m64p_header.Name)), static_cast<size_t>(20))),
|
||||
CoreStringEncoding::Shift_JIS);
|
||||
header.GameID = get_gameid_from_header(m64p_header);
|
||||
header.Region = get_region_from_countrycode(static_cast<char>(header.CountryCode));
|
||||
header.SystemType = get_systemtype_from_countrycode(header.CountryCode);
|
||||
|
||||
printf("header name len after: %i\n", header.Name.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user