aa0180571e
Renames savefile_t to saveslot_t and folds last session's standalone settings.h/.c module back in as savemeta_t, so there's one save system (SAVE.slots[] + SAVE.meta) instead of two parallel ones - while letting each platform pick its own physical format for the two concepts: - Linux now writes human-editable JSON (slot0.json, settings.json, ...) via yyjson's mutable writer API, so players can hand-fix a bad setting. - PSP folds meta into the same sceUtilitySavedata binary payload as its one save slot (SAVE_SLOT_COUNT_MAX=1 there - a future save picker will let players manage multiple named saves via the OS's own browser). - GameCube consolidates the 3 per-slot memory card files and the separate settings file into one combined card file. Also fixes two bugs surfaced while building this: the CRC finalize step seeked to a hardcoded offset (only safe for one section per file, breaks once meta+slots share a buffer), and save.c's async/sync dispatch left an unconditional fallback call that doesn't exist on PSP-only platforms. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
65 lines
1.8 KiB
C
65 lines
1.8 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "error/error.h"
|
|
#include <stddef.h>
|
|
|
|
// Backed by SAVE.platform.dataBuffer (see savepsp.h) rather than owning its
|
|
// own memory - the buffer has to outlive a single saveFileWrite()/Load()
|
|
// call, since the actual save/load dialog it's handed to only completes
|
|
// several frames later.
|
|
typedef struct {
|
|
uint8_t *buffer;
|
|
size_t bufferSize;
|
|
size_t position;
|
|
size_t length;
|
|
} savestreampsp_t;
|
|
|
|
/**
|
|
* Copies len bytes from the buffer at the current position into buf.
|
|
*
|
|
* @param p Active stream.
|
|
* @param buf Destination buffer.
|
|
* @param len Number of bytes to read.
|
|
* @return An error if the read would exceed the populated data length.
|
|
*/
|
|
errorret_t saveStreamReadBytesPSP(
|
|
savestreampsp_t *p, void *buf, const size_t len
|
|
);
|
|
|
|
/**
|
|
* Copies len bytes from buf into the buffer at the current position,
|
|
* growing p->length if this write extends past it.
|
|
*
|
|
* @param p Active stream.
|
|
* @param buf Source buffer.
|
|
* @param len Number of bytes to write.
|
|
* @return An error if the write would exceed bufferSize.
|
|
*/
|
|
errorret_t saveStreamWriteBytesPSP(
|
|
savestreampsp_t *p, const void *buf, const size_t len
|
|
);
|
|
|
|
/**
|
|
* Sets the current read/write position within the buffer.
|
|
*
|
|
* @param p Active stream.
|
|
* @param pos Target byte offset from the start of the buffer.
|
|
* @return An error if pos is out of range.
|
|
*/
|
|
errorret_t saveStreamSeekPSP(savestreampsp_t *p, const size_t pos);
|
|
|
|
/**
|
|
* Gets the current read/write position within the buffer.
|
|
*
|
|
* @param p Active stream.
|
|
* @param out Receives the current position.
|
|
* @return An error - always succeeds, matches saveStreamTellImpl's shape.
|
|
*/
|
|
errorret_t saveStreamTellPSP(savestreampsp_t *p, size_t *out);
|