0 MODE7:REM ADDED BY CJR 10 REM >EpsonS 20 REM by Steven Flintham 30 REM 40 REM A simple View printer driver supporting underline, bold, correct 50 REM printing of pound and hash, microspacing and an initial control code 60 REM sequence. Note that the screen output during printing isn't correct. 70 REM 80 REM For simplicity the HMI setting is only taken account of when printing 90 REM spaces. I don't think this is a problem. 100 REM 110 REM Friday 13th September 1996 120 REM Saturday 14th September 1996 130 REM Friday 20th September 1996 140 REM Monday 30th September 1996 150 : 160 PROCinit 170 PROCassemble 180 PROCsave 185 PRINT"Done!":REM ADDED BY CJR 190 END 200 : 210 DEF PROCinit 220 DIM code% 256 230 font_pitch=12:REM this isn't normal pitch, it's 1/120ths of an inch 240 hlt1=128:hlt2=129 250 osasci=&FFE3 260 oswrch=&FFEE 270 ENDPROC 280 : 290 DEF PROCsave 300 OSCLI "Save Driver "+STR$~code%+" "+STR$~O%+" FFFF0400 FFFF0400" 310 ENDPROC 320 : 330 DEF PROCassemble 340 FOR opt%=4 TO 7 STEP 3 350 P%=&400:O%=code% 360 [:OPT opt% 370 JMP char_out 380 JMP printer_on 390 JMP printer_off 400 JMP set_hmi 410 JMP return_options 420 : 430 \ char_out must preserve A, X and Y 440 .char_out 450 PHA 460 CMP #hlt1:BEQ toggle_underline 470 CMP #hlt2:BEQ toggle_bold 480 \ # handled by a special routine, ` changed to # 490 CMP #ASC"#":BEQ do_hash 500 CMP #ASC"`":BNE not_pound:LDA #ASC"#":.not_pound 510 JSR osasci 520 CMP #32:BEQ microspace 530 PLA 540 RTS 550 : 560 .toggle_underline 570 TXA:PHA 580 LDA underline_flag 590 EOR #1 600 STA underline_flag 610 BEQ turn_underline_on 620 .turn_underline_off 630 LDX #(underline_off-printer_codes):BNE print_and_pull \ always executes 640 .turn_underline_on 650 LDX #(underline_on-printer_codes):BNE print_and_pull \ always executes 660 : 670 .toggle_bold 680 TXA:PHA 690 LDA bold_flag 700 EOR #1 710 STA bold_flag 720 BEQ turn_bold_on 730 .turn_bold_off 740 LDX #(bold_off-printer_codes):BNE print_and_pull \ always executes 750 .turn_bold_on 760 LDX #(bold_on-printer_codes):BNE print_and_pull \ always executes 770 : 780 .do_hash 790 TXA:PHA 800 LDX #(hash-printer_codes):BNE print_and_pull \ always executes 810 : 820 \ Add extra space after the character just printed if required. 830 .microspace 840 TXA:PHA 850 SEC:LDA hmi:SBC #font_pitch 860 BEQ pla_tax_pla_rts \ exit 870 PHA 880 LDX #(double_density-printer_codes):JSR print 890 JSR vdu1:PLA:JSR oswrch 900 TAX 910 \ This loop outputs X+1 0's - the extra one is the high byte of the 920 \ 'number of bytes to follow' section 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 but 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 BNE loop, remember the test after the 970 \ BPL needs to be the exact opposite. 980 .microspace_loop 990 JSR vdu1:LDA #0:JSR oswrch 1000 DEX 1010 BPL microspace_loop 1020 BMI pla_tax_pla_rts \ always executes 1030 : 1040 \ Send the codes starting at offset X to the printer only then unstack 1050 \ the registers and return. On entry A and X should have been stacked. 1060 .print_and_pull 1070 JSR print 1080 .pla_tax_pla_rts:PLA:TAX:.pla_rts:PLA:.rts:RTS 1090 : 1100 \ Send the codes starting at offset X to the printer 1110 .print 1120 JSR vdu1 1130 LDA printer_codes,X:PHP:INX 1140 AND #127 \ strip high bit 1150 JSR oswrch 1160 PLP:BPL print \ stop after printing a byte with its high bit set 1170 RTS 1180 : 1190 .vdu1 1200 LDA #1:JMP oswrch \ implied RTS 1210 : 1220 .printer_on 1230 \ Because the flags are toggled before they are tested, these are 1240 \ effectively the opposite of the current state 1250 LDA #1:STA underline_flag:STA bold_flag 1260 LDA #font_pitch:STA hmi 1270 LDA #2:JSR oswrch 1280 LDX #(init_printer-printer_codes):BEQ print \ always executes 1290 : 1300 .printer_off 1310 LDA #3:JMP oswrch \ implied RTS 1320 : 1330 \ set_hmi must preserve X and Y 1340 .set_hmi 1350 STX hmi 1360 RTS 1370 : 1380 \ return_options must preserve X 1390 .return_options 1400 LDY #1 \ microspacing is supported 1410 RTS 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 can be sent, of course. init_printer 1490 \ MUST be first as optimisations (replacing 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 35:EQUB 27:EQUB 82:EQUB 3+128 1580 .double_density EQUB 27:EQUB 76+128 1590 ] 1600 NEXT 1610 ENDPROC