CHT Cheat File Format

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
colinvella
Posts: 74
Joined: Sun Jun 05, 2016 1:41 pm

CHT Cheat File Format

Post by colinvella »

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?

Thanks
Tile IDE and tile engine for XNA: http://tide.codeplex.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: CHT Cheat File Format

Post by lidnariq »

I think that the CHT file format is FCEUX-specific, so the only documentation is probably FCEUX's source...
User avatar
freem
Posts: 176
Joined: Mon Oct 01, 2012 3:47 pm
Location: freemland (NTSC-U)
Contact:

Re: CHT Cheat File Format

Post by freem »

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.
User avatar
colinvella
Posts: 74
Joined: Sun Jun 05, 2016 1:41 pm

Re: CHT Cheat File Format

Post by colinvella »

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

I found this in the FCEUX online help:

Code: Select all

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

Example:

   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: http://tuxnes.sourceforge.net/gamegenie.html. 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.
Tile IDE and tile engine for XNA: http://tide.codeplex.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: CHT Cheat File Format

Post by Dwedit »

Nesticle used the old .PAT file format for storing game genie codes.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
colinvella
Posts: 74
Joined: Sun Jun 05, 2016 1:41 pm

Re: CHT Cheat File Format

Post by colinvella »

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 :)
Tile IDE and tile engine for XNA: http://tide.codeplex.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/
Post Reply