.cht file structure?

General area for talk about ZSNES. The best place to ask for related questions as well as troubleshooting.

Moderator: ZSNES Mods

CheatZILLA
New Member
Posts: 6
Joined: Tue Mar 14, 2006 2:50 am

.cht file structure?

Post by CheatZILLA »

I run CheatZILLA.com and thought it might be cool to add an automatic ZSNES .cht file generator. I've searched a bit and can't find any docs on the format, anyone know?
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Try this:
http://board.zsnes.com/phpBB2/viewtopic ... 99&start=0

Do a search of cht and you'll probably find what you need.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
franpa
Gecko snack
Posts: 2374
Joined: Sun Aug 21, 2005 11:06 am
Location: Australia, QLD
Contact:

Post by franpa »

a automatic ZSNES .cht file generator would be godlike... please make such a program. :D
Core i7 920 @ 2.66GHZ | ASUS P6T Motherboard | 8GB DDR3 1600 RAM | Gigabyte Geforce 760 4GB | Windows 10 Pro x64
byuu

Post by byuu »

If I contribute c++ source code (won't work with pure c due to classes), would someone be willing to add my cheat system into ZSNES?

Basically, it does the obvious. It converts to and from GG and PAR (GF can be added easy enough), loads .cht info from text files and saves it back (.cht files are stored in plaintext and allow for large descriptions, library avoids buffer overflows), has a straightforward API for adding, removing, enabling and disabling codes to the internal list of codes for said game (remove resorts list rather than using a linked list to optimize real-time play speed over code add/remove speed), uses a bit-mask table (2mb of RAM needed, but fastest possible) to test whether a given address has an active code associated with it, and has a simple boolean function you can call to see if any codes are currently enabled to speed up games when no codes are active. Loading and saving of cht files preserves format of code (GG or PAL).

I'm also going to be adding support for a cheat.db file. This is going to be a huge list of contributed codes for at least the most popular games, stored by checksum. Not going to go too overboard, probably a limit of say the best ~32 codes for each game. In text-format so everyone can work with it. With a quick lookup tool so you can pass it the crc32 of the currently loaded game and automatically import all codes in the database for said game (with a default of disabled). Save's people some time looking up codes online all the time. It'll also probably support saving your current game codes into the database, but that might make keeping an official version number for the file difficult. Who knows.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Well, we'd probably use a PSR based cheat system if we ever overhauled it.
We do need to overhaul it, but other things are more pressing at the moment.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
CheatZILLA
New Member
Posts: 6
Joined: Tue Mar 14, 2006 2:50 am

Post by CheatZILLA »

Deathlike2 wrote:Try this:
http://board.zsnes.com/phpBB2/viewtopic ... 99&start=0

Do a search of cht and you'll probably find what you need.
Yah I saw that thread before asking. I couldn't really understand the crazy irc scripting language. Isn't there a small C snippet or a struct or something defined?
CheatZILLA
New Member
Posts: 6
Joined: Tue Mar 14, 2006 2:50 am

It is done

Post by CheatZILLA »

Ok I skimmed over the other thread some more and was able to make sense of the Perl stuff after comparing to a hex dump of a CHT file I made myself. I notice that in the CHT file it saves the "PV" or Previous Value that was in the location, is this important? For now I am stuffing a 0x00 in that spot and ZSNES seems happy enough.

So now you can go to http://www.cheatzilla.com/ and search for an SNES game, and if it has binary codes, not only can you convert from GG to PAR to GF, right under the button to do that is a link that says "Download as ZSNES .cht file".

Enjoy!
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Re: It is done

Post by creaothceann »

CheatZILLA wrote:I notice that in the CHT file it saves the "PV" or Previous Value that was in the location, is this important?
Probably only if the cheat had been created in ZSNES.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
Ichinisan
Veteran
Posts: 603
Joined: Wed Jul 28, 2004 8:54 am

Re: It is done

Post by Ichinisan »

creaothceann wrote:
CheatZILLA wrote:I notice that in the CHT file it saves the "PV" or Previous Value that was in the location, is this important?
Probably only if the cheat had been created in ZSNES.
This is the value at the time when the code was enabled. When you disable the code, the original/previous value is placed at the address. This can be annoying sometimes...I wish there was a way to disable it. The best I can do is re-add a code while it is already enabled with the value you want to be the new PV, then delete the original without toggling off.
jdratlif
Regular
Posts: 317
Joined: Tue Sep 14, 2004 12:48 am
Location: In a small padded white room
Contact:

Re: It is done

Post by jdratlif »

CheatZILLA wrote:Ok I skimmed over the other thread some more and was able to make sense of the Perl stuff after comparing to a hex dump of a CHT file I made myself. I notice that in the CHT file it saves the "PV" or Previous Value that was in the location, is this important? For now I am stuffing a 0x00 in that spot and ZSNES seems happy enough.

So now you can go to http://www.cheatzilla.com/ and search for an SNES game, and if it has binary codes, not only can you convert from GG to PAR to GF, right under the button to do that is a link that says "Download as ZSNES .cht file".

Enjoy!
I thought about doing one of these several months ago, but with the cht files being limited to names of 18 characters, a lot of cheat code names became useless. I wasn't sure it was really worth completing, so I didn't.

If people don't find the 18 character name thing limiting in this fashion, maybe I'll resume my work converting gscentral.org's codes to CHT files. http://games.technoplaza.net/temp/18charlimit.txt [CheatZilla's Page] is an example of what I'm talking about.

I made a CSV->CHT program for a guy who asked for it. It's on my website http://games.technoplaza.net/csv2cht/. You can convert comma seperated values of PAR codes and turn them into CHT codes. It's not as useful as a cheat site -> CHT converter, but it's what he asked for.

It should be ZSNES/Snes9x .cht file as Snes9x uses the same format for their cheat files.
Last edited by jdratlif on Thu Mar 23, 2006 9:22 pm, edited 1 time in total.
http://jdrrant.blogspot.com/ - CODEpendent Blog
http://games.technoplaza.net/ - Emulation Goodies
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Re: It is done

Post by grinvader »

jdratlif wrote:It should be ZSNES/Snes9x .cht file as Snes9x uses the same format for their cheat files.
Does snes9x support zsnes' memory copy code feature ?
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
jdratlif
Regular
Posts: 317
Joined: Tue Sep 14, 2004 12:48 am
Location: In a small padded white room
Contact:

Re: It is done

Post by jdratlif »

grinvader wrote:
jdratlif wrote:It should be ZSNES/Snes9x .cht file as Snes9x uses the same format for their cheat files.
Does snes9x support zsnes' memory copy code feature ?
I'm not sure what you mean by that. Are you talking about the previous value byte?

I've never seen a CHT file that ZSNES could use that Snes9x couldn't, but maybe I've missed something. When I was learning the CHT file format, I referenced the Snes9x source because it was easier to read than the ZSNES source.
http://jdrrant.blogspot.com/ - CODEpendent Blog
http://games.technoplaza.net/ - Emulation Goodies
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

You can make a cheat in ZSNES which can make one memory location mirror another.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
KingHanco
Hazed
Posts: 79
Joined: Sun Feb 26, 2006 8:08 am

Post by KingHanco »

Thanks CheatZILLA.
"Zsnes is the best one there is." :)
CheatZILLA
New Member
Posts: 6
Joined: Tue Mar 14, 2006 2:50 am

Re: It is done

Post by CheatZILLA »

jdratlif wrote: It should be ZSNES/Snes9x .cht file as Snes9x uses the same format for their cheat files.
I tried to get SNES9x to do something with the CHT file but it doesn't seem to on the Mac. Dunno why the SNES9x is such a different animal but it is. I will go ahead and say ZSNES/SNES9x, but I know I'm going to be getting email from Mac SNES9xers going "How do I use the file I downloaded?"
CheatZILLA
New Member
Posts: 6
Joined: Tue Mar 14, 2006 2:50 am

Re: It is done

Post by CheatZILLA »

jdratlif wrote:I thought about doing one of these several months ago, but with the cht files being limited to names of 18 characters, a lot of cheat code names became useless. I wasn't sure it was really worth completing, so I didn't.
According to the stuff I looked at, the limit is 20 chars. But yes, it's still quite limiting. However, the automatic CHT generator seems to be extremely popular. I don't know how much the files are getting used, but they are definitely getting downloaded.
jdratlif
Regular
Posts: 317
Joined: Tue Sep 14, 2004 12:48 am
Location: In a small padded white room
Contact:

Post by jdratlif »

Nach wrote:You can make a cheat in ZSNES which can make one memory location mirror another.
Is this a new feature? How do you do this? I'm not seeing anything that looks like this in the cheat menu for the 2/17 WIP.
CheatZILLA wrote:
jdratlif wrote: It should be ZSNES/Snes9x .cht file as Snes9x uses the same format for their cheat files.
I tried to get SNES9x to do something with the CHT file but it doesn't seem to on the Mac. Dunno why the SNES9x is such a different animal but it is. I will go ahead and say ZSNES/SNES9x, but I know I'm going to be getting email from Mac SNES9xers going "How do I use the file I downloaded?"
I have never had this problem. Then again, I only tested with Snes9x for a short time. I prefer ZSNES over Snes9x, but the CHT files I tested worked with Snes9x. And as I said, when I created my CHT file decoder, I used the Snes9x source as a reference for the structure. I did most of my testing with ZSNES though.

I don't have a Mac to test Snes9x on though. Just the Windows version.
CheatZILLA wrote:
jdratlif wrote:I thought about doing one of these several months ago, but with the cht files being limited to names of 18 characters, a lot of cheat code names became useless. I wasn't sure it was really worth completing, so I didn't.
According to the stuff I looked at, the limit is 20 chars. But yes, it's still quite limiting. However, the automatic CHT generator seems to be extremely popular. I don't know how much the files are getting used, but they are definitely getting downloaded.
Well, I'm not sure. The ZSNES cheat entry stops as 18 characters. So that's where I pulled my limit from. Snes9x uses 19 characters. The 20th spot seems to be a terminator, though I'm not sure why one would be necessary in the record.

This is an except from the Snes9x sources where it saves the cheat data to a 28-byte CHT record.

Code: Select all

	memset (data, 0, 28);
	if (i == 0)
	{
	    data [6] = 254;
	    data [7] = 252;
	}
	if (!Cheat.c [i].enabled)
	    data [0] |= 4;

	if (Cheat.c [i].saved)
	    data [0] |= 8;

	data [1] = Cheat.c [i].byte;
	data [2] = (uint8) Cheat.c [i].address;
	data [3] = (uint8) (Cheat.c [i].address >> 8);
	data [4] = (uint8) (Cheat.c [i].address >> 16);
	data [5] = Cheat.c [i].saved_byte;

	memmove (&data [8], Cheat.c [i].name, 19);
So, Snes9x seems definitely limited to 19 characters. And ZSNES limits to 18 when you create codes in-program, and I'm assuming has the same limit on loading, though I don't have a code snippit to support that.

The Snes9x Mac source is identical to the main source on loading and saving CHT files, so I don't know why your cheat file wouldn't work with Snes9x mac version. Have you tried one with the Windows version?
http://jdrrant.blogspot.com/ - CODEpendent Blog
http://games.technoplaza.net/ - Emulation Goodies
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

jdratlif wrote:
Nach wrote:You can make a cheat in ZSNES which can make one memory location mirror another.
Is this a new feature? How do you do this? I'm not seeing anything that looks like this in the cheat menu for the 2/17 WIP.
It was added in .9xx IIRC. Read the docs.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
jdratlif
Regular
Posts: 317
Joined: Tue Sep 14, 2004 12:48 am
Location: In a small padded white room
Contact:

Post by jdratlif »

Nach wrote:
jdratlif wrote:
Nach wrote:You can make a cheat in ZSNES which can make one memory location mirror another.
Is this a new feature? How do you do this? I'm not seeing anything that looks like this in the cheat menu for the 2/17 WIP.
It was added in .9xx IIRC. Read the docs.
Sorry, it wasn't in the section on cheat codes. I see it now.
grinvader wrote:
jdratlif wrote:It should be ZSNES/Snes9x .cht file as Snes9x uses the same format for their cheat files.
Does snes9x support zsnes' memory copy code feature ?
Now that we're on the same page and I've looked at one, I think no, Snes9x doesn't support this. The codes would still load, so this might cause problems using a ZSNES CHT file with Snes9x. However, CheatZilla wouldn't create any of these codes, so it wouldn't be a problem here.
http://jdrrant.blogspot.com/ - CODEpendent Blog
http://games.technoplaza.net/ - Emulation Goodies
CheatZILLA
New Member
Posts: 6
Joined: Tue Mar 14, 2006 2:50 am

Post by CheatZILLA »

jdratlif wrote:I don't have a Mac to test Snes9x on though. Just the Windows version.
I have no idea why, but the Mac version is rather different. There's no option to load/save CHT files, and I tried renaming the CHT file to the same name as the ROM except with the CHT extension, and it didn't auto load it. Also the Network Play only works between Macs and won't talk to Windoze. I don't know why someone thought that TCP is different just because they are recompiling on a Mac and changed it.
jdratlif wrote:The ZSNES cheat entry stops as 18 characters.
Good enough, I changed CheatZILLA to stop at 18 characters too.
pagefault
ZSNES Developer
ZSNES Developer
Posts: 812
Joined: Tue Aug 17, 2004 5:24 am
Location: In your garden

Post by pagefault »

I would like to add an option to automatically download the CHT files from your site but I relise this would result in less ad revenue for you. I was wondering if we could work something out to keep both sides happy.
xamenus
Veteran
Posts: 907
Joined: Fri Jul 30, 2004 12:26 am

Post by xamenus »

Shadowbird
New Member
Posts: 3
Joined: Wed Apr 26, 2006 5:37 pm
Location: Latvia
Contact:

Post by Shadowbird »

After a little examination here's what I've come up with:

Code: Select all

For every cheat:

1 byte    toggle indicator, 0x00 - on, 0x04 - off
1 byte    cheat value
3 bytes   code address in little-endian
1 byte    previous value
2 bytes   unknown, 0xFE 0xFC seem to work fine
20 bytes  name (ZSNES GUI only allows to input 18 chars, but you can put 20 in the file and seems to work fine)
Ichinisan
Veteran
Posts: 603
Joined: Wed Jul 28, 2004 8:54 am

Post by Ichinisan »

Shadowbird wrote:After a little examination here's what I've come up with:

Code: Select all

For every cheat:

1 byte    toggle indicator, 0x00 - on, 0x04 - off
1 byte    cheat value
3 bytes   code address in little-endian
1 byte    previous value
2 bytes   unknown, 0xFE 0xFC seem to work fine
20 bytes  name (ZSNES GUI only allows to input 18 chars, but you can put 20 in the file and seems to work fine)
Now pick apart the structure for GG codes, PAR mirror/reflector codes, etc.
Shadowbird
New Member
Posts: 3
Joined: Wed Apr 26, 2006 5:37 pm
Location: Latvia
Contact:

Post by Shadowbird »

Ichinisan wrote:Now pick apart the structure for GG codes, PAR mirror/reflector codes, etc.
I was kinda expecting a thanks, or a link to somewhere if this had already been done. The technical specs for NES GG can be found here, but I have no idea how much they match with SNES GG. I also have no idea what PAR mirror/reflect codes are.
Post Reply