PKG: optimize libretro-scummvm & libretro-scummvm-legacy and lighten (#150)

* PKG: optimize `lr-scummvm-legacy`
- reduce number of linked engines (only LITE+ & no WIP)
- cap framerate & increase audio_buffer (lr-option)

* PKG: optimize `lr-scummvm`
- disable Tooltip
- reduce engines count (inline with standalone)
- cap framerate->15Hz & samplerate-> 44100Hz (increase cursor speed)
This commit is contained in:
Apaczer
2025-02-10 22:26:19 +01:00
committed by GitHub
parent 0bbd0bb001
commit e1c37564d6
6 changed files with 459 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
From 2a25e6b5e20fd9638d6da37fef29165eb63a6db0 Mon Sep 17 00:00:00 2001
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
Date: Thu, 30 Jan 2025 21:12:31 +0100
Subject: [PATCH 1/3] LIBRETRO-Makefile: optimize by reducing engines count
also -fno-PIC
---
backends/platform/libretro/build/Makefile | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/backends/platform/libretro/build/Makefile b/backends/platform/libretro/build/Makefile
index 25d141eb551..066f6472422 100644
--- a/backends/platform/libretro/build/Makefile
+++ b/backends/platform/libretro/build/Makefile
@@ -283,15 +283,17 @@ else ifeq ($(platform), miyoo)
LD = /opt/miyoo/usr/bin/arm-linux-g++
AR = /opt/miyoo/usr/bin/arm-linux-ar cru
RANLIB = /opt/miyoo/usr/bin/arm-linux-ranlib
- DEFINES += -DDINGUX -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -fPIC
+ DEFINES += -DDINGUX -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -fno-PIC
DEFINES += -ffunction-sections -fdata-sections
- LDFLAGS += -shared -Wl,--gc-sections -Wl,--version-script=../link.T -fPIC
+ LDFLAGS += -shared -Wl,--gc-sections -Wl,--version-script=../link.T -fno-PIC
USE_VORBIS = 0
USE_THEORADEC = 0
USE_TREMOR = 1
USE_LIBCO = 0
HAVE_MT32EMU = 0
NO_HIGH_DEF := 1
+ LITE := 1
+ NO_WIP := 1
else ifeq ($(platform), android-armv7)
TARGET := $(TARGET_NAME)_libretro_android.so
--
2.45.2.windows.1

View File

@@ -0,0 +1,81 @@
From 9af918e6c23832bfe6545f3d5db8fcc6d8130948 Mon Sep 17 00:00:00 2001
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
Date: Sun, 9 Feb 2025 15:09:54 +0100
Subject: [PATCH 2/3] LR-Makefile.common: mv useful engines to LITE type
---
backends/platform/libretro/build/Makefile.common | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/backends/platform/libretro/build/Makefile.common b/backends/platform/libretro/build/Makefile.common
index c683e2c7e59..dabbe1c38d0 100644
--- a/backends/platform/libretro/build/Makefile.common
+++ b/backends/platform/libretro/build/Makefile.common
@@ -9,6 +9,7 @@ LIBRETRO_COMM_DIR = $(LIBRETRO_DIR)/libretro-common
ENABLED=STATIC_PLUGIN
ifeq ($(NO_HIGH_DEF), 1)
+ENABLE_ACCESS = $(ENABLED)
ENABLE_AGI = $(ENABLED)
ENABLE_AGOS = $(ENABLED)
ENABLE_CINE = $(ENABLED)
@@ -20,10 +21,12 @@ ENABLE_GOB = $(ENABLED)
ENABLE_HE = $(ENABLED)
ENABLE_IHNM = $(ENABLED)
ENABLE_KYRA = $(ENABLED)
+ENABLE_LAB = $(ENABLED)
ENABLE_LOL = $(ENABLED)
ENABLE_LURE = $(ENABLED)
ENABLE_MADE = $(ENABLED)
ENABLE_PARALLACTION = $(ENABLED)
+ENABLE_PLUMBERS = $(ENABLED)
ENABLE_QUEEN = $(ENABLED)
ENABLE_SAGA = $(ENABLED)
ENABLE_SCI = $(ENABLED)
@@ -46,6 +49,7 @@ ENABLE_TSAGE = $(ENABLED)
ENABLE_VOYEUR = $(ENABLED)
ENABLE_XEEN = $(ENABLED)
else
+ENABLE_ACCESS = $(ENABLED)
ENABLE_AGI = $(ENABLED)
ENABLE_AGOS = $(ENABLED)
ENABLE_AGOS2 = $(ENABLED)
@@ -59,11 +63,13 @@ ENABLE_GROOVIE = $(ENABLED)
ENABLE_HE = $(ENABLED)
ENABLE_IHNM = $(ENABLED)
ENABLE_KYRA = $(ENABLED)
+ENABLE_LAB = $(ENABLED)
ENABLE_LOL = $(ENABLED)
ENABLE_LURE = $(ENABLED)
ENABLE_MADE = $(ENABLED)
ENABLE_MORTEVIELLE = $(ENABLED)
ENABLE_PARALLACTION = $(ENABLED)
+ENABLE_PLUMBERS = $(ENABLED)
ENABLE_QUEEN = $(ENABLED)
ENABLE_SAGA = $(ENABLED)
ENABLE_SCI = $(ENABLED)
@@ -80,7 +86,6 @@ ENABLE_TOUCHE = $(ENABLED)
ENABLE_TUCKER = $(ENABLED)
ifneq ($(LITE), 1)
-ENABLE_ACCESS = $(ENABLED)
ENABLE_ADL = $(ENABLED)
ENABLE_BBVS = $(ENABLED)
ENABLE_BLADERUNNER = $(ENABLED)
@@ -95,13 +100,11 @@ ENABLE_HDB = $(ENABLED)
ENABLE_HUGO = $(ENABLED)
ENABLE_HOPKINS = $(ENABLED)
ENABLE_ILLUSIONS = $(ENABLED)
-ENABLE_LAB = $(ENABLED)
ENABLE_MADS = $(ENABLED)
ENABLE_MOHAWK = $(ENABLED)
ENABLE_MYST = $(ENABLED)
ENABLE_NEVERHOOD = $(ENABLED)
ENABLE_PEGASUS = $(ENABLED)
-ENABLE_PLUMBERS = $(ENABLED)
ENABLE_PRINCE = $(ENABLED)
ENABLE_RIVEN = $(ENABLED)
ENABLE_SUPERNOVA = $(ENABLED)
--
2.45.2.windows.1

View File

@@ -0,0 +1,116 @@
From 3eb8564fd92ae2939275a40ea67c3475dadd431b Mon Sep 17 00:00:00 2001
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
Date: Mon, 10 Feb 2025 21:28:33 +0100
Subject: [PATCH 3/3] LIBRETRO: add "Framerate cap" option to reduce audio
stutter
via MM+ and: https://github.com/StupidHoroscope/libretro-scummvm-miyoo-backend/commit/6c3954f916bf430e7756afd8ca74618d48b56744
---
backends/platform/libretro/libretro.cpp | 32 +++++++++++++++++--
.../platform/libretro/libretro_core_options.h | 19 +++++++++++
2 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/backends/platform/libretro/libretro.cpp b/backends/platform/libretro/libretro.cpp
index 3a5bf84b4bc..1668182774b 100644
--- a/backends/platform/libretro/libretro.cpp
+++ b/backends/platform/libretro/libretro.cpp
@@ -55,6 +55,10 @@ static bool analog_response_is_quadratic = false;
static float mouse_speed = 1.0f;
static bool speed_hack_is_enabled = false;
+static int cap_fps=50u;
+
+static size_t audio_buffer_length = 0;
+static uint32* audio_buffer = NULL;
char cmd_params[20][200];
char cmd_params_num;
@@ -144,6 +148,11 @@ void retro_init (void)
void retro_deinit(void)
{
+ if (audio_buffer != NULL)
+ {
+ delete [] audio_buffer;
+ audio_buffer = NULL;
+ }
}
void parse_command_params(char* cmdline)
@@ -258,6 +267,13 @@ static void update_variables(void)
if (strcmp(var.value, "enabled") == 0)
speed_hack_is_enabled = true;
}
+ var.key = "scummvm_audio_cap_fps";
+ var.value = NULL;
+ cap_fps = 50u;
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
+ {
+ cap_fps = (int)atof(var.value);
+ }
}
static int retro_device = RETRO_DEVICE_JOYPAD;
@@ -463,8 +479,18 @@ void retro_run (void)
video_cb(screen.pixels, screen.w, screen.h, screen.pitch);
/* Upload audio */
- static uint32 buf[735];
- int count = ((Audio::MixerImpl*)g_system->getMixer())->mixCallback((byte*)buf, 735*4);
+ // HACK: Reduce audio buffer under-run by capping framerate to lower value.
+ int samples_per_frame = 44100u / (cap_fps);
+ if (audio_buffer == NULL || samples_per_frame != audio_buffer_length)
+ {
+ if (audio_buffer != NULL)
+ {
+ delete [] audio_buffer;
+ }
+ audio_buffer_length = samples_per_frame;
+ audio_buffer = new uint32[audio_buffer_length];
+ }
+ int count = ((Audio::MixerImpl*)g_system->getMixer())->mixCallback((byte*)audio_buffer, audio_buffer_length*4);
#if defined(_3DS)
/* Hack: 3DS will produce static noise
* unless we manually send a zeroed
@@ -478,7 +504,7 @@ void retro_run (void)
}
else
#endif
- audio_batch_cb((int16_t*)buf, count);
+ audio_batch_cb((int16_t*)audio_buffer, count);
}
#if defined(USE_LIBCO)
diff --git a/backends/platform/libretro/libretro_core_options.h b/backends/platform/libretro/libretro_core_options.h
index 0fbd01e86d8..a32c0e37529 100644
--- a/backends/platform/libretro/libretro_core_options.h
+++ b/backends/platform/libretro/libretro_core_options.h
@@ -138,6 +138,25 @@ struct retro_core_option_definition option_defs_us[] = {
"disabled"
#endif
},
+ {
+ "scummvm_audio_cap_fps",
+ "Framerate cap",
+ "Lock max framerate on resource-intensive games, to reduce audio crackling",
+ {
+ { "15", NULL },
+ { "20", NULL },
+ { "25", NULL },
+ { "30", NULL },
+ { "35", NULL },
+ { "40", NULL },
+ { "45", NULL },
+ { "50", NULL },
+ { "55", NULL },
+ { "60", NULL },
+ { NULL, NULL },
+ },
+ "50"
+ },
{ NULL, NULL, NULL, {{0}}, NULL },
};
--
2.45.2.windows.1