Classic Computer Magazine Archive ANTIC VOL. 3, NO. 3 / JULY 1984



by David Plotkin


This article dicusses advanced programming techniques using the ACTION! language. To use the accompanying listings, you must have the ACTION! cartridge from Optimized Systems Software.

An "interrupt" takes place in a computer system whenever one process takes precedence over a process that is being executed. It interrupts the lower-priority process so that it (the interrupt) can be executed first. Several interrupts are available on the Atari computers, including the display-list interrupt (DLI), the vertical-blank interrupt (VBI), and the system-timer interrupt, which was discussed in the January issue (Antic, "Page Flipping!" P. 34).

Before ACTION! came along, you had to be able to program in machine language to use these interrupts. Clinton Parker, ACTION!'s author, may have envisioned that ACTION! programmers would continue to use machine code to write interrupt routines, installing blocks of machine-language codes generated by their assemblers into their ACTION! programs. But ACTlON! is so fast that you call actually write a VBI or a system-timer interrupt in this high-level language, which is much easier than writing it in machine language.

Unfortunately when an ACTION! VBI interrupts an ACTION! program, the two use the same space in memory to hold temporary math variables for calculation. Because of this, the interrupt routine can alter the variables from the interrupted routine. As a result, results can be quite unpredictable.

Mike Fitch of Optimized Systems Software (OSS), ACTION!'s publisher, has solved this dilemma with two short machine-language routines that save the contents of the temporary math registers to the stack at the beginning of the interrupt, and then restore them just before the interrupt ends. Mike calls these routines SAVETEMPS and GETTEMPS.

You use the DEFINE command to assign machine-language code blocks to SAVETEMPS and GETTEMPS. The accompanying ACTION! program demonstrates the use of GETTEMPS and SAVETEMPS in a VBI. It also produces an interesting effect on the screen. These routines are just what you need if you want to use interrupts written in ACTION!

David Plotkin is a chemical engineer with Standard Oil Company of California and an avid game programmer.

Listing: INTRUPTS.ACT Download / View