<?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=Exofu</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=Exofu"/>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php/Special:Contributions/Exofu"/>
		<updated>2026-08-29T02:21:45Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.25.1</generator>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=Amstrad_Whole_Memory_Guide_-_General_system_arrangement&amp;diff=99860</id>
		<title>Amstrad Whole Memory Guide - General system arrangement</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Amstrad_Whole_Memory_Guide_-_General_system_arrangement&amp;diff=99860"/>
				<updated>2017-11-14T23:01:10Z</updated>
		
		<summary type="html">&lt;p&gt;Exofu: Fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Chapter 1 in the book [[Amstrad Whole Memory Guide]].&lt;br /&gt;
&lt;br /&gt;
== GENERAL SYSTEM ARRANGEMENT ==&lt;br /&gt;
&lt;br /&gt;
Superficially, the CPC464 is a typical Z8Ø—based system, with an unusually economical arrangement of peripheral devices. By making full use of the capabilities of these devices, a performance level has been obtained which is higher than the limited chip count might suggest. One consequence of this is that the operating system is especially complex, a fact which is offset by the comparative ease of user access to the various functions. The word ‘comparative‘ 15 necessary, because knowledge of machine code is needed, which may be a difficulty for some users, but once they have come to terms with machine code a wide range of possibilities opens up.&lt;br /&gt;
&lt;br /&gt;
Among other ingenuities, the way in which a minimum of 96K of memory has been packed into a 64K memory map is especially noteworthy, and this aspect of the system will be studied first.&lt;br /&gt;
&lt;br /&gt;
=== The Memory Map ===&lt;br /&gt;
&lt;br /&gt;
The whole of the 64K byte memory is occupied by RAM, to which any writes to memory will be directed. This makes sense, since there is r point in trying to write to ROM. Reads from addresses in the middle half of memory will also access RAM, there being no ROM in this area. For addresses in the top and bottom quarters of memory, however, both ROM and RAN are present, and it is possible to read from either at will. A BASIC peek will always access RAM, so a special bit of machine code is needed to obtain the contents of ROM.&lt;br /&gt;
&lt;br /&gt;
The memory arrangement is complicated by the fact that the top quarter of RAM is dedicated to use as screen memory, and most be immediately accessible at regular intervals while data Is being passed to the display. For this purpose, two bytes are read every microsecond.&lt;br /&gt;
&lt;br /&gt;
The processor is put into a wait state while the pairs of bytes are being transferred, the transfer being made directly from memory to the Video Gate Array, using an address generated by the CRT Controller chip. This means that the main processor can only make one memory access per microsecond, and although its clock runs at 4 MHz the actual processing speed is slightly reduced, a point to watch when calculating execution times.&lt;br /&gt;
&lt;br /&gt;
The Video Gate Array handles the switching between ROM and RAM for this purpose, so it is natural that it is also used to control ROM selection in general. The instructions for switching between ROM and RAM are given by outputs to bits 2 and 3 of port 7FXX. A 1 disables, a 0 enables, while bit 2 applies to the lower ROM and bit 3 to the upper ROM. Incidentally, there is only one ROM component, some address fiddling dividing it into two 16K blocks as far as the System is concerned.&lt;br /&gt;
&lt;br /&gt;
As in any bank-switching memory system, the key problem is the need to jump and switch banks simultaneously, or to appear to do so. The CPC464 achieves this by using routines held in central RAM. These are always accessible, whatever the ROM selection state. In addition to simple switching between ROM and RAM, these routines allow the selection of alternative upper ROMs, extending the available memory still further. In the extreme, it would nominally be possible to address a total of 4128K bytes of memory, but few systems are likely to approach that ultimate limit. &lt;br /&gt;
&lt;br /&gt;
The complexities of the memory System can be evaded by putting machine code into the central half of the memory map, which contains only RAM, but this is neither essential nor always feasible.&lt;br /&gt;
&lt;br /&gt;
=== The I/O Map ===&lt;br /&gt;
&lt;br /&gt;
The selection of peripheral channels is largely determined by making one of the bits of the upper byte of the 16—bit I/O address low, which means that the older I/O instructions of the form IN A,(N) and OUT (N),A cannot be used, because they draw the upper byte from the contents of the A register. Instructions which set the I/O address from the contents of the BC register are mandatory, and there are strict limits regarding the contents of the B register, because no more than one of the six upper bits may be low in any given address. (Making more than one of these bits low in an input instruction invites physical damage, because two data sources may fight for control of the bus, while it is rarely sensible to send the same output to two different ports at the same time.)&lt;br /&gt;
&lt;br /&gt;
The I/O addresses can be summed up as follows:&lt;br /&gt;
&lt;br /&gt;
* If address bit A15 is low, the Video Gate Array is selected. This port is for output only. The address must be 7FXX.&lt;br /&gt;
&lt;br /&gt;
* If address bit A14 is low, the CRT Controller is selected. Address bits A8 and A9 are used to select four different transfer modes:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| BCXX || Output to Register Select&lt;br /&gt;
|-&lt;br /&gt;
| BDXX || Data Output&lt;br /&gt;
|-&lt;br /&gt;
| BEXX || Status Input&lt;br /&gt;
|-&lt;br /&gt;
| BFXX || Data Input&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* If address bit A13 is low, ROM select data is being output. The address must be DFXX.&lt;br /&gt;
&lt;br /&gt;
* If address bit A12 is low, the printer channel is selected for output only. The address must be EFXX.&lt;br /&gt;
&lt;br /&gt;
* If address bit A11 is low, the Parallel Peripheral Interface (PPI) is selected. Here again, bits A8 and A9 are used to select four sub—channels:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| F4XX || Port A (I/O)&lt;br /&gt;
|-&lt;br /&gt;
| F5XX || Port B (I/O)&lt;br /&gt;
|-&lt;br /&gt;
| F6XX || Port C (I/O)&lt;br /&gt;
|-&lt;br /&gt;
| F7XX || Control (Output only)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* If address bit A10 is low, an expansion channel is selected. In this case, bits A5 — A7 have special significance:&lt;br /&gt;
** A5 low selects a communication channel.&lt;br /&gt;
** A6 low selects a reserved function.&lt;br /&gt;
** A7 low selects the disc System.&lt;br /&gt;
&lt;br /&gt;
* Address F8FF is a general reset for expansion channels.&lt;br /&gt;
&lt;br /&gt;
The above allocations restrict the user to the following address ranges for any special I/O functions he may require:&lt;br /&gt;
&lt;br /&gt;
F8E0—F8FE: F9E0—F9FF: FAE0—FAFF: FBE0—FBFF&lt;br /&gt;
&lt;br /&gt;
=== Outer Peripherals ===&lt;br /&gt;
&lt;br /&gt;
The devices mentioned above are the ‘inner peripherals‘, which are accessed directly from the main processor. Further devices, classed as the ‘Outer Peripherals‘, are accessed by the inner peripherals. They include the Programmable Sound Generator, accesed by the PPI; the keyboard, accessed by the PPI and the&lt;br /&gt;
&lt;br /&gt;
Sound Generator; the Cassette Recorder, accessed by the PPI; the Loudspeaker, driven by the Sound Generator.&lt;br /&gt;
&lt;br /&gt;
For further details of the hardware system, consult ‘[[The Ins &amp;amp; Outs of the Amstrad|The Ins and Outs of the Amstrad]]‘, which gives additional Information on the coding and action of these devices.&lt;br /&gt;
&lt;br /&gt;
=== System States ===&lt;br /&gt;
&lt;br /&gt;
At switch-on, a number of initialisation procedures are executed, and control then passes to upper ROM Ø. If there is no external ROM of this number, the internal BASIC interpreter takes charge as the ‘foreground‘ program.&lt;br /&gt;
&lt;br /&gt;
Once a foreground program has been entered, it remains in charge until a return at entry level is executed, when a full reset is performed, and ROM is again put in charge. However, the foreground program can call on background programs for assistance, and these, in turn, can call other programs. There is thus — nominally — one foreground level, but there can be several background levels.&lt;br /&gt;
&lt;br /&gt;
A ROM other than 0, or a program in RAM, can be selected as the foreground program. This can be done by a RUN”” command which reads a machine code program that has a defined Start address, or by a machine code routine. It may be more convenient to leave the BASIC interpreter nominally in charge and run a program CALLed from BASIC as if it was a foreground program. This has the advantage that a full reset is not inevitable in response to a return at entry level. Instead, the interpreter is re—entered.&lt;br /&gt;
&lt;br /&gt;
Using BASIC in this way has other advantages. [[HIMEM]] can be checked and adjusted quite easy putting it below the area in which machine code is to reside, and other system variables can be set up. The BASIC program will use some RAM, particularly from Ø17 upwards, but this is likely to be a negligible drain on the large RAM area available.&lt;br /&gt;
&lt;br /&gt;
One point to watch is that if extension systems are added, such as disc drive, speech facility, or the [[Maxam|MAXAM]] assembler in ROM form, HIMEM is lowered, because the extensions have claimed workspace for their own use. Some commercial programs are incompatible with a disc drive ‚ because they trespass on the disc workspace. Protected or not, they cannot be transferred to disc.&lt;br /&gt;
&lt;br /&gt;
As a guide, HIMEM is AB7F in typical circumstances, but drops to A67B with disc drives connected, and may go even lower with [[AMSDOS]] active.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Scanned pages ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:AWMG page1.jpg|page 1&lt;br /&gt;
Image:AWMG page2.jpg|page 2&lt;br /&gt;
Image:AWMG page3.jpg|page 3&lt;br /&gt;
Image:AWMG page4.jpg|page 4&lt;br /&gt;
Image:AWMG page5.jpg|page 5&lt;br /&gt;
Image:AWMG page6.jpg|page 6&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:CPC Firmware]]&lt;/div&gt;</summary>
		<author><name>Exofu</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=Amstrad_Whole_Memory_Guide_-_General_system_arrangement&amp;diff=99859</id>
		<title>Amstrad Whole Memory Guide - General system arrangement</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Amstrad_Whole_Memory_Guide_-_General_system_arrangement&amp;diff=99859"/>
				<updated>2017-11-14T22:58:53Z</updated>
		
		<summary type="html">&lt;p&gt;Exofu: Formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Chapter 1 in the book [[Amstrad Whole Memory Guide]].&lt;br /&gt;
&lt;br /&gt;
== GENERAL SYSTEM ARRANGEMENT ==&lt;br /&gt;
&lt;br /&gt;
Superficially, the CPC464 is a typical Z8Ø—based system, with an unusually economical arrangement of peripheral devices. By making full use of the capabilities of these devices, a performance level has been obtained which is higher than the limited chip count might suggest. One consequence of this is that the operating system is especially complex, a fact which is offset by the comparative ease of user access to the various functions. The word ‘comparative‘ 15 necessary, because knowledge of machine code is needed, which may be a difficulty for some users, but once they have come to terms with machine code a wide range of possibilities opens up.&lt;br /&gt;
&lt;br /&gt;
Among other ingenuities, the way in which a minimum of 96K of memory has been packed into a 64K memory map is especially noteworthy, and this aspect of the system will be studied first.&lt;br /&gt;
&lt;br /&gt;
=== The Memory Map ===&lt;br /&gt;
&lt;br /&gt;
The whole of the 64K byte memory is occupied by RAM, to which any writes to memory will be directed. This makes sense, since there is r point in trying to write to ROM. Reads from addresses in the middle half of memory will also access RAM, there being no ROM in this area. For addresses in the top and bottom quarters of memory, however, both ROM and RAN are present, and it is possible to read from either at will. A BASIC peek will always access RAM, so a special bit of machine code is needed to obtain the contents of ROM.&lt;br /&gt;
&lt;br /&gt;
The memory arrangement is complicated by the fact that the top quarter of RAM is dedicated to use as screen memory, and most be immediately accessible at regular intervals while data Is being passed to the display. For this purpose, two bytes are read every microsecond.&lt;br /&gt;
&lt;br /&gt;
The processor is put into a wait state while the pairs of bytes are being transferred, the transfer being made directly from memory to the Video Gate Array, using an address generated by the CRT Controller chip. This means that the main processor can only make one memory access per microsecond, and although its clock runs at 4 MHz the actual processing speed is slightly reduced, a point to watch when calculating execution times.&lt;br /&gt;
&lt;br /&gt;
The Video Gate Array handles the switching between ROM and RAM for this purpose, so it is natural that it is also used to control ROM selection in general. The instructions for switching between ROM and RAM are given by outputs to bits 2 and 3 of port 7FXX. A 1 disables, a 0 enables, while bit 2 applies to the lower ROM and bit 3 to the upper ROM. Incidentally, there is only one ROM component, some address fiddling dividing it into two 16K blocks as far as the System is concerned.&lt;br /&gt;
&lt;br /&gt;
As in any bank-switching memory system, the key problem is the need to jump and switch banks simultaneously, or to appear to do so. The CPC464 achieves this by using routines held in central RAM. These are always accessible, whatever the ROM selection state. In addition to simple switching between ROM and RAM, these routines allow the selection of alternative upper ROMs, extending the available memory still further. In the extreme, it would nominally be possible to address a total of 4128K bytes of memory, but few systems are likely to approach that ultimate limit. &lt;br /&gt;
&lt;br /&gt;
The complexities of the memory System can be evaded by putting machine code into the central half of the memory map, which contains only RAM, but this is neither essential nor always feasible.&lt;br /&gt;
&lt;br /&gt;
=== The I/O Map ===&lt;br /&gt;
&lt;br /&gt;
The selection of peripheral channels is largely determined by making one of the bits of the upper byte of the 16—bit I/O address low, which means that the older I/O instructions of the form IN A,(N) and OUT (N),A cannot be used, because they draw the upper byte from the contents of the A register. Instructions which set the I/O address from the contents of the BC register are mandatory, and there are strict limits regarding the contents of the B register, because no more than one of the six upper bits may be low in any given address. (Making more than one of these bits low in an input instruction invites physical damage, because two data sources may fight for control of the bus, while it is rarely sensible to send the same output to two different ports at the same time.)&lt;br /&gt;
&lt;br /&gt;
The I/O addresses can be summed up as follows:&lt;br /&gt;
&lt;br /&gt;
* If address bit A15 is low, the Video Gate Array is selected. This port is for output only. The address must be 7FXX.&lt;br /&gt;
&lt;br /&gt;
* If address bit A14 is low, the CRT Controller is selected. Address bits A8 and A9 are used to select four different transfer modes:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| BCXX || Output to Register Select&lt;br /&gt;
|-&lt;br /&gt;
| BDXX || Data Output&lt;br /&gt;
|-&lt;br /&gt;
| BEXX || Status Input&lt;br /&gt;
|-&lt;br /&gt;
| BFXX || Data Input&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* If address bit A13 is low, ROM select data is being output. The address must be DFXX.&lt;br /&gt;
&lt;br /&gt;
* If address bit A12 is low, the printer channel is selected for output only. The address must be EFXX.&lt;br /&gt;
&lt;br /&gt;
* If address bit A11 is low, the Parallel Peripheral Interface (PPI) is selected. Here again, bits A8 and A9 are used to select four sub—channels:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| F4XX || Port A (I/O)&lt;br /&gt;
|-&lt;br /&gt;
| F5XX || Port B (I/O)&lt;br /&gt;
|-&lt;br /&gt;
| F6XX || Port C (I/O)&lt;br /&gt;
|-&lt;br /&gt;
| F7XX || Control (Output only) |&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* If address bit A10 is low, an expansion channel is selected. In this case, bits A5 — A7 have special significance:&lt;br /&gt;
** A5 low selects a communication channel.&lt;br /&gt;
** A6 low selects a reserved function.&lt;br /&gt;
** A7 low selects the disc System.&lt;br /&gt;
&lt;br /&gt;
* Address F8FF is a general reset for expansion channels.&lt;br /&gt;
&lt;br /&gt;
The above allocations restrict the user to the following address ranges for any special I/O functions he may require:&lt;br /&gt;
&lt;br /&gt;
F8E0—F8FE: F9E0—F9FF: FAE0—FAFF: FBE0—FBFF&lt;br /&gt;
&lt;br /&gt;
=== Outer Peripherals ===&lt;br /&gt;
&lt;br /&gt;
The devices mentioned above are the ‘inner peripherals‘, which are accessed directly from the main processor. Further devices, classed as the ‘Outer Peripherals‘, are accessed by the inner peripherals. They include the Programmable Sound Generator, accesed by the PPI; the keyboard, accessed by the PPI and the&lt;br /&gt;
&lt;br /&gt;
Sound Generator; the Cassette Recorder, accessed by the PPI; the Loudspeaker, driven by the Sound Generator.&lt;br /&gt;
&lt;br /&gt;
For further details of the hardware system, consult ‘[[The Ins &amp;amp; Outs of the Amstrad|The Ins and Outs of the Amstrad]]‘, which gives additional Information on the coding and action of these devices.&lt;br /&gt;
&lt;br /&gt;
=== System States ===&lt;br /&gt;
&lt;br /&gt;
At switch-on, a number of initialisation procedures are executed, and control then passes to upper ROM Ø. If there is no external ROM of this number, the internal BASIC interpreter takes charge as the ‘foreground‘ program.&lt;br /&gt;
&lt;br /&gt;
Once a foreground program has been entered, it remains in charge until a return at entry level is executed, when a full reset is performed, and ROM is again put in charge. However, the foreground program can call on background programs for assistance, and these, in turn, can call other programs. There is thus — nominally — one foreground level, but there can be several background levels.&lt;br /&gt;
&lt;br /&gt;
A ROM other than 0, or a program in RAM, can be selected as the foreground program. This can be done by a RUN”” command which reads a machine code program that has a defined Start address, or by a machine code routine. It may be more convenient to leave the BASIC interpreter nominally in charge and run a program CALLed from BASIC as if it was a foreground program. This has the advantage that a full reset is not inevitable in response to a return at entry level. Instead, the interpreter is re—entered.&lt;br /&gt;
&lt;br /&gt;
Using BASIC in this way has other advantages. [[HIMEM]] can be checked and adjusted quite easy putting it below the area in which machine code is to reside, and other system variables can be set up. The BASIC program will use some RAM, particularly from Ø17 upwards, but this is likely to be a negligible drain on the large RAM area available.&lt;br /&gt;
&lt;br /&gt;
One point to watch is that if extension systems are added, such as disc drive, speech facility, or the [[Maxam|MAXAM]] assembler in ROM form, HIMEM is lowered, because the extensions have claimed workspace for their own use. Some commercial programs are incompatible with a disc drive ‚ because they trespass on the disc workspace. Protected or not, they cannot be transferred to disc.&lt;br /&gt;
&lt;br /&gt;
As a guide, HIMEM is AB7F in typical circumstances, but drops to A67B with disc drives connected, and may go even lower with [[AMSDOS]] active.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Scanned pages ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:AWMG page1.jpg|page 1&lt;br /&gt;
Image:AWMG page2.jpg|page 2&lt;br /&gt;
Image:AWMG page3.jpg|page 3&lt;br /&gt;
Image:AWMG page4.jpg|page 4&lt;br /&gt;
Image:AWMG page5.jpg|page 5&lt;br /&gt;
Image:AWMG page6.jpg|page 6&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:CPC Firmware]]&lt;/div&gt;</summary>
		<author><name>Exofu</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=Amstrad_Whole_Memory_Guide_-_General_system_arrangement&amp;diff=99858</id>
		<title>Amstrad Whole Memory Guide - General system arrangement</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Amstrad_Whole_Memory_Guide_-_General_system_arrangement&amp;diff=99858"/>
				<updated>2017-11-14T22:45:44Z</updated>
		
		<summary type="html">&lt;p&gt;Exofu: /* The I/O Map */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Chapter 1 in the book [[Amstrad Whole Memory Guide]].&lt;br /&gt;
&lt;br /&gt;
== GENERAL SYSTEM ARRANGEMENT ==&lt;br /&gt;
&lt;br /&gt;
Superficially, the CPC464 is a typical Z8Ø—based system, with an unusually economical arrangement of peripheral devices. By making full use of the capabilities of these devices, a performance level has been obtained which is higher than the limited chip count might suggest. One consequence of this is that the operating system is especially complex, a fact which is offset by the comparative ease of user access to the various functions. The word ‘comparative‘ 15 necessary, because knowledge of machine code is needed, which may be a difficulty for some users, but once they have come to terms with machine code a wide range of possibilities opens up.&lt;br /&gt;
&lt;br /&gt;
Among other ingenuities, the way in which a minimum of 96K of memory has been packed into a 64K memory map is especially noteworthy, and this aspect of the system will be studied first.&lt;br /&gt;
&lt;br /&gt;
=== The Memory Map ===&lt;br /&gt;
&lt;br /&gt;
The whole of the 64K byte memory is occupied by RAM, to which any writes to memory will be directed. This makes sense, since there is r point in trying to write to ROM. Reads from addresses in the middle half of memory will also access RAM, there being no ROM in this area. For addresses in the top and bottom quarters of memory, however, both ROM and RAN are present, and it is possible to read from either at will. A BASIC peek will always access RAM, so a special bit of machine code is needed to obtain the contents of ROM.&lt;br /&gt;
&lt;br /&gt;
The memory arrangement is complicated by the fact that the top quarter of RAM is dedicated to use as screen memory, and most be immediately accessible at regular intervals while data Is being passed to the display. For this purpose, two bytes are read every microsecond.&lt;br /&gt;
&lt;br /&gt;
The processor is put into a wait state while the pairs of bytes are being transferred, the transfer being made directly from memory to the Video Gate Array, using an address generated by the CRT Controller chip. This means that the main processor can only make one memory access per microsecond, and although its clock runs at 4 MHz the actual processing speed is slightly reduced, a point to watch when calculating execution times.&lt;br /&gt;
&lt;br /&gt;
The Video Gate Array handles the switching between ROM and RAM for this purpose, so it is natural that it is also used to control ROM selection in general. The instructions for switching between ROM and RAM are given by outputs to bits 2 and 3 of port 7FXX. A 1 disables, a 0 enables, while bit 2 applies to the lower ROM and bit 3 to the upper ROM. Incidentally, there is only one ROM component, some address fiddling dividing it into two 16K blocks as far as the System is concerned.&lt;br /&gt;
&lt;br /&gt;
As in any bank-switching memory system, the key problem is the need to jump and switch banks simultaneously, or to appear to do so. The CPC464 achieves this by using routines held in central RAM. These are always accessible, whatever the ROM selection state. In addition to simple switching between ROM and RAM, these routines allow the selection of alternative upper ROMs, extending the available memory still further. In the extreme, it would nominally be possible to address a total of 4128K bytes of memory, but few systems are likely to approach that ultimate limit. &lt;br /&gt;
&lt;br /&gt;
The complexities of the memory System can be evaded by putting machine code into the central half of the memory map, which contains only RAM, but this is neither essential nor always feasible.&lt;br /&gt;
&lt;br /&gt;
=== The I/O Map ===&lt;br /&gt;
&lt;br /&gt;
The selection of peripheral channels is largely determined by making one of the bits of the upper byte of the 16—bit I/O address low, which means that the older I/O instructions of the form IN A,(N) and OUT (N),A cannot be used, because they draw the upper byte from the contents of the A register. Instructions which set the I/O address from the contents of the BC register are mandatory, and there are strict limits regarding the contents of the B register, because no more than one of the six upper bits may be low in any given address. (Making more than one of these bits low in an input instruction invites physical damage, because two data sources may fight for control of the bus, while it is rarely sensible to send the same output to two different ports at the same time.)&lt;br /&gt;
&lt;br /&gt;
The I/O addresses can be summed up as follows:&lt;br /&gt;
&lt;br /&gt;
* If address bit A15 is low, the Video Gate Array is selected. This port is for output only. The address must be 7FXX.&lt;br /&gt;
&lt;br /&gt;
* If address bit A14 is low, the CRT Controller is selected. Address bits A8 and A9 are used to select four different transfer modes:&lt;br /&gt;
&lt;br /&gt;
BCXX	Output to Register Select&lt;br /&gt;
BDXX	Data Output&lt;br /&gt;
BEXX	Status Input&lt;br /&gt;
BFXX	Data Input&lt;br /&gt;
&lt;br /&gt;
* If address bit A13 is low, ROM select data is being output. The address must be DFXX.&lt;br /&gt;
&lt;br /&gt;
* If address bit A12 is low, the printer channel is selected for output only. The address must be EFXX.&lt;br /&gt;
&lt;br /&gt;
* If address bit A11 is low, the Parallel Peripheral Interface (PPI) is selected. Here again, bits A8 and A9 are used to select four sub—channels:&lt;br /&gt;
&lt;br /&gt;
F4XX	Port A (I/O)&lt;br /&gt;
F5XX	Port B (I/O)&lt;br /&gt;
F6XX	Fort C (I/O)&lt;br /&gt;
F7XX	Control (Output only)&lt;br /&gt;
&lt;br /&gt;
* If address bit A10 is low, an expansion channel is selected. In this case, bits A5 — A7 have special significance:&lt;br /&gt;
&lt;br /&gt;
A5 low selects a communication channel.&lt;br /&gt;
A6 low selects a reserved function.&lt;br /&gt;
A7 low selects the disc System.&lt;br /&gt;
&lt;br /&gt;
* Address F8FF is a general reset for expansion channels.&lt;br /&gt;
&lt;br /&gt;
The above allocations restrict the user to the following address ranges for any special I/O functions he may require:&lt;br /&gt;
&lt;br /&gt;
F8E0—F8FE: F9E0—F9FF: FAE0—FAFF: FBE0—FBFF&lt;br /&gt;
&lt;br /&gt;
=== Outer Peripherals ===&lt;br /&gt;
&lt;br /&gt;
The devices mentioned above are the ‘inner peripherals‘, which are accessed directly from the main processor. Further devices, classed as the ‘Outer Peripherals‘, are accessed by the inner peripherals. They include the Programmable Sound Generator, accesed by the PPI; the keyboard, accessed by the PPI and the&lt;br /&gt;
&lt;br /&gt;
Sound Generator; the Cassette Recorder, accessed by the PPI; the Loudspeaker, driven by the Sound Generator.&lt;br /&gt;
&lt;br /&gt;
For further details of the hardware system, consult ‘[[The Ins &amp;amp; Outs of the Amstrad|The Ins and Outs of the Amstrad]]‘, which gives additional Information on the coding and action of these devices.&lt;br /&gt;
&lt;br /&gt;
=== System States ===&lt;br /&gt;
&lt;br /&gt;
At switch-on, a number of initialisation procedures are executed, and control then passes to upper ROM Ø. If there is no external ROM of this number, the internal BASIC interpreter takes charge as the ‘foreground‘ program.&lt;br /&gt;
&lt;br /&gt;
Once a foreground program has been entered, it remains in charge until a return at entry level is executed, when a full reset is performed, and ROM is again put in charge. However, the foreground program can call on background programs for assistance, and these, in turn, can call other programs. There is thus — nominally — one foreground level, but there can be several background levels.&lt;br /&gt;
&lt;br /&gt;
A ROM other than 0, or a program in RAM, can be selected as the foreground program. This can be done by a RUN”” command which reads a machine code program that has a defined Start address, or by a machine code routine. It may be more convenient to leave the BASIC interpreter nominally in charge and run a program CALLed from BASIC as if it was a foreground program. This has the advantage that a full reset is not inevitable in response to a return at entry level. Instead, the interpreter is re—entered.&lt;br /&gt;
&lt;br /&gt;
Using BASIC in this way has other advantages. [[HIMEM]] can be checked and adjusted quite easy putting it below the area in which machine code is to reside, and other system variables can be set up. The BASIC program will use some RAM, particularly from Ø17 upwards, but this is likely to be a negligible drain on the large RAM area available.&lt;br /&gt;
&lt;br /&gt;
One point to watch is that if extension systems are added, such as disc drive, speech facility, or the [[Maxam|MAXAM]] assembler in ROM form, HIMEM is lowered, because the extensions have claimed workspace for their own use. Some commercial programs are incompatible with a disc drive ‚ because they trespass on the disc workspace. Protected or not, they cannot be transferred to disc.&lt;br /&gt;
&lt;br /&gt;
As a guide, HIMEM is AB7F in typical circumstances, but drops to A67B with disc drives connected, and may go even lower with [[AMSDOS]] active.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Scanned pages ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:AWMG page1.jpg|page 1&lt;br /&gt;
Image:AWMG page2.jpg|page 2&lt;br /&gt;
Image:AWMG page3.jpg|page 3&lt;br /&gt;
Image:AWMG page4.jpg|page 4&lt;br /&gt;
Image:AWMG page5.jpg|page 5&lt;br /&gt;
Image:AWMG page6.jpg|page 6&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:CPC Firmware]]&lt;/div&gt;</summary>
		<author><name>Exofu</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=PSG&amp;diff=99847</id>
		<title>PSG</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=PSG&amp;diff=99847"/>
				<updated>2017-11-13T20:33:14Z</updated>
		
		<summary type="html">&lt;p&gt;Exofu: /* 0Eh - External Dataregister Port A */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Programmable Sound Generator (PSG) is able to output three separate sound channels (named Channel A, B and C). Each channel can be used to output tones and/or white noise.&lt;br /&gt;
&lt;br /&gt;
== PSG Registers ==&lt;br /&gt;
&lt;br /&gt;
The PSG has 16 read/writeable data registers, and a write-only index register. Both the index and data registers are accessed through PIO Port A, depending on the current setting of the BC1 and BDIR bits in [[8255|PPI]] Port C. The four possible combinations are:&lt;br /&gt;
  0=inactive    2=write data&lt;br /&gt;
  1=read data   3=write index&lt;br /&gt;
The procedure to write data to a specific register is as follows: Write the register number to [[8255|PPI]] Port A, set BC1/BDIR to Write Index - and back to Inactive. Now write the data to PIO Port A, set BC1/BDIR to Write Data - and back to Inactive.&lt;br /&gt;
&lt;br /&gt;
* [[How to access the PSG via PPI]]&lt;br /&gt;
&lt;br /&gt;
===00h - Channel A Tone Frequency Low  (8bit)===&lt;br /&gt;
===01h - Channel A Tone Frequency High (4bit)===&lt;br /&gt;
===02h - Channel B Tone Frequency Low  (8bit)===&lt;br /&gt;
===03h - Channel B Tone Frequency High (4bit)===&lt;br /&gt;
===04h - Channel C Tone Frequency Low  (8bit)===&lt;br /&gt;
===05h - Channel C Tone Frequency High (4bit)===&lt;br /&gt;
The tone (square wave) frequency in Hertz is calculated as follows:&lt;br /&gt;
  F = 4MHz / 64 / nn      ;with nn in range 1..4095 (nn=0 acts as nn=1)&lt;br /&gt;
Possible frequencies are in range from 62500Hz (nn=1) down to approx. 15.26Hz (nn=4095).&lt;br /&gt;
&lt;br /&gt;
===06h - Noise Frequency (5bit)===&lt;br /&gt;
The noise frequency in Hertz is calculated as follows:&lt;br /&gt;
&lt;br /&gt;
  F = 4MHz / 64 / nn      ;with nn in range 1..31 (nn=0 acts as nn=1)&lt;br /&gt;
&lt;br /&gt;
Noise can be output on all 3 channels, but there is only one noise generator (so all channels share the same noise frequency). The noise generator consists of 17bit shift register, and a 1bit noise level (0=LOW or 1=HIGH). These are updated at the selected frequency as follows:&lt;br /&gt;
&lt;br /&gt;
  noise_level = noise_level XOR shiftreg.bit0&lt;br /&gt;
  newbit = shiftreg.bit0 XOR shiftreg.bit3&lt;br /&gt;
  shiftreg = (shiftreg SHR 1) + (newbit SHL 16)&lt;br /&gt;
&lt;br /&gt;
Note that level isn't set equal to bit0, instead, it toggles when bit0=1.&lt;br /&gt;
&lt;br /&gt;
===07h - Mixer Control Register===&lt;br /&gt;
The control register enables or disables the sound channels. Each channel can output a Tone and/or Noise.&lt;br /&gt;
&lt;br /&gt;
  Bit 0  Channel A Tone   (1=off, 0=on)&lt;br /&gt;
  Bit 1  Channel B Tone   (1=off, 0=on)&lt;br /&gt;
  Bit 2  Channel C Tone   (1=off, 0=on)&lt;br /&gt;
  Bit 3  Channel A Noise  (1=off, 0=on)&lt;br /&gt;
  Bit 4  Channel B Noise  (1=off, 0=on)&lt;br /&gt;
  Bit 5  Channel C Noise  (1=off, 0=on)&lt;br /&gt;
  Bit 6  Port A Direction (1=output, 0=input) (should be always 0 for CPC)&lt;br /&gt;
  Bit 7  Port B Direction (1=output, 0=input) (not used in CPC)&lt;br /&gt;
&lt;br /&gt;
If both Tone and Noise are disabled on a channel, then a constant HIGH level is output (useful for digitized speech). If both Tone and Noise are enabled on the same channel, then the signals are ANDed (the signals aren't ADDed) (ie. HIGH is output only if both are HIGH).&lt;br /&gt;
&lt;br /&gt;
===08h - Channel A Volume  (0-0Fh=volume, 10h=use envelope instead)===&lt;br /&gt;
===09h - Channel B Volume  (0-0Fh=volume, 10h=use envelope instead)===&lt;br /&gt;
===0Ah - Channel C Volume  (0-0Fh=volume, 10h=use envelope instead)===&lt;br /&gt;
Defines the volume, 0=off, 15=max. If bit4=1, then the volume is taken from the envelope generator. The volume is non-linear. Below formula does comply with the PSG datasheet, and does more or less match the voltages measured on the CPCs speaker (the voltages on the CPCs stereo connector seem to be slightly different though).&lt;br /&gt;
  amplitude = max / sqrt(2)^(15-nn)&lt;br /&gt;
  eg. 15 --&amp;gt; max/1, 14 --&amp;gt; max/1.414, 13 --&amp;gt; max/2, etc.&lt;br /&gt;
The volume affects only HIGH levels. LOW levels are always NULL. Ie. sound output toggles between +VOL and NULL (not between +VOL and -VOL).&lt;br /&gt;
&lt;br /&gt;
Digitized samples can be written to the volume registers (mind that volume is non-linear). When doing that, it's best to switch the channel to constant HIGH level (by disabling both Tone and Noise). Another method would be to set tone frequency to 000h or 001h (the resulting frequency is too high to be audible, so the HIGH/LOW levels sound like a constant HALF level).&lt;br /&gt;
&lt;br /&gt;
=== 0Bh - Volume Envelope Frequency Low  (8bit) ===&lt;br /&gt;
=== 0Ch - Volume Envelope Frequency High (8bit) ===&lt;br /&gt;
Envelope step frequency (tone or noise) calculated as follows:&lt;br /&gt;
&lt;br /&gt;
  F = 4MHz / 64 / nn      ;with nn in range 1..65535 (nn=0 acts as nn=1)&lt;br /&gt;
&lt;br /&gt;
Depending on the envelope shape, the volume is incremented from 0 to 15, or decremented from 15 to 0. In either case it takes 16 steps to complete, the completion time for 16 steps is therefore:&lt;br /&gt;
&lt;br /&gt;
  T = nn*1024 / 4MHz      ;with nn in range 1..65535 (256us .. 16.7 seconds)&lt;br /&gt;
&lt;br /&gt;
=== 0Dh - Volume Envelope Shape (4bit) ===&lt;br /&gt;
Writing to this register (re-)starts the envelope. Additionally, the written value specifies the envelope shape, the four bits have the following meaning:&lt;br /&gt;
&lt;br /&gt;
  Bit 0  Hold        (1=stop envelope past first cycle)&lt;br /&gt;
  Bit 1  Alternate   (1=reverse direction at end of each cycle)&lt;br /&gt;
  Bit 2  Attack      (1=initial direction increase)&lt;br /&gt;
  Bit 3  Continue    (0=same as if Bit0=1 and Bit1=Bit2)&lt;br /&gt;
&lt;br /&gt;
The possible combinations and resulting shapes are:&lt;br /&gt;
&lt;br /&gt;
  Binary  Hex      Shape&lt;br /&gt;
  00XX    00h-03h  \_________  (same as 09h)&lt;br /&gt;
  01XX    04h-07h  /_________  (same as 0Fh)&lt;br /&gt;
  1000    08h      \\\\\\\\\\&lt;br /&gt;
  1001    09h      \_________  (volume remains quiet)&lt;br /&gt;
  1010    0Ah      \/\/\/\/\/&lt;br /&gt;
  1011    0Bh      \&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;  (volume remains high)&lt;br /&gt;
  1100    0Ch      //////////&lt;br /&gt;
  1101    0Dh      /&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;  (volume remains high)&lt;br /&gt;
  1110    0Eh      /\/\/\/\/\&lt;br /&gt;
  1111    0Fh      /_________  (volume remains quiet)&lt;br /&gt;
&lt;br /&gt;
When using the volume envelope generator, the volume is always increased from 00h to 0Fh (or vice versa), it is not possible to specify a starting/ending point (like from 00h to 07h).&lt;br /&gt;
&lt;br /&gt;
=== 0Eh - External Dataregister Port A ===&lt;br /&gt;
This register receives data from the CPC keyboard (or joystick), for more information read the chapter about the [[Programming:Keyboard_scanning|CPC Keyboard Matrix]]. This register can be also used as output port by setting bit 6 of the PSG control register to 1 (that would allow to use the six data pins of the joystick connector to output data to external hardware).&lt;br /&gt;
&lt;br /&gt;
=== 0Fh - External Dataregister Port B ===&lt;br /&gt;
This register is not used in CPC computers. In detail, a AY-3-8910 sound chip would have external connectors for this register, so that it could be used as a further IO port, but the CPC's sound chip (AY-3-8912, in 28 pin package) doesn't have such connectors, even though the register still does exist internally.&lt;br /&gt;
The [[Aleste 520EX]] (russian CPC clone) is a special case: does have a 8910 chip, with PSG Port B being used as 8bit printer port data.&lt;br /&gt;
&lt;br /&gt;
== Mono and Stereo Output ==&lt;br /&gt;
When using the CPC's external stereo jack, channel A is output to the right, channel C is output left, and channel B is output to both left and right, in that case channel B is output through a bigger resistor to prevent that this channel appears loader than the others.&lt;br /&gt;
&lt;br /&gt;
Otherwise (when using the built-in speaker), all three channels are mixed at the same intensity. This signal appears to be also sent to the Tape output line also, so a connected Data Recorder could be used to record CPC music also.&lt;br /&gt;
&lt;br /&gt;
== Datasheet ==&lt;br /&gt;
* [[Media:Ay3-891x.pdf|AY-3-891x datasheet]]&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/General_Instrument_AY-3-8910 Wikipedia on the PSG]&lt;br /&gt;
&lt;br /&gt;
== Video ==&lt;br /&gt;
&lt;br /&gt;
Introduction to the AY-3-8912&lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|eSfoQKiXo5g|200}}&lt;br /&gt;
&lt;br /&gt;
Amstrad CPC6128 playing [[MYM files]] &lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|PTslbiAbb5A|200}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:Music and sound| ]]&lt;br /&gt;
[[Category:Video contents]][[Category:CPC Internal Components]]&lt;/div&gt;</summary>
		<author><name>Exofu</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=PSG&amp;diff=99846</id>
		<title>PSG</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=PSG&amp;diff=99846"/>
				<updated>2017-11-13T18:28:53Z</updated>
		
		<summary type="html">&lt;p&gt;Exofu: Fix typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Programmable Sound Generator (PSG) is able to output three separate sound channels (named Channel A, B and C). Each channel can be used to output tones and/or white noise.&lt;br /&gt;
&lt;br /&gt;
== PSG Registers ==&lt;br /&gt;
&lt;br /&gt;
The PSG has 16 read/writeable data registers, and a write-only index register. Both the index and data registers are accessed through PIO Port A, depending on the current setting of the BC1 and BDIR bits in [[8255|PPI]] Port C. The four possible combinations are:&lt;br /&gt;
  0=inactive    2=write data&lt;br /&gt;
  1=read data   3=write index&lt;br /&gt;
The procedure to write data to a specific register is as follows: Write the register number to [[8255|PPI]] Port A, set BC1/BDIR to Write Index - and back to Inactive. Now write the data to PIO Port A, set BC1/BDIR to Write Data - and back to Inactive.&lt;br /&gt;
&lt;br /&gt;
* [[How to access the PSG via PPI]]&lt;br /&gt;
&lt;br /&gt;
===00h - Channel A Tone Frequency Low  (8bit)===&lt;br /&gt;
===01h - Channel A Tone Frequency High (4bit)===&lt;br /&gt;
===02h - Channel B Tone Frequency Low  (8bit)===&lt;br /&gt;
===03h - Channel B Tone Frequency High (4bit)===&lt;br /&gt;
===04h - Channel C Tone Frequency Low  (8bit)===&lt;br /&gt;
===05h - Channel C Tone Frequency High (4bit)===&lt;br /&gt;
The tone (square wave) frequency in Hertz is calculated as follows:&lt;br /&gt;
  F = 4MHz / 64 / nn      ;with nn in range 1..4095 (nn=0 acts as nn=1)&lt;br /&gt;
Possible frequencies are in range from 62500Hz (nn=1) down to approx. 15.26Hz (nn=4095).&lt;br /&gt;
&lt;br /&gt;
===06h - Noise Frequency (5bit)===&lt;br /&gt;
The noise frequency in Hertz is calculated as follows:&lt;br /&gt;
&lt;br /&gt;
  F = 4MHz / 64 / nn      ;with nn in range 1..31 (nn=0 acts as nn=1)&lt;br /&gt;
&lt;br /&gt;
Noise can be output on all 3 channels, but there is only one noise generator (so all channels share the same noise frequency). The noise generator consists of 17bit shift register, and a 1bit noise level (0=LOW or 1=HIGH). These are updated at the selected frequency as follows:&lt;br /&gt;
&lt;br /&gt;
  noise_level = noise_level XOR shiftreg.bit0&lt;br /&gt;
  newbit = shiftreg.bit0 XOR shiftreg.bit3&lt;br /&gt;
  shiftreg = (shiftreg SHR 1) + (newbit SHL 16)&lt;br /&gt;
&lt;br /&gt;
Note that level isn't set equal to bit0, instead, it toggles when bit0=1.&lt;br /&gt;
&lt;br /&gt;
===07h - Mixer Control Register===&lt;br /&gt;
The control register enables or disables the sound channels. Each channel can output a Tone and/or Noise.&lt;br /&gt;
&lt;br /&gt;
  Bit 0  Channel A Tone   (1=off, 0=on)&lt;br /&gt;
  Bit 1  Channel B Tone   (1=off, 0=on)&lt;br /&gt;
  Bit 2  Channel C Tone   (1=off, 0=on)&lt;br /&gt;
  Bit 3  Channel A Noise  (1=off, 0=on)&lt;br /&gt;
  Bit 4  Channel B Noise  (1=off, 0=on)&lt;br /&gt;
  Bit 5  Channel C Noise  (1=off, 0=on)&lt;br /&gt;
  Bit 6  Port A Direction (1=output, 0=input) (should be always 0 for CPC)&lt;br /&gt;
  Bit 7  Port B Direction (1=output, 0=input) (not used in CPC)&lt;br /&gt;
&lt;br /&gt;
If both Tone and Noise are disabled on a channel, then a constant HIGH level is output (useful for digitized speech). If both Tone and Noise are enabled on the same channel, then the signals are ANDed (the signals aren't ADDed) (ie. HIGH is output only if both are HIGH).&lt;br /&gt;
&lt;br /&gt;
===08h - Channel A Volume  (0-0Fh=volume, 10h=use envelope instead)===&lt;br /&gt;
===09h - Channel B Volume  (0-0Fh=volume, 10h=use envelope instead)===&lt;br /&gt;
===0Ah - Channel C Volume  (0-0Fh=volume, 10h=use envelope instead)===&lt;br /&gt;
Defines the volume, 0=off, 15=max. If bit4=1, then the volume is taken from the envelope generator. The volume is non-linear. Below formula does comply with the PSG datasheet, and does more or less match the voltages measured on the CPCs speaker (the voltages on the CPCs stereo connector seem to be slightly different though).&lt;br /&gt;
  amplitude = max / sqrt(2)^(15-nn)&lt;br /&gt;
  eg. 15 --&amp;gt; max/1, 14 --&amp;gt; max/1.414, 13 --&amp;gt; max/2, etc.&lt;br /&gt;
The volume affects only HIGH levels. LOW levels are always NULL. Ie. sound output toggles between +VOL and NULL (not between +VOL and -VOL).&lt;br /&gt;
&lt;br /&gt;
Digitized samples can be written to the volume registers (mind that volume is non-linear). When doing that, it's best to switch the channel to constant HIGH level (by disabling both Tone and Noise). Another method would be to set tone frequency to 000h or 001h (the resulting frequency is too high to be audible, so the HIGH/LOW levels sound like a constant HALF level).&lt;br /&gt;
&lt;br /&gt;
=== 0Bh - Volume Envelope Frequency Low  (8bit) ===&lt;br /&gt;
=== 0Ch - Volume Envelope Frequency High (8bit) ===&lt;br /&gt;
Envelope step frequency (tone or noise) calculated as follows:&lt;br /&gt;
&lt;br /&gt;
  F = 4MHz / 64 / nn      ;with nn in range 1..65535 (nn=0 acts as nn=1)&lt;br /&gt;
&lt;br /&gt;
Depending on the envelope shape, the volume is incremented from 0 to 15, or decremented from 15 to 0. In either case it takes 16 steps to complete, the completion time for 16 steps is therefore:&lt;br /&gt;
&lt;br /&gt;
  T = nn*1024 / 4MHz      ;with nn in range 1..65535 (256us .. 16.7 seconds)&lt;br /&gt;
&lt;br /&gt;
=== 0Dh - Volume Envelope Shape (4bit) ===&lt;br /&gt;
Writing to this register (re-)starts the envelope. Additionally, the written value specifies the envelope shape, the four bits have the following meaning:&lt;br /&gt;
&lt;br /&gt;
  Bit 0  Hold        (1=stop envelope past first cycle)&lt;br /&gt;
  Bit 1  Alternate   (1=reverse direction at end of each cycle)&lt;br /&gt;
  Bit 2  Attack      (1=initial direction increase)&lt;br /&gt;
  Bit 3  Continue    (0=same as if Bit0=1 and Bit1=Bit2)&lt;br /&gt;
&lt;br /&gt;
The possible combinations and resulting shapes are:&lt;br /&gt;
&lt;br /&gt;
  Binary  Hex      Shape&lt;br /&gt;
  00XX    00h-03h  \_________  (same as 09h)&lt;br /&gt;
  01XX    04h-07h  /_________  (same as 0Fh)&lt;br /&gt;
  1000    08h      \\\\\\\\\\&lt;br /&gt;
  1001    09h      \_________  (volume remains quiet)&lt;br /&gt;
  1010    0Ah      \/\/\/\/\/&lt;br /&gt;
  1011    0Bh      \&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;  (volume remains high)&lt;br /&gt;
  1100    0Ch      //////////&lt;br /&gt;
  1101    0Dh      /&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;  (volume remains high)&lt;br /&gt;
  1110    0Eh      /\/\/\/\/\&lt;br /&gt;
  1111    0Fh      /_________  (volume remains quiet)&lt;br /&gt;
&lt;br /&gt;
When using the volume envelope generator, the volume is always increased from 00h to 0Fh (or vice versa), it is not possible to specify a starting/ending point (like from 00h to 07h).&lt;br /&gt;
&lt;br /&gt;
=== 0Eh - External Dataregister Port A ===&lt;br /&gt;
This register receives data from the CPC keyboard (or joystick), for more information read the chapter about the CPC Keyboard Matrix. This register can be also used as output port by setting bit 6 of the PSG control register to 1 (that would allow to use the six data pins of the joystick connector to output data to external hardware).&lt;br /&gt;
&lt;br /&gt;
=== 0Fh - External Dataregister Port B ===&lt;br /&gt;
This register is not used in CPC computers. In detail, a AY-3-8910 sound chip would have external connectors for this register, so that it could be used as a further IO port, but the CPC's sound chip (AY-3-8912, in 28 pin package) doesn't have such connectors, even though the register still does exist internally.&lt;br /&gt;
The [[Aleste 520EX]] (russian CPC clone) is a special case: does have a 8910 chip, with PSG Port B being used as 8bit printer port data.&lt;br /&gt;
&lt;br /&gt;
== Mono and Stereo Output ==&lt;br /&gt;
When using the CPC's external stereo jack, channel A is output to the right, channel C is output left, and channel B is output to both left and right, in that case channel B is output through a bigger resistor to prevent that this channel appears loader than the others.&lt;br /&gt;
&lt;br /&gt;
Otherwise (when using the built-in speaker), all three channels are mixed at the same intensity. This signal appears to be also sent to the Tape output line also, so a connected Data Recorder could be used to record CPC music also.&lt;br /&gt;
&lt;br /&gt;
== Datasheet ==&lt;br /&gt;
* [[Media:Ay3-891x.pdf|AY-3-891x datasheet]]&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/General_Instrument_AY-3-8910 Wikipedia on the PSG]&lt;br /&gt;
&lt;br /&gt;
== Video ==&lt;br /&gt;
&lt;br /&gt;
Introduction to the AY-3-8912&lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|eSfoQKiXo5g|200}}&lt;br /&gt;
&lt;br /&gt;
Amstrad CPC6128 playing [[MYM files]] &lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|PTslbiAbb5A|200}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:Music and sound| ]]&lt;br /&gt;
[[Category:Video contents]][[Category:CPC Internal Components]]&lt;/div&gt;</summary>
		<author><name>Exofu</name></author>	</entry>

	</feed>