slinga
Established Member
I would appreciate some feedback on the API for libslinga before I get too far along.
libslinga: Saturn LIbrary for Navigating Gaming Achievements
libslinga is a Sega Saturn library for working with save game files. The goals are:
- work on real hardware
- support as many backup devices as possible (internal memory, cartridge, floppy, ODEs, etc)
- provide a shim layer for replacing Sega's BUP library
- support Cafe-Alpha's .BUP file format by default and seamlessly to the user. Have a flag to allow for skipping the BUP file format
- MIT license for easy integration with Jo Engine, YAUL, and/or any other Saturn frameworks. ODE menus can also easily use this library
For the shim layer I'm envisioning replacing the BUP library pointer at 0x06000354 with the shim. This would require an AR Cheat Code functionality. Once shimmed:
- Cartridge support could be replaced seamlessly with floppy or ODE support
- No limit to cartridge storage space. The support sizes of cartridges are stored in the BUP library. Replacing BUP lib means we can do whatever want.
- Development of Pseudo Saturn Kai or similar cart that can support both ram expansion and direct save. Honestly not sure if this is already a thing.
Here's my api so far:
libslinga: Saturn LIbrary for Navigating Gaming Achievements
libslinga is a Sega Saturn library for working with save game files. The goals are:
- work on real hardware
- support as many backup devices as possible (internal memory, cartridge, floppy, ODEs, etc)
- provide a shim layer for replacing Sega's BUP library
- support Cafe-Alpha's .BUP file format by default and seamlessly to the user. Have a flag to allow for skipping the BUP file format
- MIT license for easy integration with Jo Engine, YAUL, and/or any other Saturn frameworks. ODE menus can also easily use this library
For the shim layer I'm envisioning replacing the BUP library pointer at 0x06000354 with the shim. This would require an AR Cheat Code functionality. Once shimmed:
- Cartridge support could be replaced seamlessly with floppy or ODE support
- No limit to cartridge storage space. The support sizes of cartridges are stored in the BUP library. Replacing BUP lib means we can do whatever want.
- Development of Pseudo Saturn Kai or similar cart that can support both ram expansion and direct save. Honestly not sure if this is already a thing.
Here's my api so far:
C:
#pragma once
#define TRUE 1
#define FALSE 0
#define MAX_SAVE_SIZE (256 * 1024) // according to Cafe-Alpha this is the maximum size supported by the BIOS
#define MAX_SAVE_NAME 12 // save name as seen in the BIOS
#define MAX_SAVE_COMMENT 11 // save comment as seen in the BIOS
#define MAX_FILENAME 32 // filename as stored on the device. Not the same as the SAVE_NAME on certain devices
#define MAX_SAVES 255
// all devices should standardize on this directory
// for storing saves
#define SAVES_DIRECTORY "SATSAVES"
// backup mediums supported by SLiNGA
typedef enum
{
INTERNAL = 0, // on-board sega saturn memory
CARTRIDGE = 1,
SERIAL = 2,
ACTION_REPLAY = 3,
// ODEs?
// CD?
MAX_MEDIUM_DEVICE,
} BACKUP_MEDIUM_TYPE;
typedef enum
{
SLINGA_SUCCESS = 0,
SLINGA_NOT_INITIALIZED = 1,
SLINGA_INVALID_BACKUP_MEDIUM_TYPE = 2,
SLINGA_BUFFER_TOO_SMALL = 3,
SLINGA_DEVICE_NOT_PRESENT = 4,
SLINGA_NOT_FORMATTED = 5,
} SLINGA_ERROR;
// meta data related to save
typedef struct _SAVE_METADATA {
char filename[MAX_FILENAME]; // filename on the medium. Will have .BUP extension on CD FS and ODEs.
char name[MAX_SAVE_NAME]; // save name as seen in the BIOS
char comment[MAX_SAVE_COMMENT]; // save comment as seen in the BIOS
unsigned char language; // language of the save
unsigned int date; // save modified time in number of minutes since Jan 1, 1980
unsigned int data_size; // size of the save data in bytes
unsigned short block_size; // number of blocks used by the save
} SAVE_METADATA, *PSAVE_METADATA;
// total and available size of the backup medium
typedef struct _BACKUP_STAT
{
unsigned int total_size_bytes;
unsigned int total_blocks;
unsigned int block_size;
unsigned int free_size_bytes;
unsigned int free_blocks;
unsigned int max_saves_possible; // maximum
} BACKUP_STAT, *PBACKUP_STAT;
// libslinga API
SLINGA_ERROR Slinga_Init(void);
SLINGA_ERROR Slinga_IsPresent(BACKUP_MEDIUM_TYPE type);
SLINGA_ERROR Slinga_IsReadable(BACKUP_MEDIUM_TYPE type);
SLINGA_ERROR Slinga_IsWriteable(BACKUP_MEDIUM_TYPE type);
SLINGA_ERROR Slinga_Stat(BACKUP_MEDIUM_TYPE type, PBACKUP_STAT stat);
SLINGA_ERROR Slinga_List(BACKUP_MEDIUM_TYPE type, int use_bup_format, PSAVE_METADATA saves, unsigned int num_saves, unsigned int* saves_found);
SLINGA_ERROR Slinga_Read(BACKUP_MEDIUM_TYPE type, int use_bup_format, char* filename, unsigned char* buffer, unsigned int size, unsigned int* bytes_read);
SLINGA_ERROR Slinga_Write(BACKUP_MEDIUM_TYPE type, int use_bup_format, char* filename, unsigned char* buffer, unsigned int size);
SLINGA_ERROR Slinga_Delete(BACKUP_MEDIUM_TYPE type, char* filename);
SLINGA_ERROR Slinga_Format(BACKUP_MEDIUM_TYPE type);
// need to implment: GetDate(), SetDate() to match BUP library