Graphics 10/7 Painter

16K Cassette or 24K Disk
by Peter C. Budgell


The following program can be used to create 7-color pictures under joystick and keyboard control if you have the GTIA chip.

A variety of uses exist for pictures which can be drawn on the screen, saved, and brought back under program control. Several commercial packages are available to do this, and many users will have seen the results in graphics adventure programs. Most commercial packages work in the hi-res Graphics 7 1/2 mode, and compensate for the 4-color limit by mixing colors in some very interesting textures. Screens are stored either by dumping screen memory to storage media, or by storing the sequence of commands used to create the pictures and later reconstructing the pictures at machine language speeds.

The following program can be used to create pictures in the Graphics 10/7 mode which I introduced in ANALOG Issue 14, taking advantage of its 7-color capability, and 80*80 pixel resolution. Because this screen occupies 3200 bytes without the text window, its storage is very rapid. It is easy to add more features to the program, and relatively easy to convert it to most of the other graphics modes.

Featured in the program is a machine language fill routine. It is the familiar type which flows out in a diamond shape to fill any bordered area or to overwrite any solid color. The source code for the fill routine is included for those who would like to modify it to produce textured surfaces, by changing the color to be plotted in accordance with an imaginative algorithm. The routine is written to formally use CIO to do the plotting work. As written, it works in any graphics mode except Graphics 8, and requires only a change to the routines that check the screen size limits.

The program begins by POKEing the fill routine into page 6. Buffers which store the coordinates of points plotted by the fill routine are defined, and their locations in memory are POKED for the fill routine to use. Then Graphics 10/7 is set up.

The user is presented with a blank screen and a flashing cursor. The cursor is moved with the joystick. To paint on the screen, press the trigger.

A variety of commands are available, and selected by pressing certain keys. The menu is presented if any non-command key is pressed. The menu includes:

These routines start at Line 1000. More features can be selected starting at Line 280, and put in subroutines at the end of the program.

Other graphics modes can be used if:

  1. Screen limits in Lines 170 and 180 are changed.
  2. Lines 82 thru 93 are deleted and replaced with a call to Graphics 3 through 7.
  3. Lines 71 through 80 are removed.
  4. Line 68 is changed to read:
    68 DIM C(3):C(0)=0:C(1)=1:C(2)=2:C(3)=3
  5. Line 3000 has CVAL= changed to CVAL=4 or CVAL=2 as appropriate.
  6. In Lines 4040 and 5040, locations 856 and 857 are POKED thusly:
    Graphics Mode 3 4 5 6 7
    POKE 856, 200 144 32 64 128
    POKE 857, 0 1 3 6 13
  7. Fill routine limits are changed thusly:
    • Line 34, BASIC program, change 80 to screen width.
    • Line 38, BASIC program, change 80 to screen height.

An understanding of the program can be used to implement Graphics 9 through 11, with or without a text window.

The subroutine at Lines 4030 to 4070 can be used in another program to load a picture from disk, if the user provides the file name in Line 4030. If the cassette is used, then Line 4030 should read:

4930 TRAP 4070:OPEN #1,4,128,"C:"

The background in a graphics screen is in COLOR 0. In order to erase part of a Picture, select COLOR 0 and overwrite the unwanted image.

The biggest feature a user might wish to add would be a routine to draw a circle or polygon. Remember to trap errors, especially in plotting off the screen.

The fill routine alone can be used in other programs. The speed of the fill is limited by CIO, and commercial programs frequently go straight to screen memory to avoid CIO's overhead, which is caused by its generality.

Imagination is the most important ingredient in using a painter program. A slide show can be set up to show the results if the pictures are brought up sequentially by a loop in a program. The easiest way is to have the file names in data statements. Fun is available for those 3 years of age and up!

BASIC Listing

PAINTER.LST is available in ATASCII format.

This BASIC listing uses an image to display special characters



Checksum Data
5 DATA 832,23,848,232,325,260,259,776,
269,367,275,670,321,256,578,6291
23 DATA 636,265,379,195,220,919,45,14,
757,728,257,703,920,999,421,7458
38 DATA 954,635,280,602,914,728,279,75
5,453,66,102,664,999,52,945,8428
53 DATA 335,958,250,763,295,283,527,26
1,117,132,147,594,276,798,978,6714
68 DATA 793,317,263,810,217,272,552,29
9,330,506,775,739,489,268,886,7516
83 DATA 442,634,12,218,507,193,292,945
,405,944,271,279,576,375,491,6584
98 DATA 171,700,163,107,976,796,15,593
,275,541,657,548,586,608,667,7403
210 DATA 627,633,634,571,650,661,664,6
25,862,804,771,599,617,81,966,9765
525 DATA 246,276,598,391,892,655,666,9
,681,641,552,995,657,821,104,8184
3000 DATA 852,391,785,550,843,166,794,
667,108,943,692,367,133,797,889,8977
5030 DATA 808,357,333,116,694,843,220,
698,668,732,646,603,158,388,794,8058
6050 DATA 949,863,31,683,923,3449

The assembly listings appear on a separate page.


Previous | Contents | Next

Original text copyright 1984 by ANALOG Computing. Reprinted with permission by the Digital ANALOG Archive.