major menu unification, minor reorganization
[libpicofe.git] / common / emu.c
index 58fee61..7aac10b 100644 (file)
@@ -16,6 +16,7 @@
 #include "lprintf.h"\r
 #include "config.h"\r
 #include "common.h"\r
+#include "plat.h"\r
 \r
 #include <pico/pico_int.h>\r
 #include <pico/patch.h>\r
 \r
 char *PicoConfigFile = "config.cfg";\r
 currentConfig_t currentConfig, defaultConfig;\r
-int rom_loaded = 0;\r
 char noticeMsg[64] = { 0, };\r
 int state_slot = 0;\r
 int config_slot = 0, config_slot_current = 0;\r
-char loadedRomFName[512] = { 0, };\r
 int kb_combo_keys = 0, kb_combo_acts = 0;      // keys and actions which need button combos\r
 int pico_inp_mode = 0;\r
+int engineState = PGS_Menu;\r
+\r
+/* TODO: len checking */\r
+char rom_fname_reload[512] = { 0, };\r
+char rom_fname_loaded[512] = { 0, };\r
+int rom_loaded = 0;\r
 \r
 unsigned char *movie_data = NULL;\r
 static int movie_size = 0;\r
 \r
-// provided by platform code:\r
-extern void emu_noticeMsgUpdated(void);\r
-extern int  emu_getMainDir(char *dst, int len);\r
-extern void menu_romload_prepare(const char *rom_name);\r
-extern void menu_romload_end(void);\r
-\r
 \r
 // utilities\r
 static void strlwr_(char *string)\r
@@ -492,8 +491,8 @@ int emu_ReloadRom(char *rom_fname)
        if (currentConfig.EmuOpt & EOPT_USE_SRAM)\r
                emu_SaveLoadGame(1, 1);\r
 \r
-       strncpy(loadedRomFName, rom_fname, sizeof(loadedRomFName)-1);\r
-       loadedRomFName[sizeof(loadedRomFName)-1] = 0;\r
+       strncpy(rom_fname_loaded, rom_fname, sizeof(rom_fname_loaded)-1);\r
+       rom_fname_loaded[sizeof(rom_fname_loaded)-1] = 0;\r
        rom_loaded = 1;\r
        return 1;\r
 \r
@@ -518,8 +517,8 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
        int prefix_len = 0;\r
 \r
        // make save filename\r
-       p = loadedRomFName+strlen(loadedRomFName)-1;\r
-       for (; p >= loadedRomFName && *p != PATH_SEP_C; p--); p++;\r
+       p = rom_fname_loaded + strlen(rom_fname_loaded) - 1;\r
+       for (; p >= rom_fname_loaded && *p != PATH_SEP_C; p--); p++;\r
        *dst = 0;\r
        if (prefix) {\r
                int len = emu_getMainDir(dst, 512);\r
@@ -527,7 +526,7 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
                prefix_len = len + strlen(prefix);\r
        }\r
 #ifdef UIQ3\r
-       else p = loadedRomFName; // backward compatibility\r
+       else p = rom_fname_loaded; // backward compatibility\r
 #endif\r
        strncpy(dst + prefix_len, p, 511-prefix_len);\r
        dst[511-8] = 0;\r