CHT Cheat File Format
Page 1 of 1

Author:  colinvella [ Tue Jul 19, 2016 8:38 am ]
Post subject:  CHT Cheat File Format

As I'm planning to add cheat support to my emulator, I'm trying to make sense of the .CHT cheat file format and it seems quite straightforward.

It is essentially a text file where each line takes the form <prefix>:<address>:<value>:<comment>
Each line forces the byte value <value> at the given <address>.
The <comment> is there for explanatory reasons

The one pending mystery is the meaning of <prefix>. I've seen values "S" and "SC" for this. I suspect that the "SC" type codes are applied in the cartridge data while the "S" type applies to RAM.

Am I on the right track?


Author:  lidnariq [ Tue Jul 19, 2016 10:48 am ]
Post subject:  Re: CHT Cheat File Format

I think that the CHT file format is FCEUX-specific, so the only documentation is probably FCEUX's source...

Author:  freem [ Tue Jul 19, 2016 10:58 am ]
Post subject:  Re: CHT Cheat File Format

After having a look at FCEUX's cheat.cpp:

"S" sets type = 1. Next to the type value in the CHEATF struct is this comment: /* 0 for replace, 1 for substitute(GG). */

"C" sets doc = 1. I'm still not fully sure what this does, but the code regarding this value is around lines 246-263 of cheat.cpp.
If I had to guess, it would signify the presence of a compare byte (e.g. like the ones found in 8-letter Game Genie codes).

Hope this helps.

Author:  colinvella [ Tue Jul 19, 2016 11:03 am ]
Post subject:  Re: CHT Cheat File Format

Thanks for the pointers. I thouhgh the .CHT file was a semi-standard format of sorts.

I found this in the FCEUX online help:
Cheat Files

By default cheat files (.cht) are stored in the "cheats" subdirectory under the base FCEUX. The files are in a simple plain-text format. Each line represents a one-byte memory patch. The format is as follows(text in brackets [] represents optional parameters):

   [S][C][:]Address(hex):Value(hex):[Compare value:]Description


   040e:05:Infinite super power.

A colon(:) near the beginning of the line is used to disable the cheat. "S" denotes a cheat that is a read-substitute-style cheat(such as with Game Genie cheats), and a "C" denotes that the cheat has a compare value.

I was also curious on what was intended by the compare value. It is essentially a system to ensure that the value is overridden only when the right PRG bank is in place. The mechanism isn't foolproof, because potentially multiple banks might have he same value at the same cheat location, albeit unlikely. This is why the "SC" prefix is used. The "S" prefix on the other han, just seems to return the specified cheat value without comparing anything.

I found the compare value details here: Incidentally this also covers game genie codes, which are 6 or 8 alphabet strings that respectively encode address-value and address-value-compare cheats. I will definitely look into supporting them.

Author:  Dwedit [ Wed Jul 20, 2016 8:08 am ]
Post subject:  Re: CHT Cheat File Format

Nesticle used the old .PAT file format for storing game genie codes.

Author:  colinvella [ Wed Jul 20, 2016 8:17 am ]
Post subject:  Re: CHT Cheat File Format

Dwedit wrote:
Nesticle used the old .PAT file format for storing game genie codes.

I was thinking that since GameGenie codes get decoded to the equivalent of the .CHT S and SC type cheats, I could provide an option to enter them via a simple 1-field prompt. It might also be nice to add support for loading .PAT files directly if the filename matches the ROM. I'll look into that eventually :)

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group