mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
Yay, works :)
This commit is contained in:
parent
29addd605e
commit
efed98d5b6
@ -245,6 +245,7 @@ static const struct snes_keybind snes_keybinds_1[] = {
|
|||||||
{ SSNES_CHEAT_INDEX_PLUS, SDLK_y, NO_BTN, AXIS_NONE },
|
{ SSNES_CHEAT_INDEX_PLUS, SDLK_y, NO_BTN, AXIS_NONE },
|
||||||
{ SSNES_CHEAT_INDEX_MINUS, SDLK_t, NO_BTN, AXIS_NONE },
|
{ SSNES_CHEAT_INDEX_MINUS, SDLK_t, NO_BTN, AXIS_NONE },
|
||||||
{ SSNES_CHEAT_TOGGLE, SDLK_u, NO_BTN, AXIS_NONE },
|
{ SSNES_CHEAT_TOGGLE, SDLK_u, NO_BTN, AXIS_NONE },
|
||||||
|
{ SSNES_SCREENSHOT, SDLK_PRINT, NO_BTN, AXIS_NONE },
|
||||||
{ -1 }
|
{ -1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
3
driver.h
3
driver.h
@ -44,7 +44,8 @@ enum
|
|||||||
SSNES_SHADER_PREV,
|
SSNES_SHADER_PREV,
|
||||||
SSNES_CHEAT_INDEX_PLUS,
|
SSNES_CHEAT_INDEX_PLUS,
|
||||||
SSNES_CHEAT_INDEX_MINUS,
|
SSNES_CHEAT_INDEX_MINUS,
|
||||||
SSNES_CHEAT_TOGGLE
|
SSNES_CHEAT_TOGGLE,
|
||||||
|
SSNES_SCREENSHOT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define MAX_PLAYERS 5
|
#define MAX_PLAYERS 5
|
||||||
#define MAX_BINDS 31 // Needs to be increased every time there are new binds added.
|
#define MAX_BINDS 32 // Needs to be increased every time there are new binds added.
|
||||||
#define SSNES_NO_JOYPAD 0xFFFF
|
#define SSNES_NO_JOYPAD 0xFFFF
|
||||||
|
|
||||||
enum ssnes_shader_type
|
enum ssnes_shader_type
|
||||||
@ -121,6 +121,8 @@ struct settings
|
|||||||
char libsnes[256];
|
char libsnes[256];
|
||||||
char cheat_database[256];
|
char cheat_database[256];
|
||||||
|
|
||||||
|
char screenshot_directory[256];
|
||||||
|
|
||||||
bool rewind_enable;
|
bool rewind_enable;
|
||||||
unsigned rewind_buffer_size;
|
unsigned rewind_buffer_size;
|
||||||
unsigned rewind_granularity;
|
unsigned rewind_granularity;
|
||||||
@ -258,7 +260,9 @@ struct global
|
|||||||
size_t ptr;
|
size_t ptr;
|
||||||
} shader_dir;
|
} shader_dir;
|
||||||
|
|
||||||
char sha256[65];
|
char sha256[64 + 1];
|
||||||
|
|
||||||
|
bool do_screenshot;
|
||||||
|
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
cheat_manager_t *cheat;
|
cheat_manager_t *cheat;
|
||||||
|
@ -87,7 +87,7 @@ bool screenshot_dump(const char *folder, const uint16_t *frame,
|
|||||||
time(&cur_time);
|
time(&cur_time);
|
||||||
|
|
||||||
char timefmt[64];
|
char timefmt[64];
|
||||||
strftime(timefmt, sizeof(timefmt), "SSNES-%c", localtime(&cur_time));
|
strftime(timefmt, sizeof(timefmt), "SSNES-%c.bmp", localtime(&cur_time));
|
||||||
|
|
||||||
char filename[256];
|
char filename[256];
|
||||||
strlcpy(filename, folder, sizeof(filename));
|
strlcpy(filename, folder, sizeof(filename));
|
||||||
|
@ -374,6 +374,7 @@ static void parse_config_file(void)
|
|||||||
CONFIG_GET_STRING(audio.dsp_plugin, "audio_dsp_plugin");
|
CONFIG_GET_STRING(audio.dsp_plugin, "audio_dsp_plugin");
|
||||||
CONFIG_GET_STRING(input.driver, "input_driver");
|
CONFIG_GET_STRING(input.driver, "input_driver");
|
||||||
CONFIG_GET_STRING(libsnes, "libsnes_path");
|
CONFIG_GET_STRING(libsnes, "libsnes_path");
|
||||||
|
CONFIG_GET_STRING(screenshot_directory, "screenshot_directory");
|
||||||
|
|
||||||
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
|
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
|
||||||
|
|
||||||
@ -435,6 +436,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
|||||||
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
||||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||||
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DECLARE_BIND(player2_a, SNES_DEVICE_ID_JOYPAD_A)
|
DECLARE_BIND(player2_a, SNES_DEVICE_ID_JOYPAD_A)
|
||||||
@ -467,6 +469,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
|||||||
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
||||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||||
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DECLARE_BIND(player3_a, SNES_DEVICE_ID_JOYPAD_A)
|
DECLARE_BIND(player3_a, SNES_DEVICE_ID_JOYPAD_A)
|
||||||
@ -499,6 +502,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
|||||||
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
||||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||||
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DECLARE_BIND(player4_a, SNES_DEVICE_ID_JOYPAD_A)
|
DECLARE_BIND(player4_a, SNES_DEVICE_ID_JOYPAD_A)
|
||||||
@ -531,6 +535,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
|||||||
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
||||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||||
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DECLARE_BIND(player5_a, SNES_DEVICE_ID_JOYPAD_A)
|
DECLARE_BIND(player5_a, SNES_DEVICE_ID_JOYPAD_A)
|
||||||
@ -563,6 +568,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
|||||||
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
||||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||||
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
37
ssnes.c
37
ssnes.c
@ -32,6 +32,7 @@
|
|||||||
#include "movie.h"
|
#include "movie.h"
|
||||||
#include "netplay.h"
|
#include "netplay.h"
|
||||||
#include "strl.h"
|
#include "strl.h"
|
||||||
|
#include "screenshot.h"
|
||||||
#include "cheats.h"
|
#include "cheats.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#ifdef HAVE_SRC
|
#ifdef HAVE_SRC
|
||||||
@ -78,6 +79,30 @@ static void set_fast_forward_button(bool new_button_state)
|
|||||||
old_button_state = new_button_state;
|
old_button_state = new_button_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void take_screenshot(const uint16_t *frame, unsigned width, unsigned height)
|
||||||
|
{
|
||||||
|
if (!*(g_settings.screenshot_directory))
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool ret = screenshot_dump(g_settings.screenshot_directory, frame,
|
||||||
|
width, height, (height == 448 || height == 478) ? 1024 : 2048);
|
||||||
|
|
||||||
|
const char *msg = NULL;
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
SSNES_LOG("Taking screenshot!\n");
|
||||||
|
msg = "Taking screenshot!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SSNES_WARN("Failed to take screenshot ...\n");
|
||||||
|
msg = "Failed to take screenshot!";
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_queue_clear(g_extern.msg_queue);
|
||||||
|
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
||||||
|
}
|
||||||
|
|
||||||
// libsnes: 0.065
|
// libsnes: 0.065
|
||||||
// Format received is 16-bit 0RRRRRGGGGGBBBBB
|
// Format received is 16-bit 0RRRRRGGGGGBBBBB
|
||||||
static void video_frame(const uint16_t *data, unsigned width, unsigned height)
|
static void video_frame(const uint16_t *data, unsigned width, unsigned height)
|
||||||
@ -99,6 +124,9 @@ static void video_frame(const uint16_t *data, unsigned width, unsigned height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_extern.do_screenshot)
|
||||||
|
take_screenshot(data, width, height);
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
if (g_extern.recording)
|
if (g_extern.recording)
|
||||||
{
|
{
|
||||||
@ -1311,6 +1339,14 @@ static void check_cheats(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void check_screenshot(void)
|
||||||
|
{
|
||||||
|
static bool old_pressed = false;
|
||||||
|
bool pressed = driver.input->key_pressed(driver.input_data, SSNES_SCREENSHOT);
|
||||||
|
g_extern.do_screenshot = pressed && !old_pressed;
|
||||||
|
old_pressed = pressed;
|
||||||
|
}
|
||||||
|
|
||||||
static void do_state_checks(void)
|
static void do_state_checks(void)
|
||||||
{
|
{
|
||||||
if (!g_extern.netplay)
|
if (!g_extern.netplay)
|
||||||
@ -1342,6 +1378,7 @@ static void do_state_checks(void)
|
|||||||
|
|
||||||
check_fullscreen();
|
check_fullscreen();
|
||||||
check_input_rate();
|
check_input_rate();
|
||||||
|
check_screenshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_title_buf(void)
|
static void fill_title_buf(void)
|
||||||
|
@ -278,3 +278,9 @@
|
|||||||
# input_cheat_index_plus = y
|
# input_cheat_index_plus = y
|
||||||
# input_cheat_index_minus = t
|
# input_cheat_index_minus = t
|
||||||
# input_cheat_toggle = u
|
# input_cheat_toggle = u
|
||||||
|
|
||||||
|
# Take screenshot
|
||||||
|
# input_screenshot = print_screen
|
||||||
|
|
||||||
|
# Directory to dump screenshots to.
|
||||||
|
# screenshot_directory =
|
||||||
|
@ -97,6 +97,7 @@ static struct bind binds[] = {
|
|||||||
MISC_BIND("Toggle cheat on/off", cheat_toggle)
|
MISC_BIND("Toggle cheat on/off", cheat_toggle)
|
||||||
MISC_BIND("Cheat index plus", cheat_index_plus)
|
MISC_BIND("Cheat index plus", cheat_index_plus)
|
||||||
MISC_BIND("Cheat index minus", cheat_index_minus)
|
MISC_BIND("Cheat index minus", cheat_index_minus)
|
||||||
|
MISC_BIND("Screenshot", screenshot)
|
||||||
};
|
};
|
||||||
|
|
||||||
static void get_binds(config_file_t *conf, int player, int joypad)
|
static void get_binds(config_file_t *conf, int player, int joypad)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user