TOUCH TABLET UTILITIES

by Paul Lay

1. PICLOADA

One of the nice things about Atari Artist used with the touch tablet is that it saves pictures in a 'compacted' form which enables many more pictures to be stored on disk or cassette. One of the problems is that this format is not compatible with any of the available programs for loading pictures into your own programs. Up to now this has meant that your picture has had to be saved in 'Micropainter' format by using the INSERT key whilst in DRAW mode and every picture no matter whether simple or complex would take 62 sectors on a disk. I wanted to write a game which required many pictures and so had to find a way to use the 'compacted' format. Here then you have the inside story about Atari Artist's compaction technique together with a program (which runs in machine code) to load pictures into your own programs. Later I will provide a routine to use with this program which will allow you to add more colours to your picture.

The first point to note about the compaction technique is that there are two different modes of screen access, vertical and horizontal.

Vertical access: If we consider the screen as being divided into 40 columns (or bytes) then we access one column at a time, starting at the first row and move down every other row until we reach the bottom of the screen. We then return to the top of the column and begin with the second row moving down every other row again until we reach the bottom before moving to the next column.

Horizontal access: This simply scans across rows from left to right.

So how do we know which format to use? In every PIC file saved by Atari Artist the 8th byte in the file indicates the mode (l=vertical, 2 =horizontal). From there bytes 14 to 18 hold the values for the colour registers 708 to 712 before the actual screen data begins at byte 28. Note that, of the first 27 bytes, only those described are actually used. The others appear redundant other than a length count which it is not necessary to use. The compacted screen data takes the following form:

(OP, DATA), (OP, DATA), ... , (OP, DATA)

OP can define three different operations:

OP=0:

The data field for this operation is three bytes long and takes the form

(hi, low, byte)

hi and low form a 16 bit value (256*hi+low).

The action to be taken here is to store 'byte' in the next (256*hi+low) screen locations.

OP<=128 (but obviously>O):

In this case the data field is just one byte long

(byte)

This is similar to OP=O but is effectively an 8 bit version as the action taken is to store 'byte' in the next 'OP' screen locations.

OP>128:

In this case the data field is OP-128 bytes long

(byte 1, byte 2, byte3, ... , byte OP-128)

Here the action taken is to store the OP-128 bytes in the next OP-128 screen locations.

Note that in all three modes the 'next' byte is determined by whatever screen access mode we are in.

The whole picture from byte 28 to the end of the file is then stored as a series of 'OP's and their data fields. The OP used is dependant on the number of pixels of the same colour (or bytes of the same value) in each row or column of the screen.

The PICLOADA program can be used in conjunction with your own BASIC programs (as a subroutine). The original version was in BASIC but was somewhat slow so this is version two which is in machine code to load a picture as fast as Atari Artist. The program will prompt you for a filename (you must use the device name) and will then set up an ANTIC #E display list before loading in the picture. Once loaded you may press any key to load another picture.

The main body of the machine code is relocatable and is therefore stored in a BASIC string, although a couple of routines have to be stored in page 6. In fact the main code is 244 bytes long and the routines in page 6 occupies 158 bytes. The routine can easily be called from BASIC by the following command:

var = USR (ADR(CODE$), ADR(FILENAME$))

where CODE$ contains the main body of the machine code routine and FILENAME$ contains the filename of the compacted picture. Lines 10 to 630 of the program set up the machine code routine while the rest of the program demons- trates how the routine should be used by loading in compacted screens specified by the user.

2. COLOUR ATTRIBUTES

NOTE: This program uses the routine from PICLOADA (in this issue). PICLOADA must therefore be merged with this listing by LISTing lines 10 to 630 of PICLOADA to disk with LIST "D:filename",10,630 and then, after having LOADed Attributes, using ENTER "D:filename".

This program takes Atari Artist pictures and allows each colour register to be changed (or attributed) on every scan line thus producing a picture with many more colours than normally available. The program is controlled with the Touch Tablet.

When the program is RUN, you will be given a list of available commands and prompted for a picture filename. Enter the filename and the picture will be loaded. By using the Touch Tablet in port #0 you can now control a cross-hair cursor which you may move about the screen. Move the cursor so that it is on a certain colour and hold down any Touch Tablet button. By moving the stylus around this colour is varied from the position of the cursor to the bottom of the screen. When the desired colour is displayed, release the button and the colour will remain set.

Note, as the colour is changed from the cursor position downwards, a top-down approach should be taken when colouring pictures.

There are five functions which are accessed by the keypresses indicated.

  • [L] ...Load attributes
  • [S] ...Save attributes
  • [R] ...Random fill
  • [B] ...rainBow fill
  • [N] ...New picture

Load and Save store and recall the attributes to disk with the picture filename plus the extender .ATB.

The two fill commands affect the next colour selected by replacing it with either a random or rainbow pattern. New restarts the program so that a new picture can be worked on (don't forget to save any previous work first).

Finally note that the cross-hair cursor is a player graphic controlled by strings and it is important that the strings are DIMensioned in the correct order. If you have any problems LIST the program out to disk, re-boot and ENTER it to clear the variable table.