Add new extensions to help FBA.

This commit is contained in:
Themaister 2012-03-12 00:37:44 +01:00
parent fe0a6c8d07
commit d7afd20346
6 changed files with 59 additions and 21 deletions

View File

@ -18,6 +18,7 @@
#include <stdio.h>
#include <string.h>
#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];

View File

@ -20,10 +20,11 @@
#include <stddef.h>
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

View File

@ -20,6 +20,10 @@
#include "strl.h"
#include <string.h>
#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;

View File

@ -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;

View File

@ -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
{

View File

@ -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.