From ca88906d64e75256b708d37c07166253e4a3d93c Mon Sep 17 00:00:00 2001 From: Themaister Date: Mon, 16 Aug 2010 17:48:21 +0200 Subject: [PATCH 1/8] ;x --- config.h | 8 ++++---- config.mk | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config.h b/config.h index 50723ddd01..3456e061be 100644 --- a/config.h +++ b/config.h @@ -39,7 +39,7 @@ // Chooses which video and audio subsystem to use. Remember to update config.mk if you change these. #define VIDEO_DRIVER VIDEO_GL -#define AUDIO_DRIVER AUDIO_ALSA +#define AUDIO_DRIVER AUDIO_RSOUND //////////////// @@ -52,8 +52,8 @@ static const float yscale = 4.0; // Real y res = 224 * yscale // Fullscreen static bool fullscreen = false; // To start in Fullscreen or not -static const unsigned fullscreen_x = 1280; -static const unsigned fullscreen_y = 720; +static const unsigned fullscreen_x = 1920; +static const unsigned fullscreen_y = 1200; // Video VSYNC (recommended) static const bool vsync = true; @@ -83,7 +83,7 @@ static const unsigned out_rate = 48000; // Input samplerate from libSNES. // Lower this (slightly) if you are experiencing frequent audio dropouts and vsync is enabled. -static const unsigned in_rate = 31950; +static const unsigned in_rate = 31920; // Audio device (e.g. hw:0,0 or /dev/audio). If NULL, will use defaults. static const char* audio_device = NULL; diff --git a/config.mk b/config.mk index 04fb973188..d11f1f604d 100644 --- a/config.mk +++ b/config.mk @@ -2,10 +2,10 @@ BUILD_OPENGL = 1 BUILD_FILTER = 0 -BUILD_RSOUND = 0 +BUILD_RSOUND = 1 BUILD_OSS = 0 -BUILD_ALSA = 1 +BUILD_ALSA = 0 -PREFIX = /usr/local +PREFIX = /usr From c160c53ceeedd665fae0a673c0f8db1a495cb5e9 Mon Sep 17 00:00:00 2001 From: Themaister Date: Mon, 16 Aug 2010 22:51:56 +0200 Subject: [PATCH 2/8] ;V --- config.h | 4 ++-- config.mk | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config.h b/config.h index b47f623408..99c8f9d0fb 100644 --- a/config.h +++ b/config.h @@ -40,7 +40,7 @@ // Chooses which video and audio subsystem to use. Remember to update config.mk if you change these. #define VIDEO_DRIVER VIDEO_GL -#define AUDIO_DRIVER AUDIO_RSOUND +#define AUDIO_DRIVER AUDIO_ALSA //////////////// @@ -80,7 +80,7 @@ static const bool force_aspect = true; //////////////// // Output samplerate -static const unsigned out_rate = 48000; +static const unsigned out_rate = 44100; // Input samplerate from libSNES. // Lower this (slightly) if you are experiencing frequent audio dropouts and vsync is enabled. diff --git a/config.mk b/config.mk index c1f63e94d5..fb2697b192 100644 --- a/config.mk +++ b/config.mk @@ -3,9 +3,9 @@ BUILD_OPENGL = 1 BUILD_FILTER = 0 BUILD_RSOUND = 1 -BUILD_OSS = 0 -BUILD_ALSA = 0 -BUILD_ROAR = 0 +BUILD_OSS = 1 +BUILD_ALSA = 1 +BUILD_ROAR = 1 PREFIX = /usr From 747b621afd51772f4054267c4fb6bf813c8ec0f2 Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 19 Aug 2010 15:21:30 +0200 Subject: [PATCH 3/8] Added grayscale filter. --- hqflt/grayscale.c | 21 +++++++++++++++++++++ hqflt/grayscale.h | 7 +++++++ ssnes.c | 7 +++++++ 3 files changed, 35 insertions(+) create mode 100644 hqflt/grayscale.c create mode 100644 hqflt/grayscale.h diff --git a/hqflt/grayscale.c b/hqflt/grayscale.c new file mode 100644 index 0000000000..dd2d5081ea --- /dev/null +++ b/hqflt/grayscale.c @@ -0,0 +1,21 @@ +/* Very simple grayscale filter. + * Author: Hans-Kristian Arntzen + * License: Public domain + */ + +#include "grayscale.h" + +// Input format 0RRRRRGGGGGBBBBB. Colors themselves could be switched around. +void grayscale_filter(uint16_t *data, int width, int height) +{ + for (int i = 0; i < width * height; i++ ) + { + int r, g, b, color; + r = (data[i] >> 10) & 0x1F; + g = (data[i] >> 5) & 0x1F; + b = (data[i] >> 0) & 0x1F; + + color = (int)(r * 0.3 + g * 0.59 + b * 0.11); + data[i] = (color << 10) | (color << 5) | color; + } +} diff --git a/hqflt/grayscale.h b/hqflt/grayscale.h new file mode 100644 index 0000000000..7333095112 --- /dev/null +++ b/hqflt/grayscale.h @@ -0,0 +1,7 @@ +/* Very simple grayscale filter. + * Author: Hans-Kristian Arntzen + * License: Public domain + */ + +#include +void grayscale_filter(uint16_t *data, int width, int height); diff --git a/ssnes.c b/ssnes.c index d0d46cc2eb..e4dcfdf874 100644 --- a/ssnes.c +++ b/ssnes.c @@ -26,6 +26,7 @@ #include "config.h" #include "driver.h" #include "hqflt/pastlib.h" +#include "hqflt/grayscale.h" static bool video_active = true; static bool audio_active = true; @@ -136,6 +137,8 @@ static void init_video_input(void) scale = 2; #elif VIDEO_FILTER == FILTER_HQ4X scale = 4; +#elif VIDEO_FILTER == FILTER_GRAYSCALE + scale = 1; #else scale = 1; #endif @@ -216,6 +219,10 @@ static void video_frame(const uint16_t *data, unsigned width, unsigned height) ProcessHQ4x(output, outputHQ4x); if ( !driver.video->frame(driver.video_data, outputHQ4x, width * 4, height * 4) ) video_active = false; +#elif VIDEO_FILTER == FILTER_GRAYSCALE + grayscale_filter(output, width, height); + if ( !driver.video->frame(driver.video_data, output, width, height) ) + video_active = false; #else if ( !driver.video->frame(driver.video_data, output, width, height) ) video_active = false; From b3ddbe20a960c3027f41c78a7c9d74a0574710de Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 19 Aug 2010 15:26:58 +0200 Subject: [PATCH 4/8] Fixes segfault when audio driver is not active. --- Makefile | 1 + ssnes.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5d4bd045d1..609a2f1f23 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ ifeq ($(BUILD_OPENGL), 1) endif ifeq ($(BUILD_FILTER), 1) OBJ += hqflt/hq.o + OBJ += hqflt/grayscale.o endif CFLAGS = -Wall -O3 -march=native -std=gnu99 diff --git a/ssnes.c b/ssnes.c index e4dcfdf874..be84a25b28 100644 --- a/ssnes.c +++ b/ssnes.c @@ -87,8 +87,10 @@ void set_fast_forward_button(bool new_button_state) if (new_button_state && !old_button_state) { syncing_state = !syncing_state; - driver.video->set_nonblock_state(driver.video_data, syncing_state); - driver.audio->set_nonblock_state(driver.audio_data, syncing_state); + if (video_active) + driver.video->set_nonblock_state(driver.video_data, syncing_state); + if (audio_active) + driver.audio->set_nonblock_state(driver.audio_data, syncing_state); if (syncing_state) audio_chunk_size = AUDIO_CHUNK_SIZE_NONBLOCKING; else From 083ccd7d3a957ec5624a3dc07aa658c019045459 Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 19 Aug 2010 15:27:41 +0200 Subject: [PATCH 5/8] configs --- config.h | 11 ++++++----- config.mk | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config.h b/config.h index 99c8f9d0fb..54f92d192c 100644 --- a/config.h +++ b/config.h @@ -69,10 +69,11 @@ static const bool force_aspect = true; #define FILTER_NONE 0 #define FILTER_HQ2X 1 #define FILTER_HQ4X 2 +#define FILTER_GRAYSCALE 3 //////////////////////// // If you change this to something other than the HQ filters, make sure that you build the filter module in config.mk. -#define VIDEO_FILTER FILTER_NONE +#define VIDEO_FILTER FILTER_GRAYSCALE //////////////// @@ -80,17 +81,17 @@ static const bool force_aspect = true; //////////////// // Output samplerate -static const unsigned out_rate = 44100; +static const unsigned out_rate = 96000; // Input samplerate from libSNES. // Lower this (slightly) if you are experiencing frequent audio dropouts and vsync is enabled. -static const unsigned in_rate = 31920; +static const unsigned in_rate = 31950; // Audio device (e.g. hw:0,0 or /dev/audio). If NULL, will use defaults. -static const char* audio_device = NULL; +static const char* audio_device = "hw:0"; // Desired audio latency in milliseconds. Might not be honored if driver can't provide given latency. -static const int out_latency = 64; +static const int out_latency = 16; // Defines the quality (and cpu reqirements) of samplerate conversion. #define SAMPLERATE_QUALITY SRC_LINEAR diff --git a/config.mk b/config.mk index fb2697b192..ae4d2a47e6 100644 --- a/config.mk +++ b/config.mk @@ -1,6 +1,6 @@ BUILD_OPENGL = 1 -BUILD_FILTER = 0 +BUILD_FILTER = 1 BUILD_RSOUND = 1 BUILD_OSS = 1 From f9a177880ed9fbfa69a08717bcf7f05fe420f8e5 Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 19 Aug 2010 15:52:43 +0200 Subject: [PATCH 6/8] Adds possibility for non-syncing audio. --- config.h | 7 +++++-- ssnes.c | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/config.h b/config.h index 54f92d192c..e288c236e0 100644 --- a/config.h +++ b/config.h @@ -73,7 +73,7 @@ static const bool force_aspect = true; //////////////////////// // If you change this to something other than the HQ filters, make sure that you build the filter module in config.mk. -#define VIDEO_FILTER FILTER_GRAYSCALE +#define VIDEO_FILTER FILTER_HQ2X //////////////// @@ -85,7 +85,7 @@ static const unsigned out_rate = 96000; // Input samplerate from libSNES. // Lower this (slightly) if you are experiencing frequent audio dropouts and vsync is enabled. -static const unsigned in_rate = 31950; +static const unsigned in_rate = 31940; // Audio device (e.g. hw:0,0 or /dev/audio). If NULL, will use defaults. static const char* audio_device = "hw:0"; @@ -93,6 +93,9 @@ static const char* audio_device = "hw:0"; // Desired audio latency in milliseconds. Might not be honored if driver can't provide given latency. static const int out_latency = 16; +// Will sync audio. (recommended) +static const bool audio_sync = true; + // Defines the quality (and cpu reqirements) of samplerate conversion. #define SAMPLERATE_QUALITY SRC_LINEAR diff --git a/ssnes.c b/ssnes.c index be84a25b28..5575e9aeca 100644 --- a/ssnes.c +++ b/ssnes.c @@ -88,9 +88,9 @@ void set_fast_forward_button(bool new_button_state) { syncing_state = !syncing_state; if (video_active) - driver.video->set_nonblock_state(driver.video_data, syncing_state); + driver.video->set_nonblock_state(driver.video_data, (audio_sync) ? syncing_state : true); if (audio_active) - driver.audio->set_nonblock_state(driver.audio_data, syncing_state); + driver.audio->set_nonblock_state(driver.audio_data, (audio_sync) ? syncing_state : true); if (syncing_state) audio_chunk_size = AUDIO_CHUNK_SIZE_NONBLOCKING; else @@ -117,8 +117,13 @@ static void init_audio(void) if ( driver.audio_data == NULL ) audio_active = false; + if (!audio_sync && audio_active) + driver.audio->set_nonblock_state(driver.audio_data, true); + int err; source = src_new(SAMPLERATE_QUALITY, 2, &err); + if (!source) + audio_active = false; } static void uninit_audio(void) From 6f53dc0fa3b1602a0273181c3025ce6786e2be4c Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 19 Aug 2010 15:56:00 +0200 Subject: [PATCH 7/8] v.v --- config.h | 2 +- ssnes.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index e288c236e0..da916253c5 100644 --- a/config.h +++ b/config.h @@ -94,7 +94,7 @@ static const char* audio_device = "hw:0"; static const int out_latency = 16; // Will sync audio. (recommended) -static const bool audio_sync = true; +static const bool audio_sync = false; // Defines the quality (and cpu reqirements) of samplerate conversion. #define SAMPLERATE_QUALITY SRC_LINEAR diff --git a/ssnes.c b/ssnes.c index 5575e9aeca..d119a7cd26 100644 --- a/ssnes.c +++ b/ssnes.c @@ -88,7 +88,7 @@ void set_fast_forward_button(bool new_button_state) { syncing_state = !syncing_state; if (video_active) - driver.video->set_nonblock_state(driver.video_data, (audio_sync) ? syncing_state : true); + driver.video->set_nonblock_state(driver.video_data, syncing_state); if (audio_active) driver.audio->set_nonblock_state(driver.audio_data, (audio_sync) ? syncing_state : true); if (syncing_state) From 6a9798451a1b7f81a7a5d64a3647d09398f46f2d Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 19 Aug 2010 16:00:50 +0200 Subject: [PATCH 8/8] :v --- config.h | 9 ++++++--- ssnes.c | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/config.h b/config.h index da916253c5..673ef76a4f 100644 --- a/config.h +++ b/config.h @@ -73,19 +73,22 @@ static const bool force_aspect = true; //////////////////////// // If you change this to something other than the HQ filters, make sure that you build the filter module in config.mk. -#define VIDEO_FILTER FILTER_HQ2X +#define VIDEO_FILTER FILTER_NONE //////////////// // Audio //////////////// +// Will enable audio or not. +static const bool audio_enable = true; + // Output samplerate static const unsigned out_rate = 96000; // Input samplerate from libSNES. // Lower this (slightly) if you are experiencing frequent audio dropouts and vsync is enabled. -static const unsigned in_rate = 31940; +static const unsigned in_rate = 31950; // Audio device (e.g. hw:0,0 or /dev/audio). If NULL, will use defaults. static const char* audio_device = "hw:0"; @@ -94,7 +97,7 @@ static const char* audio_device = "hw:0"; static const int out_latency = 16; // Will sync audio. (recommended) -static const bool audio_sync = false; +static const bool audio_sync = true; // Defines the quality (and cpu reqirements) of samplerate conversion. #define SAMPLERATE_QUALITY SRC_LINEAR diff --git a/ssnes.c b/ssnes.c index d119a7cd26..d861a56add 100644 --- a/ssnes.c +++ b/ssnes.c @@ -113,6 +113,12 @@ static void uninit_drivers(void) static void init_audio(void) { + if (!audio_enable) + { + audio_active = false; + return; + } + driver.audio_data = driver.audio->init(audio_device, out_rate, out_latency); if ( driver.audio_data == NULL ) audio_active = false; @@ -128,6 +134,12 @@ static void init_audio(void) static void uninit_audio(void) { + if (!audio_enable) + { + audio_active = false; + return; + } + if ( driver.audio_data && driver.audio ) driver.audio->free(driver.audio_data);