From 31d554dc17a3857d57013117f73f26db24a98b4a Mon Sep 17 00:00:00 2001 From: Phil Bennett Date: Sun, 19 Dec 2010 17:41:56 +0000 Subject: [PATCH] Added a 'changed by' search to the cheat engine [Pugsy] ---------- Forwarded message ---------- From: Pugsy Date: Tue, Dec 14, 2010 at 3:13 PM Subject: Minor patch to improve cheat finding functionality To: submit@mamedev.org Cc: "stephh U.P." Hi Here is a simple patch that will add a "changed by" search - it's effectively a increased and decreased search rolled into one. It is useful when you are uncertain if the value has increased by x or decreased by x so it saves having to guess which search method to try first. -- Martin 'Pugsy' Pugh MAME Cheat File Maintainer http://mamecheat.co.uk Gamebase64 Team Member http://www.gamebase64.com --- src/emu/debug/debugcmd.c | 11 ++++++++++- src/emu/debug/debughlp.c | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index 0cb47062361..dbea2d50af8 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -1834,7 +1834,8 @@ static void execute_cheatnext(running_machine *machine, int ref, int params, con CHEAT_DECREASEOF, CHEAT_INCREASEOF, CHEAT_SMALLEROF, - CHEAT_GREATEROF + CHEAT_GREATEROF, + CHEAT_CHANGEDBY }; if (cheat.cpu == 0) @@ -1869,6 +1870,8 @@ static void execute_cheatnext(running_machine *machine, int ref, int params, con condition = CHEAT_SMALLEROF; else if (!strcmp(param[0], "greaterof") || !strcmp(param[0], "gt") || !strcmp(param[0], ">")) condition = CHEAT_GREATEROF; + else if (!strcmp(param[0], "changedby") || !strcmp(param[0], "ch") || !strcmp(param[0], "~")) + condition = CHEAT_CHANGEDBY; else { debug_console_printf(machine, "Invalid condition type\n"); @@ -1955,6 +1958,12 @@ static void execute_cheatnext(running_machine *machine, int ref, int params, con else disable_byte = ((UINT64)cheat_value <= (UINT64)comp_value); break; + case CHEAT_CHANGEDBY: + if (cheat_value > comp_byte) + disable_byte = (cheat_value != comp_byte + comp_value); + else + disable_byte = (cheat_value != comp_byte - comp_value); + break; } if (disable_byte) diff --git a/src/emu/debug/debughlp.c b/src/emu/debug/debughlp.c index 1f7e1efd2f0..8ef20db442f 100644 --- a/src/emu/debug/debughlp.c +++ b/src/emu/debug/debughlp.c @@ -1113,6 +1113,9 @@ static const help_item static_help_list[] = " greaterof [gt]\n" " without this condition is invalid\n" " with search for all bytes that are larger than the .\n" + " changedby [ch, ~]\n" + " without this condition is invalid\n" + " with search for all bytes that have changed by the since the last search.\n" "\n" "Examples:\n" "\n" @@ -1156,6 +1159,9 @@ static const help_item static_help_list[] = " greaterof [gt]\n" " without this condition is invalid.\n" " with search for all bytes that are larger than the .\n" + " changedby [ch, ~]\n" + " without this condition is invalid\n" + " with search for all bytes that have changed by the since the initial search.\n" "\n" "Examples:\n" "\n"