From d5761b6385e1cff4f37aabf07cbdde48f4e44102 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sat, 19 Mar 2011 20:41:07 +0100 Subject: [PATCH] Can disable netplay. --- Makefile | 6 +++++- config.features.h | 6 ++++++ qb/config.libs.sh | 3 ++- qb/config.params.sh | 1 + ssnes.c | 23 ++++++++++++++++++++++- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index cb3ad2d83a..4045f8d352 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ include config.mk TARGET = ssnes tools/ssnes-joyconfig -OBJ = ssnes.o file.o driver.o settings.o dynamic.o message.o rewind.o movie.o autosave.o netplay.o gfx/gfx_common.o +OBJ = ssnes.o file.o driver.o settings.o dynamic.o message.o rewind.o movie.o autosave.o gfx/gfx_common.o JOYCONFIG_OBJ = tools/ssnes-joyconfig.o conf/config_file.o HEADERS = $(wildcard */*.h) $(wildcard *.h) @@ -27,6 +27,10 @@ ifeq ($(HAVE_CONFIGFILE), 1) OBJ += conf/config_file.o endif +ifeq ($(HAVE_NETPLAY), 1) + OBJ += netplay.o +endif + ifeq ($(HAVE_RSOUND), 1) OBJ += audio/rsound.o LIBS += -lrsound diff --git a/config.features.h b/config.features.h index 503be24d22..ab3e9f2d8b 100644 --- a/config.features.h +++ b/config.features.h @@ -110,4 +110,10 @@ static const bool _freetype_supp = true; static const bool _freetype_supp = false; #endif +#ifdef HAVE_NETPLAY +static const bool _netplay_supp = true; +#else +static const bool _netplay_supp = false; +#endif + #endif diff --git a/qb/config.libs.sh b/qb/config.libs.sh index c161cb91cc..bdc523a8a8 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -16,6 +16,7 @@ if [ $HAVE_DYNAMIC != yes ]; then fi check_lib FILTER -ldl dlopen +check_lib NETPLAY -lc socket check_lib ALSA -lasound snd_pcm_open check_header OSS sys/soundcard.h @@ -55,7 +56,7 @@ check_pkgconf FREETYPE freetype2 check_lib XVIDEO -lXv XvShmCreateImage # Creates config.mk and config.h. -VARS="ALSA OSS AL RSOUND ROAR JACK PULSE SDL FILTER CG XML DYNAMIC FFMPEG AVCODEC AVFORMAT AVCORE AVUTIL SWSCALE SRC CONFIGFILE FREETYPE XVIDEO" +VARS="ALSA OSS AL RSOUND ROAR JACK PULSE SDL FILTER CG XML DYNAMIC FFMPEG AVCODEC AVFORMAT AVCORE AVUTIL SWSCALE SRC CONFIGFILE FREETYPE XVIDEO NETPLAY" create_config_make config.mk $VARS create_config_header config.h $VARS diff --git a/qb/config.params.sh b/qb/config.params.sh index fa01c718c8..ea2ccc7cf6 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -11,6 +11,7 @@ add_command_line_enable DYNAMIC "Enable dynamic loading of libsnes library." no add_command_line_string LIBSNES "libsnes library used" "-lsnes" add_command_line_enable FFMPEG "Enable FFmpeg recording support" no add_command_line_enable FILTER "Enable CPU filter support" auto +add_command_line_enable NETPLAY "Enable netplay support" auto add_command_line_enable SRC "Enable libsamplerate support" no add_command_line_enable CONFIGFILE "Disable support for config file" yes add_command_line_enable CG "Enable Cg shader support" auto diff --git a/ssnes.c b/ssnes.c index 2d96b69be5..761379c942 100644 --- a/ssnes.c +++ b/ssnes.c @@ -268,6 +268,7 @@ static void print_features(void) _PSUPP(src, "SRC", "libsamplerate audio resampling"); _PSUPP(configfile, "Config file", "Configuration file support"); _PSUPP(freetype, "FreeType", "TTF font rendering with FreeType"); + _PSUPP(netplay, "Netplay", "Peer-to-peer netplay"); } #undef _PSUPP @@ -295,10 +296,12 @@ static void print_help(void) 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-P/--bsvplay: Playback a BSV movie file."); +#ifdef HAVE_NETPLAY puts("\t-H/--host: Host netplay as player 1."); puts("\t-C/--connect: Connect to netplay as player 2."); puts("\t--port: Port used to netplay. Default is 55435."); puts("\t-F/--frames: Sync frames when using netplay."); +#endif #ifdef HAVE_FFMPEG puts("\t-r/--record: Path to record video file. Settings for video/audio codecs are found in config file."); @@ -733,6 +736,7 @@ static void deinit_movie(void) #define SSNES_DEFAULT_PORT 55435 +#ifdef HAVE_NETPLAY static void init_netplay(void) { if (g_extern.netplay_enable) @@ -760,12 +764,15 @@ static void init_netplay(void) } } } +#endif +#ifdef HAVE_NETPLAY static void deinit_netplay(void) { if (g_extern.netplay) netplay_free(g_extern.netplay); } +#endif static void init_autosave(void) { @@ -1187,17 +1194,25 @@ int main(int argc, char *argv[]) if (!g_extern.bsv_movie) load_save_files(); - +#ifdef HAVE_NETPLAY init_netplay(); +#endif init_drivers(); if (!g_extern.netplay) init_rewind(); +#ifdef HAVE_NETPLAY psnes_set_video_refresh(g_extern.netplay ? video_frame_net : video_frame); psnes_set_audio_sample(g_extern.netplay ? audio_sample_net : audio_sample); psnes_set_input_poll(g_extern.netplay ? input_poll_net : input_poll); psnes_set_input_state(g_extern.netplay ? input_state_net : input_state); +#else + psnes_set_video_refresh(video_frame); + psnes_set_audio_sample(audio_sample); + psnes_set_input_poll(input_poll); + psnes_set_input_state(input_state); +#endif init_controllers(); @@ -1224,8 +1239,10 @@ int main(int argc, char *argv[]) { lock_autosave(); +#ifdef HAVE_NETPLAY if (g_extern.netplay) netplay_pre_frame(g_extern.netplay); +#endif if (g_extern.bsv_movie) bsv_movie_set_frame_start(g_extern.bsv_movie); @@ -1233,8 +1250,10 @@ int main(int argc, char *argv[]) if (g_extern.bsv_movie) bsv_movie_set_frame_end(g_extern.bsv_movie); +#ifdef HAVE_NETPLAY if (g_extern.netplay) netplay_post_frame(g_extern.netplay); +#endif unlock_autosave(); } @@ -1253,7 +1272,9 @@ int main(int argc, char *argv[]) } } +#ifdef HAVE_NETPLAY deinit_netplay(); +#endif if (!g_extern.bsv_movie_playback && !g_extern.netplay_is_client) deinit_autosave();