Extract GD-ROM files from MAME CHD
The mame CHD dumps are in 2352 format, or "RAW"/"BIN". To extract game files, you first have to get the uncompressed image, chdman comes with mame.
chdman -extractcd input.chd game.toc game.bin
We need to convert this file to a an ISO image, first a cue file to extract the high density track, game.cue:
FILE "game.bin" BINARY TRACK 03 MODE1/2352 INDEX 01 10:00:00
You may add track 01 and track 02 to the cue file.
Now you can convert it to an ISO image:
bchunk game.bin game.cue game
to inspect the file, use isoinfo with parameter -N45000, this is because the layout is relative to sector 0:
isoinfo -N45000 -i game03.iso -l
Use isoinfo to extract all the files:
isoinfo -N45000 -i game03.iso -x "/NAOMIGD.BIN;1" >NAOMIGD.BIN
The first 16 sectors contains needed data, to extract it you can use dd
dd if=game03.iso bs=2048 count=16 of=IP.BIN
IP.BIN is just a filename, you can call it whatever you want.