How can I convert old cheat format?

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
Dark Helmet
Posts: 8
Joined: Wed Jun 01, 2005 3:14 pm
Contact:

How can I convert old cheat format?

Post by Dark Helmet »

Hi all :) I have a little stupid question. Why in some cheat file of Ultimate patchers the lines start with a colon? For example:

Code: Select all

:apparel:00000001:F406:00000031:FFFFFFFF:1UP Winning hand    (01/14-T)
Thank you in advance.
Last edited by Dark Helmet on Thu Oct 06, 2005 7:52 pm, edited 1 time in total.
User avatar
ianpatt
Posts: 336
Joined: Sat Sep 22, 2001 1:00 am
Location: San Francisco, CA

Post by ianpatt »

Starting a cheat line with a colon makes that cheat use the new format, which is more flexible but also takes more space.
Dark Helmet
Posts: 8
Joined: Wed Jun 01, 2005 3:14 pm
Contact:

Post by Dark Helmet »

How is the conversion between new and old format?
Dark Helmet
Posts: 8
Joined: Wed Jun 01, 2005 3:14 pm
Contact:

Post by Dark Helmet »

Excuse me the double post, but I want to do a little program that updates cheat.dat automatically... I must know how to convert old cheat format. Can you give me a link to an help, an old discussion, everythink?
User avatar
Pugsy
Posts: 3689
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Post by Pugsy »

I have a program to convert from old type to new type, but AFAIK it was never released publically. To convert old type to new type is fairly straight forward anyway (just look at the structure in the cheat.c file or the cheat.dat file). The question is why bother the old cheat format still works in the new cheat engine and keeping old-type cheats as is allows some backward compatability with older MAME builds and will keep the cheat file smaller too.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
Dark Helmet
Posts: 8
Joined: Wed Jun 01, 2005 3:14 pm
Contact:

Post by Dark Helmet »

Well, I searched in cheat.c and I fouded this:
Conversion Table:

MSB LSB
33222222 22221111 11111100 0000 0000
10987654 32109876 54321098 7654 3210
000xxxxx 00000000 00000000 0000 0000 000
000xxxxx 00000000 00000000 0000 0001 001
000xxxxx 00000000 00000000 0010 0000 002
000xxxxx 00000000 00000000 0100 0000 003
000xxxxx 00000000 00000000 1010 0000 004
000xxxxx 00000000 00000000 0010 0010 005
000xxxxx 00000000 00000000 0100 0010 006
000xxxxx 00000000 00000000 1010 0010 007
000xxxxx 00000000 00000000 0010 0100 008
000xxxxx 00000000 00000000 0100 0100 009
000xxxxx 00000000 00000000 0110 0100 010
000xxxxx 00000000 00000000 1000 0100 011
000xxxxx 00000000 00000000 0010 0011 015
000xxxxx 00000000 00000000 0100 0011 016
000xxxxx 00000000 00000000 1010 0011 017
000xxxxx 00000000 00000000 0000 0000 020 (mask used)
000xxxxx 00000000 00000000 0000 0001 021 (mask used)
000xxxxx 00000000 00000000 0010 0000 022 (mask used)
000xxxxx 00000000 00000000 0100 0000 023 (mask used)
000xxxxx 00000000 00000000 1010 0000 024 (mask used)
000xxxxx 00000000 00000000 0000 0000 040 (mask used)
000xxxxx 00000000 00000000 0000 0001 041 (mask used)
000xxxxx 00000000 00000000 0010 0000 042 (mask used)
000xxxxx 00000000 00000000 0100 0000 043 (mask used)
000xxxxx 00000000 00000000 1010 0000 044 (mask used)
000xxxxx 00000000 00000001 0000 0011 060
000xxxxx 00000000 00000011 0000 0011 061
000xxxxx 00000000 00000101 0000 0011 062
000xxxxx 00000000 00001001 0000 0011 063
000xxxxx 00000000 00001011 0000 0011 064
000xxxxx 00000000 00001101 0000 0011 065
000xxxxx 00000000 00000001 0000 0001 070
000xxxxx 00000000 00000011 0000 0001 071
000xxxxx 00000000 00000101 0000 0001 072
000xxxxx 00000000 00001001 0000 0001 073
000xxxxx 00000000 00001011 0000 0001 074
000xxxxx 00000000 00001101 0000 0001 075
000xxxxx 00000000 00000000 0000 0011 080
000xxxxx 00000000 00000010 0000 0011 081
000xxxxx 00000000 00000100 0000 0011 082
000xxxxx 00000000 00001000 0000 0011 083
000xxxxx 00000000 00001010 0000 0011 084
000xxxxx 00000000 00001100 0000 0011 085
000xxxxx 00000000 00000000 0000 0001 090
000xxxxx 00000000 00000010 0000 0001 091
000xxxxx 00000000 00000100 0000 0001 092
000xxxxx 00000000 00001000 0000 0001 093
000xxxxx 00000000 00001010 0000 0001 094
000xxxxx 00000000 00001100 0000 0001 095
001xxxxx 10000000 00000000 0000 0000 100
001xxxxx 00000000 00000000 0000 0001 101
001xxxxx 10000000 00000000 0000 0000 102
001xxxxx 00000000 00000000 0000 0001 103
010xxxxx 10000000 00000000 0000 0000 110
010xxxxx 00000000 00000000 0000 0001 111
010xxxxx 10000000 00000000 0000 0000 112
010xxxxx 00000000 00000000 0000 0001 113
01100011 00000000 00000000 0000 0001 120
01100011 00000000 00000000 0000 0001 121 (mask used)
01100011 00000000 00000000 0000 0001 122 (mask used)
00000000 00000001 00000000 0000 0000 5xx
000xxxxx 00000000 00000000 0000 0110 998
01100000 00000000 00000000 0000 0000 999
I think the last three numbers is Cheat Type. But why the conversion table contains only zero and one? And what does means:
MSB LSB
33222222 22221111 11111100 0000 0000
10987654 32109876 54321098 7654 3210
?
User avatar
ianpatt
Posts: 336
Joined: Sat Sep 22, 2001 1:00 am
Location: San Francisco, CA

Post by ianpatt »

The conversion table lists the new type field as a bitfield. The header at the top is just a list of the bit indices; it's useful if you need to find a bit quickly without counting each one.

Take a look at ConvertOldCode in cheat.c; it's the internal function that's used to convert old-style cheats to the new format. Pass it the old cheat type in 'code', the target cpu in 'cpu', and it will write out the new cheat type field and extended data field in the ints pointed to by the 'data' and 'extendData' pointers.
Dark Helmet
Posts: 8
Joined: Wed Jun 01, 2005 3:14 pm
Contact:

Post by Dark Helmet »

ianpatt wrote:Take a look at ConvertOldCode in cheat.c; it's the internal function that's used to convert old-style cheats to the new format. Pass it the old cheat type in 'code', the target cpu in 'cpu', and it will write out the new cheat type field and extended data field in the ints pointed to by the 'data' and 'extendData' pointers.
Very well :D But the address field? Does it not change from the old to the new format?
User avatar
ianpatt
Posts: 336
Joined: Sat Sep 22, 2001 1:00 am
Location: San Francisco, CA

Post by ianpatt »

Those are the only fields that are changed. Take a look at LoadCheatFile and how ConvertOldCode is called.
Dark Helmet
Posts: 8
Joined: Wed Jun 01, 2005 3:14 pm
Contact:

Post by Dark Helmet »

Thank you very much :D
Post Reply