From cf5fb8baaa1c1f84445946ad5fb51978e8f119a6 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 29 Mar 2012 15:07:48 +0200 Subject: [PATCH] (PS3) Some more Griffin overrides --- Makefile.ps3 | 1 - console/griffin/func_hooks.h | 35 +++-------------- console/griffin/griffin.c | 11 ++++++ console/griffin/ssnes_func_hooks.h | 61 ++++++++++++++++++++++++++++++ ps3/menu.c | 2 + ssnes.c | 10 +++-- 6 files changed, 87 insertions(+), 33 deletions(-) create mode 100644 console/griffin/ssnes_func_hooks.h diff --git a/Makefile.ps3 b/Makefile.ps3 index 7a21141345..b8062546ef 100644 --- a/Makefile.ps3 +++ b/Makefile.ps3 @@ -46,7 +46,6 @@ GIT = git.exe endif PPU_SRCS = console/griffin/griffin.c \ - ps3/menu.c \ console/szlib/szlib.c ifeq ($(HAVE_SSNES_GL), 1) diff --git a/console/griffin/func_hooks.h b/console/griffin/func_hooks.h index 8bd9d56909..bae2d79abb 100644 --- a/console/griffin/func_hooks.h +++ b/console/griffin/func_hooks.h @@ -15,40 +15,17 @@ * You should have received a copy of the GNU General Public License along with SSNES. * If not, see . */ +#ifndef _FUNC_HOOKS_H +#define _FUNC_HOOKS_H /*============================================================ PLAYSTATION3 ============================================================ */ #ifdef __CELLOS_LV2__ - -#define HAVE_GRIFFIN_OVERRIDE_AUDIO_FLUSH_FUNC 1 - -static bool audio_flush(const int16_t *data, size_t samples) -{ - const float *output_data = NULL; - unsigned output_frames = 0; - - audio_convert_s16_to_float(g_extern.audio_data.data, data, samples); - - struct resampler_data src_data = {0}; - src_data.data_in = g_extern.audio_data.data; - src_data.data_out = g_extern.audio_data.outsamples; - src_data.input_frames = (samples / 2); - - src_data.ratio = g_extern.audio_data.src_ratio; - if (g_extern.is_slowmotion) - src_data.ratio *= g_settings.slowmotion_ratio; - - resampler_process(g_extern.audio_data.source, &src_data); - - output_data = g_extern.audio_data.outsamples; - output_frames = src_data.output_frames; - - if (audio_write_func(output_data, output_frames * sizeof(float) * 2) < 0) - return false; - - return true; -} +#define ssnes_render_cached_frame() \ + const char *msg = msg_queue_pull(g_extern.msg_queue); \ + video_frame_func(g_extern.frame_cache.data, g_extern.frame_cache.width, g_extern.frame_cache.height, lines_to_pitch(g_extern.frame_cache.height), msg); +#endif #endif diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index 596fe09694..b83fb7dac4 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -40,6 +40,8 @@ #endif #include "../../conf/config_file.c" +#include "func_hooks.h" + /*============================================================ VIDEO ============================================================ */ @@ -162,3 +164,12 @@ NETPLAY ============================================================ */ #include "../../netplay.c" + +/*============================================================ + MENU +============================================================ */ +#if defined(__CELLOS_LV2__) +#include "../../ps3/menu.c" +#elif defined(_XBOX) +#include "../../360/menu.cpp" +#endif diff --git a/console/griffin/ssnes_func_hooks.h b/console/griffin/ssnes_func_hooks.h new file mode 100644 index 0000000000..ac3ab0a886 --- /dev/null +++ b/console/griffin/ssnes_func_hooks.h @@ -0,0 +1,61 @@ +/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - Daniel De Matteis + * + * Some code herein may be based on code found in BSNES. + * + * SSNES is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with SSNES. + * If not, see . + */ + +#ifndef _SSNES_FUNC_HOOKS_H +#define _SSNES_FUNC_HOOKS_H + +/*============================================================ + PLAYSTATION3 +============================================================ */ + +#ifdef __CELLOS_LV2__ + +#define HAVE_GRIFFIN_OVERRIDE_AUDIO_FLUSH_FUNC 1 +#define HAVE_GRIFFIN_OVERRIDE_VIDEO_FRAME_FUNC 1 + +static bool audio_flush(const int16_t *data, size_t samples) +{ + const float *output_data = NULL; + unsigned output_frames = 0; + + audio_convert_s16_to_float(g_extern.audio_data.data, data, samples); + + struct resampler_data src_data = {0}; + src_data.data_in = g_extern.audio_data.data; + src_data.data_out = g_extern.audio_data.outsamples; + src_data.input_frames = (samples / 2); + + src_data.ratio = g_extern.audio_data.src_ratio; + if (g_extern.is_slowmotion) + src_data.ratio *= g_settings.slowmotion_ratio; + + resampler_process(g_extern.audio_data.source, &src_data); + + output_data = g_extern.audio_data.outsamples; + output_frames = src_data.output_frames; + + if (audio_write_func(output_data, output_frames * sizeof(float) * 2) < 0) + return false; + + return true; +} + +#endif + + +#endif diff --git a/ps3/menu.c b/ps3/menu.c index 6b964f6d4a..22b9a2e428 100644 --- a/ps3/menu.c +++ b/ps3/menu.c @@ -2570,7 +2570,9 @@ void menu_loop(void) glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); if(g_console.emulator_initialized) + { ssnes_render_cached_frame(); + } gl_frame_menu(); diff --git a/ssnes.c b/ssnes.c index 6019dfdf08..2546c878e8 100644 --- a/ssnes.c +++ b/ssnes.c @@ -246,6 +246,11 @@ static void video_frame(const uint16_t *data, unsigned width, unsigned height) g_extern.frame_cache.height = height; } +#ifdef HAVE_GRIFFIN +#include "console/griffin/ssnes_func_hooks.h" +#endif + +#ifndef HAVE_GRIFFIN_OVERRIDE_VIDEO_FRAME_FUNC void ssnes_render_cached_frame(void) { #ifdef HAVE_FFMPEG @@ -268,9 +273,6 @@ void ssnes_render_cached_frame(void) g_extern.recording = recording; #endif } - -#ifdef HAVE_GRIFFIN -#include "console/griffin/func_hooks.h" #endif #ifndef HAVE_GRIFFIN_OVERRIDE_AUDIO_FLUSH_FUNC @@ -2179,7 +2181,9 @@ static void do_state_checks(void) #else if (check_fullscreen() && g_extern.is_paused) #endif + { ssnes_render_cached_frame(); + } #ifndef SSNES_CONSOLE if (g_extern.is_paused && !g_extern.is_oneshot)