[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Applesoft BASIC 8 bit PRINT routine
Some years ago, I wrote an 8 bit print (or actually LPRINT) routine.
It just duplicated the Applesoft PRINT code but bypasses the part that
stripped bit 7 and did INVERSE or flash and uses a direct interface card
PRINT routine instead of the COUT vector.
To shorten it, I left out the code to support TAB, SPC and "," comma.
My original code sent the 8 bit codes to an uncommon parallel printer card.
I've modified it here to work with the semi-standard slot 1 output routine.
($C107)
And I relocated it at $310 instead of $300 to avoid your conflict.
This routine works with everything that would work with a PRINT statement
(except it doesn't put in the spaces that would be put in by TAB, SPC or
",")
That is, a string variable, literal or numeric literal or variable.
e.g. 200 & "Test"; A$(3) ; CHR$(200) ; X
Use a final semi-colon to suppress CR at end.
I tested it briefly with a IIgs and an Imagewriter.
The Imagewriter has a hex dump mode which let's you see all the charaters
received.
Very handy for debugging something like this.
Printout of test program showed uncorrupted ASCII codes from $20 - $FF,
except it ate $89 (ctrl-I) and added LF after CR.
It keeps Applesoft PRINT from eating control codes, it doesn't stop the port
driver from doing that.
You should be able to avoid this by doing
print chr$(4)"pr#1": print chr$(9)"Z"
after setting your baud rate, etc.
I think it should work with a //c as well.
If you need to use port 2, then the $c107 should be changed to $c207.
I'm assuming you know how to type in the hex codes and save the ml routine.
You should initialize the port settings in the normal way.
This routine has the advantage of not needing a PR#1 before each time you
print.
You can use standard Applesoft print commands to print to screen, disk or
the other port
and intermix the & (LPRINT) command without
It's not too long and much faster than parsing a string one character at a
time from Applesoft.
On a related note.
If you are switching back and forth between printing to the screen or
printing to some other device and you find that the PR# is doing some
initialization that you don't want redone, ProDOS supports a syntax
200 print chr$(4) "PR# A$C107"
that may enable you to send characters without reinitializing the port.
SOURCE FILE #01 =>LPRINT4
0000: 1 * LPRINT4.ASM 20021206.2304
0000: 2 * Copyright 1988 - 2002 by Joel Buckley
0000: 3 * for 8-bit printer output
0000: 4 *
0000: 5 * 880915. orig - adapted from Applesoft PRINT
routine
0000: 6 * 880915.1600 rev 1 - no SPC,TAB, comma field
support
0000: 7 * 881006.1630 rev 2 - make relocatable for Toolbox
0000: 8 * 021206.2304 rev 3 - use $C107 print entry
0000: 9 * 021207.0020 rev 4 - change org to $310
0000: 10 *
----- NEXT OBJECT FILE NAME IS LPRINT4.0
0310: 0310 11 ORG $310
0310: 12 * START JSR $00B7 because Toolbox doesn't
0310:F0 27 0339 13 BEQ OUTCR
0312:C9 3B 14 SCTST CMP #$3B ';'
0314:F0 29 033F 15 BEQ PARSELP
0316:20 7B DD 16 JSR $DD7B FRMEVL
0319:24 11 17 BIT $11
031B:30 06 0323 18 BMI POUT
031D:20 34 ED 19 JSR $ED34 FOUT
0320:20 E7 E3 20 JSR $E3E7 STRLIT
0323:20 00 E6 21 POUT JSR $E600
0326:A0 00 22 LDY #$00
0328:AA 23 TAX
0329:F0 09 0334 24 BEQ DONE
032B:B1 5E 25 OUTLP LDA ($5E),Y
032D:20 07 C1 26 jsr $c107 hope it saves X + Y
0330:C8 27 INY
0331:CA 28 DEX
0332:D0 F7 032B 29 BNE OUTLP
0334:20 B7 00 30 DONE JSR $00B7
0337:D0 D9 0312 31 BNE SCTST
0339:A9 0D 32 OUTCR LDA #$0D end of line CR
033B:20 07 C1 33 jsr $c107
033E:60 34 RTS
033F: 35 *
033F:20 B1 00 36 PARSELP JSR $00B1
0342:D0 CE 0312 37 BNE SCTST
0344:60 38 RTS
0334 DONE 0339 OUTCR 032B OUTLP 033F PARSELP
0323 POUT 0312 SCTST
** SUCCESSFUL ASSEMBLY := NO ERRORS
** ASSEMBLER CREATED ON 30-APR-85 22:46
** TOTAL LINES ASSEMBLED 38
** FREE SPACE PAGE COUNT 84
100 PRINT "PRINT4.BAS 021207.0023"
105 PRINT "Allows user to send 8 bit character codes to printer."
110 PRINT "Bload lprint4.0 before use"
200 POKE 1013,76: POKE 1014,16: POKE 1015,3 : rem set & to $310
250 :
300 A$ = " joel ":B = 234
400 & A$" babs "" test "B
450 & CHR$ (27) CHR$ (120) CHR$ (51) CHR$ (18)
500 FOR A = 1 TO 7
600 FOR B = 0 TO 31
700 & CHR$ (B + 32 * A)" ";
800 NEXT B: & : &
900 NEXT A