Add compressed combined save format for PSP and Dolphin

Memory sticks/cards don't suit N+1 separate save files the way Linux's
filesystem does, so add an opt-in SAVE_DEVICE_DATA_RAW mode: settings and
all save slots get serialized to JSON, concatenated, zlib-compressed, and
framed with a magic/version/checksum/generation header, then read/written
as a single blob through one combined platform hook instead of four.

- PSP and Dolphin's SD/NAND backends write via a temp file + atomic rename,
  so a crash mid-write can never leave a half-written save behind.
- GameCube memory cards have no rename or resize primitive, so they
  ping-pong between two fixed files instead, picking whichever is valid and
  has the higher generation counter on load.
- Linux is untouched (still four separate JSON files); saveslot.h/
  savesettings.h drop their now-unnecessary pack(1) now that nothing
  persists them as raw bytes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-17 21:28:56 -05:00
parent 092e259a06
commit 82ae2bce9d
14 changed files with 1125 additions and 17 deletions
+20
View File
@@ -25,6 +25,12 @@
#define saveDeviceCheckAvailabilityPlatform \
saveDeviceDolphinNandCheckAvailability
#define saveDevicePlatformDispose saveDeviceDolphinNandDispose
// ISFS_Rename exists, so NAND uses the same write-temp-then-rename
// pattern as PSP/Linux - see SAVE_DEVICE_DATA_RAW in save/savedevice.h.
#define SAVE_DEVICE_DATA_RAW
#define saveDeviceDataWritePlatform saveDeviceDolphinNandDataWrite
#define saveDeviceDataReadPlatform saveDeviceDolphinNandDataRead
#elif defined(DUSK_WII) && defined(DUSK_SAVE_WII_METHOD_SD)
#include "savedevicedolphinsd.h"
#define SAVE_DEVICE_COUNT 1
@@ -33,6 +39,13 @@
#define saveDeviceCheckAvailabilityPlatform \
saveDeviceDolphinSDCheckAvailability
#define saveDevicePlatformDispose saveDeviceDolphinSDDispose
// libfat gives standard POSIX rename(), so SD uses the same
// write-temp-then-rename pattern as PSP/Linux - see SAVE_DEVICE_DATA_RAW
// in save/savedevice.h.
#define SAVE_DEVICE_DATA_RAW
#define saveDeviceDataWritePlatform saveDeviceDolphinSDDataWrite
#define saveDeviceDataReadPlatform saveDeviceDolphinSDDataRead
#else
#include "savedevicedolphincard.h"
#define SAVE_DEVICE_COUNT 2
@@ -41,4 +54,11 @@
#define saveDeviceCheckAvailabilityPlatform \
saveDeviceDolphinCardCheckAvailability
#define saveDevicePlatformDispose saveDeviceDolphinCardDispose
// No rename or resize primitive on the CARD API, so this ping-pongs
// between two fixed files instead - see SAVE_DEVICE_DOLPHIN_CARD_FILENAME_0
// in savedevicedolphincard.h and SAVE_DEVICE_DATA_RAW in save/savedevice.h.
#define SAVE_DEVICE_DATA_RAW
#define saveDeviceDataWritePlatform saveDeviceDolphinCardDataWrite
#define saveDeviceDataReadPlatform saveDeviceDolphinCardDataRead
#endif