CHD File

Over time, arcade games evolved from simple one screen games, such as "Pac-Man" or "Galaga," to games that utilized scrolling screens, many playable characters and impressive, cutting-edge graphics.

Hard drives were used in a few arcade games to help store the large amounts of data needed to run the game.

A CHD file is the compressed image of that hard drive; a single file holds the information of a game's entire hard drive for example, and is required to play the game through MAME and some other emulators.

Currently, CHDs can have images of hard disks, CDs, DVDs, laserdiscs and other media.

CHD is an acronym for Compressed Hunks of Data.


Compression

The CHD is a special format that allows:

  • fast reading of the contents, because it adds an index to the sectors of the compressed media
  • different compression formats (FLAC, LZMA, ZLIB, Huffman) according to the contents

If you put a CHD file in a ZIP or 7z archive for example, when emulating a game MAME will have to extract the giant CHD file into the system's RAM memory, and then decompress bits and pieces of the extracted CHD out of memory. This is highly inefficient and slow, which defeats the purpose of CHD files. Doing that is not recommended.


Working Machines

Be aware that:

  1. Only a small part of all supported machines requires CHDs (2.4%), and most machines that require CHDs don't work properly (74.4%).
  2. Some CHD games work, but run very slowly.
  3. CHDs have version numbers, V3, V4, or V5, and depending what version of MAME you are using, it may want different versions of the CHDs. You can use chdman.exe to determine the version number of each CHD that you have.
  4. You can usually tell if a game that has a CHD is supposed to be working by looking at the -listxml output for that game, then checking for the driver status tag, or the lack of a 'baddump' attribute in the 'disk' tag.


CHDMAN

The chdman.exe utility is distributed with MAME binaries and is used to compress, decompress, recompress, verify data and show information of CHD files.

Download it from MAMEDEV.org - Latest MAME Release.


To show help information:

chdman

Which results on this:

C:\mame>chdman
chdman - MAME Compressed Hunks of Data (CHD) manager 0.182 (mame0182)
Usage:
   chdman info: displays information about a CHD
   chdman verify: verifies a CHD's integrity
   chdman createraw: create a raw CHD from the input file
   chdman createhd: create a hard disk CHD from the input file
   chdman createcd: create a CD CHD from the input file
   chdman createld: create a laserdisc CHD from the input file
   chdman extractraw: extract raw file from a CHD input file
   chdman extracthd: extract raw hard disk file from a CHD input file
   chdman extractcd: extract CD file from a CHD input file
   chdman extractld: extract laserdisc AVI from a CHD input file
   chdman copy: copy data from one CHD to another of the same type
   chdman addmeta: add metadata to the CHD
   chdman delmeta: remove metadata from the CHD
   chdman dumpmeta: dump metadata from the CHD to stdout or to a file
   chdman listtemplates: list hard disk templates

For help with any command, run:
   chdman help <command>


To view the information of a CHD:

chdman info --input file.chd


Below is the information displayed of a random CHD:

D:\Pleasuredome\MAME CHDs 0.182\area51>chdman info --input area51.chd
chdman - MAME Compressed Hunks of Data (CHD) manager 0.182 (mame0182)
Input file:   area51.chd
File Version: 5
Logical size: 1,281,982,464 bytes
Hunk Size:    4,096 bytes
Total Hunks:  312,984
Unit Size:    512 bytes
Total Units:  2,503,872
Compression:  lzma (LZMA), zlib (Deflate), huff (Huffman), flac (FLAC)
CHD size:     497,632,790 bytes
Ratio:        38.8%
SHA1:         3b303bc37e206a6d7339352c869f050d04186f11
Data SHA1:    9ea749404c9a5d44f407cdb8803293ec0d61410d
Metadata:     Tag='GDDD'  Index=0  Length=35 bytes
              CYLS:2484,HEADS:16,SECS:63,BPS:512.


To verify if a CHD is corrupt:

chdman verify --input file.chd


To recompress a CHD (or update from an old version to a newer version):

chdman copy --input old.chd --output new.chd


Note: A friendlier alternative is using Qt CHDMAN GUI, which is a frontend for chdman.exe.


Emulators that support CHDs

List below:


FAQ

Here are the Frequently Asked Questions:

Why do the CHD files change version every so often?
The CHD format started with emulating games that have hard disks, hence their original acronym - Compressed Hard Disk. When CD based games became available for dumping, the format was extended to cover them and the acronym was altered to Compressed Hunks (of) Data. When more elaborate CD based games came out, the old compression types were not as effective as newly developed ones, so another revision was created. Plus it became clear that previously dumped games in the older versions were missing some data, so many of the V4 games needed to be redumped as V5 to get everything.

There are now a number of compression types used by the CHD format, matched to the type of data on the disks being dumped. If you use the "info" command with chdman.exe on each CHD, you can find the original size of the data before CHD compression. The specific compression type(s) is(are) also listed. Yes, there are usually several types of compression for most of the CHDs now. Different parts of the original data is compressed via different (and the most suitable) methods. This gives it a performance edge over 7z, as 7z will just try to compress the whole file, without respect to the fact that different parts may respond better to different compression methods.

A lot of the CHD games are not working so why download these - especially as some are quite large?
The point of collecting the non-working CHDs is not to play them, as they do not work. This is counter-intuitive of course. People have their own reasons for collecting them. Among those reasons are:
  • Just want to have the whole set of what is available.
  • Want to be ready to play any game as soon as the MAMEDevs produce a working driver.
  • MAMEDevs want other MAMEDevs to have access to the CHDs so there is a greater chance that development will continue.
  • By widely distributing game data for games that are not playable, they are preserved for future developers to work on.
  • Members of Pleasuredome need to build ratio.


See also


Reference