home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nibble Magazine
/
nib42b.dsk
/
SHAPE.BUILDER.bas
< prev
next >
Wrap
BASIC Source File
|
2023-02-26
|
12KB
|
313 lines
10 REM **********************
20 REM * SHAPE BUILDER *
30 REM * BY BILL FORTENBERRY*
40 REM * COPYRIGHT (C) 1992 *
50 REM * BY MINDCRAFT PUBL. *
60 REM * LINCOLN, MA. 01773 *
70 REM **********************
80 LOMEM: 24576
90 TEXT : HOME : PRINT "****************************************": REM 40 *
100 FOR I = 2 TO 12: VTAB I: PRINT "*"; TAB( 40);"*": NEXT
110 VTAB I
120 PRINT "****************************************": REM 40 *
130 INVERSE :A$ = " ": VTAB 3: GOSUB 2420: VTAB 5: GOSUB 2420: REM 15 SPACES
140 VTAB 4: INVERSE :A$ = " SHAPE BUILDER ": GOSUB 2420: NORMAL
150 VTAB 7:A$ = "APPLE II SHAPE TABLE UTILITY": GOSUB 2420
160 VTAB 9:A$ = "BY: BILL FORTENBERRY": GOSUB 2420
170 A$ = "(C) 1992 BY MINDCRAFT PUBL.": VTAB 11: GOSUB 2420
180 POKE 34,13
190 REM MENU
200 VTAB 15: HTAB 1: PRINT "WOULD YOU LIKE TO": PRINT : PRINT " 1. BUILD A SHAPE TABLE": PRINT " 2. CALCULATE POKE VALUES"
210 PRINT : INPUT "TYPE THE NUMBER (1-2) OF YOUR CHOICE =->";A$
220 IF A$ = "" THEN 200
230 A = VAL(A$)
240 IF A <1 OR A >2 THEN 200
250 HOME
270 IF A = 2 THEN 2430
280 REM GATHER DATA
290 VTAB 17: INPUT "HOW MANY SHAPES IN THIS TABLE ";SN$
300 IF SN$ = "" THEN 290
310 SN = VAL(SN$)
320 IF SN <0 THEN 290
330 SS = 10300
340 REM POKE SHAPE LOCATION
350 POKE 232,SS - INT(SS/256) *256
360 POKE 233, INT(SS/256)
370 DIM G(1445),SD(SN +2)
380 SD(1) = SS +2 +SN *2
390 GR : POKE 34,20
400 REM LOOP FOR # OF SHAPES
410 FOR SC = 1 TO SN
420 QQ = FRE(0)
430 GR : HOME : POKE 34,20: HOME
440 HOME : PRINT "SHAPE #";SC: PRINT "T)URTLE OR L)INE MODE (T/L)";: GET A$: IF A$ = "T" THEN 2620
450 COLOR= 1:F = 0
460 HOME : PRINT TAB( 33)"PLOT": POKE 33,30
470 REM HLIN MODE
480 HOME : PRINT "HLIN FROM ";: INPUT "";A$
490 IF A$ = "" THEN 480
500 IF A$ = "V" THEN HOME : GOTO 730
510 IF A$ = "F" THEN 980
520 IF A$ = "P" THEN 2330
530 IF A$ = "E" THEN 2370
540 IF A$ = "Q" THEN 1190
550 IF A$ = "?" THEN 2980
560 PRINT "TO ";: INPUT "";B$
570 IF B$ = "" THEN 560
580 IF B$ = "?" THEN 2980
590 B = VAL(B$)
600 IF B >38 THEN B = 38
610 IF B <1 THEN B = 1
620 PRINT "ON ";: INPUT "";C$
630 IF C$ = "?" THEN 2980
640 IF C$ = "" THEN 620
650 C = VAL(C$)
660 IF C >38 THEN C = 38
670 IF C <1 THEN C = 1
680 A = VAL(A$)
690 IF A <1 THEN A = 1
700 IF A >38 THEN A = 38
710 HLIN A,B AT C: PRINT : HOME : GOTO 480
720 REM VLIN MODE
730 INPUT "VLIN FROM ";A$
740 IF A$ = "" THEN 730
750 IF A$ = "H" THEN HOME : GOTO 480
760 IF A$ = "F" THEN 980
770 IF A$ = "P" THEN 2330
780 IF A$ = "E" THEN 2370
790 IF A$ = "Q" THEN 1190
800 IF A$ = "?" THEN 2980
810 INPUT "TO ";B$
820 IF B$ = "?" THEN 2980
830 IF B$ = "" THEN 810
840 B = VAL(B$)
850 IF B >38 THEN B = 38
860 IF B <1 THEN B = 1
870 INPUT "AT ";C$
880 IF C$ = "?" THEN 2980
890 IF C$ = "" THEN 870
900 C = VAL(C$)
910 IF C >38 THEN C = 38
920 IF C <1 THEN C = 1
930 A = VAL(A$)
940 IF A <1 THEN A = 1
950 IF A >38 THEN A = 38
960 VLIN A,B AT C: PRINT : HOME : GOTO 730
970 REM FREE CURSOR MODE
980 X = 20:Y = 20
990 ZC = SCRN( X,Y): COLOR= 15: PLOT X,Y
1000 POKE 33,40
1010 HOME : PRINT "X=";X;" Y=";Y
1020 GET A$
1030 IF A$ = "Q" THEN COLOR= ZC: PLOT X,Y: GOTO 2330
1040 IF A$ = "P" THEN ZC = 1: GOTO 1020
1050 IF A$ = "E" THEN ZC = 0: GOTO 1020
1060 IF A$ = "?" THEN 3040
1070 XX = X:YY = Y
1080 IF A$ = "I" AND Y >1 THEN YY = Y -1: GOTO 1130
1090 IF A$ = "M" AND Y <38 THEN YY = Y +1: GOTO 1130
1100 IF A$ = "J" AND X >1 THEN XX = X -1: GOTO 1130
1110 IF A$ = "K" AND X <38 THEN XX = X +1: GOTO 1130
1120 GOTO 1020
1130 CZ = SCRN( XX,YY)
1140 COLOR= 15: PLOT XX,YY: COLOR= ZC: PLOT X,Y:X = XX:Y = YY
1150 ZC = CZ
1160 HOME : PRINT "X=";X;" Y=";Y
1170 GOTO 1020
1180 REM BOX IN SHAPE
1190 L = 0:Z = 0
1200 POKE 33,40: HOME
1210 PRINT "LOCATING SHAPE EDGES"
1220 FOR D = 1 TO 39: IF SCRN( L +1,D) = 1 THEN Z = 1
1230 NEXT
1240 IF Z = 0 THEN L = L +1: GOTO 1220
1250 J = 39:Z = 0
1260 FOR D = 1 TO 39: IF SCRN( J -1,D) = 1 THEN Z = 1
1270 NEXT
1280 IF Z = 0 THEN J = J -1: GOTO 1260
1290 Z = 0:K = 39
1300 FOR D = 1 TO 39: IF SCRN( D,K -1) = 1 THEN Z = 1
1310 NEXT
1320 IF Z = 0 THEN K = K -1: GOTO 1300
1330 Z = 0:I = 0
1340 FOR D = 1 TO 39: IF SCRN( D,I +1) = 1 THEN Z = 1
1350 NEXT
1360 IF Z = 0 THEN I = I +1: GOTO 1340
1370 REM CODE SHAPE
1380 Z = 1:D = 1:X = L:Y = I +1
1390 PRINT "CODING PLOT VECTORS"
1400 X = X +1:SX = X:SY = Y: IF SCRN( X,Y) = 0 THEN 1400
1410 BX = X:BY = Y
1420 GOTO 1440
1430 X = X +D
1440 IF D = 1 AND X = J -1 AND SCRN( X,Y) = 1 THEN G(Z) = 6:Y = Y +1:D = -D:Z = Z +1: GOTO 1490
1450 IF D = 1 AND X = J -1 AND SCRN( X,Y) = 0 THEN G(Z) = 2:Y = Y +1:D = -D:Z = Z +1: GOTO 1490
1460 IF D = -1 AND X = L +1 AND SCRN( X,Y) = 0 THEN G(Z) = 2:Y = Y +1:D = -D:Z = Z +1: GOTO 1490
1470 IF D = -1 AND X = L +1 AND SCRN( X,Y) = 1 THEN G(Z) = 6:Y = Y +1:D = -D:Z = Z +1: GOTO 1490
1480 GOTO 1580
1490 IF Y > = K THEN 1630
1500 F = 0
1510 FOR B = L TO J
1520 IF SCRN( B,Y) = 1 THEN F = 1
1530 NEXT B
1540 IF F = 0 THEN G(Z) = 2:Y = Y +1:Z = Z +1: GOTO 1490
1550 F = 0
1560 IF Y > = K THEN 1630
1570 GOTO 1440
1580 IF SCRN( X,Y) = 1 AND D = 1 THEN G(Z) = 5:Z = Z +1
1590 IF SCRN( X,Y) = 1 AND D = -1 THEN G(Z) = 7:Z = Z +1
1600 IF SCRN( X,Y) = 0 AND D = 1 THEN G(Z) = 1:Z = Z +1
1610 IF SCRN( X,Y) = 0 AND D = -1 THEN G(Z) = 3:Z = Z +1
1620 GOTO 1430
1630 G(Z) = 10
1640 REM POKE SHAPE
1650 A = SD(SC)
1660 T = A
1670 Z = 0
1680 PRINT "POKING SHAPE DEFINITION"
1690 Z = Z +1
1700 IF G(Z) = 10 THEN 1790
1710 K = G(Z):Z = Z +1
1720 IF G(Z) = 10 THEN 1780
1730 K = K +G(Z) *8:Z = Z +1
1740 IF G(Z) = 10 THEN 1780
1750 IF G(Z) <4 AND G(Z) >0 THEN K = K +G(Z) *64:Z = Z +1
1760 Z = Z -1
1770 POKE A,K:A = A +1: GOTO 1690
1780 POKE A,K:A = A +1
1790 POKE A,0
1800 PRINT CHR$(7)
1810 COLOR= 15: PLOT SX,SY
1820 HOME : PRINT "THIS DEFINITION STARTS ON THE WHITE DOT."
1830 VTAB 24: INPUT "PRESS RETURN TO PLOT SHAPE ";A$
1840 REM DRAW SHAPE
1850 HOME
1860 INPUT "SCALE = ";G$:G = VAL(G$): IF G <1 THEN 1860
1870 SCALE= G: INPUT "ROT = ";G$:G = VAL(G$): ROT= G
1880 HOME : PRINT "G)REEN P)URPLE O)RANGE B)LUE W)HITE": PRINT : PRINT "ENTER FIRST LETTER OF COLOR ";: GET A$: PRINT A$
1890 IF A$ < >"G" AND A$ < >"P" AND A$ < >"O" AND A$ < >"B" AND A$ < >"W" THEN 1880
1900 REM POKE THE DIRECTORY
1910 POKE SS,SN: POKE SS +1,0
1920 X = SS +1
1930 FOR I = 1 TO SC
1940 B = SD(I) -SS
1950 X = X +1:TA = INT(B/256)
1960 POKE X,B -TA *256
1970 X = X +1: POKE X,TA
1980 NEXT I
1990 REM EDIT THE SHAPE
2000 IF A$ = "W" THEN HCOLOR= 3
2010 IF A$ = "G" THEN HCOLOR= 1
2020 IF A$ = "O" THEN HCOLOR= 5
2030 IF A$ = "P" THEN HCOLOR= 2
2040 IF A$ = "B" THEN HCOLOR= 6
2050 HGR2 : DRAW SC AT 140,40
2060 INPUT A$: POKE -16298,0: POKE -16300,0: POKE -16301,0
2070 SD(SC +1) = A +1
2080 IF TM = 0 THEN COLOR= 1: PLOT BX,BY
2090 HOME
2100 PRINT "DRAW THIS SHAPE AGAIN (Y/N) ";: GET A$: IF A$ = "" THEN 2090
2110 IF A$ = "Y" THEN 1850
2120 HOME
2130 PRINT "EDIT THIS SHAPE (Y/N) ";: GET A$: IF A$ = "" THEN 2130
2140 IF A$ = "Y" AND TM = 1 THEN 2620
2150 IF A$ = "Y" THEN 450
2160 IF TM = 1 THEN 2200
2170 HOME : PRINT "USE THIS SHAPE AS A BASE FOR ANOTHER ";: GET A$
2180 IF A$ = "Y" AND SC <SN THEN SC = SC +1: GOTO 450
2190 REM NEXT SHAPE
2200 NEXT SC
2210 REM TABLE DATA
2220 TEXT
2230 HOME : PRINT " SHAPE TABLE DATA"
2240 PRINT : PRINT : PRINT "SHAPE TABLE STARTS AT ";SS
2250 PRINT : PRINT "AND ENDS AT ";SD(SC)
2260 PRINT : PRINT "TABLE LENGTH IS ";SD(SC) -SS +1
2270 REM SHAPE LOCATION
2280 PRINT : PRINT "SAVE SHAPE WITH THIS COMMAND -"
2290 PRINT
2300 PRINT "BSAVE ";: INVERSE : PRINT "FILE NAME";: NORMAL : PRINT ",A";SS;",L";SD(SC) -SS +1
2310 END
2320 REM PLOT & ERASE SUBS
2330 POKE 33,40: HOME :
2340 PRINT TAB( 33)"PLOT": POKE 33,30
2350 COLOR= 1
2360 HOME : GOTO 480
2370 POKE 33,40: HOME
2380 PRINT TAB( 33)"ERASE": POKE 33,30
2390 COLOR= 0
2400 HOME : GOTO 480
2410 REM CENTER SUB
2420 HTAB 21 - LEN(A$)/2: PRINT A$: RETURN
2430 REM POKE CALCS
2440 VTAB 19: PRINT "START HEX NUMBERS WITH A '$'"
2450 VTAB 17: INPUT "WHERE WILL YOU PUT THE TABLE ";X$
2460 Y = VAL(X$)
2470 IF LEFT$(X$,1) = "$" THEN X$ = RIGHT$(X$, LEN(X$) -1): GOSUB 2540
2480 X = Y - INT(Y/256) *256:Z = INT(Y/256)
2490 HOME : PRINT "USE THESE POKES IN YOUR PROGRAM BEFORE YOU DRAW YOUR FIRST SHAPE"
2500 PRINT : PRINT "POKE 232,";X: PRINT "POKE 233,";Z
2510 PRINT
2520 END
2530 REM HEX CONVERTER
2540 Y = 0:Z = 0
2550 FOR I = LEN(X$) -1 TO 0 STEP -1
2560 Z = Z +1
2570 Y1 = ASC( MID$ (X$,Z,1)) -48
2580 IF Y1 >16 THEN Y1 = Y1 -7
2590 Y = Y +Y1 *16 ^I
2600 NEXT
2610 RETURN
2620 REM TURTLE MODE
2630 GR : POKE 34,20: HOME : PRINT "MOVE DOT TO START & PRESS 'P'": POKE 34,21
2640 Z = 1:X = 20:Y = X:XX = Y:YY = Y:TM = 1
2650 COLOR= 0: PLOT XX,YY: COLOR= 15: PLOT X,Y:XX = X:YY = Y: HOME : PRINT "X=";X;" Y=";Y: GET A$
2660 IF A$ = "P" THEN SX = X:SY = Y: GOTO 2720
2670 IF A$ = "I" AND Y >0 THEN Y = Y -1
2680 IF A$ = "M" AND Y <39 THEN Y = Y +1
2690 IF A$ = "K" AND X <39 THEN X = X +1
2700 IF A$ = "J" AND X >0 THEN X = X -1
2710 GOTO 2650
2720 P = 1:ZC = 0: POKE 34,20
2730 XX = X:YY = Y: HOME : PRINT "X=";X;" Y=";Y
2740 IF P = 1 THEN INVERSE : PRINT "PLOT ON": NORMAL : GOTO 2760
2750 PRINT "PLOT OFF"
2760 GET A$
2770 IF A$ = "M" AND Y <39 THEN G(Z) = 2:Z = Z +1:F = 0:Y = Y +1: GOTO 2870
2780 IF A$ = "J" AND X >0 THEN G(Z) = 3:Z = Z +1:F = 0:X = X -1: GOTO 2870
2790 IF A$ = "K" AND X <39 THEN G(Z) = 1:Z = Z +1:F = 0:X = X +1: GOTO 2870
2800 IF A$ = "I" AND Y >0 AND (F = 0 OR P = 1) THEN G(Z) = 0:F = 1:Z = Z +1:Y = Y -1: GOTO 2870
2810 IF A$ = "?" THEN 3110
2820 IF A$ = "E" THEN P = 0: GOTO 2730
2830 IF A$ = "P" THEN P = 1: GOTO 2730
2840 IF A$ = "Q" THEN G(Z) = 10: COLOR= ZC: PLOT X,Y: GOTO 1650
2850 IF A$ = CHR$(27) THEN 2900: REM ESC KEY
2860 GOTO 2730
2870 CZ = SCRN( X,Y): COLOR= ZC: PLOT XX,YY: COLOR= 15: PLOT X,Y:ZC = CZ
2880 IF P = 1 THEN G(Z -1) = G(Z -1) +4: COLOR= 1: PLOT XX,YY
2890 GOTO 2730
2900 IF Z >0 THEN Z = Z -1
2910 IF Z < = 0 THEN 2730
2920 ON G(Z) +1 GOSUB 2940,2950,2960,2970,2940,2950,2960,2970
2930 COLOR= 15: PLOT X,Y: COLOR= 0: PLOT XX,YY: GOTO 2730
2940 Y = Y +1: RETURN
2950 X = X -1: RETURN
2960 Y = Y -1: RETURN
2970 X = X +1: RETURN
2980 REM LINE MODE HELP
2990 POKE 33,40: HOME
3000 PRINT "V-> DRAW VERTICAL LINES": PRINT "H-> DRAW HORIZONTAL LINES": PRINT "F-> ENTER FREE CURSOR MODE": INPUT "PRESS RETURN";A$: HOME
3010 PRINT "DRAW LINES BY GIVING THE ENDPOINTS AND": PRINT "LEVEL TO DRAW ON": INPUT "PRESS RETURN";A$: HOME
3020 PRINT "P-> TURNS PLOT ON (DRAW LINES)": PRINT "E-> TURNS PLOT OFF (ERASE LINES)": INPUT "PRESS RETURN";A$: HOME
3030 PRINT "Q-> QUIT DRAWING AND CODE THE SHAPE": INPUT "PRESS RETURN";A$: HOME : GOTO 2330
3040 REM FREE CUR HELP
3050 HOME
3060 PRINT "I,J,K,M KEYS MOVE THE CURSOR": PRINT "P-> PLOT A POINT": PRINT "E-> ERASE A POINT": INPUT "PRESS RETURN";A$
3070 HOME
3080 PRINT "P & E ONLY EFFECT THE POINT THE CURSOR": PRINT "IS RESTING ON, NO OTHERS!": INPUT "PRESS RETURN";A$: HOME
3090 PRINT "Q-> RETURNS YOU TO THE HLIN MODE WITH": PRINT " PLOT ON": INPUT "PRESS RETURN";A$: HOME
3100 GOTO 1000
3110 REM TURTLE MODE HELP
3120 HOME : PRINT "I,J,K,M KEYS MOVE THE CURSOR": PRINT "P-> TURN PLOTTING ON": PRINT "E-> TURN PLOTTING OFF": INPUT "PRESS RETURN";A$: HOME
3130 PRINT "THE ESC KEY WILL ALLOW YOU TO 'BACK UP'": PRINT "AND ERASE ERRORS": INPUT "PRESS RETURN";A$: HOME
3140 PRINT "Q-> QUIT DRAWING AND CODE THE SHAPE": INPUT "PRESS RETURN";A$: HOME : GOTO 2730