home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / graphics / basplot.lbr / RDPLT.BZS / RDPLT.BAS
Encoding:
BASIC Source File  |  1991-06-25  |  5.1 KB  |  68 lines

  1. 1000 GOSUB 1280:PRINT"                               <<<   RDPLT   >>>":PRINT:' cls, display header
  2. 1010 PRINT"Purpose:":PRINT:PRINT"     To plot from a data file which contains HPGL command strings.":PRINT
  3. 1020 PRINT"Method:":PRINT:PRINT"     The data file must be sequential ascii file, records delimited"
  4. 1030 PRINT"     by commas and contain valid HPGL instructions.":PRINT:PRINT:PRINT:INPUT"Press ENTER to continue",A$
  5. 1040 STATP%=133:DATP%=132:CTCP%=137:' Status port, Data port, CTC port - Z80-SIO, STATP%=89, DATP%=88 for the 8251 UART
  6. 1050 GOSUB 1280:M%=22:N%=1:GOSUB 1290:INPUT"The plotter is HP? (Y/N) ",A$:IF A$<>"Y" AND A$<>"N"THEN 1050
  7. 1060 FACIT=1+(A$="Y"):GOSUB 1290:INPUT"Setup the serial port? (Y/N) ",A$:IF A$<>"Y" AND A$<>"N"THEN 1060
  8. 1070 IF A$="Y" THEN GOSUB 1140
  9. 1080 M%=22:N%=1:GOSUB 1290:LINE INPUT"Filename: ",A$:IF A$="" THEN 1110 ELSE 1090:' no checking on validity of filename
  10. 1090 FF$=A$:GOSUB 1290:INPUT"Ready to plot? (Y/N) ",A$:IF A$<>"Y" AND A$<>"N"THEN 1090
  11. 1100 IF A$="Y" THEN GOSUB 1600
  12. 1110 M%=22:N%=1:GOSUB 1290:INPUT"Exit this program? (N) ",A$:IF A$="Y" THEN END ELSE 1000
  13. 1120 '
  14. 1130 ' Suroutine to setup the serial port and set the plotter to xon/xoff handshake
  15. 1140 OUT(STATP%),24:OUT(STATP%),4:OUT(STATP%),68:OUT(CTCP%),71:' channel reset, 16x clock, async, 1 stop, data for CTC
  16. 1150 IF FACIT=0 THEN OUT(CTCP%),16 ELSE OUT(CTCP%),4:' CTC divider, 2400/9600 baud (HP-7225/FACIT)
  17. 1160 OUT(STATP%),3:OUT(STATP%),193:' 8 data, Rx enable, DCD/CTS inactive
  18. 1170 OUT(STATP%),5:OUT(STATP%),104:' 8 data, Tx enable, DTR/RTS inactive
  19. 1180 M%=22:N%=1:GOSUB 1290:INPUT"Include plotter setup commands (N)";A$:IF A$<>"Y" THEN RETURN
  20. 1190 P$=CHR$(27)+".(":GOSUB 1370:' turn plotter on (playing safe, changing paper may turn it off)
  21. 1200 P$=CHR$(27)+".@;0:":GOSUB 1370:' reset the plotter, cancell hardwire h/s (default is hardwire h/s for HP)
  22. 1210 P$=CHR$(27)+".I80;;17:":GOSUB 1370:' set the plotter buffer treshold, set X-on/X-of protocol (X-on char)
  23. 1220 P$=CHR$(27)+".N;19:":GOSUB 1370:' set X-off character (fill buffer if there is a space for 80 bytes)
  24. 1230 IF FACIT=0 THEN P$="IN;DF;IP0,0,11420,8140;VS"+STR$(VS%)+";":GOSUB 1370:RETURN:' init to HP (defaults)
  25. 1240 P$="IN;DF;IP0,0,10880,7640;VS"+STR$(VS%)+";":GOSUB 1370:' init command to FACIT plotter (defaults)
  26. 1250 RETURN:' all nicely in a file - can be coppied later to a plotter with no worries
  27. 1260 '
  28. 1270 ' Subroutines to control the screen (Televideo terminal)
  29. 1280 PRINT CHR$(27)CHR$(43):RETURN:' to clear the whole screen
  30. 1290 GOSUB 1310:PRINT CHR$(27)CHR$(89):GOSUB 1310:RETURN:' clear to the end of screen (foreground)
  31. 1300 GOSUB 1310:PRINT CHR$(27)CHR$(84):GOSUB 1310:RETURN:' to clear line at the cursor address
  32. 1310 PRINT CHR$(27)CHR$(61)CHR$(M%+31)CHR$(N%+31);:RETURN:' for direct cursor address
  33. 1320 '
  34. 1330 ' Subroutine to send a command string to the plotter (set for x-on/x-off handshake protocol)
  35. 1340 ' Comment OUT that part of this subroutine that is not relevant to your system.  The label of the subroutine
  36. 1350 ' is always 1370 and the RETURN statement is at the very end of this subroutine.
  37. 1360 '-----------------------
  38. 1370 ' LPRINT P$:' for those who are using parallel connection or when the system does the handshake
  39. 1380 '-----------------------
  40. 1390 ' The following is for Z80 SIO, status port is 133, data 132. Change to suit to your system.
  41. 1400 FOR L%=1 TO LEN(P$):' start the data send loop
  42. 1410 S%=INP(STATP%):' read RR0, 0 = rec buffer empty, 1 = full
  43. 1420 IF (S% AND 1)=0 THEN 1470:' send char if rec buff empty
  44. 1430 D%=INP(DATP%):' read char from the rec buffer
  45. 1440 IF D%=19 THEN 1430:' it is X-off char, so loop
  46. 1450 IF D%=17 THEN 1470:' it is X-on char, so send another char
  47. 1460 OUT(STATP%),48:GOTO 1410:' reset on all other chars (incl err) and go for more
  48. 1470 IF (S% AND 4)=0 THEN 1410:' transmit buffer not empty, so loop
  49. 1480 OUT(DATP%),ASC(MID$(P$,L%,1)):NEXT:' send a char of the string
  50. 1490 '-----------------------
  51. 1500 ' The following is for the 8251 UART, status port is 89, data 88. Change to suit your system.
  52. 1510 ' IF(INP(STATP%) AND 2)=0 THEN 1530:' is there a Rx char? jump if not
  53. 1520 ' C%=INP(DATP%):IF C%=17 THEN C%=0 ELSE IF C%=19 THEN C%=1:' Rx char into a variable
  54. 1530 ' IF C%<>0 THEN 1510 ELSE 1540:' loop if x-off
  55. 1540 ' FOR L%=1 to LEN(P$):' start sending data
  56. 1550 ' IF(INP(STATP%) AND 1)=0 THEN 1550 ELSE OUT(DATP%),ASC(MID$(P$,L%,1)):NEXT:' loop if buffer full else transmit
  57. 1560 '-----------------------
  58. 1570 RETURN:' return gracefully when all send (the very END of this subroutine)
  59. 1580 '
  60. 1590 '    Subroutine to plot from the SEQUENTIONAL data file (from either default $PLOT.PLT or given data file)
  61. 1600 OPEN"I",#2,FF$:' open sequentional data file for INPUT, set plot-data-file flag
  62. 1610 INPUT#2,Q$:IF MID$(Q$,1,2)="SP" THEN GOSUB 1630:' change pen on HP, no need for FACIT to stop
  63. 1620 P$=Q$:GOSUB 1370:IF EOF(2) THEN 1640 ELSE 1610:' command string to plotter, check if end of file
  64. 1630 INPUT"Change pen, then press ENTER to continue!",A$:P$=CHR$(27)+".(":GOSUB 1370:RETURN:' break, then plotter ON
  65. 1640 CLOSE:RETURN:' close the file, reset flag and return
  66. 1650 '
  67. 1660 END
  68.