 .OPT NO LIST›;  SAVE #D1:PRINTER.M65›;› .PAGE "Printer Handler"›;  LOAD #D1:ROMTEST.M65›;›; labels localized 14 Oct 94›;› *= $E430›PRINTV› .WORD OPEN.P-1 Printer› .WORD CLOSE.P-1› .WORD NOFUNC.P-1› .WORD PUT.P-1› .WORD STATUS.P-1› .WORD NOFUNC.P-1› JMP PIN› .BYTE 0›;›  *= $FE99› .LOCAL›  LIST›PIN› LDA #30     Printer init› STA PTIMOT  Set time for› RTS         status call›;›?ADRSTT› .WORD DVSTAT›;›?ADRPRT› .WORD PRNBUF›;›STATUS.P› LDA #4      Buffer len and› STA PBUFSZ  adr for status› LDX ?ADRSTT ; (ldx #<dvstat)› LDY ?ADRSTT+1 ;(ldy #>dvstat)› LDA #'S› STA DCOMND  In DAux1 causes› STA DAUX1   sideways (at820)› JSR ?SETDCB› JSR SIOV    Execute status› BMI NOFUNC.P Exit if bad› JSR ?SETTIM else set timeout›;›NOFUNC.P› RTS›;›OPEN.P› JSR STATUS.P Open Prtr› LDA #0      Check status and› STA PBPNT   reset buffer ptr› RTS›;›PUT.P› PHA         Put Byte: Save› LDA ICDNO,X on stack and› STA ICDNOZ  set device num› JSR ?BUFLEN Do buffer length› LDX PBPNT   Set index› PLA         Recover byte› STA PRNBUF,X Add to buffer› INX         Bump index and,› CPX PBUFSZ  if at maximum,› BEQ ?PRTBUF print it out.›;› STX PBPNT   Else save index› CMP #155    Was byte a CR?› BEQ ?GOTCR  If so pad buffer›;›; Exit, line incomplete›;› LDY #1      Else just return› RTS         for next byte.›;›?GOTCR› LDA #32     Pad with spaces›;›?PADLOOP› STA PRNBUF,X  Pad out› INX           printer buffer› CPX PBUFSZ    with character› BNE ?PADLOOP  in accumulator.›;›?PRTBUF› LDA #0      Reset index for› STA PBPNT   next call.› LDX ?ADRPRT   ; (ldx #<prnbuf)› LDY ?ADRPRT+1 ;(ldy #>prnbuf)› JSR ?SETDCB   Reset DCB, prt› JMP SIOV      line and exit›;›CLOSE.P› JSR ?BUFLEN Close P: If buffer is not› LDA #155    empty, pad with› LDX PBPNT   CR's, then print› BNE ?PADLOOP and exit via Sio› LDY #1      Else just exit› RTS›;›?SETDCB› STX DBUFLO  Set up DCB› STY DBUFHI  Buffer address› LDA #$40    Sio device = P1:› STA DDEVIC  (if P2: then $4F)› LDA ICDNOZ  Cio device as› STA DUNIT   set by caller.› LDA #$80    Flag Sio output› LDX DCOMND› CPX #'S     except on Status› BNE ?SETDIR› LDA #$40    which is input.›?SETDIR› STA DSTATS› LDA PBUFSZ  Finish up DCB› STA DBYTLO› LDA #0› STA DBYTHI› LDA PTIMOT› STA DTIMLO› RTS›;›?SETTIM› LDA DVSTAT+2 Get timeout› STA PTIMOT   from Status› RTS›;›?BUFLEN› LDY #'W     Command in Y› LDA ICAX2Z  Check Icax2›;›?NORM?› CMP #'N     Normal width?› BNE ?WIDE?›;› LDX #40     Yes, line len 40› BNE ?SETLEN Go always›;›?WIDE?› CMP #'D     Double width?› BNE ?SIDE?›;› LDX #20     Yes, line len 20› BNE ?SETLEN›;›?SIDE?› CMP #'S     at820 sideways?› BNE ?DEFLT›;› LDX #29     Yes, line len 29›;›?SETLEN› STX PBUFSZ› STY DCOMND› STA DAUX1   Icax2->Daux1› RTS›;›?DEFLT› LDA #'N     Make it normal› BNE ?NORM?  Go always›