#include "../libpcsxcore/cdrom.h"
#include "../libpcsxcore/cdriso.h"
#include "../libpcsxcore/cheat.h"
+#include "../libpcsxcore/ppf.h"
#include "../libpcsxcore/new_dynarec/new_dynarec.h"
#include "../plugins/dfsound/spu_config.h"
#include "psemu_plugin_defs.h"
#ifdef HAVE_CHD
"chd",
#endif
- "bz", "znx", "pbp", "cbn", NULL
+ "bz", "znx", "pbp", "cbn", "ppf", NULL
};
// rrrr rggg gggb bbbb
static int run_cd_image(const char *fname)
{
int autoload_state = g_autostateld_opt;
+ size_t fname_len = strlen(fname);
+ const char *ppfname = NULL;
+ char fname2[256];
+
+ // simle ppf handling, like game.chd.ppf
+ if (4 < fname_len && fname_len < sizeof(fname2)
+ && strcasecmp(fname + fname_len - 4, ".ppf") == 0) {
+ memcpy(fname2, fname, fname_len - 4);
+ fname2[fname_len - 4] = 0;
+ ppfname = fname;
+ fname = fname2;
+ }
ready_to_go = 0;
reload_plugins(fname);
menu_update_msg("unsupported/invalid CD image");
return -1;
}
+ if (ppfname)
+ BuildPPFCache(ppfname);
SysReset();
if (autoload_state) {
unsigned int newest = 0;
- int time, slot, newest_slot = -1;
+ int time = 0, slot, newest_slot = -1;
for (slot = 0; slot < 10; slot++) {
if (emu_check_save_file(slot, &time)) {
}
}
-void BuildPPFCache() {
+void BuildPPFCache(const char *fname) {
FILE *ppffile;
char buffer[12];
char method, undo = 0, blockcheck = 0;
if (CdromId[0] == '\0') return;
- // Generate filename in the format of SLUS_123.45
- buffer[0] = toupper(CdromId[0]);
- buffer[1] = toupper(CdromId[1]);
- buffer[2] = toupper(CdromId[2]);
- buffer[3] = toupper(CdromId[3]);
- buffer[4] = '_';
- buffer[5] = CdromId[4];
- buffer[6] = CdromId[5];
- buffer[7] = CdromId[6];
- buffer[8] = '.';
- buffer[9] = CdromId[7];
- buffer[10] = CdromId[8];
- buffer[11] = '\0';
-
- sprintf(szPPF, "%s%s", Config.PatchesDir, buffer);
-
- ppffile = fopen(szPPF, "rb");
+ if (!fname) {
+ // Generate filename in the format of SLUS_123.45
+ buffer[0] = toupper(CdromId[0]);
+ buffer[1] = toupper(CdromId[1]);
+ buffer[2] = toupper(CdromId[2]);
+ buffer[3] = toupper(CdromId[3]);
+ buffer[4] = '_';
+ buffer[5] = CdromId[4];
+ buffer[6] = CdromId[5];
+ buffer[7] = CdromId[6];
+ buffer[8] = '.';
+ buffer[9] = CdromId[7];
+ buffer[10] = CdromId[8];
+ buffer[11] = '\0';
+
+ sprintf(szPPF, "%s%s", Config.PatchesDir, buffer);
+ fname = szPPF;
+ }
+ ppffile = fopen(fname, "rb");
if (ppffile == NULL) return;
memset(buffer, 0, 5);
goto fail_io;
if (strcmp(buffer, "PPF") != 0) {
- SysPrintf(_("Invalid PPF patch: %s.\n"), szPPF);
+ SysPrintf(_("Invalid PPF patch: %s.\n"), fname);
fclose(ppffile);
return;
}
FillPPFCache(); // build address array
- SysPrintf(_("Loaded PPF %d.0 patch: %s.\n"), method + 1, szPPF);
+ SysPrintf(_("Loaded PPF %d.0 patch: %s.\n"), method + 1, fname);
+ return;
fail_io:
#ifndef NDEBUG