Request FAQ for the new cheat engine (for pugsy ?)

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.
Post Reply
asper
Posts: 132
Joined: Thu Oct 18, 2007 11:44 am

Request FAQ for the new cheat engine (for pugsy ?)

Post by asper »

Can someone explain me how the new cheat xml layout works ?

I mean can smeone show how <script state="xxx"> works and MAINLY LIST all the possible or at least MOST USED script state and PARAMETERS ?

For example: how to "always active", how to "set" or "how to bind to a key" ?

Thank you very much !!!
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: Request FAQ for the new cheat engine (for pugsy ?)

Post by Pugsy »

It's a major job to write an FAQ. I've got quite a good understanding of how it all works but I don't particularly feel that confident in writing one. If you understand the old cheat format I think the best way to learn is compare the old cheat.dat cheats with the XML cheats from the dual XML/DAT release.

Put here's some asnwers to your questions:-

script states

"on" - actions here are run just once before anything else. Used for one-shot cheats (not list or selectable value one-shot cheats though), prefills and for restore previous value (to take note of the original contents into a temp variable) . Can be used for ROM cheats but best not to as it can't be taken for granted a one-shot ROM cheat works for every game.

"off" - actions here are run just once when a cheat is turned OFF. Used just for restore previous value (to take set the original contents from a temp variable) at the moment. Could be used for other things like current Invincibility list cheats with "Enabled" & "Disabled" options...so the "run" is used for "Enabled" and the "off" is used for "Disabled" - but it's horses for courses.

"run" - pretty much all perm cheats (including perm list & perm selectable value cheats)

"change" - used for one-shot list or one-shot selectable value cheats.


parameters

These are used for selectable value or list cheats (so you must have either a "run" or a "change" script). With selectable value cheats you have min, max and step fields which contain decimal numbers (min = minimum displayed value, max = maximum displayed value and step = the size of each step between the min and max). You also have a tobcd function if the selectable value is a Binary Coded Value. IMPORTANT, all param values are decimal in the <parameter> block unless preceded by 0x, whilst in the scripts they will be hexadecimal !

Two Examples:

Code: Select all

  
level is a BCD number 0x00 to 0x99. selectable param value is 0-99 (decimal) in steps of 1. tobcd converts number into BCD so 99 (0x63) is converted into 0x99 and poked


  <cheat desc="Select Starting Level">
    <parameter min="0" max="99" step="1"/>
    <script state="change">
      <action>maincpu.pb@6020F=tobcd(param)</action>
    </script>
  </cheat>

Code: Select all

  
level is a number 0x00 to 0x62. selectable param value is 1-99 (decimal) in steps of 1. As level 1 = poke of 00, we poke param-1


  <cheat desc="Select Starting Level">
    <parameter min="1" max="99" step="1"/>
    <script state="change">
      <action>maincpu.pb@6020F=param-1</action>
    </script>
  </cheat>

Selectable value cheats rarely get used for new cheats as list cheats are a lot more popular, flexible and easier to understand.

The item values (param) can either represent the poke values (as long as the values are unique) or a straightforward decimal numbering sequence.
The first is better because the action and conditions can be simplified massively. It's best to keep to hex values though, value expects a decimal value
unless prefixed with 0x and conditions will expect hex values even without the 0x prefix.

Code: Select all

  <cheat desc="Select Weapon PL1">
    <parameter>
      <item value="0x00">Normal</item>
      <item value="0x04">Flames</item>
      <item value="0x08">3-way</item>
      <item value="0x0C">Shell</item>
    </parameter>
    <script state="run">
      <action>maincpu.pb@FF82F1=param</action>
    </script>
  </cheat>

or this (which is the same thing but longer)

Code: Select all

  <cheat desc="Select Weapon PL1">
    <parameter>
      <item value="0x01">Normal</item>
      <item value="0x02">Flames</item>
      <item value="0x03">3-way</item>
      <item value="0x04">Shell</item>
    </parameter>
    <script state="run">
      <action condition="(param==01)">maincpu.pb@FF82F1=00</action>
      <action condition="(param==02)">maincpu.pb@FF82F1=04</action>
      <action condition="(param==03)">maincpu.pb@FF82F1=08</action>
      <action condition="(param==04)">maincpu.pb@FF82F1=0C</action>
    </script>
  </cheat>



At the moment I don't think pre-enable or key binding is implemented in the new cheat engine, but then I've never looked for them.
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)
User avatar
Mohsin
Posts: 85
Joined: Sun Mar 15, 2009 1:06 pm
Location: Pakistan

Re: Request FAQ for the new cheat engine (for pugsy ?)

Post by Mohsin »

i wrote this already, but had to go some where & Pugsy replied, it took me a long time to write this so i decided to post it anyways :D but my knowledge is far less than as compared to Pugsy.

I have made this tutorial in three sections for better understanding of the XML Cheat format.

1:- Understanding MAME XML Format
2:- MAME Action Scripts, Debugging
3:- Other
4:- Examples

Section 1: Understanding MAME XML Format

In this section i`ill try to make you understand the XML format containers of MAME cheat engine, The cheat engine parses the XML format & performs the actions provided to it.

1.1:- Main Container

Code: Select all

USAGE: 

<mamecheat version="1">
</mamecheat>
The Main Container is the declaration of the cheat format, it tells the Cheat Engine that the next sub-containers contains the commands for the MAME Cheats.


1.2:- Cheat Container

Code: Select all

USAGE:

<cheat desc="description">
</cheat>
The Cheat Container is the declaration of a single MAME Cheat, it contains the cheat Action Scripts, Cheat description is shown on your cheat menu.


1.3 Parameters Container

Code: Select all

USAGE:

<parameter>
</parameter>
The parameter Container, holds the cheat parameters [pre described set of item values]

1.3.1: Item Container

Code: Select all

USAGE:

<item value="0x01">DESCRIPTION</item>
Items are the selectable values described within a single cheat to perform a different action than the previous one, Item Container is used within Parameter Container, it is used to pre describe a certain value, it is used when a cheat has two or more values, eg level1, level2, level3, its value is in Decimal Format Items are selectable from within a single cheat.

1.4:- Script Container

Code: Select all

USAGE:

<script state="state">
</script>
The Script container contains the MAME Cheat action scripts, its state can be either "ON" , "OFF" , "RUN" or "CHANGE"

"ON" - Actions contained this state are executed, when cheat it is turned on, ON state can either be used to store the value of a location to a temp location for later use or it can be used to change the value of a location(not poking it). The cheat examples are "Set the level to something".

"OFF" - Actions contained in this state are executed when the cheat is turned of, it can be used to restore the previously stored value of a location.

"RUN" Actions contained in the state run are performed constantly, until the state of the cheat has been changed, eg to poke a value in the memory so that it doesn't change, unlike "ON" state which temporary change the value only.

"CHANGE" - Used for one-shot list or one-shot selectable value cheats.

1.5: Action Container:

Code: Select all

USAGE: Action Based

<action>cheat.action</action>

USAGE: Parameters Based

<action condition="(param==XX)">cheat.action</action>

USAGE: Temporary based

<action>temp0 =region.location</action>

This is the most important container as it describes the neccesory action to be performed, or we can call it the main cheat code, but cheating action in new MAME is format is actually a debug action. it can be a simple debug action or it can be a parameters based, which are contained in parameters container. it can be used to store the value of a location to a temporary value.





Section 2: MAME Action Scripts, Debugging

The main core of the XML Cheat format is the MAME debugger, cheating in the new format is the debugging of a game, this section will explain the commands to be sent to the debugger which results in a cheating action.

2.1 RAM Based Cheats

Code: Select all

USAGE:

REGION.VALUETYPE@LOCATION=VALUE
2.1.1 REGION

Region can either be maincpu, soundcpu, prot(protection cpu), this tell the debugger where the memory is located.

2.1.2 VALUETYPE

Value Type can either be byte, 2 byte, 4 byte or 8 byte, this correspond to the commands pb, pw & pd.

2.1.3 LOCATION

Location is the physical memory address of the Game, its the memory location which u want to change, the location of the memory address is always a HEX value & contained within the region u specified.

2.1.4 VALUE

this is the new value which should replace the original value of the location, note that its a HEX value so you should know what you are doing before changing a value in the memory.


2.2 ROM Based Cheats

{ONLY PUGSY CAN HELP WITH THIS, MY KNOWLEDGE ON IT IS ZERO)




Section 3: Other

This section contains the set of XML containers which cannot fit in the above sections

3.1 Cheat Comment Container

Code: Select all

USAGE:

<comment>This is my Comment</comment>
This container is used as cheat comments. i believe this feature is not implemented yet?


3.2 Comment Container

Code: Select all

USAGE:

<!-- Cheat file downloaded from http://cheat.retrogames.com, see cheat.txt for list of 

contributors. -->
This container is actually not parsed by the XML engine, it is a commented value of XML format, can be used to describe something, but cannot be processed by the XML Engine.

3.3 Empty Line Container

Code: Select all

USAGE:

<cheat desc=" "/>
This is a empty Cheat description, which will create a empty line followed by /n in the cheat menu.


Section 4: Examples

4.1 A Simple Cheat Example

Code: Select all

	<cheat desc="Infinite Time">
		<script state="run">
			<action>maincpu.pb@28DED7=63</action>
		</script>
	</cheat>

A very simple Cheat example which is for infinite time, the action being performed is that in the maincpu program memory region, at location 28DED7 the value of the first two bytes is set to 63 (6 the value of first byte & 3 being thee value of 2nd byte)


4.2 Parameters Cheat Example 1

Code: Select all

	<cheat desc="Select Power PL1">
			<parameter>
				<item value="0x1E">Infinite</item>
				<item value="0x64">Maximum</item>
			</parameter>
		<script state="run">
			<action>maincpu.pb@29ECF3=param</action>
		</script>
	</cheat>
This example use two parameters within a single cheat, the parameters are infinite & maximum, when the cheat engine see the maincpu.pb@29ECF3=param code, it puts the value of the selected item in place of the "param", thus creating a multi value cheat.

4.3 Parameters Cheat Example 2

Code: Select all


4.4 Script State Example 1

Code: Select all


	<cheat desc="Set Maximum Level Now">
		<script state="on">
			<action>maincpu.pb@29ECF3=23</action>
		</script>
	</cheat>

This above Example will set the value of the first two bytes of memory location 29ECF3 to 23 once (not constantly poke it)

4.5 Script State Example 2

Code: Select all


  <cheat desc="Always Enable Secret Code PL1"> 
  <comment>Get the weapon at the start of every stage</comment>
    <script state="on">
      <action>temp0 =maincpu.pb@6E50</action>
    </script>
    <script state="run">
      <action>maincpu.pb@6E50=18</action>
    </script>
    <script state="off">
	<action>maincpu.pb@6E50=18</action>
    </script>
  </cheat>

The above example will first stores the value of location 6E50 to a temporary location, then run state will be performed and the value of the location 6E50 will be changed to 18, and if the cheat is turned off it will again change the value of the location 6E50 to to the value previously stored in the temp0 location.
Image
Thats not a game hack

http://mamec.netii.net/
asper
Posts: 132
Joined: Thu Oct 18, 2007 11:44 am

Re: Request FAQ for the new cheat engine (for pugsy ?)

Post by asper »

I thank both of you !

Mohsin, I just added you to msn !!

Your help is REALLY appreciated !!! ;)
User avatar
NotAGoodName
Posts: 331
Joined: Wed Feb 18, 2009 7:09 am
Location: MO, USA
Contact:

Re: Request FAQ for the new cheat engine (for pugsy ?)

Post by NotAGoodName »

What is the proper way to do less than and greater than? I wrote a cheat for hsf2 that used greater than and it worked. However, now attempting to use less than parses incorrectly for God only knows what reason.

Works:
<action condition="maincpu.pb@FF8666>>00 and maincpu.pb@FF8668>>00">maincpu.pb@FF8668=01</action>

Does not work:
<action condition="maincpu.pb@FFFF03<<param">maincpu.pb@FFFF03=param</action>
<action condition="maincpu.pb@FFFF03<param">maincpu.pb@FFFF03=param</action>
<action condition="(maincpu.pb@FFFF03<param)">maincpu.pb@FFFF03=param</action>
<action condition="(maincpu.pb@FFFF03<<param)">maincpu.pb@FFFF03=param</action>

*edit*
Nvm. I can't believe < is actually parsed as the math symbol less than...
Aww yeah. AMD A10-7850K givin' MAME and MESS systems what for.
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: Request FAQ for the new cheat engine (for pugsy ?)

Post by Pugsy »

NotAGoodName wrote:What is the proper way to do less than and greater than? I wrote a cheat for hsf2 that used greater than and it worked. However, now attempting to use less than parses incorrectly for God only knows what reason.
It's an XML thing, < is used as a start tag in XML so it will get it's knickers in a twist if you start using it willy nilly. The XML cheat files use GT instead of > and LT instead of < throughout as too many <> just looks ugly (you can see this usage in force range cheats like the keep ball in play cheats for arkanoid). There are alternatives for most things like EQ for ==, GE for >=, LE for <=.
Works:
<action condition="maincpu.pb@FF8666>>00 and maincpu.pb@FF8668>>00">maincpu.pb@FF8668=01</action>
The >> above actually represents a right bit shift of 0 bits so it's an action rather than a condition so it will always pass, and in the above example it will poke FF8668 with 01 regardless.
Does not work:
<action condition="maincpu.pb@FFFF03<<param">maincpu.pb@FFFF03=param</action>
Again that's a BIT SHIFT though to the left, it uses the same < as LT. There is currently no alternative for it so it doesn't work at all, I actually submitted a fix so << has an alt of LSHIFT and >> has an alt of RSHIFT a few days ago.

*edit*
Nvm. I can't believe < is actually parsed as the math symbol less than...
Don't use &lt, use LT it's much nicer.
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