Programming NICK                                    84.1.17 ET1/1 



                  PROGRAMMING THE NICK CHIP 
                  ************************* 

In  contrast to the majority of video display devices which allow 
the  user various modes for the whole display,  NICK allows  many 
different modes in the same display frame. 
Principal features of NICK are:- 
    * Mixed mode displays 
    * User definable characters from fonts of 64, 128 and 256 
    * 8-bit colour output (256 colours) 
    * 2,4,16 and 256 colours per line chosen from 256 
    * Maximum resolution (using interlace) 672 x 512 
    * Cell based graphics, bitmap and characters 
    * Characters any hight from l to 256 scanlines 
    * Choice of 256 border colours 
    * User defined screen width and height 
    * External colour input (unlimited sprites or TV camera) 
    * Efficient use of RAM (can work with < 1K of RAM) 
    * 4 colour-pairs in 84 column text mode 
    * Special use of bits to increase colour options 
    * Pointer-based memory mapping, for flexibility and speed 


                    CONTROL REGISTERS 
                    ***************** 
Input-output  addresses  080H  to  08FH  are  reserved  for  NICK 
registers although only 080H to 083H are used at present.   These 
registers are write-only. 
080H     /FIXBIAS 
          d7             VC1 output used to kill external colour 
          (d6,d5)        (PRIOR1,PRIOR0)      external    colour 
                        priority, working in conjunction with an 
                        external 4-bit (16 colour-value) input 
                        on EC0-EC3 
                  =00    EC0-EC3   select  corresponding  palette 
                        colour whenever the display  is  active 
                        and /EXTC is low 
                  =01    The external colour on EC0-EC3 selects 
                        the corresponding palette colour if 
                        /EXTC is low and the internal display 
                        is generating a palette colour in the 
                        range COL8-COL15. 
                  =10    The external colour on EC0-EC3 selects 
                        the corresponding palette colour if 
                        /EXTC is low and the internal display 
                        is generating a palette colour in the 
                        range C0L8-C0L15 OR the external colour 
                        is in the range COL0-C0L7 (EC3 low) 
                  =11    The external colour on EC0-EC3 selects 
                        the corresponding palette colour if 
                        /EXTC is low and the internal display 
                        is generating a palette colour in the 
                        range COL8-COL15 OR the external colour 
                        is in the ranges COL0-COL3 or COL8- 
                        COL11 (EC2 low) 
        (d4..d0)        colour bias for palette colours 8-15 
081H     /BORDER 
        (d7..d0)         8 bit border colour 
082H     /LPL 
        (d7..d0)         (a11 ..a4) of pointer to line parameter 
                        table in video RAM. The index into an 
                        entry of 16 bytes,(a3..a0), is generated 
                        by the hardware. 
083H     /LPH 
        d7              (load line parameter base) normally 1 
        d6              (clock in line parameter base) 
        (d3..d0)        (a15..a12) or pointer to the line 
                        parameter table in video RAM. 

The  video display is controlled by values loaded into the  video 
RAM  segments (up to 64K at the top of the 4M space) by the  Z80. 
Once  this 'line parameter table' has been loaded in and the line 
parameter  base register has been loaded the display requires  no 
more action on the part of the Z80. 
The visible display is split up into 'video mode  lines'.   These 
'modelines'  are made up of 1 to 256 scanlines.   (A scanline  is 
one  scan of the electron beam across the CRT and takes about  64 
microseconds.) 
The  following  16 registers are loaded from the  line  parameter 
table before each modeline: 
    ------------------------------------------------------- 
    SC        scanlines in this modeline (two's complement) 
    MB        the MODEBYTE (defines video display mode) 
    LM        left display margin etc. 
    RM        right margin etc. 
    LD1L      (a7..a0) of line data pointer LD1 
    LD1H      (a8..a15) of line data pointer LD1 
    LD2L      (a7..a0) of line data pointer LD2 
    LD2H      (a8..a15) of line data pointer LD2 
    COL0      8 bit value of palette colour £0 
    COL1              "         "           £l 
    COL2              "         "           £2 
    COL3              "         "           £3 
    COL4              "         "           £4 
    COL5              "         "           £5 
    COL6              "         "           £6 
    COL7              "         "           £7 
    -------------------------------------------------------- 

                BUS ACTIVITY FOR THE VARIOUS MODES 
                ********************************** 

The possible video modes are: 
VSYNC     no border colour and use margin information to control 
          positioning of the vertical sync pulse. This gives 
          considerable interlace flexibility. 
PIXEL     use information pointed to be LD1 as a bit mapped 
          display. 
ATTR      use information pointed to by LD2 as a 2-C bitmap 
          display and information pointed to by LD1 as cell- 
          based graphics attributes (i.e. to define paper and 
          ink colours in the cell). 
CH256     use information pointed to by LD1 as indices of 
          characters pointed to by LD2. These characters can 
          by any number of lines deep (up to 256). 
          NB: offsets in the font pointer define which line of 
          the character to start on. 
CH128     As above but assumes a font of 128 characters. 
CH64      As above but assumes a font of 64 characters. 
LPIXEL    As for pixel mode but with half the horizontal 
          resolution. 
Note that all these modes may be mixed on the same screen and 
one has the choice of 2-C,  4-C,  16-C and 256-C colour modes for 
the PIXEL,  LPIXEL,  CH256,  CH128 and CH64 modes.  Also note the 
special  interpretation of certain bits of display data described 
below. 
                        -------------- 

Details of bus use during a memory cycle in the various modes: 
PIXEL                     /VDC1               /VDC2 
Address             LD1 (15....0)       LD1 (15....0) 
Data into           BUF1 (7....0)       BUF2 (7....0) 
BUF1 and BUF2 are loaded sequentially into the shift register and 
clocked out MSB first, ie. both are display bytes.  The line data 
pointer  LD1 is incremented twice in each memory  cycle.   Screen 
data  is  fetched from memory and the LD1 counter is  incremented 
only in the active part of the display,  ie. between the left and 
right  margins of a scanline.   The scanline count loaded at  the 
beginning of the PIXEL modeline determines how many scanlines  in 
this scanline. 
ATTR                 /VDC1               /VDC2 
Address             LD1 (15....0)      LD2 (15....0) 
Data into           BUF1 (7....0)      BUF2 (7....0) 
Cell  based  (parallel  attribute) graphics.   LD1 is used  as  a 
pointer  to  the  colour array (paper and ink  colours)  and  LD2 
points  at  2-C  pixel data,  ie.  the  display  bytes.   LD2  is 
incremented  once every memory cycle while the display is  active 
and keeps incrementing up for all scanlines in the modeline.  LD1 
restarts  from  the same address for each scanline  so  attribute 
data  in BUF1 applies to cells which are 8 bits wide and  have  a 
depth of the number of scanlines in the modeline. 
The  character  modes involve indirection through  the  character 
font.  A different font may be defined for each modeline and line 
by line vertical scrolling is obtained by offsetting the original 
index. 
CH256            /VDC1                   /VDC2 
Address       LD1 (15....0)          LD2(7.... 0),BUF1(7....0) 
Data into     BUF1 (7....0)          BUF2 (7....0) 
LD1  is  reloaded  at the start of each scanline and  acts  as  a 
pointer  into  a  section of RAM containing the  indices  of  the 
characters  to  be displayed.   It is incremented  once  in  each 
memory  cycle.   LD2  is a pointer into the character font to  be 
used and is incremented at the start of each scanline (it  points 
to  a row of a character in the font.)  Thus the font consists of 
256  bytes  defining the first row  of each  character  and  then 
another 256 bytes for the next row of each character etc.  If the 
characters are 9 lines deep this requires 2304 bytes of character 
font  (256x9).   The  data  in  BUF2 is  loaded  into  the  shift 
register. 
CH128                  /VDC1                  /VDC2 
Address             LD1(15.... 0)        LD2 (8....0) BUF1(6....0) 
Data into           BUF1(7....0)         BUF2(7....0) 
This  is  basically the same as the 256 character font  mode  but 
note  that the font for 128 9 line deep characters only  requires 
1152 bytes of memory. 
CH64                   /VDC1                  /VDC2 
Address             LD1(15.... 0)        LD2(9....0) BUF1(5....0) 
Data into           BUF1(7.... 0)        BUF2(7.... 0) 
This  is  basically the same as the 256 character font  mode  but 
note  that the font for 64 9 line deep characters  only  requires 
576 bytes of memory. 
LPIXEL                   /VDC1                /VDC2 
Address             LD1(15....0)         LD1(15....0) 
Data into           BUF1(7....0)         BUF2(7....0) 
This  is  much  the same as the PIXEL mode except  that  the  LD1 
pointer  is  only incremented once in each memory cycle  and  the 
BUF2 data is not used.  This gives half the horizontal resolution 
of the PIXEL mode. 
VSYNC 
No  use  is made of the information loaded from  memory.   It  is 
equivalent to the LPIXEL mode. 



                  THE LINE PARAMETER REGISTERS 
                  **************************** 

SC  This is a two's complemented count of the number of scanlines 
    in the modeline, ie:  0FFH for one scanline in modeline. 
MB     d7       If set this takes the VIRQ interrupt line low for 
                the  duration of the  modeline.   In  conjunction 
                with the DAVE chip this causes an interrupt to be 
                generated at the beginning of the modeline. 
      (d6,d5)   Defines the colour mode: 
        00     2-C Two colour mode.   If a bit in the  byte  of 
                display  data is 1 a pixel of palette colour £1 
                is output and if 0 a pixel of palette colour £0. 
                The  bits  are  output  to  the  screen  in  the 
                following order: 
                    ----------------------------------------- 
                    :    :    :    :    :    :    :    :    : 
                    : d7 : d6 : d5 : d4 : d3 : d2 : d1 : d0 : 
                    :    :    :    :    :    :    :    :    : 
                    ----------------------------------------- 
        01     4-C Four colour mode.   Pairs of bits in the  byte 
                of display data define the colour of the pixel 
                displayed.   00  for  palette colour  £0,  01  for 
                palette colour £l, 10 for palette colour £2, and 
                11   for  palette  colour  £3.    The  pixels  are 
                displayed in the following order: 
                    ----------------------------------------- 
                    :         :         :         :         : 
                    : (d7,d3) : (d6,d2) : (d5,d1) : (d4,d0) : 
                    :         :         :         :         : 
                    ----------------------------------------- 

        10     16-C Sixteen colour mode.  Groups of 4 bits in the 
                byte  of  display data define the  colour  of  the 
                pixel displayed.  0000 for palette colour £0 up to 
                1111  for  palette  colour £15.   The  pixels  are 
                displayed in the following order: 
                    ----------------------------------------- 
                    :                   :                   : 
                    :  (d7,d5,d3,d1)    :   (d6,d4,d2,d0)   : 
                    :                   :                   : 
                    ----------------------------------------- 

Note  that palette colours £0 to £7 have 8-bit values loaded from 
the  line parameter table at the start of each scanline but  that 
palette colours £8 to £15 have 8-bit values defined as follows:- 
    palette colour  £8 = (f4,f3,f2,fl,f0,0,0,0) 
    palette colour  £9 = (f4,f3,f2,fl,f0,0,0,1) 
          ...... 
    palette colour £15 = (f4,f3,f2,f1,f0,1,1,1) 
where  (f4,f3,f2,fl,f0)  are  the  low  5  bits  of  the  FIXBIAS 
register. 
11   256-C Two hundred and fifty six colour mode. 
    In this mode the byte of display data defines the colour  of 
    a single display pixel. 
    The actual colour produced is as follows:- 
    RED   = (b0)*(4/7) + (b3)*(2/7) + (b6)*(1/7) 
    GREEN = (b1)*(4/7) + (b4)*(2/7) + (b7)*(1/7) 
    BLUE  = (b2)*(2/3) + (b5)*(1/3) 
    (Note  that this specification of red,  green and blue  also 
    occurs when allocating a colour to the palette.) 
d4   =0 for /VRES.  The VRES mode the LD1 and LD2 data pointers 
    are reloaded at the start of each scanline and so the same 
    display  pattern  is  repeated  for  each  scanline  of  the 
    modeline. 
(d3,d2,d1)  defines the video display mode (see above): 
            000 VSYNC mode 
            001 PIXEL mode 
            010 ATTR mode 
            011 CH256 mode 
            100 CH128 mode 
            101 CH64 mode 
            110 unused at present 
            111 LPIXEL mode 
    d0     If 1 this forces a reload of the line parameter base 
            register.   This will normally be programmed to occur 
            at the end of each video frame. 
LM   d7     =1 for MSBALT, ie: if the top bit of the display byte 
            is  l  this  causes palette colours £2 and £3  to  be 
            selected  instead  of £0 and £1 in  the  2-C  display 
            mode.  If the top bit is 0 palette colours £0 and £1 
            are used as usual.  In both cases the top bit seen by 
            the  shift  register is forced to 0.   This  mode  is 
            useful in simulating an 80 column VDU in the PIXEL 
            mode.  Since the msb or LHS of any character is 0 for 
            character  spacing it can-be used to highlight  areas 
            of text. 
    d6     =1  for LSBALT ie:   if the bottom bit of the  display 
            byte is 1 this causes palette colours £4 and £5 to be 
            selected instead of £0 and £1 in the 2-C display mode. 
            If the top bit is 0 palette colours £0 and £1 are used 
            as usual.  In both cases the top bit seen by the shift 
            register is forced to 0.  This mode is useful in 
            simulating an 80 column VDU in the PIXEL mode, Since 
            the lsb or RHS of any character is 0 for character 
            spacing it can be used to highlight areas of text. 
  (d5...d0) define the left hand margin of the active display. 
            In practice this value will not be below 10 for the 
            left hand edge of the CRT.  The display changes from 
            being border colour at the left hand margin and the 
            display data counters start being incremented.  The 
            left hand margin defines the start of the vertical 
            sync pulse in the VSYNC video mode. 
RM    d7    ALTIND1 If a 2-C character mode is selected this will 
            cause characters with an index above 080H to have a 
            paper of palette colour £2 and an ink of palette colour 
            £3 instead of £0 and £1. 
      d6    ALTIND0  If a 2-C character mode is selected this  will 
            cause   characters  which  have  their  next  to   most 
            significant   bit  set  to  swap  palette  colours   as 
            follows:- 
                          £0 - > £4 
                          £1 - > £5 
                          £2 - > £6 
                          £3 - > £7 
  (d5...d0) These  bits define the right hand side of  the  active 
            display.   The  maximum  value is normally 54  for  the 
            right hand edge of the CRT.  The display returns to the 
            border  colour  at the right hand margin and  the  line 
            data pointers are not incremented until the next left 
            hand margin.  In the VSYNC video mode the right hand 
            margin defines the end of the vertical sync pulse. 
LD1L        This 8-bit value defines the starting value of (a7..a0) 
            of the line data pointer LD1. 
LD1H        This  8-bit  value  defines  the  starting  value  of 
            (a8..a15) of the line data pointer LD1. 
            LD1 is used as a pointer to the next byte of display 
            data in the PIXEL and LPIXEL modes.  In the CH256, 
            CH128 and CH64 modes it is the index of a character 
            in the character font.  In the ATTR mode it points to 
            attribute information. 
LD2L        This 8-bit value defines the starting value of (a7..a0) 
            of the line data pointer LD2. 
LD2H        This  8-bit  value  defines  the  starting  value   of 
            (a8..a15) of the line data pointer LD2. 
            LD2 is used as a pointer for pixel information in the 
            ATTR  display  mode and as a pointer to  the  character 
            font in the CH256, CH128 and CH64 modes. 
            It is not at present used in the PIXEL and LPIXEL modes 
            but it is hoped that it will define vertical pixel 
            resolution at a later date. 
COL0        Palette  colour £0.   This is the paper colour  in  2C 
            modes though note the exceptions above. 
COL1        Palette colour E1.  This is the ink colour in 2C modes 
            though note the exceptions above. 
COL2        Palette colour £2 (Alternate paper) 
COL3        Palette colour £3 (Alternate ink) 
COL4        Palette colour £4 
COL5        Palette colour £5 
COL6        Palette colour £6 
COL7        Palette colour £7 



**********************END OF DOCUMENT****************************