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  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

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.

Emulators that support CHDs
List below:
 * DEmul
 * FinalBurn Neo
 * MAME
 * MESS
 * ZiNc
 * Mednafen
 * U64Emu (formerly known as KIAME)
 * WinUAE (for Amiga CD32)

FAQ
Here are the Frequently Asked Questions:

Reference

 * MAMEdev.org - FAQ: Setting Up