<?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=Lordheavy</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=Lordheavy"/>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php/Special:Contributions/Lordheavy"/>
		<updated>2026-08-30T06:26:48Z</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=119555</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=119555"/>
				<updated>2024-10-14T15:37:48Z</updated>
		
		<summary type="html">&lt;p&gt;Lordheavy: /* Extensions to the above specification */&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. Note that sector size's unit is 256-bytes. So, a sector size of 2, translates to 256 &amp;lt;&amp;lt; (2-1), or 512 bytes.&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;
**b6 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;
! Data 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;
! Mode &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;
| 4µs per bit&lt;br /&gt;
|-&lt;br /&gt;
| 4MHz &lt;br /&gt;
| MFM &lt;br /&gt;
| 2µs 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>Lordheavy</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=8255&amp;diff=112012</id>
		<title>8255</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=8255&amp;diff=112012"/>
				<updated>2023-08-15T11:56:12Z</updated>
		
		<summary type="html">&lt;p&gt;Lordheavy: /* Programming Examples */&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 [https://cpctech.cpcwiki.de/docs/cpcplus.html Extra CPC+ documentation] 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),E               ;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:Intel_8255A_Datasheet.pdf]] PPI Datasheet (Intel)&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;
*[http://quasar.cpcscene.net/doku.php?id=assem:ppi Quasar PPI documentation (in french)]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Electronic Component]][[Category:CPC Internal Components]][[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Lordheavy</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=8255&amp;diff=112011</id>
		<title>8255</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=8255&amp;diff=112011"/>
				<updated>2023-08-15T11:55:15Z</updated>
		
		<summary type="html">&lt;p&gt;Lordheavy: Value assigned in the wrong register&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 [https://cpctech.cpcwiki.de/docs/cpcplus.html Extra CPC+ documentation] 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 A,&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:Intel_8255A_Datasheet.pdf]] PPI Datasheet (Intel)&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;
*[http://quasar.cpcscene.net/doku.php?id=assem:ppi Quasar PPI documentation (in french)]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Electronic Component]][[Category:CPC Internal Components]][[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Lordheavy</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=CRTC&amp;diff=111550</id>
		<title>CRTC</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=CRTC&amp;diff=111550"/>
				<updated>2023-08-05T07:12:08Z</updated>
		
		<summary type="html">&lt;p&gt;Lordheavy: New crtc compendium version&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||48&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). Bits MA11 and MA10 of the address generated by the CRTC are not written on the address bus to access video memory; settings both bits to 1 is the only way to cause a carry to bit MA12 when address pass over the end of current video page to change the memory address to the next video page.&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;
* [http://logon.system.free.fr/down/ACCC1.6-EN.pdf   Amstrad Cpc Crtc Compendium]     Latest (2023!!) document containing in-depth info about CRTC programming on CPC.&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>Lordheavy</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=Format:SNA_snapshot_file_format&amp;diff=109198</id>
		<title>Format:SNA snapshot file format</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Format:SNA_snapshot_file_format&amp;diff=109198"/>
				<updated>2022-08-07T10:00:30Z</updated>
		
		<summary type="html">&lt;p&gt;Lordheavy: cleanup example of RLE compression&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;
= Snapshot (.SNA) file format  =&lt;br /&gt;
&lt;br /&gt;
The format was first defined for the CPCEMU emulator but is now widely supported. The format was originally defined by Marco Vieth. Version 3 was defined by Ulrich Doewich, Martin Korth, Richard Wilson and Kevin Thacker. &lt;br /&gt;
&lt;br /&gt;
There are 3 versions defined in this document. Version 3 is the most recent and is currently supported by a few of the most recent emulators. &lt;br /&gt;
&lt;br /&gt;
Abbreviations: &lt;br /&gt;
&lt;br /&gt;
*GA = &amp;quot;Gate Array&amp;quot; &lt;br /&gt;
*CRTC = &amp;quot;6845 Cathode Ray Tube Controller&amp;quot; &lt;br /&gt;
*PPI = &amp;quot;Intel 8255 Programmable Peripheral Interface&amp;quot; &lt;br /&gt;
*PSG = &amp;quot;AY-3-8912 Programmable Sound Generator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Version 1  ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset (Hex) &lt;br /&gt;
! Count &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 00-07 &lt;br /&gt;
| 8 &lt;br /&gt;
| The identification string &amp;quot;MV - SNA&amp;quot;. This must exist for the snapshot to be valid.&lt;br /&gt;
|-&lt;br /&gt;
| 08-0f &lt;br /&gt;
| 8 &lt;br /&gt;
| (not used; set to 0)&lt;br /&gt;
|-&lt;br /&gt;
| 10 &lt;br /&gt;
| 1 &lt;br /&gt;
| snapshot version (1)&lt;br /&gt;
|-&lt;br /&gt;
| 11 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register F&lt;br /&gt;
|-&lt;br /&gt;
| 12 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register A&lt;br /&gt;
|-&lt;br /&gt;
| 13 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register C&lt;br /&gt;
|-&lt;br /&gt;
| 14 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register B&lt;br /&gt;
|-&lt;br /&gt;
| 15 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register E&lt;br /&gt;
|-&lt;br /&gt;
| 16 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register D&lt;br /&gt;
|-&lt;br /&gt;
| 17 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register L&lt;br /&gt;
|-&lt;br /&gt;
| 18 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register H&lt;br /&gt;
|-&lt;br /&gt;
| 19 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register R&lt;br /&gt;
|-&lt;br /&gt;
| 1a &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register I&lt;br /&gt;
|-&lt;br /&gt;
| 1b &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 interrupt flip-flop IFF0 (note 2)&lt;br /&gt;
|-&lt;br /&gt;
| 1c &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 interrupt flip-flop IFF1 (note 2)&lt;br /&gt;
|-&lt;br /&gt;
| 1d &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register IX (low) (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| 1e &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register IX (high) (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| 1f &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register IY (low) (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| 20 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register IY (high) (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| 21 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register SP (low) (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| 22 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register SP (high) (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| 23 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register PC (low) (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| 24 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register PC (high) (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| 25 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 interrupt mode (0,1,2) (note 3)&lt;br /&gt;
|-&lt;br /&gt;
| 26 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register F' (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 27 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register A' (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 28 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register C' (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 29 &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register B' (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 2a &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register E' (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 2b &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register D' (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 2c &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register L' (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 2d &lt;br /&gt;
| 1 &lt;br /&gt;
| Z80 register H' (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 2e &lt;br /&gt;
| 1 &lt;br /&gt;
| GA: index of selected pen (note 10)&lt;br /&gt;
|-&lt;br /&gt;
| 2f-3f &lt;br /&gt;
| 17 &lt;br /&gt;
| GA: current palette (note 11)&lt;br /&gt;
|-&lt;br /&gt;
| 40 &lt;br /&gt;
| 1 &lt;br /&gt;
| GA: multi configuration (note 12)&lt;br /&gt;
|-&lt;br /&gt;
| 41 &lt;br /&gt;
| 1 &lt;br /&gt;
| current RAM configuration (note 13)&lt;br /&gt;
|-&lt;br /&gt;
| 42 &lt;br /&gt;
| 1 &lt;br /&gt;
| CRTC: index of selected register (note 14)&lt;br /&gt;
|-&lt;br /&gt;
| 43-54 &lt;br /&gt;
| 18 &lt;br /&gt;
| CRTC: register data (0..17) (note 15)&lt;br /&gt;
|-&lt;br /&gt;
| 55 &lt;br /&gt;
| 1 &lt;br /&gt;
| current ROM selection (note 16)&lt;br /&gt;
|-&lt;br /&gt;
| 56 &lt;br /&gt;
| 1 &lt;br /&gt;
| PPI: port A (note 6)&lt;br /&gt;
|-&lt;br /&gt;
| 57 &lt;br /&gt;
| 1 &lt;br /&gt;
| PPI: port B (note 7)&lt;br /&gt;
|-&lt;br /&gt;
| 58 &lt;br /&gt;
| 1 &lt;br /&gt;
| PPI: port C (note 8)&lt;br /&gt;
|-&lt;br /&gt;
| 59 &lt;br /&gt;
| 1 &lt;br /&gt;
| PPI: control port (note 9)&lt;br /&gt;
|-&lt;br /&gt;
| 5a &lt;br /&gt;
| 1 &lt;br /&gt;
| PSG: index of selected register (note 17)&lt;br /&gt;
|-&lt;br /&gt;
| 5b-6a &lt;br /&gt;
| 16 &lt;br /&gt;
| PSG: register data (0,1,....15)&lt;br /&gt;
|-&lt;br /&gt;
| 6b-6c &lt;br /&gt;
| 1 &lt;br /&gt;
| memory dump size in Kilobytes (e.g. 64 for 64K, 128 for 128k) (note 18)&lt;br /&gt;
|-&lt;br /&gt;
| 6d-ff &lt;br /&gt;
| 93 &lt;br /&gt;
| not used set to 0&lt;br /&gt;
|-&lt;br /&gt;
| 100-... &lt;br /&gt;
| (defined by memory dump size) &lt;br /&gt;
| memory dump&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
#All multi-byte values are stored in little-endian format (low byte followed by higher bytes). &lt;br /&gt;
#&amp;quot;IFF0&amp;quot; reflects the state of the maskable interrupt (INT). &amp;quot;IFF1&amp;quot; is used to store the state of IFF0 when a non-maskable interrupt (NMI) is executed. Bit 0 of these bytes is significant. For CPCEMU compatibility, these bytes should be set to &amp;quot;1&amp;quot; when the IFF flip-flop is &amp;quot;1&amp;quot; and &amp;quot;0&amp;quot; when the flip-flop is &amp;quot;0&amp;quot;. For compatibility with other emulators, bits 7-1 should be set to &amp;quot;0&amp;quot;. When bit 0 of &amp;quot;IFF0&amp;quot; is &amp;quot;0&amp;quot; maskable interrupts will be ignored. When bit 0 of &amp;quot;IFF1&amp;quot; is &amp;quot;1&amp;quot; maskable interrupts will be acknowledged and executed. See the document about the Z80 for more information. &lt;br /&gt;
#This byte will be 0, 1 or 2 for the interrupt modes 0, 1 or 2. The interrupt mode is set using the &amp;quot;IM x&amp;quot; instructions. See the document about the Z80 for more information. &lt;br /&gt;
#These registers are from the alternate register set of the Z80. &lt;br /&gt;
#These registers are 16-bit. &amp;quot;low&amp;quot; indicates bits 7..0, &amp;quot;high&amp;quot;indicates bits 15..8. &lt;br /&gt;
#This byte represents the inputs to PPI port A regardless of the input/output setting of this port. &lt;br /&gt;
#This byte represents the inputs to PPI port B regardless of the input/output setting of this port. &lt;br /&gt;
#This byte represents the outputs from port C regardless of the input/output setting of this port. &lt;br /&gt;
#This byte represents the PPI control byte which defines the input/output and mode of each port and not the last value written to this port. For CPCEMU compatibility bit 7 of this byte must be set to &amp;quot;1&amp;quot;. &lt;br /&gt;
#This byte in the snapshot represents the selected pen register of the Gate-Array. This byte is the last value written to this port. Bit 7,6,5 should be set to &amp;quot;0&amp;quot;. &lt;br /&gt;
#This byte in the snapshot represents the multi-configuration register of the Gate-Array. This byte is the last byte written to this register. For CPCEMU compatibility, bit 7 should be set to &amp;quot;1&amp;quot; and bit 6 and bit 5 set to &amp;quot;0&amp;quot;. &lt;br /&gt;
#These bytes are the current palette. For CPCEMU compatibility, these bytes should have bit 7=bit 6=bit 5=&amp;quot;0&amp;quot;. Bits 4..0 define the colour using the hardware colour code. The colours are stored in the order pen 0, pen1, pen 2,...,pen 15 followed by border colour. &lt;br /&gt;
#This byte represents a ram configuration for a Dk'Tronics/Dobbertin/Amstrad compatible RAM expansion, or the built in RAM expansion of the CPC6128 and CPC6128+. Bits 5..0 define the ram expansion code. For CPCEMU compatibility, bit 7 and bit 6 of this byte should be set to &amp;quot;0&amp;quot;. &lt;br /&gt;
#This byte in the snapshot represents the index of the currently selected CRTC register. For compatibility with CPCEMU this value should be in the range 0-31. &lt;br /&gt;
#These bytes represent the data of the CRTC's registers. &lt;br /&gt;
#This byte in the snapshot represents the last byte written to the &amp;quot;ROM select&amp;quot; I/O port. &lt;br /&gt;
#This byte in the snapshot represents the index of the currently selected PSG register. For CPCEMU compatibility, this byte should be in the range 0-15. &lt;br /&gt;
#the first 64k is always the base 64k of ram. The second 64k (if present) is the additional ram in a Dk'Tronics/Dobbertin/Amstrad compatible RAM expansion or the internal ram of the CPC6128/CPC6128+. The memory dump is not dependant on the current RAM configuration. Note that CPCEMU can only write a 64K or 128K snapshot.&lt;br /&gt;
&lt;br /&gt;
== Changes and additions in Version 2 from Version 1  ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset (Hex) &lt;br /&gt;
! Count &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 10 &lt;br /&gt;
| 1 &lt;br /&gt;
| snapshot version (2)&lt;br /&gt;
|-&lt;br /&gt;
| 6d &lt;br /&gt;
| 1 &lt;br /&gt;
| &lt;br /&gt;
CPC type: &lt;br /&gt;
&lt;br /&gt;
*0 = CPC464 &lt;br /&gt;
*1 = CPC664 &lt;br /&gt;
*2 = CPC6128 &lt;br /&gt;
*3 = unknown&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 6e &lt;br /&gt;
| 1 &lt;br /&gt;
| interrupt number (0..5) (note 1a)&lt;br /&gt;
|-&lt;br /&gt;
| 6f-74 &lt;br /&gt;
| 6 &lt;br /&gt;
| 6 multimode bytes (note 1b)&lt;br /&gt;
|-&lt;br /&gt;
| 75-ff &lt;br /&gt;
| x &lt;br /&gt;
| (not used)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
#If standard CPC raster interrupts are used, interrupts are acknowledged and &amp;quot;executed&amp;quot; at the time they are requested, then there will be 6 interrupts executed per screen update cycle. &lt;br /&gt;
#*CPCEMU uses a simple system to emulate the interrupts. It is assumed there are exactly 6 interrupts per screen update cycle (the interrupts are assumed to occur at a frequency of 300Hz). This byte records the interrupt number in the current screen update cycle. More accurate emulators use the correct interrupt generation method and may ignore this byte. For CPCEMU compatibility, these emulators should set this byte to &amp;quot;0&amp;quot;. &lt;br /&gt;
#*CPCEMU uses a simple system to emulate the screen display. It allows the mode to be changed in each of the 6 interrupts that occur during a single 50Hz/60Hz period. These bytes represent the mode in each of these sections, i.e. the screen modes (0,1 or 2) for the interrupts 0..5. More accurate emulators support changing of the screen mode at any point supported by the Amstrad hardware, these emulators should write &amp;quot;0&amp;quot; for all these bytes.&lt;br /&gt;
&lt;br /&gt;
== Changes and additions in Version 3 from Version 2  ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset (Hex) &lt;br /&gt;
! Count &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 10 &lt;br /&gt;
| 1 &lt;br /&gt;
| snapshot version (3)&lt;br /&gt;
|-&lt;br /&gt;
| 6d &lt;br /&gt;
| 1 &lt;br /&gt;
| &lt;br /&gt;
CPC type: &lt;br /&gt;
&lt;br /&gt;
*0 = CPC464 &lt;br /&gt;
*1 = CPC664 &lt;br /&gt;
*2 = CPC6128 &lt;br /&gt;
*3 = unknown &lt;br /&gt;
*4 = 6128 Plus &lt;br /&gt;
*5 = 464 Plus &lt;br /&gt;
*6 = GX4000&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 9C &lt;br /&gt;
| 1 &lt;br /&gt;
| FDD motor drive state (0=off, 1=on)&lt;br /&gt;
|-&lt;br /&gt;
| 9D-A0 &lt;br /&gt;
| 1 &lt;br /&gt;
| FDD current physical track (note 15)&lt;br /&gt;
|-&lt;br /&gt;
| A1 &lt;br /&gt;
| 1 &lt;br /&gt;
| Printer Data/Strobe Register (note 1)&lt;br /&gt;
|-&lt;br /&gt;
| A4 &lt;br /&gt;
| 1 &lt;br /&gt;
| &lt;br /&gt;
CRTC type: &lt;br /&gt;
&lt;br /&gt;
*0 = HD6845S/UM6845 &lt;br /&gt;
*1 = UM6845R &lt;br /&gt;
*2 = MC6845 &lt;br /&gt;
*3 = 6845 in CPC+ ASIC &lt;br /&gt;
*4 = 6845 in Pre-ASIC&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| A9 &lt;br /&gt;
| 1 &lt;br /&gt;
| CRTC horizontal character counter register (note 11)&lt;br /&gt;
|-&lt;br /&gt;
| AA &lt;br /&gt;
| 1 &lt;br /&gt;
| unused (0)&lt;br /&gt;
|-&lt;br /&gt;
| AB &lt;br /&gt;
| 1 &lt;br /&gt;
| CRTC character-line counter register (note 2)&lt;br /&gt;
|-&lt;br /&gt;
| AC &lt;br /&gt;
| 1 &lt;br /&gt;
| CRTC raster-line counter register (note 3)&lt;br /&gt;
|-&lt;br /&gt;
| AD &lt;br /&gt;
| 1 &lt;br /&gt;
| CRTC vertical total adjust counter register (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| AE &lt;br /&gt;
| 1 &lt;br /&gt;
| CRTC horizontal sync width counter (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| AF &lt;br /&gt;
| 1 &lt;br /&gt;
| CRTC vertical sync width counter (note 6)&lt;br /&gt;
|-&lt;br /&gt;
| B0-B1 &lt;br /&gt;
| 2 &lt;br /&gt;
| &lt;br /&gt;
CRTC state flags. (note 7) &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Bit &lt;br /&gt;
! Function&lt;br /&gt;
|-&lt;br /&gt;
| 0 &lt;br /&gt;
| if &amp;quot;1&amp;quot; VSYNC is active, if &amp;quot;0&amp;quot; VSYNC is inactive (note 8)&lt;br /&gt;
|-&lt;br /&gt;
| 1 &lt;br /&gt;
| if &amp;quot;1&amp;quot; HSYNC is active, if &amp;quot;0&amp;quot; HSYNC is inactive (note 9)&lt;br /&gt;
|-&lt;br /&gt;
| 2-7 &lt;br /&gt;
| reserved&lt;br /&gt;
|-&lt;br /&gt;
| 7 &lt;br /&gt;
| if &amp;quot;1&amp;quot; Vertical Total Adjust is active, if &amp;quot;0&amp;quot; Vertical Total Adjust is inactive (note 10)&lt;br /&gt;
|-&lt;br /&gt;
| 8-15 &lt;br /&gt;
| Reserved (0)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| B2 &lt;br /&gt;
| 1 &lt;br /&gt;
| GA vsync delay counter (note 14)&lt;br /&gt;
|-&lt;br /&gt;
| B3 &lt;br /&gt;
| 1 &lt;br /&gt;
| GA interrupt scanline counter (note 12)&lt;br /&gt;
|-&lt;br /&gt;
| B4 &lt;br /&gt;
| 1 &lt;br /&gt;
| interrupt request flag (0=no interrupt requested, 1=interrupt requested) (note 13)&lt;br /&gt;
|-&lt;br /&gt;
| B5-FF &lt;br /&gt;
| 75 &lt;br /&gt;
| unused (0)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
#This byte in the snapshot represents the last byte written to the printer I/O port (this byte does not include the automatic inversion of the strobe caused by the Amstrad hardware). &lt;br /&gt;
#This register is internal to the CRTC and counts the number of character-lines. The counter counts up. This value is in the range 0-127. (This counter is compared against CRTC register 4). &lt;br /&gt;
#This register is internal to the CRTC and counts the number of raster-lines. The counter counts up. This value is in the range 0-31. (This counter is compared against CRTC register 9). &lt;br /&gt;
#This register is internal to the CRTC and counts the number of raster-lines during vertical adjust. The counter counts up. This value is in the range 0-31. This should be ignored if the CRTC is not &amp;quot;executing&amp;quot; vertical. adjust.(This counter is compared against CRTC register 5). &lt;br /&gt;
#This register is internal to the CRTC and counts the number of characters during horizontal sync. This counter counts up. This value is in the range 0-16. This should be ignored if the CRTC is not &amp;quot;executing&amp;quot; horizontal sync. (This counter is compared against CRTC register 3). &lt;br /&gt;
#This register is internal to the CRTC and counts the number of scan-lines during vertical sync. This counter counts up. This value is in the range 0-16. This should be ignored if the CRTC is not &amp;quot;executing&amp;quot; vertical sync. (This counter is compared against CRTC register 3). &lt;br /&gt;
#These bytes define the internal state of the CRTC. Each bit in these bytes represents a state. &lt;br /&gt;
#When VSYNC is active, the CRTC is &amp;quot;executing&amp;quot; vertical sync, and the vertical sync width counter in the snapshot is used. &lt;br /&gt;
#When HSYNC is active, the CRTC is &amp;quot;executing&amp;quot; horizontal sync width counter in the snapshot is used. &lt;br /&gt;
#When Vertical total adjust is active, the CRTC is &amp;quot;executing&amp;quot; vertical total adjust and the vertical total adjust counter in the snapshot is used. &lt;br /&gt;
#This register is internal to the CRTC and counts the number of characters. This counter counts up. This value is in the range 0-255. (This counter is compared against CRTC register 0). &lt;br /&gt;
#This counter is internal to the GA and counts the number of HSYNCs. This counter is used to generate CPC raster interrupts. This counter counts up. This value is in the range 0-51. &lt;br /&gt;
#This flag is &amp;quot;1&amp;quot; if a interrupt request has been sent to the Z80 and it has not yet been acknowledged by the Z80. (A interrupt request is sent by the GA for standard CPC raster interrupts or by the ASIC for raster or dma interrupts). &lt;br /&gt;
#This is a counter internal to the GA and counts the number of HSYNCs since the start of the VSYNC and it is used to reset the interrupt counter to synchronise interrupts with the VSYNC. This counter counts up. This value is between 0 and 2. If this value is 0, the counter is inactive. If this counter is 1 or 2 the counter is active.&lt;br /&gt;
&lt;br /&gt;
Immediatly following the memory dump there is optional data which is seperated into chunks. &lt;br /&gt;
&lt;br /&gt;
Each chunk of data has a header and this is followed by the data in the chunk. The header has the following format: &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset (Hex) &lt;br /&gt;
! Count &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 &lt;br /&gt;
| 4 &lt;br /&gt;
| Chunk name (note 1)&lt;br /&gt;
|-&lt;br /&gt;
| 4 &lt;br /&gt;
| 4 &lt;br /&gt;
| Chunk data length (note 2)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
#The chunks are defined with 4-byte character codes. (e.g. &amp;quot;CPC+&amp;quot;). In this example, the 4-byte character code would be stored in the file as 'C' then 'P' then 'C' then '+'. &lt;br /&gt;
#The &amp;quot;Chunk data length&amp;quot; defines the length of data following the header and does not include the size of the header. This number is stored in little endian format. &lt;br /&gt;
#If a emulator finds a chunk which it does not support then it should skip the chunk and continue with the next chunk in the file. Therefore an emulator author may add emulator specific chunks to the file and it will not prevent the snapshot from being used with other emulators that do not recognise the added chunks. &lt;br /&gt;
#There is not a terminator chunk. The snapshot reader should determine if there are more chunks based on the size of data remaining to be read from the file.&lt;br /&gt;
&lt;br /&gt;
The following chunks are currently defined: &lt;br /&gt;
&lt;br /&gt;
== V3 Chunks ==&lt;br /&gt;
&lt;br /&gt;
=== CPC+ Chunk (Plus only) ===&lt;br /&gt;
&lt;br /&gt;
Chunk name: &amp;quot;CPC+&amp;quot; &lt;br /&gt;
&lt;br /&gt;
If this chunk exists assume that you should use a 464Plus/6128Plus configuration to run the snapshot.&lt;br /&gt;
&lt;br /&gt;
Chunk data: &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset (Hex) &lt;br /&gt;
! Length &lt;br /&gt;
! Addr in ASIC register-ram &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 000-7FF &lt;br /&gt;
| 800h &lt;br /&gt;
| 4000-4FFF &lt;br /&gt;
| Sprite Bitmaps (note 1)&lt;br /&gt;
|-&lt;br /&gt;
| 800-87F &lt;br /&gt;
| 8*16 &lt;br /&gt;
| 6000-607F &lt;br /&gt;
| Sprite Attributes (see below) (note 2)&lt;br /&gt;
|-&lt;br /&gt;
| 880-8BF &lt;br /&gt;
| 32*2 &lt;br /&gt;
| 6400-643F &lt;br /&gt;
| Palettes (note 3)&lt;br /&gt;
|-&lt;br /&gt;
| 8C0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 6800 &lt;br /&gt;
| Programmable Raster Interrupt (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 8C1 &lt;br /&gt;
| 1 &lt;br /&gt;
| 6801 &lt;br /&gt;
| Screen split scan-line (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 8C2 &lt;br /&gt;
| 2 &lt;br /&gt;
| 6802-6803 &lt;br /&gt;
| Screen split secondary screen-address (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 8C4 &lt;br /&gt;
| 1 &lt;br /&gt;
| 6804 &lt;br /&gt;
| Soft scroll control register (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 8C5 &lt;br /&gt;
| 1 &lt;br /&gt;
| 6805 &lt;br /&gt;
| Interrupt vector (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 8C6-8C7 &lt;br /&gt;
| 2 &lt;br /&gt;
| - &lt;br /&gt;
| unused (0)&lt;br /&gt;
|-&lt;br /&gt;
| 8C8-8CF &lt;br /&gt;
| 8 &lt;br /&gt;
| 6808-680f &lt;br /&gt;
| Analogue input channels 0-7 (note 5)&lt;br /&gt;
|-&lt;br /&gt;
| 8D0-8DB &lt;br /&gt;
| 3*4 &lt;br /&gt;
| 6C00-6C0B &lt;br /&gt;
| Sound DMA channel attributes 0-2 (see below) (note 6)&lt;br /&gt;
|-&lt;br /&gt;
| 8DC-8DE &lt;br /&gt;
| 3 &lt;br /&gt;
| - &lt;br /&gt;
| unused (0)&lt;br /&gt;
|-&lt;br /&gt;
| 8DF &lt;br /&gt;
| 1 &lt;br /&gt;
| 6C0F &lt;br /&gt;
| DMA Control/Status (note 4)&lt;br /&gt;
|-&lt;br /&gt;
| 8E0-8F4 &lt;br /&gt;
| 3*7 &lt;br /&gt;
| internal &lt;br /&gt;
| DMA channel 0-2 internal registers (see below) (note 7)&lt;br /&gt;
|-&lt;br /&gt;
| 8F5 &lt;br /&gt;
| 1 &lt;br /&gt;
| internal &lt;br /&gt;
| gate array A0 register value (note 8)&lt;br /&gt;
|-&lt;br /&gt;
| 8F6 &lt;br /&gt;
| 1 &lt;br /&gt;
| internal &lt;br /&gt;
| gate array A0 lock: 0=locked, 1=unlocked (note 9)&lt;br /&gt;
|-&lt;br /&gt;
| 8F7 &lt;br /&gt;
| 1 &lt;br /&gt;
| internal &lt;br /&gt;
| ASIC unlock sequence state (note 10)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
1. The sprite data is packed, with two sprite pixels per byte. Bits 7..4 define the first pixel and bits 3..0 define the second pixel.&amp;lt;br&amp;gt; 2. The attributes for each sprite take 8 bytes. Each attribute block has the following format: &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&amp;amp;nbsp; &lt;br /&gt;
! Length&amp;amp;nbsp; &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 &lt;br /&gt;
| 2 &lt;br /&gt;
| Sprite X (see note)&lt;br /&gt;
|-&lt;br /&gt;
| 2 &lt;br /&gt;
| 2 &lt;br /&gt;
| Sprite Y (see note)&lt;br /&gt;
|-&lt;br /&gt;
| 4 &lt;br /&gt;
| 1 &lt;br /&gt;
| Sprite Magnification (see note)&lt;br /&gt;
|-&lt;br /&gt;
| 5-7 &lt;br /&gt;
| 3 &lt;br /&gt;
| unused (0)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: the Sprite X, Y and magnification are in the same order as the ASIC registers &lt;br /&gt;
&lt;br /&gt;
3. This is a direct copy of the palette in CPC+ ASIC Ram. There are 32 colours each with 2-bytes per colour.&amp;lt;br&amp;gt; 4. These bytes in the snapshot represent the last value written to these ASIC registers.&amp;lt;br&amp;gt; 5. These bytes represent the inputs to the analogue channels.&amp;lt;br&amp;gt; 6. The attributes for each DMA channel take 4 bytes. Each attribute block has the following format: &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&amp;amp;nbsp; &lt;br /&gt;
! Length&amp;amp;nbsp; &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 &lt;br /&gt;
| 2 &lt;br /&gt;
| DMA Channel address (see note)&lt;br /&gt;
|-&lt;br /&gt;
| 2 &lt;br /&gt;
| 1 &lt;br /&gt;
| DMA Channel prescalar (see note)&lt;br /&gt;
|-&lt;br /&gt;
| 3 &lt;br /&gt;
| 1 &lt;br /&gt;
| unused (0)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: the DMA address and prescalar are in the same order as the ASIC registers. &lt;br /&gt;
&lt;br /&gt;
7. These registers are internal to the CPC+ and define the current DMA operation: &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&amp;amp;nbsp; &lt;br /&gt;
! Length&amp;amp;nbsp; &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 &lt;br /&gt;
| 2 &lt;br /&gt;
| loop counter (note a)&lt;br /&gt;
|-&lt;br /&gt;
| 2 &lt;br /&gt;
| 2 &lt;br /&gt;
| loop address (note b)&lt;br /&gt;
|-&lt;br /&gt;
| 4 &lt;br /&gt;
| 2 &lt;br /&gt;
| pause count (note c)&lt;br /&gt;
|-&lt;br /&gt;
| 6 &lt;br /&gt;
| 1 &lt;br /&gt;
| pause prescalar count (note d)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
a.) This value represents the number of loops remaining. 0 = none. This count is between 0..0FFF. This counter counts down.&amp;lt;br&amp;gt; b.) This is the Amstrad memory address to loop back to. It is a pointer to the DMA instruction after the last REPEAT instruction.&amp;lt;br&amp;gt; c.) This value represents the pause count and the count is between 0...0FFF. (TO BE CHECKED: down counter? what exactly does it represent)&amp;lt;br&amp;gt; d.) This value represents the pause prescalar count and the count is between 0..FF. (TO BE CHECKED: down counter? what exactly does it represent)&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
8. This value represents the last value written to this I/O port.&amp;lt;br&amp;gt; 9. This value represents the lock status of the ASIC. If the ASIC is un-locked then the advanced features and ASIC registers are accessible.&amp;lt;br&amp;gt; 10. This value represents the current unlock sequence state. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! State ID&amp;amp;nbsp; &lt;br /&gt;
! Synchronised State&amp;amp;nbsp; &lt;br /&gt;
! Note&lt;br /&gt;
|-&lt;br /&gt;
| 0 &lt;br /&gt;
| not synchronised &lt;br /&gt;
| ASIC is waiting for first non-zero byte to be written, this is the first synchronisation byte required&lt;br /&gt;
|-&lt;br /&gt;
| 1 &lt;br /&gt;
| not synchronised &lt;br /&gt;
| ASIC is waiting for zero byte to be written, this is the second synchronisation byte required&lt;br /&gt;
|-&lt;br /&gt;
| 2..10h &lt;br /&gt;
| synchronised &lt;br /&gt;
| ASIC is waiting for byte from unlock sequence. e.g. if &amp;quot;2&amp;quot;, ASIC is waiting for &amp;amp;amp;FF, the first byte of the unlock sequence. if &amp;quot;3&amp;quot; ASIC is waiting for &amp;amp;amp;77, the second byte of the unlock sequence.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Memory block chunks (CPC/Plus/KC Compact/Aleste) ===&lt;br /&gt;
&lt;br /&gt;
There may be 1 or more of these memory blocks.&lt;br /&gt;
&lt;br /&gt;
Chunk name: MEM0..MEM8. &lt;br /&gt;
&lt;br /&gt;
Each block represents 64K.&lt;br /&gt;
&lt;br /&gt;
MEM0 describes the standard on-board 64k.&lt;br /&gt;
MEM1...MEM8 for memory expansion bank. &lt;br /&gt;
The MEM1..MEM8 memory blocks map to RAM expansions:&lt;br /&gt;
* MEM1 = extra 64KB ram in CPC6128 or 6128Plus&lt;br /&gt;
* MEM1-4 = 256KB dk'tronics compatible ram expansion&lt;br /&gt;
* MEM5-8 = 256KB dk'tronics silicon disk compatible&lt;br /&gt;
&lt;br /&gt;
Other RAM expansions have the full 512KB such as the X-MEM. These map to MEM1-MEM8.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a chunk exists in the snapshot that means that memory is stored compressed.&lt;br /&gt;
&lt;br /&gt;
It is possible to have a snapshot with 64KB base ram uncompressed and additional banks compressed but it's advised to either use MEM chunks or store the memory uncompressed in the V2 style.&lt;br /&gt;
&lt;br /&gt;
The memory size in the snapshot refers to the amount of uncompressed V2 style memory that is in the snapshot. If the memory is described only by chunks it is 0.&lt;br /&gt;
If there is both uncompressed and compressed data then the compressed data takes priority over the uncompressed data. I.e. handle the uncompressed data first then the compressed data.&lt;br /&gt;
&lt;br /&gt;
A RLE compression is used with 0x0e5 as the control byte.&lt;br /&gt;
&lt;br /&gt;
i.e. &amp;lt;control byte&amp;gt;, &amp;lt;count&amp;gt;, &amp;lt;byte&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples (Uncompressed = Compressed):&lt;br /&gt;
* 11 22 33 = 11 22 33&lt;br /&gt;
* E5 03 11 = 11 11 11&lt;br /&gt;
* E5 00 = E5&lt;br /&gt;
&lt;br /&gt;
=== Breakpoint chunk (Winape emulator specific) ===&lt;br /&gt;
&lt;br /&gt;
Breakpoint chunk has the name &amp;quot;BRKS&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The chunk contains 1 or more breakpoints.&lt;br /&gt;
&lt;br /&gt;
Each breakpoint has the form:&lt;br /&gt;
&lt;br /&gt;
2 byte address&lt;br /&gt;
1 byte code (0=base 64K RAM, 1 = extended RAM)&lt;br /&gt;
2 bytes condition&lt;br /&gt;
&lt;br /&gt;
=== Inserted disc images (Winape emulator specific) ===&lt;br /&gt;
&lt;br /&gt;
There are two chunks. 'DSCA' and 'DSCB'.&lt;br /&gt;
DSCA is for drive A and DSCB is for drive B.&lt;br /&gt;
&lt;br /&gt;
The chunk contains a string which is the path to the disk image inserted into that drive.&lt;br /&gt;
&lt;br /&gt;
== Memory ==&lt;br /&gt;
&lt;br /&gt;
Uncompressed memory described by the snapshot allows sizes of:&lt;br /&gt;
* 64K (base 64K only), &lt;br /&gt;
* 128K (base 64K + 64K dk'tronics compatible RAM expansion using ram selections C4-C7), &lt;br /&gt;
* 312K (base 64K+256K dk'tronics compatible RAM expansion using ram selections C4-CC),&lt;br /&gt;
* 576K (base 64K+512K RAM composed of dk'tronics compatible 256K RAM AND dk'tronics compatible 256K silicon disk). Ram selections c4-ff.&lt;br /&gt;
&lt;br /&gt;
The MEM chunks do allow to describe RAM expansions where the configurations are not continuous. (e.g. 64K base + 256K silicon disk).&lt;br /&gt;
&lt;br /&gt;
== Limitations of this snapshot format==&lt;br /&gt;
* The snapshot format doesn't support more than 512K RAM and only supports dk'tronics compatible RAM expansions.&lt;br /&gt;
* The snapshot format doesn't support additional hardware. A basic CPC464, CPC664, CPC6128 system is assumed.&lt;br /&gt;
* The snapshot format doesn't support KC Compact or Aleste hardware.&lt;br /&gt;
* The snapshot doesn't have knowledge of which ROMs are in use. This means it doesn't know which OS, BASIC or AMSDOS ROM, and nothing about expansion roms.&lt;br /&gt;
&lt;br /&gt;
The format generally assumes a base CPC6128/6128Plus system with no attached hardware except for up to 512K of dk'tronics compatible RAM.&lt;/div&gt;</summary>
		<author><name>Lordheavy</name></author>	</entry>

	</feed>