patch/gg support, 1.201 release
[picodrive.git] / platform / gp2x / emu.c
index d973805..c8c4f8a 100644 (file)
@@ -21,8 +21,9 @@
 #include "asmutils.h"\r
 #include "cpuctrl.h"\r
 \r
-#include "Pico/PicoInt.h"\r
-#include "zlib/zlib.h"\r
+#include <Pico/PicoInt.h>\r
+#include <Pico/Patch.h>\r
+#include <zlib/zlib.h>\r
 \r
 \r
 #ifdef BENCHMARK\r
@@ -229,6 +230,8 @@ int emu_ReloadRom(void)
                return 0;\r
        }\r
 \r
+       PicoPatchUnload();\r
+\r
        // check for movie file\r
        if(movie_data) {\r
                free(movie_data);\r
@@ -269,6 +272,16 @@ int emu_ReloadRom(void)
                }\r
                get_ext(romFileName, ext);\r
        }\r
+       else if (!strcmp(ext, ".pat")) {\r
+               int dummy;\r
+               PicoPatchLoad(romFileName);\r
+               dummy = try_rfn_cut() || try_rfn_cut();\r
+               if (!dummy) {\r
+                       sprintf(menuErrorMsg, "Could't find a ROM to patch.");\r
+                       return 0;\r
+               }\r
+               get_ext(romFileName, ext);\r
+       }\r
 \r
        // check for MegaCD image\r
        cd_state = cd_check(ext, &used_rom_name);\r
@@ -351,6 +364,11 @@ int emu_ReloadRom(void)
        strncpy(currentConfig.lastRomFile, romFileName, sizeof(currentConfig.lastRomFile)-1);\r
        currentConfig.lastRomFile[sizeof(currentConfig.lastRomFile)-1] = 0;\r
 \r
+       if (PicoPatches) {\r
+               PicoPatchPrepare();\r
+               PicoPatchApply();\r
+       }\r
+\r
        // additional movie stuff\r
        if(movie_data) {\r
                if(movie_data[0x14] == '6')\r