aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c10
-rw-r--r--overrides.h1
-rw-r--r--overrides/fake-08.h1
-rw-r--r--overrides/pcsx_rearmed.h1
-rw-r--r--patches/fake-08/0001-fix-resume-state.patch81
5 files changed, 13 insertions, 81 deletions
diff --git a/main.c b/main.c
index c14f2fb..14be5a3 100644
--- a/main.c
+++ b/main.c
@@ -611,6 +611,8 @@ int state_resume(void) {
int main(int argc, char **argv) {
char content_path[MAX_PATH];
+ const struct core_override *override;
+ int defer_frames = 0;
if (argc > 1) {
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
@@ -689,6 +691,14 @@ int main(int argc, char **argv) {
show_startup_message();
+ override = get_overrides();
+ defer_frames = CORE_OVERRIDE(override, defer_frames, 0);
+ if (defer_frames > 0) {
+ toggle_fast_forward(0);
+ while(defer_frames--) core_run_frame();
+ toggle_fast_forward(1);
+ }
+
#ifdef FUNKEY_S
FK_InitMenu();
FK_Resume();
diff --git a/overrides.h b/overrides.h
index 2ab0633..928bb6d 100644
--- a/overrides.h
+++ b/overrides.h
@@ -35,6 +35,7 @@ struct core_override {
me_bind_action* emu_actions;
const size_t emu_action_size;
const struct core_override_option* options;
+ int defer_frames;
int needs_reopen;
int prevent_resume;
};
diff --git a/overrides/fake-08.h b/overrides/fake-08.h
index 8773958..8dfa02c 100644
--- a/overrides/fake-08.h
+++ b/overrides/fake-08.h
@@ -16,4 +16,5 @@ me_bind_action fake08_ctrl_actions[] =
.core_name = "fake-08", \
.actions = fake08_ctrl_actions, \
.action_size = array_size(fake08_ctrl_actions), \
+ .defer_frames = 3, \
}
diff --git a/overrides/pcsx_rearmed.h b/overrides/pcsx_rearmed.h
index d5b20d7..c1d92b9 100644
--- a/overrides/pcsx_rearmed.h
+++ b/overrides/pcsx_rearmed.h
@@ -256,4 +256,5 @@ const struct core_override_startup_msg pcsx_rearmed_startup_msg = {
.actions = pcsx_rearmed_ctrl_actions, \
.action_size = array_size(pcsx_rearmed_ctrl_actions), \
.options = pcsx_rearmed_core_option_overrides, \
+ .defer_frames = 3, \
}
diff --git a/patches/fake-08/0001-fix-resume-state.patch b/patches/fake-08/0001-fix-resume-state.patch
deleted file mode 100644
index b3d73bc..0000000
--- a/patches/fake-08/0001-fix-resume-state.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-diff --git a/platform/libretro/libretro.cpp b/platform/libretro/libretro.cpp
-index 927ea8d4b8d1658a1d7521fe7e9abcbdede0ba5f..63a43f3f065344cdf45e0b10e5c9c089736695f2 100644
---- a/platform/libretro/libretro.cpp
-+++ b/platform/libretro/libretro.cpp
-@@ -82,6 +82,46 @@ EXPORT void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) { audio_
- EXPORT void retro_set_input_poll(retro_input_poll_t cb) { input_poll_cb = cb; }
- EXPORT void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; }
-
-+
-+static int frames = 0;
-+static int defer_frames = 2;
-+static void* deferred_data = NULL;
-+static size_t deferred_size = 0;
-+
-+static void free_deferred_data(void) {
-+ if (deferred_size) {
-+ if (log_cb) log_cb(RETRO_LOG_INFO, "Freed deferred save state.\n");
-+ free(deferred_data);
-+ deferred_data = NULL;
-+ deferred_size = 0;
-+ }
-+}
-+
-+static void defer_unserialize(const void *data, size_t size) {
-+ free_deferred_data();
-+
-+ if (data==NULL || size<=0) return;
-+
-+ if (log_cb) log_cb(RETRO_LOG_INFO, "Deferred save state load.\n");
-+
-+ deferred_data = malloc(size);
-+ memcpy(deferred_data, data, size);
-+ deferred_size = size;
-+}
-+static void update_deferred(void) {
-+ frames += 1;
-+
-+ if (frames<defer_frames) return;
-+
-+ if (deferred_size==0) return;
-+
-+ retro_unserialize(deferred_data, deferred_size);
-+
-+ if (log_cb) log_cb(RETRO_LOG_INFO, "Loaded deferred save state.\n");
-+
-+ free_deferred_data();
-+}
-+
- EXPORT void retro_init()
- {
- retro_log_callback log;
-@@ -132,6 +172,8 @@ EXPORT void retro_deinit()
- if (log_cb) {
- log_cb(RETRO_LOG_INFO, "Retro deinit called. tearing down\n");
- }
-+ free_deferred_data();
-+
- //delete things created in init
- _vm->CloseCart();
- _host->oneTimeCleanup();
-@@ -205,6 +247,8 @@ int flip = 0;
-
- EXPORT void retro_run()
- {
-+ if (frames<defer_frames) update_deferred();
-+
- //TODO: improve this so slower hardware can play 30fps games at full speed
- if (_vm->getTargetFps() == 60 || frame % 2 == 0)
- {
-@@ -396,6 +440,11 @@ EXPORT bool retro_serialize(void *data, size_t size)
-
- EXPORT bool retro_unserialize(const void *data, size_t size)
- {
-+ if (frames<defer_frames) {
-+ defer_unserialize(data,size);
-+ return true;
-+ }
-+
- if (log_cb) {
- log_cb(RETRO_LOG_INFO, "lua deserialize\n");
- }