patch/gg support, 1.201 release
authornotaz <notasas@gmail.com>
Mon, 26 Feb 2007 23:46:45 +0000 (23:46 +0000)
committernotaz <notasas@gmail.com>
Mon, 26 Feb 2007 23:46:45 +0000 (23:46 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@58 be3aeb3a-fb24-0410-a615-afba39da0efa

gp2x/Makefile
gp2x/emu.c
gp2x/menu.c
gp2x/version.h
linux/Makefile

index c5d339f..a3c6961 100644 (file)
@@ -38,7 +38,8 @@ OBJS += main.o menu.o fonts.o gp2x.o usbjoy.o emu.o squidgehack.o asmutils.o cpu
 OBJS += 940ctl.o\r
 # Pico\r
 OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory.o ../../Pico/Misc.o \\r
-               ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o\r
+               ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \\r
+               ../../Pico/Patch.o\r
 # Pico - CD\r
 OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \\r
                ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \\r
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
index 236b693..032616a 100644 (file)
@@ -17,8 +17,9 @@
 #include "usbjoy.h"\r
 #include "version.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
 #ifndef _DIRENT_HAVE_D_TYPE\r
 #error "need d_type for file browser\r
@@ -391,6 +392,54 @@ static char *romsel_loop(char *curr_path)
        return ret;\r
 }\r
 \r
+// ------------ patch/gg menu ------------\r
+\r
+static void draw_patchlist(int sel)\r
+{\r
+       int start, i, pos;\r
+\r
+       start = 12 - sel;\r
+\r
+       gp2x_pd_clone_buffer2();\r
+\r
+       for (i = 0; i < PicoPatchCount; i++) {\r
+               pos = start + i;\r
+               if (pos < 0)  continue;\r
+               if (pos > 23) break;\r
+               gp2x_smalltext8_lim(14,     pos*10, PicoPatches[i].active ? "ON " : "OFF", 3);\r
+               gp2x_smalltext8_lim(14+6*4, pos*10, PicoPatches[i].name, 53-5);\r
+       }\r
+       pos = start + i;\r
+       if (pos < 24) gp2x_smalltext8_lim(14, pos*10, "done", 4);\r
+\r
+       gp2x_text_out8(5, 120, ">");\r
+       gp2x_video_flip2();\r
+}\r
+\r
+\r
+void patches_menu_loop(void)\r
+{\r
+       int menu_sel = 0;\r
+       unsigned long inp = 0;\r
+\r
+       for(;;)\r
+       {\r
+               draw_patchlist(menu_sel);\r
+               inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_B|GP2X_X);\r
+               if(inp & GP2X_UP  ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }\r
+               if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }\r
+               if(inp &(GP2X_LEFT|GP2X_L))  { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }\r
+               if(inp &(GP2X_RIGHT|GP2X_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; }\r
+               if(inp & GP2X_B) { // action\r
+                       if (menu_sel < PicoPatchCount)\r
+                               PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active;\r
+                       else    return;\r
+               }\r
+               if(inp & GP2X_X) return;\r
+       }\r
+\r
+}\r
+\r
 // ------------ savestate loader ------------\r
 \r
 static void menu_prepare_bg(void);\r
@@ -1106,6 +1155,8 @@ static void draw_menu_root(int menu_sel)
        gp2x_text_out8(tl_x, (y+=10), "Configure controls");\r
        gp2x_text_out8(tl_x, (y+=10), "Credits");\r
        gp2x_text_out8(tl_x, (y+=10), "Exit");\r
+       if (PicoPatches)\r
+               gp2x_text_out8(tl_x, (y+=10), "Patches / GameGenie");\r
 \r
        // draw cursor\r
        gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">");\r
@@ -1133,6 +1184,7 @@ static void menu_loop_root(void)
        }\r
 \r
        if (rom_data) menu_sel = menu_sel_min = 0;\r
+       if (PicoPatches) menu_sel_max = 9;\r
 \r
        for(;;)\r
        {\r
@@ -1199,6 +1251,14 @@ static void menu_loop_root(void)
                                case 8: // exit\r
                                        engineState = PGS_Quit;\r
                                        return;\r
+                               case 9: // patches/gg\r
+                                       if (rom_data && PicoPatches) {\r
+                                               patches_menu_loop();\r
+                                               PicoPatchApply();\r
+                                               strcpy(menuErrorMsg, "Patches applied");\r
+                                               continue;\r
+                                       }\r
+                                       break;\r
                        }\r
                }\r
                menuErrorMsg[0] = 0; // clear error msg\r
index eeb782c..db5382d 100644 (file)
@@ -1,2 +1,2 @@
-#define VERSION "1.20"\r
+#define VERSION "1.201"\r
 \r
index 732a830..fc5ff06 100644 (file)
@@ -27,7 +27,8 @@ LDFLAGS += `pkg-config --libs gthread-2.0`
 OBJS += ../gp2x/main.o ../gp2x/menu.o ../gp2x/fonts.o ../gp2x/emu.o ../gp2x/usbjoy.o blit.o gp2x.o 940ctl_ym2612.o
 # Pico
 OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory.o ../../Pico/Misc.o \
-               ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o
+               ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \
+               ../../Pico/Patch.o
 # Pico - CD
 OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
                ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \