PROGRAMMABLE GRAPHICS GENERATOR

Introduction

The programmable video graphics + character system makes use of a scheme of variable length data to give efficient use of memory when creating pictures. A few definitions are necessary before further examination of the scheme.

A "Scan" is:
One traverse of the screen by the electron beam drawing the picture. (there are 625 in a European television picture).
A "Line" is:
A number of scans all of which are controlled by the same information in the RAM.
A "Mode" is:
One of the different ways information may be displayed on the screen. For instance, in "character mode" bytes in memory are shown as characters on the screen, in "4 colour graphics" mode, bytes describe the colour of blobs on the screen.
A "Blob" is:
The smallest area on the screen whose color can be set (The physical size of a blob is different in different screen modes).
A "Field" is:
A set of 8 blobs whose colour is controlled by a pair of bytes from memory.

The picture is defined by a number of lines, one after another down the screen. Each line is independent of all others and may be in any of the possible modes.
At the start of each line two bytes are taken from memory which define the mode for that line, and may update the colour RAM two bytes. These are called respectively the Control and Colour Control bytes. The rest of each line is colour or character information, and the number of bytes used for it is a characteristic of the particular mode. (see example programs).
The screen can operate at a number of different definitions horizontally (e.g, blobs/scan). In the highest definition graphics mode there are 352 visible blobs across the screen. The two lower definitions have respectively 1/2 and 1/4 of this number. There are about 520 scans visible on a "625 line" television, and the screen hardware can only draw (at minimum) Z scans per line, due to the interlacing. This gives a maximum definition of 260 by 352 which is close to the 3:4 ratio of the screen sides. Thus circles come out round !
Characters are fitted onto this grid by using 8 columns of blobs per character, the dot positions being defined for each character by a ROM. This allows 44 characters per line maximum (or 22/11 in lower definition modes).
A fourth horizontal definition provides for a "high density" character mode with 66 characters/line.
A total of 16 different colours, including white and black can be displayed by the system. Whenever a 4 bit code is used to describe a colour, it selects from this range of possibilities. In some modes (characters + or four colour graphics) a set of 4 of these colours (not necessarily distinct) are loaded into a set of "colour registers". Any 2 bit code describing a colour selects an entry from these registers.
Vertical definition is set by a 4 bit field in the control byte. In graphics modes this simply allows repetition of the information to fill any even number at scans from 2 to 32, In character mode it defines the number of scans occupied by each line of characters; thus the vertical spacing on the screen can be changed to allow anything between an 8 x 7 (the sensible minimum) and 8 x 16 character matrix, giving between 35 and 15 lines of characters on the screen.

Arrangement of information in memory

The first byte of information for the screen is located at the top of an 8K or 32K block of memory. Successive bytes follow at descending addresses The screen takes memory and displays a picture on the screen accordingly until the whole screen has been filled. It then starts again at the first byte.

Screen Data Format

At the beginning of the data for each line, two bytes of data represent the lines control word. The control word defines the raster scan depth of the line, the horizontal graphical resolution of the line and selects the display mode of that particular line. Subsequent to this control word a number of data words are stored that represent the colour of pixels,or definition and colour of characters according to the selected display mode.

Control Word Format

High Address Byte (Mode byte)

High Address Byte


Line Repeat Count

The line repeat count controls the number of horizontal raster scans for which the same data will be displayed, Since interlace of the TV scan is ignored a minimum of two raster scans correspond to a line repeat count of zero. Thereafter, each additional repeat adds two scans to the line. The maximum programmable depth of any horizontal display segment is thus 32 scans. (European TV sets will show approximately 520 scans total for a full picture),

Resolution Control

The resolution control bits allow selection of one of four different horizontal definitions for display of data on the TV screen for each individual line.

Code (Bit 5, Bit 4) Definition (pixels per screen width)
00 88 (Low definition graphics)
01 176 (Medium definition graphics)
10 352 (High definition graphics)
11 528 (Text with 66 characters per line)
( Screendriver uses 60 characters for text).
(Could be used for a very high definition
graphics mode).

Mode Control

The mode control bits determine how data will be used to generate the picture for that particular segment.

Code
(Bit 7, Bit 6)
Display mode
00 Four colour graphics
01 Four colour characters
10 Sixteen colouz graphics
11 Sixteen colour characters

Low Address Byte (Colour type)

The Low Address control byte is used to store colours into a set of 4 "colour registers" for the four colour mode. Any one of the four colours in the registers can be changed at the beginning of any line of display data, Only the colours in these registers can be displayed in any 4 colour mode. The four colours are freely selectable from the sixteen colours defined in Colour Select Table.

Low address byte

Code Code
0 Black
1 Dark blue
2 Purple Red
3 Red
4 Purple Brown
5 Emerand Green
6 Kakhi Brown
7 Mustard Brown
8 Grey
9 Middle Blue
10 Orange
11 Pink
12 Light Blue
13 Light Green
14 Light Yellow
15 White

Data Mode

Four Colour Mode

In this mode only two bits of data aze required to define the colour of a pixel. These data bits are obtained in parallel from the upper and lower bytes of each data word using the high order bits first. The 2 bytes in a field are considered as 8 pairs of bits, Each pair sets the colour for one spot. HIGH ADDRESS BYTE pairs of bits used to address colour RAM. LOW ADDRESS BYTE Leftmost spot Rightmost spot

The 2 bits for each spot select one of the four colours which have been loaded into the colour RAM by previous Colour Control bytes. So on any line 4 colours are available. On the next line any one of these may be changed for another, and so on.

Sixteen Colour Mode

This graphics mode is designed to allow multi-colour high definition pictures in half the memory requirement of other systems. The basic organization is that the low address byte selects two of the sixteen possible colours. Bits 0 - 3 "Background" colour. Bits 4 - 7 " Foreground" colour.


The high address byte than defines by each successive bit whether a colour blob should be foreground or background.

NB

The two bytes in the field serve different purposes, one being used to define two available colours for use in the field, and the other to choose one of these for each spot. HIGH ADDRESS BYTE leftmost 1 0 rightmost blob bit bit blob LOW ADDRESS BYTE "Foreground "Background colour" colour"

The bit for each spot can select either the "foreground" or the "back- ground" colour. However, what these colours are is totally independent of the preceding or following fields. So any line may use any and all of the total 16 colours. The contents of the colour RAM are irrelevant in this mode.

One additional feature is added to eliminate restrictions of the scheme. After each eight bit field of colour the background is extended into a new area, even if a new background colour is specified, until the new foreground is first used. It is therefore possible to create a required picture by suitable combination of foreground and background.

Character Mode

In this mode, characters are generated using a character generator ROM in conjunction with the four colour registers or using any 2 colours for each in the 16 colour character mode.


The usual character matrix is 6 x 9 bits out of a possible 8 x 16. Therefore the line repeat count should be at least eleven, to guarantee full character display plus line spacing. Four colour characters are produced on the screen in a way similar to the four colour graphics mode, but with the character ASCIV data replacing the high address data byte used for four colours. The result is that characters are displayed using colours from the four colour registers. The data from the character generator ROM control the lower address bit and bits from the low-address byte determine the other. This allows characters on a single horizontal display segment to be in one of two colour combinations of character/background, or even with a vertical striped pattern controlled by the low address byte. However, note that as compared with four colour mode information (but not the low-address byte) is subject to a one character position delay before appearing on the screen.

In character mode the height of the characters is a set number of horizontal scans. The character width is determined by the definition selection in the control byte. A definition of 352 yields 44 characters per line, 528 hields the normal 66 characters per line. Other definitions are possible and they yield wide characters, useful as large capitals in applications such as the power-on message. However, this feature is not supported by the resident BASIC.

Special characters:

CR

Terminates a line of characters and positions the cursor at the first position of next line. If necessary, the screen is "rolled up" to make room.

FF

Fills the character area with spaces and positions the cursor at the start of the tope line on the screen.

BS If the current line has some characters on it, then the cursor is moved back to the previous position and the character there is replaced by a space.


  • A line of characters on the screen can be extended up to 4 screen widths. Continuations are indented a few characters, and a letter "C" is displayed in the first position of these lines.
  • When a third continuation line is full any character except CR, FF and BS is ignored.
  • Attempts to backspace past the beginning of the line are ignored.
  • If the screen is in "all graphic mode" and character output is necessary then a mode change will be to an appropriate mode including a character area. First the corresponding "split" mode will be tried e. g. if the screen is in mode 1, then mode 1A. If in mode I a program claims all free memory (e. g. by using "CLEAR") then mode lA, which requires more memory than mode 1, will not be possible and the default is to mode 0. In this case the program is deleted by an automatic "NEW" command.

CHANGING LINE BACKGROUND OR LETTERS COLOR ON ONE LINE

Line 1 Control byte is located at address XFEF and line 1 Color Control byte address at XFEE (X being 1 for 8K machine, 7 for 32K machine, B for 48K machine). The first character byte of line I is located at line 1 Control byte address minus 2, and the character Colour Control byte at line 1 Control byte address minus 3. Each of the 66 positions of the screen is located at line Control byte - (2* position of character on the line) for the character and at line Colour Control byte - (2* position of character on the line) for the Colour Control byte of the character. Remember that there are 66 character positions on the screen but that the first and last three characters are kept blank for the margins. Therefore the Control byte for the next line is located at Control byte of previous line (i, e. XFEF) less 134 bytes (#86. So if the Control byte of line I is a BFEF, the Control byte of line 2 will be at # BFEF - # 86 = # BF69.

Examples:

Control Byte Line 1 #BFEF
Control Byte Line 5 #BFEF - (# 86 * 5) = # BDD7
Colour Control byte Line 5 = #BDD6
Character N° 6 on Line 5 # BDD7 - 6 * 2 = #BDCC
Colour Character 6 of Line 5 = #BDCB

(see VIDEO RAM TABLE and examples I and 2)

Use the POKE in your program for changing line background, letter colour, or letter, and Utility 3 for checking the location you intend to POKE (when you return to BASIC the colour changes you made in Utility mode are erased if you enter MODE I, RETURN, MODE 0.


Example

COLORT 8 0 5 10
POKE #BA2D,,#DA (Will change colour of latter from black to
colour 10 on line 12)
POKE#BA2D,#C3    (Will change background frorn 8 to 3)

The locations from #x350 to #x35F and #xFF0 to #xFFF
z = 1 FOR 8K RAM, x = 2 FOR 12K, x = 7 FOR 32K, x = B FOR 48K
control the screen background and forground colours

Example
COLORT 0 15 7 8

     00 00 B8 3F 00 00 A7 3F 00 00 9F 3F 00 00 80 3F

     00 00 B8 36 00 00 A7 36 00 00 9F 36 00 00 80 36

*POKE#735A,#90:POKE#7FFA,#90:POKE#735E,#80:POKE#7FFE,#80

You will see the screen black and the letters black
the # numbers 90 and 80 can be replaced by any # number
from #90 to #9F and #80 to #8f

VIDEO RAM TABLE

Line N° Start Address of
Line (in Hex)
Line Colour Control
byte Address (in Hex)
1 XFEF XFEE
2 XF69 XF68
3 XEE3 XEEZ
4 XE5D XE5C
5 XDD7 XDD6
6 XD51 XD50
7 XCCB XCC4
8 XC45 XC44
9 XBBF XBBE
10 XB39 XB38
11 XAB3 XAB2
12 XA2D XA2C
13 X9A7 X9A6
14 X921 X920
15 X89B X89A
16 X815 X814
17 X78F X78E
18 X709 X7p8
19 X683 X682
20 XSFD X5FC
21 X577 X576
22 X4P1 X4F0
23 X46B X46A
14 X3E5 X3E4

X=1 FOR 8K MACHINE, X = Z FOR 12K, X = 7 FOR 32K, X=B FOR 48K


Unit colour mode

This mode is available for space saving during uniform scans of the picture. A horizontal band of constant colour (or repeated pattern) can be drawn using only one control word and one data word. The data for this mode should be in high speed format. Using this mode a full screen of data need be no more than 40 bytes of ram.

Video Interface

The television interface is realized such that a separate adaptor module plugs into the fundamental logic to realize normal Black and White interface, standard colour modules of PAL, SECAM or NTSC and video monitors. Other video interfaces are easily realizable by construction of an adaptor that plugs into the video interface connector of the DAI personal computer.

Some info on the DAI Programmable Graphics Generator

Note this a description of the DAI hardware. Not all 
possibilities are implemented in BASIC. But most can
be used via POKE.

The part of DAI memory that can be used for graphics
consists of interleaving bytes of the two upper memory banks,
bank B and C in the manual. The Graphics Generator reads
a byte from each bank simultaneously. So the graphics section
effectively has a 16-bit wide access.

Each line (two or more screen scan lines) as defined in the 
DAI graphics memory is preceeded by two control bytes. These
bytes have the following meaning:

Control bytes
-------------

High address byte (Mode byte)

Specify the horizontal and vertical resolution for this line
as wel as the colour depth.

bit  7 6 5 4 3 2 1 0
     | | | | | | | |
     | | | | +-+-+-+-- Line repeat count in scans 
     | | | |           for this line.  0000 = 2, 
     | | | |                           0001 = 4,
     | | | |                             .    .
     | | | |                           1111 = 32
     | | +-+---------- Resolution control in blobs 
     | |               (pixels) 00 =  88,
     | |                        01 = 176,
     | |                        10 = 353,
     | |                        11 = 528 
     +-+-------------- Display mode control 
                       0x = four colour mode,
                       1x = sixteen colour mode

Low address byte (Colour byte)

Update one of the four colour registers with a new colour or
specify a repeat of the previous line.

bit  7 6 5 4 3 2 1 0
     | | | | | | | |
     | | | | +-+-+-+-- Colour select (see table below)
     | | | |
     | | +-+---------- Register select 00 = background colour
     | |                               01 = foreground colour
     | |                               10 = alternate background colour*
     | |                               11 = alternate foreground colour*
     | +-------------- Line type 0 = 'unit colour mode' (repeat previous line)
     |                           1 = new line definition
     +---------------- Enable colour change 0 = ignore bit 0-5
                                            1 = interpret bit 0-5

 0 Black           8 Grey
 1 Dark Blue       9 Middle Blue
 2 Purple Red     10 Orange
 3 Red            11 Pink
 4 Purple Brown   12 Light Blue
 5 Emerald Green  13 Light Green
 6 Kakhi Brown    14 Light Yellow
 7 Mustard Brown  15 White

*) accessible by POKE and machine language routines, not by BASIC.

Data bytes
----------

Four colour graphics mode

The combination of the two equal numbered bits in the high and low address
byte select one of four colour registers. 

Sixteen colour graphics mode

The high address byte specifies for eight blobs to have the foreground colour
(1) or background colour (0). The upper nibble of the low address byte specifies
the foreground colour, the lower nibble the background colour.

Character mode

For character mode the line repeat count should be at least eleven.

The high address byte contains the ASCII value of the character which is converted
to blobs and lines with a character generator.

The low address byte contains the colour information, not of the corresponding
character, but of the previous character.
In four colour mode this can lead to vertically striped characters, using the
primary foreground and background colours..
In sixteen colour mode the low address byte works as in the graphics mode.

The table below summarizes the effect of CONTROL BYTES. 
Control Display Colours Resolution Bytes to new Data and Visible fields** bytes control byte col. bytes and blobs 0x 40 GRAPHICS 4 LOW 24 11 11 - 88 1x 40 GRAPHICS 4 MEDIUM 46 22 22 - 176 2x 40 GRAPHICS 4 HIGH 90 44 44 - 352 3x 40 GRAPHICS 4 SUPER 134 66 66 - 528 4x 40 CHAR 4 LOW 26 12 10 - 87 5x 40 CHAR 4 MEDIUM 48 23 21 - 173 6x 40 CHAR 4 HIGH 90 44 43 - 345 7x 40 CHAR 4 SUPER 134 66 64 - 519 8x 40 GRAPHICS 16 LOW 24 11 11 - 88 9x 40 GRAPHICS 16 MEDIUM 46 22 22 - 176 Ax 40 GRAPHICS 16 HIGH 90 44 44 - 352 Bx 40 GRAPHICS 16 SUPER 134 66 66 - 528 Cx 40 CHAR 16 LOW 26 12 10 - 87 Dx 40 CHAR 16 MEDIUM 48 23 21 - 173 Ex 40 CHAR 16 HIGH 90 44 43 - 345 Fx 40 CHAR 16 SUPER 134 66 64 - 519 ************************ UNIT COLOUR MODE ***************************************** 0x 00 GRAPHICS 4 LOW 2 1 11 - 88 1x 00 GRAPHICS 4 MEDIUM 2 1 22 - 176 2x 00 GRAPHICS 4 HIGH 4 1 44 - 352 3x 00 GRAPHICS 4 SUPER 4 1 66 - 528 4x 00 CHAR 4 LOW 2 1 11 - 88 5x 00 CHAR 4 MEDIUM 2 1 22 - 176 6x 00 CHAR 4 HIGH 4 1 44 - 352 7x 00 CHAR 4 SUPER 4 1 66 - 528 8x 00 GRAPHICS 16 LOW 2 1 11 - 88 9x 00 GRAPHICS 16 MEDIUM 2 1 22 - 176 Ax 00 GRAPHICS 16 HIGH 4 1 44 - 352 Bx 00 GRAPHICS 16 SUPER 4 1 66 - 528 Cx 00 CHAR 16 LOW 2 1 11 - 88 Dx 00 CHAR 16 MEDIUM 2 1 22 - 176 Ex 00 CHAR 16 HIGH 4 1 44 - 352 Fx 00 CHAR 16 SUPER 4 1 66 - 528 **) a field is the number of blobs controlled by a pair of bytes from memory. In all modes there are 8 blobs in a field.

This article is based on the DAI Personal Computer Reference Manual and an article in DAInamic 13 written by N.P. Looije (english translation in DAInamic 18).

Copyright 2004-2023 © Bruno VIVIEN tous droits réservés.