It is currently Mon Oct 16, 2017 9:10 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: CHT Cheat File Format
PostPosted: Tue Jul 19, 2016 8:38 am 
Offline
User avatar

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


Top
 Profile  
 
PostPosted: Tue Jul 19, 2016 10:48 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6273
Location: Seattle
I think that the CHT file format is FCEUX-specific, so the only documentation is probably FCEUX's source...


Top
 Profile  
 
PostPosted: Tue Jul 19, 2016 10:58 am 
Offline
User avatar

Joined: Mon Oct 01, 2012 3:47 pm
Posts: 152
Location: freemland (NTSC-U)
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.


Top
 Profile  
 
PostPosted: Tue Jul 19, 2016 11:03 am 
Offline
User avatar

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


Top
 Profile  
 
PostPosted: Wed Jul 20, 2016 8:08 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3940
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!


Top
 Profile  
 
PostPosted: Wed Jul 20, 2016 8:17 am 
Offline
User avatar

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group