ATR: chpt.15: Display Lists

From: Craig Lisowski (aa853@cleveland.Freenet.Edu)
Date: 01/04/94-02:45:15 PM Z


From: aa853@cleveland.Freenet.Edu (Craig Lisowski)
Subject: ATR: chpt.15: Display Lists
Date: Tue Jan  4 14:45:15 1994



                                  CHAPTER 15
     
                                 DISPLAY LISTS
     
     
     [some of this file was lost...]
     
     
     chip also has a memory scan counter.  This register scans the display
     buffer for data to be interpreted and displayed.  Once loaded, the
     memory scan counter's 4 most significant bits are fixed.  The result
     is that the memory scan counter cannot cross a 4K memory boundary
     (i.e. $AFFF to $B000) without being reloaded.
     
     DISPLAY LIST INSTRUCTIONS
     
     There are three basic instructions in the display list.  The type of
     instruction is determined by bits 0,1,2 and 3 of an instruction byte. 
     The other four bits give auxilliary parameters for the instruction. 
     Bit 7 always enables a display list interrupts (DLIs).
     
                      Display list instruction format
     
          7 6 5 4 3 2 1 0
         -----------------
         |I|n|n|n|0|0|0|0|
         -----------------
            \   / \      /
             ---   ------
              |      |
              |      0 = display blank lines
              |
              0-7 = number of blank lines (1-8)
     
     
     
          7 6 5 4 3 2 1 0
         -----------------
         |I|W| | |0|0|0|1|
         -----------------
            |     \      /
            |      ------
            |        |
            |        1 = jump (3 byte instruction)
            |
            0 = jump and display one blank line
            1 = jump and wait for vertical blank
     
     
          7 6 5 4 3 2 1 0
         -----------------
         |I|R|H|V|M|M|M|M|
         -----------------
          | | | | \      /
          | | | |  ------
          | | | |    |
          | | | |    2-F = display one line of graphics in
          | | | |          ANTIC mode 2-F
          | | | 1 = horizontal scroll enabled
          | | |
          | | 1 = vertical scroll enabled
          | |
          | 1 = reload memory scan counter with next two bytes
          |
          1 = display list interrupt, all instructions
     
     
     In the display instruction, the ANTIC mode is different from the CIO
     graphics mode.  However, each CIO graphics mode uses a particular
     ANTIC mode.  Below are descriptions of the ANTIC modes with their
     associated graphics (CIO) modes.
     
     
     ANTIC MODE 2 (Graphics 0)
     
     Uses 8 pixel by 8 pixel characters, 40 characters horizontal, 8 TV
     scan lines vertical.  Only one color can be displayed at a time.
     
     ANTIC MODE 3
     
     8 X 10 pixel, Graphics 0 type characters.  This mode requires a custom
     character set.  The advantage is that it allows true decenders.  The
     custom C-set is still 8 X 8 pixels.  Lower-case letters with decenders
     have the bottom row of pixels put on the top row.
     
                      Lower-case "y" for ANTIC mode 3
     
     
            C-set          Display
     
          ----------     ----------
          | XXXXX  |     |        |
          |        |     |        |
          |        |     |        |
          | XX  XX |     | XX  XX |
          | XX  XX |     | XX  XX |
          | XX  XX |     | XX  XX |
          |  XXXXX |     |  XXXXX |
          |     XX |     |     XX |
          ----------     | XXXXX  |
                         |        |
                         ----------
     
     
     ANTIC MODE 4 (graphics 12 on XL and XE)
     
     This mode has characters the same size as graphics 0.  However, the
     characters are only 4 X 8 pixels.  This gives only half the horizontal
     resolution of graphics 0.  The advantage is that up to four colors of
     "graphics 0" characters can be displayed at once.  This mode also
     requires a custom C-set.  Below is a comparison of the normal C-set to
     one which works with the ANTIC 4 mode.
     
                    Upper-case "A" for ANTIC modes 2 and 4
     
            mode 2          mode 4
     
          ----------     ----------
          |        |     |        |
          |   XX   |     |  yy    |
          |  XXXX  |     |  yy    |
          | XX  XX |     |xx  zz  |
          | XX  XX |     |xx  zz  |
          | XXXXXX |     |xxyyzz  |
          | XX  XX |     |xx  zz  |
          |        |     |        |
          ----------     ----------
     
     xx, yy and zz represent two bit binary numbers, controlling one pixel
     each.  These numbers determine which color register a pixel is
     assigned to: (COLOR0, COLOR1, COLOR2 or COLOR3).
     
     ANTIC mode 5
     
     Antic mode five is identical to ANTIC mode 4 except the characters are
     displayed twice as tall.  This makes only 12 lines on the screen.
     
     ANTIC MODE 6 (Graphics 1)
     
     This mode uses 8 X 8 pixel characters except they are displayed twice
     as wide as in ANTIC mode 2.  There are 3 colors available at once but
     only one case (upper or lower) can be displayed at a time.  The data
     base variable CHBAS [$02F4 (756)] controls the character, [$E0 (224) =
     upper-case, $E2 (226) = lower-case]
     
     The color/character is controlled by either the color statement or the
     ATASCII number of the character printed.  Control characters are
     controlled by COLOR0, upper-case characters by COLOR1 and lower-case
     characters by COLOR2.  Remember that all characters print as
     upper-case alpha characters, but of different colors.
     
     ANTIC MODE 7 (Graphics 2)
     
     This mode is identical to mode 6 except the characters are displayed
     twice as tall.  This results in only 12 lines possible on the screen.
     
     ANTIC MODE 8 (Graphics 3)
     
     This is the first graphics (non-character) mode.  This mode, as other
     non-character graphics modes do, uses data in the display buffer as a
     bit map to be displayed.
     
     A command to display in mode 8 will cause the ANTIC chip to read the
     next 10 bytes in the display buffer.  Each pair of bits will control
     one pixel as in mode 4.  However, the pixels are blocks the same size
     as a Graphics 0 (ANTIC 2) characters.
     
     ANTIC MODE 9 (Graphics 4)
     
     This is similar to ANTIC mode 8 except each byte controls 8 pixels
     (instead of 4) and only one color can be displayed at a time.  The
     pixels are also half the size of those in ANTIC mode 8.
     
     ANTIC MODE A (Graphics 5)
     
     This mode uses 20 bytes per line/command.  As in ANTIC mode 8, each
     pair of bits controls one pixel.  The result is that the pixels are
     the same size as in ANTIC mode 9 but four colors can be displayed at
     once.
     
     ANTIC MODE B (Graphics 6)
     
     As in mode A, there are 8 pixels per byte and only one color.  The
     pixels are half the size as in mode A.
     
     ANTIC MODE C
     
     Like mode B except the pixels are half as tall (only one T.V. line).
     
     ANTIC MODE D (Graphics 7)
     
     40 Bytes per line, each byte controls 4 pixels.  The pixels are 1/4 as
     large as in ANTIC mode 8 (Graphics 3).
     
     ANTIC MODE E (Graphics 15 on XL and XE)
     
     Like mode D except the pixels are half as tall (one T.V. line).  Antic
     mode E is sometimes called Graphics 7.5
     
     ANTIC mode F (Graphics 8, 9, 10 and 11)
     
     This is the highest resolution mode.  Pixels are 1/8 the size of ANTIC
     mode 8 or mode 2 characters.  It uses 40 bytes per line, each byte
     controlling 8 pixels, unless the GTIA chip intervenes.  Only one color
     can be displayed at a time.
                                                                           


     DISPLAY LIST EXAMPLES
     
     When CIO opens a channel to the screen, it sets up the proper display
     list for the ANTIC chip.  The following are the things CIO must handle
     when setting up the display list.
     
                      Display list duties as used by CIO
     
     
     display a certain number of blank lines at the top of the screen.
     
     Load the memory scan counter with the address of the display data
     buffer.
     
     Display the required number of lines in the required ANTIC mode.
     
     Set up a jump instruction if the display list crosses a 1K memory
     boundary.
     
     Set up a reload-memory-scan-counter instruction if the display data
     buffer crosses a 4K memory boundary.
     
     CIO assumes that the display data buffer will butt against an 8K
     memory boundary.  If a program causes the display buffer to cross a 4K
     boundary (by changing RAMTOP [$006A (106)] to point to an address
     which is not at an 8K boundary) the screen will be scrambled.  This is
     not usually a problem if the graphics mode doesn't require a large
     block of memory.
     
     SAMPLE DISPLAY LIST
     
     Below is an example of a Graphics 0 display list as CIO would set it
     up.
     
     
                          Display list for Graphics 0
                        assuming BASIC starts at $A000
     
     address  instruction      explanation
     
              Dec.   Hex.
     
     $9C20    112    $70 \
              112    $70  >---- 24 blank lines (8 each command)
              112    $70 /
               66    $42 ----- load memory scan counter with 
     $9C24     64    $40 \__   next two bytes and display one line
              156    $9C /  \  of ANTIC 2 characters
                2    $02 -\ |
                2    $02  | \- address of display data buffer
                2    $02  |
                2    $02  \--- 2nd ANTIC 2 instruction

                -    ---

                2    $02 ----- 24th ANTIC 2 instruction
               65    $41 \
               32    $20  >---- jump back to start of list
              156    $9C /
     $9C40    ???     ??       first byte of display data buffer
     
              ---     --
     
     $9FFF    ???     ??       last byte of buffer
     
     $A000                     start of ROM
     
     A display list for a higher resolution graphics mode would require
     more instructions and might cross a 1K boundary.  It would then
     include a jump instruction to cross the boundary.
     
     MULTIPLE DISPLAYS
     
     It is possible to set up multiple displays and use one at a time.  The
     technique of changing from one display to another is called page
     flipping.  Below is the simplest way to set up two displays.
     
                            setting up two displays
     
     Call a graphics mode through CIO or by using a BASIC GRAPHICS
     command.
     
     Store the display list pointers, SDLSTL and SDLSTH, and the CIO screen
     pointer, SAVMSC [$0058,2 (88)].
     
     Move the start-of-ROM pointer, RAMTOP [$006A (106)] to below the
     current display list.  RAMTOP is a one byte pointer so it changes in
     increments of one page (256 bytes).
     
     make another graphics call as in the first step.
     
     store the new display list pointer and CIO screen pointer.
     
     This will set up two displays, each with it's own display list.  If
     the displays are in the same graphics mode, or you will not make any
     changes in the displays with CIO commands, (PLOT, PRINT, etc.) you can
     flip between the two simply by changing the display list pointer.
     
     If the screens are in the same graphics mode and you want to change
     which one to do CIO commands to, Change the CIO screen pointer, SAVMSC
     [$0058,2 (88)].  This way, you can display one screen while drawing on
     the other.
     
     If you want to do CIO commands to screens of different graphics modes,
     you will have the move RAMTOP and do a graphics call to change
     screens.
     
     If your manipulation of RAMTOP causes the display data buffer to cross
     a 4K boundary, the screen may be scrambled.
     
     DISPLAY LIST INTERRUPTS
     
     DLIs are not used by the operating system.  However, other programs
     can initiate and use them.  Use the following steps to set up display
     list interrupts.
     
     
                                Setting up DLIs
     
     Set bit 7 of the display list instruction for the line before you want
     the interrupt to occur.  (The interrupt routine should set WSYNC and
     wait for the next line to execute.)
     
     Set bit 7 of NMIEN [$D40E (54286)] to enable DLIs.
     
     Set the DLI routine vector, VDSLST [$0200,2 (512)] to point to your
     machine language DLI routine.
     
     Your DLI routine should set WSYNC [$D40A (54282)].  STA WSYNC will do.
     THis will cause the 6502 to wait for the next horizontal sync.  This
     will keep the DLI routine from changing something in the middle of a
     T.V. line.
     
     The DLI routine must end with an RTI instruction.
     
     SCROLLING
     
     Scrolling is controlled by a combination of scroll position registers,
     and changing the memory scan counter.  Basically, course scrolling is
     done by reloading the memory scan counter and fine scrolling is done
     by changing the scroll registers.
     
     VERTICAL SCROLLING
     
     Vertical scrolling is very simple.  Follow the steps below to set up
     vertical scrolling of graphics.
     
     
                        Steps to use vertical scrolling
     
     Set bit 4 of the first byte of the display list instruction for each
     line to be scrolled.
     
     Put the number of T.V. lines to offset the graphics vertically in the
     vertical scroll register, VSCROL [$D405 (54277)]
     
     The vertical scroll register can offset the graphics upward by 0 - 7
     T.V. lines in the 24 line graphics modes (ANTIC modes 2 and 4).  In 12
     line graphics modes (ANTIC modes 5 and 7) it can vertically offset the
     graphics by 0 - 15 T.V. lines.  To offset the graphics an 8th (or
     16th) line, the scroll register is reset to 0 and the memory scan
     counter is reloaded with the address of the next line of graphics in
     the display data buffer.  If the entire screen is being scrolled, the
     load-memory-scan-counter command (near the beginning of the display
     list) is changed to point to the address of the second line of
     graphics.
     
     HORIZONTAL SCROLLING
     
     Horizontal scrolling works much like vertical scrolling.  It is
     enabled by setting bit 5 of the instruction for each line to be
     scrolled.  The horizontal scroll register, HSCROL [$D404 (54276)],
     sets the offset.  The small difference is that graphics are moved
     twice as far per change (two graphics 8 pixels instead of one).  Also,
     when HSCROL = 0 the graphics are offset beyond the left edge of the
     screen by 16 color clocks (32 Graphics 8 pixels).  When HSCROL = 15,
     the graphics line is shifted one color clock (2 Graphics 8 pixels) to
     the left of the screen.
     
     The big difference is that the memory scan counter gets messed up. 
     This means that you must use a reload-memory-scan-counter command for
     each line of graphics.  This is a major modification of the display
     list.  It will require you to move and build the list yourself.
     
     The advantage of this is that you can have a scrolling window in a
     large graphics map.  The technique is to move the window by reloading
     the memory scan counter, then fine scrolling to the invisible bytes
     beyond the edges of the screen.
     
     
                   useful data base variables and OS equates
     
     
     SAVMSC $0058,2       (88): pointer to current screen for CIO commands
     RAMTOP $006A        (106): start-of-ROM pointer (MSB only)
     VDSLST $0200,2      (512): DLI vector
     RAMSIZ $02E4        (740): permanent start-of-ROM pointer (MSB only)
     DLISTL $D402      (54274): display list pointer low byte
     DLISTH $D403      (54275):     "    high byte
     HSCROL $D404      (54276): horizontal scroll register
     VSCROL $D405      (54277): vertical scroll register
     NMIEN  $D40E      (54286): NMI enable (DLIs)
     
     
                               Shadow registers
     
     
     SDLSTL $0230        (560): DLISTL
     SDLSTH $0231        (561): DLISTH
                                                                           


-----------------------------------------
Return to message index