CheatMaker 论坛

注册

 

发新话题 回复该主题

holycheat! MAME cheat编写教程 [复制链接]

1#
源:https://www.mamecheat.co.uk/guides.htm
需要飞机,对面中国IP做了屏蔽。
holycheat!.zip (, 下载次数:5)


https://github.com/mamedev/mame/blob/master/src/frontend/mame/cheat.cpp
  1.     Cheat XML format:

  2.     <mamecheat version="1">
  3.         <cheat desc="blah">
  4.            <parameter min="minval(0)" max="maxval(numitems)" step="stepval(1)">
  5.               <item value="itemval(previtemval|minval+stepval)">text</item>
  6.               ...
  7.            </parameter>
  8.            <script state="on|off|run|change(run)">
  9.               <action condition="condexpr(1)">expression</action>
  10.               ...
  11.               <output condition="condexpr(1)" format="format(required)" line="line(0)" align="left|center|right(left)">
  12.                  <argument count="count(1)">expression</argument>
  13.               </output>
  14.               ...
  15.            </script>
  16.            ...
  17.            <comment>
  18.               ... text ...
  19.            </comment>
  20.         </cheat>
  21.         ...
  22.     </mamecheat>

  23. ****************************************************************************

  24.     Expressions are standard debugger expressions. Note that & and
  25.     < must be escaped per XML rules. Within attributes you must use
  26.     & and <. For tags, you can also use <![CDATA[ ... ]]>.

  27.     Each cheat has its own context-specific variables:

  28.         temp0-temp9 -- 10 temporary variables for any use
  29.         param       -- the current value of the cheat parameter
  30.         frame       -- the current frame index
  31.         argindex    -- for arguments with multiple iterations, this is the index

  32.     By default, each cheat has 10 temporary variables that are
  33.     persistent while executing its scripts. Additional temporary
  34.     variables may be requested via the 'tempvariables' attribute
  35.     on the cheat.

  36. ****************************************************************************

  37.     Cheats are generally broken down into categories based on
  38.     which actions are defined and whether or not there is a
  39.     parameter present:

  40.     ---- Actions -----
  41.     On   Off  Run  Chg  Param?  Type
  42.     ===  ===  ===  ===  ======  =================================
  43.      N    N    N    ?    None   Text-only (displays text in menu)
  44.      Y    N    N    ?    None   Oneshot (select to activate)
  45.      Y    Y    N    ?    None   On/Off (select to toggle)
  46.      ?    ?    Y    ?    None   On/Off (select to toggle)

  47.      ?    N    N    Y    Any    Oneshot parameter (select to alter)
  48.      ?    Y    ?    ?    Value  Value parameter (off or a live value)
  49.      ?    ?    Y    ?    Value  Value parameter (off or a live value)
  50.      ?    Y    ?    ?    List   Item list parameter (off or a live value)
  51.      ?    ?    Y    ?    List   Item list parameter (off or a live value)
复制代码
  1. <cheat desc="Enable Mobi-Chan Flag">
  2.     <script state="run">
  3.       <action>maincpu.pb@E009=99</action>
  4.     </script>
  5.   </cheat>
复制代码
script state,启用方式。on/off为按下回车后启用,但两这项是对立且独立的。通常情况下,on/off搭配temp用于对ROM区的内存操作。on开启cheat后,数据会写入temp。off关闭对应操作后会将temp的数据还原。on可单独使用,用于直接按下后启用,不需要关闭的情况。
run为开关式启用,可选择开或关。
change为多选项切换启用,在多个选项之间按回车启用。

maincpu,主要CPU,CPU 0。一些基板不只一个CPU。比如:主CPU 68K,处理音频的CPU Z80;PGM部分游戏会有ARM CPU。通常情况下用maincpu。

p这个位置表示写入类型。
p=程序写入(写入RAM)
m=区域写入(写入ROM)
r=RAM写入(适用于p或m无法运作时)
o=操作码写入(适用于r或m无法动作时,常用于加密的内存 )
d=数据写入
i=i/o写入
3=SPACE3写入

通常情况下用p。

b这个位置表示值的大小。
b=字节,8位
w=字,16位
d=双字,32位
q=四字,64位
最后编辑leoxxx 最后编辑于 2026-05-04 19:21:00
分享 转发
TOP
2#

dat文件的cheat。126及之前的版本可用。
cheat126.7z (, 下载次数:1)
TOP
3#

其实更习惯做ips
TOP
4#

https://github.com/libretro/mame ... /master/src/cheat.c
.dat的cheat格式规范
  1. /******    Cheat File Specification **********************************************

  2. Type Field:

  3. MSB                                 LSB
  4. 33222222 22221111 11111100 00000000
  5. 10987654 32109876 54321098 76543210

  6.                                     [ type ]
  7. -------- -------- -------- -------x        one-shot cheat
  8. -------- -------- -------- -----xx-        type
  9.                                             00 =    normal/delay
  10.                                             01 =    wait for modification
  11.                                             10 =    ignore if decrementing
  12.                                             11 =    watch
  13. -------- -------- -------- ---xx---        operation (combined    with operation
  14.                                         extend bit)
  15.                                             [extend    = 0]
  16.                                                 00 =    write with mask
  17.                                                 01 =    add/subtract
  18.                                                 10 =    force range
  19.                                                 11 =    set/clear bits (for
  20.                                                         relative address mode)
  21.                                             [extend    = 1]
  22.                                                 00 =    unused
  23.                                                 01 =    unused
  24.                                                 10 =    unused
  25.                                                 11 =    nothing
  26. -------- -------- -------- xxx-----        parameter
  27.                                             type ==    00    delay in seconds
  28.                                                         between    operations
  29.                                             type ==    01    delay after
  30.                                                         modification before
  31.                                                         operation in seconds
  32.                                             type ==    10    decrement ignore value
  33.                                             type ==    11    watch options
  34.                                                             display format
  35.                                                 -00 =    hex
  36.                                                 -01 =    decimal
  37.                                                 -10 =    binary
  38.                                                 -11 =    ascii
  39.                                                             show label
  40.                                                 0-- =    no
  41.                                                 1-- =    yes, copy from comment
  42.                                     [ user-selected    value ]
  43. -------- -------- -------x --------        enable
  44. -------- -------- ------x- --------        displayed value
  45.                                             0 =    value
  46.                                             1 =    value + 1
  47. -------- -------- -----x-- --------        minimum    value
  48.                                             0 =    0
  49.                                             1 =    1
  50. -------- -------- ----x--- --------        BCD
  51.                                     [ prefill ]
  52. -------- -------- --xx---- --------        value/enable
  53.                                             00 =    disable
  54.                                             01 =    prefill    with 0xFF
  55.                                             10 =    prefill    with 0x00
  56.                                             11 =    prefill    with 0x01
  57.                                     [ link / options ]
  58. -------- -------- -x------ --------        don't add to list (used for commands)
  59. -------- -------- x------- --------        add as extend for previous cheat
  60. -------- -------x -------- --------        enable
  61. -------- ------x- -------- --------        copy previous value
  62. -------- -----x-- -------- --------        operation parameter
  63.                                             operation == 001    add/subtract
  64.                                                 0 =    add
  65.                                                 1 =    subtract
  66.                                             operation == 011    set/clear
  67.                                                 0 = set
  68.                                                 1 = clear
  69. -------- ----x--- -------- --------        operation extend bit
  70. -------- --xx---- -------- --------        bytes used
  71.                                             00 =    1
  72.                                             01 =    2
  73.                                             10 =    3
  74.                                             11 =    4
  75. -------- -x------ -------- --------        endianness
  76.                                             locations associated with a
  77.                                             processor
  78.                                                 0 =        same endianness    as
  79.                                                         target processor
  80.                                                 1 =        different endianness
  81.                                             generic    locations
  82.                                                 0 =        big    endian
  83.                                                 1 =        little endian
  84. -------- x------- -------- --------        restore previous value on disable
  85.                                     [ location / effective address ]
  86. ---xxxxx -------- -------- --------        parameter
  87.                                             type ==    000    CPU    index
  88.                                             type ==    001    region offset
  89.                                                         (REGION_xxx)
  90.                                             type ==    010    CPU    index
  91.                                             type ==    011    custom cheat type
  92.                                                 00000        comment
  93.                                                 00001        EEPROM
  94.                                                 00010        select
  95.                                                 00011        assign activation key
  96.                                                 00100        enable
  97.                                                 00101        overclock
  98.                                                 ...            others?
  99.                                             type ==    100    address    size, CPU
  100.                                                 ---00        8 bit
  101.                                                 ---01        16 bit
  102.                                                 ---10        24 bit
  103.                                                 ---11        32 bit
  104.                                                 xxx--        cpu
  105. xxx----- -------- -------- --------        type
  106.                                             000    =    standard memory    write
  107.                                             001    =    memory region
  108.                                             010    =    write handler mapped memory
  109.                                             011    =    custom
  110.                                             100    =    relative address (CPU)
  111.                                             101    =    cheatscript
  112.                                             110    =    unused
  113.                                             111    =    unused

  114. Conversion Table:

  115. MSB                                LSB
  116. 33222222 22221111 11111100 0000    0000
  117. 10987654 32109876 54321098 7654    3210
  118. 000xxxxx 00000000 00000000 0000    0000    000
  119. 000xxxxx 00000000 00000000 0000    0001    001
  120. 000xxxxx 00000000 00000000 0010    0000    002
  121. 000xxxxx 00000000 00000000 0100    0000    003
  122. 000xxxxx 00000000 00000000 1010    0000    004
  123. 000xxxxx 00000000 00000000 0010    0010    005
  124. 000xxxxx 00000000 00000000 0100    0010    006
  125. 000xxxxx 00000000 00000000 1010    0010    007
  126. 000xxxxx 00000000 00000000 0010    0100    008
  127. 000xxxxx 00000000 00000000 0100    0100    009
  128. 000xxxxx 00000000 00000000 0110    0100    010
  129. 000xxxxx 00000000 00000000 1000    0100    011
  130. 000xxxxx 00000000 00000000 0010    0011    015
  131. 000xxxxx 00000000 00000000 0100    0011    016
  132. 000xxxxx 00000000 00000000 1010    0011    017
  133. 000xxxxx 00000000 00000000 0000    0000    020    (mask used)
  134. 000xxxxx 00000000 00000000 0000    0001    021    (mask used)
  135. 000xxxxx 00000000 00000000 0010    0000    022    (mask used)
  136. 000xxxxx 00000000 00000000 0100    0000    023    (mask used)
  137. 000xxxxx 00000000 00000000 1010    0000    024    (mask used)
  138. 000xxxxx 00000000 00000000 0000    0000    040    (mask used)
  139. 000xxxxx 00000000 00000000 0000    0001    041    (mask used)
  140. 000xxxxx 00000000 00000000 0010    0000    042    (mask used)
  141. 000xxxxx 00000000 00000000 0100    0000    043    (mask used)
  142. 000xxxxx 00000000 00000000 1010    0000    044    (mask used)
  143. 000xxxxx 00000000 00000001 0000    0011    060
  144. 000xxxxx 00000000 00000011 0000    0011    061
  145. 000xxxxx 00000000 00000101 0000    0011    062
  146. 000xxxxx 00000000 00001001 0000    0011    063
  147. 000xxxxx 00000000 00001011 0000    0011    064
  148. 000xxxxx 00000000 00001101 0000    0011    065
  149. 000xxxxx 00000000 00000001 0000    0001    070
  150. 000xxxxx 00000000 00000011 0000    0001    071
  151. 000xxxxx 00000000 00000101 0000    0001    072
  152. 000xxxxx 00000000 00001001 0000    0001    073
  153. 000xxxxx 00000000 00001011 0000    0001    074
  154. 000xxxxx 00000000 00001101 0000    0001    075
  155. 000xxxxx 00000000 00000000 0000    0011    080
  156. 000xxxxx 00000000 00000010 0000    0011    081
  157. 000xxxxx 00000000 00000100 0000    0011    082
  158. 000xxxxx 00000000 00001000 0000    0011    083
  159. 000xxxxx 00000000 00001010 0000    0011    084
  160. 000xxxxx 00000000 00001100 0000    0011    085
  161. 000xxxxx 00000000 00000000 0000    0001    090
  162. 000xxxxx 00000000 00000010 0000    0001    091
  163. 000xxxxx 00000000 00000100 0000    0001    092
  164. 000xxxxx 00000000 00001000 0000    0001    093
  165. 000xxxxx 00000000 00001010 0000    0001    094
  166. 000xxxxx 00000000 00001100 0000    0001    095
  167. 001xxxxx 10000000 00000000 0000    0000    100
  168. 001xxxxx 00000000 00000000 0000    0001    101
  169. 001xxxxx 10000000 00000000 0000    0000    102
  170. 001xxxxx 00000000 00000000 0000    0001    103
  171. 010xxxxx 10000000 00000000 0000    0000    110
  172. 010xxxxx 00000000 00000000 0000    0001    111
  173. 010xxxxx 10000000 00000000 0000    0000    112
  174. 010xxxxx 00000000 00000000 0000    0001    113
  175. 01100011 00000000 00000000 0000 0001    120
  176. 01100011 00000000 00000000 0000 0001    121 (mask used)
  177. 01100011 00000000 00000000 0000 0001    122 (mask used)
  178. 00000000 00000001 00000000 0000    0000    5xx
  179. 000xxxxx 00000000 00000000 0000    0110    998
  180. 01100000 00000000 00000000 0000    0000    999

  181. Cheat Format:

  182. :[ drivername ]:[ type ]:[ address ]:[ data ]:[ extended data ]:[ name ]:[ description ]


  183. drivername        string    maximum    8 chars
  184. type            hex        32 bits
  185. address            hex        32 bits
  186. data            hex        32 bits
  187. extended data    hex        32 bits
  188. name            string    maximum    255    chars
  189. description        string    maximum    255    chars

  190. Extended Data Field:

  191. [ force    range ]

  192. 0xAABB

  193. AA = minimum value accepted
  194. BB = maximum value accepted

  195. [ add/subtract ]

  196. The    field will store either    the    minimum    or maximum boundary    for    modification,
  197. depending on the operation parameter.

  198. [ write    with mask ]

  199. The    field will store a mask    containing which bits are modified by the
  200. operation. For normal operation, set the mask to 0xFFFFFFFF.
  201. Example    code: data = (data & ~mask)    | (input & mask);

  202. Copy Previous Value:

  203. If this    field is true, the value for this cheat    is determined by taking    the
  204. value read from    the    previous cheat and adding the value    stored in the data
  205. field.

  206. Relative Address:

  207. The    extend data    field will store the the signed    offset to be applied to    the
  208. address    read. Because of this, any operation using the extend data field may
  209. have interesting results. Use the special set/clear bits operations instead of
  210. a masked write.

  211. Select Cheat Type: (01100010 -------0 -------- --------) 0x62000000

  212. May    be used    only as    the    first cheat    of a linked    cheat. In the "Enable/Disable
  213. Cheat" menu, instead of    simple listing On/Off or Set as    the    menu option, the
  214. engine will    list the name fields of    each of    the    subcheats. If the current
  215. selected subcheat is a one-shot    cheat, pressing    Enter will activate    the
  216. currently subcheat.    If the subcheat    is an on/off cheat,    the    currently selected
  217. subcheat (and only that    subcheat) will be activated.

  218. Assign Activation Key: (01100011 -------- -1------ --------) 0x63004000

  219. Assigns an activation key to a cheat. Put the index of the cheat you want to
  220. modify in the address field, then put the key index in the data field.

  221. Example: to set the second cheat in the cheat list to activate when "Q" is
  222. pressed, add this cheat to the file.

  223. :gamename:63004000:00000001:00000010:00000000:

  224. Key Index List:

  225.     A        00    Q        10    6        20    F3        30    [        40    PGDN    50    RCTRL    60
  226.     B        01    R        11    7        21    F4        31    ]        41    LEFT    51    LALT    61
  227.     C        02    S        12    8        22    F5        32    ENTER    42    RIGHT    52    RALT    62
  228.     D        03    T        13    9        23    F6        33    :        43    UP        53    SCRLOCK    63
  229.     E        04    U        14    [0]        24    F7        34    '        44    DOWN    54    NUMLOCK    64
  230.     F        05    V        15    [1]        25    F8        35    \        45    [/]        55    CAPSLCK    65
  231.     G        06    W        16    [2]        26    F9        36    \        46    [*]        56    LWIN    66
  232.     H        07    X        17    [3]        27    F10        37    ,        47    [-]        57    RWIN    67
  233.     I        08    Y        18    [4]        28    F11        38    .        48    [+]        58    MENU    68
  234.     J        09    Z        19    [5]        29    F12        39    /        49    [DEL]    59
  235.     K        0A    0        1A    [6]        2A    ESC        3A    SPACE    4A    [ENTER]    5A
  236.     L        0B    1        1B    [7]        2B    ~        3B    INS        4B    PRTSCR    5B
  237.     M        0C    2        1C    [8]        2C    -        3C    DEL        4C    PAUSE    5C
  238.     N        0D    3        1D    [9]        2D    =        3D    HOME    4D    LSHIFT    5D
  239.     O        0E    4        1E    F1        2E    BACKSP    3E    END        4E    RSHIFT    5E
  240.     P        0F    5        1F    F2        2F    TAB        3F    PGUP    4F    LCTRL    5F

  241. Pre-Enable: (01100100 -------- -1------ --------) 0x64004000

  242. Enables a cheat on startup. Put the index of the cheat you want to enable in
  243. the address field.

  244. Example: to activate the eleventh cheat in the cheat list, add this cheat to
  245. the file:

  246. :gamename:64004000:0000000A:00000000:00000000:

  247. Overclock: (01100101 -------- -1------ --------) 0x65004000

  248. Overclocks a CPU. Put the CPU index you want in the address field, and the
  249. overclocking amount in the data field. Use 16.16 fixed point notation for
  250. the overclocking amount.

  251. Example 1: overclocking CPU #0 by 200%

  252. :gamename:65004000:00000000:00020000:00000000:

  253. Example 2: overclocking CPU #3 by 125%

  254. :gamename:65004000:00000003:00014000:00000000:

  255. To convert a percent to 16.16 fixed point notation, take the percentage as a
  256. decimal value (eg. 65% = .65) and multiply it by 65536. Then, convert the value
  257. to hex.

  258. Cheat Engine Commands:

  259. These special cheat lines are used to set global preferences for the cheat engine. They follow
  260. this format:

  261. :_command:[ data ]

  262. The lower byte of the data field stores the command, and the remaining bytes store data
  263. for the command. Here is a list of the commands:

  264. 0x00    disable help boxes (once I add them)
  265. 0x01    use old-style cheat search box (now redundant)
  266. 0x02    use new-style cheat search box
  267. 0x03    don't print labels in new-style search menu
  268. 0x04    auto-save cheats on exit

  269. So, if you wanted to use the old-style cheat box, you would add this line to your cheat.dat:

  270. :_command:00000001

  271. Watches:

  272. You can specify options for watches using the data field. Specify fields like this:

  273. MSB                                LSB
  274. 33222222 22221111 11111100 00000000
  275. 10987654 32109876 54321098 76543210
  276. -------- -------- -------- xxxxxxxx        number of elements - 1
  277. -------- -------- xxxxxxxx --------        bytes to skip after each element
  278. -------- xxxxxxxx -------- --------        elements per line
  279.                                             0 = all on one line
  280. xxxxxxxx -------- -------- --------        signed value to add

  281. So, to make a watch on CPU1 address 0064407F with six elements, skipping three bytes after each element,
  282. showing two elements per line, you would do this:

  283. :gamename:00000006:0064407F:00020305:00000000:

  284. The extend data field is used to position the watch display.

  285. MSB                              LSB
  286. 3322222222221111 1111110000000000
  287. 1098765432109876 5432109876543210
  288. xxxxxxxxxxxxxxxx ----------------    x pixel offset
  289. ---------------- xxxxxxxxxxxxxxxx    y pixel offset

  290. Notes:

  291. - if you want to have a    list of    many on/off    subcheats, include a "None"    option,
  292. or there will be no    way    to disable the cheat
  293. - the engine will display "Press Enter to Activate Cheat" if a one-shot    cheat
  294. is selected

  295. *******************************************************************************/
复制代码
cheat.7z (, 下载次数:1)
最后编辑leoxxx 最后编辑于 2026-05-04 16:15:39
TOP
5#

; [ 中国龙 东方之珠(香港版) ]
:rgnwrldv11h:00000000:100B3D:00000000:FFFFFFFF:过关
:[rom名]:[类型]:[地址 ]:[值]:[掩码]:[作用描述]

类型是4段二进制值组合而成的,但写CHEAT时要转换成16进制值。

未使用或其它未明确定定义的功能不在此列出。

第一段,前三位
000=标准内存写入=XML版的p(程序写入RAM)
001=内存区域=XML版的m(域区写入ROM)
010=写入映射内存的处理程序
011=自定义。与后五位一并使用效果。
00000=评论
00001=EEPROM
00010=选择
00011=设置激活键
00100=启用
00101=超频

100=相对地址(CPU)。与后五位一并使用效果。
---00=8位
---01=16位
---10=24位
---11=32位
xxx--=cpu
101=作弊脚本
最后编辑leoxxx 最后编辑于 2026-05-04 19:55:18
TOP
发新话题 回复该主题