From: notaz Date: Tue, 25 Mar 2025 23:44:06 +0000 (+0200) Subject: misc: accept savestates with RASTATE header X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d37ac0de60034664546b09f97cc0d131b6508db6;p=pcsx_rearmed.git misc: accept savestates with RASTATE header can load RA .state file in standalone after: rzip x a.state .pcsx/sstates/-.000 --- 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));