8-Bit Software Online Conversion

View Printer Driver Generator - Listing

0MODE7:REM ADDED BY CJR 10REM >EpsonS 20REM by Steven Flintham 30REM 40REM A simple View printer driver su pporting underline, bold, correct 50REM printing of pound and hash, mic rospacing and an initial control code 60REM sequence. Note that the screen output during printing isn't correct. 70REM 80REM For simplicity the HMI setting is only taken account of when printing 90REM spaces. I don't think this is a problem. 100REM 110REM Friday 13th September 1996 120REM Saturday 14th September 1996 130REM Friday 20th September 1996 140REM Monday 30th September 1996 150: 160PROCinit 170PROCassemble 180PROCsave 185PRINT"Done!":REM ADDED BY CJR 190END 200: 210DEF PROCinit 220DIM code% 256 230font`pitch=12:REM this isn't normal pitch, it's 1/120ths of an inch 240hlt1=128:hlt2=129 250osasci=&FFE3 260oswrch=&FFEE 270ENDPROC 280: 290DEF PROCsave 300OSCLI "Save Driver "+STR$÷code%+" " +STR$÷O%+" FFFF0400 FFFF0400" 310ENDPROC 320: 330DEF PROCassemble 340FOR opt%=4 TO 7 STEP 3 350P%=&400:O%=code% 360[:OPT opt% 370JMP char`out 380JMP printer`on 390JMP printer`off 400JMP set`hmi 410JMP return`options 420: 430½ char`out must preserve A, X and Y 440.char`out 450PHA 460CMP #hlt1:BEQ toggle`underline 470CMP #hlt2:BEQ toggle`bold 480½ # handled by a special routine, £ changed to # 490CMP #ASC"#":BEQ do`hash 500CMP #ASC"£":BNE not`pound:LDA #ASC" #":.not`pound 510JSR osasci 520CMP #32:BEQ microspace 530PLA 540RTS 550: 560.toggle`underline 570TXA:PHA 580LDA underline`flag 590EOR #1 600STA underline`flag 610BEQ turn`underline`on 620.turn`underline`off 630LDX #(underline`off-printer`codes): BNE print`and`pull ½ always executes 640.turn`underline`on 650LDX #(underline`on-printer`codes):B NE print`and`pull ½ always executes 660: 670.toggle`bold 680TXA:PHA 690LDA bold`flag 700EOR #1 710STA bold`flag 720BEQ turn`bold`on 730.turn`bold`off 740LDX #(bold`off-printer`codes):BNE p rint`and`pull ½ always executes 750.turn`bold`on 760LDX #(bold`on-printer`codes):BNE pr int`and`pull ½ always executes 770: 780.do`hash 790TXA:PHA 800LDX #(hash-printer`codes):BNE print `and`pull ½ always executes 810: 820½ Add extra space after the charact er just printed if required. 830.microspace 840TXA:PHA 850SEC:LDA hmi:SBC #font`pitch 860BEQ pla`tax`pla`rts ½ exit 870PHA 880LDX #(double`density-printer`codes) :JSR print 890JSR vdu1:PLA:JSR oswrch 900TAX 910½ This loop outputs X+1 0's - the e xtra one is the high byte of the 920½ 'number of bytes to follow' secti on of the graphics command 930½ Note that using a BPL loop rather than explicitly incrementing X and 940½ having a BNE loop saves 1 byte bu t will cause things to go wrong if 950½ a very large space (over 1 inch, so it should never happen) is 960½ required. If changing back to a B NE loop, remember the test after the 970½ BPL needs to be the exact opposit e. 980.microspace`loop 990JSR vdu1:LDA #0:JSR oswrch 1000DEX 1010BPL microspace`loop 1020BMI pla`tax`pla`rts ½ always execut es 1030: 1040½ Send the codes starting at offset X to the printer only then unstack 1050½ the registers and return. On entr y A and X should have been stacked. 1060.print`and`pull 1070JSR print 1080.pla`tax`pla`rts:PLA:TAX:.pla`rts:P LA:.rts:RTS 1090: 1100½ Send the codes starting at offset X to the printer 1110.print 1120JSR vdu1 1130LDA printer`codes,X:PHP:INX 1140AND #127 ½ strip high bit 1150JSR oswrch 1160PLP:BPL print ½ stop after printing a byte with its high bit set 1170RTS 1180: 1190.vdu1 1200LDA #1:JMP oswrch ½ implied RTS 1210: 1220.printer`on 1230½ Because the flags are toggled bef ore they are tested, these are 1240½ effectively the opposite of the c urrent state 1250LDA #1:STA underline`flag:STA bold` flag 1260LDA #font`pitch:STA hmi 1270LDA #2:JSR oswrch 1280LDX #(init`printer-printer`codes):B EQ print ½ always executes 1290: 1300.printer`off 1310LDA #3:JMP oswrch ½ implied RTS 1320: 1330½ set`hmi must preserve X and Y 1340.set`hmi 1350STX hmi 1360RTS 1370: 1380½ return`options must preserve X 1390.return`options 1400LDY #1 ½ microspacing is supported 1410RTS 1420: 1430.underline`flag EQUB 0 1440.bold`flag EQUB 0 1450.hmi EQUB 0 1460: 1470½ Each code sequence is terminated by setting the high bit of the last 1480½ code - this means no codes >127 c an be sent, of course. init`printer 1490½ MUST be first as optimisations (r eplacing JMP with a branch) in the 1500½ code rely on it. 1510.printer`codes 1520.init`printer EQUB 27:EQUB 64:EQUB 27:EQUB 82:EQUB 3:EQUB 27:EQUB 120:EQUB 1+128 1530.underline`on EQUB 27:EQUB 45:EQUB 1+128 1540.underline`off EQUB 27:EQUB 45:EQUB 0+128 1550.bold`on EQUB 27:EQUB 69+128 1560.bold`off EQUB 27:EQUB 70+128 1570.hash EQUB 27:EQUB 82:EQUB 0:EQUB 3 5:EQUB 27:EQUB 82:EQUB 3+128 1580.double`density EQUB 27:EQUB 76+128 1590] 1600NEXT 1610ENDPROC