> PRNDEMO # Needs to run in I/O processor : ( debug%= 2 128 <"USB Printer Demo v0.10" FA ctrl% 31,M%(32),data% 31,print% 72:in%=0:X%=ctrl%:Y%=X%256 P :Close_All: Z: d"Waiting for PRN device"; n"usb_Init:usb_Sync:usb_Flush x*usb_Cmd(&11) : TEXT COMMANDS -usb_Cmd("IPH") : I/O IN BINARY ; If IPH gives Bad command we're already in binary mode ':usb_Cmd("QP2") : QUERY PORT 2 res%=?usb_result%:usb_Sync  (res% 4)=0:A%=(100) , (res% 4) : BIT 2 = PRINTER 1usb_Cmd("SC "+0) : SET CURRENT DEVICE 0  " - Connected"' : : 2usb_Cmd("PGS") : PRINTER GET STATUS res%=?usb_result%:usb_Sync "Printer status: "; #res%8:"NOERR "; "ERROR "; 'res%16:"SELECTED "; "NOSEL "; &res%32:"NOPAPER"; "PAPEROK"; " , "File to print: "in$ 6! in$,1)="*":in$,2):in$="" @ in$<>"" J0in%=(in$): in%=0:"File '"in$"' not found" Tin% ^: h/:A%=#in%: A%=10 A%=13 #in%:B%=#in% r.crlf%=((A%=13 B%=10) (A%=10 B%=13)) |5usb_WrStr("DSD "+1+13) : DEVICE SEND DATA 7usb_WrStr(13) : CARRIAGE RETURN $ptr%=0:ext%=#in%:#in%=0:col%=0 .:13;"Printing ";(100*(ptr%/ext%));"%"; *len%=32:len%+ptr%>ext%:len%=ext%-ptr%  gbpb(4,in%,data%,len%,ptr%) iptr%=0:optr%=0   A%=data%?iptr%:iptr%=iptr%+1  A%=26:A%=32 print%?optr%=A%:B%=1 D A%=10 A%=13:col%=-1: crlf%:optr%=optr%+1:print%?optr%=23-A% 3 A%=9:B%=8-(col%+1)8:$(print%+optr%)=B%," ") col%=col%+B%:optr%=optr%+B%  iptr%>=len% optr%>63  usb_Sync 5usb_WrStr("DSD "+optr%+13) : DEVICE SEND DATA &, n%=0 optr%-1:usb_Wr(print%?n%): n% 0ptr%=ptr%+len%: ptr%>=ext% :5usb_WrStr("DSD "+1+13) : DEVICE SEND DATA D1usb_WrStr(12) : FORM FEED N#in%:in%=0:' X b: lClose_All v"in%=in%:in%:A%=in%:in%=0:#A%  : Tgbpb(A%,chn%,addr%,num%,ptr%):?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:&FFD1: : :  > USBLib 1.00 :  USB access routines  =================== +usb_Sync:A%=?usb_D:(?usb_S 128): !usb_Flush:(?usb_S 128): 2'"Flushing USB";::A%=?usb_D:(?usb_S 128) $A%=+20:>A%:(?usb_S 128): Vݤusb_Err:?usb_result%=13 usb_result%?1=":":=0 "USB Error: "$usb_result%:=  1usb_Cmd(A$):usb_WrStr(A$+13):usb_RdStr: (ݤusb_Cmd(A$):usb_Cmd(A$):=usb_Err  #usb_WrStr(A$):debug%:0:129 *O A%=1 A$:(?usb_S 64)=0:?usb_D=A$,A%,1):debug%:c0(A$,A%,1)); 4:debug%:1:128 > H?usb_RdStr:A%=usb_result%-1:A%=A%+1:?A%=usb_Rd:?A%=13: R.usb_Wr(A%):(?usb_S 64)=0:?usb_D=A%: \Eݤusb_Rd:(?usb_S 128)=0:Z%=?usb_D:debug%:c0(Z%);:=Z% =Z% fusb_Init pusb_D=&FCF8:usb_S=&FCF9 z+usb_result%=usb_result%: usb_result%:  usb_result% 63,mc% 99  P=0 1:P%=mc%:[OPT P*2 .usb_RdData 'TAY:LDA #data% 255:STA usb_RdLp+4 *LDA #data% 256:STA usb_RdLp+5:LDX #0 5.usb_RdLp:JSR usb_Rd:STA data%,X:INX:BNE usb_RdLp 'INC usb_RdLp+5:DEY:BNE usb_RdLp:RTS 4.usb_Rd:BIT usb_S:BPL usb_Rd2:BIT &FF:BPL usb_Rd .usb_Rd2:LDA usb_D:RTS .usb_WrData 'TAY:LDA #data% 255:STA usb_WrLp+1 *LDA #data% 256:STA usb_WrLp+2:LDX #0 $.usb_WrLp:LDA data%,X:JSR usb_Wr 0.usb_WrLp2:LDA usb_D:BIT usb_S:BPL usb_WrLp2 INX:BNE usb_WrLp 'INC usb_WrLp+2:DEY:BNE usb_WrLp:RTS $4.usb_Wr:BIT usb_S:BVC usb_Wr2:BIT &FF:BPL usb_Wr ..usb_Wr2:STA usb_D:RTS 8]: B: