Classic Computer Magazine Archive ANTIC VOL. 5, NO. 10 / FEBRUARY 1987

Flash 8 pictures lightning-fast

130XE Slide Show

By Bill Marquardt, Antic Technical Assistant

Learn to use the extra 64K memory in your 130XE. These short programs demonstrate how you can use Atari BASIC to control RAM bank switching. 130XE Slide Show works on Atari 130XE computers (or compatible memory upgrades) with disk. This article's first listing, the simpler 130XE Bank Switcher routine, will work on cacsette as well as disk.

"How can I use the 130XE's extra memory in my own BASIC programs?"

This is one of the questions asked most often of the Antic technical staff.

Elsewhere in this issue, Bill Wilkinson warns us of the difficulties in using Atari BASIC to control 130XE RAM bank switching. Ian Chadwick offered similar advice in the November 1985 Antic (130XE Memory Management, page 28). You should carefully read both articles before trying this technique in your own programs.

Although bank-switching programs are best written in assembly language, Atari BASIC is powerful enough to demonstrate the "bare bones" of the technique. These two demonstration programs are short, but surprisingly effective.

And even if you don't understand the processes involved, you can still enjoy using your 130XE Slide Show program. It is ideal for user group meetings, trade show displays, or even short animation sequences.


Type in Listing 1, SWTTCH.BAS, checking it with TYPO II, and SAVE a copy (to disk or cassette) before you RUN it. This short stand-alone program fills the first "extra" 16K memory bank with letter A's, the second bank with B's, the third with C's and the fourth with D's. The program then "switches" rapidly between banks, displaying the contents of each bank on a Graphics 2 screen.

Each screen is located in a different 16K bank of the 130XE's extended memory. When you type RUN, you'll first see your 130XE slowly fill each bank with the appropriate letter. The letters will then begin flashing before your eyes as one bank is switched "in" and another is switched "out."


Listing 2, SLIDES.BAS, is a considerably more useful program even though it's not that much longer than the first listing. Type in SLIDES.BAS, check it with TYPO II, and SAVE a copy (to disk only) before you RUN it.

SLIDES.BAS loads eight of your favorite microscreens into RAM and continuously flashes each picture onscreen in a digital slideshow--at adjustable speeds that you can make blinding-fast if you desire.

Use Micro-Painter or PD MicroPaint Artist ($10, The Catalog, PD0053) to create your screens.

If your microscreens are in a different format, you can use the Rapid Graphics Converter (Antic, November 1985) to convert your pictures to Micro-Painter format. (Antic Disk owners: We have included Rapid Graphics Converter as a bonus program, CONVERT.BAS, on the monthly disk.)

After you have selected your microscreens, copy them to your SLIDES disk using filenames "D:F1", "D:F2" and so on up to "D:F8".

If you'd rather use other filenames, type them in at lines 180 to 210, or replace these lines with your own input routine.

When RUN, SLIDES.BAS loads all eight microscreens into the XE's "extra" RAM. You'll only see four of these pictures as they load, though, and their colors will not be correct. But once all eight screens are loaded, the colors are corrected and the slide show begins.

You can adjust the speed of the slide show with a paddle controller plugged into joystick port 1.


Each Micro-Painter picture contains 7680 bytes of picture information and four bytes of color information. This is just less than 8K of memory. We can put two of these pictures into each 16K bank of memory. By combining page flipping and bank switching techniques, we are actually using almost all of the 130XE's extra memory!

On the older Ataris (those with four joystick ports), ports 3 and 4 were controlled by PORTB (54017, $D301). The 130XE, having only two joystick ports, uses PORTB to determine how the memory will be used by the 6502 CPU and the ANTC chip.

Primarily, we're interested in bits 2 through 5 of PORTB. Bits 0, 6 and 7 will be set (equal to 1), giving us a base value of 193 (1+64+128 = 193).

A zero in bit 5 tells ANTIC to use the extended memory. Otherwise, ANTIC will use main memory. Bit 4 is used the same way for the 6502. The variable MODE controls bits 4 and 5. Bits 2 and 3 determine which of the four 16K banks of the extended memory will be used.

Using this information, we can use the following formula to do all of our bank switching:

POKE PORTB,(193 + 16*MODE+4*BANK).

Here, MODE is set to 0, telling both ANTIC and the CPU to use extended memory. BANK0 through BANK3 contain the proper bank values. These variables are defined in lines 278-280. Our initial display list is set up in line 250 and 300-350.

In extended memory mode, memory at locations 16384 ($4000) to 31767 ($7FFF) are switched out and one of the four 16K extra banks is switched in to take its place. Now, when your program PEEKs and POKEs in this range, it will be dealing with the new bank instead of the original.

Next, the program loads a pair of microscreens into each of the four memoy banks. Lines 290 and 360-460 switch in the appropriate bank, then call the subroutine at line 740 to load two pictures into that bank.

Bytes 4 and 5 of the display list form an address which points to the beginning of screen memory. Notice that byte 4, the low address byte, is POKEd with a 16 at line 300. This offset is needed because our 7680 byte screen must cross a 4K boundary in RAM. Without the offset, the lower portion of our picture would not display correctly. The file loader routine requires the same offset at line 770.

The variable HI is used as the high address byte of the screens. It is POKEd into the display list as appropriate. During loading, HI is also used to determine whether the picture is to be stored into the upper or lower 8K of the bank.

Lines 470-620 do the actual back switching and page flipping, using the subroutine at line 630 to set the color registers and adjust the display list.

To learn more about the techniques discussed here, we suggest the following books:

Your Atari Computer by Lon Poole.
$19.95, Osborne/McGraw-Hill.

Atari Graphics and Arcade Game Design by jeffrey Stanton with Dan Pinal. $12.35, The Catalog, MG0103.

Listing1:SWITCH.BAS Download

Listing2:SLIDES.BAS Download

Listing3:CONVERT.BAS Download