<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://oldwiki.cpcwiki.eu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Thomasharte</id>
		<title>CPCWiki - THE Amstrad CPC encyclopedia! - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://oldwiki.cpcwiki.eu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Thomasharte"/>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php/Special:Contributions/Thomasharte"/>
		<updated>2026-08-29T23:58:59Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.25.1</generator>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=Format:DSK_disk_image_file_format&amp;diff=99574</id>
		<title>Format:DSK disk image file format</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Format:DSK_disk_image_file_format&amp;diff=99574"/>
				<updated>2017-10-08T00:08:56Z</updated>
		
		<summary type="html">&lt;p&gt;Thomasharte: /* Disc Information block */Fixed typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Cpctech.org]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid rgb(228, 222, 222); margin: 0px 0px 5px; padding: 0.5em 1em; background-color: rgb(249, 249, 249);&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''This article originally came from Kevin Thackers' archive at [http://www.cpctech.org.uk http://www.cpctech.org.uk].''''' &amp;lt;/center&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disk image file format  =&lt;br /&gt;
&lt;br /&gt;
This document describes the standard disk image format. It has the file extension &amp;quot;.DSK&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
== Disc Information block  ==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Disc Information block&amp;quot; is always at offset 0 in the disk image file. If track data exists, then this will immediately follow the Disc Information Block and will start at offset &amp;amp;amp;100 in the disc image file. &lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Disc Information block&amp;quot; has the following structure: &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! offset &lt;br /&gt;
! description &lt;br /&gt;
! bytes&lt;br /&gt;
|-&lt;br /&gt;
| 00-21 &lt;br /&gt;
| &amp;quot;MV - CPCEMU Disk-File\r\nDisk-Info\r\n&amp;quot; &lt;br /&gt;
| 34&lt;br /&gt;
|-&lt;br /&gt;
| 22-2f &lt;br /&gt;
| name of creator &lt;br /&gt;
| 14&lt;br /&gt;
|-&lt;br /&gt;
| 30 &lt;br /&gt;
| number of tracks &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 31 &lt;br /&gt;
| number of sides &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 32-33 &lt;br /&gt;
| size of a track (little endian; low byte followed by high byte) &lt;br /&gt;
| 2&lt;br /&gt;
|-&lt;br /&gt;
| 34-ff &lt;br /&gt;
| not used (0) &lt;br /&gt;
| 204&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
*Track 0 (or Track 0 side 0 for double sided disks) immediatly follows the Disk Information Block, and is at offset &amp;amp;amp;100 in the disk image. &lt;br /&gt;
*&amp;quot;MV - CPC&amp;quot; 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. &lt;br /&gt;
*&amp;quot;\r&amp;quot; is the C programming language equivalent of ASCII character 13. &lt;br /&gt;
*&amp;quot;\n&amp;quot; is the C programming language equivalent of ASCII character 10. &lt;br /&gt;
*'''All''' tracks must be the same size. &lt;br /&gt;
*&amp;quot;size of track&amp;quot; is used to calculate the location of the data for a chosen track. &lt;br /&gt;
*&amp;quot;size of track&amp;quot; includes the &amp;amp;amp;100 byte Track Information Block. &lt;br /&gt;
*'''All''' tracks must have a &amp;quot;Track Information Block&amp;quot; &lt;br /&gt;
*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... &lt;br /&gt;
*The track blocks are stored in increasing order 0..number of tracks, with alternating sides interleaved if the disc 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 disc-format described by the disc image. &lt;br /&gt;
*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: &lt;br /&gt;
**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. &lt;br /&gt;
**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.&lt;br /&gt;
&lt;br /&gt;
== Track Information Block  ==&lt;br /&gt;
&lt;br /&gt;
Each Track Block comprises a Track Information Block and sector data. The sector data is always at an offset of &amp;amp;amp;100 bytes from the start of the track block. The data for the next track in the disc image immediatly follows the data for the current track. &lt;br /&gt;
&lt;br /&gt;
The first Track Block is located at offset &amp;amp;amp;100 in the disk image file. The track block starts with the Track Information Block and has this form. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! offset &lt;br /&gt;
! description &lt;br /&gt;
! bytes&lt;br /&gt;
|-&lt;br /&gt;
| 00 - 0b &lt;br /&gt;
| &amp;quot;Track-Info\r\n&amp;quot; &lt;br /&gt;
| 12&lt;br /&gt;
|-&lt;br /&gt;
| 0c - 0f &lt;br /&gt;
| unused &lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
| 10 &lt;br /&gt;
| track number &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 11 &lt;br /&gt;
| side number &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 12 - 13 &lt;br /&gt;
| unused &lt;br /&gt;
| 2&lt;br /&gt;
|-&lt;br /&gt;
| 14 &lt;br /&gt;
| sector size &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 15 &lt;br /&gt;
| number of sectors &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 16 &lt;br /&gt;
| GAP#3 length &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 17 &lt;br /&gt;
| filler byte &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 18 - xx &lt;br /&gt;
| Sector Information List &lt;br /&gt;
| xx&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
*&amp;quot;number of sectors&amp;quot; is used to identify the number of valid entries in the sector information list. &lt;br /&gt;
*&amp;quot;sector size&amp;quot; parameter is used to calculate the location of each sector's data. Therefore, The 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. The &amp;quot;sector size&amp;quot; parameter is used to calculate the location of the sector data. &lt;br /&gt;
*Sector data always follows Track Information Block at offset &amp;amp;amp;100 from the start of the track information block. &lt;br /&gt;
*Sector data is stored in the same order as the sectors in the sector info block.&lt;br /&gt;
&lt;br /&gt;
=== Sector info  ===&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! offset &lt;br /&gt;
! description &lt;br /&gt;
! bytes&lt;br /&gt;
|-&lt;br /&gt;
| 00 &lt;br /&gt;
| track (equivalent to C parameter in NEC765 commands) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 01 &lt;br /&gt;
| side (equivalent to H parameter in NEC765 commands) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 02 &lt;br /&gt;
| sector ID (equivalent to R parameter in NEC765 commands) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 03 &lt;br /&gt;
| sector size (equivalent to N parameter in NEC765 commands) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 04 &lt;br /&gt;
| FDC status register 1 (equivalent to NEC765 ST1 status register) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 05 &lt;br /&gt;
| FDC status register 2 (equivalent to NEC765 ST2 status register) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 06 - 07 &lt;br /&gt;
| notused (0) &lt;br /&gt;
| 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
*The following bits are used from NEC765 status register 1: &lt;br /&gt;
**b7 EN (End of Cylinder) &lt;br /&gt;
**b5 DE (Data Error) &lt;br /&gt;
**b2 ND (No Data) &lt;br /&gt;
**b0 MA (Missing Address Mark) &lt;br /&gt;
*The following bits are used from NEC765 status register 2: &lt;br /&gt;
**b5 CM (Control Mark) &lt;br /&gt;
**b5 DD (Data Error in Data field) &lt;br /&gt;
**b0 MD (Missing address Mark in Data field) &lt;br /&gt;
*For 8k Sectors (N=&amp;quot;6&amp;quot;), only 1800h bytes is stored.&lt;br /&gt;
&lt;br /&gt;
== General format  ==&lt;br /&gt;
&lt;br /&gt;
=== Single sided DSK images  ===&lt;br /&gt;
&lt;br /&gt;
*Disc Information Block &lt;br /&gt;
*Track 0 data &lt;br /&gt;
**Track Information Block &lt;br /&gt;
**Sector data &lt;br /&gt;
*Track 1 data &lt;br /&gt;
**Track Information Block &lt;br /&gt;
**Sector data . . . . &lt;br /&gt;
*Track (number_of_tracks-1) data &lt;br /&gt;
**Track Information Block &lt;br /&gt;
**Sector data&lt;br /&gt;
&lt;br /&gt;
=== Double sided DSK images  ===&lt;br /&gt;
&lt;br /&gt;
*Disc Information Block &lt;br /&gt;
*Track 0 side 0 data &lt;br /&gt;
**Track Information Block &lt;br /&gt;
**Sector data &lt;br /&gt;
*Track 0 side 1 data &lt;br /&gt;
**Track Information Block &lt;br /&gt;
**Sector data . . . . &lt;br /&gt;
*Track (number_of_tracks-1) side 1 data &lt;br /&gt;
**Track Information Block &lt;br /&gt;
**Sector data&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
= Extended DSK image definition  =&lt;br /&gt;
&lt;br /&gt;
The extended DSK image is a file designed to describe copy-protected floppy disk software. It's definition was defined by Marco Vieth, Ulrich Doewich and Kevin Thacker. &lt;br /&gt;
&lt;br /&gt;
This format has been widely adopted and is one of the major file formats used (the other major format is the standard disk image with the &amp;quot;MV - CPC&amp;quot; identifier). &lt;br /&gt;
&lt;br /&gt;
The extended disk image format should be used for copy-protected disc software, or in place of a standard disk image if the resulting image is smaller than in the standard disk image form. &lt;br /&gt;
&lt;br /&gt;
== Extended DiSK Format (Rev.5)  ==&lt;br /&gt;
&lt;br /&gt;
The disc image has the following format: &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| DISK INFORMATION BLOCK (256 bytes)&lt;br /&gt;
|-&lt;br /&gt;
| TRACK INFORMATION BLOCK * number of tracks * number of sides&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The track blocks are stored in increasing order 0..number of tracks, with alternating sides interleaved if the disc 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 &lt;br /&gt;
&lt;br /&gt;
The tracks are '''always''' ordered in this way regardless of the disc-format described by the disc image. &lt;br /&gt;
&lt;br /&gt;
The location of the track information block is found by using the track size table. &lt;br /&gt;
&lt;br /&gt;
== DISK INFORMATION BLOCK  ==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;DISK INFORMATION BLOCK&amp;quot; is always located at offset 0 in the disk image file, and has the following structure: &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! offset &lt;br /&gt;
! description &lt;br /&gt;
! bytes&lt;br /&gt;
|-&lt;br /&gt;
| 00 - 21 &lt;br /&gt;
| &amp;quot;EXTENDED CPC DSK File\r\nDisk-Info\r\n&amp;quot; &lt;br /&gt;
| 34&lt;br /&gt;
|-&lt;br /&gt;
| 22 - 2f &lt;br /&gt;
| name of creator (utility/emulator) &lt;br /&gt;
| 14&lt;br /&gt;
|-&lt;br /&gt;
| 30 &lt;br /&gt;
| number of tracks &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 31 &lt;br /&gt;
| number of sides &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 32 - 33 &lt;br /&gt;
| unused &lt;br /&gt;
| 2&lt;br /&gt;
|-&lt;br /&gt;
| 34 - xx &lt;br /&gt;
| track size table &lt;br /&gt;
| number of tracks*number of sides&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
NOTES: &lt;br /&gt;
&lt;br /&gt;
*An extended DSK image is identified by the &amp;quot;EXTENDED&amp;quot; tag. The track size at offset 32h and 33h, used by the STANDARD disk image is ignored for extended format DSK images. &lt;br /&gt;
*If track data exists, then it starts at offset 100h. &lt;br /&gt;
*The &amp;quot;EXTENDED&amp;quot; tag is present to prevent existing emulators which support the standard DSK image from interpreting the data wrong and possibly crashing. &lt;br /&gt;
*&amp;quot;\r&amp;quot; is the C programming language equivalent of ASCII character 13. &lt;br /&gt;
*&amp;quot;\n&amp;quot; is the C programming language equivalent of ASCII character 10.&lt;br /&gt;
&lt;br /&gt;
== TRACK OFFSET TABLE  ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! offset &lt;br /&gt;
! description &lt;br /&gt;
! bytes&lt;br /&gt;
|-&lt;br /&gt;
| 01 &lt;br /&gt;
| high byte of track 0 length (equivalent to track length/256) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| ... &lt;br /&gt;
| ... &lt;br /&gt;
| ...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
NOTES: &lt;br /&gt;
&lt;br /&gt;
*Depending on the information in the disk information block, the table contains &lt;br /&gt;
**track lengths for a single sided floppy disc &lt;br /&gt;
**track lengths for a double sided floppy disc &lt;br /&gt;
*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... &lt;br /&gt;
*A size of &amp;quot;0&amp;quot; indicates an unformatted track. In this case there is no data, and no track information block for this track in the image file! &lt;br /&gt;
*Actual length of track data = (high byte of track length) * 256 &lt;br /&gt;
*Track length includes the size of the TRACK INFORMATION BLOCK (256 bytes) &lt;br /&gt;
*The location of a Track Information Block for a chosen track is found by summing the sizes of all tracks up to the chosen track plus the size of the Disc Information Block (&amp;amp;amp;100 bytes). The first track is at offset &amp;amp;amp;100 in the disc image.&lt;br /&gt;
&lt;br /&gt;
== TRACK INFORMATION BLOCK  ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! offset &lt;br /&gt;
! description &lt;br /&gt;
! bytes&lt;br /&gt;
|-&lt;br /&gt;
| 00 - 0b &lt;br /&gt;
| &amp;quot;Track-Info\r\n&amp;quot; &lt;br /&gt;
| 12&lt;br /&gt;
|-&lt;br /&gt;
| 0c - 0f &lt;br /&gt;
| unused &lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
| 10 &lt;br /&gt;
| track number &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 11 &lt;br /&gt;
| side number &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 12 - 13 &lt;br /&gt;
| unused &lt;br /&gt;
| 2&lt;br /&gt;
|-&lt;br /&gt;
| 14 &lt;br /&gt;
| sector size &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 15 &lt;br /&gt;
| number of sectors &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 16 &lt;br /&gt;
| GAP#3 length &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 17 &lt;br /&gt;
| filler byte &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 18 - xx &lt;br /&gt;
| Sector Information List &lt;br /&gt;
| xx&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
NOTES: &lt;br /&gt;
&lt;br /&gt;
*Identical to the original DSK format definition.&lt;br /&gt;
&lt;br /&gt;
== SECTOR INFORMATION LIST  ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! offset &lt;br /&gt;
! description &lt;br /&gt;
! bytes&lt;br /&gt;
|-&lt;br /&gt;
| 00 &lt;br /&gt;
| track (equivalent to C parameter in NEC765 commands) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 01 &lt;br /&gt;
| side (equivalent to H parameter in NEC765 commands) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 02 &lt;br /&gt;
| sector ID (equivalent to R parameter in NEC765 commands) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 03 &lt;br /&gt;
| sector size (equivalent to N parameter in NEC765 commands) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 04 &lt;br /&gt;
| FDC status register 1 (equivalent to NEC765 ST1 status register) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 05 &lt;br /&gt;
| FDC status register 2 (equivalent to NEC765 ST2 status register) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 06 - 07 &lt;br /&gt;
| actual data length in bytes &lt;br /&gt;
| 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
NOTES: &lt;br /&gt;
&lt;br /&gt;
*Identical to the original definition except for the addition of the sector data length. This value is in bytes and stored in little endian notation. (low byte followed by high byte) &lt;br /&gt;
*The location of each sectors data is found by adding the size of the previous sectors, plus the size of the 256 byte header. &lt;br /&gt;
*For 8k Sectors (N=&amp;quot;6&amp;quot;), only 1800h bytes is stored. Please see extensions below!!!&lt;br /&gt;
&lt;br /&gt;
== Extensions to the above specification  ==&lt;br /&gt;
&lt;br /&gt;
1. This extension was proposed by John Elliott. Extension to TRACK INFORMATION BLOCK: &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! offset &lt;br /&gt;
! description &lt;br /&gt;
! bytes&lt;br /&gt;
|-&lt;br /&gt;
| 12 &lt;br /&gt;
| Data rate. (See note 1 and note 3) &lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 13 &lt;br /&gt;
| Recording mode. (See note 2 and note 3) &lt;br /&gt;
| 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
:Notes:&lt;br /&gt;
&lt;br /&gt;
:1. Data rate defines the rate at which data was written to the track. This value applies to the entire track.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Date rate &lt;br /&gt;
! description&lt;br /&gt;
|-&lt;br /&gt;
| 0 &lt;br /&gt;
| Unknown.&lt;br /&gt;
|-&lt;br /&gt;
| 1 &lt;br /&gt;
| Single or double density&lt;br /&gt;
|-&lt;br /&gt;
| 2 &lt;br /&gt;
| High Density&lt;br /&gt;
|-&lt;br /&gt;
| 3 &lt;br /&gt;
| Extended density&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Existing files should have zeroes in these bytes; hence the use of 0 for unknown. &lt;br /&gt;
&lt;br /&gt;
:2. Recording mode is used to define how the data was written. It defines the encoding used to write the data to the disc and the structure of the data on the disc including the layout of the sectors. This value applies to the entire track.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Date rate &lt;br /&gt;
! description&lt;br /&gt;
|-&lt;br /&gt;
| 0 &lt;br /&gt;
| Unknown.&lt;br /&gt;
|-&lt;br /&gt;
| 1 &lt;br /&gt;
| FM&lt;br /&gt;
|-&lt;br /&gt;
| 2 &lt;br /&gt;
| MFM&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Existing files should have zeroes in these bytes; hence the use of 0 for unknown. &lt;br /&gt;
&lt;br /&gt;
:3. How to determine the actual rate. The NEC765 floppy disc controller is supplied with a single clock. When reading from and writing to a disc using the NEC765 you can choose FM or MFM recording modes. Use of these modes and the clock into the NEC765 define the final rate at which the data is written to the disc. &lt;br /&gt;
:When FM recording mode is used, data is read from or written to at a rate which is double that of when MFM is used. The time for each bit will be twice the time for MFM. &lt;br /&gt;
:Examples:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! NEC765 Clock &lt;br /&gt;
! FM/MFM &lt;br /&gt;
! Actual rate&lt;br /&gt;
|-&lt;br /&gt;
| 4Mhz &lt;br /&gt;
| FM &lt;br /&gt;
| 4us per bit&lt;br /&gt;
|-&lt;br /&gt;
| 4Mhz &lt;br /&gt;
| MFM &lt;br /&gt;
| 2us per bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
2. This extension was proposed by Simon Owen. &lt;br /&gt;
&lt;br /&gt;
:1. It has been found that many protections using 8K Sectors (N=&amp;quot;6&amp;quot;) do store more than &amp;amp;amp;1800 bytes of useable data. It was thought that &amp;amp;amp;1800 was the maximum useable limit, but this has proved wrong. So you should support 8K of data to ensure this data is read correctly. The size of the sector will be reported in the SECTOR INFORMATION LIST as described above. &lt;br /&gt;
:For sector size N=&amp;quot;7&amp;quot; the full 16K will be stored. It is assumed that sector sizes are defined as 3 bits only, so that a sector size of N=&amp;quot;8&amp;quot; is equivalent to N=&amp;quot;0&amp;quot;. &lt;br /&gt;
:2. Storing Multiple Versions of Weak/Random Sectors. &lt;br /&gt;
:Some copy protections have what is described as 'weak/random' data. Each time the sector is read one or more bytes will change, the value may be random between consecutive reads of the same sector. &lt;br /&gt;
:To support these formats the following extension has been proposed. &lt;br /&gt;
:Where a sector has weak/random data, there are multiple copies stored. The actual sector size field in the SECTOR INFORMATION LIST describes the size of all the copies. To determine if a sector has multiple copies then compare the actual sector size field to the size defined by the N parameter. For multiple copies the actual sector size field will have a value which is a multiple of the size defined by the N parameter. The emulator should then choose which copy of the sector it should return on each read.&lt;/div&gt;</summary>
		<author><name>Thomasharte</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=CRTC&amp;diff=98460</id>
		<title>CRTC</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=CRTC&amp;diff=98460"/>
				<updated>2017-08-10T16:24:05Z</updated>
		
		<summary type="html">&lt;p&gt;Thomasharte: Minor adjustments; some incorrect apostrophes, and minor other things.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* ''This is an article about the &amp;quot;Cathode Ray Tube Controller&amp;quot; hardware unit of the Amstrad CPC. For the cpc scene member see [[ChaRleyTroniC]]''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''CRTC''' (Cathode Ray Tube Controller) helps to generate the video signal of the Amstrad CPC.&lt;br /&gt;
&lt;br /&gt;
NOTE: This document describes the functionality in terms of the CPC with its separate CRTC and Gate-Array. The Plus has both integrated into the same IC, but could be considered to have two functional blocks, one for CRTC and one for Gate-Array. In this document the term 'Gate-Array' is used, but this also applies to the ASIC.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The 6845 Cathode Ray Tube Controller (CRTC) is a programmable IC used to generate video displays. This IC is used in a variety of computers including the Amstrad CPC, Amstrad CPC+ and KC Compact. &lt;br /&gt;
&lt;br /&gt;
The CRTC was a common part available from many different manufacturers. During the life of the CPC, Amstrad sourced the CRTC from various manufacturers. &lt;br /&gt;
&lt;br /&gt;
All ICs used were based on the same design but have a different implementation. As a result they do not operate identically in all situations. This document highlights these differences. &lt;br /&gt;
&lt;br /&gt;
This table lists the known ICs used, with their part number, manufacturer and type number. &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Part number''||''Manufacturer''||''Type number (note 3)''&lt;br /&gt;
|-&lt;br /&gt;
|HD6845S||Hitachi||0&lt;br /&gt;
|-&lt;br /&gt;
|UM6845||UMC||0&lt;br /&gt;
|-&lt;br /&gt;
|UM6845R||UMC||1&lt;br /&gt;
|-&lt;br /&gt;
|MC6845||Motorola||2&lt;br /&gt;
|-&lt;br /&gt;
|AMS40489||Amstrad||3 (note 1)&lt;br /&gt;
|-&lt;br /&gt;
|40226||Amstrad||4 (note 2)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''NOTES''' &lt;br /&gt;
&lt;br /&gt;
1. The CRTC functionality is integrated into the CPC+ ASIC. This type exists only in the CPC464+,CPC6128+ and GX4000. &lt;br /&gt;
&lt;br /&gt;
2. This type exists in &amp;quot;cost-down&amp;quot; CPC464 and CPC6128 systems. In the &amp;quot;cost-down&amp;quot; the CRTC functionality is integrated into a single ASIC IC. This ASIC is often refered to as the &amp;quot;Pre-ASIC&amp;quot; because it preceeded the CPC+ ASIC. The CRTC functionality of the Pre-ASIC is almost identical to the CRTC within the ASIC.&lt;br /&gt;
 &lt;br /&gt;
3. In the Amstrad community each 6845 implementation has been assigned a type number. This type identifies a group of implementations which operate in exactly the same way. &lt;br /&gt;
&lt;br /&gt;
As far as I know, the type number system was originally used by demo programmers. &lt;br /&gt;
&lt;br /&gt;
It is possible to detect the 6845 present using software methods, and this is done to: &lt;br /&gt;
&lt;br /&gt;
* warn that the software was not designed for the detected 6845 and may function incorrectly, &lt;br /&gt;
* to adapt the software so that it will run with the detected 6845 &lt;br /&gt;
* In most cases, the type of the detected 6845 is reported. &lt;br /&gt;
&lt;br /&gt;
4. As far as I know, the KC compact used HD6845R only.&lt;br /&gt;
&lt;br /&gt;
== Timings and relating with Z80 instructions count ==&lt;br /&gt;
&lt;br /&gt;
Some informations like : how many Z80 instructions can I fit within a scan line ? Within a screen ? Etc... See http://www.cpcwiki.eu/forum/programming/frame-flyback-and-interrupts/msg25106/#msg25106&lt;br /&gt;
(To be extracted/edited to conform to wiki good practices).&lt;br /&gt;
&lt;br /&gt;
==Programming==&lt;br /&gt;
&lt;br /&gt;
The 6845 is selected when bit 14 of the I/O port address is set to &amp;quot;0&amp;quot;. Bit 9 and 8 of the I/O port address define the function to access. The remaining bits can be any value, but it is adviseable to set these to &amp;quot;1&amp;quot; to avoid conflict with other devices in the system.&lt;br /&gt;
&lt;br /&gt;
The recommended I/O port addresses are&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''I/O port address''||''Function''||''Read/Write''&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;BCxx||Select 6845 register||Write only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;BDxx||Write 6845 register data||Write only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;BExx||(note 1)||Read only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;BFxx||(note 1)||Read only&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''NOTE'''&lt;br /&gt;
&lt;br /&gt;
1. The function of these I/O ports is dependant on the CRTC type&lt;br /&gt;
 &lt;br /&gt;
2. If you perform an IN instruction to the select or write functions it will write data to the CRTC from the current data on the bus.&lt;br /&gt;
&lt;br /&gt;
==Addressing==&lt;br /&gt;
&lt;br /&gt;
The following table defines the generated memory address from the CRTC and Gate-Array signals. &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Memory Address Signal''||''Signal source''||''Signal name''&lt;br /&gt;
|-&lt;br /&gt;
|A15||6845||MA13 &lt;br /&gt;
|-&lt;br /&gt;
|A14||6845||MA12&lt;br /&gt;
|-&lt;br /&gt;
|A13||6845||RA2 &lt;br /&gt;
|-&lt;br /&gt;
|A12||6845||RA1 &lt;br /&gt;
|-&lt;br /&gt;
|A11||6845||RA0 &lt;br /&gt;
|-&lt;br /&gt;
|A10||6845||MA9 &lt;br /&gt;
|-&lt;br /&gt;
|A9||6845||MA8 &lt;br /&gt;
|-&lt;br /&gt;
|A8||6845||MA7 &lt;br /&gt;
|-&lt;br /&gt;
|A7||6845||MA6 &lt;br /&gt;
|-&lt;br /&gt;
|A6||6845||MA5 &lt;br /&gt;
|-&lt;br /&gt;
|A5||6845||MA4 &lt;br /&gt;
|-&lt;br /&gt;
|A4||6845||MA3 &lt;br /&gt;
|-&lt;br /&gt;
|A3||6845||MA2 &lt;br /&gt;
|-&lt;br /&gt;
|A2||6845||MA1 &lt;br /&gt;
|-&lt;br /&gt;
|A1||6845||MA0&lt;br /&gt;
|-&lt;br /&gt;
|A0||Gate-Array||CCLK&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
CRTC generates the address, Gate-Array reads the data and converts it to pixels based on the current mode.&lt;br /&gt;
&lt;br /&gt;
== DISPTMG ==&lt;br /&gt;
&lt;br /&gt;
DISPTMG signal defines the border. When DISPTMG is &amp;quot;1&amp;quot; the border colour is output by the Gate-Array to the display. The DISPTMG can be forced using R8 (DISPTMG Skew) on type 0,3 and 4 or by setting R6=0 on type 1. It is not possible to force the DISPTMG on type 2 or 5.&lt;br /&gt;
&lt;br /&gt;
The border has higher priority than pixels but lower priority than the black colour output when HSYNC/VSYNC are active.&lt;br /&gt;
&lt;br /&gt;
== HSYNC and VSYNC ==&lt;br /&gt;
&lt;br /&gt;
On CPC, HSYNC and VSYNC from the CRTC are passed into the Gate-Array.&lt;br /&gt;
&lt;br /&gt;
When HSYNC is active Gate-Array outputs the palette colour black. If the HSYNC is set to 14 characters then black will be output for 14us.&lt;br /&gt;
&lt;br /&gt;
The HSYNC is modified before being sent to the monitor. It  happens 2us after the HSYNC from the CRTC and lasts 4us when HSYNC length is greater or equal to 6. &lt;br /&gt;
&lt;br /&gt;
If R2=46, and HSYNC width is 14 then monitor hsync starts at 48 and lasts until 51.&lt;br /&gt;
&lt;br /&gt;
On a CPC monitor, the HSYNC is rendered in &amp;quot;absolute black&amp;quot;. It is darker than the black output by the Gate-Array.&lt;br /&gt;
&lt;br /&gt;
The VSYNC is also modified before being sent to the monitor. It happens two lines* after the VSYNC from the CRTC and stay two lines (same cut rule if VSYNC is lower than 4). PAL (50Hz) does need two lines VSYNC_width, and 4us HSYNC_width.&lt;br /&gt;
&lt;br /&gt;
Using CRTC1, VSYNC width value 0 means a value of 16.&lt;br /&gt;
&lt;br /&gt;
== The 6845 Registers ==&lt;br /&gt;
&lt;br /&gt;
The Internal registers of the 6845 are:&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Register Index''||''Register Name''||''Range''||''CPC Setting''||''Notes''&lt;br /&gt;
|-&lt;br /&gt;
|0||Horizontal Total||00000000||63||Width of the screen, in characters. Should always be 63 (64 characters). 1 character == 1μs.&lt;br /&gt;
|-&lt;br /&gt;
|1||Horizontal Displayed||00000000||40||Number of characters displayed. Once horizontal character count (HCC) matches this value, DISPTMG is set to 1.&lt;br /&gt;
|-&lt;br /&gt;
|2||Horizontal Sync Position||00000000||46||When to start the HSync signal.&lt;br /&gt;
|-&lt;br /&gt;
|3||Horizontal and Vertical Sync Widths||VVVVHHHH||128+14||HSync pulse width in characters (0 means 16 on some CRTC), should always be more than 8; VSync width in scan-lines. (0 means 16 on some CRTC. Not present on all CRTCs, fixed to 16 lines on these)&lt;br /&gt;
|-&lt;br /&gt;
|4||Vertical Total||x0000000||38||Height of the screen, in characters.&lt;br /&gt;
|-&lt;br /&gt;
|5||Vertical Total Adjust||xxx00000||0||Measured in scanlines, can be used for smooth vertical scrolling on CPC.&lt;br /&gt;
|-&lt;br /&gt;
|6||Vertical Displayed||x0000000||25||Height of displayed screen in characters. Once vertical character count (VCC) matches this value, DISPTMG is set to 1.&lt;br /&gt;
|-&lt;br /&gt;
|7||Vertical Sync position||x0000000||30||When to start the VSync signal, in characters.&lt;br /&gt;
|-&lt;br /&gt;
|8||Interlace and Skew||xxxxxx00||0||00: No interlace; 01: Interlace Sync Raster Scan Mode; 10: No Interlace; 11: Interlace Sync and Video Raster Scan Mode&lt;br /&gt;
|-&lt;br /&gt;
|9||Maximum Raster Address||xxx00000||7||Maximum scan line address on CPC can hold between 0 and 7, higher values' upper bits are ignored&lt;br /&gt;
|-&lt;br /&gt;
|10||Cursor Start Raster||xBP00000||0||Cursor not used on CPC. B = Blink On/Off; P = Blink Period Control (Slow/Fast). Sets first raster row of character that cursor is on to invert.&lt;br /&gt;
|-&lt;br /&gt;
|11||Cursor End Raster||xxx00000||0||Sets last raster row of character that cursor is on to invert&lt;br /&gt;
|-&lt;br /&gt;
|12||Display Start Address (High)||xx000000||32&lt;br /&gt;
|-&lt;br /&gt;
|13||Display Start Address (Low)||00000000||0||Allows you to offset the start of screen memory for hardware scrolling, and if using memory from address &amp;amp;0000 with the firmware.&lt;br /&gt;
|-&lt;br /&gt;
|14||Cursor Address (High)||xx000000||0&lt;br /&gt;
|-&lt;br /&gt;
|15||Cursor Address (Low)||00000000||0&lt;br /&gt;
|-&lt;br /&gt;
|16||Light Pen Address (High)||xx000000||||Read Only&lt;br /&gt;
|-&lt;br /&gt;
|17||Light Pen Address (Low)||00000000||||Read Only&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
registers 18-31 read as 0, on type 0 and 2.&lt;br /&gt;
registers 18-30 read as 0 on type1, register 31 reads as 0x0ff.&lt;br /&gt;
&lt;br /&gt;
Details about Reg. 12 and Reg. 13 specifically:&lt;br /&gt;
&lt;br /&gt;
  .------- REG 12 --------.   .------- REG 13 --------.&lt;br /&gt;
  |                       |   |                       |&lt;br /&gt;
   15 14 13 12 11 10 09 08     07 06 05 04 03 02 01 00&lt;br /&gt;
  .--.--.--.--.--.--.--.--.   .--.--.--.--.--.--.--.--.&lt;br /&gt;
  |X |X |  |  |  |  |  |  |   |  |  |  |  |  |  |  |  |&lt;br /&gt;
  '--'--'--'--'--'--'--'--'   '--'--'--'--'--'--'--'--'&lt;br /&gt;
        '--.--'--.--'---------------.-----------------'&lt;br /&gt;
           |     |                  |&lt;br /&gt;
           |     |                  '------&amp;gt; Offset for setting&lt;br /&gt;
           |     |                           videoram &lt;br /&gt;
           |     |                           (1024 positions)&lt;br /&gt;
           |     |                           Bits 0..9&lt;br /&gt;
           |     |&lt;br /&gt;
           |     '-------------------------&amp;gt; Video Buffer : note (1)&lt;br /&gt;
           |&lt;br /&gt;
           '-------------------------------&amp;gt; Video Page : note (2)&lt;br /&gt;
  note (1)                 note (2)&lt;br /&gt;
  .--.--.--------------.  .--.--.---------------.&lt;br /&gt;
  |11|10| Video Buffer |  |13|12|   Video Page  |&lt;br /&gt;
  |--|--|--------------|  |--|--|---------------|&lt;br /&gt;
  | 0| 0|     16Ko     |  | 0| 0|  0000 - 3FFF  |&lt;br /&gt;
  |--|--|--------------|  |--|--|---------------|&lt;br /&gt;
  | 0| 1|     16Ko     |  | 0| 1|  4000 - 7FFF  |&lt;br /&gt;
  |--|--|--------------|  |--|--|---------------|&lt;br /&gt;
  | 1| 0|     16Ko     |  | 1| 0|  8000 - BFFF  |&lt;br /&gt;
  |--|--|--------------|  |--|--|---------------|&lt;br /&gt;
  | 1| 1|     32Ko     |  | 1| 1|  C000 - FFFF  |&lt;br /&gt;
  '--'--'--------------'  '--'--'---------------'&lt;br /&gt;
&lt;br /&gt;
So, it's possible to use 32KB screen size (used for [[Programming:Overscan|overscan]]) by setting bits 11 and 10 both to 1 (of Register 12).&lt;br /&gt;
&lt;br /&gt;
== CRTC Differences ==&lt;br /&gt;
&lt;br /&gt;
In this section I will attempt to identify all the differences between each CRTC. &lt;br /&gt;
&lt;br /&gt;
The following tables list the functions that can be accessed for each type: &lt;br /&gt;
&lt;br /&gt;
Type 0&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''b1''||''b0''||''Function''||''Read/Write'' &lt;br /&gt;
|-&lt;br /&gt;
|0||0||Select internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|0||1||Write to selected internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|1||0||-||- &lt;br /&gt;
|-&lt;br /&gt;
|1||1||Read from selected internal 6845 register||Read only &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Type 1&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''b1''||''b0''||''Function''||''Read/Write'' &lt;br /&gt;
|-&lt;br /&gt;
|0||0||Select internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|0||1||Write to selected internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|1||0||Read Status Register||Read Only &lt;br /&gt;
|-&lt;br /&gt;
|1||1||Read from selected internal 6845 register||Read only &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Type 2&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''b1''||''b0''||''Function''||''Read/Write'' &lt;br /&gt;
|-&lt;br /&gt;
|0||0||Select internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|0||1||Write to selected internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|1||0||-||- &lt;br /&gt;
|-&lt;br /&gt;
|1||1||Read from selected internal 6845 register||Read only &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Type 3 and 4&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''b1''||''b0''||''Function''||''Read/Write'' &lt;br /&gt;
|-&lt;br /&gt;
|0||0||Select internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|0||1||Write to selected internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|1||0||Read from selected internal 6845 register||Read Only &lt;br /&gt;
|-&lt;br /&gt;
|1||1||Read from selected internal 6845 register||Read only &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It is not possible to read from all the internal registers, this table shows the read/write status of each register for each type: &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|rowspan=2|''Register Index''||rowspan=2|''Register Name''||colspan=4|''Type'' &lt;br /&gt;
|-&lt;br /&gt;
|0||1||2||3||4&lt;br /&gt;
|-&lt;br /&gt;
|0||Horizontal Total||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|1||Horizontal Displayed||Write Only||Write Only||Write Only||(note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|2||Horizontal Sync Position||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|3||Horizontal and Vertical Sync Widths||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|4||Vertical Total||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|5||Vertical Total Adjust||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|6||Vertical Displayed||Write Only||Write Only||Write Only||(note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|7||Vertical Sync position||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|8||Interlace and Skew||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|9||Maximum Raster Address||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|10||Cursor Start Raster||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|11||Cursor End Raster||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|12||Display Start Address (High)||Read/Write||Write Only||Write Only||Read/Write (note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|13||Display Start Address (Low)||Read/Write||Write Only||Write Only||Read/Write (note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|14||Cursor Address (High)||Read/Write||Read/Write||Read/Write||Read/Write (note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|15||Cursor Address (Low)||Read/Write||Read/Write||Read/Write||Read/Write (note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|16||Light Pen Address (High)||Read Only||Read Only||Read Only||Read Only (note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|17||Light Pen Address (Low)||Read Only||Read Only||Read Only||Read Only (note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Notes'''&lt;br /&gt;
&lt;br /&gt;
1. On type 0 and 1, if a Write Only register is read from, &amp;quot;0&amp;quot; is returned. &lt;br /&gt;
&lt;br /&gt;
2. See the document &amp;quot;Extra CPC Plus Hardware Information&amp;quot; for more details.&lt;br /&gt;
&lt;br /&gt;
3. CRTC type 4 is the same as CRTC type 3. The registers also repeat as they do on the type 3.&lt;br /&gt;
&lt;br /&gt;
== Horizontal and Vertical Sync (R3) ==&lt;br /&gt;
&lt;br /&gt;
UM6845:&lt;br /&gt;
&lt;br /&gt;
Bits 7..4 define Vertical Sync Width. If 0 is programmed this gives 16 lines of VSYNC.&lt;br /&gt;
Bits 3..0 define Horizontal Sync Width. If 0 is programmed no HSYNC is generated.&lt;br /&gt;
&lt;br /&gt;
UM6845R:&lt;br /&gt;
&lt;br /&gt;
Bits 7..4 are ignored. Vertical Sync is fixed at 16 lines.&lt;br /&gt;
Bits 3..0 define Horizontal Sync Width. If 0 is programmed no HSYNC is generated.&lt;br /&gt;
&lt;br /&gt;
MC6845:&lt;br /&gt;
&lt;br /&gt;
Bits 7..4 are ignored. Vertical Sync is fixed at 16 lines.&lt;br /&gt;
Bits 3..0 define Horizontal Sync Width. If 0 is programmed this gives a HSYNC width of 16.&lt;br /&gt;
&lt;br /&gt;
Pre-ASIC/ASIC:&lt;br /&gt;
&lt;br /&gt;
Bits 7..4 define Vertical Sync Width. If 0 is programmed this gives 16 lines of VSYNC.&lt;br /&gt;
Bits 3..0 define Horizontal Sync Width. If 0 is programmed this gives a HSYNC width of 16.&lt;br /&gt;
&lt;br /&gt;
== UM6845R and R31 ==&lt;br /&gt;
&lt;br /&gt;
R31 is described in the UM6845R documentation as &amp;quot;Dummy Register&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Its use is described in the documentation for the Rockwell R6545 in combination with R18, R19 and R8 and the Status Register.&lt;br /&gt;
&lt;br /&gt;
In the UM6845R it appears to have no effect. Reading and writing does nothing. Reading it returns 0x0ff.&lt;br /&gt;
&lt;br /&gt;
R31 doesn't exist on types 0,2,3.&lt;br /&gt;
&lt;br /&gt;
== UM6845R and R12/R13 ==&lt;br /&gt;
&lt;br /&gt;
The UM6845R differs to other CRTC in respect of R12/R13. &lt;br /&gt;
&lt;br /&gt;
When VCC=0, R12/R13 is re-read at the start of each line. R12/R13 can therefore be changed for each scanline when VCC=0. &lt;br /&gt;
&lt;br /&gt;
Just like other CRTCs when RC==(R9-1), the current MA is captured for the next char-line.&lt;br /&gt;
&lt;br /&gt;
In demos to make a display compatible with all CRTCs program R12/R13 when VCC!=0. This will then take effect at the next frame start.&lt;br /&gt;
&lt;br /&gt;
== UM6845R status register ==&lt;br /&gt;
&lt;br /&gt;
The UM6845R has a status register that can be read using port &amp;amp;BExx.&lt;br /&gt;
&lt;br /&gt;
Bit 6 is set to 1 if there is a strobe input to the /LPEN signal. It is cleared to 0 when either R17 or R16 (LPEN address) of the CRTC are read. It signals there is a valid LPEN input. On my CPC (arnoldemu) with UM6845R, it is triggered at power on, R17 and R16 have the values 0 when read.&lt;br /&gt;
&lt;br /&gt;
Bit 5 is set to 1 when CRTC is in &amp;quot;vertical blanking&amp;quot;. Vertical blanking is when the vertical border is active. i.e. VCC&amp;gt;=R6. &lt;br /&gt;
&lt;br /&gt;
It is cleared when the frame is started (VCC=0). It is not directly related to the DISPTMG output (used by the CPC to display the border colour) because that output is a combination of horizontal and vertical blanking.&lt;br /&gt;
This bit will be 0 when pixels are being displayed.&lt;br /&gt;
&lt;br /&gt;
All the other bits read as 0 and don't have any function.&lt;br /&gt;
&lt;br /&gt;
== Datasheets ==&lt;br /&gt;
&lt;br /&gt;
* [[Media:hd6845.hitachi.pdf|HD6845S (Hitachi) (aka type 0)]]&lt;br /&gt;
* [[Media:Um6845.umc.pdf|UM6845 (UMC)  (aka type 0)]]&lt;br /&gt;
* [[Media:Um6845r.umc.pdf|UM6845R (UMC)  (aka type 1)]]&lt;br /&gt;
* [[Media:Mc6845.motorola.pdf|MC6845 (Motorola) (aka type 2)]]&lt;br /&gt;
&lt;br /&gt;
* [[VHDL implementation of the 6845]]&lt;br /&gt;
&lt;br /&gt;
== Clones ==&lt;br /&gt;
* [CM607P   a Bulgarian clone made in Pravetz factory]&lt;br /&gt;
* [EF6845P  by Thomson Semiconductors]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools about CRTC ==&lt;br /&gt;
&lt;br /&gt;
*  [http://www.cpcwiki.eu/imgs/9/99/Elmar_Krieger-SPECIAL_EFFECTS.dsk  some BASIC tools to detect CRTC types 0-1-2 and show some effects - by [[Elmar Krieger]] ]     (DSK for Emulators)&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/6845 Wikipedia on the CRTC]&lt;br /&gt;
* [http://www.grimware.org/doku.php/documentations/devices/crtc CRTCs on grimware]&lt;br /&gt;
&lt;br /&gt;
==Related pages==&lt;br /&gt;
&lt;br /&gt;
*[[Gate Array]]&lt;br /&gt;
&lt;br /&gt;
*[[ASIC]]&lt;br /&gt;
&lt;br /&gt;
*[[Video modes]]&lt;br /&gt;
&lt;br /&gt;
*[[Synchronising with the CRTC and display]] : technic and details on the relationship between Gate Array and CRTC.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]] [[Category:CPC Internal Components]] [[Category:Programming]] [[Category:Datasheet]] [[Category:Graphic]]&lt;/div&gt;</summary>
		<author><name>Thomasharte</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=8255&amp;diff=98441</id>
		<title>8255</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=8255&amp;diff=98441"/>
				<updated>2017-08-07T23:40:10Z</updated>
		
		<summary type="html">&lt;p&gt;Thomasharte: There's no apostrophe for ownership on 'its' (or the other personal pronouns — hers, yours, etc — other than one's)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== 8255 Part numbers used in the CPC during its lifetime ==&lt;br /&gt;
&lt;br /&gt;
* NEC D8255AC-2&lt;br /&gt;
* NEC D8255AC-5&lt;br /&gt;
* Toshiba TMP8255AP-5&lt;br /&gt;
&lt;br /&gt;
All of these are almost identical in their operation. It is possible to detect each version by writing and then reading from the ppi control i/o port. Each can give a different pattern of values that are read back.&lt;br /&gt;
&lt;br /&gt;
== The 8255 in the CPC ==&lt;br /&gt;
&lt;br /&gt;
The [[8255 PPI chip]] is a general purpose input/output IC. This document will describe its role in the Amstrad CPC, CPC+ and KC compact systems. To understand its full functions please read the datasheet.&lt;br /&gt;
&lt;br /&gt;
In these systems it is connected to the AY-3-8912 Programmable Sound Generator (PSG), keyboard, cassette recorder, the VSYNC of the 6845 CRTC and the &amp;quot;busy&amp;quot; signal from the parallel port.&lt;br /&gt;
&lt;br /&gt;
The PPI is selected when A11 of the I/O port address is set to &amp;quot;0&amp;quot;, A9 and A8 then define the PPI function access (as shown below), A15-A12 and A10 should be &amp;quot;1&amp;quot; (to prevent conflicts with other hardware), A7-A0 are don't care. So, resulting Port addresses are: &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''I/O address''||''A9''||''A8''||''Description''||''Read/Write status''||''Used Direction''||''Used for''&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;F4xx||0||0||Port A Data||Read/Write||In/Out||[[PSG]] (Sound/Keyboard/Joystick)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;F5xx||0||1||Port B Data||Read/Write||In||Vsync/Jumpers/PrinterBusy/CasIn/Exp&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;F6xx||1||0||Port C Data||Read/Write||Out||KeybRow/CasOut/PSG&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;F7xx||1||1||Control||Write Only||Out||Control&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the CPC+, the 8255 is integrated into the ASIC. The &amp;quot;emulation&amp;quot; is not complete and some functionality is not available. Please see the &amp;quot;Extra CPC+ documentation&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
* Mode 1 (Strobed Input/Output) and Mode 2 (Bi-Directional Bus), as far as I know, are not used by any program, Mode 0 (Basic Input/Output) is always used.&lt;br /&gt;
&lt;br /&gt;
== Port Usage ==&lt;br /&gt;
&lt;br /&gt;
* NOTE - If you are using the firmware, always return the operating modes and I/O state of the ports used to their settings below. The firmware expects the settings to be the same as given below and may operate incorrectly if they are not. &lt;br /&gt;
&lt;br /&gt;
== PPI Port A ==&lt;br /&gt;
&lt;br /&gt;
Operating system settings:&lt;br /&gt;
* I/O Mode 0,&lt;br /&gt;
* For writing data to PSG all bits must be set to output,&lt;br /&gt;
* for reading data from PSG all bits must be set to input (thereafter, output direction should be restored, for compatibility with the BIOS). &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Bit''||''Description''||''Usage''&lt;br /&gt;
|-&lt;br /&gt;
|7-0||PSG.DATA||[[PSG]] Databus (Sound/Keyboard/Joystick)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== PPI Port B ==&lt;br /&gt;
&lt;br /&gt;
Operating system settings:&lt;br /&gt;
&lt;br /&gt;
* I/O Mode 0,&lt;br /&gt;
* Input &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Bit''||''Description''||''Usage in CPC''||''Usage in KC Compact''&lt;br /&gt;
|-&lt;br /&gt;
|7||CAS.IN||Cassette data input||Same as on CPC&lt;br /&gt;
|-&lt;br /&gt;
|6||PRN.BUSY||Parallel/Printer port ready signal, &amp;quot;1&amp;quot; = not ready, &amp;quot;0&amp;quot; = Ready||Same as on CPC&lt;br /&gt;
|-&lt;br /&gt;
|5||/EXP||Expansion Port /EXP pin||Same as on CPC&lt;br /&gt;
|-&lt;br /&gt;
|4||LK4||Screen Refresh Rate (&amp;quot;1&amp;quot;=50Hz, &amp;quot;0&amp;quot;=60Hz)||Set to &amp;quot;1&amp;quot;=50Hz (but ignored by the KC BIOS, which always uses 50Hz even if LK4 is changed)&lt;br /&gt;
|-&lt;br /&gt;
|3||LK3|| rowspan=&amp;quot;3&amp;quot; |3bit Distributor ID. Usually set to 4=[[Awa]], 5=[[Schneider]], or 7=[[Amstrad]], see [[LK-selectable Brand Names]] for details.||Purpose unknown (set to &amp;quot;1&amp;quot;)&lt;br /&gt;
|-&lt;br /&gt;
|2||LK2||Purpose unknown (set to &amp;quot;0&amp;quot;)&lt;br /&gt;
|-&lt;br /&gt;
|1||LK1||Expansion Port /TEST pin&lt;br /&gt;
|-&lt;br /&gt;
|0||[[CRTC]] VSYNC||Vertical Sync (&amp;quot;1&amp;quot;=VSYNC active, &amp;quot;0&amp;quot;=VSYNC inactive)||Same as on CPC&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* LK1-4 are links on the mainboard (&amp;quot;0&amp;quot; bits are wired to GND). On CPC464,CPC664,CPC6128 and GX4000 they are labeled LK1-LK4, on the CPC464+ and CPC6128+ they are labeled LK101-LK103 (and LK104, presumably?).&lt;br /&gt;
&lt;br /&gt;
* Bit5 (/EXP) can be used by a expansion device to report its presence. &amp;quot;1&amp;quot; = device connected, &amp;quot;0&amp;quot; = device not connected. This is not always used by all expansion devices. ''is it used by any expansions?'' [in the DDI-1 disc interface, /EXP connects to the ROM bank selection, bank 0 or bank 7]&lt;br /&gt;
&lt;br /&gt;
* If port B is programmed as an output, you can make a fake vsync visible to the Gate-Array by writing 1 to bit 0. You can then turn it off by writing 0 to bit 0. It is fake in the sense that it is not generated by the CRTC as it normally is. This fake vsync doesn't work on all CPCs. It is not known if it is dependent on CRTC or 8255 or both.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* For more info on LK1-LK4 (and further LKs) see [[LK Links]]&lt;br /&gt;
&lt;br /&gt;
== PPI Port C ==&lt;br /&gt;
&lt;br /&gt;
Operating system settings:&lt;br /&gt;
&lt;br /&gt;
* upper: I/O Mode 0, lower: I/O mode 0,&lt;br /&gt;
* upper: output, lower: output &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Bit''||''Description''||''Usage''&lt;br /&gt;
|-&lt;br /&gt;
|7||PSG BDIR||PSG function selection&lt;br /&gt;
|-&lt;br /&gt;
|6||PSG BC1||&lt;br /&gt;
|-&lt;br /&gt;
|5||Cassette Write data||Cassette Out (sometimes also used as Printer Bit7, see [[8bit Printer Ports]])&lt;br /&gt;
|-&lt;br /&gt;
|4||Cassette Motor Control||set bit to &amp;quot;1&amp;quot; for motor on, or &amp;quot;0&amp;quot; for motor off&lt;br /&gt;
|-&lt;br /&gt;
|3||rowspan=4|Keyboard line||rowspan=4|Select keyboard line to be scanned (0-15)&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
PSG function selection:&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Bit 7''||''Bit 6''||''Function''&lt;br /&gt;
|-&lt;br /&gt;
|0||0||Inactive&lt;br /&gt;
|-&lt;br /&gt;
|0||1||Read from selected PSG register&lt;br /&gt;
|-&lt;br /&gt;
|1||0||Write to selected PSG register&lt;br /&gt;
|-&lt;br /&gt;
|1||1||Select PSG register&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== PPI Control ==&lt;br /&gt;
&lt;br /&gt;
This register has two different functions depending on bit7 of the data written to this register.&lt;br /&gt;
&lt;br /&gt;
=== PPI Control with Bit7=1 ===&lt;br /&gt;
If Bit 7 is &amp;quot;1&amp;quot; then the other bits will initialize Port A-B as Input or Output:&lt;br /&gt;
&lt;br /&gt;
  Bit 0    IO-Cl    Direction for Port C, lower bits (always 0=Output in CPC)&lt;br /&gt;
  Bit 1    IO-B     Direction for Port B             (always 1=Input in CPC)&lt;br /&gt;
  Bit 2    MS0      Mode for Port B and Port Cl      (always zero in CPC)&lt;br /&gt;
  Bit 3    IO-Ch    Direction for Port C, upper bits (always 0=Output in CPC)&lt;br /&gt;
  Bit 4    IO-A     Direction for Port A             (0=Output, 1=Input)&lt;br /&gt;
  Bit 5,6  MS0,MS1  Mode for Port A and Port Ch      (always zero in CPC)&lt;br /&gt;
  Bit 7    SF       Must be &amp;quot;1&amp;quot; to setup the above bits&lt;br /&gt;
&lt;br /&gt;
* CAUTION: Writing to PIO Control Register (with Bit7 set), automatically resets PIO Ports A,B,C to 00h each!&lt;br /&gt;
* In the CPC only Bit 4 is of interest, all other bits are always having the same value. In order to write to the PSG sound registers, a value of 82h must be written to this register. In order to read from the keyboard (through PSG register 0Eh), a value of 92h must be written to this register.&lt;br /&gt;
&lt;br /&gt;
=== PPI Control with Bit7=0 ===&lt;br /&gt;
Otherwise, if Bit 7 is &amp;quot;0&amp;quot; then the register is used to set or clear a single bit in Port C:&lt;br /&gt;
&lt;br /&gt;
  Bit 0    B        New value for the specified bit (0=Clear, 1=Set)&lt;br /&gt;
  Bit 1-3  N0,N1,N2 Specifies the number of a bit (0-7) in Port C&lt;br /&gt;
  Bit 4-6  -        Not Used&lt;br /&gt;
  Bit 7    SF       Must be &amp;quot;0&amp;quot; in this case&lt;br /&gt;
&lt;br /&gt;
== Programming Examples ==&lt;br /&gt;
&lt;br /&gt;
1. Using the control byte&lt;br /&gt;
&lt;br /&gt;
* Setting bit 7 of port C to 1,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            LD B,&amp;amp;F7                ;8255 Control port&lt;br /&gt;
            LD A,%00001111          ;Bit Set/reset function&lt;br /&gt;
            OUT (C),A               ;Send it to 8255&lt;br /&gt;
            RET&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Set port A to input, operating in mode 0, port B to output, operating in mode 0 and port C to input, operating in mode 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            LD B,&amp;amp;F7                ;8255 Control port&lt;br /&gt;
            LD A,%10011001          ;Configuration function&lt;br /&gt;
            OUT (C),A               ;Send it to 8255&lt;br /&gt;
            RET&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Using port A/B/C,&lt;br /&gt;
&lt;br /&gt;
In this example, port A is set to output, port B is set to input, and port C is set to output, and they are all operating in mode 0.&lt;br /&gt;
&lt;br /&gt;
We will only be using port A for these examples.&lt;br /&gt;
* Reading from port A,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
                                    ;Set port A to input&lt;br /&gt;
&lt;br /&gt;
            LD B,&amp;amp;F7                ;8255 Control port&lt;br /&gt;
            LD A,%10010010          ;Configuration function&lt;br /&gt;
            OUT (C),A               ;Send to 8255&lt;br /&gt;
&lt;br /&gt;
            LD B,&amp;amp;F4                ;Port A port address&lt;br /&gt;
            IN E,(C)                ;Get byte from port&lt;br /&gt;
&lt;br /&gt;
                                    ;Register E holds value from port&lt;br /&gt;
&lt;br /&gt;
                                    ;Return port I/O status and operating modes&lt;br /&gt;
                                    ;to previous settings.&lt;br /&gt;
&lt;br /&gt;
            LD B,&amp;amp;F7                ;8255 Control port&lt;br /&gt;
            LD A,%10000010          ;Configuration function&lt;br /&gt;
            OUT (C),A               ;Send to 8255&lt;br /&gt;
            RET&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Writing to port A,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
                                    ;Set port A to output&lt;br /&gt;
&lt;br /&gt;
                                    ;(Note the next few lines are not necessary&lt;br /&gt;
                                    ;as port A is already acting as output, however&lt;br /&gt;
                                    ;it is given here just to make the example&lt;br /&gt;
                                    ;more understandable)&lt;br /&gt;
&lt;br /&gt;
            LD B,&amp;amp;F7                ;8255 Control port&lt;br /&gt;
            LD A,%10000010          ;Configuration function&lt;br /&gt;
            OUT (C),A               ;Send to 8255&lt;br /&gt;
&lt;br /&gt;
            LD B,&amp;amp;F4                ;port A port address&lt;br /&gt;
&lt;br /&gt;
                                    ;Register E holds value to put into port&lt;br /&gt;
&lt;br /&gt;
            LD E,&amp;amp;FF                ;Data to put into port&lt;br /&gt;
            OUT (C),A               ;Send to port A&lt;br /&gt;
&lt;br /&gt;
                                    ;Return port I/O status and operating modes&lt;br /&gt;
                                    ;to previous settings.&lt;br /&gt;
&lt;br /&gt;
            LD B,&amp;amp;F7                ;8255 Control port&lt;br /&gt;
            LD A,%10000010          ;Configuration function&lt;br /&gt;
            OUT (C),A&lt;br /&gt;
            RET&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Diagrams =&lt;br /&gt;
&lt;br /&gt;
[[Image:8255 ppi 1.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[Image:8255 ppi 2.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Resources =&lt;br /&gt;
&lt;br /&gt;
* [[Media:PPI M5L8255AP-5.pdf]] PPI Datasheet (Mitsubishi)&lt;br /&gt;
* [[VHDL implementation of the 8255 PIO]]&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Intel_8255 Wikipedia about the 8255ppi]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Electronic Component]][[Category:CPC Internal Components]][[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Thomasharte</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=CPC_old_generation&amp;diff=98421</id>
		<title>CPC old generation</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=CPC_old_generation&amp;diff=98421"/>
				<updated>2017-08-04T20:01:59Z</updated>
		
		<summary type="html">&lt;p&gt;Thomasharte: /* The 3&amp;quot; floppy disk drives */ the +3 wasn't produced by Sinclair. It was launched in 1987, a year after Amstrad's acquisition of the Spectrum&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Hardware|*]][[Category:CPC Internal Components| ]][[Category:CPC History|*]][[Category:Amstrad Products| ]]&lt;br /&gt;
&lt;br /&gt;
[[Image:464.png|thumb|CPC 464 with Colour monitor]]&lt;br /&gt;
[[Image:Schneider 664 en.jpg|thumb|German CPC 664]]&lt;br /&gt;
&lt;br /&gt;
''The following text was copied in part from the [http://en.wikipedia.org/wiki/Amstrad_CPC English Wikipedia article].''&lt;br /&gt;
&lt;br /&gt;
==Hardware description==&lt;br /&gt;
All CPC models were based on a Zilog Z80 processor clocked at 4 MHz. Because a common pool of RAM is shared with the video circuits, the Z80 may only make a memory access once every four cycles, which has the effect of rounding all instruction cycle lengths up to the next multiple of four. For details, see [http://www.grimware.org/doku.php/documentations/devices/z80 a nearly complete list of instructions with timings (number of cycles) for each.]&lt;br /&gt;
&lt;br /&gt;
The system came with 64 KB or 128 KB of RAM depending on the model (capable of being expanded to more). The machines also featured a standard 9-pin Atari-style joystick socket which was able to take two joysticks via a splitter.&lt;br /&gt;
&lt;br /&gt;
The machines' dimensions are:&lt;br /&gt;
*'''CPC464''' : 17 x 57.5 x 7.5&lt;br /&gt;
*'''CPC6128''' : 17.5 x 51.1 x 5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Video (graphics): modes, outputs===&lt;br /&gt;
Underlying the CPC's video output was the [[CRTC|Motorola 6845]] address generator. This chip was connected to a pixel generator that supported 4 bpp, 2 bpp and 1 bpp output (bits per pixel). The address generator was clocked at a constant rate so the 4 bpp display generated half as many pixels as the 2 bpp and a quarter as many as the 1 bpp.&lt;br /&gt;
&lt;br /&gt;
The ROM featured three built-in display resolutions but many others could be achieved by reprogramming the 6845.&lt;br /&gt;
&lt;br /&gt;
The standard [[video modes]] were:&lt;br /&gt;
*'''Mode 0''': '''160×200''' pixels with 16 colours (4 bpp)&lt;br /&gt;
*'''Mode 1''': '''320×200''' pixels with 4 colours (2 bpp)&lt;br /&gt;
*'''Mode 2''': '''640×200''' pixels with 2 colours (1 bpp)&lt;br /&gt;
*'''Mode 3''': '''160×200''' pixels with 4 colours (2 bpp) (this is not an official mode, but rather a side-effect of the hardware)&lt;br /&gt;
&lt;br /&gt;
A colour palette of 27 colours was supported, derived from RGB colour space with each component assigned as either off, half on or on. The later '''Plus''' models extended this to 4096 colours and added support for hardware sprites.&lt;br /&gt;
&lt;br /&gt;
This hardware compares well with the other 8-bit computers. In particular the CPC lacks the colour clash of the ZX Spectrum, and clever programming of the 6845 could produce overscan, different resolutions (although with the same pixel density) and smooth pixel scrolling.&lt;br /&gt;
&lt;br /&gt;
The machine lacked either a RF TV or composite video output and instead shipped with a proprietary 5-pin DIN connector intended for use solely with the supplied Amstrad monitor. An external adapter for RF TV was available to be bought separately.&lt;br /&gt;
&lt;br /&gt;
The five-pin DIN connector is capable of driving a television with a correctly wired SCART lead.&lt;br /&gt;
&lt;br /&gt;
===Audio (sound)===&lt;br /&gt;
The CPC used the General Instrument AY-3-8912 sound chip, providing three channels, each configurable to generate square waves, white noise or both. A small array of hardware volume envelopes are available.&lt;br /&gt;
&lt;br /&gt;
Output was provided in mono by a small (4 cm) built-in loudspeaker with volume control, driven by an unusually powerful amplifier. Stereo output was provided through a 3.5mm headphone jack, not present on some early CPC464 models. In those models, what looked like a standard 3.5&amp;quot; headphone jack was actually used for connecting an external tape recorder, although later models used a five-pin DIN connector for the same purpose.&lt;br /&gt;
&lt;br /&gt;
Playback of digital sound samples at a resolution of a little better than 5-bit, as heard on the title screen of the game ''RoboCop'', was possible through clever programming of the sound chip. This trick was very processor intensive and hard to combine with any other processing.&lt;br /&gt;
&lt;br /&gt;
===The 3&amp;quot; floppy disk drives===&lt;br /&gt;
Amstrad's idiosyncratic choice of Hitachi's 3&amp;quot; floppy disk drive, when the rest of the PC industry was moving to Sony's 3.5&amp;quot; format, is often claimed to be due to Amstrad bulk-buying a large consignment of 3&amp;quot; drive units in Asia. The cheapest drive (built-in in later models) was a single-sided 40-track unit that required the user to physically remove and flip the disk to access both sides. Each side had its own independent write-protect switch. The sides were termed &amp;quot;A&amp;quot; and &amp;quot;B&amp;quot;, with each one holding 180KB (178KB in AMSDOS format) for a total of 360KB per disc.  &lt;br /&gt;
&lt;br /&gt;
The disk drive interface was a NEC 765 FDC, used for the same purpose in the IBM PC/XT, PC/AT and PS/2 machines. Many of its features were unused in order to cut costs, namely DMA transfers and support for single density disks. Disks were formatted as double density using Modified Frequency Modulation. &lt;br /&gt;
&lt;br /&gt;
Disks were shipped in a paper sleeve or a hard plastic case resembling a compact disc &amp;quot;jewel&amp;quot; case. The casing is thicker and more rigid than that of 3.5&amp;quot; diskettes and the sliding metal cover to protect the media surface is internal to the casing and latched, unlike the simple external sliding cover of Sony's version (some reviews at the time reported driving over them with no problems). Because of this they were significantly more expensive than both the 5.25&amp;quot; and 3.5&amp;quot; alternatives. This, combined with their low nominal capacities and their essentially proprietary nature, lead to the format being discontinued when the CPC itself was discontinued.&lt;br /&gt;
&lt;br /&gt;
Apart from Amstrad's other 3&amp;quot; machines, the PCW and the ZX Spectrum +3 (produced by Amstrad after their acquisition of the Spectrum from Sinclair), the only other computer systems to use them were the Sega SF-7000 and mostly obscure and exotic CP/M systems such as the Tatung Einstein and Osborne machines. It should be noted that some of these machines used drives with different pinouts and care should be taken when replacing drives.&lt;br /&gt;
&lt;br /&gt;
The data formatting of 3&amp;quot; disks was very similar to that of 5&amp;amp;frac14;&amp;quot; disks, and the Amstrad CPC machines were able to use 5&amp;amp;frac14;&amp;quot; drives through their &amp;quot;external drive&amp;quot; port - either one specially designed for use by the CPC or an adapted IBM-PC drive.&lt;br /&gt;
&lt;br /&gt;
A more popular alternative was to attach an adapted IBM-PC 3&amp;amp;frac12;&amp;quot; drive for operation in either single-sided 180 KB or double-sided 360 KB mode, although with the later availability of the PARADOS Disc Operating System, 720k per disc became available. (It was possible to patch CP/M Plus so that it recognised 80 track double sided disk formats, too.)&lt;br /&gt;
&lt;br /&gt;
===Serial port adaptor===&lt;br /&gt;
An official RS-232-C D25 serial port adaptor was produced that attached to the expansion connector at the rear of the machine, and had a through-connector for the CPC464 disk drive or other peripherals. The adaptor came with a &amp;quot;''Book of Spells''&amp;quot; for facilitating data transfer between other systems using a proprietary protocol in the device's own ROM, as well as terminal software to connect to British Telecom's Prestel service. A separate version of the ROM was created for the U.S. market due to the use of the commands &amp;quot;SUCK&amp;quot; and &amp;quot;BLOW&amp;quot;, which were considered unacceptable there.&lt;br /&gt;
&lt;br /&gt;
===Similarities to the BBC Micro===&lt;br /&gt;
The CPC has been termed an &amp;quot;improved Z80 implementation of the (earlier) BBC Micro&amp;quot; due to similarities in firmware and hardware. Both used the Motorola 6845 video address generator and the two have very similar sound output chips - the General Instrument AY-3-8912 in the CPC provided three tone channels each optionally with added noise and the Texas Instruments SN76489 in the BBC offered three tone channels and one exclusive noise channel.&lt;br /&gt;
&lt;br /&gt;
The BBC Micro used an Intel 8271 floppy disc controller. The CPC used the Intel 8272, which is similar to the 8271 but contains the addition of a double density (MFM) mode.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;two cursor&amp;quot; BASIC editing system seen on the Amstrad CPC (whereby holding Shift and using the cursor keys moves a shadow text cursor allowing text to be copied from another area of the screen to the normal cursor) was a lift from BBC BASIC, albeit substantially improved by allowing free movement of the normal cursor.&lt;br /&gt;
&lt;br /&gt;
Both systems provided similar systems of full hardware abstraction through Operating System calls. This saves programs which don't require time critical hardware access from having to touch the underlying machine and provides a level of machine portability for those programs.&lt;br /&gt;
&lt;br /&gt;
As the CPC had its own dialect of [[BASIC]], namely [[Locomotive BASIC]], so the BBC Micro has its own version named [[BBC BASIC]]. BBC BASIC evolved with subsequent models of BBC computers and with Acorn's next system, the Archimedes. Both had their own sets of advantages: Locomotive BASIC was faster in many contexts, had native support for text windows, had more comprehensive commands for manipulating sound, ''etc.''; BBC BASIC had support for procedures (rather than just arithmetic functions), an inline assembler, and others. Of note is the fact that among the numerous [http://www.bbcbasic.co.uk/bbcbasic.html ports of BBC Basic] produced by the company [http://www.rtrussell.co.uk/ R.T. Russell] is a version especially adapted for the Amstrad CPC, including support for its specific graphics and sound capabilities; there is also a generic version for [[CP/M]].&lt;br /&gt;
&lt;br /&gt;
==Software==&lt;br /&gt;
===Built-in BASIC and operating system===&lt;br /&gt;
Like most home computers at the time, the CPC had its OS and a BASIC interpreter built in as ROM. It used Locomotive BASIC - a variant specifically written for the CPC hardware which as a result was faster, more comfortable and more powerful than the generic but common Microsoft BASIC used by the Commodore 64 and MSX amongst others. It was particularly notable for providing easy access to the machine's video and audio resources in contrast to the arcane POKE commands required on some Microsoft implementations (the MSX implementation of Microsoft Basic being an exception, which even allowed for hardware sprite manipulation and collision detection).&lt;br /&gt;
&lt;br /&gt;
===Other languages===&lt;br /&gt;
Although it was possible to obtain compilers for Locomotive BASIC, BCPL, C, Forth, and Turbo Pascal the majority of the CPC's software was written in native Z80 assembly language.&lt;br /&gt;
&lt;br /&gt;
An interpreter for the educational language LOGO was also supplied with the 664 and 6128 (and available for the 464 with purchase of an external disc drive).&lt;br /&gt;
&lt;br /&gt;
==What was in the box?==&lt;br /&gt;
&lt;br /&gt;
=== CPC464 ===&lt;br /&gt;
&lt;br /&gt;
* The computer itself, including built-in [[Datacorder]]&lt;br /&gt;
* [[Demostration tape or disc|Demonstration tape]] in local language (UK, Germany, France, Spain)&lt;br /&gt;
* [[User Manual]]&lt;br /&gt;
* Either an [[Amstrad GT64/GT65 Green Monitor|Amstrad GT64 (Later: GT65) green monitor]] or an [[Amstrad CTM640/CTM644 Color Monitor|Amstrad CTM640 (Later: CTM644) Colour Monitor]]&lt;br /&gt;
* Optional: [[Amstrad MP1/MP2 modulator|Amstrad MP-1 (Later: MP-2) TV modulator and power supply]]&lt;br /&gt;
* A Gamepack consisting of 12 Amsoft Titles on Tape.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:CPC464_pcb_r1.jpg|CPC464 PCB revision 0 (original)&lt;br /&gt;
Image:CPC464_pcb_r3.jpg|CPC464 PCB revision 3 (costdown)&lt;br /&gt;
Image:CPC464_new_amstrad_logo.jpg|CPC464 (new Amstrad logo - photo from costdown model)&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== CPC472 ===&lt;br /&gt;
The CPC 472 was a spanish version of the CPC 464 with additional (nonfunctional) 8 KB RAM. The reason for this was that Amstrad wanted to circumvent a Spanish law that levied an extra tax for machines with 64KB or less of memory; thus, they upped the spec to 72KB by including an additional 8KB though this extra memory was not functional.&lt;br /&gt;
&lt;br /&gt;
* Amstrad CPC [[472]]&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:CPC_472_es.jpg|The CPC472&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
=== CPC664 ===&lt;br /&gt;
&lt;br /&gt;
* The computer itself, including built-in 3&amp;quot; disk drive&lt;br /&gt;
* [[System Disk]]: CP/M 2.2 disk with demo in local language (UK, Germany, France, Spain)&lt;br /&gt;
* [[User Manual]]&lt;br /&gt;
* Either an [[Amstrad GT64/GT65 Green Monitor|Amstrad GT65 green monitor]] or an [[Amstrad CTM640/CTM644 Color Monitor|Amstrad CTM644 Colour Monitor]]&lt;br /&gt;
* Optional: [[Amstrad MP1/MP2 modulator|Amstrad MP-2 TV modulator and power supply]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:664.jpg|The 664 in high-res&lt;br /&gt;
Image:CPC664_Top.jpg|CPC 664 Top&lt;br /&gt;
Image:CPC664_PCB_Top.jpg|CPC 664 Motherboard Top&lt;br /&gt;
Image:CPC664_PCB_Bottom.jpg|CPC 664 Motherboard Bottom&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Links ====&lt;br /&gt;
&lt;br /&gt;
* http://www.sellmyretro.com/ - Buy new keyboard membranes for CPC664 from RWAP software&lt;br /&gt;
* http://www.rwapsoftware.co.uk/ - RWAP Software, makers of membranes for Sinclair, Enterprise and CPC664&lt;br /&gt;
&lt;br /&gt;
=== CPC6128 ===&lt;br /&gt;
&lt;br /&gt;
* The computer itself, including built-in 3&amp;quot; disk drive&lt;br /&gt;
* [[System Disk]]s with CP/M Plus, CP/M 2.2 and a demo in local language (UK, Germany, France, Spain)&lt;br /&gt;
* [[User Manual]]&lt;br /&gt;
* Either an [[Amstrad GT64/GT65 Green Monitor|Amstrad GT65 green monitor]] or an [[Amstrad CTM640/CTM644 Color Monitor|Amstrad CTM644 Colour Monitor]]&lt;br /&gt;
* Optional: [[Amstrad MP1/MP2 modulator|Amstrad MP-2 TV modulator and power supply]]&lt;br /&gt;
* Later models came with the [[Amstrad PP8 Promotional Pack]] &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:CPC6128_Top.jpg|CPC 6128 Top&lt;br /&gt;
Image:CPC6128_PCB_Top_(Z70290_MC0020B).jpg|CPC 6128 Motherboard Top&lt;br /&gt;
Image:CPC6128_PCB_Bottom_(Z70290_MC0020B).jpg|CPC 6128 Motherboard Bottom&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== DDI-1 ===&lt;br /&gt;
&lt;br /&gt;
* Controller DDI-1&lt;br /&gt;
* 3&amp;quot; disk drive FD-1&lt;br /&gt;
* [[System Disk]]: CP/M 2.2 disk with demo&lt;br /&gt;
* [[User Manual]]&lt;br /&gt;
&lt;br /&gt;
==Others==&lt;br /&gt;
&lt;br /&gt;
* [[Keyboard Versions]]&lt;br /&gt;
* [[Mainboard Versions]]&lt;br /&gt;
* [[CPC6128_Keyboard_Disassembled]]&lt;br /&gt;
*[[CPC464 &amp;amp; CPC664_logos | CPC Case logos]]&lt;br /&gt;
&lt;br /&gt;
==Clones==&lt;br /&gt;
&lt;br /&gt;
See [[Clones]] for a list of classic and modern clones.&lt;/div&gt;</summary>
		<author><name>Thomasharte</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=Other_Computers:Other_Amstrad_products&amp;diff=98389</id>
		<title>Other Computers:Other Amstrad products</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Other_Computers:Other_Amstrad_products&amp;diff=98389"/>
				<updated>2017-08-02T20:11:21Z</updated>
		
		<summary type="html">&lt;p&gt;Thomasharte: Minor copy edits: a spelling correction, extra space removed, etc.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Thanks to the success of the CPC464 Amstrad was able to be a major part of the computer market in the '80s.&lt;br /&gt;
&lt;br /&gt;
*[[PCW]]: a revolutionary and fully equipped 8-bit word processor.&lt;br /&gt;
*[[Amstrad PC]]: the first &amp;quot;cheap&amp;quot; IBM PC compatible range.&lt;br /&gt;
*[[NC Series]]: a range of portable computers.&lt;br /&gt;
*[[ZX Spectrum]]: Amstrad bought Sinclair's computer brand and produced its own ZX Spectrum range from 1986.&lt;br /&gt;
&lt;br /&gt;
[[Category:Non CPC Computers]][[Category:Amstrad Products]][[Category:CPC History]]&lt;/div&gt;</summary>
		<author><name>Thomasharte</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=CRTC&amp;diff=98385</id>
		<title>CRTC</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=CRTC&amp;diff=98385"/>
				<updated>2017-08-01T15:37:10Z</updated>
		
		<summary type="html">&lt;p&gt;Thomasharte: /* Addressing */ the top two bits of MA are retained, not the almost-top-two.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* ''This is an article about the &amp;quot;Cathode Ray Tube Controller&amp;quot; hardware unit of the Amstrad CPC. For the cpc scene member see [[ChaRleyTroniC]]''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''CRTC''' (Cathode Ray Tube Controller) helps to generate the video signal of the Amstrad CPC.&lt;br /&gt;
&lt;br /&gt;
NOTE: This document describes the functionality in terms of the CPC with it's separate CRTC and Gate-Array. &lt;br /&gt;
The Plus has both integrated into the same IC, but could be considered to have 2 functional blocks, one for CRTC and one for Gate-Array. In this document Gate-Array is used, but this also applies to the ASIC.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The 6845 Cathode Ray Tube Controller (CRTC) is a programmable IC used to generate video displays. This IC is used in a variety of computers including the Amstrad CPC, Amstrad CPC+ and KC Compact. &lt;br /&gt;
&lt;br /&gt;
The CRTC was a common part available from many different manufacturers. During the life of the CPC, Amstrad sourced the CRTC from various manufacturers. &lt;br /&gt;
&lt;br /&gt;
All ICs used were based on the same design but have a different implementation. As a result they do not operate identically in all situations. This document highlights these differences. &lt;br /&gt;
&lt;br /&gt;
This table lists the known ICs used, with their part number, manufacturer and type number. &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Part number''||''Manufacturer''||''Type number (note 3)''&lt;br /&gt;
|-&lt;br /&gt;
|HD6845S||Hitachi||0&lt;br /&gt;
|-&lt;br /&gt;
|UM6845||UMC||0&lt;br /&gt;
|-&lt;br /&gt;
|UM6845R||UMC||1&lt;br /&gt;
|-&lt;br /&gt;
|MC6845||Motorola||2&lt;br /&gt;
|-&lt;br /&gt;
|AMS40489||Amstrad||3 (note 1)&lt;br /&gt;
|-&lt;br /&gt;
|40226||Amstrad||4 (note 2)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''NOTES''' &lt;br /&gt;
&lt;br /&gt;
1. The CRTC functionality is integrated into the CPC+ ASIC. This type exists only in the CPC464+,CPC6128+ and GX4000. &lt;br /&gt;
&lt;br /&gt;
2. This type exists in &amp;quot;cost-down&amp;quot; CPC464 and CPC6128 systems. In the &amp;quot;cost-down&amp;quot; the CRTC functionality is integrated into a single ASIC IC. This ASIC is often refered to as the &amp;quot;Pre-ASIC&amp;quot; because it preceeded the CPC+ ASIC. The CRTC functionality of the Pre-ASIC is almost identical to the CRTC within the ASIC.&lt;br /&gt;
 &lt;br /&gt;
3. In the Amstrad community each 6845 implementation has been assigned a type number. This type identifies a group of implementations which operate in exactly the same way. &lt;br /&gt;
&lt;br /&gt;
As far as I know, the type number system was originally used by demo programmers. &lt;br /&gt;
&lt;br /&gt;
It is possible to detect the 6845 present using software methods, and this is done to: &lt;br /&gt;
&lt;br /&gt;
* warn that the software was not designed for the detected 6845 and may function incorrectly, &lt;br /&gt;
* to adapt the software so that it will run with the detected 6845 &lt;br /&gt;
* In most cases, the type of the detected 6845 is reported. &lt;br /&gt;
&lt;br /&gt;
4. As far as I know, the KC compact used HD6845R only.&lt;br /&gt;
&lt;br /&gt;
== Timings and relating with Z80 instructions count ==&lt;br /&gt;
&lt;br /&gt;
Some informations like : how many Z80 instructions can I fit within a scan line ? Within a screen ? Etc... See http://www.cpcwiki.eu/forum/programming/frame-flyback-and-interrupts/msg25106/#msg25106&lt;br /&gt;
(To be extracted/edited to conform to wiki good practices).&lt;br /&gt;
&lt;br /&gt;
==Programming==&lt;br /&gt;
&lt;br /&gt;
The 6845 is selected when bit 14 of the I/O port address is set to &amp;quot;0&amp;quot;. Bit 9 and 8 of the I/O port address define the function to access. The remaining bits can be any value, but it is adviseable to set these to &amp;quot;1&amp;quot; to avoid conflict with other devices in the system.&lt;br /&gt;
&lt;br /&gt;
The recommended I/O port addresses are&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''I/O port address''||''Function''||''Read/Write''&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;BCxx||Select 6845 register||Write only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;BDxx||Write 6845 register data||Write only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;BExx||(note 1)||Read only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;BFxx||(note 1)||Read only&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''NOTE'''&lt;br /&gt;
&lt;br /&gt;
1. The function of these I/O ports is dependant on the CRTC type&lt;br /&gt;
 &lt;br /&gt;
2. If you perform an IN instruction to the select or write functions it will write data to the CRTC from the current data on the bus.&lt;br /&gt;
&lt;br /&gt;
==Addressing==&lt;br /&gt;
&lt;br /&gt;
The following table defines the generated memory address from the CRTC and Gate-Array signals. &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Memory Address Signal''||''Signal source''||''Signal name''&lt;br /&gt;
|-&lt;br /&gt;
|A15||6845||MA13 &lt;br /&gt;
|-&lt;br /&gt;
|A14||6845||MA12&lt;br /&gt;
|-&lt;br /&gt;
|A13||6845||RA2 &lt;br /&gt;
|-&lt;br /&gt;
|A12||6845||RA1 &lt;br /&gt;
|-&lt;br /&gt;
|A11||6845||RA0 &lt;br /&gt;
|-&lt;br /&gt;
|A10||6845||MA9 &lt;br /&gt;
|-&lt;br /&gt;
|A9||6845||MA8 &lt;br /&gt;
|-&lt;br /&gt;
|A8||6845||MA7 &lt;br /&gt;
|-&lt;br /&gt;
|A7||6845||MA6 &lt;br /&gt;
|-&lt;br /&gt;
|A6||6845||MA5 &lt;br /&gt;
|-&lt;br /&gt;
|A5||6845||MA4 &lt;br /&gt;
|-&lt;br /&gt;
|A4||6845||MA3 &lt;br /&gt;
|-&lt;br /&gt;
|A3||6845||MA2 &lt;br /&gt;
|-&lt;br /&gt;
|A2||6845||MA1 &lt;br /&gt;
|-&lt;br /&gt;
|A1||6845||MA0&lt;br /&gt;
|-&lt;br /&gt;
|A0||Gate-Array||CCLK&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
CRTC generates the address, Gate-Array reads the data and converts it to pixels based on the current mode.&lt;br /&gt;
&lt;br /&gt;
== DISPTMG ==&lt;br /&gt;
&lt;br /&gt;
DISPTMG signal defines the border. When DISPTMG is &amp;quot;1&amp;quot; the border colour is output by the Gate-Array to the display. The DISPTMG can be forced using R8 (DISPTMG Skew) on type 0,3 and 4 or by setting R6=0 on type 1. It is not possible to force the DISPTMG on type 2 or 5.&lt;br /&gt;
&lt;br /&gt;
The border has higher priority than pixels but lower priority than the black colour output when HSYNC/VSYNC are active.&lt;br /&gt;
&lt;br /&gt;
== HSYNC and VSYNC ==&lt;br /&gt;
&lt;br /&gt;
On CPC, HSYNC and VSYNC from the CRTC are passed into the Gate-Array.&lt;br /&gt;
&lt;br /&gt;
When HSYNC is active Gate-Array outputs the palette colour black. If the HSYNC is set to 14 characters then black will be output for 14us.&lt;br /&gt;
&lt;br /&gt;
The HSYNC is modified before being sent to the monitor. It  happens 2us after the HSYNC from the CRTC and lasts 4us when HSYNC length is greater or equal to 6. &lt;br /&gt;
&lt;br /&gt;
If R2=46, and HSYNC width is 14 then monitor hsync starts at 48 and lasts until 51.&lt;br /&gt;
&lt;br /&gt;
On a CPC monitor, the HSYNC is rendered in &amp;quot;absolute black&amp;quot;. It is darker than the black output by the Gate-Array.&lt;br /&gt;
&lt;br /&gt;
The VSYNC is also modified before being sent to the monitor. It happens two lines* after the VSYNC from the CRTC and stay two lines (same cut rule if VSYNC is lower than 4). PAL (50Hz) does need two lines VSYNC_width, and 4us HSYNC_width.&lt;br /&gt;
&lt;br /&gt;
Using CRTC1, VSYNC width value 0 means a value of 16.&lt;br /&gt;
&lt;br /&gt;
== The 6845 Registers ==&lt;br /&gt;
&lt;br /&gt;
The Internal registers of the 6845 are:&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''Register Index''||''Register Name''||''Range''||''CPC Setting''||''Notes''&lt;br /&gt;
|-&lt;br /&gt;
|0||Horizontal Total||00000000||63||Width of the screen, in characters. Should always be 63 (64 characters). 1 character == 1μs.&lt;br /&gt;
|-&lt;br /&gt;
|1||Horizontal Displayed||00000000||40||Number of characters displayed. Once horizontal character count (HCC) matches this value, DISPTMG is set to 1.&lt;br /&gt;
|-&lt;br /&gt;
|2||Horizontal Sync Position||00000000||46||When to start the HSync signal.&lt;br /&gt;
|-&lt;br /&gt;
|3||Horizontal and Vertical Sync Widths||VVVVHHHH||128+14||HSync pulse width in characters (0 means 16 on some CRTC), should always be more than 8; VSync width in scan-lines. (0 means 16 on some CRTC. Not present on all CRTCs, fixed to 16 lines on these)&lt;br /&gt;
|-&lt;br /&gt;
|4||Vertical Total||x0000000||38||Height of the screen, in characters.&lt;br /&gt;
|-&lt;br /&gt;
|5||Vertical Total Adjust||xxx00000||0||Measured in scanlines, can be used for smooth vertical scrolling on CPC.&lt;br /&gt;
|-&lt;br /&gt;
|6||Vertical Displayed||x0000000||25||Height of displayed screen in characters. Once vertical character count (VCC) matches this value, DISPTMG is set to 1.&lt;br /&gt;
|-&lt;br /&gt;
|7||Vertical Sync position||x0000000||30||When to start the VSync signal, in characters.&lt;br /&gt;
|-&lt;br /&gt;
|8||Interlace and Skew||xxxxxx00||0||00: No interlace; 01: Interlace Sync Raster Scan Mode; 10: No Interlace; 11: Interlace Sync and Video Raster Scan Mode&lt;br /&gt;
|-&lt;br /&gt;
|9||Maximum Raster Address||xxx00000||7||Maximum scan line address on CPC can hold between 0 and 7, higher values' upper bits are ignored&lt;br /&gt;
|-&lt;br /&gt;
|10||Cursor Start Raster||xBP00000||0||Cursor not used on CPC. B = Blink On/Off; P = Blink Period Control (Slow/Fast). Sets first raster row of character that cursor is on to invert.&lt;br /&gt;
|-&lt;br /&gt;
|11||Cursor End Raster||xxx00000||0||Sets last raster row of character that cursor is on to invert&lt;br /&gt;
|-&lt;br /&gt;
|12||Display Start Address (High)||xx000000||32&lt;br /&gt;
|-&lt;br /&gt;
|13||Display Start Address (Low)||00000000||0||Allows you to offset the start of screen memory for hardware scrolling, and if using memory from address &amp;amp;0000 with the firmware.&lt;br /&gt;
|-&lt;br /&gt;
|14||Cursor Address (High)||xx000000||0&lt;br /&gt;
|-&lt;br /&gt;
|15||Cursor Address (Low)||00000000||0&lt;br /&gt;
|-&lt;br /&gt;
|16||Light Pen Address (High)||xx000000||||Read Only&lt;br /&gt;
|-&lt;br /&gt;
|17||Light Pen Address (Low)||00000000||||Read Only&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
registers 18-31 read as 0, on type 0 and 2.&lt;br /&gt;
registers 18-30 read as 0 on type1, register 31 reads as 0x0ff.&lt;br /&gt;
&lt;br /&gt;
Details about Reg. 12 and Reg. 13 specifically:&lt;br /&gt;
&lt;br /&gt;
  .------- REG 12 --------.   .------- REG 13 --------.&lt;br /&gt;
  |                       |   |                       |&lt;br /&gt;
   15 14 13 12 11 10 09 08     07 06 05 04 03 02 01 00&lt;br /&gt;
  .--.--.--.--.--.--.--.--.   .--.--.--.--.--.--.--.--.&lt;br /&gt;
  |X |X |  |  |  |  |  |  |   |  |  |  |  |  |  |  |  |&lt;br /&gt;
  '--'--'--'--'--'--'--'--'   '--'--'--'--'--'--'--'--'&lt;br /&gt;
        '--.--'--.--'---------------.-----------------'&lt;br /&gt;
           |     |                  |&lt;br /&gt;
           |     |                  '------&amp;gt; Offset for setting&lt;br /&gt;
           |     |                           videoram &lt;br /&gt;
           |     |                           (1024 positions)&lt;br /&gt;
           |     |                           Bits 0..9&lt;br /&gt;
           |     |&lt;br /&gt;
           |     '-------------------------&amp;gt; Video Buffer : note (1)&lt;br /&gt;
           |&lt;br /&gt;
           '-------------------------------&amp;gt; Video Page : note (2)&lt;br /&gt;
  note (1)                 note (2)&lt;br /&gt;
  .--.--.--------------.  .--.--.---------------.&lt;br /&gt;
  |11|10| Video Buffer |  |13|12|   Video Page  |&lt;br /&gt;
  |--|--|--------------|  |--|--|---------------|&lt;br /&gt;
  | 0| 0|     16Ko     |  | 0| 0|  0000 - 3FFF  |&lt;br /&gt;
  |--|--|--------------|  |--|--|---------------|&lt;br /&gt;
  | 0| 1|     16Ko     |  | 0| 1|  4000 - 7FFF  |&lt;br /&gt;
  |--|--|--------------|  |--|--|---------------|&lt;br /&gt;
  | 1| 0|     16Ko     |  | 1| 0|  8000 - BFFF  |&lt;br /&gt;
  |--|--|--------------|  |--|--|---------------|&lt;br /&gt;
  | 1| 1|     32Ko     |  | 1| 1|  C000 - FFFF  |&lt;br /&gt;
  '--'--'--------------'  '--'--'---------------'&lt;br /&gt;
&lt;br /&gt;
So, it's possible to use 32KB screen size (used for [[Programming:Overscan|overscan]]) by setting bits 11 and 10 both to 1 (of Register 12).&lt;br /&gt;
&lt;br /&gt;
== CRTC Differences ==&lt;br /&gt;
&lt;br /&gt;
In this section I will attempt to identify all the differences between each CRTC. &lt;br /&gt;
&lt;br /&gt;
The following tables list the functions that can be accessed for each type: &lt;br /&gt;
&lt;br /&gt;
Type 0&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''b1''||''b0''||''Function''||''Read/Write'' &lt;br /&gt;
|-&lt;br /&gt;
|0||0||Select internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|0||1||Write to selected internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|1||0||-||- &lt;br /&gt;
|-&lt;br /&gt;
|1||1||Read from selected internal 6845 register||Read only &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Type 1&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''b1''||''b0''||''Function''||''Read/Write'' &lt;br /&gt;
|-&lt;br /&gt;
|0||0||Select internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|0||1||Write to selected internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|1||0||Read Status Register||Read Only &lt;br /&gt;
|-&lt;br /&gt;
|1||1||Read from selected internal 6845 register||Read only &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Type 2&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''b1''||''b0''||''Function''||''Read/Write'' &lt;br /&gt;
|-&lt;br /&gt;
|0||0||Select internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|0||1||Write to selected internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|1||0||-||- &lt;br /&gt;
|-&lt;br /&gt;
|1||1||Read from selected internal 6845 register||Read only &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Type 3 and 4&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|''b1''||''b0''||''Function''||''Read/Write'' &lt;br /&gt;
|-&lt;br /&gt;
|0||0||Select internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|0||1||Write to selected internal 6845 register||Write Only &lt;br /&gt;
|-&lt;br /&gt;
|1||0||Read from selected internal 6845 register||Read Only &lt;br /&gt;
|-&lt;br /&gt;
|1||1||Read from selected internal 6845 register||Read only &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It is not possible to read from all the internal registers, this table shows the read/write status of each register for each type: &lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable|width: 700px; font-size: 2em;}}&lt;br /&gt;
|rowspan=2|''Register Index''||rowspan=2|''Register Name''||colspan=4|''Type'' &lt;br /&gt;
|-&lt;br /&gt;
|0||1||2||3||4&lt;br /&gt;
|-&lt;br /&gt;
|0||Horizontal Total||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|1||Horizontal Displayed||Write Only||Write Only||Write Only||(note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|2||Horizontal Sync Position||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|3||Horizontal and Vertical Sync Widths||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|4||Vertical Total||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|5||Vertical Total Adjust||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|6||Vertical Displayed||Write Only||Write Only||Write Only||(note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|7||Vertical Sync position||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|8||Interlace and Skew||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|9||Maximum Raster Address||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|10||Cursor Start Raster||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|11||Cursor End Raster||Write Only||Write Only||Write Only||(note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|12||Display Start Address (High)||Read/Write||Write Only||Write Only||Read/Write (note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|13||Display Start Address (Low)||Read/Write||Write Only||Write Only||Read/Write (note 2)||(note 3) &lt;br /&gt;
|-&lt;br /&gt;
|14||Cursor Address (High)||Read/Write||Read/Write||Read/Write||Read/Write (note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|15||Cursor Address (Low)||Read/Write||Read/Write||Read/Write||Read/Write (note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|16||Light Pen Address (High)||Read Only||Read Only||Read Only||Read Only (note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|17||Light Pen Address (Low)||Read Only||Read Only||Read Only||Read Only (note 2)||(note 3)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Notes'''&lt;br /&gt;
&lt;br /&gt;
1. On type 0 and 1, if a Write Only register is read from, &amp;quot;0&amp;quot; is returned. &lt;br /&gt;
&lt;br /&gt;
2. See the document &amp;quot;Extra CPC Plus Hardware Information&amp;quot; for more details.&lt;br /&gt;
&lt;br /&gt;
3. CRTC type 4 is the same as CRTC type 3. The registers also repeat as they do on the type 3.&lt;br /&gt;
&lt;br /&gt;
== UM6845R and R31 ==&lt;br /&gt;
&lt;br /&gt;
R31 is described in the UM6845R documentation as &amp;quot;Dummy Register&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It's use is described in the documentation for the Rockwell R6545 in combination with R18, R19 and R8 and the Status Register.&lt;br /&gt;
&lt;br /&gt;
In the UM6845R it appears to have no effect. Reading and writing does nothing. Reading it returns 0x0ff.&lt;br /&gt;
&lt;br /&gt;
R31 doesn't exist on types 0,2,3.&lt;br /&gt;
&lt;br /&gt;
== UM6845R and R12/R13 ==&lt;br /&gt;
&lt;br /&gt;
The UM6845R differs to other CRTC in respect of R12/R13. &lt;br /&gt;
&lt;br /&gt;
When VCC=0, R12/R13 is re-read at the start of each line. R12/R13 can therefore be changed for each scanline when VCC=0. &lt;br /&gt;
&lt;br /&gt;
Just like other CRTCs when RC==(R9-1), the current MA is captured for the next char-line.&lt;br /&gt;
&lt;br /&gt;
In demos to make a display compatible with all CRTCs program R12/R13 when VCC!=0. This will then take effect at the next frame start.&lt;br /&gt;
&lt;br /&gt;
== UM6845R status register ==&lt;br /&gt;
&lt;br /&gt;
The UM6845R has a status register that can be read using port &amp;amp;BExx.&lt;br /&gt;
&lt;br /&gt;
Bit 6 is set to 1 if there is a strobe input to the /LPEN signal. It is cleared to 0 when either R17 or R16 (LPEN address) of the CRTC are read. It signals there is a valid LPEN input. On my CPC (arnoldemu) with UM6845R, it is triggered at power on, R17 and R16 have the values 0 when read.&lt;br /&gt;
&lt;br /&gt;
Bit 5 is set to 1 when CRTC is in &amp;quot;vertical blanking&amp;quot;. Vertical blanking is when the vertical border is active. i.e. VCC&amp;gt;=R6. &lt;br /&gt;
&lt;br /&gt;
It is cleared when the frame is started (VCC=0). It is not directly related to the DISPTMG output (used by the CPC to display the border colour) because that output is a combination of horizontal and vertical blanking.&lt;br /&gt;
This bit will be 0 when pixels are being displayed.&lt;br /&gt;
&lt;br /&gt;
All the other bits read as 0 and don't have any function.&lt;br /&gt;
&lt;br /&gt;
== Datasheets ==&lt;br /&gt;
&lt;br /&gt;
* [[Media:hd6845.hitachi.pdf|HD6845S (Hitachi) (aka type 0)]]&lt;br /&gt;
* [[Media:Um6845.umc.pdf|UM6845 (UMC)  (aka type 0)]]&lt;br /&gt;
* [[Media:Um6845r.umc.pdf|UM6845R (UMC)  (aka type 1)]]&lt;br /&gt;
* [[Media:Mc6845.motorola.pdf|MC6845 (Motorola) (aka type 2)]]&lt;br /&gt;
&lt;br /&gt;
* [[VHDL implementation of the 6845]]&lt;br /&gt;
&lt;br /&gt;
== Clones ==&lt;br /&gt;
* [CM607P   a Bulgarian clone made in Pravetz factory]&lt;br /&gt;
* [EF6845P  by Thomson Semiconductors]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools about CRTC ==&lt;br /&gt;
&lt;br /&gt;
*  [http://www.cpcwiki.eu/imgs/9/99/Elmar_Krieger-SPECIAL_EFFECTS.dsk  some BASIC tools to detect CRTC types 0-1-2 and show some effects - by [[Elmar Krieger]] ]     (DSK for Emulators)&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/6845 Wikipedia on the CRTC]&lt;br /&gt;
* [http://www.grimware.org/doku.php/documentations/devices/crtc CRTCs on grimware]&lt;br /&gt;
&lt;br /&gt;
==Related pages==&lt;br /&gt;
&lt;br /&gt;
*[[Gate Array]]&lt;br /&gt;
&lt;br /&gt;
*[[ASIC]]&lt;br /&gt;
&lt;br /&gt;
*[[Video modes]]&lt;br /&gt;
&lt;br /&gt;
*[[Synchronising with the CRTC and display]] : technic and details on the relationship between Gate Array and CRTC.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]] [[Category:CPC Internal Components]] [[Category:Programming]] [[Category:Datasheet]] [[Category:Graphic]]&lt;/div&gt;</summary>
		<author><name>Thomasharte</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=765_FDC&amp;diff=98333</id>
		<title>765 FDC</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=765_FDC&amp;diff=98333"/>
				<updated>2017-07-28T13:38:13Z</updated>
		
		<summary type="html">&lt;p&gt;Thomasharte: /* Notes */ Minor copy edits. Hopefully improvements.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;µPD765 - Floppy Disc Controller (used in [[DDI-1]] and CPC 664/6128).&lt;br /&gt;
&lt;br /&gt;
* Port FA7Eh - Floppy Motor On/Off Flipflop&lt;br /&gt;
* Port FB7Eh - FDC 765 Main Status Register (read only)&lt;br /&gt;
* Port FB7Fh - FDC 765 Data Register (read/write)&lt;br /&gt;
&lt;br /&gt;
== IC Models used in CPC ==&lt;br /&gt;
&lt;br /&gt;
More than one manufacturer made 765 compatible ICs. These are the ones known to be used in the CPC by looking at pictures of CPC mainboards.&lt;br /&gt;
All should operate almost identically.&lt;br /&gt;
&lt;br /&gt;
* [[Zilog]] Z0765A08PSC&lt;br /&gt;
* NEC D765AC-2&lt;br /&gt;
* NEC D765AC&lt;br /&gt;
* UMC UM8272A&lt;br /&gt;
&lt;br /&gt;
The following data seperators are used:&lt;br /&gt;
&lt;br /&gt;
* FDC9216&lt;br /&gt;
&lt;br /&gt;
== Accessing the FDC 765 ==&lt;br /&gt;
The Data Register (Port FB7Fh) is used to write Commands and Parameters, to read/write data bytes, and to receive result bytes. These three operations are called Command-, Execution-, and Result-Phase. The Main Status Register signalizes when the FDC is ready to send/receive the next byte through the Data Register.&lt;br /&gt;
&lt;br /&gt;
Command Phase&lt;br /&gt;
A command consists of a command byte (eventually including the MF, MK, SK bits), and up to eight parameter bytes.&lt;br /&gt;
&lt;br /&gt;
Execution Phase&lt;br /&gt;
During this phase, the actual data is transferred (if any). Usually that are the data bytes for the read/written sector(s), except for the Format Track Command, in that case four bytes for each sector are transferred.&lt;br /&gt;
&lt;br /&gt;
Result Phase&lt;br /&gt;
Returns up to seven result bytes (depending on the command) that are containing status information. The Recalibrate and Seek Track commands do not return result bytes directly, instead the program must wait until the Main Status Register signalizes that the command has been completed, and then it must (!) send a Sense Interrupt State command to 'terminate' the Seek/Recalibrate command.&lt;br /&gt;
&lt;br /&gt;
== FDC Command Table ==&lt;br /&gt;
&lt;br /&gt;
 Command     Parameters              Exm Result               Description&lt;br /&gt;
 02+MF+SK    HU TR HD ?? SZ NM GP SL &amp;lt;R&amp;gt; S0 S1 S2 TR HD NM SZ read track&lt;br /&gt;
 03          XX YY                    -                       specify spd/dma&lt;br /&gt;
 04          HU                       -  S3                   sense drive state&lt;br /&gt;
 05+MT+MF    HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ write sector(s)&lt;br /&gt;
 06+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;R&amp;gt; S0 S1 S2 TR HD LS SZ read sector(s)&lt;br /&gt;
 07          HU                       -                       recalib.seek TP=0&lt;br /&gt;
 08          -                        -  S0 TP                sense int.state&lt;br /&gt;
 09+MT+MF    HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ wr deleted sec(s)&lt;br /&gt;
 0A+MF       HU                       -  S0 S1 S2 TR HD LS SZ read ID&lt;br /&gt;
 0C+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;R&amp;gt; S0 S1 S2 TR HD LS SZ rd deleted sec(s)&lt;br /&gt;
 0D+MF       HU SZ NM GP FB          &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ format track&lt;br /&gt;
 0F          HU TP                    -                       seek track n&lt;br /&gt;
 11+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ scan equal&lt;br /&gt;
 19+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ scan low or equal&lt;br /&gt;
 1D+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ scan high or eq.&lt;br /&gt;
&lt;br /&gt;
Parameter bits that can be specified in some Command Bytes are:&lt;br /&gt;
&lt;br /&gt;
  MT  Bit7  Multi Track (continue multi-sector-function on other head)&lt;br /&gt;
  MF  Bit6  MFM-Mode-Bit (Default 1=Double Density)&lt;br /&gt;
  SK  Bit5  Skip-Bit (set if secs with deleted DAM shall be skipped)&lt;br /&gt;
&lt;br /&gt;
Parameter/Result bytes are:&lt;br /&gt;
&lt;br /&gt;
  HU  b0,1=Unit/Drive Number, b2=Physical Head Number, other bits zero&lt;br /&gt;
  TP  Physical Track Number&lt;br /&gt;
  TR  Track-ID (usually same value as TP)&lt;br /&gt;
  HD  Head-ID&lt;br /&gt;
  SC  First Sector-ID (sector you want to read)&lt;br /&gt;
  SZ  Sector Size (80h shl n) (default=02h for 200h bytes)&lt;br /&gt;
  LS  Last Sector-ID (should be same as SC when reading a single sector)&lt;br /&gt;
  GP  Gap (default=2Ah except command 0D: default=52h)&lt;br /&gt;
  SL  Sectorlen if SZ=0 (default=FFh)&lt;br /&gt;
  Sn  Status Register 0..3&lt;br /&gt;
  FB  Fillbyte (for the sector data areas) (default=E5h)&lt;br /&gt;
  NM  Number of Sectors (default=09h)&lt;br /&gt;
  XX  b0..3=headunload n*32ms (8&amp;quot; only), b4..7=steprate (16-n)*2ms&lt;br /&gt;
  YY  b0=DMA_disable, b1-7=headload n*4ms (8&amp;quot; only)&lt;br /&gt;
&lt;br /&gt;
Format Track: output TR,HD,SC,SZ for each sector during execution phase&lt;br /&gt;
Read Track: reads NM sectors (starting with first sec past index hole)&lt;br /&gt;
Read ID: read ID bytes for current sec, repeated/undelayed read lists all IDs&lt;br /&gt;
Recalib: walks up to 77 tracks, 80tr-drives may need second recalib if failed&lt;br /&gt;
Seek/Recalib: All read/write commands will be disabled until succesful senseint&lt;br /&gt;
Senseint: Set's IC if unsuccesful (no int has occured) (until IC=0)&lt;br /&gt;
&lt;br /&gt;
== FDC Status Registers ==&lt;br /&gt;
&lt;br /&gt;
The Main Status register can be always read through Port FB7E. The other four Status Registers cannot be read directly, instead they are returned through the data register as result bytes in response to specific commands.&lt;br /&gt;
&lt;br /&gt;
Main Status Register (Port FB7E)&lt;br /&gt;
&lt;br /&gt;
  b0..3  DB  FDD0..3 Busy (seek/recalib active, until succesful sense intstat)&lt;br /&gt;
  b4     CB  FDC Busy (still in command-, execution- or result-phase)&lt;br /&gt;
  b5     EXM Execution Mode (still in execution-phase, non_DMA_only)&lt;br /&gt;
  b6     DIO Data Input/Output (0=CPU-&amp;gt;FDC, 1=FDC-&amp;gt;CPU) (see b7)&lt;br /&gt;
  b7     RQM Request For Master (1=ready for next byte) (see b6 for direction)&lt;br /&gt;
&lt;br /&gt;
Status Register 0&lt;br /&gt;
&lt;br /&gt;
  b0,1   US  Unit Select (driveno during interrupt)&lt;br /&gt;
  b2     HD  Head Address (head during interrupt)&lt;br /&gt;
  b3     NR  Not Ready (drive not ready or non-existing 2nd head selected)&lt;br /&gt;
  b4     EC  Equipment Check (drive failure or recalibrate failed (retry))&lt;br /&gt;
  b5     SE  Seek End (Set if seek-command completed)&lt;br /&gt;
  b6,7   IC  Interrupt Code (0=OK, 1=aborted:readfail/OK if EN, 2=unknown cmd&lt;br /&gt;
             or senseint with no int occured, 3=aborted:disc removed etc.)&lt;br /&gt;
&lt;br /&gt;
Status Register 1&lt;br /&gt;
&lt;br /&gt;
  b0     MA  Missing Address Mark (Sector_ID or DAM not found)&lt;br /&gt;
  b1     NW  Not Writeable (tried to write/format disc with wprot_tab=on)&lt;br /&gt;
  b2     ND  No Data (Sector_ID not found, CRC fail in ID_field)&lt;br /&gt;
  b3,6   0   Not used&lt;br /&gt;
  b4     OR  Over Run (CPU too slow in execution-phase (ca. 26us/Byte))&lt;br /&gt;
  b5     DE  Data Error (CRC-fail in ID- or Data-Field)&lt;br /&gt;
  b7     EN  End of Track (set past most read/write commands) (see IC)&lt;br /&gt;
&lt;br /&gt;
Status Register 2&lt;br /&gt;
&lt;br /&gt;
  b0     MD  Missing Address Mark in Data Field (DAM not found)&lt;br /&gt;
  b1     BC  Bad Cylinder (read/programmed track-ID different and read-ID = FF)&lt;br /&gt;
  b2     SN  Scan Not Satisfied (no fitting sector found)&lt;br /&gt;
  b3     SH  Scan Equal Hit (equal)&lt;br /&gt;
  b4     WC  Wrong Cylinder (read/programmed track-ID different) (see b1)&lt;br /&gt;
  b5     DD  Data Error in Data Field (CRC-fail in data-field)&lt;br /&gt;
  b6     CM  Control Mark (read/scan command found sector with deleted DAM)&lt;br /&gt;
  b7     0   Not Used&lt;br /&gt;
&lt;br /&gt;
Status Register 3&lt;br /&gt;
&lt;br /&gt;
  b0,1   US  Unit Select (pin 28,29 of FDC)&lt;br /&gt;
  b2     HD  Head Address (pin 27 of FDC)&lt;br /&gt;
  b3     TS  Two Side (0=yes, 1=no (!))&lt;br /&gt;
  b4     T0  Track 0 (on track 0 we are)&lt;br /&gt;
  b5     RY  Ready (drive ready signal)&lt;br /&gt;
  b6     WP  Write Protected (write protected)&lt;br /&gt;
  b7     FT  Fault (if supported: 1=Drive failure)&lt;br /&gt;
&lt;br /&gt;
== Motor On/Off Flipflop ==&lt;br /&gt;
Writing 00h to Port FA7Eh turns all disk drive motors off, writing 01h turns all motors on. It is not possible to turn on/off the motor of a specific drive separately.&lt;br /&gt;
An exception are the Vortex F1-S, F1-D, M1-S and M1-D drives.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
Before accessing a disk you should issue a ''recalibrate'' command to the drive to move the head backwards until the ''track zero'' signal from the drive is sensed by the FDC. The FDC will also set its track counter for that drive to zero. &lt;br /&gt;
&lt;br /&gt;
On an 80-track drive you may need to repeat that twice because some models of the FDC stop after 77 steps so if recalibrating from track 78 or above the controller might not reach track zero.&lt;br /&gt;
&lt;br /&gt;
In order to format, read or write a sector on a specific track you must first ''seek'' that track using command 0Fh. That'll move the read/write head to the physical track number. If you don't do that then the FDC will attempt to read/write data from/to the current physical track, irrespective of the specified logical ''track ID''.&lt;br /&gt;
&lt;br /&gt;
The ''track'', ''sector'', and ''head'' IDs are logical IDs only. These logical IDs are defined when formatting the disk and aren't required to reflect the physical track, sector, or head numbers. However, when reading or writing a sector you must specify the same IDs that have been used during formatting.&lt;br /&gt;
&lt;br /&gt;
Despite the name, a sector with a ''Deleted data Address Mark'' (DAM) is not deleted; the DAM-flag is just another ID bit. 'Deleted' sectors can be read/written just like normal data sectors and if that ID bit is specified correctly in the command.&lt;br /&gt;
&lt;br /&gt;
At the end of a successful read or write command, the program should send a ''Terminal Count'' (TC) signal to the FDC. However, in the CPC the TC pin isn't connected to the I/O bus, making it impossible for the program to confirm a correct operation. For that reason, the FDC will assume that the command has failed, and it'll return both Bit 6 in Status Register 0 and Bit 7 in Status Register 1 set. The program should ignore this error message.&lt;br /&gt;
&lt;br /&gt;
The CPC doesn't support floppy DMA transfers, and the FDCs Interrupt signal isn't used in the CPC.&lt;br /&gt;
&lt;br /&gt;
Usually single sided 40-track 3&amp;quot; disk drives are used in CPCs. For practical purposes, 42 tracks could be used — the limit is specific to the drive and some support more tracks but 42 is a good maximum. The FDC controller can be used to control 80-tracks and/or double sided drives, though AMSDOS doesn't support such formats. AMSDOS supports a maximum of two disk drives only.&lt;br /&gt;
&lt;br /&gt;
== Datasheets ==&lt;br /&gt;
&lt;br /&gt;
* [[Media:UPD765 Datasheet OCRed.pdf]] - uPD765 disc controller&lt;br /&gt;
* [[Media:FDC9229BT Datasheet.pdf]] - FDC9229BT data separator (that usually assists the uPD765 chip)&lt;br /&gt;
* [[Media:DDI Schematic.png]] - DDI-1 Schematic (disc interface for CPC464)&lt;br /&gt;
&lt;br /&gt;
[[Category:CPC Internal Components]][[Category:Programming]][[Category:DATA Storage]][[Category:Electronic Component]]&lt;/div&gt;</summary>
		<author><name>Thomasharte</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=765_FDC&amp;diff=98332</id>
		<title>765 FDC</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=765_FDC&amp;diff=98332"/>
				<updated>2017-07-28T13:04:56Z</updated>
		
		<summary type="html">&lt;p&gt;Thomasharte: Removed incorrect apostrophe.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;µPD765 - Floppy Disc Controller (used in [[DDI-1]] and CPC 664/6128).&lt;br /&gt;
&lt;br /&gt;
* Port FA7Eh - Floppy Motor On/Off Flipflop&lt;br /&gt;
* Port FB7Eh - FDC 765 Main Status Register (read only)&lt;br /&gt;
* Port FB7Fh - FDC 765 Data Register (read/write)&lt;br /&gt;
&lt;br /&gt;
== IC Models used in CPC ==&lt;br /&gt;
&lt;br /&gt;
More than one manufacturer made 765 compatible ICs. These are the ones known to be used in the CPC by looking at pictures of CPC mainboards.&lt;br /&gt;
All should operate almost identically.&lt;br /&gt;
&lt;br /&gt;
* [[Zilog]] Z0765A08PSC&lt;br /&gt;
* NEC D765AC-2&lt;br /&gt;
* NEC D765AC&lt;br /&gt;
* UMC UM8272A&lt;br /&gt;
&lt;br /&gt;
The following data seperators are used:&lt;br /&gt;
&lt;br /&gt;
* FDC9216&lt;br /&gt;
&lt;br /&gt;
== Accessing the FDC 765 ==&lt;br /&gt;
The Data Register (Port FB7Fh) is used to write Commands and Parameters, to read/write data bytes, and to receive result bytes. These three operations are called Command-, Execution-, and Result-Phase. The Main Status Register signalizes when the FDC is ready to send/receive the next byte through the Data Register.&lt;br /&gt;
&lt;br /&gt;
Command Phase&lt;br /&gt;
A command consists of a command byte (eventually including the MF, MK, SK bits), and up to eight parameter bytes.&lt;br /&gt;
&lt;br /&gt;
Execution Phase&lt;br /&gt;
During this phase, the actual data is transferred (if any). Usually that are the data bytes for the read/written sector(s), except for the Format Track Command, in that case four bytes for each sector are transferred.&lt;br /&gt;
&lt;br /&gt;
Result Phase&lt;br /&gt;
Returns up to seven result bytes (depending on the command) that are containing status information. The Recalibrate and Seek Track commands do not return result bytes directly, instead the program must wait until the Main Status Register signalizes that the command has been completed, and then it must (!) send a Sense Interrupt State command to 'terminate' the Seek/Recalibrate command.&lt;br /&gt;
&lt;br /&gt;
== FDC Command Table ==&lt;br /&gt;
&lt;br /&gt;
 Command     Parameters              Exm Result               Description&lt;br /&gt;
 02+MF+SK    HU TR HD ?? SZ NM GP SL &amp;lt;R&amp;gt; S0 S1 S2 TR HD NM SZ read track&lt;br /&gt;
 03          XX YY                    -                       specify spd/dma&lt;br /&gt;
 04          HU                       -  S3                   sense drive state&lt;br /&gt;
 05+MT+MF    HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ write sector(s)&lt;br /&gt;
 06+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;R&amp;gt; S0 S1 S2 TR HD LS SZ read sector(s)&lt;br /&gt;
 07          HU                       -                       recalib.seek TP=0&lt;br /&gt;
 08          -                        -  S0 TP                sense int.state&lt;br /&gt;
 09+MT+MF    HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ wr deleted sec(s)&lt;br /&gt;
 0A+MF       HU                       -  S0 S1 S2 TR HD LS SZ read ID&lt;br /&gt;
 0C+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;R&amp;gt; S0 S1 S2 TR HD LS SZ rd deleted sec(s)&lt;br /&gt;
 0D+MF       HU SZ NM GP FB          &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ format track&lt;br /&gt;
 0F          HU TP                    -                       seek track n&lt;br /&gt;
 11+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ scan equal&lt;br /&gt;
 19+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ scan low or equal&lt;br /&gt;
 1D+MT+MF+SK HU TR HD SC SZ LS GP SL &amp;lt;W&amp;gt; S0 S1 S2 TR HD LS SZ scan high or eq.&lt;br /&gt;
&lt;br /&gt;
Parameter bits that can be specified in some Command Bytes are:&lt;br /&gt;
&lt;br /&gt;
  MT  Bit7  Multi Track (continue multi-sector-function on other head)&lt;br /&gt;
  MF  Bit6  MFM-Mode-Bit (Default 1=Double Density)&lt;br /&gt;
  SK  Bit5  Skip-Bit (set if secs with deleted DAM shall be skipped)&lt;br /&gt;
&lt;br /&gt;
Parameter/Result bytes are:&lt;br /&gt;
&lt;br /&gt;
  HU  b0,1=Unit/Drive Number, b2=Physical Head Number, other bits zero&lt;br /&gt;
  TP  Physical Track Number&lt;br /&gt;
  TR  Track-ID (usually same value as TP)&lt;br /&gt;
  HD  Head-ID&lt;br /&gt;
  SC  First Sector-ID (sector you want to read)&lt;br /&gt;
  SZ  Sector Size (80h shl n) (default=02h for 200h bytes)&lt;br /&gt;
  LS  Last Sector-ID (should be same as SC when reading a single sector)&lt;br /&gt;
  GP  Gap (default=2Ah except command 0D: default=52h)&lt;br /&gt;
  SL  Sectorlen if SZ=0 (default=FFh)&lt;br /&gt;
  Sn  Status Register 0..3&lt;br /&gt;
  FB  Fillbyte (for the sector data areas) (default=E5h)&lt;br /&gt;
  NM  Number of Sectors (default=09h)&lt;br /&gt;
  XX  b0..3=headunload n*32ms (8&amp;quot; only), b4..7=steprate (16-n)*2ms&lt;br /&gt;
  YY  b0=DMA_disable, b1-7=headload n*4ms (8&amp;quot; only)&lt;br /&gt;
&lt;br /&gt;
Format Track: output TR,HD,SC,SZ for each sector during execution phase&lt;br /&gt;
Read Track: reads NM sectors (starting with first sec past index hole)&lt;br /&gt;
Read ID: read ID bytes for current sec, repeated/undelayed read lists all IDs&lt;br /&gt;
Recalib: walks up to 77 tracks, 80tr-drives may need second recalib if failed&lt;br /&gt;
Seek/Recalib: All read/write commands will be disabled until succesful senseint&lt;br /&gt;
Senseint: Set's IC if unsuccesful (no int has occured) (until IC=0)&lt;br /&gt;
&lt;br /&gt;
== FDC Status Registers ==&lt;br /&gt;
&lt;br /&gt;
The Main Status register can be always read through Port FB7E. The other four Status Registers cannot be read directly, instead they are returned through the data register as result bytes in response to specific commands.&lt;br /&gt;
&lt;br /&gt;
Main Status Register (Port FB7E)&lt;br /&gt;
&lt;br /&gt;
  b0..3  DB  FDD0..3 Busy (seek/recalib active, until succesful sense intstat)&lt;br /&gt;
  b4     CB  FDC Busy (still in command-, execution- or result-phase)&lt;br /&gt;
  b5     EXM Execution Mode (still in execution-phase, non_DMA_only)&lt;br /&gt;
  b6     DIO Data Input/Output (0=CPU-&amp;gt;FDC, 1=FDC-&amp;gt;CPU) (see b7)&lt;br /&gt;
  b7     RQM Request For Master (1=ready for next byte) (see b6 for direction)&lt;br /&gt;
&lt;br /&gt;
Status Register 0&lt;br /&gt;
&lt;br /&gt;
  b0,1   US  Unit Select (driveno during interrupt)&lt;br /&gt;
  b2     HD  Head Address (head during interrupt)&lt;br /&gt;
  b3     NR  Not Ready (drive not ready or non-existing 2nd head selected)&lt;br /&gt;
  b4     EC  Equipment Check (drive failure or recalibrate failed (retry))&lt;br /&gt;
  b5     SE  Seek End (Set if seek-command completed)&lt;br /&gt;
  b6,7   IC  Interrupt Code (0=OK, 1=aborted:readfail/OK if EN, 2=unknown cmd&lt;br /&gt;
             or senseint with no int occured, 3=aborted:disc removed etc.)&lt;br /&gt;
&lt;br /&gt;
Status Register 1&lt;br /&gt;
&lt;br /&gt;
  b0     MA  Missing Address Mark (Sector_ID or DAM not found)&lt;br /&gt;
  b1     NW  Not Writeable (tried to write/format disc with wprot_tab=on)&lt;br /&gt;
  b2     ND  No Data (Sector_ID not found, CRC fail in ID_field)&lt;br /&gt;
  b3,6   0   Not used&lt;br /&gt;
  b4     OR  Over Run (CPU too slow in execution-phase (ca. 26us/Byte))&lt;br /&gt;
  b5     DE  Data Error (CRC-fail in ID- or Data-Field)&lt;br /&gt;
  b7     EN  End of Track (set past most read/write commands) (see IC)&lt;br /&gt;
&lt;br /&gt;
Status Register 2&lt;br /&gt;
&lt;br /&gt;
  b0     MD  Missing Address Mark in Data Field (DAM not found)&lt;br /&gt;
  b1     BC  Bad Cylinder (read/programmed track-ID different and read-ID = FF)&lt;br /&gt;
  b2     SN  Scan Not Satisfied (no fitting sector found)&lt;br /&gt;
  b3     SH  Scan Equal Hit (equal)&lt;br /&gt;
  b4     WC  Wrong Cylinder (read/programmed track-ID different) (see b1)&lt;br /&gt;
  b5     DD  Data Error in Data Field (CRC-fail in data-field)&lt;br /&gt;
  b6     CM  Control Mark (read/scan command found sector with deleted DAM)&lt;br /&gt;
  b7     0   Not Used&lt;br /&gt;
&lt;br /&gt;
Status Register 3&lt;br /&gt;
&lt;br /&gt;
  b0,1   US  Unit Select (pin 28,29 of FDC)&lt;br /&gt;
  b2     HD  Head Address (pin 27 of FDC)&lt;br /&gt;
  b3     TS  Two Side (0=yes, 1=no (!))&lt;br /&gt;
  b4     T0  Track 0 (on track 0 we are)&lt;br /&gt;
  b5     RY  Ready (drive ready signal)&lt;br /&gt;
  b6     WP  Write Protected (write protected)&lt;br /&gt;
  b7     FT  Fault (if supported: 1=Drive failure)&lt;br /&gt;
&lt;br /&gt;
== Motor On/Off Flipflop ==&lt;br /&gt;
Writing 00h to Port FA7Eh turns all disk drive motors off, writing 01h turns all motors on. It is not possible to turn on/off the motor of a specific drive separately.&lt;br /&gt;
An exception are the Vortex F1-S, F1-D, M1-S and M1-D drives.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
Before accessing a disk you should first &amp;quot;Recalibrate&amp;quot; the drive, that moves the head backwards until it reaches Track 0. (The Track 0 signal from the drive is sensed by the FDC and it initializes its internal track counter for that drive to 0). &lt;br /&gt;
&lt;br /&gt;
On a 80 track drive you may need to repeat that twice because some models of the FDC stop after 77 steps and if your recalibrating from track 80 it will not recalibrate fully.&lt;br /&gt;
&lt;br /&gt;
Now if you want to format, read or write a sector on a specific track you must first Seek that track (command 0Fh). That'll move the read/write head to the physical track number. If you don't do that, then the FDC will attempt to read/write data to/from the current physical track, independenly of the specified logical Track-ID.&lt;br /&gt;
&lt;br /&gt;
The Track-, Sector-, and Head-IDs are logical IDs only. These logical IDs are defined when formatting the disk, and aren't required to be identical to the physical Track, Sector, or Head numbers. However, when reading or writing a sector you must specify the same IDs that have been used during formatting.&lt;br /&gt;
&lt;br /&gt;
Despite the confusing name, a sector with a &amp;quot;Deleted Data Address Mark&amp;quot; (DAM) is not deleted. The DAM-flag is just another ID-bit, and (if that ID-bit is specified correctly in the command) it can be read/written like normal data sectors.&lt;br /&gt;
&lt;br /&gt;
At the end of a successful read/write command, the program should send a Terminal Count (TC) signal to the FDC. However, in the CPC the TC pin isn't connected to the I/O bus, making it impossible for the program to confirm a correct operation. For that reason, the FDC will assume that the command has failed, and it'll return both Bit 6 in Status Register 0 and Bit 7 in Status Register 1 set. The program should ignore this error message.&lt;br /&gt;
&lt;br /&gt;
The CPC doesn't support floppy DMA transfers, and the FDCs Interrupt signal isn't used in the CPC also.&lt;br /&gt;
&lt;br /&gt;
Usually single sided 40 Track 3&amp;quot; disk drives are used in CPCs, whereas 40 tracks is the official specification, practically 42 tracks could be used (the limit is specific to the FDD, some support more tracks. 42 is a good maximum). The FDC controller can be used to control 80 tracks, and/or double sided drives also, even though AMSDOS isn't supporting such formats. AMSDOS is supporting a maximum of two disk drives only.&lt;br /&gt;
&lt;br /&gt;
== Datasheets ==&lt;br /&gt;
&lt;br /&gt;
* [[Media:UPD765 Datasheet OCRed.pdf]] - uPD765 disc controller&lt;br /&gt;
* [[Media:FDC9229BT Datasheet.pdf]] - FDC9229BT data separator (that usually assists the uPD765 chip)&lt;br /&gt;
* [[Media:DDI Schematic.png]] - DDI-1 Schematic (disc interface for CPC464)&lt;br /&gt;
&lt;br /&gt;
[[Category:CPC Internal Components]][[Category:Programming]][[Category:DATA Storage]][[Category:Electronic Component]]&lt;/div&gt;</summary>
		<author><name>Thomasharte</name></author>	</entry>

	</feed>