8999 STOP
9000 REM Plotter driver for TRS-80 
9010 REM Color Graphic Printer CGP-115
9020 REM by Carl Tenning, September 1985
9030 REM
9040 REM	User program sets values for
9050 REM	X=horiz coordinate and
9060 REM	Y=vert coordinate followed
9070 REM	by a GOSUB 9000. End plot by
9080 REM	doing GOSUB 9000 without
9090 REM	changing X or Y. Options:
9100 REM	Pen color set COLOR%=n (0-3)
9110 REM	Dash line set DASH%=n (0-15)
9120 REM        Raise pen set PENUP%=1
9130 REM
9140 REM
9150 IF INIT%=0 THEN 9190
9160 IF COLOR%>=0 THEN LPRINT "C"; COLOR%
9170 IF DASH%>=0 THEN LPRINT "L"; DASH%
9180 GOTO 9500
9190 REM initialize
9200 INIT%=-1
9210 PENUP%=-1
9220 LASTX=X-1
9230 LASTY=Y-1
9240 IF XMIN < XMAX AND YMIN < YMAX THEN 9310
9250 PRINT "Remember to initialize grid limits"
9260 PRINT
9270 INPUT "X min=";XMIN
9280 INPUT "X max=";XMAX
9290 INPUT "Y min=";YMIN
9300 INPUT "Y max=";YMAX
9310 LPRINT CHR$(18)
9320 LPRINT "M0,-400"
9330 LPRINT "I"
9340 LPRINT "L0"
9350 PXMIN%=0:PXMAX%=480
9360 PYMIN%=0:PYMAX%=400
9370 DEF FNDRAW$(X%,Y%)="D"+STR$(X%)+","+STR$(Y%)
9375 DEF FNMOVE$(X%,Y%)="M"+STR$(X%)+","+STR$(Y%)
9380 LPRINT FNDRAW$(PXMIN%,PYMAX%)
9390 LPRINT FNDRAW$(PXMAX%,PYMAX%)
9400 LPRINT FNDRAW$(PXMAX%,PYMIN%)
9410 LPRINT FNDRAW$(PXMIN%,PYMIN%)
9420 PXRAN%=PXMAX%-PXMIN%
9430 PYRAN%=PYMAX%-PYMIN%
9440 XRAN=XMAX-XMIN
9450 YRAN=YMAX-YMIN
9460 IF DASH%>0 THEN LPRINT "L"; DASH%
9470 DASH%=-1
9480 IF COLOR%>0 AND COLOR%<4 THEN LPRINT "C"; COLOR%
9490 COLOR%=-1
9500 REM plot
9510 IF X<>LASTX OR Y<>LASTY THEN 9570
9520 LPRINT "H"
9530 LPRINT "L0"
9535 LPRINT "S1"
9540 LPRINT "A"
9550 INIT%=0
9560 RETURN
9570 REM calculate plot
9580 XPLOT%=INT(PXRAN%*(X-XMIN)/XRAN+.5)
9590 YPLOT%=INT(PYRAN%*(Y-YMIN)/YRAN+.5)
9600 IF XPLOT%<PXMIN% OR XPLOT%>PXMAX% THEN PENUP%=-1 : GOTO 9670
9610 IF YPLOT%<-999 OR YPLOT%>PYMAX% THEN PENUP%=-1 : GOTO 9670
9620 IF PENUP% THEN 9650
9630 LPRINT FNDRAW$(XPLOT%,YPLOT%)
9640 GOTO 9670
9650 LPRINT FNMOVE$(XPLOT%,YPLOT%)
9660 PENUP%=0
9670 LASTX=X
9680 LASTY=Y
9690 RETURN
W$(XPLOT%,YPLOT%)
9640 GOTO 9670
9650 LPRINT FNMOVE$(XPLOT%,YPLOT%)
9660 PENUP%=0
9670 L