#include "lprintf.h"\r
#include "config.h"\r
#include "common.h"\r
+#include "plat.h"\r
\r
-#include <Pico/PicoInt.h>\r
-#include <Pico/Patch.h>\r
-#include <Pico/cd/cue.h>\r
+#include <pico/pico_int.h>\r
+#include <pico/patch.h>\r
+#include <pico/cd/cue.h>\r
#include <zlib/zlib.h>\r
\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
+static void strlwr_(char *string)\r
{\r
- while ( (*string++ = (char)tolower(*string)) );\r
+ char *p;\r
+ for (p = string; *p; p++)\r
+ *p = (char)tolower(*p);\r
}\r
\r
static int try_rfn_cut(char *fname)\r
return 0;\r
}\r
get_ext(rom_fname, ext);\r
+ lprintf("gmv loaded for %s\n", rom_fname);\r
}\r
else if (!strcmp(ext, ".pat"))\r
{\r
rom_loaded = 0;\r
\r
if ( (ret = PicoCartLoad(rom, &rom_data, &rom_size)) ) {\r
- sprintf(menuErrorMsg, "PicoCartLoad() failed.");\r
+ if (ret == 2) sprintf(menuErrorMsg, "Out of memory");\r
+ else if (ret == 3) sprintf(menuErrorMsg, "Read failed");\r
+ else sprintf(menuErrorMsg, "PicoCartLoad() failed.");\r
lprintf("%s\n", menuErrorMsg);\r
goto fail2;\r
}\r
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
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
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
}\r
\r
\r
+void emu_writelrom(void)\r
+{\r
+ char cfg[512];\r
+ make_config_cfg(cfg);\r
+ config_writelrom(cfg);\r
+#ifndef NO_SYNC\r
+ sync();\r
+#endif\r
+}\r
+\r
#ifndef UIQ3\r
void emu_textOut8(int x, int y, const char *text)\r
{\r
} else {\r
// MXYZ SACB RLDU\r
PicoPad[0] = ~movie_data[offs] & 0x8f; // ! SCBA RLDU\r
- if(!(movie_data[offs] & 0x10)) PicoPad[0] |= 0x40; // A\r
- if(!(movie_data[offs] & 0x20)) PicoPad[0] |= 0x10; // B\r
- if(!(movie_data[offs] & 0x40)) PicoPad[0] |= 0x20; // A\r
+ if(!(movie_data[offs] & 0x10)) PicoPad[0] |= 0x40; // C\r
+ if(!(movie_data[offs] & 0x20)) PicoPad[0] |= 0x10; // A\r
+ if(!(movie_data[offs] & 0x40)) PicoPad[0] |= 0x20; // B\r
PicoPad[1] = ~movie_data[offs+1] & 0x8f; // ! SCBA RLDU\r
- if(!(movie_data[offs+1] & 0x10)) PicoPad[1] |= 0x40; // A\r
- if(!(movie_data[offs+1] & 0x20)) PicoPad[1] |= 0x10; // B\r
- if(!(movie_data[offs+1] & 0x40)) PicoPad[1] |= 0x20; // A\r
+ if(!(movie_data[offs+1] & 0x10)) PicoPad[1] |= 0x40; // C\r
+ if(!(movie_data[offs+1] & 0x20)) PicoPad[1] |= 0x10; // A\r
+ if(!(movie_data[offs+1] & 0x40)) PicoPad[1] |= 0x20; // B\r
PicoPad[0] |= (~movie_data[offs+2] & 0x0A) << 8; // ! MZYX\r
if(!(movie_data[offs+2] & 0x01)) PicoPad[0] |= 0x0400; // X\r
if(!(movie_data[offs+2] & 0x04)) PicoPad[0] |= 0x0100; // Z\r