CPC emulator disk usage background __________________________________ This document explains how to use disk files on an Amstrad CPC emulator. It was adapted for Linux Format by Simon N Goodwin, based on documents at http://andercheran.aiind.upv.es/~amstrad/docs/ and is intended to make it easier for Linux enthusiasts to use and manipulate Amstrad emulator files. ************************************************************************** Disk Image (.DSK) A disk image is a file containing a description of an Amstrad disk. This sumarises the procedure to use one: Insert Disk Image into drive A Reset CPC There are different ways to load a game, depending on if a disk image describes a copy protected program. Type: CAT [return] This should display a directory listing similar to this: Drive A: user 0 DISC .BAS 1k 20K free On many disks, there is a file called "DISC" or "DISK" which can be chosen to run the main program. All files have a filename which has a 8 letter name and a 3 letter extension. A "." separates the name from the extension. The default extensions are ".BAS" and ".BIN", and the program to run usually has one of these extensions. If a file has one of these extensions, then you do not need to type the filename in full. e.g. if the file was "DISC.BAS" you can enter: RUN "DISC"to run the file. If the file does not have one of these extensions, then you will need to enter the filename in full, including the extension. e.g. if the filename was "FILE.COD" you must enter: RUN"FILE.COD" It is not necessary to type the final " character and RUN"DISC"is the same as RUN"DISC Thus, type: RUN" [enter] Where is a name in the directory listing. The program should load and start automatically. If the program doesn't start choose another name from the directory listing. If the directory listing does not appear, and the following message is displayed: Drive A: read error
(R)etry, (I)gnore or (C)ancel? Tape Image (.CDT/.TZX) A tape image is a file containing a description of the tape sound. Programs stored in a tape image will take the same time to load as they would on a real tape if the emulator is running at 100% speed. Insert Tape Image Reset CPC Type: |TAPE [return] RUN" [return] The message "Press Play then any key" will appear. Press any key then wait. After a short time you should see: "Loading [game] block 1" where [game] is the name of the file found. ************************************************************************** Disk image file format The standard emulator disk image format has the file extension ".DSK", and the following structure: General format Single sided DSK images Disk Information Block Track 0 data Track Information Block Sector data Track 1 data Track Information Block Sector data . . . . Track (number_of_tracks-1) data Track Information Block Sector data Double sided DSK images Disk Information Block Track 0 side 0 data Track Information Block Sector data Track 0 side 1 data Track Information Block Sector data . . . . Track (number_of_tracks-1) side 1 data Track Information Block Sector data Disk Information block This is at the start of all disk image files. Data for the first track immediatly follows the Disk Information Block and is at offset &100 in the disk image file (256 bytes in decimal; & denotes hexadecimal later). offset description bytes &00-21 "MV - CPCEMU Disk-File\r\nDisk-Info\r\n" 34 &22-2F name of utility/emulator that created the file 14 &30 number of tracks 1 &31 number of sides 1 &32-33 size of a track (little endian; 2 low byte followed by high byte) &34-ff not used (0) Notes: "\r" is the C programming language equivalent of ASCII character 13, CR. "\n" is the C programming language equivalent of ASCII character 10, LF. Track 0 (or Track 0 side 0 for double sided disks) immediately follows the Disk Information Block, and is at offset &100 in the disk image. "MV - CPC" must be present, because it is used to identify the file as a disk image. It is sufficient to check this to identify the file as being a disk image. All tracks must be the same size. "size of track" is used to calculate the location of the data for a chosen track. "size of track" includes the &100 byte Track Information Block. All tracks must have a "Track Information Block" track lengths are stored in the same order as the tracks in the image e.g. In the case of a double sided disk: Track 0 side 0, Track 0 side 1, Track 1 side 0 etc... The track blocks are stored in increasing order 0..number of tracks, with alternating sides interleaved if the disk image describes a double sided disk. e.g. if the disk image represents a double sided disk, the order of tracks is: track 0 side 0, track 0 side 1, track 1 side 0, track 1 side 1.... track (number of tracks-1) side 0, track (number of tracks-1) side 1 The tracks are always ordered in this way regardless of the disk-format described by the disk image. A standard disk image can be used to describe a copy-protected disk, but will often result in a file which is larger than the same disk described by a extended disk image. For a standard disk image to represent a copy-protected disk all track sizes in the standard disk image must be the same. This value therefore would be the size of the largest track, and other tracks would have unused space in them. All sector sizes within each track must be the same size, but not necessarily the same size as the sectors for another track. If a track contained different sized sectors, the size of the largest sector should be used. This would result in some wasted space. Track Information Block Each Track Block comprises a Track Information Block and sector data. The sector data is always at an offset of &100 bytes from the start of the track block. The data for the next track in the disk image immediatly follows the data for the current track. The first Track Block is located at offset &100 in the disk image file. The track block starts with the Track Information Block and has this format. offset description bytes &00 - 0C "Track-Info\r\n" 13 &0D - 0F unused 3 &10 track number 1 &11 side number 1 &12 - 13 unused 2 &14 sector size 1 &15 number of sectors 1 &16 GAP#3 length 1 &17 filler byte 1 &18 - xx Sector Information List ? Notes: "number of sectors" is used to identify the number of valid entries in the sector information list. The "sector size" parameter is used to calculate the location of each sector's data. Therefore, the amount of data allocated for each sector must be the same. If the track contains different sized sectors, then the data allocated must be the size of the biggest sector. This allows use of some protected disk formats, at the expense of a little extra space. Sector data always follows the Track Information Block at offset &100 from the start of the track information block. Sector data is stored in the same order as the sectors in the sector info block. Sector info offset description bytes 0 track (equivalent to C parameter in NEC765 commands) 1 1 side (equivalent to H parameter in NEC765 commands) 1 2 sector ID (equivalent to R parameter in NEC765 commands) 1 3 sector size (equivalent to N parameter in NEC765 commands) 1 4 FDC status register 1 (equivalent to NEC765 ST1 status register) 1 5 FDC status register 2 (equivalent to NEC765 ST2 status register) 1 6-7 not used 2 Notes: The following bits are used from NEC765 status register 1: b7 EN (End of Cylinder) b5 DE (Data Error) b2 ND (No Data) b0 MA (Missing Address Mark) The following bits are used from NEC765 status register 2: b5 CM (Control Mark) b5 DD (Data Error in Data field) b0 MD (Missing address Mark in Data field) For 8K Sectors (N="6"), only &1800 bytes are stored.