diff options
author | neonloop | 2021-08-27 00:30:47 +0000 |
---|---|---|
committer | neonloop | 2021-08-27 00:30:47 +0000 |
commit | 3f527c7426cbbdbd04962545b801c944434a0377 (patch) | |
tree | f9ba8499e54dcafb2fea259522fd4ff1b9f66f2b /main.c | |
parent | 0060a16ad707c1d6f2013947821ff55e377ceb92 (diff) | |
download | picoarch-3f527c7426cbbdbd04962545b801c944434a0377.tar.gz picoarch-3f527c7426cbbdbd04962545b801c944434a0377.tar.bz2 picoarch-3f527c7426cbbdbd04962545b801c944434a0377.zip |
Adds a standalone multi-emulator mode
When starting without arguments, can select a core in the current
directory and some content (a game). Allows loading a different game
from the in-game menu.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 74 |
1 files changed, 32 insertions, 42 deletions
@@ -17,36 +17,18 @@ #include <mmenu.h> #include <SDL/SDL.h> void* mmenu = NULL; -static int resume_slot = -1; char save_template_path[MAX_PATH]; #endif bool should_quit = false; unsigned current_audio_buffer_size; char core_name[MAX_PATH]; -char* content_path; int config_override = 0; static int last_screenshot = 0; static uint32_t vsyncs; static uint32_t renders; -static void extract_core_name(const char* core_file) { - char *suffix = NULL; - - strncpy(core_name, basename(core_file), MAX_PATH); - core_name[sizeof(core_name) - 1] = 0; - - suffix = strrchr(core_name, '_'); - if (suffix && !strcmp(suffix, "_libretro.so")) - *suffix = 0; - else { - suffix = strrchr(core_name, '.'); - if (suffix && !strcmp(suffix, ".so")) - *suffix = 0; - } -} - static void toggle_fast_forward(int force_off) { static int frameskip_style_was; @@ -294,7 +276,7 @@ void load_config(void) } } -static void load_config_keys(void) +void load_config_keys(void) { char *config = NULL; int kcount = 0; @@ -518,35 +500,50 @@ static void adjust_audio(void) { } int main(int argc, char **argv) { - if (argc != 3) { - printf("Usage: picoarch LIBRETRO_CORE CONTENT"); - return -1; + if (argc > 1) { + if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { + printf("Usage: picoarch [libretro_core [content]]\n"); + return 0; + } } - extract_core_name(argv[1]); - content_path = argv[2]; - - set_defaults(); - - if (core_load(argv[1])) { + if (plat_init()) { quit(-1); } - if (core_load_content(argv[2])) { + if (menu_init()) { quit(-1); } - if (plat_init()) { + if (argc > 1 && argv[1]) { + strncpy(core_path, argv[1], sizeof(core_path) - 1); + } else { + if (menu_select_core()) + quit(-1); + } + + core_extract_name(core_path, core_name, sizeof(core_name)); + + set_defaults(); + + if (core_load(core_path)) { quit(-1); } - /* Must happen after initializing plat_input */ - load_config_keys(); + if (argc > 2 && argv[2]) { + strncpy(content_path, argv[2], sizeof(content_path) - 1); + } else { + if (menu_select_content()) + quit(-1); + } - if (menu_init()) { + if (core_load_content(content_path)) { quit(-1); } + load_config_keys(); + plat_reinit(); + #ifdef MMENU mmenu = dlopen("libmmenu.so", RTLD_LAZY); @@ -554,14 +551,10 @@ int main(int argc, char **argv) { ResumeSlot_t ResumeSlot = (ResumeSlot_t)dlsym(mmenu, "ResumeSlot"); if (ResumeSlot) resume_slot = ResumeSlot(); } - - if (state_allowed() && resume_slot!=-1) { - state_slot = resume_slot; - state_read(); - resume_slot = -1; - } #endif + state_resume(); + show_startup_message(); do { count_fps(); @@ -575,9 +568,6 @@ int main(int argc, char **argv) { } int quit(int code) { - if (current_core.initialized) - sram_write(); - menu_finish(); core_unload(); plat_finish(); |