2012-06-03 15:48:14 +00:00
|
|
|
#include "mednafen/mednafen.h"
|
2012-11-29 22:21:44 +00:00
|
|
|
#include "mednafen/mempatcher.h"
|
2012-06-03 15:48:14 +00:00
|
|
|
#include "mednafen/git.h"
|
|
|
|
#include "mednafen/general.h"
|
2013-04-27 14:40:24 +00:00
|
|
|
#include "mednafen/md5.h"
|
2012-11-16 14:12:25 +00:00
|
|
|
#ifdef NEED_DEINTERLACER
|
|
|
|
#include "mednafen/video/Deinterlacer.h"
|
|
|
|
#endif
|
2012-06-03 15:48:14 +00:00
|
|
|
#include "libretro.h"
|
|
|
|
|
|
|
|
static MDFNGI *game;
|
2014-04-21 22:25:50 +00:00
|
|
|
|
|
|
|
struct retro_perf_callback perf_cb;
|
|
|
|
retro_get_cpu_features_t perf_get_cpu_features_cb = NULL;
|
2014-04-20 14:32:46 +00:00
|
|
|
retro_log_printf_t log_cb;
|
2012-06-03 15:48:14 +00:00
|
|
|
static retro_video_refresh_t video_cb;
|
|
|
|
static retro_audio_sample_t audio_cb;
|
|
|
|
static retro_audio_sample_batch_t audio_batch_cb;
|
|
|
|
static retro_environment_t environ_cb;
|
|
|
|
static retro_input_poll_t input_poll_cb;
|
|
|
|
static retro_input_state_t input_state_cb;
|
|
|
|
|
2013-09-26 11:42:08 +00:00
|
|
|
static retro_rumble_interface rumble;
|
|
|
|
|
2013-02-25 19:39:39 +00:00
|
|
|
static bool overscan;
|
2012-11-16 14:12:25 +00:00
|
|
|
static double last_sound_rate;
|
|
|
|
static MDFN_PixelFormat last_pixel_format;
|
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
static MDFN_Surface *surf;
|
|
|
|
|
2012-06-15 23:00:17 +00:00
|
|
|
static bool failed_init;
|
2012-06-03 15:48:14 +00:00
|
|
|
|
2014-01-20 23:19:08 +00:00
|
|
|
static void hookup_ports(bool force);
|
|
|
|
|
|
|
|
static bool initial_ports_hookup = false;
|
|
|
|
|
2012-10-13 13:31:49 +00:00
|
|
|
std::string retro_base_directory;
|
|
|
|
std::string retro_base_name;
|
2014-02-07 07:16:01 +00:00
|
|
|
std::string retro_save_directory;
|
2012-10-13 13:31:49 +00:00
|
|
|
|
2013-04-27 14:40:24 +00:00
|
|
|
static void set_basename(const char *path)
|
|
|
|
{
|
|
|
|
const char *base = strrchr(path, '/');
|
|
|
|
if (!base)
|
|
|
|
base = strrchr(path, '\\');
|
|
|
|
|
|
|
|
if (base)
|
|
|
|
retro_base_name = base + 1;
|
|
|
|
else
|
|
|
|
retro_base_name = path;
|
|
|
|
|
|
|
|
retro_base_name = retro_base_name.substr(0, retro_base_name.find_last_of('.'));
|
|
|
|
}
|
|
|
|
|
2012-11-16 14:12:25 +00:00
|
|
|
#ifdef NEED_DEINTERLACER
|
|
|
|
static bool PrevInterlaced;
|
|
|
|
static Deinterlacer deint;
|
|
|
|
#endif
|
|
|
|
|
2014-06-18 16:27:13 +00:00
|
|
|
#if defined(WANT_LYNX_EMU)
|
2013-12-18 20:42:11 +00:00
|
|
|
#define MEDNAFEN_CORE_NAME_MODULE "lynx"
|
|
|
|
#define MEDNAFEN_CORE_NAME "Mednafen Lynx"
|
|
|
|
#define MEDNAFEN_CORE_VERSION "v0.9.32"
|
|
|
|
#define MEDNAFEN_CORE_EXTENSIONS "lnx"
|
|
|
|
#define MEDNAFEN_CORE_TIMING_FPS 75
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_W 160
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_H 102
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 160
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 102
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
|
|
|
|
#define FB_WIDTH 160
|
|
|
|
#define FB_HEIGHT 102
|
|
|
|
static bool is_pal = false;
|
|
|
|
|
2012-10-20 21:32:28 +00:00
|
|
|
#elif defined(WANT_PCE_FAST_EMU)
|
2014-04-22 08:25:01 +00:00
|
|
|
#include "mednafen/pce_fast-09333/pcecd.h"
|
2012-10-20 23:47:02 +00:00
|
|
|
#define MEDNAFEN_CORE_NAME_MODULE "pce_fast"
|
2012-10-20 21:32:28 +00:00
|
|
|
#define MEDNAFEN_CORE_NAME "Mednafen PCE Fast"
|
2014-04-20 21:05:37 +00:00
|
|
|
#define MEDNAFEN_CORE_VERSION "v0.9.33.3"
|
2014-04-20 22:24:36 +00:00
|
|
|
#define MEDNAFEN_CORE_EXTENSIONS "pce|sgx|cue|ccd"
|
2012-10-20 23:47:02 +00:00
|
|
|
#define MEDNAFEN_CORE_TIMING_FPS 59.82
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_W (game->nominal_width)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_H (game->nominal_height)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 512
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 242
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
|
|
|
|
#define FB_WIDTH 512
|
|
|
|
#define FB_HEIGHT 242
|
2012-10-22 12:34:14 +00:00
|
|
|
|
|
|
|
#elif defined(WANT_WSWAN_EMU)
|
|
|
|
#define MEDNAFEN_CORE_NAME_MODULE "wswan"
|
|
|
|
#define MEDNAFEN_CORE_NAME "Mednafen WonderSwan"
|
2014-04-20 21:43:06 +00:00
|
|
|
#define MEDNAFEN_CORE_VERSION "v0.9.33.3"
|
2013-04-30 22:03:33 +00:00
|
|
|
#define MEDNAFEN_CORE_EXTENSIONS "ws|wsc"
|
2012-10-22 12:34:14 +00:00
|
|
|
#define MEDNAFEN_CORE_TIMING_FPS 75.47
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_W (game->nominal_width)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_H (game->nominal_height)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 224
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 144
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
|
|
|
|
#define FB_WIDTH 224
|
|
|
|
#define FB_HEIGHT 144
|
|
|
|
|
2012-11-24 06:44:49 +00:00
|
|
|
#elif defined(WANT_NGP_EMU)
|
|
|
|
#define MEDNAFEN_CORE_NAME_MODULE "ngp"
|
2012-11-24 07:17:18 +00:00
|
|
|
#define MEDNAFEN_CORE_NAME "Mednafen Neopop"
|
2014-04-20 21:59:21 +00:00
|
|
|
#define MEDNAFEN_CORE_VERSION "v0.9.33.3"
|
2013-04-30 22:03:33 +00:00
|
|
|
#define MEDNAFEN_CORE_EXTENSIONS "ngp|ngc"
|
2012-11-24 06:44:49 +00:00
|
|
|
#define MEDNAFEN_CORE_TIMING_FPS 60.25
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_W (game->nominal_width)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_H (game->nominal_height)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 160
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 152
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
|
|
|
|
#define FB_WIDTH 160
|
|
|
|
#define FB_HEIGHT 152
|
|
|
|
|
2012-11-24 07:17:18 +00:00
|
|
|
#elif defined(WANT_GBA_EMU)
|
|
|
|
#define MEDNAFEN_CORE_NAME_MODULE "gba"
|
|
|
|
#define MEDNAFEN_CORE_NAME "Mednafen VBA-M"
|
2014-04-30 03:05:04 +00:00
|
|
|
#define MEDNAFEN_CORE_VERSION "v0.9.33.3"
|
|
|
|
#define MEDNAFEN_CORE_EXTENSIONS "gba|agb|bin"
|
2012-11-24 07:17:18 +00:00
|
|
|
#define MEDNAFEN_CORE_TIMING_FPS 59.73
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_W (game->nominal_width)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_H (game->nominal_height)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 240
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 160
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
|
|
|
|
#define FB_WIDTH 240
|
|
|
|
#define FB_HEIGHT 160
|
|
|
|
|
2012-11-24 16:14:05 +00:00
|
|
|
#elif defined(WANT_SNES_EMU)
|
|
|
|
#define MEDNAFEN_CORE_NAME_MODULE "snes"
|
|
|
|
#define MEDNAFEN_CORE_NAME "Mednafen bSNES"
|
|
|
|
#define MEDNAFEN_CORE_VERSION "v0.9.26"
|
2013-04-30 22:03:33 +00:00
|
|
|
#define MEDNAFEN_CORE_EXTENSIONS "smc|fig|bs|st|sfc"
|
2012-11-24 16:14:05 +00:00
|
|
|
#define MEDNAFEN_CORE_TIMING_FPS 60.10
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_W (game->nominal_width)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_H (game->nominal_height)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 512
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 512
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
|
|
|
|
#define FB_WIDTH 512
|
|
|
|
#define FB_HEIGHT 512
|
|
|
|
|
2012-11-25 02:41:54 +00:00
|
|
|
#elif defined(WANT_VB_EMU)
|
|
|
|
#define MEDNAFEN_CORE_NAME_MODULE "vb"
|
|
|
|
#define MEDNAFEN_CORE_NAME "Mednafen VB"
|
2014-04-20 22:38:14 +00:00
|
|
|
#define MEDNAFEN_CORE_VERSION "v0.9.33.3"
|
2013-04-30 22:03:33 +00:00
|
|
|
#define MEDNAFEN_CORE_EXTENSIONS "vb|vboy|bin"
|
2012-11-25 02:41:54 +00:00
|
|
|
#define MEDNAFEN_CORE_TIMING_FPS 50.27
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_W (game->nominal_width)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_H (game->nominal_height)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 384
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 224
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
|
|
|
|
#define FB_WIDTH 384
|
2012-11-27 03:05:55 +00:00
|
|
|
#define FB_HEIGHT 224
|
2012-11-25 02:41:54 +00:00
|
|
|
|
2012-11-28 07:20:45 +00:00
|
|
|
#elif defined(WANT_PCFX_EMU)
|
|
|
|
#define MEDNAFEN_CORE_NAME_MODULE "pcfx"
|
2014-04-26 04:29:19 +00:00
|
|
|
#define MEDNAFEN_CORE_NAME "Mednafen PC-FX"
|
2014-04-20 23:51:59 +00:00
|
|
|
#define MEDNAFEN_CORE_VERSION "v0.9.33.3"
|
2014-04-26 04:29:19 +00:00
|
|
|
#define MEDNAFEN_CORE_EXTENSIONS "cue|ccd"
|
2012-11-28 07:20:45 +00:00
|
|
|
#define MEDNAFEN_CORE_TIMING_FPS 59.94
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_W (game->nominal_width)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_H (game->nominal_height)
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 341
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 480
|
|
|
|
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
|
|
|
|
#define FB_WIDTH 344
|
|
|
|
#define FB_HEIGHT 480
|
2012-10-22 15:00:42 +00:00
|
|
|
#endif
|
|
|
|
|
2013-10-01 12:28:59 +00:00
|
|
|
|
|
|
|
#define FB_MAX_HEIGHT FB_HEIGHT
|
|
|
|
|
|
|
|
// Wastes a little space for NTSC PSX, but better than dynamically allocating.
|
2012-10-22 15:00:42 +00:00
|
|
|
#ifdef WANT_16BPP
|
2013-10-01 12:28:59 +00:00
|
|
|
static uint16_t mednafen_buf[FB_WIDTH * FB_MAX_HEIGHT];
|
2012-10-22 15:00:42 +00:00
|
|
|
#else
|
2013-10-01 12:28:59 +00:00
|
|
|
static uint32_t mednafen_buf[FB_WIDTH * FB_MAX_HEIGHT];
|
2012-10-20 21:32:28 +00:00
|
|
|
#endif
|
2012-10-20 21:56:43 +00:00
|
|
|
const char *mednafen_core_str = MEDNAFEN_CORE_NAME;
|
2012-10-20 21:32:28 +00:00
|
|
|
|
|
|
|
static void check_system_specs(void)
|
|
|
|
{
|
2012-10-22 12:34:14 +00:00
|
|
|
unsigned level = 0;
|
|
|
|
environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level);
|
2012-10-20 21:32:28 +00:00
|
|
|
}
|
|
|
|
|
2014-04-21 22:25:50 +00:00
|
|
|
void retro_init(void)
|
2012-06-03 15:48:14 +00:00
|
|
|
{
|
2014-01-02 01:50:09 +00:00
|
|
|
struct retro_log_callback log;
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log))
|
|
|
|
log_cb = log.log;
|
|
|
|
else
|
|
|
|
log_cb = NULL;
|
|
|
|
|
2012-11-29 22:21:44 +00:00
|
|
|
MDFNI_InitializeModule();
|
2012-06-03 15:48:14 +00:00
|
|
|
|
2012-06-11 23:03:09 +00:00
|
|
|
const char *dir = NULL;
|
2012-06-15 23:00:17 +00:00
|
|
|
|
2012-06-11 23:03:09 +00:00
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir)
|
|
|
|
{
|
2012-10-13 13:31:49 +00:00
|
|
|
retro_base_directory = dir;
|
2012-11-10 01:20:13 +00:00
|
|
|
// Make sure that we don't have any lingering slashes, etc, as they break Windows.
|
2012-11-10 11:59:05 +00:00
|
|
|
size_t last = retro_base_directory.find_last_not_of("/\\");
|
|
|
|
if (last != std::string::npos)
|
|
|
|
last++;
|
|
|
|
|
|
|
|
retro_base_directory = retro_base_directory.substr(0, last);
|
2012-11-10 01:20:13 +00:00
|
|
|
|
|
|
|
MDFNI_Initialize(retro_base_directory.c_str());
|
2012-06-11 23:03:09 +00:00
|
|
|
}
|
2012-06-15 23:00:17 +00:00
|
|
|
else
|
2012-06-11 23:03:09 +00:00
|
|
|
{
|
2013-12-17 01:24:08 +00:00
|
|
|
/* TODO: Add proper fallback */
|
|
|
|
if (log_cb)
|
|
|
|
log_cb(RETRO_LOG_WARN, "System directory is not defined. Fallback on using same dir as ROM for system directory later ...\n");
|
2012-06-15 23:00:17 +00:00
|
|
|
failed_init = true;
|
2012-06-11 23:03:09 +00:00
|
|
|
}
|
2014-02-07 07:07:58 +00:00
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir)
|
|
|
|
{
|
2014-02-07 22:34:14 +00:00
|
|
|
// If save directory is defined use it, otherwise use system directory
|
|
|
|
retro_save_directory = *dir ? dir : retro_base_directory;
|
2014-02-07 07:07:58 +00:00
|
|
|
// Make sure that we don't have any lingering slashes, etc, as they break Windows.
|
|
|
|
size_t last = retro_save_directory.find_last_not_of("/\\");
|
|
|
|
if (last != std::string::npos)
|
|
|
|
last++;
|
|
|
|
|
|
|
|
retro_save_directory = retro_save_directory.substr(0, last);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* TODO: Add proper fallback */
|
|
|
|
if (log_cb)
|
2014-02-07 22:34:14 +00:00
|
|
|
log_cb(RETRO_LOG_WARN, "Save directory is not defined. Fallback on using SYSTEM directory ...\n");
|
2014-02-07 07:07:58 +00:00
|
|
|
retro_save_directory = retro_base_directory;
|
|
|
|
}
|
2012-06-09 22:46:41 +00:00
|
|
|
|
2012-10-22 12:34:14 +00:00
|
|
|
#if defined(WANT_16BPP) && defined(FRONTEND_SUPPORTS_RGB565)
|
|
|
|
enum retro_pixel_format rgb565 = RETRO_PIXEL_FORMAT_RGB565;
|
2013-12-17 01:24:08 +00:00
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb565) && log_cb)
|
|
|
|
log_cb(RETRO_LOG_INFO, "Frontend supports RGB565 - will use that instead of XRGB1555.\n");
|
2012-10-22 12:34:14 +00:00
|
|
|
#endif
|
|
|
|
|
2014-04-21 22:25:50 +00:00
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_PERF_INTERFACE, &perf_cb))
|
|
|
|
perf_get_cpu_features_cb = perf_cb.get_cpu_features;
|
|
|
|
else
|
|
|
|
perf_get_cpu_features_cb = NULL;
|
|
|
|
|
2012-10-20 21:32:28 +00:00
|
|
|
check_system_specs();
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
2014-04-20 14:32:46 +00:00
|
|
|
void retro_reset(void)
|
2012-06-03 15:48:14 +00:00
|
|
|
{
|
2012-11-16 14:12:25 +00:00
|
|
|
game->DoSimpleCommand(MDFN_MSC_RESET);
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool retro_load_game_special(unsigned, const struct retro_game_info *, size_t)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-24 15:26:57 +00:00
|
|
|
static void set_volume (uint32_t *ptr, unsigned number)
|
|
|
|
{
|
|
|
|
switch(number)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
*ptr = number;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-09 02:05:18 +00:00
|
|
|
static void check_variables(void)
|
|
|
|
{
|
|
|
|
struct retro_variable var = {0};
|
|
|
|
|
|
|
|
#if defined(WANT_PCE_FAST_EMU)
|
|
|
|
var.key = "pce_nospritelimit";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
|
|
|
if (strcmp(var.value, "disabled") == 0)
|
|
|
|
setting_pce_fast_nospritelimit = 0;
|
|
|
|
else if (strcmp(var.value, "enabled") == 0)
|
|
|
|
setting_pce_fast_nospritelimit = 1;
|
|
|
|
}
|
2013-05-24 15:26:57 +00:00
|
|
|
|
2013-05-24 15:37:36 +00:00
|
|
|
var.key = "pce_keepaspect";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
|
|
|
if (strcmp(var.value, "disabled") == 0)
|
|
|
|
{
|
|
|
|
setting_pce_keepaspect = 0;
|
|
|
|
game->fb_width = 512;
|
|
|
|
game->nominal_width = 341;
|
|
|
|
game->lcm_width = 341;
|
|
|
|
}
|
|
|
|
else if (strcmp(var.value, "enabled") == 0)
|
|
|
|
{
|
|
|
|
setting_pce_keepaspect = 1;
|
|
|
|
game->fb_width = 682;
|
|
|
|
game->nominal_width = 288;
|
|
|
|
game->lcm_width = 1024;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-24 15:26:57 +00:00
|
|
|
bool do_cdsettings = false;
|
|
|
|
var.key = "pce_cddavolume";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
|
|
|
do_cdsettings = true;
|
|
|
|
setting_pce_fast_cddavolume = atoi(var.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
var.key = "pce_adpcmvolume";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
|
|
|
do_cdsettings = true;
|
|
|
|
setting_pce_fast_adpcmvolume = atoi(var.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
var.key = "pce_cdpsgvolume";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
|
|
|
do_cdsettings = true;
|
|
|
|
setting_pce_fast_cdpsgvolume = atoi(var.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
var.key = "pce_cdspeed";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
|
|
|
do_cdsettings = true;
|
|
|
|
setting_pce_fast_cdspeed = atoi(var.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_cdsettings)
|
|
|
|
{
|
2014-04-21 22:31:36 +00:00
|
|
|
PCE_Fast::PCECD_Settings settings = {0};
|
2014-06-05 16:06:15 +00:00
|
|
|
settings.CDDA_Volume = (double)setting_pce_fast_cddavolume / 100;
|
2013-05-24 15:26:57 +00:00
|
|
|
settings.CD_Speed = setting_pce_fast_cdspeed;
|
2014-06-05 16:06:15 +00:00
|
|
|
settings.ADPCM_Volume = (double)setting_pce_fast_adpcmvolume / 100;
|
2013-05-24 15:26:57 +00:00
|
|
|
|
2013-12-17 01:24:08 +00:00
|
|
|
if (PCECD_SetSettings(&settings) && log_cb)
|
|
|
|
log_cb(RETRO_LOG_INFO, "PCE CD Audio settings changed.\n");
|
2013-05-24 15:26:57 +00:00
|
|
|
}
|
2013-05-24 16:59:38 +00:00
|
|
|
#elif defined(WANT_NGP_EMU)
|
|
|
|
var.key = "ngp_language";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
|
|
|
if (strcmp(var.value, "japanese") == 0)
|
|
|
|
setting_ngp_language = 0;
|
|
|
|
else if (strcmp(var.value, "english") == 0)
|
2014-02-07 22:34:14 +00:00
|
|
|
setting_ngp_language = 1;
|
2013-05-24 16:59:38 +00:00
|
|
|
retro_reset();
|
|
|
|
}
|
2014-03-08 13:32:15 +00:00
|
|
|
#elif defined (WANT_GBA_EMU)
|
|
|
|
var.key = "gba_hle";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
|
|
|
if (strcmp(var.value, "enabled") == 0)
|
|
|
|
setting_gba_hle = 1;
|
|
|
|
else if (strcmp(var.value, "disabled") == 0)
|
|
|
|
setting_gba_hle = 0;
|
|
|
|
}
|
2014-02-07 22:34:14 +00:00
|
|
|
#elif defined (WANT_VB_EMU)
|
|
|
|
var.key = "vb_color_mode";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
2014-02-08 01:41:05 +00:00
|
|
|
if (strcmp(var.value, "black & red") == 0)
|
|
|
|
{
|
2014-02-07 22:34:14 +00:00
|
|
|
setting_vb_lcolor = 0xFF0000;
|
2014-02-08 01:41:05 +00:00
|
|
|
setting_vb_rcolor = 0x000000;
|
|
|
|
}
|
|
|
|
else if (strcmp(var.value, "black & white") == 0)
|
|
|
|
{
|
2014-02-07 22:34:14 +00:00
|
|
|
setting_vb_lcolor = 0xFFFFFF;
|
2014-02-08 01:41:05 +00:00
|
|
|
setting_vb_rcolor = 0x000000;
|
|
|
|
}
|
|
|
|
log_cb(RETRO_LOG_INFO, "[%s]: Palette changed: %s .\n", mednafen_core_str, var.value);
|
2014-02-07 22:34:14 +00:00
|
|
|
}
|
2014-02-08 01:41:05 +00:00
|
|
|
|
|
|
|
var.key = "vb_anaglyph_preset";
|
|
|
|
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(var.value, "disabled") == 0)
|
|
|
|
setting_vb_anaglyph_preset = 0;
|
|
|
|
else if (strcmp(var.value, "red & blue") == 0)
|
|
|
|
setting_vb_anaglyph_preset = 1;
|
|
|
|
else if (strcmp(var.value, "red & cyan") == 0)
|
|
|
|
setting_vb_anaglyph_preset = 2;
|
|
|
|
else if (strcmp(var.value, "red & electric cyan") == 0)
|
|
|
|
setting_vb_anaglyph_preset = 3;
|
|
|
|
else if (strcmp(var.value, "red & green") == 0)
|
|
|
|
setting_vb_anaglyph_preset = 4;
|
|
|
|
else if (strcmp(var.value, "green & magenta") == 0)
|
|
|
|
setting_vb_anaglyph_preset = 5;
|
|
|
|
else if (strcmp(var.value, "yellow & blue") == 0)
|
|
|
|
setting_vb_anaglyph_preset = 6;
|
|
|
|
|
|
|
|
log_cb(RETRO_LOG_INFO, "[%s]: Palette changed: %s .\n", mednafen_core_str, var.value);
|
|
|
|
}
|
2013-04-09 02:05:18 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-06-18 16:27:13 +00:00
|
|
|
#if defined(WANT_PCE_FAST_EMU)
|
2013-04-09 03:23:42 +00:00
|
|
|
|
|
|
|
#define MAX_PLAYERS 5
|
|
|
|
#define MAX_BUTTONS 13
|
|
|
|
static uint8_t input_buf[MAX_PLAYERS][2] = {0};
|
|
|
|
|
2013-12-18 20:42:11 +00:00
|
|
|
#elif defined(WANT_LYNX_EMU)
|
|
|
|
|
|
|
|
#define MAX_PLAYERS 1
|
|
|
|
#define MAX_BUTTONS 9
|
|
|
|
static uint8_t input_buf[MAX_PLAYERS][2] = {0};
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
#elif defined(WANT_WSWAN_EMU)
|
|
|
|
|
|
|
|
#define MAX_PLAYERS 1
|
|
|
|
#define MAX_BUTTONS 11
|
|
|
|
static uint16_t input_buf;
|
|
|
|
|
|
|
|
#elif defined(WANT_NGP_EMU)
|
|
|
|
|
|
|
|
#define MAX_PLAYERS 1
|
2013-08-10 01:46:37 +00:00
|
|
|
#define MAX_BUTTONS 7
|
|
|
|
static uint8_t input_buf;
|
2013-04-09 03:23:42 +00:00
|
|
|
|
|
|
|
#elif defined(WANT_GBA_EMU)
|
|
|
|
|
|
|
|
#define MAX_PLAYERS 1
|
|
|
|
#define MAX_BUTTONS 11
|
|
|
|
static uint16_t input_buf;
|
|
|
|
|
|
|
|
#elif defined(WANT_SNES_EMU)
|
|
|
|
|
|
|
|
#define MAX_PLAYERS 5
|
|
|
|
#define MAX_BUTTONS 14
|
|
|
|
static uint8_t input_buf[MAX_PLAYERS][2];
|
|
|
|
|
|
|
|
#elif defined(WANT_VB_EMU)
|
|
|
|
|
|
|
|
#define MAX_PLAYERS 1
|
|
|
|
#define MAX_BUTTONS 14
|
|
|
|
static uint16_t input_buf[MAX_PLAYERS];
|
|
|
|
|
|
|
|
#elif defined(WANT_PCFX_EMU)
|
|
|
|
|
|
|
|
#define MAX_PLAYERS 2
|
|
|
|
#define MAX_BUTTONS 12
|
|
|
|
static uint16_t input_buf[MAX_PLAYERS];
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define MAX_PLAYERS 1
|
|
|
|
#define MAX_BUTTONS 7
|
|
|
|
|
|
|
|
static uint16_t input_buf[1];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void hookup_ports(bool force)
|
|
|
|
{
|
|
|
|
MDFNGI *currgame = game;
|
|
|
|
|
|
|
|
if (initial_ports_hookup && !force)
|
|
|
|
return;
|
|
|
|
|
2014-05-01 00:17:23 +00:00
|
|
|
#if defined(WANT_PCE_FAST_EMU)
|
2013-04-09 03:23:42 +00:00
|
|
|
// Possible endian bug ...
|
|
|
|
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
currgame->SetInput(i, "gamepad", &input_buf[i][0]);
|
2013-12-18 20:42:11 +00:00
|
|
|
#elif defined(WANT_LYNX_EMU)
|
|
|
|
currgame->SetInput(0, "gamepad", &input_buf);
|
2013-04-09 03:23:42 +00:00
|
|
|
#elif defined(WANT_WSWAN_EMU)
|
|
|
|
currgame->SetInput(0, "gamepad", &input_buf);
|
|
|
|
#elif defined(WANT_NGP_EMU)
|
|
|
|
currgame->SetInput(0, "gamepad", &input_buf);
|
|
|
|
#elif defined(WANT_GBA_EMU)
|
|
|
|
// Possible endian bug ...
|
|
|
|
currgame->SetInput(0, "gamepad", &input_buf);
|
|
|
|
#elif defined(WANT_SNES_EMU)
|
|
|
|
// Possible endian bug ...
|
|
|
|
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
currgame->SetInput(i, "gamepad", &input_buf[i][0]);
|
|
|
|
#elif defined(WANT_VB_EMU)
|
|
|
|
// Possible endian bug ...
|
|
|
|
currgame->SetInput(0, "gamepad", &input_buf[0]);
|
|
|
|
#else
|
|
|
|
// Possible endian bug ...
|
|
|
|
currgame->SetInput(0, "gamepad", &input_buf[0]);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
initial_ports_hookup = true;
|
|
|
|
}
|
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
bool retro_load_game(const struct retro_game_info *info)
|
|
|
|
{
|
2012-06-15 23:00:17 +00:00
|
|
|
if (failed_init)
|
|
|
|
return false;
|
|
|
|
|
2012-10-20 23:47:02 +00:00
|
|
|
#ifdef WANT_32BPP
|
2012-06-16 13:07:18 +00:00
|
|
|
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
|
2013-12-17 10:08:34 +00:00
|
|
|
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
|
2012-10-21 00:37:11 +00:00
|
|
|
{
|
2013-12-17 01:24:08 +00:00
|
|
|
if (log_cb)
|
|
|
|
log_cb(RETRO_LOG_ERROR, "Pixel format XRGB8888 not supported by platform, cannot use %s.\n", MEDNAFEN_CORE_NAME);
|
2012-10-21 00:37:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-10-20 23:47:02 +00:00
|
|
|
#endif
|
2012-06-16 13:07:18 +00:00
|
|
|
|
2013-02-25 19:39:39 +00:00
|
|
|
overscan = false;
|
|
|
|
environ_cb(RETRO_ENVIRONMENT_GET_OVERSCAN, &overscan);
|
|
|
|
|
2013-04-27 14:40:24 +00:00
|
|
|
set_basename(info->path);
|
2012-10-13 13:31:49 +00:00
|
|
|
|
2014-03-08 13:32:15 +00:00
|
|
|
#if defined(WANT_GBA_EMU)
|
|
|
|
check_variables();
|
|
|
|
#endif
|
|
|
|
|
2014-02-08 01:41:05 +00:00
|
|
|
#if defined(WANT_VB_EMU)
|
|
|
|
check_variables();
|
|
|
|
#endif
|
|
|
|
|
2012-10-20 23:47:02 +00:00
|
|
|
game = MDFNI_LoadGame(MEDNAFEN_CORE_NAME_MODULE, info->path);
|
2012-09-23 09:52:47 +00:00
|
|
|
if (!game)
|
|
|
|
return false;
|
|
|
|
|
2012-08-22 19:38:30 +00:00
|
|
|
MDFN_PixelFormat pix_fmt(MDFN_COLORSPACE_RGB, 16, 8, 0, 24);
|
2012-11-16 14:12:25 +00:00
|
|
|
memset(&last_pixel_format, 0, sizeof(MDFN_PixelFormat));
|
2013-10-01 12:28:59 +00:00
|
|
|
|
2012-10-22 15:00:42 +00:00
|
|
|
surf = new MDFN_Surface(mednafen_buf, FB_WIDTH, FB_HEIGHT, FB_WIDTH, pix_fmt);
|
2012-10-13 13:31:49 +00:00
|
|
|
|
2012-11-16 14:12:25 +00:00
|
|
|
#ifdef NEED_DEINTERLACER
|
|
|
|
PrevInterlaced = false;
|
|
|
|
deint.ClearState();
|
|
|
|
#endif
|
|
|
|
|
2014-06-18 16:27:13 +00:00
|
|
|
#if !defined(WANT_PCE_FAST_EMU) || !defined(WANT_PCFX_EMU)
|
2013-04-09 03:23:42 +00:00
|
|
|
hookup_ports(true);
|
2014-05-01 00:32:39 +00:00
|
|
|
#endif
|
2013-04-09 03:23:42 +00:00
|
|
|
|
2013-09-17 00:03:54 +00:00
|
|
|
check_variables();
|
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
return game;
|
|
|
|
}
|
|
|
|
|
|
|
|
void retro_unload_game()
|
|
|
|
{
|
2013-01-19 09:22:57 +00:00
|
|
|
if (!game)
|
|
|
|
return;
|
2012-11-29 22:21:44 +00:00
|
|
|
|
2014-04-20 19:44:56 +00:00
|
|
|
MDFNI_CloseGame();
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
|
2012-07-25 01:17:14 +00:00
|
|
|
|
2012-06-03 16:58:46 +00:00
|
|
|
// Hardcoded for PSX. No reason to parse lots of structures ...
|
|
|
|
// See mednafen/psx/input/gamepad.cpp
|
2012-10-20 21:32:28 +00:00
|
|
|
static void update_input(void)
|
2012-06-03 16:58:46 +00:00
|
|
|
{
|
2014-04-20 19:44:56 +00:00
|
|
|
MDFNGI *currgame = (MDFNGI*)game;
|
2014-06-18 16:27:13 +00:00
|
|
|
#if defined(WANT_LYNX_EMU)
|
2013-12-18 20:42:11 +00:00
|
|
|
static unsigned map[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_START,
|
|
|
|
};
|
|
|
|
|
|
|
|
for (unsigned j = 0; j < MAX_PLAYERS; j++)
|
|
|
|
{
|
|
|
|
uint16_t input_state = 0;
|
|
|
|
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
|
|
|
input_state |= input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
|
|
|
|
|
|
|
// Input data must be little endian.
|
|
|
|
input_buf[j][0] = (input_state >> 0) & 0xff;
|
|
|
|
input_buf[j][1] = (input_state >> 8) & 0xff;
|
|
|
|
}
|
2012-10-20 23:47:02 +00:00
|
|
|
#elif defined(WANT_PCE_FAST_EMU)
|
|
|
|
|
|
|
|
static unsigned map[] = {
|
2012-11-22 20:03:38 +00:00
|
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
2012-10-20 23:47:02 +00:00
|
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_START,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
2012-11-22 20:03:38 +00:00
|
|
|
RETRO_DEVICE_ID_JOYPAD_Y,
|
2012-10-20 23:47:02 +00:00
|
|
|
RETRO_DEVICE_ID_JOYPAD_X,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L2
|
|
|
|
};
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned j = 0; j < MAX_PLAYERS; j++)
|
2012-10-20 23:47:02 +00:00
|
|
|
{
|
2013-04-09 03:23:42 +00:00
|
|
|
uint16_t input_state = 0;
|
|
|
|
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
|
|
|
input_state |= input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
2012-10-20 23:47:02 +00:00
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
// Input data must be little endian.
|
|
|
|
input_buf[j][0] = (input_state >> 0) & 0xff;
|
|
|
|
input_buf[j][1] = (input_state >> 8) & 0xff;
|
2012-10-20 23:47:02 +00:00
|
|
|
}
|
2012-10-22 12:34:14 +00:00
|
|
|
#elif defined(WANT_WSWAN_EMU)
|
|
|
|
input_buf = 0;
|
|
|
|
|
|
|
|
static unsigned map[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP, //X Cursor horizontal-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT, //X Cursor horizontal-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN, //X Cursor horizontal-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT, //X Cursor horizontal-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R2, //Y Cursor UP vertical-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R, //Y Cursor RIGHT vertical-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L2, //Y Cursor DOWN vertical-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L, //Y Cursor LEFT vertical-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_START,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
|
|
|
};
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
2012-11-24 06:44:49 +00:00
|
|
|
input_buf |= map[i] != -1u &&
|
|
|
|
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
2012-10-22 12:34:14 +00:00
|
|
|
|
|
|
|
#ifdef MSB_FIRST
|
|
|
|
union {
|
|
|
|
uint8_t b[2];
|
|
|
|
uint16_t s;
|
|
|
|
} u;
|
|
|
|
u.s = input_buf;
|
|
|
|
input_buf = u.b[0] | u.b[1] << 8;
|
|
|
|
#endif
|
|
|
|
|
2012-11-27 02:38:27 +00:00
|
|
|
#elif defined(WANT_NGP_EMU)
|
|
|
|
input_buf = 0;
|
|
|
|
|
|
|
|
static unsigned map[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP, //X Cursor horizontal-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN, //X Cursor horizontal-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT, //X Cursor horizontal-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT, //X Cursor horizontal-layout games
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_START,
|
|
|
|
};
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
2012-11-27 02:38:27 +00:00
|
|
|
input_buf |= map[i] != -1u &&
|
|
|
|
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
|
|
|
|
|
|
|
#ifdef MSB_FIRST
|
|
|
|
union {
|
|
|
|
uint8_t b[2];
|
|
|
|
uint16_t s;
|
|
|
|
} u;
|
|
|
|
u.s = input_buf;
|
|
|
|
input_buf = u.b[0] | u.b[1] << 8;
|
|
|
|
#endif
|
|
|
|
|
2012-11-24 07:17:18 +00:00
|
|
|
#elif defined(WANT_GBA_EMU)
|
|
|
|
input_buf = 0;
|
|
|
|
static unsigned map[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A, //A button
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B, //B button
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_START,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L,
|
|
|
|
};
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
2012-11-24 07:17:18 +00:00
|
|
|
input_buf |= map[i] != -1u &&
|
|
|
|
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
|
|
|
|
2012-11-27 04:54:01 +00:00
|
|
|
#ifdef MSB_FIRST
|
|
|
|
union {
|
|
|
|
uint8_t b[2];
|
|
|
|
uint16_t s;
|
|
|
|
} u;
|
|
|
|
u.s = input_buf;
|
|
|
|
input_buf = u.b[0] | u.b[1] << 8;
|
|
|
|
#endif
|
|
|
|
|
2012-11-24 16:14:05 +00:00
|
|
|
#elif defined(WANT_SNES_EMU)
|
|
|
|
|
|
|
|
static unsigned map[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_Y,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_START,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_X,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R,
|
|
|
|
};
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned j = 0; j < MAX_PLAYERS; j++)
|
2012-11-24 16:14:05 +00:00
|
|
|
{
|
2013-04-09 03:23:42 +00:00
|
|
|
uint16_t input_state = 0;
|
|
|
|
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
|
|
|
input_state |= input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
2012-11-24 16:14:05 +00:00
|
|
|
|
2012-11-27 03:05:55 +00:00
|
|
|
#ifdef MSB_FIRST
|
|
|
|
union {
|
|
|
|
uint8_t b[2];
|
|
|
|
uint16_t s;
|
|
|
|
} u;
|
|
|
|
u.s = input_buf[j];
|
|
|
|
input_buf[j] = u.b[0] | u.b[1] << 8;
|
2012-11-27 03:16:48 +00:00
|
|
|
#else
|
|
|
|
input_buf[j][0] = (input_state >> 0) & 0xff;
|
|
|
|
input_buf[j][1] = (input_state >> 8) & 0xff;
|
2012-11-27 03:05:55 +00:00
|
|
|
#endif
|
2012-11-24 16:14:05 +00:00
|
|
|
}
|
|
|
|
|
2012-11-25 02:41:54 +00:00
|
|
|
#elif defined(WANT_VB_EMU)
|
|
|
|
input_buf[0] = 0;
|
|
|
|
static unsigned map[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L2, //right d-pad UP
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R3, //right d-pad RIGHT
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT, //left d-pad
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT, //left d-pad
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN, //left d-pad
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP, //left d-pad
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_START,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R2, //right d-pad LEFT
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L3, //right d-pad DOWN
|
|
|
|
};
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned j = 0; j < MAX_PLAYERS; j++)
|
2012-11-25 02:41:54 +00:00
|
|
|
{
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
2012-11-25 02:41:54 +00:00
|
|
|
input_buf[j] |= map[i] != -1u &&
|
|
|
|
input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
2012-11-27 03:05:55 +00:00
|
|
|
|
|
|
|
#ifdef MSB_FIRST
|
|
|
|
union {
|
|
|
|
uint8_t b[2];
|
|
|
|
uint16_t s;
|
|
|
|
} u;
|
|
|
|
u.s = input_buf[j];
|
|
|
|
input_buf[j] = u.b[0] | u.b[1] << 8;
|
|
|
|
#endif
|
2012-11-25 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
2012-11-28 07:20:45 +00:00
|
|
|
#elif defined(WANT_PCFX_EMU)
|
|
|
|
input_buf[0] = input_buf[1] = 0;
|
|
|
|
static unsigned map[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_X,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_Y,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_L,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_R,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_START,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
|
|
|
};
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned j = 0; j < MAX_PLAYERS; j++)
|
2012-11-28 07:20:45 +00:00
|
|
|
{
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
2012-11-28 07:20:45 +00:00
|
|
|
input_buf[j] |= map[i] != -1u &&
|
|
|
|
input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
|
|
|
|
|
|
|
#ifdef MSB_FIRST
|
|
|
|
union {
|
|
|
|
uint8_t b[2];
|
|
|
|
uint16_t s;
|
|
|
|
} u;
|
|
|
|
u.s = input_buf[j];
|
|
|
|
input_buf[j] = u.b[0] | u.b[1] << 8;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
2012-11-24 06:44:49 +00:00
|
|
|
#else
|
|
|
|
input_buf[0] = 0;
|
|
|
|
static unsigned map[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A, //A button
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B, //B button
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_START, //Option button
|
|
|
|
};
|
|
|
|
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned j = 0; j < MAX_PLAYERS; j++)
|
2012-11-24 06:44:49 +00:00
|
|
|
{
|
2013-04-09 03:23:42 +00:00
|
|
|
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
2012-11-24 06:44:49 +00:00
|
|
|
input_buf[j] |= map[i] != -1u &&
|
|
|
|
input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
|
|
|
}
|
|
|
|
|
2012-10-20 21:32:28 +00:00
|
|
|
#endif
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 19:38:19 +00:00
|
|
|
static uint64_t video_frames, audio_frames;
|
|
|
|
|
2013-04-09 02:05:18 +00:00
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
void retro_run()
|
|
|
|
{
|
2012-11-29 22:21:44 +00:00
|
|
|
MDFNGI *curgame = game;
|
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
input_poll_cb();
|
|
|
|
|
2012-06-03 16:58:46 +00:00
|
|
|
update_input();
|
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
static int16_t sound_buf[0x10000];
|
2013-10-01 12:28:59 +00:00
|
|
|
static MDFN_Rect rects[FB_MAX_HEIGHT];
|
2012-06-16 13:07:18 +00:00
|
|
|
rects[0].w = ~0;
|
2012-06-03 15:48:14 +00:00
|
|
|
|
2012-07-25 01:17:14 +00:00
|
|
|
EmulateSpecStruct spec = {0};
|
2012-06-03 15:48:14 +00:00
|
|
|
spec.surface = surf;
|
|
|
|
spec.SoundRate = 44100;
|
|
|
|
spec.SoundBuf = sound_buf;
|
|
|
|
spec.LineWidths = rects;
|
|
|
|
spec.SoundBufMaxSize = sizeof(sound_buf) / 2;
|
|
|
|
spec.SoundVolume = 1.0;
|
|
|
|
spec.soundmultiplier = 1.0;
|
2012-11-16 14:12:25 +00:00
|
|
|
spec.SoundBufSize = 0;
|
|
|
|
spec.VideoFormatChanged = false;
|
|
|
|
spec.SoundFormatChanged = false;
|
|
|
|
|
2013-01-19 09:22:57 +00:00
|
|
|
if (memcmp(&last_pixel_format, &spec.surface->format, sizeof(MDFN_PixelFormat)))
|
2012-11-16 14:12:25 +00:00
|
|
|
{
|
|
|
|
spec.VideoFormatChanged = TRUE;
|
|
|
|
|
|
|
|
last_pixel_format = spec.surface->format;
|
|
|
|
}
|
|
|
|
|
2013-01-19 09:22:57 +00:00
|
|
|
if (spec.SoundRate != last_sound_rate)
|
2012-11-16 14:12:25 +00:00
|
|
|
{
|
|
|
|
spec.SoundFormatChanged = true;
|
|
|
|
last_sound_rate = spec.SoundRate;
|
|
|
|
}
|
|
|
|
|
2012-11-29 22:21:44 +00:00
|
|
|
curgame->Emulate(&spec);
|
2012-11-16 14:12:25 +00:00
|
|
|
|
|
|
|
#ifdef NEED_DEINTERLACER
|
2013-01-19 09:22:57 +00:00
|
|
|
if (spec.InterlaceOn)
|
2012-11-16 14:12:25 +00:00
|
|
|
{
|
2013-01-19 09:22:57 +00:00
|
|
|
if (!PrevInterlaced)
|
2012-11-16 14:12:25 +00:00
|
|
|
deint.ClearState();
|
|
|
|
|
|
|
|
deint.Process(spec.surface, spec.DisplayRect, spec.LineWidths, spec.InterlaceField);
|
|
|
|
|
|
|
|
PrevInterlaced = true;
|
|
|
|
|
|
|
|
spec.InterlaceOn = false;
|
|
|
|
spec.InterlaceField = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
PrevInterlaced = false;
|
|
|
|
#endif
|
|
|
|
|
2012-11-29 22:21:44 +00:00
|
|
|
int16 *const SoundBuf = spec.SoundBuf + spec.SoundBufSizeALMS * curgame->soundchan;
|
2012-11-16 14:12:25 +00:00
|
|
|
int32 SoundBufSize = spec.SoundBufSize - spec.SoundBufSizeALMS;
|
|
|
|
const int32 SoundBufMaxSize = spec.SoundBufMaxSize - spec.SoundBufSizeALMS;
|
2012-06-03 15:48:14 +00:00
|
|
|
|
2012-11-16 14:12:25 +00:00
|
|
|
spec.SoundBufSize = spec.SoundBufSizeALMS + SoundBufSize;
|
2012-06-03 15:48:14 +00:00
|
|
|
|
2012-11-21 01:27:23 +00:00
|
|
|
unsigned width = spec.DisplayRect.w;
|
|
|
|
unsigned height = spec.DisplayRect.h;
|
2012-10-20 21:56:43 +00:00
|
|
|
|
2013-02-23 23:45:47 +00:00
|
|
|
#if defined(WANT_32BPP)
|
2012-11-21 01:28:26 +00:00
|
|
|
const uint32_t *pix = surf->pixels;
|
2012-11-21 01:27:23 +00:00
|
|
|
video_cb(pix, width, height, FB_WIDTH << 2);
|
2012-10-22 12:34:14 +00:00
|
|
|
#elif defined(WANT_16BPP)
|
2012-10-20 23:47:02 +00:00
|
|
|
const uint16_t *pix = surf->pixels16;
|
|
|
|
video_cb(pix, width, height, FB_WIDTH << 1);
|
2012-10-20 21:56:43 +00:00
|
|
|
#endif
|
2012-06-03 15:48:14 +00:00
|
|
|
|
2012-09-20 19:38:19 +00:00
|
|
|
video_frames++;
|
|
|
|
audio_frames += spec.SoundBufSize;
|
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
audio_batch_cb(spec.SoundBuf, spec.SoundBufSize);
|
2013-04-09 02:05:18 +00:00
|
|
|
|
|
|
|
bool updated = false;
|
|
|
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
|
|
|
|
check_variables();
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void retro_get_system_info(struct retro_system_info *info)
|
|
|
|
{
|
|
|
|
memset(info, 0, sizeof(*info));
|
2012-10-20 21:32:28 +00:00
|
|
|
info->library_name = MEDNAFEN_CORE_NAME;
|
2012-10-22 12:34:14 +00:00
|
|
|
info->library_version = MEDNAFEN_CORE_VERSION;
|
2012-06-03 15:48:14 +00:00
|
|
|
info->need_fullpath = true;
|
2012-10-20 21:56:43 +00:00
|
|
|
info->valid_extensions = MEDNAFEN_CORE_EXTENSIONS;
|
2012-10-20 23:47:02 +00:00
|
|
|
info->block_extract = false;
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void retro_get_system_av_info(struct retro_system_av_info *info)
|
|
|
|
{
|
|
|
|
memset(info, 0, sizeof(*info));
|
2013-10-01 12:28:59 +00:00
|
|
|
info->timing.fps = MEDNAFEN_CORE_TIMING_FPS;
|
2012-06-03 15:48:14 +00:00
|
|
|
info->timing.sample_rate = 44100;
|
2012-10-20 21:56:43 +00:00
|
|
|
info->geometry.base_width = MEDNAFEN_CORE_GEOMETRY_BASE_W;
|
|
|
|
info->geometry.base_height = MEDNAFEN_CORE_GEOMETRY_BASE_H;
|
|
|
|
info->geometry.max_width = MEDNAFEN_CORE_GEOMETRY_MAX_W;
|
|
|
|
info->geometry.max_height = MEDNAFEN_CORE_GEOMETRY_MAX_H;
|
|
|
|
info->geometry.aspect_ratio = MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO;
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 19:38:19 +00:00
|
|
|
void retro_deinit()
|
|
|
|
{
|
|
|
|
delete surf;
|
|
|
|
surf = NULL;
|
|
|
|
|
2013-12-17 01:24:08 +00:00
|
|
|
if (log_cb)
|
|
|
|
{
|
|
|
|
log_cb(RETRO_LOG_INFO, "[%s]: Samples / Frame: %.5f\n",
|
|
|
|
mednafen_core_str, (double)audio_frames / video_frames);
|
|
|
|
log_cb(RETRO_LOG_INFO, "[%s]: Estimated FPS: %.5f\n",
|
|
|
|
mednafen_core_str, (double)video_frames * 44100 / audio_frames);
|
|
|
|
}
|
2012-09-20 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
unsigned retro_get_region(void)
|
|
|
|
{
|
2013-10-01 12:28:59 +00:00
|
|
|
return RETRO_REGION_NTSC; // FIXME: Regions for other cores.
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned retro_api_version(void)
|
|
|
|
{
|
|
|
|
return RETRO_API_VERSION;
|
|
|
|
}
|
|
|
|
|
2012-07-25 01:17:14 +00:00
|
|
|
void retro_set_controller_port_device(unsigned in_port, unsigned device)
|
|
|
|
{
|
2014-05-01 00:17:23 +00:00
|
|
|
MDFNGI *currgame = (MDFNGI*)game;
|
|
|
|
|
|
|
|
if (!currgame)
|
2012-08-17 21:01:08 +00:00
|
|
|
return;
|
|
|
|
|
2014-05-01 00:32:39 +00:00
|
|
|
#if defined(WANT_PCE_FAST_EMU)
|
|
|
|
switch(device)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_JOYPAD:
|
|
|
|
if (currgame->SetInput)
|
|
|
|
currgame->SetInput(in_port, "gamepad", &input_buf[in_port][0]);
|
|
|
|
break;
|
|
|
|
case RETRO_DEVICE_MOUSE:
|
|
|
|
if (currgame->SetInput)
|
|
|
|
currgame->SetInput(in_port, "mouse", &input_buf[in_port][0]);
|
|
|
|
break;
|
|
|
|
}
|
2014-05-01 00:43:04 +00:00
|
|
|
#elif defined(WANT_PCFX_EMU)
|
|
|
|
switch(device)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_JOYPAD:
|
|
|
|
if (currgame->SetInput)
|
|
|
|
currgame->SetInput(in_port, "gamepad", &input_buf[in_port]);
|
|
|
|
break;
|
|
|
|
case RETRO_DEVICE_MOUSE:
|
|
|
|
if (currgame->SetInput)
|
|
|
|
currgame->SetInput(in_port, "mouse", &input_buf[in_port]);
|
|
|
|
break;
|
|
|
|
}
|
2012-10-20 23:47:02 +00:00
|
|
|
#endif
|
2012-07-25 01:17:14 +00:00
|
|
|
}
|
2012-06-03 15:48:14 +00:00
|
|
|
|
|
|
|
void retro_set_environment(retro_environment_t cb)
|
|
|
|
{
|
|
|
|
environ_cb = cb;
|
2013-04-09 02:05:18 +00:00
|
|
|
|
|
|
|
#if defined(WANT_PCE_FAST_EMU)
|
|
|
|
static const struct retro_variable vars[] = {
|
|
|
|
{ "pce_nospritelimit", "No Sprite Limit; disabled|enabled" },
|
2013-05-24 15:37:36 +00:00
|
|
|
{ "pce_keepaspect", "Keep Aspect; enabled|disabled" },
|
2014-06-05 16:06:15 +00:00
|
|
|
{ "pce_cddavolume", "(CD) CDDA Volume; 0|10|20|30|40|50|60|70|80|90|100" },
|
|
|
|
{ "pce_adpcmvolume", "(CD) ADPCM Volume; 0|10|20|30|40|50|60|70|80|90|100" },
|
|
|
|
{ "pce_cdpsgvolume", "(CD) CD PSG Volume; 0|10|20|30|40|50|60|70|80|90|100" },
|
2013-05-24 15:26:57 +00:00
|
|
|
{ "pce_cdspeed", "(CD) CD Speed; 1|2|4|8" },
|
2013-04-09 02:05:18 +00:00
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
2014-05-01 00:43:04 +00:00
|
|
|
|
|
|
|
static const struct retro_controller_description pads[] = {
|
|
|
|
{ "PCE Joypad", RETRO_DEVICE_JOYPAD },
|
|
|
|
{ "Mouse", RETRO_DEVICE_MOUSE },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct retro_controller_info ports[] = {
|
|
|
|
{ pads, 2 },
|
|
|
|
{ pads, 2 },
|
|
|
|
{ 0 },
|
|
|
|
};
|
|
|
|
|
2013-05-19 17:55:15 +00:00
|
|
|
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
2014-05-01 00:43:04 +00:00
|
|
|
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
|
|
|
#elif defined(WANT_PCFX_EMU)
|
|
|
|
static const struct retro_controller_description pads[] = {
|
|
|
|
{ "PCFX Joypad", RETRO_DEVICE_JOYPAD },
|
|
|
|
{ "Mouse", RETRO_DEVICE_MOUSE },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct retro_controller_info ports[] = {
|
|
|
|
{ pads, 2 },
|
|
|
|
{ pads, 2 },
|
|
|
|
{ 0 },
|
|
|
|
};
|
|
|
|
|
2014-05-01 00:17:23 +00:00
|
|
|
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
2014-03-08 13:32:15 +00:00
|
|
|
#elif defined(WANT_GBA_EMU)
|
|
|
|
static const struct retro_variable vars[] = {
|
|
|
|
{ "gba_hle", "HLE bios emulation; enabled|disabled" },
|
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
2013-05-24 16:59:38 +00:00
|
|
|
#elif defined(WANT_NGP_EMU)
|
|
|
|
static const struct retro_variable vars[] = {
|
|
|
|
{ "ngp_language", "Language; japanese|english" },
|
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
2014-02-07 22:34:14 +00:00
|
|
|
#elif defined(WANT_VB_EMU)
|
|
|
|
static const struct retro_variable vars[] = {
|
2014-02-08 01:41:05 +00:00
|
|
|
{ "vb_anaglyph_preset", "Anaglyph preset (restart); disabled|red & blue|red & cyan|red & electric cyan|red & green|green & magenta|yellow & blue" },
|
|
|
|
{ "vb_color_mode", "Palette (restart); black & red|black & white" },
|
2014-02-07 22:34:14 +00:00
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
|
|
|
|
2013-05-19 17:55:15 +00:00
|
|
|
#endif
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void retro_set_audio_sample(retro_audio_sample_t cb)
|
|
|
|
{
|
|
|
|
audio_cb = cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb)
|
|
|
|
{
|
|
|
|
audio_batch_cb = cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
void retro_set_input_poll(retro_input_poll_t cb)
|
|
|
|
{
|
|
|
|
input_poll_cb = cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
void retro_set_input_state(retro_input_state_t cb)
|
|
|
|
{
|
|
|
|
input_state_cb = cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
void retro_set_video_refresh(retro_video_refresh_t cb)
|
|
|
|
{
|
|
|
|
video_cb = cb;
|
|
|
|
}
|
|
|
|
|
2012-10-20 23:47:02 +00:00
|
|
|
static size_t serialize_size;
|
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
size_t retro_serialize_size(void)
|
|
|
|
{
|
2014-04-20 19:44:56 +00:00
|
|
|
MDFNGI *curgame = (MDFNGI*)game;
|
2012-10-21 01:46:12 +00:00
|
|
|
//if (serialize_size)
|
|
|
|
// return serialize_size;
|
|
|
|
|
2012-11-29 22:21:44 +00:00
|
|
|
if (!curgame->StateAction)
|
2012-10-21 01:46:12 +00:00
|
|
|
{
|
2013-12-17 01:24:08 +00:00
|
|
|
if (log_cb)
|
|
|
|
log_cb(RETRO_LOG_WARN, "[mednafen]: Module %s doesn't support save states.\n", curgame->shortname);
|
2012-10-21 01:46:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
StateMem st;
|
|
|
|
memset(&st, 0, sizeof(st));
|
|
|
|
|
2012-11-14 00:41:02 +00:00
|
|
|
if (!MDFNSS_SaveSM(&st, 0, 0, NULL, NULL, NULL))
|
2012-10-21 01:46:12 +00:00
|
|
|
{
|
2013-12-17 01:24:08 +00:00
|
|
|
if (log_cb)
|
|
|
|
log_cb(RETRO_LOG_WARN, "[mednafen]: Module %s doesn't support save states.\n", curgame->shortname);
|
2012-10-21 01:46:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(st.data);
|
|
|
|
return serialize_size = st.len;
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
2012-10-21 01:46:12 +00:00
|
|
|
bool retro_serialize(void *data, size_t size)
|
2012-06-03 15:48:14 +00:00
|
|
|
{
|
2012-10-21 01:46:12 +00:00
|
|
|
StateMem st;
|
|
|
|
memset(&st, 0, sizeof(st));
|
|
|
|
st.data = (uint8_t*)data;
|
|
|
|
st.malloced = size;
|
|
|
|
|
2012-11-14 00:41:02 +00:00
|
|
|
return MDFNSS_SaveSM(&st, 0, 0, NULL, NULL, NULL);
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
2012-10-21 01:46:12 +00:00
|
|
|
bool retro_unserialize(const void *data, size_t size)
|
2012-06-03 15:48:14 +00:00
|
|
|
{
|
2012-10-21 01:46:12 +00:00
|
|
|
StateMem st;
|
|
|
|
memset(&st, 0, sizeof(st));
|
|
|
|
st.data = (uint8_t*)data;
|
|
|
|
st.len = size;
|
|
|
|
|
2012-11-14 00:41:02 +00:00
|
|
|
return MDFNSS_LoadSM(&st, 0, 0);
|
2012-06-03 15:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *retro_get_memory_data(unsigned)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t retro_get_memory_size(unsigned)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void retro_cheat_reset(void)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void retro_cheat_set(unsigned, bool, const char *)
|
|
|
|
{}
|