}\r
\r
\r
-int Insert_CD(char *cdimg_name, int type)\r
+int Insert_CD(const char *cdimg_name, int type)\r
{\r
int ret = 1;\r
\r
void PicoCDBufferFlush(void);\r
\r
// cd/cd_sys.c\r
-int Insert_CD(char *cdimg_name, int type);\r
+int Insert_CD(const char *cdimg_name, int type);\r
void Stop_CD(void); // releases all resources taken when CD game was started.\r
\r
// Cart.c\r
return 0;\r
}\r
\r
-static void get_ext(char *file, char *ext)\r
+static void get_ext(const char *file, char *ext)\r
{\r
- char *p;\r
+ const char *p;\r
\r
p = file + strlen(file) - 4;\r
if (p < file) p = file;\r
\r
/* checks if fname points to valid MegaCD image\r
* if so, checks for suitable BIOS */\r
-int emu_cd_check(int *pregion, char *fname_in)\r
+static int emu_cd_check(int *pregion, const char *fname_in)\r
{\r
+ const char *fname = fname_in;\r
unsigned char buf[32];\r
pm_file *cd_f;\r
int region = 4; // 1: Japan, 4: US, 8: Europe\r
- char ext[5], *fname = fname_in;\r
+ char ext[5];\r
cue_track_type type = CT_UNKNOWN;\r
cue_data_t *cue_data = NULL;\r
\r
return 0;\r
}\r
\r
+int emu_swap_cd(const char *fname)\r
+{\r
+ cd_img_type cd_type;\r
+ int ret = -1;\r
+\r
+ cd_type = emu_cd_check(NULL, fname);\r
+ if (cd_type != CIT_NOT_CD)\r
+ ret = Insert_CD(fname, cd_type);\r
+ if (ret != 0) {\r
+ me_update_msg("Load failed, invalid CD image?");\r
+ return 0;\r
+ }\r
+\r
+ strncpy(rom_fname_loaded, fname, sizeof(rom_fname_loaded)-1);\r
+ rom_fname_loaded[sizeof(rom_fname_loaded)-1] = 0;\r
+ return 1;\r
+}\r
+\r
static void romfname_ext(char *dst, const char *prefix, const char *ext)\r
{\r
char *p;\r
void emu_loop(void);
int emu_reload_rom(char *rom_fname);
+int emu_swap_cd(const char *fname);
int emu_save_load_game(int load, int sram);
void emu_reset_game(void);
void emu_update_input(void);
void emu_get_game_name(char *str150);
void emu_set_fastforward(int set_on);
-int emu_cd_check(int *pregion, char *fname_in);
void emu_status_msg(const char *format, ...);
#ifdef __cplusplus
\r
static int mh_tray_load_cd(menu_id id, int keys)\r
{\r
- cd_img_type cd_type;\r
char *ret_name;\r
- int ret = -1;\r
\r
ret_name = romsel_run();\r
if (ret_name == NULL)\r
return 0;\r
\r
- cd_type = emu_cd_check(NULL, ret_name);\r
- if (cd_type != CIT_NOT_CD)\r
- ret = Insert_CD(ret_name, cd_type);\r
- if (ret != 0) {\r
- me_update_msg("Load failed, invalid CD image?");\r
- return 0;\r
- }\r
-\r
engineState = PGS_RestartRun;\r
- return 1;\r
+ return emu_swap_cd(ret_name);\r
}\r
\r
static int mh_tray_nothing(menu_id id, int keys)\r
mee_label (""),\r
mee_handler("Load CD image", mh_tray_load_cd),\r
mee_handler("Insert nothing", mh_tray_nothing),\r
+ mee_end,\r
};\r
\r
int menu_loop_tray(void)\r