aboutsummaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorneonloop2023-01-25 07:35:46 +0000
committerneonloop2023-01-25 07:35:46 +0000
commit4188eb5b7c459df34fb11c3078d737a90dc56eeb (patch)
tree72f7c0d4341d39adc7b173eb116f591a29df4723 /menu.c
parentb90dbbdc967878dc461fefe78a8ef86886ae7a5a (diff)
downloadpicoarch-4188eb5b7c459df34fb11c3078d737a90dc56eeb.tar.gz
picoarch-4188eb5b7c459df34fb11c3078d737a90dc56eeb.tar.bz2
picoarch-4188eb5b7c459df34fb11c3078d737a90dc56eeb.zip
Fixes load new content
Cores do not always clean up on unload content, deinit and reinit is more reliable. Some cores do not even clean up on deinit and reinit, need all statics reinitialized. On many platforms dlclose / dlopen will work. FunKey uses musl libc where dlclose is no-op, so instead will exec again with current core and new content path. Overrides decide whether easy or hard clean up is needed. Assume unknown cores need hard cleanup, otherwise specified by "needs_reopen" override. Also - FunKey will now autosave and resume during load new content - Load new content deferred until after menu responds to keypress, otherwise key release can be missed and menu seems stuck
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/menu.c b/menu.c
index fde7c10..bd00e52 100644
--- a/menu.c
+++ b/menu.c
@@ -8,12 +8,18 @@
#include "scale.h"
#include "util.h"
+#ifdef FUNKEY_S
+#include "funkey/fk_instant_play.h"
+#endif
+
static int drew_alt_bg = 0;
static char cores_path[MAX_PATH];
static struct dirent **corelist = NULL;
static int corelist_len = 0;
+static const char *new_fname = NULL;
+
#define MENU_ALIGN_LEFT 0
#define MENU_X2 0
@@ -306,7 +312,29 @@ static int menu_loop_select_content(int id, int keys) {
if (fname == NULL)
return -1;
- core_unload_content();
+ new_fname = fname;
+
+ return 1;
+}
+
+static void load_new_content(const char *fname) {
+ const struct core_override *override = get_overrides();
+
+ if (!override || override->needs_reopen) {
+#ifdef FUNKEY_S
+ FK_LoadNewGame(fname);
+ /* Does not return */
+#else
+ core_close();
+ core_open(core_path);
+#endif
+ } else {
+#ifdef FUNKEY_S
+ FK_Autosave();
+#endif
+ core_unload();
+ }
+ core_load();
content = content_init(fname);
if (!content) {
@@ -328,7 +356,9 @@ static int menu_loop_select_content(int id, int keys) {
state_resume();
}
- return 1;
+#ifdef FUNKEY_S
+ FK_Resume();
+#endif
}
static int menu_loop_disc(int id, int keys)
@@ -685,7 +715,6 @@ void menu_loop(void)
{
static int sel = 0;
bool needs_disc_ctrl = disc_get_count() > 1;
- const struct core_override *override = get_overrides();
plat_video_menu_enter(1);
@@ -697,9 +726,6 @@ void menu_loop(void)
me_enable(e_menu_main, MA_MAIN_DISC_CTRL, needs_disc_ctrl);
- if (override)
- me_enable(e_menu_main, MA_MAIN_CONTENT_SEL, !override->block_load_content);
-
#ifdef MMENU
if (state_allowed()) {
me_enable(e_menu_main, MA_MAIN_SAVE_STATE, mmenu == NULL);
@@ -712,6 +738,11 @@ void menu_loop(void)
while (in_menu_wait_any(NULL, 50) & (PBTN_MENU|PBTN_MOK|PBTN_MBACK))
;
+ if (new_fname) {
+ load_new_content(new_fname);
+ new_fname = NULL;
+ }
+
/* Force the hud to clear */
plat_video_set_msg(NULL, 0, 0);
plat_video_menu_leave();