Changes
/* External links */
Gate Array
In the [[KC compact]] CPC+ system, the functions of the Gate-Array are "emulated" in integrated into a single [[TTL logicASIC|ASIC]] . When the ASIC is "locked", the extra features are not available and by the [[Zilog Z8536 CIO]]ASIC operates the same as the Gate-Array in the CPC allowing programs written for the CPC to work on the Plus without modification. The ASIC must be "un-locked" to access the new features.
In the "cost-down" version of the CPC6128[[KC Compact]] system, the functions of the Gate-Array are integrated into a ASIC"emulated" in TTL chips, [[CIO Overview|CIO]], and its color translation EPROM.
The recommended gate array is controlled by I/O. The gate array is selected when bit 15 of the I/O port address is set to "0" and bit 14 of the I/O port address is &7Fxxset to "1". The values of the other bits are ignored. However, to avoid conflict with other devices in the system, these bits should be set to "1".
The recommended I/O port address is &7Fxx. The function to be performed is selected by writing data to the Gate-Array, bit 7 and 6 of the data define the function selected (see table below). It is not possible to read from the Gate-Array.
{|{{Prettytable|width: 700px; font-size: 2em;}}
|-
|0''Data Bit 7''||0''Data Bit 6''||Select pen''Function''
|-
|0||10 ||Select colour for selected pen
|-
|10 ||01 ||Select screen mode, rom configuration and interrupt controlcolour for selected pen
|-
| 1 || 0 || Select screen mode, ROM configuration and interrupt control|-|1||1||Ram RAM Memory Management (note 1)
|-
|}
===== Note ===== This function is not available in the Gate-Array, but is performed by a device at the same I/O port address location. In the CPC464,CPC664 and KC compact, this function is performed in a memory-expansion (e.g. Dk'Tronics 64K Ram Expansion), if this expansion is not present then the function is not available. In the CPC6128, this function is performed by a PAL located on the main PCB, or a memory-expansion. In the 464+ and 6128+ this function is performed by the ASIC or a memory expansion. Please read the document on Ram Management for more information.
=== Summary ===
{|{{Prettytable|width: 700px; font-size: 2em;}}
|-
|7''Bit'' ||0''Value'' ||rowspan=2|Gate Array function "Pen Selection"''Function''
|-
|67 ||0|| rowspan="2" | Gate Array function "Pen Selection"
|-
|56 ||-||not used0
|-
|45 ||1- ||Select bordernot used
|-
|34 ||x1 ||rowspan=4|IgnoredSelect border
|-
|23 ||x|| rowspan="4" | Ignored
|-
|12 ||x
|-
|01 ||x
|-
| 0 || x
|}
<br>
{|{{Prettytable|width: 700px; font-size: 2em;}}
|-
|7''Bit'' ||0''Value'' ||rowspan=2|Gate Array function "Pen Selection"''Function''
|-
|67 ||0|| rowspan="2" | Gate Array function "Pen Selection"
|-
|56 ||-||not used0
|-
|45 ||1- ||Select pennot used
|-
|34 ||x0 ||rowspan=4|Pen numberSelect pen
|-
|23 ||x|| rowspan="4" | Pen number
|-
|12 ||x
|-
|01 ||x
|-
| 0 || x
|}
==== Register 1 - Palette Data (Colour selection ==) ==
Once the pen has been selected the its colour can then be changed. Bits 4 to 0 specify the hardware colour number from the hardware colour palette.
Even though there is provision for 32 colours, only 27 are possible. The remaining colours are duplicates of those already in the colour palette.
{|{{Prettytable|width: 700px; font-size: 2em;}}
|-
|7''Bit'' ||0''Value'' ||rowspan=2|Gate Array function "Colour selection"''Function''
|-
|67 ||10 || rowspan="2" | Gate Array function "Colour selection"
|-
|56 ||-||not used1
|-
|45 ||x- ||rowspan=5|Colour number xnot used
|-
|34 ||x || rowspan="5" | Colour number x
|-
|23 ||x
|-
|12 ||x
|-
|01 ||x
|-
| 0 || x
|}
==Register 2 - Select screen mode and ROM configuration == Hardware colour palette This is a general purpose register responsible for the [[Video modes|screen mode]] and the ROM configuration. ===Screen mode selection === The function of bits 1 and 0 is to define the screen mode. The settings for bits 1 and 0 and the corresponding screen mode are given in the table below.
{|{{Prettytable|width: 700px; font-size: 2em;}}
|-
|0''Bit 1'' ||White|''Bit 0'' |bgcolor="#808080"|''Screen mode''
|-
|10 ||White (note 1)0 ||bgcolor="#808080"|Mode 0, 160x200 resolution, 16 colours
|-
|20 ||Sea Green1 ||bgcolor="#00FF80"|Mode 1, 320x200 resolution, 4 colours
|-
|3||Pastel Yellow||bgcolor="#FFFF50"||-|4||Blue||bgcolor="#000080"||-|5||Purple||bgcolor="#FF0080"||-|6||Cyan||bgcolor="#008080"||-|7||Pink||bgcolor="#FF8080"||-|8||Purple (note 1)||bgcolor="#FF0080"||-|9||Pastel Yellow (note 1)||bgcolor="#FFFF50"||-|10||Bright Yellow||bgcolor="#FFFF80"||-|11||Bright White|-|12||Bright Red|-|13||Bright Magenta|-|14||Orange|-|15||Pastel Magenta|-|16||Blue (note 1)||bgcolor="#000080"||-|17||Sea Green (note 1)||bgcolor="#00FF80"||-|18||Bright Green|-|19||Bright Cyan|-|20||Black|-|21||Bright Blue|-|22||Green|-|23||Sky Blue|-|24||Magenta|-|25||Pastel Green|-|26||Lime|-|27||Pastel Cyan|-|28||Red|-|29||Mauve|-|30||Yellow|-|31||Pastel Blue|0 |bgcolor="#8080FF"|Mode 2, 640x200 resolution, 2 colours
|-
| 1 || 1 || Mode 3, 160x200 resolution, 4 colours (undocumented)
|}
{|{{Prettytable|width: 700px; font-size: 2em;}}
|-
|0''Bit'' ||0''Value'' ||Mode 0, 160x200 resolution, 16 colours''Function''
|-
|07 ||1||Mode 1, 320x200 resolution, 4 coloursrowspan="2" | Gate Array function
|-
|16 ||0||Mode 2, 640x200 resolution, 2 colours
|-
|15 ||1- ||Mode 3, 160x200 resolution, 4 colours (note 1)not used
|-
| 4 || x || Interrupt generation control
|-
| 3 || x || 1=Upper ROM area disable, 0=Upper ROM area enable
|-
| 2 || x || 1=Lower ROM area disable, 0=Lower ROM area enable
|-
| 1 || x || rowspan="2" | Screen Mode slection
|-
| 0 || x
|}
{|{{Prettytable|width: 700px; font-size: 2em;}}
|-
|7''Bit'' ||0''Value'' ||rowspan=2|Gate Array function ''Function''
|-
|67 ||1|| rowspan="2" | Gate Array function 3
|-
|56 ||-||not used1
|-
|45 ||xb ||Interrupt generation controlrowspan="3" |64K bank number (0..7); always 0 on an unexpanded CPC6128, 0-7 on [[Standard Memory Expansions]]
|-
|34 ||x||*1 Upper rom area disable*0 Upper rom area enableb
|-
|23 ||x||*1 Lower rom area disable*0 Lower rom area enableb
|-
|12 ||x||rowspan=2"3" |Mode slectionRAM Config (0..7)
|-
|01 ||x
|-
| 0 || x
|}
The Video RAM is always located in the first 64K, VRAM is in no way affected by this register. == Programming the Gate Array - Examples == Defining the colours, <prebr>Setting pen 0 to Bright White. <pre>LD BC,7F00 ;Gate Array portLD A,%00000000+0 ;Pen number (and Gate Array function)OUT (C),A ;Send pen numberLD A,%01000000+11 ;Pen colour (and Gate Array function)OUT (C),A ;Send it
RET
Setting the mode and rom ROM configuration, Mode 2, upper and lower rom ROM disabled.
LD BC,7F00 ;Gate array portLD A,%10000000+%00001110 ;Mode and rom ROM selection (and Gate Array function)OUT (C),A ;Send it
RET
</pre>
==== Conversion chart =Misc ===
The hardware colour number is different to the colour range used by the firmware, so a conversion chart is provided for the corresponding firmware/hardware colour values and the corresponding colour name.
The firmware keeps track of the colours it is using. Every VSYNC (assuming interrupts are enabled) the firmware sets the colours. This enables the user to have flashing colours. If the user selects a new colour using the gate array, the new colour will flash temporarily and then return to it's its original colour. This is due to the firmware re- setting resetting the colour. When using the firmware, use it's its routines to select the colour, and the colour will remain.
;and pen number
out (c),c
ld bc,7f00 ;41
;Gate array function (set colour)
;and colour number
</pre>
==== Pallette Palette R,G,B definitions ====
There are 27 colours which are generated from red, green and blue mixed in different quantities. There are 3 levels of red, 3 levels of green and 3 levels of blue, and these can be thought of as off/no colour, half-on/half-colour, and on/full-colour.
To display a CPC image you will need to use a analogue monitor with a composite sync.
{|{{Prettytable|width: 700px; font-size: 2em;}}|''Hardware Colour Index''||''Colour Name''||''R %''||''G %''||''B %''||''Color'' class="FCK__ShowTableBorders"
|-
|0''Hardware Number||WhiteFirmware Number||align="right"''Colour Name'' |50''R %'' ||align="right"''G %'' |50|''B %'' |align="right"|50||bgcolor="#808080"|''Colour''
|-
|1 0 (40h) || 13 ||White ||align="right"|50||align="right"|50||align="right"|50||bgcolor="#808080"|
|-
|2 1 (41h) ||Sea Green(13) ||align="right"White |0|50|align="right"|10050||align="right"|50||bgcolor="#00FF80808080"|
|-
|3 2 (42h) ||Pastel Yellow19 ||align="right"Sea Green |100| 0|align="right"|100||align="right"|50||bgcolor="#FFFF8000ff80"|
|-
|4 3 (43h) ||Blue25 ||align="right"Pastel Yellow |0|100|align="right"|0100||align="right"|50||bgcolor="#000080ffff80"|
|-
|5 4 (44h) ||Purple1 ||align="right"Blue |100| 0|align="right"| 0||align="right"|50||bgcolor="#FF0080000080"|
|-
|6 5 (45h) ||Cyan7 ||align="right"Purple |0|100|align="right"|50 0||align="right"|50||bgcolor="#008080ff0080"|
|-
|7 6 (46h) ||Pink10 ||align="right"Cyan |100| 0|align="right"|50||align="right"|50||bgcolor="#FF8080008080"|
|-
|8 7 (47h) ||Purple16 ||align="right"Pink ||100||align="right"50|0||align="right"|50||bgcolor="#FF0080ff8080"|
|-
|9 8 (48h) ||Pastel Yellow(7) ||align="right"Purple ||100||align="right" 0|100||align="right"|50||bgcolor="#FFFF80ff0080"|
|-
|10 9 (49h) ||Bright (25) || Pastel Yellow||align="right"|100||align="right"|100||align="right"|050||bgcolor="#FFFF00ffff80"|
|-
|1110 (4Ah) || 24 ||Bright WhiteYellow ||align="right"|100||align="right"|100||align="right"|100 0||bgcolor="#FFFFFFffff00"|
|-
|1211 (4Bh) || 26 ||Bright RedWhite ||align="right"|100||align="right"100|0||align="right"|0100||bgcolor="#FF0000ffffff"|
|-
|1312 (4Ch) || 6 ||Bright MagentaRed ||align="right"|100||align="right"| 0||align="right"|100 0||bgcolor="#FF00FFff0000"|
|-
|1413 (4Dh) ||Orange8 ||align="right"Bright Magenta||100||align="right" 0|50||align="right"|0100||bgcolor="#FF8000ff00ff"|
|-
| 14 (4Eh) ||15 ||Pastel MagentaOrange ||align="right"|100||align="right"|50||align="right"|100 0||bgcolor="#FF80FFff8000"|
|-
|1615 (4Fh) ||Blue17 ||align="right"Pastel Magenta|0|100|align="right"|050||align="right"|50100||bgcolor="#000080ff80ff"|
|-
|1716 (50h) ||Sea Green(1) ||align="right"Blue || 0||align="right" 0|100||align="right"|50||bgcolor="#00FF80000080"|
|-
|1817 (51h) ||Bright (19) || Sea Green ||align="right"| 0||align="right"|100||align="right"|050||bgcolor="#00FF0000ff80"|
|-
|1918 (52h) || 18 ||Bright CyanGreen ||align="right"| 0||align="right"|100||align="right"|100 0||bgcolor="#00FFFF00ff00"|
|-
| 19 (53h) ||20 ||BlackBright Cyan ||align="right"| 0||align="right"100|0||align="right"|0100||bgcolor="#00000000ffff"|
|-
|2120 (54h) ||Bright Blue0 ||align="right"Black || 0||align="right"| 0||align="right"|100 0||bgcolor="#0000FF000000"|
|-
|2221 (55h) ||Green2 ||align="right"Bright Blue || 0||align="right" 0|50||align="right"|0100||bgcolor="#0080000000ff"|
|-
|2322 (56h) ||Sky Blue9 ||align="right"Green || 0||align="right"|50||align="right"|100 0||bgcolor="#0080FF008000"|
|-
|2423 (57h) ||Magenta11 ||align="right"Sky Blue |50| 0|align="right"|050||align="right"|50100||bgcolor="#8000800080ff"|
|-
|2524 (58h) ||Pastel Green4 ||align="right"Magenta ||50||align="right" 0|100||align="right"|50||bgcolor="#80FF80800080"|
|-
|2625 (59h) ||Lime22 ||align="right"Pastel Green ||50||align="right"|100||align="right"|050||bgcolor="#80FF0080ff80"|
|-
|2726 (5Ah) ||Pastel Cyan21 ||align="right"Lime ||50||align="right"|100||align="right"|100 0||bgcolor="#80FFFF80ff00"|
|-
|2827 (5Bh) ||Red23 ||align="right"Pastel Cyan ||50||align="right"100|0||align="right"|0100||bgcolor="#80000080ffff"|
|-
|2928 (5Ch) ||Mauve3 ||align="right"Red ||50||align="right"| 0||align="right"|100 0||bgcolor="#8000FF800000"|
|-
|3029 (5Dh) ||Yellow5 ||align="right"Mauve ||50||align="right" 0|50||align="right"|0100||bgcolor="#8080008000ff"|
|-
|3130 (5Eh) ||Pastel Blue12 ||align="right"Yellow ||50||align="right"|50||align="right"|100 0||bgcolor="#8080FF808000"|
|-
| 31 (5Fh) || 14 || Pastel Blue || 50|| 50||100|| bgcolor="#8080ff" |
|}
==== RGB assignments for the software colours =Palette sorted by Firmware Colour Numbers ===
|-
|0''Firmware Number'' ||Black''Hardware Number'' ||0''Colour Name'' |''R %'' |0|''G %'' |0|''B %'' |bgcolor="#000000"| ''Colour''
|-
|10||Blue54h ||Black || 0|| 0||50 0||bgcolor="#000080000000"|
|-
|21|| 44h (or 50h) ||Bright Blue || 0|| 0||10050||bgcolor="#0000FF000080"|
|-
|32||Red55h ||50Bright Blue || 0|| 0||100||bgcolor="#8000000000ff"|
|-
|43||Magenta5Ch ||Red ||50|| 0||50 0||bgcolor="#800080800000"|
|-
|54||Mauve58h ||Magenta ||50|| 0||10050||bgcolor="#8000FF800080"|
|-
|65||Bright Red5Dh ||100Mauve ||050|| 0||100||bgcolor="#FF00008000ff"|
|-
|76||Purple4Ch ||Bright Red ||100|| 0||50 0||bgcolor="#FF0080ff0000"|
|-
|87||Bright Magenta45h (or 48h) ||Purple ||100|| 0||10050||bgcolor="#FF00FFff0080"|
|-
|98||Green4Dh ||0Bright Magenta ||50100|| 0||100||bgcolor="#008000ff00ff"|
|-
|109||Cyan56h ||Green || 0||50||50 0||bgcolor="#008080008000"|
|-
|1110||Sky Blue46h ||Cyan || 0||50||10050||bgcolor="#0080FF008080"|
|-
|1211||Yellow57h ||50Sky Blue || 0||50||0100||bgcolor="#8080000080ff"|
|-
|1312||White5Eh ||50Yellow ||50||50|| 0||bgcolor="#808080808000"|
|-
|1413||Pastel Blue40h (or 41h) ||White ||50||50||10050||bgcolor="#8080FF808080"|
|-
|1514||Orange5Fh ||100Pastel Blue ||50||050||100||bgcolor="#FF80008080ff"|
|-
|1615||Pink4Eh ||Orange ||100||50||50 0||bgcolor="#FF8080ff8000"|
|-
|1716||Pastel Magenta47h ||Pink ||100||50||10050||bgcolor="#FF80FFff8080"|
|-
|1817||Bright Green4Fh ||0Pastel Magenta ||100||050||100||bgcolor="#00FF00ff80ff"|
|-
|1918||Sea 52h ||Bright Green || 0||100||50 0||bgcolor="#00FF8000ff00"|
|-
|2019||Bright Cyan42h (or 51h) ||Sea Green || 0||100||10050||bgcolor="#00FFFF00ff80"|
|-
|2120||Lime53h ||50Bright Cyan || 0||100||0100||bgcolor="#80FF0000ffff"|
|-
|2221||Pastel Green5Ah ||Lime ||50||100||50 0||bgcolor="#80FF8080ff00"|
|-
|2322|| 59h ||Pastel CyanGreen ||50||100||10050||bgcolor="#80FFFF80ff80"|
|-
|2423||Bright Yellow5Bh ||100Pastel Cyan || 50||100||0100||bgcolor="#FFFF0080ffff"|
|-
|2524||Pastel 4Ah ||Bright Yellow ||100||100||50 0||bgcolor="#FFFF80ffff00"|
|-
|2625||Bright White43h (or 49h) ||100Pastel Yellow ||100||100|| 50||bgcolor="#FFFFFFffff80"|
|-
|26|| 4Bh ||Bright White ||100||100||100||bgcolor="#ffffff"|
|}
===== To calculate the colour value ==Intensities ===
The 0%, 50%, and 100% values in the above tables are "should-be" values. However, the real hardware doesn't exactly match that intensities. The actual intensities depend on the luminance mixing (R,G,B tied together via resistors), on chipset (classic CPC, or newer ASIC ones), and on the load applied by external hardware (Monitor, or TV set).* [[CPC Palette]] - some more details === To calculate the colour value === '''Red'''
0% => do not add anything
50% => add 3 100% => add 6 '''Green''' 0% => do not add anything 50% => add 9 100% => add 18 '''Blue''' 0% => do not add anything 50% => add 1 100% => add 2
[[Category:Hardware]][[Category:Programming]][[Category:Datasheet]][[Category:Graphic]][[Category:CPC Internal Components]][[Category:Electronic Component]]