From c0c7ccbc14a81fc2bc0c3a14c403e0ab54087290 Mon Sep 17 00:00:00 2001 From: neonloop Date: Fri, 22 Oct 2021 15:04:42 +0000 Subject: Adds picodrive core --- .gitignore | 1 + Makefile | 10 ++- overrides.c | 2 + overrides/picodrive.h | 61 +++++++++++++ patches/picodrive/0001-frameskip-interval.patch | 113 ++++++++++++++++++++++++ patches/picodrive/1000-trimui-build.patch | 42 +++++++++ 6 files changed, 227 insertions(+), 2 deletions(-) create mode 100644 overrides/picodrive.h create mode 100644 patches/picodrive/0001-frameskip-interval.patch create mode 100644 patches/picodrive/1000-trimui-build.patch diff --git a/.gitignore b/.gitignore index fc49c3e..8120fdf 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ picoarch /mame2000 /mame2003_plus /pcsx_rearmed +/picodrive /quicknes /smsplus-gx /snes9x2002 diff --git a/Makefile b/Makefile index a5b6977..90afbd6 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ LDFLAGS = -lc -ldl -lgcc -lm -lSDL -lasound -lpng -lz -Wl,--gc-sections -flto # Unpolished or slow cores that build # EXTRA_CORES += fbalpha2012 # EXTRA_CORES += mame2003_plus -CORES = beetle-pce-fast fceumm gambatte gme gpsp mame2000 pcsx_rearmed quicknes smsplus-gx snes9x2002 snes9x2005 $(EXTRA_CORES) +CORES = beetle-pce-fast fceumm gambatte gme gpsp mame2000 pcsx_rearmed picodrive quicknes smsplus-gx snes9x2002 snes9x2005 $(EXTRA_CORES) beetle-pce-fast_REPO = https://github.com/libretro/beetle-pce-fast-libretro beetle-pce-fast_CORE = mednafen_pce_fast_libretro.so @@ -39,6 +39,8 @@ mame2003_plus_REPO = https://github.com/libretro/mame2003-plus-libretro pcsx_rearmed_MAKEFILE = Makefile.libretro +picodrive_MAKEFILE = Makefile.libretro + quicknes_REPO = https://github.com/libretro/QuickNES_Core smsplus-gx_MAKEFILE = Makefile.libretro @@ -113,7 +115,7 @@ $1_BUILD_PATH ?= $(1) $1_MAKE = make $(and $($1_MAKEFILE),-f $($1_MAKEFILE)) platform=$(platform) $(and $(DEBUG),DEBUG=$(DEBUG)) $(and $(PROFILE),PROFILE=$(PROFILE)) $($(1)_FLAGS) $(1): - git clone $(if $($1_REVISION),,--depth 1) $$($(1)_REPO) $(1) + git clone $(if $($1_REVISION),,--depth 1) --recursive $$($(1)_REPO) $(1) $(if $1_REVISION,cd $(1) && git checkout $($1_REVISION),) (test ! -d patches/$(1)) || (cd $(1) && $(foreach patch, $(sort $(wildcard patches/$(1)/*.patch)), git apply -p1 < ../$(patch) &&) true) @@ -181,6 +183,10 @@ mame2003_plus_ROM_DIR = ARCADE mame2003_plus_TYPES = zip mame2003_plus_PAK_NAME = Arcade (MAME 2003-plus) +picodrive_ROM_DIR = MD +picodrive_TYPES = bin,gen,smd,md,32x,cue,iso,chd,sms,m3u,68k,sgd +picodrive_PAK_NAME = Genesis + pcsx_rearmed_ROM_DIR = PS pcsx_rearmed_TYPES = bin,cue,img,mdf,pbp,toc,cbn,m3u,chd pcsx_rearmed_PAK_NAME = PlayStation diff --git a/overrides.c b/overrides.c index 27d130e..8a37332 100644 --- a/overrides.c +++ b/overrides.c @@ -6,6 +6,7 @@ #include "overrides/gpsp.h" #include "overrides/mame2000.h" #include "overrides/pcsx_rearmed.h" +#include "overrides/picodrive.h" #include "overrides/quicknes.h" #include "overrides/smsplus.h" #include "overrides/snes9x2002.h" @@ -20,6 +21,7 @@ static const struct core_override overrides[] = { gpsp_overrides, mame2000_overrides, pcsx_rearmed_overrides, + picodrive_overrides, quicknes_overrides, smsplus_overrides, snes9x2002_overrides, diff --git a/overrides/picodrive.h b/overrides/picodrive.h new file mode 100644 index 0000000..31618da --- /dev/null +++ b/overrides/picodrive.h @@ -0,0 +1,61 @@ +#include "overrides.h" + +static const struct core_override_option picodrive_core_option_overrides[] = { + { + .key = "picodrive_overscan", + .info = "Crop out the potentially random glitchy video output that would have been hidden by the TV bezel." + }, + { + .key = "picodrive_audio_filter", + .info = "Enable a low pass audio filter to better simulate the characteristic sound of a Model 1 Genesis. Ignored for SMS and PICO.", + }, + { + .key = "picodrive_lowpass_range", + .info = "Specify the cut-off frequency of the audio low pass filter. A higher value increases the perceived 'strength' of the filter.", + }, + { + .key = "picodrive_frameskip", + .info = "Skip frames to avoid audio crackling. Improves performance at the expense of visual smoothness.", + }, + { + .key = "picodrive_frameskip_threshold", + .desc = "FS Threshold (%)", + .info = "When 'Frameskip' is set to 'Threshold', sets how low the audio buffer can get before frames will be skipped.", + }, + { + .key = "picodrive_aspect", + .blocked = true, + }, + { NULL } +}; + +me_bind_action picodrive_ctrl_actions[] = +{ + { "UP ", 1 << RETRO_DEVICE_ID_JOYPAD_UP}, + { "DOWN ", 1 << RETRO_DEVICE_ID_JOYPAD_DOWN }, + { "LEFT ", 1 << RETRO_DEVICE_ID_JOYPAD_LEFT }, + { "RIGHT ", 1 << RETRO_DEVICE_ID_JOYPAD_RIGHT }, + { "A ", 1 << RETRO_DEVICE_ID_JOYPAD_Y }, + { "B ", 1 << RETRO_DEVICE_ID_JOYPAD_B }, + { "C ", 1 << RETRO_DEVICE_ID_JOYPAD_A }, + { "X ", 1 << RETRO_DEVICE_ID_JOYPAD_L }, + { "Y ", 1 << RETRO_DEVICE_ID_JOYPAD_X }, + { "Z ", 1 << RETRO_DEVICE_ID_JOYPAD_R }, + { "MODE ", 1 << RETRO_DEVICE_ID_JOYPAD_SELECT }, + { "START ", 1 << RETRO_DEVICE_ID_JOYPAD_START }, + { NULL, 0 } +}; + +const struct core_override_fast_forward picodrive_fast_forward = { + .type_key = "picodrive_frameskip", + .type_value = "auto", + .interval_key = "picodrive_frameskip_interval", +}; + +#define picodrive_overrides { \ + .core_name = "picodrive", \ + .fast_forward = &picodrive_fast_forward, \ + .actions = picodrive_ctrl_actions, \ + .action_size = array_size(picodrive_ctrl_actions), \ + .options = picodrive_core_option_overrides \ +} diff --git a/patches/picodrive/0001-frameskip-interval.patch b/patches/picodrive/0001-frameskip-interval.patch new file mode 100644 index 0000000..bfc9b39 --- /dev/null +++ b/patches/picodrive/0001-frameskip-interval.patch @@ -0,0 +1,113 @@ +diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c +index 3574c32..ac96c4f 100644 +--- a/platform/libretro/libretro.c ++++ b/platform/libretro/libretro.c +@@ -137,13 +137,11 @@ char **g_argv; + static unsigned frameskip_type = 0; + static unsigned frameskip_threshold = 0; + static uint16_t frameskip_counter = 0; ++static unsigned frameskip_interval = 0; + + static bool retro_audio_buff_active = false; + static unsigned retro_audio_buff_occupancy = 0; + static bool retro_audio_buff_underrun = false; +-/* Maximum number of consecutive frames that +- * can be skipped */ +-#define FRAMESKIP_MAX 60 + + static unsigned audio_latency = 0; + static bool update_audio_latency = false; +@@ -1926,7 +1924,7 @@ static void update_variables(bool first_run) + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "auto") == 0) + frameskip_type = 1; +- else if (strcmp(var.value, "manual") == 0) ++ else if (strcmp(var.value, "auto_threshold") == 0) + frameskip_type = 2; + } + +@@ -1936,6 +1934,12 @@ static void update_variables(bool first_run) + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + frameskip_threshold = strtol(var.value, NULL, 10); + ++ frameskip_interval = 4; ++ var.key = "picodrive_frameskip_interval"; ++ var.value = NULL; ++ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) ++ frameskip_interval = strtol(var.value, NULL, 10); ++ + old_vout_format = vout_format; + var.value = NULL; + var.key = "picodrive_renderer"; +@@ -2041,7 +2045,7 @@ void retro_run(void) + break; + } + +- if (!PicoIn.skipFrame || (frameskip_counter >= FRAMESKIP_MAX)) { ++ if (!PicoIn.skipFrame || (frameskip_counter >= frameskip_interval)) { + PicoIn.skipFrame = 0; + frameskip_counter = 0; + } else +@@ -2211,6 +2215,7 @@ void retro_init(void) + frameskip_type = 0; + frameskip_threshold = 0; + frameskip_counter = 0; ++ frameskip_interval = 0; + retro_audio_buff_active = false; + retro_audio_buff_occupancy = 0; + retro_audio_buff_underrun = false; +diff --git a/platform/libretro/libretro_core_options.h b/platform/libretro/libretro_core_options.h +index 23ca416..2512eac 100644 +--- a/platform/libretro/libretro_core_options.h ++++ b/platform/libretro/libretro_core_options.h +@@ -203,11 +203,11 @@ struct retro_core_option_definition option_defs_us[] = { + { + "picodrive_frameskip", + "Frameskip", +- "Skip frames to avoid audio buffer under-run (crackling). Improves performance at the expense of visual smoothness. 'Auto' skips frames when advised by the frontend. 'Manual' utilises the 'Frameskip Threshold (%)' setting.", ++ "Skip frames to avoid audio buffer under-run (crackling). Improves performance at the expense of visual smoothness. 'Auto' skips frames when advised by the frontend. 'Threshold' utilises the 'Frameskip Threshold (%)' setting.", + { +- { "disabled", NULL }, +- { "auto", "Auto" }, +- { "manual", "Manual" }, ++ { "disabled", NULL }, ++ { "auto", "Auto" }, ++ { "auto_threshold", "Threshold" }, + { NULL, NULL }, + }, + "disabled" +@@ -215,7 +215,7 @@ struct retro_core_option_definition option_defs_us[] = { + { + "picodrive_frameskip_threshold", + "Frameskip Threshold (%)", +- "When 'Frameskip' is set to 'Manual', specifies the audio buffer occupancy threshold (percentage) below which frames will be skipped. Higher values reduce the risk of crackling by causing frames to be dropped more frequently.", ++ "When 'Frameskip' is set to 'Threshold', specifies the audio buffer occupancy threshold (percentage) below which frames will be skipped. Higher values reduce the risk of crackling by causing frames to be dropped more frequently.", + { + { "15", NULL }, + { "18", NULL }, +@@ -237,6 +237,25 @@ struct retro_core_option_definition option_defs_us[] = { + }, + "33" + }, ++ { ++ "picodrive_frameskip_interval", ++ "Frameskip Interval", ++ "The maximum number of frames that can be skipped before a new frame is rendered.", ++ { ++ { "1", NULL }, ++ { "2", NULL }, ++ { "3", NULL }, ++ { "4", NULL }, ++ { "5", NULL }, ++ { "6", NULL }, ++ { "7", NULL }, ++ { "8", NULL }, ++ { "9", NULL }, ++ { "10", NULL }, ++ { NULL, NULL }, ++ }, ++ "3" ++ }, + { + "picodrive_renderer", + "Renderer", diff --git a/patches/picodrive/1000-trimui-build.patch b/patches/picodrive/1000-trimui-build.patch new file mode 100644 index 0000000..6e21ae7 --- /dev/null +++ b/patches/picodrive/1000-trimui-build.patch @@ -0,0 +1,42 @@ +diff --git a/Makefile.libretro b/Makefile.libretro +index 919e0c1..e3bcd36 100644 +--- a/Makefile.libretro ++++ b/Makefile.libretro +@@ -517,6 +517,23 @@ else ifeq ($(platform), miyoo) + LOW_MEMORY = 1 + NO_ARM_ASM = 1 + ++# TRIMUI ++else ifeq ($(platform), trimui) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--no-undefined ++ DONT_COMPILE_IN_ZLIB = 1 ++ CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -D__GCW0__ ++ CFLAGS += -fno-PIC -flto ++ LDFLAGS += -flto ++ HAVE_ARMv6 = 0 ++ LOW_MEMORY = 1 ++ ifeq (,$(DEBUG)) ++ LDFLAGS += -s ++ endif ++ + # Windows MSVC 2017 all architectures + else ifneq (,$(findstring windows_msvc2017,$(platform))) + NO_GCC := 1 +@@ -720,6 +737,13 @@ else + endif + endif + ++ifeq ($(PROFILE), GENERATE) ++ CFLAGS += -fprofile-generate=./profile/$(TARGET_NAME) ++ LDFLAGS += -lgcov ++else ifeq ($(PROFILE), APPLY) ++ CFLAGS += -fprofile-use -fprofile-dir=../profile/$(TARGET_NAME) -fbranch-probabilities ++endif ++ + ifneq (,$(findstring msvc,$(platform))) + OBJOUT = -Fo + LINKOUT = -out: -- cgit v1.2.3