From 70d2ecc5ebd5465ad000ff648abe79b3b4969e64 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 26 Feb 2007 23:46:45 +0000 Subject: [PATCH] patch/gg support, 1.201 release git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@58 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/Makefile | 3 ++- gp2x/emu.c | 22 +++++++++++++++-- gp2x/menu.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++-- gp2x/version.h | 2 +- linux/Makefile | 3 ++- 5 files changed, 87 insertions(+), 7 deletions(-) diff --git a/gp2x/Makefile b/gp2x/Makefile index c5d339f..a3c6961 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -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 # 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 \ diff --git a/gp2x/emu.c b/gp2x/emu.c index d973805..c8c4f8a 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -21,8 +21,9 @@ #include "asmutils.h" #include "cpuctrl.h" -#include "Pico/PicoInt.h" -#include "zlib/zlib.h" +#include +#include +#include #ifdef BENCHMARK @@ -229,6 +230,8 @@ int emu_ReloadRom(void) return 0; } + PicoPatchUnload(); + // check for movie file if(movie_data) { free(movie_data); @@ -269,6 +272,16 @@ int emu_ReloadRom(void) } get_ext(romFileName, ext); } + else if (!strcmp(ext, ".pat")) { + int dummy; + PicoPatchLoad(romFileName); + dummy = try_rfn_cut() || try_rfn_cut(); + if (!dummy) { + sprintf(menuErrorMsg, "Could't find a ROM to patch."); + return 0; + } + get_ext(romFileName, ext); + } // check for MegaCD image cd_state = cd_check(ext, &used_rom_name); @@ -351,6 +364,11 @@ int emu_ReloadRom(void) strncpy(currentConfig.lastRomFile, romFileName, sizeof(currentConfig.lastRomFile)-1); currentConfig.lastRomFile[sizeof(currentConfig.lastRomFile)-1] = 0; + if (PicoPatches) { + PicoPatchPrepare(); + PicoPatchApply(); + } + // additional movie stuff if(movie_data) { if(movie_data[0x14] == '6') diff --git a/gp2x/menu.c b/gp2x/menu.c index 236b693..032616a 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -17,8 +17,9 @@ #include "usbjoy.h" #include "version.h" -#include "Pico/PicoInt.h" -#include "zlib/zlib.h" +#include +#include +#include #ifndef _DIRENT_HAVE_D_TYPE #error "need d_type for file browser @@ -391,6 +392,54 @@ static char *romsel_loop(char *curr_path) return ret; } +// ------------ patch/gg menu ------------ + +static void draw_patchlist(int sel) +{ + int start, i, pos; + + start = 12 - sel; + + gp2x_pd_clone_buffer2(); + + for (i = 0; i < PicoPatchCount; i++) { + pos = start + i; + if (pos < 0) continue; + if (pos > 23) break; + gp2x_smalltext8_lim(14, pos*10, PicoPatches[i].active ? "ON " : "OFF", 3); + gp2x_smalltext8_lim(14+6*4, pos*10, PicoPatches[i].name, 53-5); + } + pos = start + i; + if (pos < 24) gp2x_smalltext8_lim(14, pos*10, "done", 4); + + gp2x_text_out8(5, 120, ">"); + gp2x_video_flip2(); +} + + +void patches_menu_loop(void) +{ + int menu_sel = 0; + unsigned long inp = 0; + + for(;;) + { + draw_patchlist(menu_sel); + inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_B|GP2X_X); + if(inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } + if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } + if(inp &(GP2X_LEFT|GP2X_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } + if(inp &(GP2X_RIGHT|GP2X_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; } + if(inp & GP2X_B) { // action + if (menu_sel < PicoPatchCount) + PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active; + else return; + } + if(inp & GP2X_X) return; + } + +} + // ------------ savestate loader ------------ static void menu_prepare_bg(void); @@ -1106,6 +1155,8 @@ static void draw_menu_root(int menu_sel) gp2x_text_out8(tl_x, (y+=10), "Configure controls"); gp2x_text_out8(tl_x, (y+=10), "Credits"); gp2x_text_out8(tl_x, (y+=10), "Exit"); + if (PicoPatches) + gp2x_text_out8(tl_x, (y+=10), "Patches / GameGenie"); // draw cursor gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">"); @@ -1133,6 +1184,7 @@ static void menu_loop_root(void) } if (rom_data) menu_sel = menu_sel_min = 0; + if (PicoPatches) menu_sel_max = 9; for(;;) { @@ -1199,6 +1251,14 @@ static void menu_loop_root(void) case 8: // exit engineState = PGS_Quit; return; + case 9: // patches/gg + if (rom_data && PicoPatches) { + patches_menu_loop(); + PicoPatchApply(); + strcpy(menuErrorMsg, "Patches applied"); + continue; + } + break; } } menuErrorMsg[0] = 0; // clear error msg diff --git a/gp2x/version.h b/gp2x/version.h index eeb782c..db5382d 100644 --- a/gp2x/version.h +++ b/gp2x/version.h @@ -1,2 +1,2 @@ -#define VERSION "1.20" +#define VERSION "1.201" diff --git a/linux/Makefile b/linux/Makefile index 732a830..fc5ff06 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -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 \ -- 2.39.2