c hpplt - filters files from plt and sends to hp-7470 plotter
c
c
c	date of   first   version:  26-Jun-84
c
c
c**********************************************************************
c pnum -
      subroutine pnum(num)
      byte buf(10)
      integer int,size
c calibrated for HP-7475A on 7-Aug-84
      data s/2.625/
      data size/10/
      int=max0(min0(num,4095),0)*s
      k=itoc(int,buf,size)
      call putpl(buf)
      return
      end
c pmove -
      subroutine pmove(ix,iy)
      call putpl('PU')
      call pnum(ix)
      call putpl(',')
      call pnum(iy)
      call putpl(';')
      return
      end
c pdraw -
      subroutine pdraw(ix,iy)
      call putpl('PD')
      call pnum(ix)
      call putpl(',')
      call pnum(iy)
      call putpl(';')
      return
      end
c ppage - new page
      subroutine ppage
      common/hpcom/ipen
      call putpl('SP;')
      type *,'Please change paper and hit return to plot next page.'
      accept 200,k
      call ppen(ipen)
      return
200   format(1a1)
      end
c ppen - change pens
      subroutine ppen(num)
      byte num,str(6)
      integer ipen,pnchng
      common/hpcom/ipen,pnchng
      data str/'S','P','0',';',0,0/
      if(.not.(pnchng.eq.1 .and. ipen.ne.num))goto 23000
         str(3)=num
         call putpl(str)
         ipen=num
23000 continue
      return
      end
c popen
      subroutine popen
      integer ipen,pnchng
      common/hpcom/ipen,pnchng
      byte speed(6)
      data speed/'V','S',4*0/
      pnchng=1
c device control
      open(unit=1,name='PL:')
c output and clear ext. error
      call putesc('.E')
c set handshake mode xon/xoff
      call putesc('.I81;;17:')
c set xoff trigger character
      call putesc('.N;19:')
c hp-gl
c output and clear error
      call putpl('OE;')
c initialize defaults
      call putpl('IN;')
      type 200
      accept 100,k
      if(.not.(k.eq.'Y' .or. k.eq.'y'))goto 23002
         type 202
         accept 102,mmps
         if(.not.(mmps.gt.0))goto 23004
            i=itoc(min0(mmps,40),speed(3),3)
            call putpl(speed)
            call putpl(';')
23004    continue
         type 203
         accept 100,k
         if(.not.(k.eq.'Y' .or. k.eq.'y'))goto 23006
            pnchng=0
23006    continue
23002 continue
      return
100   format(80a1)
101   format(i3)
102   format(i5)
200   format(' Perform pen-plotter initialization (Y/N) ? ',$$ )
202   format(' New pen speed [4 - 40 (cm/s)] ? ', $$ )
203   format(' Inhibit changing of pens (Y/N) ? ', $$ )
      end
c pclose
      subroutine pclose
      call putpl('SP;')
      return
      end
c putpl - send string to plotter
      subroutine putpl(str)
      byte str(1)
      external len
      write(1,200)(str(i),i=1,len(str))
c	type200,(str(i),i=1,len(str))
      return
200   format(1x,80a1)
      end
c putesc - send string to plotter
      subroutine putesc(str)
      byte str(1),esc
      data esc/27/
      external len
      write(1,200)esc,(str(i),i=1,len(str))
      return
200   format(1x,80a1)
      end
