Automatic printer control codes
PrintSet is a short utility routine that automatically sends control codes to a printer when you turn your ST on. You can select compressed mode, no linefeeds, bold, italics... whatever you like. In fact, you can send any number of codes at once.
Simply edit PrintSet's assembly language source code to include the control codes you need, then reassemble. This will produce an executable program that automatically sets up a printer to your specifications.
You'll need to edit the last line in the source code. It has the label pcodes. Currently, this line contains the Epson printer codes to reset a printer. The format of the line is [n,n,...n,0], where n is a decimal control code. Notice the list must end with a zero. In our example line, the number 27 is the [ESCAPE] character, the number 64 is the [@] symbol (which means "reset" to Epson printers) and the list ends with a zero.
TYPING IT IN
Listing 1, PSET.S, is written in 68000 assembly language, and can be implemented using any assembler which runs on the ST--including C language assemblers. Carefully type in the program and SAVE a copy to disk. The procedure to properly assemble the program is somewhat different for different assemblers. So we will describe what is needed using AS68.PRG, the 68000 assembler included with the Atari ST Developers Kit.
On your disk, you'll need the following 10 programs:
1. AS68 .PRG 2. AS68SYMB .DAT 3. BATCH .TTP 4. LINK68 .PRG 5. OSBIND .O 6. RELMOD .O 7. RM .PRG 8. WAIT .PRG 9. ASM .BAT 10.PSET .S
The top eight programs are part of the Atari ST Developers Kit. And you just typed in number 10, PSET.S. But where does ASM.BAT, number 9, come from?
You'll need to create your own ASM.BAT batch file, but don't worry, it's quite short. The file consists of the following lines of code:
as68 -1 -u %l.s
link68[ u,s ] %1.68k=%1,osbind
relmod %1.68k %l.prg
Note that the -1 in the first line is a lower-case letter l--all other similar-looking characters are number ones. When finished, save the above file to disk as ASM.BAT. This is the file which will instruct the BATCH program how to assemble and link the PSET program together.
With all the needed files on one disk, preferably a RAMdisk, double-click on BATCH.TTP. In the resulting dialog box, type in ASM PSET without the .s extender. AS6S will assemble and LINK68 will link your resulting .o file together with OSBIND.O to create a finished .PRG program. When finished, you'll find PSET.PRG on your desktop. This is your PrintSet program.
HOW IT WORKS
The top four lines of Listing 1 and any line starting with an asterisk [*] are comments. This program has a very short equates section with just three lines. The program really begins at the label start, and begins by calculating the final address of where we keep the printer control codes, then placing that address into address register zero (a0). This creates apointer to the of control codes to send.
Next, at continue we check to see if the end of the list of control codes has been reached. The list ends with a zero, so we test the byte that a0 is pointing to. If the byte isn't a zero, we haven't reached the end yet, so we don't take the branch to done. Otherwise we place the character we're pointing at onto the stack and point to the next available character. Then we place the device number of the destination device on the stack, in this case the number of the printer, and jump into GEMDOS which will output the character we passed into it over to the device we selected.
If any errors occurred while we output the character, the negative error number is placed in register d0 and returned. When we do return from GEMDOS we need to add four bytes to the stack, because we pushed four bytes before we called it. Then we check for errors by testing the number inside register d0. If no errors occurred, the value in d0 is zero and we branch back up to continue getting the next character in line.
On printer error, or when we've reached the end of the line to output, we end up at done, which will exit this application and return to the desktop by placing the exit application opcode on the stack and jumping into GEMDOS. If it works properly we should never return from this call, but just in case we do, we clean up the stack and return to the main program.
The last thing in the file is pcodes. where we keep the list of characters to actually output to the printer. Notice this demonstration code only sends the standard Epson reset command. You may place any amount of printer initialization codes here. Just make sure the list ends with a zero.
If you change your printer's attributes on a regular basis, you might find it handy to place the PrintSet program in an AUTO folder. That way, every time you boot up your ST, PrintSet will be run automatically. Please note that in this case, the program must be installed as a GEM application (.prg extension). To set up the AUTO folder, create a new folder on your bootup disk called AUTO and copy the PrintSet program to the folder. Only programs which make no calls to GEM may be run from within an AUTO folder.
Brad Robillard is a student at the University of Western Ontario. He is working towards dual degrees in music theory and computer science.
[Listing not available]