24K disk
by Tom Hudson

There are, several graphics artwork programs available for ATARI personal computers. One of the more popular packages, Datasoft's MICRO-PAINTER, allows the generation of pictures in GRAPHICS 7+, a mode that is not available with the current operating system.

Many people would like to use pictures generated with MICRO-PAINTER in their BASIC programs, but don't know how to load them. This article will present a fast, machine-language subroutine which sets up the proper graphics mode and loads standard, MICRO-PAINTER files.

Micro-Painter Files

MICRO-PAINTER allows computer artists to easily draw and save high-resolution graphics displays. When a graphic display is saved, the entire graphics memory area is saved, along with four color indicator bytes. The picture area consists of 192 lines, each containing 40 bytes for, for a total of 7680 bytes. This plus the 4 bytes of color information comes to a total of 7684 bytes in a MICRO-PAINTER picture file.

"Oh," you say, "all I have to do is put these bytes where they belong in memory, and that's it?" Not quite.

As mentioned earlier, MICRO-PAINTER uses GRAPHICS 7+, a mode similar, to GRAPHICS 7, but with twice the vertical resolution. In order to get the proper display, we must tell the computer to display the picture in mode 7+. Listing 1 is a BASIC program which sets up the graphics mode, reads the picture file, and sets the proper colors. Listing 2 the assembly language source code for the picture loader subroutine, for those readers interested in machine-language programming.

Picture Perfect

Type in the program in listing 1. After it is, SAVEd, RUN it. The program will ask for a MICRO-PAINTER filename. Place a disk with a MICRO-PAINTER picture file on it in your disk drive and type in the filename, with the "D:" prefix. If you make, a mistake, the program will ask again.

Once you enter a valid filename, the program will load the file very quickly placing it on the screen. While the picture is being loaded, you may notice that the colors in the picture are not correct. This is because the four color bytes are at the end of the file, and are read last. As soon as the picture is completely loaded, the colors will be changed to their proper values.

The Program

Let's look at Listing 1 and walk through the program.

Line 230 - This line sets up the string LD$ and READS the DATA in lines 390-430 into this string. This is a machine-language subroutine which sets up the GRAPHICS 7+ screen and reads the 7680 bytes of picture information into the screen RAM very quickly.

Line 290 - Sets up a string variable to hold the picture filename.

Line 300 - Inputs the picture filename and opens the file as input. The "TRAP 300" will cause any errors to be sent to' line 300. That is, if there is any error condition, the program will ask for the filename again.

Line 310 - This line actually sets up the GRAPHICS 7+ mode and loads in the picture. The "GRAPHICS 24" command sets up a full-screen GRAPHICS 8 screen, which happens to use 7680 bytes, the same as GRAPHICS 7+. The USR call "A=USR(ADR(LD$))" converts the GRAPHICS 8 screen to GRAPHICS 7+, then reads the first 7680 bytes of the picture file into the display memory. During this operation, you will see the picture appear from the top of the screen to the bottom.

Line 320 - The USR call returns a value in the variable "A." If this value is a 1, the picture data was loaded successfully and the program continues with the next line. If the value is not 1, there was some type of error and the program goes to line 300 and asks for the filename again.

Line 330 - This line reads the last four bytes of the file, which contain the picture's color information. These values are POKEd into the color registers. At this point, the picture is completely loaded, with correct colors.

Line 340 - This line loops until the START key is pressed.

Line 350 - Once the START key is pressed, this line transfers control to line 300, which asks for another filename.

Lines 390-430 - These DATA statements are the machine-language values for the picture loader.

Using The Loader In Your Programs

The machine-language picture loader presented here is very easy to use in your own programs. Simply follow the step-by-step instructions.
  1. Set up LD$ with the machine-language sub-routine. (Line 230)
  2. Open IOCB #1 as input with the desired filename. You MUST use IOCB #1 or the loader will not work.
  3. Do a GRAPHICS 24 command.
  4. Call the machine-language subroutine with the command: A=USR(ADR(LD$))
That's all there is to it!

Summary

With this subroutine, ATARI computer owners who use Datasoft's MICRO-PAINTER graphics package will be able to show their pictures in their BASIC programs. The subroutine is much faster than BASIC, and is easy to use.