image
Tool
tools/disc/image.py(library, Discs and disk images). Read the tracks and sectors of a CD image: a CUE sheet with its BIN files, a raw BIN without a sheet, or a plain ISO.
A library: other tools and your own scripts import it. Source on GitHub.
Its own help
This is the help text in the tool itself, as ./gameframe tool image prints it.
text
Read the tracks and sectors of a CD image: a CUE sheet with its BIN files, a raw
BIN without a sheet, or a plain ISO.
from image import open_image
disc = open_image('target/cd/GAME.CUE')
for t in disc.tracks: print(t.number, t.mode, t.lba, t.frames)
data = disc.tracks[0].read(16) # 2048 bytes of user data from sector 16
A CD sector holds 2352 bytes. A data sector puts 2048 bytes of user data inside that, after a
sync pattern and a header: at byte 16 in Mode 1, and at byte 24 in Mode 2 Form 1 (CD-ROM XA,
used by the PlayStation, the CD-i and many PC discs). Mode 2 Form 2 sectors hold 2324 bytes
(video and streamed sound) and no error correction. An audio sector is 2352 bytes of 16-bit
stereo samples at 44,100 Hz, so 75 sectors make one second. A cooked image (.iso, or
MODE1/2048 in a CUE sheet) keeps only the 2048 user bytes of each data sector.
Positions are frames (sectors). A CUE sheet gives them as minutes:seconds:frames from the
start of each FILE. `lba` below is the frame count from the start of the image, which is the
disc's own sector number for a single-session image. Standard library only.