diff options
author | neonloop | 2023-01-25 07:35:46 +0000 |
---|---|---|
committer | neonloop | 2023-01-25 07:35:46 +0000 |
commit | 4188eb5b7c459df34fb11c3078d737a90dc56eeb (patch) | |
tree | 72f7c0d4341d39adc7b173eb116f591a29df4723 /main.c | |
parent | b90dbbdc967878dc461fefe78a8ef86886ae7a5a (diff) | |
download | picoarch-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 'main.c')
-rw-r--r-- | main.c | 70 |
1 files changed, 25 insertions, 45 deletions
@@ -25,7 +25,6 @@ char save_template_path[MAX_PATH]; #ifdef FUNKEY_S #include "funkey/fk_menu.h" #include "funkey/fk_instant_play.h" -static bool instant_play = false; bool should_suspend = false; #endif @@ -610,10 +609,6 @@ int state_resume(void) { int main(int argc, char **argv) { char content_path[MAX_PATH]; -#ifdef FUNKEY_S - char autosave_path[MAX_PATH]; -#endif - if (argc > 1) { if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { @@ -662,20 +657,6 @@ int main(int argc, char **argv) { load_config(); core_load(); - if (core_load_content(content)) { - quit(-1); - } - - load_config_keys(); - -#ifdef MMENU - - mmenu = dlopen("libmmenu.so", RTLD_LAZY); - if (mmenu) { - ResumeSlot_t ResumeSlot = (ResumeSlot_t)dlsym(mmenu, "ResumeSlot"); - if (ResumeSlot) resume_slot = ResumeSlot(); - } -#endif #ifdef FUNKEY_S if (IMG_Init(IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_TIF | IMG_INIT_WEBP) == 0) { PA_ERROR("Error initializing SDL_Image\n"); @@ -686,30 +667,30 @@ int main(int argc, char **argv) { PA_ERROR("Error initializing SDL_ttf\n"); quit(-1); } - FK_InitMenu(); +#endif - state_file_name(autosave_path, MAX_PATH, AUTOSAVE_SLOT); - if (access(autosave_path, F_OK) == 0) { - if (instant_play) { - resume_slot = AUTOSAVE_SLOT; - } else { - SDL_Surface *screen = SDL_GetVideoSurface(); - int resume = FK_RunResumeMenu(screen); - if (resume == RESUME_YES) { - resume_slot = AUTOSAVE_SLOT; - } - } + if (core_load_content(content)) { + quit(-1); } - instant_play = false; - FK_InitInstantPlay(argc, argv); + load_config_keys(); + +#ifdef MMENU + mmenu = dlopen("libmmenu.so", RTLD_LAZY); + if (mmenu) { + ResumeSlot_t ResumeSlot = (ResumeSlot_t)dlsym(mmenu, "ResumeSlot"); + if (ResumeSlot) resume_slot = ResumeSlot(); + } + + state_resume(); #endif + show_startup_message(); - state_resume(); #ifdef FUNKEY_S - remove(autosave_path); - remove_config(CONFIG_TYPE_AUTO); + FK_InitMenu(); + FK_Resume(); + FK_InitInstantPlay(argc, argv); #endif do { @@ -731,21 +712,20 @@ int main(int argc, char **argv) { return quit(0); } -int quit(int code) { - menu_finish(); - +void finish(void) { #ifdef FUNKEY_S - if (current_core.initialized && state_allowed()) { - state_slot = AUTOSAVE_SLOT; - state_write(); - } - + FK_Autosave(); FK_EndMenu(); TTF_Quit(); IMG_Quit(); #endif - core_unload(); + menu_finish(); + core_close(); plat_finish(); +} + +int quit(int code) { + finish(); exit(code); } |