Classic Computer Magazine Archive COMPUTE! ISSUE 39 / AUGUST 1983 / PAGE 242

VICplot

Gerald Chick

This utility draws or erases points on a 64 x 64 grid. The program also lets you examine a point to determine its previous status. Using the example program, you can get a feel for the uses of this short, but effective, programming tool. If you LOAD a program in from cassette, you'll need to re-READ the DATA of VICplot back into the cassette buffer (see lines 1399-1420 and 1510-1560). For the VIC, expanded by 3 or 8K of memory.

"VICplot" is a simple utility for the VIC-20 designed to plot or erase points on a 64 × 64 grid. VICplot's 83-byte program accomplishes three important functions: it allows plotting, erasure, and indicates a point's previous condition.

Functions to draw, erase, or examine a point (similar to Super Expander commands POINT c,x,y and RDOT(x,y)) are included in VICplot. The last function is particularly important. Quite often you will want to know whether a point was lit or not. The sample program uses this function to gather data.

Protecting The Character Set

The character set which makes up the grid is stored in 2K of RAM beginning at 5120 ($1400). This set must be established by BASIC. VICplot is placed in the cassette buffer, so only the character set need be protected from BASIC. If you are using 3K or less expansion, type:

POKE 56,20 :POKE 52,20 :POKE 55,0

With 8K of added RAM, you will have to type:

POKE 44,28 :POKE 7168,0

before you load the program. This sets the start of BASIC above the character set.

The pointer to character memory must also be reset: POKE 36869, 205 for 8K expansion; POKE with 253 for less memory. The sample program has a subroutine at 1400 to load VICplot and draw the screen. Once this is finished, VICplot is ready to use. A few precautions are in order, though.

First, there is no error detection. A too large Y coordinate will plot in the wrong column. Worse than that, a too large X coordinate will be placed beyond the matrix, possibly in BASIC or on the screen. A value of 128 for X will cause a point to appear in your BASIC program around location 9200. Second, don't be surprised at the size of the dots. They are actually two pixels square.

Plotting Points With A Sample Program

To access VICplot, the X and Y coordinates should be placed in locations 251 and 252, respectively. To plot this point, place a one in location 253. To erase, place a zero there. Now call VICplot with SYS 832. Voilà! Location 251 now holds the status flag. It can be read with

F= -(PEEK (251) =0).

If F = 1 then the point was lit previously. A zero indicates it was dark.

A point can be lit in one of three colors (character, border, or auxiliary) set by the user. The color used is determined by the following table, which shows the value for each color. The data for this table is in line 1500 of the sample program.

The sample program is a good demonstration of how VICplot works. Two areas are selected, and 4000 random points are plotted on each. If a chosen point is already lit, a counter is incremented. Ten samples are taken of this count, and a bar graph is drawn to compare each trial. The bars are numbered, and the graph is scaled by hundreds.

The program is written for the 8K expander. To work in less memory, the POKEs for screen and color will have to be changed. The many REMarks should help you understand all the elements of this handy program.

VICplot Color Table
COLOR: Screen Border Char. Aux.
828 0 1 2 3
829 0 4 8 12
830 0 16 32 48
831 0 64 128 192
033C 00 01 02 03
033D 00 04 08 0C
033E 00 10 20 30
033F 00 40 80 C0