Feature Application
Antic Spooler
By GLENN SMITHKeep on computing while you print!
Antic Spooler is a short machine Ianguage printer buffer that allows you to continue using your computer for other tasks while printing lengthy program listings. The BASIC program which creates Antic Spooler works on all 8-bit Atari computers of any memory size, with disk drive.
"Is your computer tired of waiting for your printer to finish?'' You've seen ads for printer buffers (also called printer spoolers). These devices--which can be either hardware or software--temporarily store data sent to the printer by your computer program and send that data to the printer, one line at a time.
As your program sends more data to the printer, the buffer intercepts it and stores it until the first task has been completed. For many applications, printer buffers really do save time because the printer and the computer can work simultaneously.
Antic Spooler creates an 8K buffer in the memory of your 8-bit Atari. Text sent to the printer is intercepted by Antic Spooler, which returns control to your computer as soon as the characters have been stored in RAM. Antic Spooler then sends characters continuously from RAM to the printer while your main program keeps on running.
ANTIC SPOOLER CHALLENGE
The MAC/65 source code for Antic Spooler, SPOOLER.M65, is 118 sectors long and can be found on this month's Antic Disk. Assembly language programmers should not find it hard to enhance Antic Spooler. This magazine would be interested in publishing the best patches or add-ons to Antic Spooler.
For example, you might want to enlarge the buffer to 16K or so, modify it to use the RAM under the operating system, or create a 64K buffer using the extended memory in the 130XE and upgraded XL computers.
As written, Antic Spooler is useful mainly for making printouts of your own program listings while you continue to compute. Maybe you could even find ways to make Antic Spooler work with some disk-based commercial word processing software. (As is, the spooler should already work with commercial cartridge software such as the original version of Atariwriter.)
GETTNG STARTED
Since Antic Spooler is a machine language program and cannot be typed-in and SAVEd, we'll use a simple BASIC ''helper'' program that will automatically recreate Antic
Spooler and store it to a disk file.
Type in Listing 1, SPOOLMAK.BAS, check it with TYPO II and SAVE a copy before you RUN it. Listing 1 will create Antic Spooler, and store it to a disk file called SPOOLER.OBJ. Antic Disk users will find a copy of SPOOLER.OBJ on this month's disk.
Copy SPOOLER.OBJ to another disk and rename it as AUTORUN.SYS. Make sure this disk also has the DOS.SYS and DUP.SYS files, too. Now reboot your Atari with this disk. The AUTORUN.SYS file will install the spooler into low memory. Your free memory will be reduced by about 8K.
Let's test the spooler. LOAD any BASIC program, type LIST "P:" and Antic Spooler will capture text and begin printing it. After the program has been LlSTed, BASIC's "READY" prompt will appear.
HOW IT WORKS
Multi-tasking? No, not really. Antic Spooler modifies the resident "P:" printer handler, specifically the PUT CHAR routine. Whenever you execute a statement that PRINTs
to the printer (LPRINT, LIST "P:", PRINT #), the new P: handler will store text in the spooler and increment the character counter. Then every 1/60 of a second, during
the Vertical Blank Interrupt, control passes to the VBI part of Antic Spooler.
The VBI routine first checks to see if the printer is busy. In this routine, PUT CHAR takes priority over printing, which means that the spooler would rather store characters in its buffer than print them.
When the printer is free, the priority flag is turned off (set to zero), and the spooler will try to print a character.
The priority flag is turned on by PUT CHAR whenever a character is stored in the buffer, waiting to be printed.
lf the priority flag was off, the VBI routine checks the result of its last attempt to print a character. If there was some problem and that character was not printed, it is re-sent until the character is printed.
If, on the other hand, the character was printed successfully, Antic Spooler searches the buffer for the next character. If it finds one, Antic Spooler puts it into the resident print handler buffer and decrements the character counter.
When the resident buffer becomes full, it's printed using the standard SIO vector (the same vector normally used by your printer).
WARNINGS & DON'TS
Since Antic Spooler sends characters to the printer through the SIO vector, it's not affected by OPEN and CLOSE statements, or by the LPRINT and LIST "P:" commands.
This means it will work with software that never executes a CLOSE command, which is why it works with commercial cartridge software like the original version of AtariWriter.
To conserve memory for your main program, Antic Spooler relocates itself to the lowest memory location possible. The program pushes your Atari to its limit. The computer wasn't designed to do two things at once, so programs won't always be as fast as you'd expect. There may even be moments when the screen freezes briefly while Antic Spooler sends text to the printer or frees buffer space for incoming characters. And since printing affects the sound registers, programs that use sound will be affected.
You should also keep the following cautions in mind: lf you try to LOAD a large BASIC program over the Antic Spooler or its buffer, your computer may lock up. Antic has successfully tested Antic Spooler with BASIC programs as large as the 94-sector WYSIWYG Cassette Jackets (November 1987).
You can't turn BASIC on or off while Antic Spooler is printing, but you can do so afterwards.
Finally, you shouldn't use the DOS command because the DUP.SYS file might load right over Antic Spooler. lf you enter DOS, Antic Spooler will abort its printing, reset all modified memory pointers and exit to DOS. When you return to BASIC, Antic Spooler will be unavailable.
Glenn Smith is a Mesa College senior at Grand Junction, Colorado and has been programming for five years. This is his first publication inAntic.
Listing 1:SPOOLER.M65 Download / View
Listing2:SPOOLER.OBJ Download