From d37ac0de60034664546b09f97cc0d131b6508db6 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 26 Mar 2025 01:44:06 +0200 Subject: [PATCH] misc: accept savestates with RASTATE header can load RA .state file in standalone after: rzip x a.state .pcsx/sstates/-.000 --- libpcsxcore/misc.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 172fdd2c..41999a5d 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -775,12 +775,25 @@ int LoadState(const char *file) { f = SaveFuncs.open(file, "rb"); if (f == NULL) return -1; - SaveFuncs.read(f, header, sizeof(header)); + if (!file) + file = "(stream)"; + memset(header, 0, sizeof(header)); + SaveFuncs.read(f, header, 16); + if (strncmp("RASTATE", header, 7) == 0) { + // looks like RA header, normal savestate should follow + SysPrintf("%s: trying to skip RASTATE header\n", file); + SaveFuncs.read(f, header, 16); + } + SaveFuncs.read(f, header + 16, 16); SaveFuncs.read(f, &version, sizeof(u32)); SaveFuncs.read(f, &hle, sizeof(boolean)); - if (strncmp("STv4 PCSX", header, 9) != 0 || version != SaveVersion) { - SysPrintf("incompatible savestate version %x\n", version); + if (strncmp("STv4 PCSX", header, 9) != 0) { + SysPrintf("%s: is not a savestate?\n", file); + goto cleanup; + } + if (version != SaveVersion) { + SysPrintf("%s: incompatible savestate version %x\n", file, version); goto cleanup; } oldhle = Config.HLE; @@ -866,7 +879,11 @@ int CheckState(const char *file) { f = SaveFuncs.open(file, "rb"); if (f == NULL) return -1; - SaveFuncs.read(f, header, sizeof(header)); + memset(header, 0, sizeof(header)); + SaveFuncs.read(f, header, 16); + if (strncmp("RASTATE", header, 7) == 0) + SaveFuncs.read(f, header, 16); + SaveFuncs.read(f, header + 16, 16); SaveFuncs.read(f, &version, sizeof(u32)); SaveFuncs.read(f, &hle, sizeof(boolean)); -- 2.39.5