rom_data -> rom_loaded
authornotaz <notasas@gmail.com>
Fri, 7 Mar 2008 19:03:06 +0000 (19:03 +0000)
committernotaz <notasas@gmail.com>
Fri, 7 Mar 2008 19:03:06 +0000 (19:03 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@372 be3aeb3a-fb24-0410-a615-afba39da0efa

platform/common/emu.c
platform/common/emu.h
platform/gizmondo/menu.c
platform/gp2x/menu.c
platform/psp/menu.c
platform/win32/GenaDrive/Main.cpp

index 71f6716..b7832bb 100644 (file)
@@ -35,7 +35,7 @@
 \r
 char *PicoConfigFile = "picoconfig.bin";\r
 currentConfig_t currentConfig;\r
-unsigned char *rom_data = NULL;\r
+int rom_loaded = 0;\r
 char noticeMsg[64];\r
 int state_slot = 0;\r
 int config_slot = 0, config_slot_current = 0;\r
@@ -193,6 +193,7 @@ int emu_ReloadRom(void)
 {\r
        unsigned int rom_size = 0;\r
        char *used_rom_name = romFileName;\r
+       unsigned char *rom_data = NULL;\r
        char ext[5];\r
        pm_file *rom;\r
        int ret, cd_state, cd_region, cfg_loaded = 0;\r
@@ -202,7 +203,7 @@ int emu_ReloadRom(void)
        get_ext(romFileName, ext);\r
 \r
        // detect wrong extensions\r
-       if(!strcmp(ext, ".srm") || !strcmp(ext, "s.gz") || !strcmp(ext, ".mds")) { // s.gz ~ .mds.gz\r
+       if (!strcmp(ext, ".srm") || !strcmp(ext, "s.gz") || !strcmp(ext, ".mds")) { // s.gz ~ .mds.gz\r
                sprintf(menuErrorMsg, "Not a ROM selected.");\r
                return 0;\r
        }\r
@@ -210,11 +211,11 @@ int emu_ReloadRom(void)
        PicoPatchUnload();\r
 \r
        // check for movie file\r
-       if(movie_data) {\r
+       if (movie_data) {\r
                free(movie_data);\r
                movie_data = 0;\r
        }\r
-       if(!strcmp(ext, ".gmv")) {\r
+       if (!strcmp(ext, ".gmv")) {\r
                // check for both gmv and rom\r
                int dummy;\r
                FILE *movie_file = fopen(romFileName, "rb");\r
@@ -293,20 +294,17 @@ int emu_ReloadRom(void)
        }\r
 \r
        rom = pm_open(used_rom_name);\r
-       if(!rom) {\r
+       if (!rom) {\r
                sprintf(menuErrorMsg, "Failed to open rom.");\r
                return 0;\r
        }\r
 \r
        menu_romload_prepare(used_rom_name); // also CD load\r
 \r
-       if(rom_data) {\r
-               free(rom_data);\r
-               rom_data = 0;\r
-               rom_size = 0;\r
-       }\r
+       PicoCartUnload();\r
+       rom_loaded = 0;\r
 \r
-       if( (ret = PicoCartLoad(rom, &rom_data, &rom_size)) ) {\r
+       if ( (ret = PicoCartLoad(rom, &rom_data, &rom_size)) ) {\r
                sprintf(menuErrorMsg, "PicoCartLoad() failed.");\r
                lprintf("%s\n", menuErrorMsg);\r
                pm_close(rom);\r
@@ -316,10 +314,9 @@ int emu_ReloadRom(void)
        pm_close(rom);\r
 \r
        // detect wrong files (Pico crashes on very small files), also see if ROM EP is good\r
-       if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 ||\r
+       if (rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 ||\r
          ((*(unsigned char *)(rom_data+4)<<16)|(*(unsigned short *)(rom_data+6))) >= (int)rom_size) {\r
                if (rom_data) free(rom_data);\r
-               rom_data = 0;\r
                sprintf(menuErrorMsg, "Not a ROM selected.");\r
                menu_romload_end();\r
                return 0;\r
@@ -332,7 +329,7 @@ int emu_ReloadRom(void)
        }\r
 \r
        lprintf("PicoCartInsert(%p, %d);\n", rom_data, rom_size);\r
-       if(PicoCartInsert(rom_data, rom_size)) {\r
+       if (PicoCartInsert(rom_data, rom_size)) {\r
                sprintf(menuErrorMsg, "Failed to load ROM.");\r
                menu_romload_end();\r
                return 0;\r
@@ -395,9 +392,10 @@ int emu_ReloadRom(void)
        emu_noticeMsgUpdated();\r
 \r
        // load SRAM for this ROM\r
-       if(currentConfig.EmuOpt & 1)\r
+       if (currentConfig.EmuOpt & 1)\r
                emu_SaveLoadGame(1, 1);\r
 \r
+       rom_loaded = 1;\r
        return 1;\r
 }\r
 \r
index 2d2aa49..dd114ca 100644 (file)
@@ -29,7 +29,7 @@ typedef struct {
 
 extern currentConfig_t currentConfig;
 extern char *PicoConfigFile;
-extern unsigned char *rom_data;
+extern int rom_loaded;
 extern char noticeMsg[64];
 extern int state_slot;
 extern int config_slot, config_slot_current;
index 5da9c23..b1d3b14 100644 (file)
@@ -124,7 +124,7 @@ void menu_romload_prepare(const char *rom_name)
        const char *p = rom_name + strlen(rom_name);\r
        while (p > rom_name && *p != '/') p--;\r
 \r
-       if (rom_data == NULL)\r
+       if (!rom_loaded)\r
                memset(menu_screen, 0, 321*240*2);\r
        menu_draw_begin(1);\r
 \r
@@ -179,7 +179,7 @@ static void draw_dirlist(char *curdir, struct my_dirent **namelist, int n, int s
 \r
        menu_draw_begin(1);\r
 \r
-       if (rom_data == NULL) {\r
+       if (!rom_loaded) {\r
                menu_darken_bg(menu_screen, menu_screen, 321*240, 0);\r
        }\r
 \r
@@ -826,7 +826,7 @@ static void kc_sel_loop(void)
                                case 1: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 1); return;\r
                                case 2: key_config_loop(emuctrl_actions,\r
                                                sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return;\r
-                               case 3: if (rom_data == NULL) emu_WriteConfig(0); return;\r
+                               case 3: if (!rom_loaded) emu_WriteConfig(0); return;\r
                                default: return;\r
                        }\r
                }\r
@@ -1232,7 +1232,7 @@ static int menu_loop_options(void)
        currentConfig.PsndRate = PsndRate;\r
        currentConfig.PicoRegion = PicoRegionOverride;\r
 \r
-       me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_data != NULL);\r
+       me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_loaded);\r
        me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);\r
        menu_sel_max = me_count_enabled(opt_entries, OPT_ENTRY_COUNT) - 1;\r
        if (menu_sel > menu_sel_max) menu_sel = menu_sel_max;\r
@@ -1422,10 +1422,10 @@ static void menu_loop_root(void)
        int ret, menu_sel_max;\r
        unsigned long inp = 0;\r
 \r
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESUME_GAME, rom_data != NULL);\r
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_SAVE_STATE,  rom_data != NULL);\r
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_LOAD_STATE,  rom_data != NULL);\r
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESET_GAME,  rom_data != NULL);\r
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESUME_GAME, rom_loaded);\r
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_SAVE_STATE,  rom_loaded);\r
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_LOAD_STATE,  rom_loaded);\r
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESET_GAME,  rom_loaded);\r
        me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_PATCHES,     PicoPatches != NULL);\r
 \r
        menu_sel_max = me_count_enabled(main_entries, MAIN_ENTRY_COUNT) - 1;\r
@@ -1444,7 +1444,7 @@ static void menu_loop_root(void)
                if(inp & BTN_DOWN)  { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                if((inp & (BTN_L|BTN_R)) == (BTN_L|BTN_R)) debug_menu_loop();\r
                if( inp & (BTN_HOME|BTN_STOP)) {\r
-                       if (rom_data) {\r
+                       if (rom_loaded) {\r
                                while (Framework_PollGetButtons() & (BTN_HOME|BTN_STOP)) Sleep(50); // wait until released\r
                                engineState = PGS_Running;\r
                                break;\r
@@ -1454,14 +1454,14 @@ static void menu_loop_root(void)
                        switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel))\r
                        {\r
                                case MA_MAIN_RESUME_GAME:\r
-                                       if (rom_data) {\r
+                                       if (rom_loaded) {\r
                                                while (Framework_PollGetButtons() & BTN_PLAY) Sleep(50);\r
                                                engineState = PGS_Running;\r
                                                return;\r
                                        }\r
                                        break;\r
                                case MA_MAIN_SAVE_STATE:\r
-                                       if (rom_data) {\r
+                                       if (rom_loaded) {\r
                                                if(savestate_menu_loop(0))\r
                                                        continue;\r
                                                engineState = PGS_Running;\r
@@ -1469,7 +1469,7 @@ static void menu_loop_root(void)
                                        }\r
                                        break;\r
                                case MA_MAIN_LOAD_STATE:\r
-                                       if (rom_data) {\r
+                                       if (rom_loaded) {\r
                                                if(savestate_menu_loop(1))\r
                                                        continue;\r
                                                engineState = PGS_Running;\r
@@ -1477,7 +1477,7 @@ static void menu_loop_root(void)
                                        }\r
                                        break;\r
                                case MA_MAIN_RESET_GAME:\r
-                                       if (rom_data) {\r
+                                       if (rom_loaded) {\r
                                                emu_ResetGame();\r
                                                engineState = PGS_Running;\r
                                                return;\r
@@ -1520,7 +1520,7 @@ static void menu_loop_root(void)
                                        engineState = PGS_Quit;\r
                                        return;\r
                                case MA_MAIN_PATCHES:\r
-                                       if (rom_data && PicoPatches) {\r
+                                       if (rom_loaded && PicoPatches) {\r
                                                patches_menu_loop();\r
                                                PicoPatchApply();\r
                                                strcpy(menuErrorMsg, "Patches applied");\r
@@ -1586,7 +1586,7 @@ static void menu_prepare_bg(int use_game_bg)
 \r
 static void menu_gfx_prepare(void)\r
 {\r
-       menu_prepare_bg(rom_data != NULL);\r
+       menu_prepare_bg(rom_loaded);\r
 \r
        menu_draw_begin(1);\r
        menu_draw_end();\r
index ef54ed6..5ff8ac0 100644 (file)
@@ -169,7 +169,7 @@ void menu_romload_prepare(const char *rom_name)
        const char *p = rom_name + strlen(rom_name);\r
        while (p > rom_name && *p != '/') p--;\r
 \r
-       if (rom_data) gp2x_pd_clone_buffer2();\r
+       if (rom_loaded) gp2x_pd_clone_buffer2();\r
        else memset(gp2x_screen, 0, 320*240*2);\r
 \r
        smalltext_out16(1, 1, "Loading", 0xffff);\r
@@ -215,7 +215,7 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)
 \r
        gp2x_pd_clone_buffer2();\r
 \r
-       if (rom_data == NULL) {\r
+       if (!rom_loaded) {\r
                menu_darken_bg(gp2x_screen, 320*240, 0);\r
        }\r
 \r
@@ -860,7 +860,7 @@ static void kc_sel_loop(void)
                                case 1: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 1); return;\r
                                case 2: key_config_loop(emuctrl_actions,\r
                                                sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return;\r
-                               case 3: if (rom_data == NULL) emu_WriteConfig(0); return;\r
+                               case 3: if (!rom_loaded) emu_WriteConfig(0); return;\r
                                default: return;\r
                        }\r
                }\r
@@ -1294,7 +1294,7 @@ static int menu_loop_options(void)
        currentConfig.PsndRate = PsndRate;\r
        currentConfig.PicoRegion = PicoRegionOverride;\r
 \r
-       me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_data != NULL);\r
+       me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_loaded);\r
        me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);\r
        menu_sel_max = me_count_enabled(opt_entries, OPT_ENTRY_COUNT) - 1;\r
        if (menu_sel > menu_sel_max) menu_sel = menu_sel_max;\r
@@ -1485,10 +1485,10 @@ static void menu_loop_root(void)
        int ret, menu_sel_max;\r
        unsigned long inp = 0;\r
 \r
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESUME_GAME, rom_data != NULL);\r
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_SAVE_STATE,  rom_data != NULL);\r
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_LOAD_STATE,  rom_data != NULL);\r
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESET_GAME,  rom_data != NULL);\r
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESUME_GAME, rom_loaded);\r
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_SAVE_STATE,  rom_loaded);\r
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_LOAD_STATE,  rom_loaded);\r
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESET_GAME,  rom_loaded);\r
        me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_PATCHES,     PicoPatches != NULL);\r
 \r
        menu_sel_max = me_count_enabled(main_entries, MAIN_ENTRY_COUNT) - 1;\r
@@ -1506,7 +1506,7 @@ static void menu_loop_root(void)
                if(inp & GP2X_DOWN)  { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                if((inp & (GP2X_L|GP2X_R)) == (GP2X_L|GP2X_R)) debug_menu_loop();\r
                if(inp &(GP2X_SELECT|GP2X_X)){\r
-                       if (rom_data) {\r
+                       if (rom_loaded) {\r
                                while (gp2x_joystick_read(1) & (GP2X_SELECT|GP2X_X)) usleep(50*1000); // wait until select is released\r
                                engineState = PGS_Running;\r
                                break;\r
@@ -1516,14 +1516,14 @@ static void menu_loop_root(void)
                        switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel))\r
                        {\r
                                case MA_MAIN_RESUME_GAME:\r
-                                       if (rom_data) {\r
+                                       if (rom_loaded) {\r
                                                while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000);\r
                                                engineState = PGS_Running;\r
                                                return;\r
                                        }\r
                                        break;\r
                                case MA_MAIN_SAVE_STATE:\r
-                                       if (rom_data) {\r
+                                       if (rom_loaded) {\r
                                                if(savestate_menu_loop(0))\r
                                                        continue;\r
                                                engineState = PGS_Running;\r
@@ -1531,7 +1531,7 @@ static void menu_loop_root(void)
                                        }\r
                                        break;\r
                                case MA_MAIN_LOAD_STATE:\r
-                                       if (rom_data) {\r
+                                       if (rom_loaded) {\r
                                                if(savestate_menu_loop(1))\r
                                                        continue;\r
                                                engineState = PGS_Running;\r
@@ -1539,7 +1539,7 @@ static void menu_loop_root(void)
                                        }\r
                                        break;\r
                                case MA_MAIN_RESET_GAME:\r
-                                       if (rom_data) {\r
+                                       if (rom_loaded) {\r
                                                emu_ResetGame();\r
                                                engineState = PGS_Running;\r
                                                return;\r
@@ -1582,7 +1582,7 @@ static void menu_loop_root(void)
                                        engineState = PGS_Quit;\r
                                        return;\r
                                case MA_MAIN_PATCHES:\r
-                                       if (rom_data && PicoPatches) {\r
+                                       if (rom_loaded && PicoPatches) {\r
                                                patches_menu_loop();\r
                                                PicoPatchApply();\r
                                                strcpy(menuErrorMsg, "Patches applied");\r
@@ -1641,7 +1641,7 @@ static void menu_prepare_bg(int use_game_bg)
 \r
 static void menu_gfx_prepare(void)\r
 {\r
-       menu_prepare_bg(rom_data != NULL);\r
+       menu_prepare_bg(rom_loaded);\r
 \r
        // switch to 16bpp\r
        gp2x_video_changemode2(16);\r
index bc7c875..c2df05f 100644 (file)
@@ -153,7 +153,7 @@ void menu_romload_prepare(const char *rom_name)
        while (p > rom_name && *p != '/') p--;
 
        psp_video_switch_to_single();
-       if (rom_data) menu_draw_begin();
+       if (rom_loaded) menu_draw_begin();
        else memset32_uncached(psp_screen, 0, 512*272*2/4);
 
        smalltext_out16(1, 1, "Loading", 0xffff);
@@ -206,7 +206,7 @@ static void draw_dirlist(char *curdir, struct my_dirent **namelist, int n, int s
 
        menu_draw_begin();
 
-       if (rom_data == NULL) {
+       if (!rom_loaded) {
 //             menu_darken_bg(menu_screen, menu_screen, 321*240, 0);
        }
 
@@ -836,7 +836,7 @@ static void kc_sel_loop(void)
                                case 1: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 1); return;
                                case 2: key_config_loop(emuctrl_actions,
                                                sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return;
-                               case 3: if (rom_data == NULL) emu_WriteConfig(0); return;
+                               case 3: if (!rom_loaded) emu_WriteConfig(0); return;
                                default: return;
                        }
                }
@@ -1051,7 +1051,7 @@ static void menu_opt3_preview(int is_32col)
 {
        void *oldstate = NULL;
 
-       if (rom_data == NULL || ((Pico.video.reg[12]&1)^1) != is_32col)
+       if (!rom_loaded || ((Pico.video.reg[12]&1)^1) != is_32col)
        {
                extern char bgdatac32_start[], bgdatac40_start[];
                extern int bgdatac32_size, bgdatac40_size;
@@ -1061,7 +1061,7 @@ static void menu_opt3_preview(int is_32col)
                ret = uncompress((Bytef *)bg_buffer, &outsize, bgdata, insize);
                if (ret == 0)
                {
-                       if (rom_data != NULL) oldstate = get_oldstate_for_preview();
+                       if (rom_loaded) oldstate = get_oldstate_for_preview();
                        memcpy(Pico.vram,  bg_buffer, sizeof(Pico.vram));
                        memcpy(Pico.cram,  (char *)bg_buffer + 0x10000, 0x40*2);
                        memcpy(Pico.vsram, (char *)bg_buffer + 0x10080, 0x40*2);
@@ -1415,7 +1415,7 @@ static int menu_loop_options(void)
        currentConfig.PsndRate = PsndRate;
        currentConfig.PicoRegion = PicoRegionOverride;
 
-       me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_data != NULL);
+       me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_loaded);
        me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);
        menu_sel_max = me_count_enabled(opt_entries, OPT_ENTRY_COUNT) - 1;
        if (menu_sel > menu_sel_max) menu_sel = menu_sel_max;
@@ -1602,10 +1602,10 @@ static void menu_loop_root(void)
        int ret, menu_sel_max;
        unsigned long inp = 0;
 
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESUME_GAME, rom_data != NULL);
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_SAVE_STATE,  rom_data != NULL);
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_LOAD_STATE,  rom_data != NULL);
-       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESET_GAME,  rom_data != NULL);
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESUME_GAME, rom_loaded);
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_SAVE_STATE,  rom_loaded);
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_LOAD_STATE,  rom_loaded);
+       me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESET_GAME,  rom_loaded);
        me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_PATCHES,     PicoPatches != NULL);
 
        menu_sel_max = me_count_enabled(main_entries, MAIN_ENTRY_COUNT) - 1;
@@ -1632,7 +1632,7 @@ static void menu_loop_root(void)
                if(inp & BTN_DOWN)  { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
                if((inp & (BTN_L|BTN_R)) == (BTN_L|BTN_R)) debug_menu_loop();
                if( inp & (BTN_SELECT|BTN_X)) {
-                       if (rom_data) {
+                       if (rom_loaded) {
                                while (psp_pad_read(1) & (BTN_SELECT|BTN_X)) psp_msleep(50); // wait until released
                                engineState = PGS_Running;
                                break;
@@ -1643,14 +1643,14 @@ static void menu_loop_root(void)
                        switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel))
                        {
                                case MA_MAIN_RESUME_GAME:
-                                       if (rom_data) {
+                                       if (rom_loaded) {
                                                while (psp_pad_read(1) & BTN_CIRCLE) psp_msleep(50);
                                                engineState = PGS_Running;
                                                return;
                                        }
                                        break;
                                case MA_MAIN_SAVE_STATE:
-                                       if (rom_data) {
+                                       if (rom_loaded) {
                                                if(savestate_menu_loop(0))
                                                        continue;
                                                engineState = PGS_Running;
@@ -1658,7 +1658,7 @@ static void menu_loop_root(void)
                                        }
                                        break;
                                case MA_MAIN_LOAD_STATE:
-                                       if (rom_data) {
+                                       if (rom_loaded) {
                                                if(savestate_menu_loop(1))
                                                        continue;
                                                engineState = PGS_Running;
@@ -1666,7 +1666,7 @@ static void menu_loop_root(void)
                                        }
                                        break;
                                case MA_MAIN_RESET_GAME:
-                                       if (rom_data) {
+                                       if (rom_loaded) {
                                                emu_ResetGame();
                                                engineState = PGS_Running;
                                                return;
@@ -1711,7 +1711,7 @@ static void menu_loop_root(void)
                                        engineState = PGS_Quit;
                                        return;
                                case MA_MAIN_PATCHES:
-                                       if (rom_data && PicoPatches) {
+                                       if (rom_loaded && PicoPatches) {
                                                patches_menu_loop();
                                                PicoPatchApply();
                                                strcpy(menuErrorMsg, "Patches applied");
@@ -1773,7 +1773,7 @@ static void menu_prepare_bg(int use_game_bg, int use_fg)
 
 static void menu_gfx_prepare(void)
 {
-       menu_prepare_bg(rom_data != NULL, 1);
+       menu_prepare_bg(rom_loaded, 1);
 
        menu_draw_begin();
        menu_draw_end();
index 87c2be9..93db3cd 100644 (file)
@@ -11,7 +11,7 @@ int lock_to_1_1 = 1;
 int MainWidth=720,MainHeight=480;\r
 \r
 static HMENU mdisplay = 0;\r
-static unsigned char *rom_data = NULL;\r
+static int rom_loaded = 0;\r
 \r
 static void UpdateRect()\r
 {\r
@@ -63,10 +63,10 @@ static void LoadROM(const char *cmdpath)
   LoopWait=1;\r
   for (i = 0; LoopWaiting == 0 && i < 10; i++) Sleep(100);\r
 \r
+  PicoUnloadCart();\r
   PicoCartInsert(rom_data_new, rom_size);\r
 \r
-  if (rom_data) free(rom_data);\r
-  rom_data = rom_data_new;\r
+  rom_loaded = 1;\r
   romname = rompath;\r
   LoopWait=0;\r
 }\r
@@ -106,7 +106,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
             lock_to_1_1=0;\r
             CheckMenuItem(mdisplay, 1104, MF_UNCHECKED);\r
           }\r
-          if (rom_data != NULL) LoopWait=0;\r
+          if (rom_loaded) LoopWait=0;\r
           return 0;\r
         case 1104:\r
           lock_to_1_1=!lock_to_1_1;\r