Graphics


The Basics of Using POKE in Atari Graphics

Charles G. Fortner

Did you ever wonder how the Atari can store 61,440 pixels in less than 8,000 bytes? With the information in this article, you'll have the background to create graphics in machine language, high-speed screen save/recall, mix text and graphics, and lots else.

In order to use the poke statement in Atari graphics, we must first know two things:

1) Where to poke
2) What to poke

To display where to poke, we must look at the display list for each graphics mode. This display list is found by PEEK (560) + PEEK (561) *256. The display list determines how the memory is displayed on the screen. The 5th and 6th byte of the display list hold the addresses of the first byte to be displayed. Table 1-1 gives the starting address for each graphics mode plus other information.

Determining what to poke involved trial and error with the following results:

1) Graphics Modes 3, 5, 7, 19, 21, 23

These modes are four color modes which display only four pixels for each eight bit byte of memory displayed. Bits 7 and 6, numbered as 7-6-5-4-3-2-1-0, determine the color of the first (left-most) pixel; bits 5 and 4 the second; 3 and 2 the third; and 1 and 0 the fourth. The two control bits act as a "COLOR" statement for each pixel. If the hex value of the two control bits equals 0 it corresponds to a "COLOR 0" statement; if they equal 1, they correspond to a "COLOR 1" statement, etc.

2) Graphics Modes 4, 6, 20, 22

These modes are two color modes which display eight pixels for each eight bit byte of memory. Each bit acts as a "COLOR" statement for an individual pixel. A one in a location corresponds to a "COLOR 1" statement and a zero corresponds to a "COLOR 0" statement.

3) Graphics Mode 8, 2, 4

These modes are high resolution modes with only one color. They display eight pixels per memory byte with a "1" bit displaying a pixel of the same color as the background but with a higher luminance. A "0" bit displays a pixel of the same color and luminance as the background.

The "COLOR" statements mentioned in the above explanations indirectly control the color of each pixel by determining which color register is active for an individual pixel. The exact manner in which a "COLOR" statement chooses this register is explained in Table 9.5 of the Atari-Basic Reference Manual.

TABLE 1-1

GRAPHICS  DISPLAY   # OF    # OF    BYTES   BITS DISP.  # OF COLORS
  MODE   DATA ADDR. ROWS  COLUMNS  PER ROW   PER BYTE    AVAILABLE
   3       24176     20      40      10         4             4
   4       23936     40      80      10         8             2
   5       23456     40      80      20         4             4
   6       22496     80     160      20         8             2
   7       20576     80     160      40         4             4
   8       NOTE 1   160     320      40         8             1
  19       24176     24      40      10         4             4
  20       23936     48      80      10         8             2
  21       23456     48      80      20         4             4
  22       22496     96     160      20         8             2
  23       20576     96     160      40         4             4
  24       16720    192     160      40         8             1
NOTE: Graphics Mode 8 has two addresses--16720 is the starting address for the first 80 lines and 20480 is the starting address for the second 80 lines.

Here's an interesting program to get started in graphics:

Listing 1: Graphics 5 demo

Download (Saved BASIC)
Download / View (Listed BASIC)

References: "Atari 400/800 Basic Reference Manual," Copyright 1980, Atari, Inc.

A note on using the basics of POKE...

Larry rewrote the original program that Charles sent in so it will adjust itself to your machine's memory. After you try the program in the article, take a look at these. I expanded them to randomly alter the SETCOLOR parameters...you'll discover some of the versatility of your machine after you let the program run for five minutes or so.

Listing 2: Graphics 23 demo

Download (Saved BASIC)
Download / View (Listed BASIC)

Listing 3: Graphics 7 demo

Download (Saved BASIC)
Download / View (Listed BASIC)


Return to Table of Contents | Previous Section | Next Section