by Vern L. Mastel
Inspired by the Apple Graphics Tablet, the following Drawing Board program uses a number of the Atari's special features, including player-missile graphics. Player-Missile graphics let you mix text from the Graphics Mode 0 with the high -resolution Graphics Mode 8 screen, without using fancy tricks like display list interrupts. The program runs on any Atari computer with no modifications.
The program is very simple. You control all drawing from two joysticks (which need not be actual joysticks), and you're guided by two cursors placed on the screen. The cursors are single resolution players which take priority over all screen images.
These cursors mark the ends of lines to be plotted when in the line mode. They mark the opposite corners of rectangles when in the box mode. They mark the center and radius of a circle when in the circle mode. When in the draw or print mode, one cursor is disabled (actually positioned off the edge of the screen), and the other is used to guide all of the screen work.
The program is broken into three sections: cursor positioning, command processing and initialization routines. Lines 100 to 184 handle all of the positioning chores. The status of the joysticks plugged into ports 1 and 2 is read and translated into cursor positions on the screen and the triggers on the sticks are read at the same time.
All the while, the program continuously monitors the keyboard, checking for changes in the operating mode, translating and reading what is going on between each and every point plotted on the screen. Remember this, if you feel the cursor motion is too slow.
The initialization routine is used only once and sets up the parameters for the program. It also sets up the machine language routines that allow you to move vertically. These routines are tucked away into page six in memory.
Lines 10 through 90 are the main subroutines for screen processing. Line 10 clears the screen and restores the cursor. Lines 20, 30 and 40 plot color changes. Line 45 is very important. Because the screen coordinates for player-missile graphics do not correspond to the coordinates for plotting on the playfield. I had to translate the actual position of the player-missile cursors into normal playfield coordinates. Line 45 calculates, these.
Lines 50 through 85 check the range. This routine ensures that your plotting remains inside the normal playfield boundaries.
You should pay special attention to the section of the program in Lines 1200 to 1320. This is a very, very fast load and save routine for saving your drawings to a disk. (It will work with a cassette as well, but more slowly.) This routine comes straight from the pages of De Re Atari (B-37) and has been elaborated on in Softside Magazine, (Issue #33, page 82).
The routine uses the CIO to move the screen image very rapidly. It copies all of screen memory and sends it to the disk. Loading the image, it reverses the process, and loads the bytes coming from the disk directly into screen memory. The whole process of saving or loading takes less than 30 seconds. The only drawback is that the routine gobbles up large quantities of disk space, about 60 sectors per screen. See Table 1 for a review of Drawing Board's commands.
The Vertical Move
Two different routines move the cursors. To move horizontally simply increment or decrement the value in the PM position registers located at decimal 5324B and 53249.
Moving vertically is a bit more complicated. I used a machine language subroutine that rapidly moves the player's bit patterns through the memory. This routine is not my own creation. I found it on page 318 of Your Atari Computer, A Guide to the 400/800 by Poole, Martin and Cook. I did adapt it to handle the motion of two players, by making use of several additional unused memory locations. It is simple and very effective.
The command process changes operating modes and colors to plot or draw. Remember, even though you draw in Graphics 8, you still have only two colors to work with, 0 and 1. This means that if you want to erase a line, you simply plot it again in color 0!
To plot in color 1, press joystick trigger 1. To plot in color 0 (erase, if you prefer), press joystick trigger 0.
Note, if you select inverse screen display, the colors will be reversed. Holding down a trigger button, while moving a cursor, will produce some very interesting effects. By all means experiment!
Lastly, what about Joysticks?
For my current drawing box, I have a unit which has 10 push buttons on it. Four are for each joystick, and the other two for the triggers. I find this arrangement infinitely preferable to joysticks simply because it can be run with one hand.
- L: Line mode, the cursors mark the endpoints of the line to be plotted.
- D:Draw mode, one cursor is removed for the screen.
- C:Circle mode, one cursor plots the center of the circle and the other sets the radius. For this to work correctly the cursors must be in line horizontally on the screen.
- B: Box mode, the cursors mark the opposite corners of the rectangle to be plotted.
- P:Print mode allows text to be added to the drawing at the specified position. To escape without printing enter an asterisk.
- I: Inverts the screen, black to white.
- N: Returns the screen to its normal mode.
- F:Fill mode works like The Box mode except that the area bounded by the rectangle is filled with a solid color.
- Control L: Load from specified file. To load from a disk file specify D:filename. To load from a cassette file just enter C:.
- Control S: Save to specified file. The same format as outlined above applies to saving. D:file name for disk and C: for cassette.
- Control C:Clear the screen without saving the picture.
Listing: ATDRAW.BAS Download