aboutsummaryrefslogtreecommitdiff
path: root/patches/gpsp
diff options
context:
space:
mode:
Diffstat (limited to 'patches/gpsp')
-rw-r--r--patches/gpsp/0001-trimui-support.patch103
-rw-r--r--patches/gpsp/0002-core-options.patch149
-rw-r--r--patches/gpsp/0003-frameskip-changes.patch22
-rw-r--r--patches/gpsp/1000-avoid-audio-popping.patch16
4 files changed, 290 insertions, 0 deletions
diff --git a/patches/gpsp/0001-trimui-support.patch b/patches/gpsp/0001-trimui-support.patch
new file mode 100644
index 0000000..b3dd044
--- /dev/null
+++ b/patches/gpsp/0001-trimui-support.patch
@@ -0,0 +1,103 @@
+diff --git a/Makefile b/Makefile
+index f043a85..b2a5562 100644
+--- a/Makefile
++++ b/Makefile
+@@ -451,6 +451,20 @@ else ifeq ($(platform), rs90)
+ HAVE_DYNAREC := 1
+ CPU_ARCH := mips
+
++else ifeq ($(platform), trimui)
++ TARGET := $(TARGET_NAME)_libretro.so
++ CC = $(CROSS_COMPILE)gcc
++ SHARED := -shared -Wl,--version-script=link.T -mcpu=arm926ej-s -mtune=arm926ej-s
++ CFLAGS += -ffast-math -fdata-sections -ffunction-sections -flto -fno-PIC
++ LDFLAGS += -flto
++ ifeq (,$(DEBUG))
++ LDFLAGS += -s
++ endif
++ HAVE_DYNAREC := 1
++ CPU_ARCH_ARM_BLENDING_OPTS := 1
++ CPU_ARCH := arm
++ OPTIMIZE := -Ofast -DNDEBUG
++
+ # Windows
+ else
+ TARGET := $(TARGET_NAME)_libretro.dll
+@@ -479,7 +493,14 @@ ifeq ($(DEBUG), 1)
+ OPTIMIZE := -O0 -g
+ else
+ OPTIMIZE_SAFE := -O2 -DNDEBUG
+- OPTIMIZE := -O3 -DNDEBUG
++ OPTIMIZE ?= -O3 -DNDEBUG
++endif
++
++ifeq ($(PROFILE), GENERATE)
++ CFLAGS += -fprofile-generate=./profile/gpsp
++ LDFLAGS += -lgcov
++else ifeq ($(PROFILE), APPLY)
++ CFLAGS += -fprofile-use -fprofile-dir=../profile/gpsp -fbranch-probabilities
+ endif
+
+ DEFINES := -DHAVE_STRINGS_H -DHAVE_STDINT_H -DHAVE_INTTYPES_H -D__LIBRETRO__ -DINLINE=inline -Wall
+diff --git a/arm/arm_stub.S b/arm/arm_stub.S
+index 4058b22..03e9996 100644
+--- a/arm/arm_stub.S
++++ b/arm/arm_stub.S
+@@ -79,8 +79,26 @@ _##symbol:
+ #define IOREG_OFF 0x8D00
+
+
+-#define extract_u16(rd, rs) \
++#if __ARM_ARCH >= 6
++#define extract_u16(rd, rs) ;\
+ uxth rd, rs
++#else
++#define extract_u16(rd, rs) ;\
++ bic rd, rs, #0xff000000 ;\
++ bic rd, rd, #0x00ff0000
++#endif
++
++#if __ARM_ARCH >= 6
++#define sat_u4(rd, rs, shift) ;\
++ usat rd, #4, rs, shift
++#else
++#define sat_u4(rd, rs, shift) ;\
++ mov rd, rs, shift ;\
++ bic rd, rd, rd, asr #31 ;\
++ sub rd, rd, #15 ;\
++ and rd, rd, rd, asr #31 ;\
++ add rd, rd, #15
++#endif
+
+ @ Will load the register set from memory into the appropriate cached registers.
+ @ See arm_emit.h for listing explanation.
+@@ -539,7 +557,7 @@ return_to_main:
+ #define execute_store_builder(store_type, str_op, str_op16, load_op, tnum) ;\
+ ;\
+ defsymbl(execute_store_u##store_type) ;\
+- usat r2, #4, r0, asr #24 /* r2 contains [0-15] */;\
++ sat_u4(r2, r0, asr #24) /* r2 contains [0-15] */;\
+ add r2, r2, #((STORE_TBL_OFF + 16*4*tnum) >> 2) /* add table offset */;\
+ ldr pc, [reg_base, r2, lsl #2] /* load handler addr */;\
+ nop ;\
+@@ -628,7 +646,7 @@ execute_store_builder(32, str, str, ldr, 2)
+ @ This is a store that is executed in a strm case (so no SMC checks in-between)
+
+ defsymbl(execute_store_u32_safe)
+- usat r2, #4, r0, asr #24
++ sat_u4(r2, r0, asr #24)
+ add r2, r2, #((STORE_TBL_OFF + 16*4*3) >> 2)
+ ldr pc, [reg_base, r2, lsl #2]
+ nop
+@@ -773,9 +791,9 @@ lookup_pc_arm:
+ defsymbl(execute_load_##load_type) ;\
+ .if albits >= 1 ;\
+ ror r1, r0, #(albits) /* move alignment bits to MSB */;\
+- usat r1, #4, r1, asr #(24-albits) /* r1 contains [0-15] */;\
++ sat_u4(r1, r1, asr #(24-albits)) /* r1 contains [0-15] */;\
+ .else ;\
+- usat r1, #4, r0, asr #24 /* r1 contains [0-15] */;\
++ sat_u4(r1, r0, asr #24) /* r1 contains [0-15] */;\
+ .endif ;\
+ add r1, r1, #((STORE_TBL_OFF + 16*4*tnum) >> 2) /* add table offset */;\
+ ldr pc, [reg_base, r1, lsl #2] /* load handler addr */;\
diff --git a/patches/gpsp/0002-core-options.patch b/patches/gpsp/0002-core-options.patch
new file mode 100644
index 0000000..086c5ed
--- /dev/null
+++ b/patches/gpsp/0002-core-options.patch
@@ -0,0 +1,149 @@
+diff --git a/libretro_core_options.h b/libretro_core_options.h
+index c23a2c3..ae3c70c 100644
+--- a/libretro_core_options.h
++++ b/libretro_core_options.h
+@@ -56,11 +56,13 @@ struct retro_core_option_definition option_defs_us[] = {
+ {
+ "gpsp_bios",
+ "BIOS",
+- "Choose the BIOS image to use. The official BIOS must be provided by the user. Using a non-official (or builtin) BIOS might result in incompatibility problems with some games. Best results are to be achieved with the official Nintendo BIOS.",
++ "Choose the BIOS image to use. The official BIOS\n"
++ "must be provided by the user. Using a builtin\n"
++ "BIOS might result in compatibility problems.",
+ {
+- { "auto", "Auto select" },
+- { "builtin", "Builtin BIOS" },
+- { "official", "Original BIOS" },
++ { "auto", "auto" },
++ { "builtin", "builtin" },
++ { "official", "original" },
+ { NULL, NULL },
+ },
+ "auto"
+@@ -68,10 +70,11 @@ struct retro_core_option_definition option_defs_us[] = {
+ {
+ "gpsp_boot_mode",
+ "Boot mode",
+- "Choose whether to boot the BIOS before the game or not. There's not much difference in either modes.",
++ "Choose whether to boot the BIOS before the game\n"
++ "or not.",
+ {
+- { "game", "Boot to game" },
+- { "bios", "Boot to BIOS" },
++ { "game", "game" },
++ { "bios", "BIOS" },
+ { NULL, NULL },
+ },
+ "game"
+@@ -79,20 +82,23 @@ struct retro_core_option_definition option_defs_us[] = {
+ {
+ "gpsp_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. 'Auto (Threshold)' utilises the 'Frameskip Threshold (%)' setting. 'Fixed Interval' utilises the 'Frameskip Interval' setting.",
++ "Skip frames to avoid audio crackling. Improves\n"
++ "performance at the expense of visual smoothness.",
+ {
+ { "disabled", NULL },
+ { "auto", "Auto" },
+- { "auto_threshold", "Auto (Threshold)" },
+- { "fixed_interval", "Fixed Interval" },
++ { "auto_threshold", "Threshold" },
++ { "fixed_interval", "Fixed" },
+ { NULL, NULL },
+ },
+- "disabled"
++ "auto"
+ },
+ {
+ "gpsp_frameskip_threshold",
+- "Frameskip Threshold (%)",
+- "When 'Frameskip' is set to 'Auto (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.",
++ "FS Threshold (%)",
++ "When 'Frameskip' is set to 'Threshold', sets\n"
++ "how low the audio buffer can get before frames\n"
++ "will be skipped.",
+ {
+ { "15", NULL },
+ { "18", NULL },
+@@ -116,8 +122,9 @@ struct retro_core_option_definition option_defs_us[] = {
+ },
+ {
+ "gpsp_frameskip_interval",
+- "Frameskip Interval",
+- "When 'Frameskip' is set to 'Fixed Interval', the value set here is the number of frames omitted after a frame is rendered - i.e. '0' = 60fps, '1' = 30fps, '2' = 15fps, etc.",
++ "FS Interval",
++ "The maximum number of frames that can be skipped\n"
++ "before a new frame is rendered.",
+ {
+ { "0", NULL },
+ { "1", NULL },
+@@ -132,46 +139,49 @@ struct retro_core_option_definition option_defs_us[] = {
+ { "10", NULL },
+ { NULL, NULL },
+ },
+- "1"
++ "3"
+ },
+ {
+ "gpsp_color_correction",
+ "Color Correction",
+- "Adjusts output colors to match the display of real GBA hardware.",
++ "Adjusts output colors to match real GBA hardware.",
+ {
+- { "enabled", NULL },
+ { "disabled", NULL },
++ { "enabled", NULL },
+ { NULL, NULL },
+ },
+ "disabled"
+ },
+ {
+ "gpsp_frame_mixing",
+- "Interframe Blending",
+- "Simulates LCD ghosting effects by performing a 50:50 mix of the current and previous frames. Required for correct operation when playing games that exploit LCD ghosting for transparency effects (F-Zero, the Boktai series, etc.).",
++ "Frame Blending",
++ "Simulates LCD ghosting effects.",
+ {
+- { "enabled", NULL },
+ { "disabled", NULL },
++ { "enabled", NULL },
+ { NULL, NULL },
+ },
+ "disabled"
+ },
+ {
+ "gpsp_save_method",
+- "Backup Save Method (Restart)",
+- "Choose the data format used for cartridge save files. 'gpSP' can be used for compatibility with the stand-alone version of gpSP. 'libretro' provides better integration with the frontend.",
++ "Save Format",
++ "Choose the data format used for cartridge save\n"
++ "files. Must restart to take effect.",
+ {
+ { "gpSP", NULL },
+ { "libretro", NULL },
+ { NULL, NULL },
+ },
+- "gpSP"
++ "libretro"
+ },
+ #if defined(HAVE_DYNAREC)
+ {
+ "gpsp_drc",
+ "Dynamic Recompiler",
+- "Dynamically recompile CPU instructions to native instructions. Greatly improves performance, but may reduce accuracy.",
++ "Dynamically recompile CPU instructions to native\n"
++ "instructions. Greatly improves performance, but\n"
++ "may reduce accuracy.",
+ {
+ { "enabled", NULL },
+ { "disabled", NULL },
+@@ -183,7 +193,8 @@ struct retro_core_option_definition option_defs_us[] = {
+ {
+ "gpsp_turbo_period",
+ "Turbo Button Period",
+- "Specify the repeat interval (in frames) when holding down the Turbo A/B buttons.",
++ "Specify the repeat interval (in frames) when\n"
++ "holding down the Turbo A/B buttons.",
+ {
+ { "4", NULL },
+ { "5", NULL },
diff --git a/patches/gpsp/0003-frameskip-changes.patch b/patches/gpsp/0003-frameskip-changes.patch
new file mode 100644
index 0000000..3444df9
--- /dev/null
+++ b/patches/gpsp/0003-frameskip-changes.patch
@@ -0,0 +1,22 @@
+diff --git a/libretro.c b/libretro.c
+index f31235b..241a69e 100644
+--- a/libretro.c
++++ b/libretro.c
+@@ -1099,7 +1099,7 @@ void retro_run(void)
+ 1 : 0;
+
+ if (!skip_next_frame ||
+- (frameskip_counter >= FRAMESKIP_MAX))
++ (frameskip_counter >= frameskip_interval))
+ {
+ skip_next_frame = 0;
+ frameskip_counter = 0;
+@@ -1116,7 +1116,7 @@ void retro_run(void)
+ 1 : 0;
+
+ if (!skip_next_frame ||
+- (frameskip_counter >= FRAMESKIP_MAX))
++ (frameskip_counter >= frameskip_interval))
+ {
+ skip_next_frame = 0;
+ frameskip_counter = 0;
diff --git a/patches/gpsp/1000-avoid-audio-popping.patch b/patches/gpsp/1000-avoid-audio-popping.patch
new file mode 100644
index 0000000..ed868a4
--- /dev/null
+++ b/patches/gpsp/1000-avoid-audio-popping.patch
@@ -0,0 +1,16 @@
+diff --git a/sound.h b/sound.h
+index 08d1de5..93221d5 100644
+--- a/sound.h
++++ b/sound.h
+@@ -24,8 +24,10 @@
+ #define BUFFER_SIZE_MASK (BUFFER_SIZE - 1)
+
+ #define GBA_SOUND_FREQUENCY (64 * 1024)
++#define GBA_60HZ_RATE 16853760.0f /* 228*(272+960)*60 */
+
+-#define GBC_BASE_RATE ((float)(16 * 1024 * 1024))
++// run GBA at 60Hz (~0.5% faster) to better match host display
++#define GBC_BASE_RATE GBA_60HZ_RATE
+
+ typedef enum
+ {