aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c1
-rw-r--r--core.c83
-rw-r--r--core.h3
-rw-r--r--funkey/fk_instant_play.c1
-rw-r--r--main.c2
-rw-r--r--menu.c13
-rw-r--r--options.c1
-rw-r--r--options.h1
-rw-r--r--patches/pcsx_rearmed/1000-trimui-support.patch28
-rw-r--r--scale.c20
10 files changed, 133 insertions, 20 deletions
diff --git a/config.c b/config.c
index 91835f8..beab9a9 100644
--- a/config.c
+++ b/config.c
@@ -26,6 +26,7 @@ static const struct {
CE_NUM(show_cpu),
CE_NUM(limit_frames),
CE_NUM(enable_drc),
+ CE_NUM(use_srm),
CE_NUM(audio_buffer_size),
CE_NUM(scale_size),
CE_NUM(scale_filter),
diff --git a/core.c b/core.c
index 6f28d28..2a1cf5b 100644
--- a/core.c
+++ b/core.c
@@ -68,8 +68,12 @@ void sram_write(void) {
if (!sram_size) {
return;
}
-
- content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".sav");
+
+ if (use_srm == 1) {
+ content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".srm");
+ } else {
+ content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".sav");
+ }
sram_file = fopen(filename, "w");
if (!sram_file) {
@@ -98,7 +102,23 @@ void sram_read(void) {
return;
}
- content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".sav");
+ if (use_srm == 1) {
+ content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".srm");
+
+ sram_file = fopen(filename, "r");
+ if (!sram_file) {
+ memset(filename, 0, sizeof(filename));
+ content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".sav");
+ }
+ } else {
+ content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".sav");
+
+ sram_file = fopen(filename, "r");
+ if (!sram_file) {
+ memset(filename, 0, sizeof(filename));
+ content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".srm");
+ }
+ }
sram_file = fopen(filename, "r");
if (!sram_file) {
@@ -114,6 +134,61 @@ void sram_read(void) {
fclose(sram_file);
}
+void rtc_write(void) {
+ char filename[MAX_PATH];
+ FILE *rtc_file = NULL;
+ void *rtc;
+
+ size_t rtc_size = current_core.retro_get_memory_size(RETRO_MEMORY_RTC);
+ if (!rtc_size) {
+ return;
+ }
+
+ content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".rtc");
+
+ rtc_file = fopen(filename, "w");
+ if (!rtc_file) {
+ PA_ERROR("Error opening RTC file: %s\n", strerror(errno));
+ return;
+ }
+
+ rtc = current_core.retro_get_memory_data(RETRO_MEMORY_RTC);
+
+ if (!rtc || rtc_size != fwrite(rtc, 1, rtc_size, rtc_file)) {
+ PA_ERROR("Error writing RTC data to file\n");
+ }
+
+ fclose(rtc_file);
+
+ sync();
+}
+
+void rtc_read(void) {
+ char filename[MAX_PATH];
+ FILE *rtc_file = NULL;
+ void *rtc;
+
+ size_t rtc_size = current_core.retro_get_memory_size(RETRO_MEMORY_RTC);
+ if (!rtc_size) {
+ return;
+ }
+
+ content_based_name(content, filename, MAX_PATH, save_dir, NULL, ".rtc");
+
+ rtc_file = fopen(filename, "r");
+ if (!rtc_file) {
+ return;
+ }
+
+ rtc = current_core.retro_get_memory_data(RETRO_MEMORY_RTC);
+
+ if (!rtc || !fread(rtc, 1, rtc_size, rtc_file)) {
+ PA_ERROR("Error reading RTC data\n");
+ }
+
+ fclose(rtc_file);
+}
+
bool state_allowed(void) {
return current_core.retro_serialize_size() > 0;
}
@@ -675,6 +750,7 @@ int core_load_content(struct content *content) {
}
sram_read();
+ rtc_read();
if (!strcmp(core_name, "fmsx") && current_core.retro_set_controller_port_device) {
/* fMSX works best with joypad + keyboard */
@@ -769,6 +845,7 @@ void core_run_frame(void) {
void core_unload_content(void) {
sram_write();
+ rtc_write();
cheats_free(cheats);
cheats = NULL;
diff --git a/core.h b/core.h
index 8049aa7..33deac1 100644
--- a/core.h
+++ b/core.h
@@ -48,6 +48,9 @@ void save_relative_path(char *buf, size_t len, const char *basename);
void sram_read(void);
void sram_write(void);
+void rtc_read(void);
+void rtc_write(void);
+
bool state_allowed(void);
void state_file_name(char *name, size_t size, int slot);
bool state_exists(int slot);
diff --git a/funkey/fk_instant_play.c b/funkey/fk_instant_play.c
index a0d9451..261821b 100644
--- a/funkey/fk_instant_play.c
+++ b/funkey/fk_instant_play.c
@@ -84,6 +84,7 @@ void FK_Suspend(void)
FK_Autosave();
sram_write();
+ rtc_write();
save_config(CONFIG_TYPE_AUTO);
PA_INFO("Suspending with %s %s %s %s %s\n", SHELL_CMD_INSTANT_PLAY, "save", prog_name, core_path, content->path);
diff --git a/main.c b/main.c
index 1408a46..5883bee 100644
--- a/main.c
+++ b/main.c
@@ -210,6 +210,7 @@ void set_defaults(void)
limit_frames = 1;
enable_audio = 1;
enable_drc = 1;
+ use_srm = 0;
audio_buffer_size = 5;
scale_size = SCALE_SIZE_NONE;
scale_filter = SCALE_FILTER_NEAREST;
@@ -389,6 +390,7 @@ static void perform_emu_action(void) {
case EACTION_MENU:
toggle_fast_forward(1); /* Force FF off */
sram_write();
+ rtc_write();
in_menu = true;
#if defined(MMENU)
if (mmenu && content && strlen(content->path)) {
diff --git a/menu.c b/menu.c
index a76ea44..1d68619 100644
--- a/menu.c
+++ b/menu.c
@@ -538,6 +538,11 @@ static const char h_scale_filter[] =
"When stretching, how missing pixels are filled.\n"
"Nearest copies the last pixel. Sharp keeps pixels\n"
"aligned where possible. Smooth adds a blur effect.";
+
+static const char h_use_srm[] =
+ "Use .srm files for SRAM saves, needed for\n"
+ "compatibility with mainline retroarch saves.\n"
+ "Save file compression needs to be off in retroarch.";
static const char *men_scale_size[] = { "Native", "Aspect", "Full", NULL};
#else
@@ -561,6 +566,12 @@ static const char h_scale_filter[] =
"are filled. Nearest copies the last\n"
"pixel. Sharp tries to keep pixels\n"
"aligned. Smooth adds a blur effect.";
+
+static const char h_use_srm[] =
+ "Use .srm files for SRAM saves,\n"
+ "needed for compatibility with mainline\n"
+ "retroarch saves. Save file compression\n"
+ "needs to be off in retroarch.";
static const char *men_scale_size[] = { "Native", "Aspect", "Full", "Crop", NULL};
#endif
@@ -615,6 +626,8 @@ const char *config_label(int id, int *offs) {
static menu_entry e_menu_config_options[] =
{
+ mee_onoff_h ("Use .srm saves", 0, use_srm, 1, h_use_srm),
+ mee_label (""),
mee_cust_nosave ("Save global config", MA_OPT_SAVECFG, mh_savecfg, mgn_saveloadcfg),
mee_cust_nosave ("Save game config", MA_OPT_SAVECFG_GAME, mh_savecfg, mgn_saveloadcfg),
mee_handler_id_h ("Delete game config", MA_OPT_RMCFG_GAME, mh_rmcfg, h_rm_config_game),
diff --git a/options.c b/options.c
index decc29c..7c9c921 100644
--- a/options.c
+++ b/options.c
@@ -13,6 +13,7 @@ int show_hud;
int limit_frames;
int enable_audio;
int enable_drc;
+int use_srm;
unsigned audio_buffer_size;
enum scale_size scale_size;
enum scale_filter scale_filter;
diff --git a/options.h b/options.h
index c76e251..3b8e7f5 100644
--- a/options.h
+++ b/options.h
@@ -9,6 +9,7 @@ extern int show_hud;
extern int limit_frames;
extern int enable_audio;
extern int enable_drc;
+extern int use_srm;
extern unsigned audio_buffer_size;
extern enum scale_size scale_size;
extern enum scale_filter scale_filter;
diff --git a/patches/pcsx_rearmed/1000-trimui-support.patch b/patches/pcsx_rearmed/1000-trimui-support.patch
index d751ac1..5e442dd 100644
--- a/patches/pcsx_rearmed/1000-trimui-support.patch
+++ b/patches/pcsx_rearmed/1000-trimui-support.patch
@@ -1,5 +1,5 @@
diff --git a/Makefile b/Makefile
-index ff8d1bb..8eef4a7 100644
+index 9b5d245..ae7745c 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@ TARGET ?= pcsx
@@ -12,10 +12,10 @@ index ff8d1bb..8eef4a7 100644
ifeq ($(platform), $(filter $(platform), vita ctr))
CFLAGS += -O3 -DNDEBUG
diff --git a/Makefile.libretro b/Makefile.libretro
-index 069290c..692d998 100644
+index d3a3530..7711b07 100644
--- a/Makefile.libretro
+++ b/Makefile.libretro
-@@ -394,6 +394,27 @@ else ifeq ($(platform), rpi4_64)
+@@ -458,6 +458,27 @@ else ifeq ($(platform), rpi4_64)
fpic := -fPIC
CFLAGS += -march=armv8-a+crc+simd -mtune=cortex-a72 -ftree-vectorize
@@ -43,7 +43,7 @@ index 069290c..692d998 100644
# Classic Platforms ####################
# Platform affix = classic_<ISA>_<µARCH>
# Help at https://modmyclassic.com/comp
-@@ -519,6 +540,13 @@ CFLAGS += $(fpic)
+@@ -590,6 +611,13 @@ CFLAGS += $(fpic)
MAIN_LDFLAGS += -shared
MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
@@ -58,10 +58,10 @@ index 069290c..692d998 100644
ifeq ($(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep __SIZEOF_LONG__ | awk '{print $$3}'),4)
CFLAGS += -D_FILE_OFFSET_BITS=64
diff --git a/frontend/libretro.c b/frontend/libretro.c
-index 938b8e5..dcc16ef 100644
+index 1808c5e..35ce1d1 100644
--- a/frontend/libretro.c
+++ b/frontend/libretro.c
-@@ -3057,7 +3057,7 @@ void retro_init(void)
+@@ -3748,7 +3748,7 @@ void retro_init(void)
* we have to do this because cache misses and some IO penalties
* are not emulated. Warning: changing this may break compatibility. */
Config.cycle_multiplier = CYCLE_MULT_DEFAULT;
@@ -71,19 +71,19 @@ index 938b8e5..dcc16ef 100644
#endif
pl_rearmed_cbs.gpu_peops.iUseDither = 1;
diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h
-index 4165237..c34008a 100644
+index 7c33b08..c522995 100644
--- a/frontend/libretro_core_options.h
+++ b/frontend/libretro_core_options.h
-@@ -203,7 +203,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
- "PSX CPU Clock Speed",
+@@ -222,7 +222,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
+ "PSX CPU Clock Speed (%)",
NULL,
- "Overclock or under-clock the PSX CPU. Try adjusting this if the game is too slow, too fast or hangs."
+ "Overclock or under-clock the PSX CPU. The value has to be lower than 100 because of some slowdowns (cache misses, hw access penalties, etc.) that are not emulated. Try adjusting this if the game is too slow, too fast or hangs."
-#if defined(HAVE_PRE_ARMV7) && !defined(_3DS)
+#if defined(HAVE_PRE_ARMV7) && !defined(_3DS) && !defined(_TRIMUI)
" Default is 50."
#else
" Default is 57."
-@@ -285,7 +285,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
+@@ -304,7 +304,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "100", NULL },
{ NULL, NULL },
},
@@ -92,7 +92,7 @@ index 4165237..c34008a 100644
"50",
#else
"57",
-@@ -303,7 +303,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
+@@ -322,7 +322,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "enabled", NULL },
{ NULL, NULL },
},
@@ -102,10 +102,10 @@ index 4165237..c34008a 100644
#else
"enabled",
diff --git a/frontend/main.c b/frontend/main.c
-index cf015a4..beaee12 100644
+index 65114e3..2ad3c69 100644
--- a/frontend/main.c
+++ b/frontend/main.c
-@@ -165,7 +165,7 @@ void emu_set_default_config(void)
+@@ -164,7 +164,7 @@ void emu_set_default_config(void)
spu_config.iTempo = 0;
// may cause issues, no effect if only 1 core is detected
spu_config.iUseThread = 0;
diff --git a/scale.c b/scale.c
index 842e4ae..5857589 100644
--- a/scale.c
+++ b/scale.c
@@ -186,7 +186,19 @@ static void scale_blend(unsigned w, unsigned h, size_t pitch, const void *src, v
if (!lines)
pnext -= (pitch / sizeof(uint16_t));
- if (dy > rat_dst_h - bh[0]) {
+ if (dy <= bh[0] && dy + rat_h > (rat_dst_h + rat_dst_h - bh[0])) {
+ /* Will miss next line, blend in instead */
+ const uint32_t *src32 = (const uint32_t *)src;
+ const uint32_t *pnext32 = (const uint32_t *)pnext;
+ uint32_t *pblend32 = (uint32_t *)pblend;
+ int count = w / 2;
+
+ while(count--) {
+ *pblend32++ = AVERAGE32(*src32, *pnext32);
+ src32++;
+ pnext32++;
+ }
+ } else if (dy > rat_dst_h - bh[0]) {
pblend = pnext;
} else if (dy <= bh[0]) {
/* Drops const, won't get touched later though */
@@ -227,15 +239,17 @@ static void scale_blend(unsigned w, unsigned h, size_t pitch, const void *src, v
while (dx < rat_dst_w) {
if (a == b) {
out = a;
+ } else if (dx <= bw[0] && dx + rat_w > (rat_dst_w + rat_dst_w - bw[0])) {
+ out = AVERAGE16_NOCHK(a, b); // will miss next pixel, blend in instead
} else if (dx > rat_dst_w - bw[0]) { // top quintile, bbbb
out = b;
} else if (dx <= bw[0]) { // last quintile, aaaa
out = a;
} else {
if (dx > rat_dst_w - bw[1]) { // 2nd quintile, abbb
- a = AVERAGE16_NOCHK(a,b);
+ a = AVERAGE16_NOCHK(a, b);
} else if (dx <= bw[1]) { // 4th quintile, aaab
- b = AVERAGE16_NOCHK(a,b);
+ b = AVERAGE16_NOCHK(a, b);
}
out = AVERAGE16_NOCHK(a, b); // also 3rd quintile, aabb