Classic Computer Magazine Archive ANTIC VOL. 8, NO. 4 / AUGUST 1989

Type-In Software

Hi-Res PUT and GET

Animation without Player/Missiles.

By Brad Timmins

Here's a different way to create colorful objects that move smoothly around your computer screen. This BASIC demo program includes the handy PUT-GET machine language routine for use in your own programs. It works on all 8-bit Atari computers of any memory size, with disk or cassette.

Creating colorful objects that move smoothly around your computer screen can be one the of most satisfying and eye-popping effects your Atari has to offer. Player/Missile graphics were specifically designed for this purpose, but P/M graphics have their limitations. First, you can only have a maximum of five players (objects) on the screen at once. Each player can only be eight resolution-lines wide. Also, you are limited to one color per player.

Hi-Res PUT and GET overcomes these limitations by allowing you to take a "snapshot" of any rectangular section of the screen and store it in memory. Then you retrieve the image, and reposition it on screen.

For example, if you wanted to move a box smoothly across the screen, you would start by drawing the box using PLOT and DRAWTO commands. Then, using the PUT and GET routine, save to memory the portion of the screen where you drew the box. And finally, put the image back in the screen shifted over by one pixel from the previous image.

Cycling through this procedure will create the illusion of smooth motion. You can also cycle through changing images to give the illusion of animation.

GETTING STARTED

To see the routine in action, type in Listing 1, PUTGET.BAS, and check it with TYPO II. Be sure to SAVE a copy before you RUN it. This demonstration program will draw an object and move it smoothly around the screen.

PUT and GET works with all high-resolution graphics modes (3-11). It also supports ANTIC modes E and D. ANTIC E is the so-called 7 1/2 graphics mode. This mode offers fine resolution and four colors to work with. ANTIC E is available on the XL/XE computers as Graphics 15.

ANTIC D has greater resolution than ANTIC E but only allows one color. This mode is available on XL/XE computers as Graphics 14. Atari 400/800 users must set up a special Display List to access these modes. PUT and GET does not support any text modes.

USING THE ROUTINE

PUT and GET is written in machine language for maximum speed. It is called by the USR statememt: X=USR(1536,XSTART,YSTART, XWIDTH ,YLENGTH, STORAGE, GRAPHICS MODE,COMMAND)

XSTART and YSTART are the upper left corner of the rectangular section of the screen you want to work with. XWIDTH and YLENGTH define the size of the rectangle XWIDTH defines the width of the rectangle. YLENGTH defines the length of the rectangle. Both can range from zero to the maximum coordinate value for the graphics mode you're in. For speed purposes, PUT and GET does not check for boundary errors so be careful.

STORAGE is the area of memory you want to store your image in. To determine how much memory you'll need, multiply XWIDTH by YLENGTH, then divide the result by the appropriate number listed on the table below:

Graphics mode           Divide by 
3                       4																
4                       8
5                       4
6                       8
7                       4
8                       8
9-11                    2
14 (Antic mode D)       8
15 (Antic mode E)       4  

Add one to the result of the division if you get a remainder other than zero. If you are going to store your image in a string, add one to XWIDTH and YLENGTH before you multiply.

GRAPHICS MODE tells PUT and GET what graphics mode you'll be using. Values range from 3 to 13. Values 3 through 11 are the standard high-resolution graphics modes. Use a value of 12 for Graphics 14 (ANTIC D), and 13 for Graphics 15 (ANTIC E).

COMMAND tells PUT and GET what action you want done. If COMMAND equals zero, PUT and GET will copy a section of the screen to memory. If COMMAND equals one, an area of memory will be copied to the screen.

PUT and GET takes up most of Page six and all of the cassette buffer. So if you do any cassette operations, you'll have to reinitialize PUT and GET.

Machine language programmers can access PUT and GET with a JSR to $609, and by subsituting these Zero Page locations for the USR parameters:

XSTART = 224 (two bytes)
YSTART = 222
XWIDTH = 220 (two bytes)
YLENGTH = 218
STORAGE = 216
GRAPHICS MODE = 214
COMMAND = 212

Note that XSTART and XWIDTH should both be set up as two-byte values, even if the coordinate values are less than 255.

Brad Timmins is a freelance programmer living in Draper, Utah. His program Macro RESET appeared in the January, 1989 Antic.

Listing: PUTGET.BAS Download