My personal system for the search of the cheat

If you are having problems finding or using cheats for an Emulator (particularly MAME/MESS) or have found a trick that you wish to share this is the place to do it. But please read the Cheat FAQ first.
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

My personal system for the search of the cheat

Post by s.ronco »

Hi to everybody,

After the rewrite of the cheat system, MAME doesn't have a system for search the cheats, then I decided to do it myself.
Here is the link to the file, that contains the binary MAME (with my seeking system) and a small guide.

http://www.megaupload.com/?d=TQ0QW52C

For any problem or suggestion use this forum (hoping that Pugsy agrees).
This is only a first version and has only basic functions.
User avatar
Pugsy
Posts: 3638
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 12 times
Contact:

Re: My personal system for the search of the cheat

Post by Pugsy »

Wow! That has come completely out of the blue and sounds very interesting & promising! I'll take a ganders tonight, any chance of the debug* source changes or submitting them to Aaron soonish?
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.259 XML cheat collection (6 OCTOBER 2023) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/q4dHGZ6K#i-EUiqIjH ... KMz7hnbTfw (ZIP Archive 3.76MB)
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

Thanks Pugsy, this is the diff of the changes.

http://www.megaupload.com/?d=8CA3CB7O
User avatar
Pugsy
Posts: 3638
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 12 times
Contact:

Re: My personal system for the search of the cheat

Post by Pugsy »

I'm impressed, works very well - actually looks quite straightforward to modify too. I have a few observations/suggestions to start with - all simple things to fix I think.

The decode conditions..
Would be good to have some alternatives like gt,lt,ne,eq,le,ge,+,- (don't really like the present wordy descriptions).
The seperate xxxxxto conditions could be trimmed by testing for a valid param[1], so if the condition was "decrease" with a param[1] of 5 it would assume a "decreaseof" without having to type it in.

When cheat list is output to a file, it would be better to output it in a basic xml format which will be easier to get working along the lines of:

Code: Select all

      	fprintf(f, "  <cheat desc=\"Possibility %d : %X (%02X)\">\n",i+1, (UINT32)cheat.cheatmap[i].offset, byte);  
      	fprintf(f, "    <script state=\"run\">\n");  
      	fprintf(f, "      <action>maincpu.pb@%X=%02X</action>\n", (UINT32)cheat.cheatmap[i].offset, byte);
      	fprintf(f, "    </script>\n"); 
      	fprintf(f, "  </cheat>\n\n"); 
There needs to be short forms of the cheat commands handled by debug_console_register_command
eg. "cheatinit" could also accept "init" and "ci" and maybe "start"
"cheatnext" could also accept "next" and "cn" and maybe "continue"/"cont"
etc.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.259 XML cheat collection (6 OCTOBER 2023) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/q4dHGZ6K#i-EUiqIjH ... KMz7hnbTfw (ZIP Archive 3.76MB)
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

For the conditions I will follow his suggestion, but for the commands handled I would not use too generic words (like start or continue) that could have other uses, ci, cn, cl and cu should fit
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

New version with Pugsy's suggestions.

The main change are:
-if cheatinit is used without parametre initialize the entire memory of main cpu
-the xxxxxto conditions are automatic detected when is found a valid param[1]
-the file out is in xml
-new function cheatnextf for comparison whit initial value
-added alternative words for the conditions and the commands

http://www.megaupload.com/?d=PAGYWUJB
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

now only writable bytes are initialized, less resource required (especially on 32 bit cpu).

http://www.megaupload.com/?d=JDKO7B9D
User avatar
Pugsy
Posts: 3638
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 12 times
Contact:

Re: My personal system for the search of the cheat

Post by Pugsy »

Sounds good, any chance of an updated diff file please.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.259 XML cheat collection (6 OCTOBER 2023) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/q4dHGZ6K#i-EUiqIjH ... KMz7hnbTfw (ZIP Archive 3.76MB)
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

The last diff is in the zip of last update.
User avatar
Pugsy
Posts: 3638
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 12 times
Contact:

Re: My personal system for the search of the cheat

Post by Pugsy »

Thanks, only searching writeable bytes works a treat.

Some more observations

1. The poke value returned by the cheatlist command should be the first value rather than the current value (as it's what you desire most of the time). So, if you do start a lives search when you have 5 lives and find the result when you have 2 lives you'd expect it to show something like: ADD33551 05 instead of ADD33551 02. Ideally it could show both values along the lines of "ADD33551 START=05, CURRENT=02".

2. When the results get down to under say about 5 locations it should automatically perform a screen cheatlist.

3. "cn gt" and "cn lt" should be error-trapped before doing anything as they haven't got a comparison value - so they correspond to "cn gt,0" and "cn lt,0" and not surprisingly "cn lt 0" will return 0 bytes and bugger up your search :) Ideally it should also error-trap "cn lt,0" or "cn gt,XX" (where XX>0xFE). There is another problem though as it doesn't error trap the comparison value at all, it doesn't complain if I type in "cn gt,helloworld" and even returns matches!
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.259 XML cheat collection (6 OCTOBER 2023) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/q4dHGZ6K#i-EUiqIjH ... KMz7hnbTfw (ZIP Archive 3.76MB)
stephh
Posts: 601
Joined: Fri Aug 17, 2001 1:00 am
Location: Paris, France

Re: My personal system for the search of the cheat

Post by stephh »

Even if I haven't tested your additions (I can't even compile them yet), I'm very impressed (and of course happy) to see that you've added in an easy way what we expected from Aaron since last year and the change to XML format :)


Before you submit this to MAME Team, here are a couple of things to do or change :

1) Add contents of your help.txt file to src/emu/debug/debughlp.c file : this shall be straightforward as this souce file is full of text (only ensure that you don't forget the \n at the end of the lines) ...

2) In execute_cheatnext function, you've declared some #define :

Code: Select all

+	#define CHEAT_ALL				    0
+	#define CHEAT_EQUAL				    1
+	#define CHEAT_NOTEQUAL				2
+	#define CHEAT_EQUALTO				3
+	#define CHEAT_NOTEQUALTO			4
+	#define CHEAT_DECREASE				5
+	#define CHEAT_INCREASE				6
+	#define CHEAT_DECREASEOF			7
+	#define CHEAT_INCREASEOF			8
+	#define CHEAT_SMALLEROF				9
+	#define CHEAT_GREATERTOF			10
IMO, this could be done with an enum like, for example, in src/mame/includes/arkanoid.h :

Code: Select all

enum {
	CHEAT_ALL=0,
	CHEAT_EQUAL,
	CHEAT_NOTEQUAL,
	CHEAT_EQUALTO,
	CHEAT_NOTEQUALTO,
	CHEAT_DECREASE,
	CHEAT_INCREASE,
	CHEAT_DECREASEOF,
	CHEAT_INCREASEOF,
	CHEAT_SMALLEROF,
	CHEAT_GREATEROF
};
I can't tell however if this declaration shall stay in the function, be moved to emu/src/debug/debugcmd.h, be moved to emu/src/cheat.h, or be moved elsewhere ...

3) In execute_cheatlist function, you shall open the file with an append instead of a write :

Code: Select all

+		f = fopen(param[0], "w");
shall be :

Code: Select all

+		f = fopen(param[0], "a");
or we might lose previous saves ...


Once you've coded these modifications, I think you shall submit them to MAME Team, so they can be included in an official release and we could get the benefit of having a working cheat engine as for next "stable" MAME version (ie 0.134) ... Once again, great work ! :)

Image Steph from The Ultimate Patchers Image
stephh
Posts: 601
Joined: Fri Aug 17, 2001 1:00 am
Location: Paris, France

Re: My personal system for the search of the cheat

Post by stephh »

Pugsy wrote:Some more observations

1. The poke value returned by the cheatlist command should be the first value rather than the current value (as it's what you desire most of the time). So, if you do start a lives search when you have 5 lives and find the result when you have 2 lives you'd expect it to show something like: ADD33551 05 instead of ADD33551 02. Ideally it could show both values along the lines of "ADD33551 START=05, CURRENT=02".
I agree that the initial and the current value shall be shown ...
2. When the results get down to under say about 5 locations it should automatically perform a screen cheatlist.
I don't really agree : the results shall be automatically saved only if there is ONE matching address (same behaviour as before) ...
3. "cn gt" and "cn lt" should be error-trapped before doing anything as they haven't got a comparison value - so they correspond to "cn gt,0" and "cn lt,0" and not surprisingly "cn lt 0" will return 0 bytes and bugger up your search :) Ideally it should also error-trap "cn lt,0" or "cn gt,XX" (where XX>0xFE). There is another problem though as it doesn't error trap the comparison value at all, it doesn't complain if I type in "cn gt,helloworld" and even returns matches!
Well ... No need to lengthen the code with tests for errors that "expert" cheat finders won't do (especially your comparison with a string) ...

Image Steph from The Ultimate Patchers Image
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

@Pugsy
1: you are right the first value is more important, but however the format "ADD33551 START=05, CURRENT=02" is the best

2: do an automatic cheatlist when active byte are <= 5 is useful and is very easy to do

3: the control if the param[1] is a valid number is important, the others situations can be manage by the cheat finder, and however can use cheatundo

@stephh
1: is in my TODO list

2: yes enum is better that define, changed

3: the currently file output is only a list of active byte, append doesn't have sense, if in the future I write a function that add a cheat directly in the <gamename>.xml, of course I will use the append.
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

new update:
- add new command cheatrange for add multiple range to the cheat system
- minor change and fix
thanks to Pugsy and stephh for their suggestions

http://www.megaupload.com/?d=O5IH62DZ
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

I have integrated help.txt in the code and some tests on mess.

http://www.megaupload.com/?d=8ZBQJ7TJ
User avatar
Pugsy
Posts: 3638
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 12 times
Contact:

Re: My personal system for the search of the cheat

Post by Pugsy »

Brilliant work, I believe you could safely submit this to mamedev.

Only real problem I have is with some of the confusing english in debughlp.c, I think something along these lines maybe better (it's still not perfect though).

Code: Select all

+		"  cheatinit [<address>,<length>[,<cpu>]] -- initialize the cheat search to the selected memory area\n"
+		"  cheatrange <address>,<length> -- add to the cheat search the selected memory area\n"
+		"  cheatnext <condition>[,<comparisonvalue>] -- continue cheat search comparing with the the last value\n"
+		"  cheatnextf <condition>[,<comparisonvalue>] -- continue cheat search comparing with the the first value\n"
+		"  cheatlist [<filename>] -- show the list of cheat search matches or save them to <filename>\n"
+		"  cheatundo [<wpnum>] -- undo the last cheat search (state only)\n"


+		"cheatinit",
+		"\n"
+		"  cheatinit [<address>,<length>[,<cpu>]]\n"
+		"\n"
+		"The cheatinit command initializes the cheat search to the selected memory area.\n"
+		"If no parameter is specified the cheat search is initialized to all changeable memory of the main cpu.\n"
+		"\n"
+		"Examples:\n"
+		"\n"
+		"cheatinit 0x1000,0x10\n"
+		"  Initialize the cheat search from 0x1000 to 0x1010 of the first CPU.\n"
+		"\n"
+		"cheatinit 0x2000,0x1000,1\n"
+		"  Initialize the cheat search from 0x2000 to 0x3000 of the second CPU.\n"


+		"cheatrange",
+		"\n"
+		"  cheatrange <address>,<length>\n"
+		"\n"
+		"The cheatrange command adds the selected memory area to the cheat search.\n"
+		"Before using cheatrange it is necessary to initialize the cheat search with cheatinit.\n" 
+		"\n"
+		"Examples:\n"
+		"\n"
+		"cheatrange 0x1000,0x10\n"
+		"  Add the bytes from 0x1000 to 0x1010 to the cheat search.\n"


+		"cheatnext",
+		"\n"
+		"  cheatnext <condition>[,<comparisonvalue>]\n"
+		"\n"
+		"The cheatnext command will make comparisons with the last search matches.\n"
+		"Possible <condition>:\n"
+		"  all\n"
+		"   no <comparisonvalue> needed.\n"
+		"   use to update the last value without changing the current matches.\n"
+		"  equal [eq]\n"
+		"   without <comparisonvalue> search for all bytes that are equal to the last search.\n"
+		"   with <comparisonvalue> search for all bytes that are equal to the <comparisonvalue>.\n"
+		"  notequal [ne]\n"
+		"   without <comparisonvalue> search for all bytes that are not equal to the last search.\n"
+		"   with <comparisonvalue> search for all bytes that are not equal to the <comparisonvalue>.\n"
+		"  decrease [de, +]\n"
+		"   without <comparisonvalue> search for all bytes that have decreased since the last search.\n"
+		"   with <comparisonvalue> search for all bytes that have decreased by the <comparisonvalue> since the last search.\n"
+		"  increase [in, -]\n"
+		"   without <comparisonvalue> search for all bytes that have increased since the last search.\n"
+		"   with <comparisonvalue> search for all bytes that have increased by the <comparisonvalue> since the last search.\n"
+		"  smallerof [lt]\n"
+		"   without <comparisonvalue> this condition is invalid\n"
+		"   with <comparisonvalue> search for all bytes that are smaller than the <comparisonvalue>.\n"
+		"  greaterof [gt]\n"
+		"   without <comparisonvalue> this condition is invalid\n"
+		"   with <comparisonvalue> search for all bytes that are larger than the <comparisonvalue>.\n"
+		"\n"
+		"Examples:\n"
+		"\n"
+		"cheatnext increase\n"
+		"  search for all bytes that have increased since the last search.\n"
+		"\n"
+		"cheatnext decrease, 1\n"
+		"  search for all bytes that have decreased by 1 since the last search.\n"


+		"cheatnextf",
+		"\n"
+		"  cheatnextf <condition>[,<comparisonvalue>]\n"
+		"\n"
+		"The cheatnextf command will make comparisons with the initial search.\n"
+		"Possible <condition>:\n"
+		"  all\n"
+		"   no <comparisonvalue> needed.\n"
+		"   use to update the last value without changing the current matches.\n"
+		"  equal [eq]\n"
+		"   without <comparisonvalue> search for all bytes that are equal to the initial search.\n"
+		"   with <comparisonvalue> search for all bytes that are equal to the <comparisonvalue>.\n"
+		"  notequal [ne]\n"
+		"   without <comparisonvalue> search for all bytes that are not equal to the initial search.\n"
+		"   with <comparisonvalue> search for all bytes that are not equal to the <comparisonvalue>.\n"
+		"  decrease [de, +]\n"
+		"   without <comparisonvalue> search for all bytes that have decreased since the initial search.\n"
+		"   with <comparisonvalue> search for all bytes that have decreased by the <comparisonvalue> since the initial search.\n"
+		"  increase [in, -]\n"
+		"   without <comparisonvalue> search for all bytes that have increased since the initial search.\n"
+		"   with <comparisonvalue> search for all bytes that have increased by the <comparisonvalue> since the initial search.\n"
+		"  smallerof [lt]\n"
+		"   without <comparisonvalue> this condition is invalid.\n"
+		"   with <comparisonvalue> search for all bytes that are smaller than the <comparisonvalue>.\n"
+		"  greaterof [gt]\n"
+		"   without <comparisonvalue> this condition is invalid.\n"
+		"   with <comparisonvalue> search for all bytes that are larger than the <comparisonvalue>.\n"
+		"\n"
+		"Examples:\n"
+		"\n"
+		"cheatnextf increase\n"
+		"  search for all bytes that have increased since the initial search.\n"
+		"\n"
+		"cheatnextf decrease, 1\n"
+		"  search for all bytes that have decreased by 1 since the initial search.\n"


+		"cheatlist",
+		"\n"
+		"  cheatlist [<filename>]\n"
+		"\n"
+		"Without <filename> show the list of matches in the debug console.\n"
+		"With <filename> save the list of matches in basic xml format to <filename>.\n"
+		"\n"
+		"Examples:\n"
+		"\n"
+		"cheatlist\n"
+		"  Show the current matches in the debug console.\n"
+		"cheatlist cheat.txt\n"
+		"  Save the current matches to cheat.txt.\n"


+		"cheatundo",
+		"\n"
+		"  cheatundo\n"
+		"\n"
+		"Undo the results of the last search.\n"
+		"The undo command has no effect on the last value.\n"  <-- THIS NEEDS MORE CLARIFICATION
+		"\n"
+		"Examples:\n"
+		"\n"
+		"cheatundo\n"
+		"  Undo the last search (state only).\n"
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.259 XML cheat collection (6 OCTOBER 2023) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/q4dHGZ6K#i-EUiqIjH ... KMz7hnbTfw (ZIP Archive 3.76MB)
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

Thanks Pugsy, my English is very bad.
etabeta78
Posts: 32
Joined: Tue Dec 05, 2006 9:46 pm
Location: Trondheim, Norway

Re: My personal system for the search of the cheat

Post by etabeta78 »

I hope you will submit the changes to Aaron soon: even if you plan to change some more code, inclusion in next update would allow much wider testing among both MAMEDev and MAME users, with faster reports of bugs and other possible issues

great work in any case!
s.ronco
Posts: 24
Joined: Tue Aug 18, 2009 3:29 pm

Re: My personal system for the search of the cheat

Post by s.ronco »

You are right, I have submitted the diff.
User avatar
Pugsy
Posts: 3638
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 12 times
Contact:

Re: My personal system for the search of the cheat

Post by Pugsy »

Great work, my fingers are crossed for it to make u4.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.259 XML cheat collection (6 OCTOBER 2023) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/q4dHGZ6K#i-EUiqIjH ... KMz7hnbTfw (ZIP Archive 3.76MB)
Post Reply