Gate Array

From CPCWiki

Jump to: navigation, search

Gate Array

Contents

Introduction

The gate array is a specially designed chip exclusively for use in the Amstrad CPC and was designed by Amstrad plc.

In the CPC+ system, the functions of the Gate-Array are integrated into a single ASIC. When the ASIC is "locked", the extra features are not available and the 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 KC compact system, the functions of the Gate-Array are "emulated" in TTL logic and by the Zilog Z8536 CIO.

In the "cost-down" version of the CPC6128, the functions of the Gate-Array are integrated into a ASIC.

The Gate Array is described here, as it is in a standard CPC.

What does it do?

The Gate Array is responsible for the display (colour palette, resolution, horizontal and vertical sync), interrupt generation and memory arrangement.

Controlling the Gate Array

The 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 set 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.

Bit 7Bit 6Function
00Select pen
01Select colour for selected pen
10Select screen mode, rom configuration and interrupt control
11Ram 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.

Pen selection

When bit 7 and bit 6 are set to "0", the remaining bits determine which pen is to have its colour changed. When bit 4 is set to "0", bits 3 to 0 define which pen is to be selected. When bit 4 is set to "1", the value contained in bits 3-0 is ignored and the border is selected.

The pen remains selected until another is chosen.

Each mode has a fixed number of pens. Mode 0 has 16 pens, mode 1 has 4 pens and mode 2 has 2 pens.

Summary
BitValueFunction
70Gate Array function "Pen Selection"
60
5-not used
41Select border
3xIgnored
2x
1x
0x


BitValueFunction
70Gate Array function "Pen Selection"
60
5-not used
41Select pen
3xPen number
2x
1x
0x

Colour selection

Once the pen has been selected the 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.

Summary
BitValueFunction
70Gate Array function "Colour selection"
61
5-not used
4xColour number x
3x
2x
1x
0x

Hardware colour palette

Colour NumberColour NameColor
0White
1White (note 1)
2Sea Green
3Pastel Yellow
4Blue
5Purple
6Cyan
7Pink
8Purple (note 1)
9Pastel Yellow (note 1)
10Bright Yellow
11Bright White
12Bright Red
13Bright Magenta
14Orange
15Pastel Magenta
16Blue (note 1)
17Sea Green (note 1)
18Bright Green
19Bright Cyan
20Black
21Bright Blue
22Green
23Sky Blue
24Magenta
25Pastel Green
26Lime
27Pastel Cyan
28Red
29Mauve
30Yellow
31Pastel Blue
Notes

This is not an official colour

Select screen mode and rom configuration

This is a general purpose register responsible for the 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.

Bit 1Bit 0Screen mode
00Mode 0, 160x200 resolution, 16 colours
01Mode 1, 320x200 resolution, 4 colours
10Mode 2, 640x200 resolution, 2 colours
11Mode 3, 160x200 resolution, 4 colours (note 1)

This mode is not official. From the combinations possible, we can see that 4 modes can be defined, although the Amstrad only has 3. Mode 3 is similar to mode 0, because it has the same resolution, but it is limited to only 4 colours.

Mode changing is synchronised with HSYNC. If the mode is changed, it will take effect from the next HSYNC.

Rom configuration selection

Bit 2 is used to enable or disable the lower rom area. The lower rom area occupies memory addressess &0000-&3fff and is used to access the operating system rom. When the lower rom area is is enabled, reading from &0000-&3FFF will return data in the rom. When a value is written to &0000-&3FFF, it will be written to the ram underneath the rom. When it is disabled, data read from &0000-&3FFF will return the data in the ram.

Similarly, bit 3 controls enabling or disabling of the upper rom area. The upper rom area occupies memory addressess &C000-&FFFF and is BASIC or any expansion roms which may be plugged into a rom board/box. See the document on upper rom selection for more details. When the upper rom area enabled, reading from &c000-&ffff, will return data in the rom. When data is written to &c000-&FFFF, it will be written to the ram at the same address as the rom. When the upper rom area is disabled, and data is read from &c000-&ffff the data returned will be the data in the ram.

Bit 4 controls the interrupt generation. It can be used to delay interrupts. See the document on interrupt generation for more information.

Summary
BitValueFunction
70Gate Array function
61
5-not used
4xInterrupt generation control
3x
  • 1 Upper rom area disable
  • 0 Upper rom area enable
2x
  • 1 Lower rom area disable
  • 0 Lower rom area enable
1xMode slection
0x

Programming the Gate Array - Examples

Defining the colours,
Setting pen 0 to Bright White.

LD BC,7F00 ;Gate Array port
LD A,%00000000+0 ;Pen number (and Gate Array function)
OUT (C),A ;Send pen number
LD A,%01000000+11 ;Pen colour (and Gate Array function)
OUT (C),A ;Send it
RET

Setting the mode and rom configuration, 
Mode 2, upper and lower rom disabled.

LD BC,7F00 ;Gate array port
LD A,%10000000+%00001110 ;Mode and rom selection (and Gate Array function)
OUT (C),A ;Send it
RET

Conversion chart

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.

Note

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 original colour. This is due to the firmware re- setting the colour. When using the firmware, use it's routines to select the colour, and the colour will remain.

Firmware Colour NumberColour NameHardware NumberQuick reference colour valueColor
0Black20&54
1Blue4&44
2Bright Blue21&55
3Red28&5C
4Magenta24&58
5Mauve 29&5D
6Bright Red12&4C
7Purple 5&45
8Bright Magenta13&4D
9Green22&56
10Cyan6&46
11Sky Blue23&57
12Yellow30&5E
13White0&40
14Pastel Blue31&5F
15Orange14&4E
16Pink7&47
17Pastel Magenta15&4F
18Bright Green18&52
19Sea Green2
20Bright Cyan19&53
21Lime26&5A
22Pastel Green25&59
23Pastel Cyan27&5B
24Bright Yellow10&4A
25Pastel Yellow3&43
26Bright White11&4B

This chart also gives a quick reference guide for programming the colours. The number is the colour number which can be sent directly, once the pen has been selected, to get the colour wanted.

Example:

ld bc,7f00+1 ;Gate array function (set pen)
;and pen number
out (c),c
ld bc,7f00 ;41 
;Gate array function (set colour)
;and colour number
out (c),c
ret

Pallette 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.

This table shows the relationship between hardware colour number, colour name and RGB mixing.


Hardware Colour IndexColour NameR %G %B %Color
0White505050
1White505050
2Sea Green010050
3Pastel Yellow10010050
4Blue0050
5Purple100050
6Cyan05050
7Pink1005050
8Purple100050
9Pastel Yellow10010050
10Bright Yellow1001000
11Bright White100100100
12Bright Red10000
13Bright Magenta1000100
14Orange100500
15Pastel Magenta10050100
16Blue0050
17Sea Green010050
18Bright Green01000
19Bright Cyan0100100
20Black000
21Bright Blue00100
22Green0500
23Sky Blue050100
24Magenta50050
25Pastel Green5010050
26Lime501000
27Pastel Cyan50100100
28Red5000
29Mauve500100
30Yellow50500
31Pastel Blue5050100

RGB assignments for the software colours

This is simply a sidenote to illustrate a pattern in the RGB assignments of the software colours and to show how their value is calculated.

Firmware Colour NumberColour NameR %G %B %Color
0Black000
1Blue0050
2Bright Blue00100
3Red5000
4Magenta50050
5Mauve500100
6Bright Red10000
7Purple100050
8Bright Magenta1000100
9Green0500
10Cyan05050
11Sky Blue050100
12Yellow50500
13White505050
14Pastel Blue5050100
15Orange100500
16Pink1005050
17Pastel Magenta10050100
18Bright Green01000
19Sea Green010050
20Bright Cyan0100100
21Lime501000
22Pastel Green5010050
23Pastel Cyan50100100
24Bright Yellow1001000
25Pastel Yellow10010050
26Bright White100100100
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

Green Screen Colours

On a green screen (where all colours are shades of green), the colours (in the software/firmware colours), are in order of increasing intensity. So that black is very dark, and white is bright green, and colour 13 is a medium green. (Thanks to Mark Rison for this information)

Personal tools
Multiple Upload
Server space and bandwidth kindly donated by
CMO Internet Dienstleistungen GmbH
Image:Cmologo55x25.gif

CPC-TopSite