From 4e1c6f1c41a3538c8122d3d871fd3d133f881f75 Mon Sep 17 00:00:00 2001 From: ggdrt <45282415+ggdrt@users.noreply.github.com> Date: Sun, 8 Dec 2019 09:26:41 -0800 Subject: [PATCH] Separate core globals from callbacks --- Makefile.common | 3 ++- beetle_psx_globals.c | 10 ++++++++++ beetle_psx_globals.h | 29 +++++++++++++++++++++++++++++ libretro.cpp | 7 ++++--- libretro_cbs.c | 8 -------- libretro_cbs.h | 9 +-------- mednafen/psx/gpu_polygon.cpp | 8 ++++---- rsx/rsx_intf.cpp | 1 + 8 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 beetle_psx_globals.c create mode 100644 beetle_psx_globals.h diff --git a/Makefile.common b/Makefile.common index 9fb4c3e0..f70759c7 100644 --- a/Makefile.common +++ b/Makefile.common @@ -170,7 +170,8 @@ ifneq ($(HAVE_GRIFFIN), 1) SOURCES_CXX += $(CORE_EMU_DIR)/decomp.cpp endif - SOURCES_C += $(CORE_DIR)/libretro_cbs.c + SOURCES_C += $(CORE_DIR)/libretro_cbs.c \ + $(CORE_DIR)/beetle_psx_globals.c ifeq ($(NEED_TREMOR), 1) SOURCES_C += $(sort $(wildcard $(MEDNAFEN_DIR)/tremor/*.c)) diff --git a/beetle_psx_globals.c b/beetle_psx_globals.c new file mode 100644 index 00000000..31b8fb03 --- /dev/null +++ b/beetle_psx_globals.c @@ -0,0 +1,10 @@ +#include +#include + +bool content_is_pal = false; +uint8_t widescreen_hack; +uint8_t psx_gpu_upscale_shift; +int line_render_mode; +int filter_mode; +bool opaque_check; +bool semitrans_check; diff --git a/beetle_psx_globals.h b/beetle_psx_globals.h new file mode 100644 index 00000000..90e45d77 --- /dev/null +++ b/beetle_psx_globals.h @@ -0,0 +1,29 @@ +#ifndef BEETLE_PSX_GLOBALS_H__ +#define BEETLE_PSX_GLOBALS_H__ + +#include +#include + +/* Global state variables used by the Beetle PSX Core. + * These are typically set by core options and are used + * by methods in the Mednafen PSX module that have been + * modified for Beetle PSX. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern bool content_is_pal; +extern uint8_t widescreen_hack; +extern uint8_t psx_gpu_upscale_shift; +extern int line_render_mode; +extern int filter_mode; +extern bool opaque_check; +extern bool semitrans_check; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libretro.cpp b/libretro.cpp index 74a04d76..7277a799 100644 --- a/libretro.cpp +++ b/libretro.cpp @@ -16,6 +16,7 @@ #include "ugui_tools.h" #include "rsx/rsx_intf.h" #include "libretro_cbs.h" +#include "beetle_psx_globals.h" #include "libretro_options.h" #include "input.h" @@ -2911,11 +2912,11 @@ static void check_variables(bool startup) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (strcmp(var.value, "disabled") == 0) - lineRenderMode = 0; + line_render_mode = 0; else if (strcmp(var.value, "default") == 0) - lineRenderMode = 1; + line_render_mode = 1; else if (strcmp(var.value, "aggressive") == 0) - lineRenderMode = 2; + line_render_mode = 2; } var.key = BEETLE_OPT(filter); diff --git a/libretro_cbs.c b/libretro_cbs.c index 6c3603db..c17dbb27 100644 --- a/libretro_cbs.c +++ b/libretro_cbs.c @@ -1,12 +1,4 @@ -#include #include "libretro.h" -bool content_is_pal = false; retro_video_refresh_t video_cb; retro_environment_t environ_cb; -uint8_t widescreen_hack; -uint8_t psx_gpu_upscale_shift; -int lineRenderMode; -int filter_mode; -bool opaque_check; -bool semitrans_check; diff --git a/libretro_cbs.h b/libretro_cbs.h index 31d96bcb..d29d4ca8 100644 --- a/libretro_cbs.h +++ b/libretro_cbs.h @@ -1,21 +1,14 @@ #ifndef __LIBRETRO_CBS_H #define __LIBRETRO_CBS_H -#include +#include "libretro.h" #ifdef __cplusplus extern "C" { #endif -extern bool content_is_pal; extern retro_video_refresh_t video_cb; extern retro_environment_t environ_cb; -extern uint8_t widescreen_hack; -extern uint8_t psx_gpu_upscale_shift; -extern int lineRenderMode; -extern int filter_mode; -extern bool opaque_check; -extern bool semitrans_check; #ifdef __cplusplus } diff --git a/mednafen/psx/gpu_polygon.cpp b/mednafen/psx/gpu_polygon.cpp index e5bbc9e1..09bbec4c 100644 --- a/mednafen/psx/gpu_polygon.cpp +++ b/mednafen/psx/gpu_polygon.cpp @@ -1,6 +1,6 @@ #include #include -#include "libretro_cbs.h" +#include "beetle_psx_globals.h" #define COORD_FBS 12 #define COORD_MF_INT(n) ((n) << COORD_FBS) @@ -1037,11 +1037,11 @@ static void Command_DrawPolygon(PS_GPU *gpu, const uint32_t *cb) } // Line Renderer: Detect triangles that would resolve as lines at x1 scale and create second triangle to make quad - if ((lineRenderMode != 0) && (!lineFound) && (numvertices == 3) && (textured)) + if ((line_render_mode != 0) && (!lineFound) && (numvertices == 3) && (textured)) { - if(lineRenderMode == 1) + if(line_render_mode == 1) lineFound = Hack_FindLine(gpu, vertices, lineVertices); // Default enabled - else if (lineRenderMode == 2) + else if (line_render_mode == 2) lineFound = Hack_ForceLine(gpu, vertices, lineVertices); // Aggressive mode enabled (causes more artifacts) else lineFound = false; diff --git a/rsx/rsx_intf.cpp b/rsx/rsx_intf.cpp index 91528432..8cbeb383 100644 --- a/rsx/rsx_intf.cpp +++ b/rsx/rsx_intf.cpp @@ -19,6 +19,7 @@ #include "rsx_intf.h" #include "rsx.h" #include "../libretro_cbs.h" +#include "../beetle_psx_globals.h" #ifdef RSX_DUMP