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.
"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.
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.
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.
A=USR(ADR(LD$))