mirror of
https://github.com/libretro/RetroArch
synced 2025-02-08 15:40:14 +00:00
Some more logic hooked up.
This commit is contained in:
parent
b97c45df78
commit
2446300dd9
3
file.c
3
file.c
@ -22,6 +22,7 @@
|
|||||||
#include <libsnes.hpp>
|
#include <libsnes.hpp>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
|
#include "movie.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
@ -103,6 +104,8 @@ static ssize_t read_rom_file(FILE* file, void** buf)
|
|||||||
*buf = rom_buf;
|
*buf = rom_buf;
|
||||||
ret = length;
|
ret = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_extern.cart_crc = crc32_calculate(*buf, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "record/ffemu.h"
|
#include "record/ffemu.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "rewind.h"
|
#include "rewind.h"
|
||||||
|
#include "movie.h"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -155,6 +156,11 @@ struct global
|
|||||||
void *state_buf;
|
void *state_buf;
|
||||||
bool frame_is_reverse;
|
bool frame_is_reverse;
|
||||||
|
|
||||||
|
bsv_movie_t *bsv_movie;
|
||||||
|
char bsv_movie_path[256];
|
||||||
|
bool bsv_movie_end;
|
||||||
|
bool bsv_movie_playback;
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
ffemu_t *rec;
|
ffemu_t *rec;
|
||||||
char record_path[256];
|
char record_path[256];
|
||||||
|
60
ssnes.c
60
ssnes.c
@ -29,6 +29,7 @@
|
|||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
#include "record/ffemu.h"
|
#include "record/ffemu.h"
|
||||||
#include "rewind.h"
|
#include "rewind.h"
|
||||||
|
#include "movie.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#ifdef HAVE_SRC
|
#ifdef HAVE_SRC
|
||||||
#include <samplerate.h>
|
#include <samplerate.h>
|
||||||
@ -214,11 +215,27 @@ static void input_poll(void)
|
|||||||
|
|
||||||
static int16_t input_state(bool port, unsigned device, unsigned index, unsigned id)
|
static int16_t input_state(bool port, unsigned device, unsigned index, unsigned id)
|
||||||
{
|
{
|
||||||
|
if (g_extern.bsv_movie && g_extern.bsv_movie_playback)
|
||||||
|
{
|
||||||
|
int16_t ret;
|
||||||
|
if (bsv_movie_get_input(g_extern.bsv_movie, &ret))
|
||||||
|
return ret;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_extern.bsv_movie_end = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const struct snes_keybind *binds[MAX_PLAYERS];
|
const struct snes_keybind *binds[MAX_PLAYERS];
|
||||||
for (int i = 0; i < MAX_PLAYERS; i++)
|
for (int i = 0; i < MAX_PLAYERS; i++)
|
||||||
binds[i] = g_settings.input.binds[i];
|
binds[i] = g_settings.input.binds[i];
|
||||||
|
|
||||||
return driver.input->input_state(driver.input_data, binds, port, device, index, id);
|
int16_t res = driver.input->input_state(driver.input_data, binds, port, device, index, id);
|
||||||
|
if (g_extern.bsv_movie && !g_extern.bsv_movie_playback)
|
||||||
|
bsv_movie_set_input(g_extern.bsv_movie, res);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_pathname(char *out_path, char *in_path, const char *replace)
|
static void fill_pathname(char *out_path, char *in_path, const char *replace)
|
||||||
@ -299,6 +316,7 @@ static void print_help(void)
|
|||||||
puts("\t-j/--justifier: Connect a virtual Konami Justifier into port 2 of the SNES.");
|
puts("\t-j/--justifier: Connect a virtual Konami Justifier into port 2 of the SNES.");
|
||||||
puts("\t-J/--justifiers: Daisy chain two virtual Konami Justifiers into port 2 of the SNES.");
|
puts("\t-J/--justifiers: Daisy chain two virtual Konami Justifiers into port 2 of the SNES.");
|
||||||
puts("\t-4/--multitap: Connect a multitap to port 2 of the SNES.");
|
puts("\t-4/--multitap: Connect a multitap to port 2 of the SNES.");
|
||||||
|
puts("\t-P/--bsvplay: Playback a BSV movie file.");
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
puts("\t-r/--record: Path to record video file. Settings for video/audio codecs are found in config file.");
|
puts("\t-r/--record: Path to record video file. Settings for video/audio codecs are found in config file.");
|
||||||
@ -337,6 +355,7 @@ static void parse_input(int argc, char *argv[])
|
|||||||
{ "multitap", 0, NULL, '4' },
|
{ "multitap", 0, NULL, '4' },
|
||||||
{ "sufamiA", 1, NULL, 'Y' },
|
{ "sufamiA", 1, NULL, 'Y' },
|
||||||
{ "sufamiB", 1, NULL, 'Z' },
|
{ "sufamiB", 1, NULL, 'Z' },
|
||||||
|
{ "bsvplay", 1, NULL, 'P' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -354,7 +373,7 @@ static void parse_input(int argc, char *argv[])
|
|||||||
#define CONFIG_FILE_ARG
|
#define CONFIG_FILE_ARG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char optstring[] = "hs:vS:m:p4jJg:b:B:Y:Z:" FFMPEG_RECORD_ARG CONFIG_FILE_ARG;
|
char optstring[] = "hs:vS:m:p4jJg:b:B:Y:Z:P:" FFMPEG_RECORD_ARG CONFIG_FILE_ARG;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
int c = getopt_long(argc, argv, optstring, opts, &option_index);
|
int c = getopt_long(argc, argv, optstring, opts, &option_index);
|
||||||
@ -446,6 +465,11 @@ static void parse_input(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
case 'P':
|
||||||
|
strncpy(g_extern.bsv_movie_path, optarg, sizeof(g_extern.bsv_movie_path) - 1);
|
||||||
|
g_extern.bsv_movie_playback = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
print_help();
|
print_help();
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -663,6 +687,19 @@ static void deinit_rewind(void)
|
|||||||
free(g_extern.state_buf);
|
free(g_extern.state_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void init_movie(void)
|
||||||
|
{
|
||||||
|
if (strlen(g_extern.bsv_movie_path) > 0)
|
||||||
|
g_extern.bsv_movie = bsv_movie_init(g_extern.bsv_movie_path,
|
||||||
|
g_extern.bsv_movie_playback ? SSNES_MOVIE_PLAYBACK : SSNES_MOVIE_RECORD);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void deinit_movie(void)
|
||||||
|
{
|
||||||
|
if (g_extern.bsv_movie)
|
||||||
|
bsv_movie_free(g_extern.bsv_movie);
|
||||||
|
}
|
||||||
|
|
||||||
static void fill_pathnames(void)
|
static void fill_pathnames(void)
|
||||||
{
|
{
|
||||||
switch (g_extern.game_type)
|
switch (g_extern.game_type)
|
||||||
@ -844,11 +881,14 @@ static void do_state_checks(void)
|
|||||||
{
|
{
|
||||||
set_fast_forward_button(driver.input->key_pressed(driver.input_data, SSNES_FAST_FORWARD_KEY));
|
set_fast_forward_button(driver.input->key_pressed(driver.input_data, SSNES_FAST_FORWARD_KEY));
|
||||||
|
|
||||||
|
if (!g_extern.bsv_movie)
|
||||||
|
{
|
||||||
check_stateslots();
|
check_stateslots();
|
||||||
check_savestates();
|
check_savestates();
|
||||||
|
check_rewind();
|
||||||
|
}
|
||||||
check_fullscreen();
|
check_fullscreen();
|
||||||
check_input_rate();
|
check_input_rate();
|
||||||
check_rewind();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -877,22 +917,26 @@ int main(int argc, char *argv[])
|
|||||||
psnes_set_input_state(input_state);
|
psnes_set_input_state(input_state);
|
||||||
|
|
||||||
init_controllers();
|
init_controllers();
|
||||||
|
init_movie();
|
||||||
|
|
||||||
|
if (!g_extern.bsv_movie)
|
||||||
|
{
|
||||||
load_save_files();
|
load_save_files();
|
||||||
|
init_rewind();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
init_recording();
|
init_recording();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
init_msg_queue();
|
init_msg_queue();
|
||||||
init_rewind();
|
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
// Time to drop?
|
// Time to drop?
|
||||||
if (driver.input->key_pressed(driver.input_data, SSNES_QUIT_KEY) ||
|
if (driver.input->key_pressed(driver.input_data, SSNES_QUIT_KEY) ||
|
||||||
!driver.video->alive(driver.video_data))
|
!driver.video->alive(driver.video_data) || g_extern.bsv_movie_end)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Checks for stuff like fullscreen, save states, etc.
|
// Checks for stuff like fullscreen, save states, etc.
|
||||||
@ -902,14 +946,18 @@ int main(int argc, char *argv[])
|
|||||||
psnes_run();
|
psnes_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit_rewind();
|
|
||||||
deinit_msg_queue();
|
deinit_msg_queue();
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
deinit_recording();
|
deinit_recording();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!g_extern.bsv_movie)
|
||||||
|
{
|
||||||
|
deinit_rewind();
|
||||||
save_files();
|
save_files();
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit_movie();
|
||||||
psnes_unload_cartridge();
|
psnes_unload_cartridge();
|
||||||
psnes_term();
|
psnes_term();
|
||||||
uninit_drivers();
|
uninit_drivers();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user