mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
More work on configs.
This commit is contained in:
parent
013234a89a
commit
2da6a4e2cc
2
Makefile
2
Makefile
@ -46,7 +46,7 @@ ifeq ($(BUILD_FILTER), 1)
|
||||
OBJ += hqflt/snes_ntsc/snes_ntsc.o
|
||||
endif
|
||||
|
||||
CFLAGS = -Wall -O3 -std=gnu99 -Wno-unused-variable -I. $(DEFINES)
|
||||
CFLAGS = -Wall -O0 -g -std=gnu99 -Wno-unused-variable -I. $(DEFINES)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
|
21
driver.c
21
driver.c
@ -37,36 +37,36 @@ void init_audio(void)
|
||||
{
|
||||
if (!audio_enable)
|
||||
{
|
||||
audio_active = false;
|
||||
g_extern.audio_active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
driver.audio_data = driver.audio->init(audio_device, out_rate, out_latency);
|
||||
if ( driver.audio_data == NULL )
|
||||
audio_active = false;
|
||||
g_extern.audio_active = false;
|
||||
|
||||
if (!audio_sync && audio_active)
|
||||
if (!audio_sync && g_extern.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;
|
||||
g_extern.source = src_new(SAMPLERATE_QUALITY, 2, &err);
|
||||
if (!g_extern.source)
|
||||
g_extern.audio_active = false;
|
||||
}
|
||||
|
||||
void uninit_audio(void)
|
||||
{
|
||||
if (!audio_enable)
|
||||
{
|
||||
audio_active = false;
|
||||
g_extern.audio_active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( driver.audio_data && driver.audio )
|
||||
driver.audio->free(driver.audio_data);
|
||||
|
||||
if ( source )
|
||||
src_delete(source);
|
||||
if ( g_extern.source )
|
||||
src_delete(g_extern.source);
|
||||
}
|
||||
|
||||
void init_video_input(void)
|
||||
@ -139,9 +139,6 @@ void uninit_video_input(void)
|
||||
driver.input->free(driver.input_data);
|
||||
}
|
||||
|
||||
bool video_active = true;
|
||||
bool audio_active = true;
|
||||
|
||||
driver_t driver = {
|
||||
#if VIDEO_DRIVER == VIDEO_GL
|
||||
.video = &video_gl,
|
||||
|
2
driver.h
2
driver.h
@ -92,8 +92,6 @@ void uninit_video_input(void);
|
||||
void init_audio(void);
|
||||
void uninit_audio(void);
|
||||
|
||||
extern bool video_active;
|
||||
extern bool audio_active;
|
||||
extern driver_t driver;
|
||||
|
||||
//////////////////////////////////////////////// Backends
|
||||
|
27
general.h
27
general.h
@ -23,14 +23,6 @@
|
||||
#include <samplerate.h>
|
||||
#include "driver.h"
|
||||
|
||||
#define SSNES_LOG(msg, args...) do { \
|
||||
if (verbose) \
|
||||
fprintf(stderr, "SSNES: " msg, ##args); \
|
||||
} while(0)
|
||||
|
||||
#define SSNES_ERR(msg, args...) do { \
|
||||
fprintf(stderr, "SSNES [ERROR] :: " msg, ##args); \
|
||||
} while(0)
|
||||
|
||||
#define MAX_PLAYERS 2
|
||||
#define MAX_BINDS 14
|
||||
@ -40,6 +32,7 @@ struct settings
|
||||
{
|
||||
float xscale;
|
||||
float yscale;
|
||||
bool fullscreen;
|
||||
unsigned fullscreen_x;
|
||||
unsigned fullscreen_y;
|
||||
bool vsync;
|
||||
@ -66,8 +59,26 @@ struct settings
|
||||
} input;
|
||||
};
|
||||
|
||||
struct global
|
||||
{
|
||||
bool verbose;
|
||||
SRC_STATE *source;
|
||||
bool audio_active;
|
||||
bool video_active;
|
||||
};
|
||||
|
||||
void parse_config(void);
|
||||
|
||||
extern struct settings g_settings;
|
||||
extern struct global g_extern;
|
||||
|
||||
#define SSNES_LOG(msg, args...) do { \
|
||||
if (g_extern.verbose) \
|
||||
fprintf(stderr, "SSNES: " msg, ##args); \
|
||||
} while(0)
|
||||
|
||||
#define SSNES_ERR(msg, args...) do { \
|
||||
fprintf(stderr, "SSNES [ERROR] :: " msg, ##args); \
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "conf/config_file.h"
|
||||
#include "config.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
struct settings g_settings;
|
||||
|
||||
@ -9,12 +10,15 @@ static void set_defaults(void)
|
||||
{
|
||||
g_settings.video.xscale = xscale;
|
||||
g_settings.video.yscale = yscale;
|
||||
g_settings.video.fullscreen = fullscreen;
|
||||
g_settings.video.fullscreen_x = fullscreen_x;
|
||||
g_settings.video.fullscreen_y = fullscreen_y;
|
||||
g_settings.video.vsync = vsync;
|
||||
g_settings.video.smootn = video_smooth;
|
||||
g_settings.video.smooth = video_smooth;
|
||||
g_settings.video.force_aspect = force_aspect;
|
||||
#if HAVE_CG
|
||||
strncpy(g_settings.video.cg_shader_path, cg_shader_path, sizeof(g_settings.video.cg_shader_path) - 1);
|
||||
#endif
|
||||
strncpy(g_settings.video.video_filter, "foo", sizeof(g_settings.video.video_filter) - 1);
|
||||
|
||||
g_settings.audio.enable = audio_enable;
|
||||
@ -126,7 +130,7 @@ void parse_config(void)
|
||||
if (config_get_int(conf, "audio_src_quality", &tmp_int))
|
||||
{
|
||||
int quals[] = {SRC_ZERO_ORDER_HOLD, SRC_LINEAR, SRC_SINC_FASTEST,
|
||||
SRC_SINC_MEDIUM, SRC_SINC_BEST};
|
||||
SRC_SINC_MEDIUM_QUALITY, SRC_SINC_BEST_QUALITY};
|
||||
|
||||
if (tmp_int > 0 && tmp_int < 6)
|
||||
g_settings.audio.src_quality = quals[tmp_int];
|
||||
|
23
ssnes.c
23
ssnes.c
@ -33,6 +33,10 @@
|
||||
#include "hqflt/ntsc.h"
|
||||
#include "general.h"
|
||||
|
||||
struct global g_extern = {
|
||||
.video_active = true,
|
||||
.audio_active = true
|
||||
};
|
||||
|
||||
// To avoid continous switching if we hold the button down, we require that the button must go from pressed, unpressed back to pressed to be able to toggle between then.
|
||||
|
||||
@ -46,9 +50,9 @@ void set_fast_forward_button(bool new_button_state)
|
||||
if (new_button_state && !old_button_state)
|
||||
{
|
||||
syncing_state = !syncing_state;
|
||||
if (video_active)
|
||||
if (g_extern.video_active)
|
||||
driver.video->set_nonblock_state(driver.video_data, syncing_state);
|
||||
if (audio_active)
|
||||
if (g_extern.audio_active)
|
||||
driver.audio->set_nonblock_state(driver.audio_data, (audio_sync) ? syncing_state : true);
|
||||
if (syncing_state)
|
||||
audio_chunk_size = AUDIO_CHUNK_SIZE_NONBLOCKING;
|
||||
@ -79,7 +83,7 @@ static inline void process_frame (uint16_t * restrict out, const uint16_t * rest
|
||||
// Format received is 16-bit 0RRRRRGGGGGBBBBB
|
||||
static void video_frame(const uint16_t *data, unsigned width, unsigned height)
|
||||
{
|
||||
if ( !video_active )
|
||||
if ( !g_extern.video_active )
|
||||
return;
|
||||
|
||||
#if VIDEO_FILTER == FILTER_HQ2X
|
||||
@ -117,15 +121,14 @@ static void video_frame(const uint16_t *data, unsigned width, unsigned height)
|
||||
video_active = false;
|
||||
#else
|
||||
if ( !driver.video->frame(driver.video_data, data, width, height, (height == 448 || height == 478) ? 1024 : 2048) )
|
||||
video_active = false;
|
||||
g_extern.video_active = false;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
SRC_STATE* source = NULL;
|
||||
static void audio_sample(uint16_t left, uint16_t right)
|
||||
{
|
||||
if ( !audio_active )
|
||||
if ( !g_extern.audio_active )
|
||||
return;
|
||||
|
||||
static float data[AUDIO_CHUNK_SIZE_NONBLOCKING];
|
||||
@ -148,14 +151,14 @@ static void audio_sample(uint16_t left, uint16_t right)
|
||||
src_data.end_of_input = 0;
|
||||
src_data.src_ratio = (double)out_rate / (double)in_rate;
|
||||
|
||||
src_process(source, &src_data);
|
||||
src_process(g_extern.source, &src_data);
|
||||
|
||||
src_float_to_short_array(outsamples, temp_outsamples, src_data.output_frames_gen * 2);
|
||||
|
||||
if ( driver.audio->write(driver.audio_data, temp_outsamples, src_data.output_frames_gen * 4) < 0 )
|
||||
{
|
||||
fprintf(stderr, "SSNES [ERROR]: Audio backend failed to write. Will continue without sound.\n");
|
||||
audio_active = false;
|
||||
g_extern.audio_active = false;
|
||||
}
|
||||
|
||||
data_ptr = 0;
|
||||
@ -199,7 +202,6 @@ static void print_help(void)
|
||||
puts("\t-v/--verbose: Verbose logging");
|
||||
}
|
||||
|
||||
bool fullscreen = START_FULLSCREEN;
|
||||
static FILE* rom_file = NULL;
|
||||
static char savefile_name_srm[256] = {0};
|
||||
bool verbose = false;
|
||||
@ -304,6 +306,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
snes_init();
|
||||
parse_input(argc, argv);
|
||||
parse_config();
|
||||
|
||||
void *rom_buf;
|
||||
ssize_t rom_len = 0;
|
||||
@ -367,7 +370,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
else if ( glfwGetKey( TOGGLE_FULLSCREEN ) )
|
||||
{
|
||||
fullscreen = !fullscreen;
|
||||
g_settings.video.fullscreen = !g_settings.video.fullscreen;
|
||||
uninit_drivers();
|
||||
init_drivers();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user