mirror of https://github.com/snes9xgit/snes9x.git
Add subsystem code
This commit is contained in:
parent
fbdb855bef
commit
c4ece5ced8
|
@ -23,6 +23,21 @@
|
|||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
// Special memory types.
|
||||
#define RETRO_MEMORY_SNES_BSX_RAM ((1 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_BSX_PRAM ((2 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_SUFAMI_TURBO_A_RAM ((3 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_SUFAMI_TURBO_B_RAM ((4 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_GAME_BOY_RAM ((5 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_GAME_BOY_RTC ((6 << 8) | RETRO_MEMORY_RTC)
|
||||
|
||||
// Special game types passed into retro_load_game_special().
|
||||
// Only used when multiple ROMs are required.
|
||||
#define RETRO_GAME_TYPE_BSX 0x101
|
||||
#define RETRO_GAME_TYPE_BSX_SLOTTED 0x102
|
||||
#define RETRO_GAME_TYPE_SUFAMI_TURBO 0x103
|
||||
#define RETRO_GAME_TYPE_SUPER_GAME_BOY 0x104
|
||||
|
||||
static retro_log_printf_t log_cb = NULL;
|
||||
static retro_video_refresh_t s9x_video_cb = NULL;
|
||||
static retro_audio_sample_t s9x_audio_cb = NULL;
|
||||
|
@ -83,7 +98,40 @@ void retro_set_environment(retro_environment_t cb)
|
|||
{ "s9x_sndchan_8", "Enable sound channel 8; Yes|No" },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
|
||||
static const retro_subsystem_memory_info sufami_a_memory[] = {
|
||||
{ "srm", RETRO_MEMORY_SNES_SUFAMI_TURBO_A_RAM },
|
||||
};
|
||||
|
||||
static const retro_subsystem_memory_info sufami_b_memory[] = {
|
||||
{ "srm", RETRO_MEMORY_SNES_SUFAMI_TURBO_B_RAM },
|
||||
};
|
||||
|
||||
static const struct retro_subsystem_rom_info sufami_roms[] = {
|
||||
{ "Sufami A", "sfc|smc", false, false, false, sufami_a_memory, 1 },
|
||||
{ "Sufami B", "sfc|smc", false, false, false, sufami_b_memory, 1 },
|
||||
{ "Sufami BIOS", "sfc|smc", false, false, true, NULL, 0 },
|
||||
};
|
||||
|
||||
static const retro_subsystem_memory_info bsx_memory[] = {
|
||||
{ "srm", RETRO_MEMORY_SNES_BSX_RAM },
|
||||
{ "psrm", RETRO_MEMORY_SNES_BSX_PRAM },
|
||||
};
|
||||
|
||||
static const struct retro_subsystem_rom_info bsx_roms[] = {
|
||||
{ "BSX ROM", "bs", false, false, true, bsx_memory, 2 },
|
||||
{ "BSX BIOS", "sfc|smc", false, false, true, NULL, 0 },
|
||||
};
|
||||
|
||||
// OR in 0x1000 on types to remain ABI compat with the older-style retro_load_game_special().
|
||||
static const struct retro_subsystem_info subsystems[] = {
|
||||
{ "Sufami Turbo", "sufami", sufami_roms, 3, RETRO_GAME_TYPE_SUFAMI_TURBO | 0x1000 }, // Sufami Turbo
|
||||
{ "BSX", "bsx", bsx_roms, 2, RETRO_GAME_TYPE_BSX | 0x1000 }, // BSX
|
||||
{ "BSX slotted", "bsxslot", bsx_roms, 2, RETRO_GAME_TYPE_BSX_SLOTTED | 0x1000 }, // BSX slotted
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO, (void*)subsystems);
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2010-2013 The RetroArch team
|
||||
/* Copyright (C) 2010-2014 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this libretro API header (libretro.h).
|
||||
|
@ -27,11 +27,13 @@
|
|||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
|
||||
// Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant.
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#else
|
||||
#if defined(_MSC_VER) && !defined(SN_TARGET_PS3) && !defined(__cplusplus)
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#if defined(_MSC_VER) && !defined(SN_TARGET_PS3)
|
||||
/* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */
|
||||
#define bool unsigned char
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
@ -94,9 +96,6 @@ extern "C" {
|
|||
// Eventually _PRESSED will return false for an index. No further presses are registered at this point.
|
||||
#define RETRO_DEVICE_POINTER 6
|
||||
|
||||
// FIXME: Document this.
|
||||
#define RETRO_DEVICE_SENSOR_ACCELEROMETER 7
|
||||
|
||||
// These device types are specializations of the base types above.
|
||||
// They should only be used in retro_set_controller_type() to inform libretro implementations
|
||||
// about use of a very specific device type.
|
||||
|
@ -153,11 +152,6 @@ extern "C" {
|
|||
#define RETRO_DEVICE_ID_POINTER_Y 1
|
||||
#define RETRO_DEVICE_ID_POINTER_PRESSED 2
|
||||
|
||||
// Id values for SENSOR types.
|
||||
#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_X 0
|
||||
#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_Y 1
|
||||
#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_Z 2
|
||||
|
||||
// Returned from retro_get_region().
|
||||
#define RETRO_REGION_NTSC 0
|
||||
#define RETRO_REGION_PAL 1
|
||||
|
@ -168,7 +162,7 @@ extern "C" {
|
|||
|
||||
// Regular save ram. This ram is usually found on a game cartridge, backed up by a battery.
|
||||
// If save game data is too complex for a single memory buffer,
|
||||
// the SYSTEM_DIRECTORY environment callback can be used.
|
||||
// the SAVE_DIRECTORY (preferably) or SYSTEM_DIRECTORY environment callback can be used.
|
||||
#define RETRO_MEMORY_SAVE_RAM 0
|
||||
|
||||
// Some games have a built-in clock to keep track of time.
|
||||
|
@ -181,21 +175,6 @@ extern "C" {
|
|||
// Video ram lets a frontend peek into a game systems video RAM (VRAM).
|
||||
#define RETRO_MEMORY_VIDEO_RAM 3
|
||||
|
||||
// Special memory types.
|
||||
#define RETRO_MEMORY_SNES_BSX_RAM ((1 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_BSX_PRAM ((2 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_SUFAMI_TURBO_A_RAM ((3 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_SUFAMI_TURBO_B_RAM ((4 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_GAME_BOY_RAM ((5 << 8) | RETRO_MEMORY_SAVE_RAM)
|
||||
#define RETRO_MEMORY_SNES_GAME_BOY_RTC ((6 << 8) | RETRO_MEMORY_RTC)
|
||||
|
||||
// Special game types passed into retro_load_game_special().
|
||||
// Only used when multiple ROMs are required.
|
||||
#define RETRO_GAME_TYPE_BSX 0x101
|
||||
#define RETRO_GAME_TYPE_BSX_SLOTTED 0x102
|
||||
#define RETRO_GAME_TYPE_SUFAMI_TURBO 0x103
|
||||
#define RETRO_GAME_TYPE_SUPER_GAME_BOY 0x104
|
||||
|
||||
// Keysyms used for ID in input state callback when polling RETRO_KEYBOARD.
|
||||
enum retro_key
|
||||
{
|
||||
|
@ -385,7 +364,7 @@ enum retro_mod
|
|||
// Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES), and reserved to avoid possible ABI clash.
|
||||
#define RETRO_ENVIRONMENT_SET_MESSAGE 6 // const struct retro_message * --
|
||||
// Sets a message to be displayed in implementation-specific manner for a certain amount of 'frames'.
|
||||
// Should not be used for trivial messages, which should simply be logged to stderr.
|
||||
// Should not be used for trivial messages, which should simply be logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a fallback, stderr).
|
||||
#define RETRO_ENVIRONMENT_SHUTDOWN 7 // N/A (NULL) --
|
||||
// Requests the frontend to shutdown.
|
||||
// Should only be used if game has a specific
|
||||
|
@ -421,6 +400,9 @@ enum retro_mod
|
|||
// If so, no such directory is defined,
|
||||
// and it's up to the implementation to find a suitable directory.
|
||||
//
|
||||
// NOTE: Some cores used this folder also for "save" data such as memory cards, etc, for lack of a better place to put it.
|
||||
// This is now discouraged, and if possible, cores should try to use the new GET_SAVE_DIRECTORY.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10
|
||||
// const enum retro_pixel_format * --
|
||||
// Sets the internal pixel format used by the implementation.
|
||||
|
@ -568,6 +550,121 @@ enum retro_mod
|
|||
// struct retro_perf_callback * --
|
||||
// Gets an interface for performance counters. This is useful for performance logging in a
|
||||
// cross-platform way and for detecting architecture-specific features, such as SIMD support.
|
||||
#define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29
|
||||
// struct retro_location_callback * --
|
||||
// Gets access to the location interface.
|
||||
// The purpose of this interface is to be able to retrieve location-based information from the host device,
|
||||
// such as current latitude / longitude.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30
|
||||
// const char ** --
|
||||
// Returns the "content" directory of the frontend.
|
||||
// This directory can be used to store specific assets that the core relies upon, such as art assets,
|
||||
// input data, etc etc.
|
||||
// The returned value can be NULL.
|
||||
// If so, no such directory is defined,
|
||||
// and it's up to the implementation to find a suitable directory.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31
|
||||
// const char ** --
|
||||
// Returns the "save" directory of the frontend.
|
||||
// This directory can be used to store SRAM, memory cards, high scores, etc, if the libretro core
|
||||
// cannot use the regular memory interface (retro_get_memory_data()).
|
||||
//
|
||||
// NOTE: libretro cores used to check GET_SYSTEM_DIRECTORY for similar things before.
|
||||
// They should still check GET_SYSTEM_DIRECTORY if they want to be backwards compatible.
|
||||
// The path here can be NULL. It should only be non-NULL if the frontend user has set a specific save path.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32
|
||||
// const struct retro_system_av_info * --
|
||||
// Sets a new av_info structure. This can only be called from within retro_run().
|
||||
// This should *only* be used if the core is completely altering the internal resolutions, aspect ratios, timings, sampling rate, etc.
|
||||
// Calling this can require a full reinitialization of video/audio drivers in the frontend,
|
||||
// so it is important to call it very sparingly, and usually only with the users explicit consent.
|
||||
// An eventual driver reinit will happen so that video and audio callbacks
|
||||
// happening after this call within the same retro_run() call will target the newly initialized driver.
|
||||
//
|
||||
// This callback makes it possible to support configurable resolutions in games, which can be useful to
|
||||
// avoid setting the "worst case" in max_width/max_height.
|
||||
//
|
||||
// ***HIGHLY RECOMMENDED*** Do not call this callback every time resolution changes in an emulator core if it's
|
||||
// expected to be a temporary change, for the reasons of possible driver reinit.
|
||||
// This call is not a free pass for not trying to provide correct values in retro_get_system_av_info().
|
||||
//
|
||||
// If this returns false, the frontend does not acknowledge a changed av_info struct.
|
||||
#define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33
|
||||
// const struct retro_get_proc_address_interface * --
|
||||
// Allows a libretro core to announce support for the get_proc_address() interface.
|
||||
// This interface allows for a standard way to extend libretro where use of environment calls are too indirect,
|
||||
// e.g. for cases where the frontend wants to call directly into the core.
|
||||
//
|
||||
// If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK **MUST** be called from within retro_set_environment().
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34
|
||||
// const struct retro_subsystem_info * --
|
||||
// This environment call introduces the concept of libretro "subsystems".
|
||||
// A subsystem is a variant of a libretro core which supports different kinds of games.
|
||||
// The purpose of this is to support e.g. emulators which might have special needs, e.g. Super Nintendos Super GameBoy, Sufami Turbo.
|
||||
// It can also be used to pick among subsystems in an explicit way if the libretro implementation is a multi-system emulator itself.
|
||||
//
|
||||
// Loading a game via a subsystem is done with retro_load_game_special(),
|
||||
// and this environment call allows a libretro core to expose which subsystems are supported for use with retro_load_game_special().
|
||||
// A core passes an array of retro_game_special_info which is terminated with a zeroed out retro_game_special_info struct.
|
||||
//
|
||||
// If a core wants to use this functionality, SET_SPECIAL_GAME_TYPES **MUST** be called from within retro_set_environment().
|
||||
|
||||
struct retro_subsystem_memory_info
|
||||
{
|
||||
const char *extension; // The extension associated with a memory type, e.g. "psram".
|
||||
unsigned type; // The memory type for retro_get_memory(). This should be at least 0x100 to avoid conflict with standardized libretro memory types.
|
||||
};
|
||||
|
||||
struct retro_subsystem_rom_info
|
||||
{
|
||||
const char *desc; // Describes what the ROM is (SGB bios, GB rom, etc).
|
||||
const char *valid_extensions; // Same definition as retro_get_system_info().
|
||||
bool need_fullpath; // Same definition as retro_get_system_info().
|
||||
bool block_extract; // Same definition as retro_get_system_info().
|
||||
bool required; // This is set if the ROM is required to load a game. If this is set to false, a zeroed-out retro_game_info can be passed.
|
||||
|
||||
// ROMs can have multiple associated persistent memory types (retro_get_memory()).
|
||||
const struct retro_subsystem_memory_info *memory;
|
||||
unsigned num_memory;
|
||||
};
|
||||
|
||||
struct retro_subsystem_info
|
||||
{
|
||||
const char *desc; // Human-readable string of the subsystem type, e.g. "Super GameBoy"
|
||||
// A computer friendly short string identifier for the subsystem type.
|
||||
// This name must be [a-z].
|
||||
// E.g. if desc is "Super GameBoy", this can be "sgb".
|
||||
// This identifier can be used for command-line interfaces, etc.
|
||||
const char *ident;
|
||||
|
||||
// Infos for each ROM. The first entry is assumed to be the "most significant" ROM for frontend purposes.
|
||||
// E.g. with Super GameBoy, the first ROM should be the GameBoy ROM, as it is the most "significant" ROM to a user.
|
||||
// If a frontend creates new file paths based on the ROM used (e.g. savestates), it should use the path for the first ROM to do so.
|
||||
const struct retro_subsystem_rom_info *roms;
|
||||
|
||||
unsigned num_roms; // Number of ROMs associated with a subsystem.
|
||||
unsigned id; // The type passed to retro_load_game_special().
|
||||
};
|
||||
|
||||
typedef void (*retro_proc_address_t)(void);
|
||||
// libretro API extension functions:
|
||||
// (None here so far).
|
||||
//////
|
||||
|
||||
// Get a symbol from a libretro core.
|
||||
// Cores should only return symbols which are actual extensions to the libretro API.
|
||||
// Frontends should not use this to obtain symbols to standard libretro entry points (static linking or dlsym).
|
||||
// The symbol name must be equal to the function name, e.g. if void retro_foo(void); exists, the symbol must be called "retro_foo".
|
||||
// The returned function pointer must be cast to the corresponding type.
|
||||
typedef retro_proc_address_t (*retro_get_proc_address_t)(const char *sym);
|
||||
struct retro_get_proc_address_interface
|
||||
{
|
||||
retro_get_proc_address_t get_proc_address;
|
||||
};
|
||||
|
||||
enum retro_log_level
|
||||
{
|
||||
|
@ -598,6 +695,13 @@ struct retro_log_callback
|
|||
#define RETRO_SIMD_NEON (1 << 5)
|
||||
#define RETRO_SIMD_SSE3 (1 << 6)
|
||||
#define RETRO_SIMD_SSSE3 (1 << 7)
|
||||
#define RETRO_SIMD_MMX (1 << 8)
|
||||
#define RETRO_SIMD_MMXEXT (1 << 9)
|
||||
#define RETRO_SIMD_SSE4 (1 << 10)
|
||||
#define RETRO_SIMD_SSE42 (1 << 11)
|
||||
#define RETRO_SIMD_AVX2 (1 << 12)
|
||||
#define RETRO_SIMD_VFPU (1 << 13)
|
||||
#define RETRO_SIMD_PS (1 << 14)
|
||||
|
||||
typedef uint64_t retro_perf_tick_t;
|
||||
typedef int64_t retro_time_t;
|
||||
|
@ -683,10 +787,17 @@ enum retro_sensor_action
|
|||
RETRO_SENSOR_DUMMY = INT_MAX
|
||||
};
|
||||
|
||||
// Id values for SENSOR types.
|
||||
#define RETRO_SENSOR_ACCELEROMETER_X 0
|
||||
#define RETRO_SENSOR_ACCELEROMETER_Y 1
|
||||
#define RETRO_SENSOR_ACCELEROMETER_Z 2
|
||||
|
||||
typedef bool (*retro_set_sensor_state_t)(unsigned port, enum retro_sensor_action action, unsigned rate);
|
||||
typedef float (*retro_sensor_get_input_t)(unsigned port, unsigned id);
|
||||
struct retro_sensor_interface
|
||||
{
|
||||
retro_set_sensor_state_t set_sensor_state;
|
||||
retro_sensor_get_input_t get_sensor_input;
|
||||
};
|
||||
////
|
||||
|
||||
|
@ -743,6 +854,41 @@ struct retro_camera_callback
|
|||
retro_camera_lifetime_status_t deinitialized;
|
||||
};
|
||||
|
||||
// Sets the interval of time and/or distance at which to update/poll location-based data.
|
||||
// To ensure compatibility with all location-based implementations, values for both
|
||||
// interval_ms and interval_distance should be provided.
|
||||
// interval_ms is the interval expressed in milliseconds.
|
||||
// interval_distance is the distance interval expressed in meters.
|
||||
typedef void (*retro_location_set_interval_t)(unsigned interval_ms, unsigned interval_distance);
|
||||
|
||||
// Start location services. The device will start listening for changes to the
|
||||
// current location at regular intervals (which are defined with retro_location_set_interval_t).
|
||||
typedef bool (*retro_location_start_t)(void);
|
||||
|
||||
// Stop location services. The device will stop listening for changes to the current
|
||||
// location.
|
||||
typedef void (*retro_location_stop_t)(void);
|
||||
|
||||
// Get the position of the current location. Will set parameters to 0 if no new
|
||||
// location update has happened since the last time.
|
||||
typedef bool (*retro_location_get_position_t)(double *lat, double *lon, double *horiz_accuracy,
|
||||
double *vert_accuracy);
|
||||
|
||||
// Callback which signals when the location driver is initialized and/or deinitialized.
|
||||
// retro_location_start_t can be called in initialized callback.
|
||||
typedef void (*retro_location_lifetime_status_t)(void);
|
||||
|
||||
struct retro_location_callback
|
||||
{
|
||||
retro_location_start_t start;
|
||||
retro_location_stop_t stop;
|
||||
retro_location_get_position_t get_position;
|
||||
retro_location_set_interval_t set_interval;
|
||||
|
||||
retro_location_lifetime_status_t initialized;
|
||||
retro_location_lifetime_status_t deinitialized;
|
||||
};
|
||||
|
||||
enum retro_rumble_effect
|
||||
{
|
||||
RETRO_RUMBLE_STRONG = 0,
|
||||
|
@ -802,7 +948,6 @@ typedef void (*retro_hw_context_reset_t)(void);
|
|||
typedef uintptr_t (*retro_hw_get_current_framebuffer_t)(void);
|
||||
|
||||
// Get a symbol from HW context.
|
||||
typedef void (*retro_proc_address_t)(void);
|
||||
typedef retro_proc_address_t (*retro_hw_get_proc_address_t)(const char *sym);
|
||||
|
||||
enum retro_hw_context_type
|
||||
|
|
Loading…
Reference in New Issue