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
+15
View File
@@ -14,3 +14,18 @@
#define saveDevicePlatformUpdate saveDevicePSPUpdate
#define saveDeviceCheckAvailabilityPlatform saveDevicePSPCheckAvailability
#define saveDevicePlatformDispose saveDevicePSPDispose
// The memory stick has no directory-listing UI convention to preserve like
// GameCube/Wii memory cards do, so settings + all save slots are combined
// into one compressed blob rather than kept as separate files - see
// SAVE_DEVICE_DATA_RAW in save/savedevice.h.
#define SAVE_DEVICE_DATA_RAW
#define saveDeviceDataWritePlatform saveDevicePSPDataWrite
#define saveDeviceDataReadPlatform saveDevicePSPDataRead
#ifndef SAVE_DEVICE_PSP_DIRECTORY_NAME
#define SAVE_DEVICE_PSP_DIRECTORY_NAME "ms0:/DUSK"
#endif
#ifndef SAVE_DEVICE_PSP_DATA_FILENAME
#define SAVE_DEVICE_PSP_DATA_FILENAME "save.dat"
#endif