Compucolor.org – Virtual Media

Listing of file='DRAW.BAS;01' on disk='vmedia/mixed-sector.ccvf'

100 REM  "DRAW.BAS"
120 REM  DRAW PICTURES ON EPSON FX-85 PRINTER VIA PRIMITIVES.
160 REM  FOR INSTRUCTIONS SEE DRAWI.BAS.
180 REM  WALLACE R. RUST, JAN 1987
200 REM
220 REM  --- HOUSEKEEPING
240 CLEAR 70:GOSUB 3400
260 REM  PICTURE IS 512 BY 384 DOTS; 72 DOTS/INCH; 24576 BYTES.
280 R$= "X RANGES FROM 0 TO 511; Y RANGES FROM 0 TO 383."
300 KA= 40700:REM  1ST ADDR OF PIC RAM
320 KH= 512:REM  HORIZ PIC SIZE IN BYTES
340 KV= 48:REM  VERT PIC SIZE IN BYTES
360 KD= 8:REM  VERT DOTS/BYTE
380 KZ= 65275:REM  LAST ADDR OF PIC RAM = KA+KH*KV-1
400 N2= INT (KH/ 256):N1= KH- N2* 256
420 KP= 0:REM  ADDR OF PIXEL X,Y
440 KW= 0:REM  PIXEL BIT WT (1 2 4...128)
460 KR= 0:REM  PIC ROW NO.
480 M$= "DRAW"
500 KC= .5:REM  FOR ROUNDING
520 REM  --- BAUD RATE
540 PLOT 6,3,15,12
560 INPUT "ENTER PRINTER BAUD RATE CODE (1 TO 7): ";BR
580 IF BR< 1OR BR> 7THEN 560
600 REM  --- USER MENU
620 PLOT 6,2,15,12
640 PRINT "PROGRAM TO DRAW PICTURES ON AN EPSON FX-85 PRINTER."
660 PRINT "MAXIMUM RUN TIMES IN MIN:SEC.  DO CHOICE 1 OR 2 FIRST."
680 PRINT :PLOT 6,6:PRINT "MEMORY OPERATIONS:"
700 PRINT :PLOT 6,3
720 PRINT " 1. ERASE PIC FROM MEMORY 0:01"
740 PRINT " 2. ERASE MEMORY & LOAD PIC FROM DISK TO MEMORY 0:13"
760 PRINT " 3. SAVE PIC TO DISK 0:25"
780 PRINT " 4. PRINT PIC ON PRINTER 4:00"
800 PRINT " 5."
820 PRINT " 6. END THE PROGRAM"
840 PRINT :PLOT 6,6:PRINT "CREATE PIC OPERATIONS: ";
845 A= 68:IF M$= "ERASE"THEN A= 69
850 PLOT 6,A:PRINT "(NOW IN ";M$;" MODE)"
860 PRINT :PLOT 6,3
880 PRINT " 7. DRAW FRAME AROUND PIC 3:05"
900 PRINT " 8. DRAW STRAIGHT LINE 1:00"
920 PRINT " 9. PLOT A POINT 0:01"
940 PRINT "10. DRAW ALL OR HALF OF A CIRCLE OR ELLIPSE 3:20"
960 PRINT "11. DRAW RECTANGLE 3:05"
965 PRINT "12. ENTER DRAW MODE"
970 PRINT "13. ENTER ERASE MODE"
1000 FOR J= 22TO 31:PLOT 3,0,J,11:NEXT J:PLOT 6,1,3,0,22
1020 INPUT "YOUR CHOICE (1 TO 13): ";MC
1040 IF MC< 1OR MC> 13THEN 1000
1060 ON MCGOTO 1780,1600,1420,1200,1000,1100,2080,2120
1080 ON MC- 8GOTO 2540,2660,3040,3600,3620
1100 PLOT 6,3:END
1120 REM  --- SUBR TO STORE PIXEL IN RAM
1140 Y= INT (Y+ KC):KR= INT (Y/ KD):KP= KA+ KH* KR+ INT (X+ KC)
1160 IF KP< KAOR KP> KZTHEN RETURN
1170 KW= 2^ (Y- KD* KR)
1180 IF M$= "DRAW"THEN POKE KP,PEEK (KP)OR KW:RETURN
1190 POKE KP,PEEK (KP)AND NOT KW:RETURN
1200 REM  --- PRINT PIC
1220 GOSUB 3320
1240 REM  SELECT PRINTER; INIT; 8/72" LINE SPACING; ERASE BUFFER
1260 POKE 33289,80:PLOT 15,27,18,BR,27,13:OUT 8,4
1280 PLOT 27,64,27,65,8,24
1300 FOR LINE= KV- 1TO 0STEP - 1
1320 SA= KA+ LINE* KH:PLOT 27,42,5,N1,N2
1340 FOR J= 0TO KH- 1:PLOT PEEK (SA+ J):NEXT J
1360 PRINT :NEXT LINE
1380 PLOT 27,64:OUT 8,255:POKE 33265,0:POKE 33289,64
1400 GOTO 600
1420 REM  --- SAVE PIC TO DISK
1440 PLOT 6,3,15,12
1460 PRINT "DISK TO RECEIVE PICTURE MUST HAVE AT LEAST"
1480 PRINT "C0 (HEX) BYTES OF FREE SPACE."
1500 PRINT :GOSUB 1840
1520 ON QGOTO 1540,1440,600
1540 PRINT :GOSUB 3320
1560 PLOT 27,4:PRINT "SAVE EPSON.PIC 9EFC-FEFB":PLOT 27,27
1580 GOTO 600
1600 REM  --- LOAD PIC FROM DISK
1620 PLOT 6,3,15,12
1640 PRINT "SOURCE DISK MUST HAVE AN EPSON.PIC FILE."
1660 PRINT :GOSUB 1840
1680 ON QGOTO 1700,1620,600
1700 INPUT "WHICH VERSION (VR) NO.? ";Q$
1720 PRINT :GOSUB 3320
1740 PLOT 27,4:PRINT "LOAD EPSON.PIC;"Q$:PLOT 27,27
1760 GOTO 600
1780 REM  --- ERASE PIC FROM RAM
1800 Y= CALL (0):GOTO 600
1840 REM  --- SUBR DISP DISK DIR
1860 PRINT "INSERT DISK YOU PLAN TO USE AND PRESS <RETURN>"
1880 INPUT "TO SEE DIRECTORY. ";Q$
1900 PLOT 27,4:PRINT "DIR":PLOT 27,27
1920 PRINT
1940 PRINT "CHOICES:"
1960 PRINT "  1. USE THIS DISK"
1980 PRINT "  2. TRY ANOTHER DISK"
2000 PRINT "  3. GO BACK TO MENU"
2020 PRINT
2040 INPUT "YOUR CHOICE (1,2,3): ";Q
2060 RETURN
2080 REM  --- FRAME
2100 X0= 0:Y0= 0:X1= 511:Y1= 383:GOTO 3180
2120 REM  --- LINE
2140 PLOT 6,2
2160 PRINT "SPECIFY ENDPOINTS OF LINE (X0,Y0) AND (X1,Y1)."
2180 PRINT R$:PRINT
2200 PLOT 6,1:INPUT "ENTER X0,Y0,X1,Y1: ";X0,Y0,X1,Y1
2220 GOSUB 3320
2240 DX= X1- X0:DY= Y1- Y0:SX= SGN (DX):SY= SGN (DY)
2260 IF DX= 0AND DY= 0THEN 600
2280 IF DX= 0THEN 2400
2300 IF DY= 0THEN 2440
2320 IF ABS (DY/ DX)< 1THEN 2480
2340 REM  STEP BY Y
2360 A= DX/ DY:B= X1- A* Y1
2380 FOR Y= Y0TO Y1STEP SY:X= A* Y+ B:GOSUB 1140:NEXT :GOTO 600
2400 REM  VERT LINE
2420 X= X0:FOR Y= Y0TO Y1STEP SY:GOSUB 1140:NEXT :GOTO 600
2440 REM  HORIZ LINE
2460 Y= Y0:FOR X= X0TO X1STEP SX:GOSUB 1140:NEXT :GOTO 600
2480 REM  STEP BY X
2500 A= DY/ DX:B= Y1- A* X1
2520 FOR X= X0TO X1STEP SX:Y= A* X+ B:GOSUB 1140:NEXT :GOTO 600
2540 REM  --- POINT
2560 PLOT 6,2
2580 PRINT "SPECIFY COORDINATES (X,Y) OF THE POINT."
2600 PRINT R$:PRINT
2620 PLOT 6,1:INPUT "ENTER X,Y: ";X,Y
2640 GOSUB 1140:GOTO 600
2660 REM  --- CIRCLE, ELLIPSE
2680 PLOT 6,2
2700 PRINT "DO YOU WANT ALL OF THE FIGURE, OR JUST THE TOP OR"
2720 INPUT "BOTTOM HALF? (A,T,B): ";Q$
2740 PLOT 6,3:PRINT R$:PLOT 6,2
2760 INPUT "SPECIFY CENTER (X,Y): ";XC,YC
2780 INPUT "SPECIFY X-RADIUS AND Y-RADIUS (RX,RY): ";RX,RY
2800 GOSUB 3320
2820 X2= RX* RX:Y2= RY* RY
2840 A= X2/ SQR (X2+ Y2):B= Y2/ SQR (X2+ Y2):REM  SLOPE=1 AT (A,B)
2860 FOR J= - ATO A:K= SQR (Y2* (1- J* J/ X2)):X= XC+ J
2880 IF Q$< > "B"THEN Y= YC+ K:GOSUB 1140
2900 IF Q$< > "T"THEN Y= YC- K:GOSUB 1140
2920 NEXT J
2940 K1= - B:K2= B:IF Q$= "T"THEN K1= 0
2960 IF Q$= "B"THEN K2= 0
2980 FOR K= K1TO K2:J= SQR (X2* (1- K* K/ Y2))
3000 Y= YC+ K:X= XC+ J:GOSUB 1140:X= XC- J:GOSUB 1140:NEXT K
3020 GOTO 600
3040 REM  --- RECTANGLE
3060 PLOT 6,2
3080 PRINT "SPECIFY LOWER LEFT CORNER (X0,Y0) AND"
3100 PRINT "UPPER RIGHT CORNER (X1,Y1) OF THE RECTANGLE."
3120 PRINT R$:PRINT
3140 PLOT 6,1:INPUT "ENTER X0,Y0,X1,Y1: ";X0,Y0,X1,Y1
3160 IF X0> = X1OR Y0> = Y1THEN 3140
3180 REM  ENTER HERE FOR FRAME
3200 GOSUB 3320
3220 Y= Y0:FOR X= X0TO X1:GOSUB 1140:NEXT
3240 Y= Y1:FOR X= X0TO X1:GOSUB 1140:NEXT
3260 X= X0:FOR Y= Y0TO Y1:GOSUB 1140:NEXT
3280 X= X1:FOR Y= Y0TO Y1:GOSUB 1140:NEXT
3300 GOTO 600
3320 REM  --- "WAIT"
3340 PLOT 6,6:PRINT "WAIT...":RETURN
3400 REM  --- LOAD ERASE-RAM PGM
3420 POKE 33283,230:POKE 33284,158:REM  JUMP TO 40678
3440 DATA 235,33,252,158,62,192,6,128,54,0
3460 DATA 35,5,194,238,158,61,194,236,158,235,201
3480 RESTORE 3440:FOR A= 40678TO 40698:READ X:POKE A,X:NEXT A
3500 RETURN
3580 REM  --- DRAW/ERASE
3600 M$= "DRAW":GOTO 600
3620 M$= "ERASE":GOTO 600