diff --git a/console/console_ext.c b/console/console_ext.c index 1f0b751ec9..a50c8b2ee7 100644 --- a/console/console_ext.c +++ b/console/console_ext.c @@ -18,6 +18,7 @@ #include #include #include "../boolean.h" +#include "../strl.h" #include "../libsnes.hpp" #include "../input/input_luts.h" #include "../general.h" @@ -33,7 +34,14 @@ #include "../posix_string.h" #endif -const char * ssnes_console_get_rom_ext(void) +static char g_rom_ext[1024]; + +void ssnes_console_set_rom_ext(const char *ext) +{ + strlcpy(g_rom_ext, ext, sizeof(g_rom_ext)); +} + +const char *ssnes_console_get_rom_ext(void) { const char *id = snes_library_id(); @@ -55,6 +63,8 @@ const char * ssnes_console_get_rom_ext(void) // Genesis Plus GX/Next else if (strstr(id, "Genesis Plus GX")) return "md|smd|bin|gen|zip|MD|SMD|bin|GEN|ZIP|sms|SMS|gg|GG|sg|SG"; + else if (*g_rom_ext) + return g_rom_ext; return NULL; } @@ -108,22 +118,6 @@ void ssnes_console_set_default_keybind_names_for_emulator(void) } #ifdef HAVE_ZLIB - -/* if 0, the emulator core uses zlib internally and therefore we can't extract zip files to the cache partitions. If 1, zip files can be extracted to the cache partitions */ - -int can_extract_zip_files(void) -{ - bool retval = 1; - - const char *id = snes_library_id(); - - // FBA Next - if (strstr(id, "FB Alpha")) - retval = 0; - - return retval; -} - static int ssnes_extract_currentfile_in_zip(unzFile uf) { char filename_inzip[PATH_MAX]; diff --git a/console/console_ext.h b/console/console_ext.h index db91077aaf..fefdca33a3 100644 --- a/console/console_ext.h +++ b/console/console_ext.h @@ -20,10 +20,11 @@ #include +void ssnes_console_set_rom_ext(const char *ext); + // Get rom extensions for current library. -// Infers info from snes_library_id(). // Returns NULL if library doesn't have any preferences in particular. -const char * ssnes_console_get_rom_ext(void); +const char *ssnes_console_get_rom_ext(void); // Transforms a library id to a name suitable as a pathname. void ssnes_console_name_from_id(char *name, size_t size); @@ -33,7 +34,6 @@ void ssnes_console_name_from_id(char *name, size_t size); void ssnes_console_set_default_keybind_names_for_emulator(void); #ifdef HAVE_ZLIB -int can_extract_zip_files(void); int ssnes_extract_zipfile(const char *zip_path); #endif diff --git a/dynamic.c b/dynamic.c index 4649f47774..626b134779 100644 --- a/dynamic.c +++ b/dynamic.c @@ -20,6 +20,10 @@ #include "strl.h" #include +#ifdef SSNES_CONSOLE +#include "console/console_ext.h" +#endif + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -382,6 +386,25 @@ static bool environment_cb(unsigned cmd, void *data) break; } +#ifdef SSNES_CONSOLE + case SNES_ENVIRONMENT_SET_BATCH_LOAD: + g_console.block_zip_extract = *(const bool*)data; + break; + + case SNES_ENVIRONMENT_SET_ROM_FORMATS: + ssnes_console_set_rom_ext((const char*)data); + break; +#endif + + case SNES_ENVIRONMENT_SET_MESSAGE: + { + const struct snes_message *msg = (const struct snes_message*)data; + SSNES_LOG("Environ SET_MESSAGE: %s\n", msg->msg); + if (g_extern.msg_queue) + msg_queue_push(g_extern.msg_queue, msg->msg, 1, msg->frames); + break; + } + default: SSNES_LOG("Environ UNSUPPORTED (#%u).\n", cmd); return false; diff --git a/general.h b/general.h index f22ba18949..368d3d278d 100644 --- a/general.h +++ b/general.h @@ -190,6 +190,7 @@ struct console_settings bool default_sram_dir_enable; bool default_savestate_dir_enable; bool extract_zip_files_enable; + bool block_zip_extract; bool frame_advance_enable; bool gamma_correction_enable; bool initialize_ssnes_enable; diff --git a/libsnes.hpp b/libsnes.hpp index 0116d4f85e..4227af09d2 100755 --- a/libsnes.hpp +++ b/libsnes.hpp @@ -111,6 +111,27 @@ extern "C" { // which variables it might want to check for later using GET_VARIABLE. // 'data' points to an array of snes_variable structs terminated by a { NULL, NULL } element. // snes_variable::value should contain a human readable description of the key. + // +#define SNES_ENVIRONMENT_SET_BATCH_LOAD 10 // const bool * -- + // If true, the implementation will load several roms in batch. + // This means the rom must be provided exactly as is, i.e. it cannot be extracted. + // If supported, this must be called directly when snes_set_environment() is called. + // (Used on consoles). + // +#define SNES_ENVIRONMENT_SET_ROM_FORMATS 11 // const char * -- + // Sets rom extensions the core generally supports. + // If supported, this must be called directly when snes_set_environment() is called. + // Formats are delimited with '|', i.e. "foo|bar|baz". + // (Used on consoles). + // +#define SNES_ENVIRONMENT_SET_MESSAGE 12 // const struct snes_message * -- + // Sets a message to be displayed in implementation-specific manner for a certain amount of 'frames'. + +struct snes_message +{ + const char *msg; + unsigned frames; +}; struct snes_variable { diff --git a/message.h b/message.h index 4ec088ce4f..21395c6bdc 100644 --- a/message.h +++ b/message.h @@ -27,7 +27,6 @@ typedef struct msg_queue msg_queue_t; msg_queue_t *msg_queue_new(size_t size); // Higher prio is... higher prio :) Duration is how many times a message can be pulled from queue before it vanishes. (E.g. show a message for 3 seconds @ 60fps = 180 duration). - void msg_queue_push(msg_queue_t *queue, const char *msg, unsigned prio, unsigned duration); // Pulls highest prio message in queue. Returns NULL if no message in queue.