mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-25 00:49:47 +00:00
Merge branch 'master' of github.com:Themaister/SSNES into ssnes-consoles
This commit is contained in:
commit
c8d3278dbc
17
dynamic.c
17
dynamic.c
@ -291,14 +291,14 @@ static bool environment_cb(unsigned cmd, void *data)
|
||||
{
|
||||
case SNES_ENVIRONMENT_GET_FULLPATH:
|
||||
*(const char**)data = g_extern.system.fullpath;
|
||||
SSNES_LOG("FULLPATH: \"%s\"\n", g_extern.system.fullpath);
|
||||
SSNES_LOG("Environ FULLPATH: \"%s\"\n", g_extern.system.fullpath);
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_SET_GEOMETRY:
|
||||
g_extern.system.geom = *(const struct snes_geometry*)data;
|
||||
g_extern.system.geom.max_width = next_pow2(g_extern.system.geom.max_width);
|
||||
g_extern.system.geom.max_height = next_pow2(g_extern.system.geom.max_height);
|
||||
SSNES_LOG("SET_GEOMETRY: (%ux%u) / (%ux%u)\n",
|
||||
SSNES_LOG("Environ SET_GEOMETRY: (%ux%u) / (%ux%u)\n",
|
||||
g_extern.system.geom.base_width,
|
||||
g_extern.system.geom.base_height,
|
||||
g_extern.system.geom.max_width,
|
||||
@ -307,24 +307,32 @@ static bool environment_cb(unsigned cmd, void *data)
|
||||
|
||||
case SNES_ENVIRONMENT_SET_PITCH:
|
||||
g_extern.system.pitch = *(const unsigned*)data;
|
||||
SSNES_LOG("SET_PITCH: %u\n", g_extern.system.pitch);
|
||||
SSNES_LOG("Environ SET_PITCH: %u\n", g_extern.system.pitch);
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_GET_OVERSCAN:
|
||||
*(bool*)data = !g_settings.video.crop_overscan;
|
||||
SSNES_LOG("GET_OVERSCAN: %u\n", (unsigned)!g_settings.video.crop_overscan);
|
||||
SSNES_LOG("Environ GET_OVERSCAN: %u\n", (unsigned)!g_settings.video.crop_overscan);
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_SET_TIMING:
|
||||
g_extern.system.timing = *(const struct snes_system_timing*)data;
|
||||
g_extern.system.timing_set = true;
|
||||
SSNES_LOG("Environ SET_TIMING: %.3lf Hz/ %.3lf Hz\n", g_extern.system.timing.fps, g_extern.system.timing.sample_rate);
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_GET_CAN_DUPE:
|
||||
*(bool*)data = true;
|
||||
SSNES_LOG("Environ GET_CAN_DUPE: true\n");
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_SET_NEED_FULLPATH:
|
||||
g_extern.system.need_fullpath = *(const bool*)data;
|
||||
SSNES_LOG("Environ SET_NEED_FULLPATH: %s\n", g_extern.system.need_fullpath ? "true" : "false");
|
||||
break;
|
||||
|
||||
default:
|
||||
SSNES_LOG("Environ UNSUPPORTED (#%u)!\n", cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -351,6 +359,7 @@ static void set_environment(void)
|
||||
// Assume SNES as defaults.
|
||||
static void set_environment_defaults(void)
|
||||
{
|
||||
SSNES_LOG("Setting environment defaults (SNES)\n");
|
||||
g_extern.system.pitch = 0; // 0 is classic libsnes semantics.
|
||||
g_extern.system.geom = (struct snes_geometry) {
|
||||
.base_width = 256,
|
||||
|
31
file.c
31
file.c
@ -737,19 +737,34 @@ static bool load_normal_rom(void)
|
||||
void *rom_buf = NULL;
|
||||
ssize_t rom_len = 0;
|
||||
|
||||
if ((rom_len = read_rom_file(g_extern.rom_file, &rom_buf)) == -1)
|
||||
if (!g_extern.system.need_fullpath)
|
||||
{
|
||||
SSNES_ERR("Could not read ROM file.\n");
|
||||
return false;
|
||||
if ((rom_len = read_rom_file(g_extern.rom_file, &rom_buf)) == -1)
|
||||
{
|
||||
SSNES_ERR("Could not read ROM file.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (g_extern.rom_file)
|
||||
fclose(g_extern.rom_file);
|
||||
|
||||
SSNES_LOG("ROM size: %d bytes\n", (int)rom_len);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!g_extern.rom_file)
|
||||
{
|
||||
SSNES_ERR("Implementation requires a full path to be set, cannot load ROM from stdin. Aborting ...\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (g_extern.rom_file != NULL)
|
||||
fclose(g_extern.rom_file);
|
||||
|
||||
SSNES_LOG("ROM size: %d bytes\n", (int)rom_len);
|
||||
|
||||
char *xml_buf = load_xml_map(g_extern.xml_name);
|
||||
SSNES_LOG("ROM loading skipped. Implementation will load it on its own.\n");
|
||||
}
|
||||
|
||||
char *xml_buf = load_xml_map(g_extern.xml_name);
|
||||
|
||||
if (!psnes_load_cartridge_normal(xml_buf, rom_buf, rom_len))
|
||||
{
|
||||
SSNES_ERR("ROM file is not valid!\n");
|
||||
|
@ -225,6 +225,7 @@ struct global
|
||||
char fullpath[MAXPATHLEN];
|
||||
struct snes_system_timing timing;
|
||||
bool timing_set;
|
||||
bool need_fullpath;
|
||||
} system;
|
||||
|
||||
struct
|
||||
|
35
libsnes.hpp
35
libsnes.hpp
@ -67,14 +67,33 @@ extern "C" {
|
||||
#define SNES_MEMORY_CGRAM 104
|
||||
|
||||
// SSNES extension. Not required to be implemented for a working implementation.
|
||||
#define SNES_ENVIRONMENT_GET_FULLPATH 0 // const char ** -- Full path of game loaded.
|
||||
#define SNES_ENVIRONMENT_SET_GEOMETRY 1 // const struct snes_geometry * -- Window geometry information for the system/game.
|
||||
#define SNES_ENVIRONMENT_SET_PITCH 2 // const unsigned * -- Pitch of game image.
|
||||
#define SNES_ENVIRONMENT_GET_OVERSCAN 3 // bool * -- Boolean value whether or not the implementation should use overscan.
|
||||
#define SNES_ENVIRONMENT_SET_TIMING 4 // const struct snes_system_timing * -- Set exact timings of the system.
|
||||
// Used primarily for video recording.
|
||||
#define SNES_ENVIRONMENT_GET_CAN_DUPE 5 // bool * -- Boolean value whether or not SSNES supports frame duping,
|
||||
// passing NULL to video frame callback.
|
||||
#define SNES_ENVIRONMENT_GET_FULLPATH 0 // const char ** --
|
||||
// Full path of game loaded.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_SET_GEOMETRY 1 // const struct snes_geometry * --
|
||||
// Window geometry information for the system/game.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_SET_PITCH 2 // const unsigned * --
|
||||
// Pitch of game image.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_GET_OVERSCAN 3 // bool * --
|
||||
// Boolean value whether or not the implementation should use overscan.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_SET_TIMING 4 // const struct snes_system_timing * --
|
||||
// Set exact timings of the system. Used primarily for video recording.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_GET_CAN_DUPE 5 // bool * --
|
||||
// Boolean value whether or not SSNES supports frame duping,
|
||||
// passing NULL to video frame callback.
|
||||
//
|
||||
//
|
||||
#define SNES_ENVIRONMENT_SET_NEED_FULLPATH 6 // const bool * --
|
||||
// Boolean value telling if implementation needs a valid fullpath to be able to run.
|
||||
// If this is the case, SSNES will not open the rom directly,
|
||||
// and pass NULL to rom data.
|
||||
// Implementation must then use SNES_ENVIRONMENT_GET_FULLPATH.
|
||||
// This is useful for implementations with very large roms,
|
||||
// which are impractical to load fully into RAM.
|
||||
|
||||
struct snes_geometry
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user