diff --git a/mupen64plus-core/src/api/frontend.c b/mupen64plus-core/src/api/frontend.c index 6a6fcc9..7e8a36c 100644 --- a/mupen64plus-core/src/api/frontend.c +++ b/mupen64plus-core/src/api/frontend.c @@ -199,9 +199,9 @@ EXPORT m64p_error CALL CoreDoCommand(m64p_command Command, int ParamInt, void *P case M64CMD_PIF_OPEN: if (g_EmulatorRunning) return M64ERR_INVALID_STATE; - if (ParamPtr == NULL || ParamInt != 2048) + if (ParamPtr == NULL || ParamInt < 1984) return M64ERR_INPUT_ASSERT; - return open_pif((const unsigned char *) ParamPtr, ParamInt); + return open_pif((const unsigned char *) ParamPtr); case M64CMD_ROM_GET_HEADER: if (!l_ROMOpen) return M64ERR_INVALID_STATE; diff --git a/mupen64plus-core/src/main/main.c b/mupen64plus-core/src/main/main.c index fdab9b7..27e4606 100644 --- a/mupen64plus-core/src/main/main.c +++ b/mupen64plus-core/src/main/main.c @@ -1524,10 +1524,10 @@ m64p_error main_run(void) FILE* PifFile = fopen(get_pif_path(ROM_PARAMS.systemtype), "rb"); if (PifFile != NULL) { - unsigned char* pif_buffer = malloc(2048); - size_t file_size = fread(pif_buffer, 1, 2048, PifFile); + unsigned char* pif_buffer = malloc(1984); + fread(pif_buffer, 1, 1984, PifFile); fclose(PifFile); - open_pif(pif_buffer, file_size); + open_pif(pif_buffer); free(pif_buffer); } @@ -1972,10 +1972,10 @@ void main_stop(void) #endif } -m64p_error open_pif(const unsigned char* pifimage, unsigned int size) +m64p_error open_pif(const unsigned char* pifimage) { - md5_byte_t pif_ntsc_md5[] = {0x49, 0x21, 0xD5, 0xF2, 0x16, 0x5D, 0xEE, 0x6E, 0x24, 0x96, 0xF4, 0x38, 0x8C, 0x4C, 0x81, 0xDA}; - md5_byte_t pif_pal_md5[] = {0x2B, 0x6E, 0xEC, 0x58, 0x6F, 0xAA, 0x43, 0xF3, 0x46, 0x23, 0x33, 0xB8, 0x44, 0x83, 0x45, 0x54}; + md5_byte_t pif_ntsc_md5[] = {0x5C, 0x12, 0x4E, 0x79, 0x48, 0xAD, 0xA8, 0x5D, 0xA6, 0x03, 0xA5, 0x22, 0x78, 0x29, 0x40, 0xD0}; + md5_byte_t pif_pal_md5[] = {0xD4, 0x23, 0x2D, 0xC9, 0x35, 0xCA, 0xD0, 0x65, 0x0A, 0xC2, 0x66, 0x4D, 0x52, 0x28, 0x1F, 0x3A}; uint32_t *dst32 = mem_base_u32(g_mem_base, MM_PIF_MEM); uint32_t *src32 = (uint32_t*) pifimage; @@ -1983,7 +1983,7 @@ m64p_error open_pif(const unsigned char* pifimage, unsigned int size) md5_byte_t digest[16]; md5_init(&state); - md5_append(&state, (const md5_byte_t*)pifimage, size); + md5_append(&state, (const md5_byte_t*)pifimage, 1984); md5_finish(&state, digest); if (memcmp(digest, pif_ntsc_md5, 16) == 0) @@ -1996,7 +1996,7 @@ m64p_error open_pif(const unsigned char* pifimage, unsigned int size) return M64ERR_INPUT_INVALID; } - for (unsigned int i = 0; i < size; i += 4) + for (unsigned int i = 0; i < 1984; i += 4) *dst32++ = big32(*src32++); g_start_address = UINT32_C(0xbfc00000); diff --git a/mupen64plus-core/src/main/main.h b/mupen64plus-core/src/main/main.h index 482cdd7..9b64eb2 100644 --- a/mupen64plus-core/src/main/main.h +++ b/mupen64plus-core/src/main/main.h @@ -98,7 +98,7 @@ int main_volume_get_muted(void); m64p_error main_reset(int do_hard_reset); -m64p_error open_pif(const unsigned char* pifimage, unsigned int size); +m64p_error open_pif(const unsigned char* pifimage); #endif /* __MAIN_H__ */