mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-24 00:02:43 +02:00
Detect Perfect Dark GBC Rom, emulating Transfer Pak functionality.
This commit is contained in:
5 files changed
+59
No files matched your search
@@ -22,4 +22,6 @@ u8 *romdataSegGetData(const char *segName);
|
|||||||
u8 *romdataSegGetDataEnd(const char *segName);
|
u8 *romdataSegGetDataEnd(const char *segName);
|
||||||
u32 romdataSegGetSize(const char *segName);
|
u32 romdataSegGetSize(const char *segName);
|
||||||
|
|
||||||
|
void gbcRomCheck(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -107,6 +107,7 @@ int main(int argc, const char **argv)
|
|||||||
inputInit();
|
inputInit();
|
||||||
audioInit();
|
audioInit();
|
||||||
romdataInit();
|
romdataInit();
|
||||||
|
gbcRomCheck();
|
||||||
|
|
||||||
gameInit();
|
gameInit();
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "preprocess.h"
|
#include "preprocess.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#ifndef PLATFORM_N64
|
||||||
|
#include "bss.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* asset files and ROM segments can be replaced by optional external files,
|
* asset files and ROM segments can be replaced by optional external files,
|
||||||
@@ -51,6 +54,9 @@
|
|||||||
|
|
||||||
#define ROMDATA_MAX_FILES 2048
|
#define ROMDATA_MAX_FILES 2048
|
||||||
|
|
||||||
|
#define GBC_ROM_NAME "pd.gbc"
|
||||||
|
#define GBC_ROM_SIZE 4194304
|
||||||
|
|
||||||
u8 *g_RomFile;
|
u8 *g_RomFile;
|
||||||
u32 g_RomFileSize;
|
u32 g_RomFileSize;
|
||||||
|
|
||||||
@@ -386,6 +392,45 @@ s32 romdataInit(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gbcRomCheck(void)
|
||||||
|
{
|
||||||
|
u32 gbcRomSize;
|
||||||
|
u8* gbcRomFile = fsFileLoad(GBC_ROM_NAME, &gbcRomSize);
|
||||||
|
|
||||||
|
if (!gbcRomFile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gbcRomSize != GBC_ROM_SIZE) {
|
||||||
|
free(gbcRomFile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ROM title
|
||||||
|
|
||||||
|
if (memcmp(gbcRomFile + 0x134, "PerfDark VPDE", 15) != 0) {
|
||||||
|
free(gbcRomFile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Licensee code
|
||||||
|
|
||||||
|
if (memcmp(gbcRomFile + 0x144, "4Y", 2) != 0) {
|
||||||
|
free(gbcRomFile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Header and global checksums
|
||||||
|
|
||||||
|
if (gbcRomFile[0x14D] != 0xA1 || gbcRomFile[0x14E] != 0xAD || gbcRomFile[0x14F] != 0x0F) {
|
||||||
|
free(gbcRomFile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_validGbcRomFound = true;
|
||||||
|
free(gbcRomFile);
|
||||||
|
}
|
||||||
|
|
||||||
s32 romdataFileGetSize(s32 fileNum)
|
s32 romdataFileGetSize(s32 fileNum)
|
||||||
{
|
{
|
||||||
if (fileNum < 1 || fileNum >= ROMDATA_MAX_FILES) {
|
if (fileNum < 1 || fileNum >= ROMDATA_MAX_FILES) {
|
||||||
|
|||||||
@@ -329,6 +329,10 @@ u8 g_PaksPlugged = 0;
|
|||||||
bool var80075d14 = true;
|
bool var80075d14 = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PLATFORM_N64
|
||||||
|
bool g_validGbcRomFound = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
u32 pakGetBlockSize(s8 device)
|
u32 pakGetBlockSize(s8 device)
|
||||||
{
|
{
|
||||||
return device == SAVEDEVICE_GAMEPAK ? 0x10 : 0x20;
|
return device == SAVEDEVICE_GAMEPAK ? 0x10 : 0x20;
|
||||||
@@ -5982,6 +5986,7 @@ s32 pak0f11e750(s8 device)
|
|||||||
|
|
||||||
bool gbpakIsAnyPerfectDark(void)
|
bool gbpakIsAnyPerfectDark(void)
|
||||||
{
|
{
|
||||||
|
#ifdef PLATFORM_N64
|
||||||
s8 i;
|
s8 i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_PLAYERS; i++) {
|
for (i = 0; i < MAX_PLAYERS; i++) {
|
||||||
@@ -5991,6 +5996,9 @@ bool gbpakIsAnyPerfectDark(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
#else
|
||||||
|
return g_validGbcRomFound;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -293,5 +293,8 @@ extern struct bossfile g_BossFile;
|
|||||||
extern struct chrdata *g_MpBotChrPtrs[MAX_BOTS];
|
extern struct chrdata *g_MpBotChrPtrs[MAX_BOTS];
|
||||||
extern s32 g_JpnMaxCacheItems;
|
extern s32 g_JpnMaxCacheItems;
|
||||||
extern s32 var8009d370jf;
|
extern s32 var8009d370jf;
|
||||||
|
#ifndef PLATFORM_N64
|
||||||
|
extern bool g_validGbcRomFound;
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in new issue
Block a user