Splitting up cheat.dat

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
benrg
Posts: 2
Joined: Sun Feb 18, 2007 10:13 pm

Splitting up cheat.dat

Post by benrg »

I love everything about Pugsy's cheat.dat except that it's so large that it adds a couple of seconds to the load time of every game when cheats are turned on.

To fix this I hacked MAME to support a cheat directory (default "cheats") for per-game cheat files. The files have the same format as cheat.dat except that they're named {gamename}.cht. Because of MAME's transparent zip-folder support, you can also put some or all of the files into a single zip file called cheats.zip. So I wrote a Perl script to split up cheat.dat, zipped up all the files, and now the cheats load pretty much instantaneously, which is very nice. As an added bonus cheats.zip is about a quarter the size of cheat.dat, not that that matters much in these days of 30MB executables.

The patch is simple and I think the MAMEdevs would likely accept it, but there's no point submitting it unless Pugsy is interested in moving to this format. So I'm posting here to find out if there's any interest.
User avatar
Gaius_4
Posts: 138
Joined: Sun Oct 26, 2003 2:27 pm

Post by Gaius_4 »

I had the thought for some/all games that don't have cheats or aren't working to say

a crude example..

:gamename:000000:000000:000000:No cheats available

Instead of the 5, 6, or 7 lines that is typically used. Or just anything that shorter and to the point.

In the hazemd cheat file I occasionally change other lines for games that have no cheats to

:gamename:000000:000000:000000:---

I've done this to a bunch. I usually keep doing it till I get bored, so there's a bunch more to do. :wink:
As always, your patients is appreciated. :cool:
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: Splitting up cheat.dat

Post by Pugsy »

Thanks for the offer but I much prefer cheat.dat as a single file (it's smaller now than it used to be BTW). This split up of the cheat file has been suggested before and infact somebody a few years back added gz support off their own back for the cheat file which was thankfully quickly removed. Some other arcade emulators already support single game cheat files and I believe the results speak for themselves - MAME has got it just about perfect with the single file method.

There's a couple of serious issues which would not help me or other mame cheat file maintainers come to that:

1. It's easier to maintain a single file rather than a bunch of files - 1 file or 6500 files which although the end user could have them all zipped I'd have to have unzipped - so even directory display would be slow. To be honest it would become a complete nightmare to try and maintain such a beast, a single file makes it easy to quickly fix/edit a load of games with relatively little work.

2. I have a few tools that I use with the cheat file and they would not be suitable for conversion as it uses the fact that all the cheats are in a single file.

3. A zipped cheat.dat is about 1300K give or take a few 100K, individual zipped game cheats for 6500 games would be close to 3000K (2.5 times the size). This could seriously effect the server as suddenly the cheat page bandwidth would effectively double - I know I could get round this by double zipping or zipping in another archive format, but that's just a workaround which would cause people to complain or question why the cheat file no longer works.
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)
benrg
Posts: 2
Joined: Sun Feb 18, 2007 10:13 pm

Re: Splitting up cheat.dat

Post by benrg »

Pugsy wrote:This split up of the cheat file has been suggested before and infact somebody a few years back added gz support off their own back for the cheat file which was thankfully quickly removed. Some other arcade emulators already support single game cheat files and I believe the results speak for themselves - MAME has got it just about perfect with the single file method.
Well, perverse though it may be, I'm going to take another stab at convincing you...
1. It's easier to maintain a single file rather than a bunch of files - 1 file or 6500 files which although the end user could have them all zipped I'd have to have unzipped - so even directory display would be slow. To be honest it would become a complete nightmare to try and maintain such a beast, a single file makes it easy to quickly fix/edit a load of games with relatively little work.
The solution here is simple: continue to maintain the file as you always have, and convert to zip format only for distribution. My patch doesn't eliminate support for global cheat files, it just combines cheats found in per-game files with cheats found in global files. If you never use per-game cheat files then things work exactly as before. I'm more than happy to write a turnkey conversion tool if that's what'll change your mind.

You might ask why, in that case, people can't just download your cheat.dat and do the conversion at their end. And, well, you'd have a point. It's just that if cheats aren't actually distributed in this form then it's harder to make the case for supporting it in MAME at all, and I want it to be supported because I want to use it. Plus I think it would be useful to other people. It's a better format for the great majority of end users, though probably most of them don't care that much one way or the other.
3. A zipped cheat.dat is about 1300K give or take a few 100K, individual zipped game cheats for 6500 games would be close to 3000K (2.5 times the size). This could seriously effect the server as suddenly the cheat page bandwidth would effectively double - I know I could get round this by double zipping or zipping in another archive format, but that's just a workaround which would cause people to complain or question why the cheat file no longer works.
This occurred to me, and it seems as though double zipping would solve the problem while being pretty much idiot-proof. All the end users have to do is treat the nested cheats.zip exactly as they currently treat cheat.dat. I'm sure some of them would mistakenly unzip it, but that's not a problem as it would work that way too.
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: Splitting up cheat.dat

Post by Pugsy »

benrg wrote:Well, perverse though it may be, I'm going to take another stab at convincing you...

Still a resounding NO from me I'm afraid. Such a massive change and extra-work for me (even a 'turnkey' solution which I already effectively have does not help). At the end of the day you are suggesting a method that will cost me time when all it's going to do is perhaps save a second or two at load time and if anything puts another wall between a cheat user becoming a cheat finder...the ability to browse the cheat file in a text editor is a big plus.

Another thing is that such a change would adversely effect the ability of the cheat engine to parse more than one cheat file and I'm sure that pre-enabled, and pre-assigned cheats would either not work or be a LOT more tiresome to setup.

I can see a a lot of minus points for the change and only one small plus of perhaps a few seconds saving at MAME startup...sorry it's a no-brainer.
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