Generally SYNC prefers articles in some depth to help you get more out of your computer. However, we receive many short programs that illustrate a point, demonstrate a technique, or show something the reader has found interesting. “Just for Fun” shares these programs with you. If you learn something, great. If you have some fun, great. If you have some that you want to share, send them to: Just for Fun, SYNC, 39 E. Hanover Ave., Morris Plains, NJ 07950.
Four Quadrants
Tuan Ton
After plotting a few functions on the ZX81, I found that it could plot only on the first quadrant of a plane. So I developed this program which graphs an input function on all four quadrants.
Type in the program, press RUN and ENTER.
After the axes are drawn, enter your formulas in response to the L cursor in “slope and Y-intercept” form. For example, SQR Y – X = 0 must be changed to y = x * x and enter the “X*X” leaving out the y. Try entering: X*X; -4*X; 2**X; -2*X.
[Figure: Screen display of the graph of -2*X on four quadrants]
Lines 10-40 draw two axes (x-axis, y-axis); this gives a full sized plane (four quadrants) with the origin in the middle of the screen instead of in the bottom-left corner. The origin can be moved by changing the constant in lines 20 and 30.
Line 70 automatically sets your X value for the most fitting value for Y that can be plotted.
1 FAST
10 FOR X=0 TO 43
20 PLOT 21,X
30 PLOT X,21
40 NEXT X
50 INPUT F$
60 FOR X=-21 TO 21
70 IF VAL F$+21>42 OR VAL F$+21<0 THEN GOTO 90
80 PLOT X+21,VAL F$+21
90 NEXT X
100 PRINT AT 1,23;F$
Hi-Res “Draw It”
John Herriott
Using the program “Draw It” by Robert Boynton (SYNC 2:4) as a basis, the program below allows for relatively fine detail drawing using the Hi Res Graphics Board made by Memotech. The resolution provided by this board is 248 (X) by 192 (Y) dots.
The first seven lines are in Basic and allow for the setting of the starting point of the drawing. The ZX81 keys 5 to 8 are used to draw the lines (without SHIFT). 0 is used to erase and can be used also to move to a new spot on the screen. It would be wise to make the spot appear from time to time (by pressing 0 a second time) otherwise you will lose track of it.
STARCH is a composite command provided by the Memotech board. PLOT and UNPLOT are similar to the ZX81 statements.
The resultant work of art can be passed into a long string which can then be saved on tape.
Readers might find the process of drawing a lot easier if the “keys” are operated with the eraser end of the pencil. Pressure is positive and response immediate—not always the case with fingers on the ZX81 keyboard!
5 REM "DRAW"
9680 PRINT "INPUT X. (MAX. 247)"
9682 INPUT X
9684 CLS
9685 PRINT "INPUT Y. (MAX. 192)"
9687 INPUT Y
9689 CLS
9700 LET V=40000 (19000 for 16K)
9710 LET Z$="STARCH"
9712 GOSUB 9990
9720 LET X=X
9722 LET Y=Y
9723 LET Z=0
9730 LET Z$="PLOT"
9735 GOSUB 9990
9740 IF INKEY$="5" THEN LET X=X-1
9742 IF INKEY$="8" THEN LET X=X+1
9745 IF INKEY$="6" THEN LET Y=Y-1
9747 IF INKEY$="7" THEN LET Y=Y+1
9750 IF INKEY$="0" THEN GOTO 9770
9755 GOSUB 9990
9760 GOTO 9730
9770 LET Z$="UNPLOT"
9775 GOSUB 9990
9780 IF INKEY$="5" THEN LET X=X-1
9782 IF INKEY$="8" THEN LET X=X+1
9785 IF INKEY$="6" THEN LET Y=Y-1
9787 IF INKEY$="7" THEN LET Y=Y+1
9790 IF INKEY$="0" THEN GOTO 9730
9800 GOSUB 9990
9810 GOTO 9770
9990 RAND USR 8192
9991 RETURN
3-D Cube
Joe Chaiet
Type in the program, type SLOW and ENTER, then RUN and ENTER. Press any key as you normally would. Press again. Notice what happens when you hold the key down. When the error code appears, press RUN and ENTER to play again.
10 FOR X=1 TO 20
11 IF INKEY$="" THEN GOTO 11
20 PLOT 19+X,43
25 PLOT 19+X,23
26 PLOT 29+X,33
27 PLOT 29+X,13
60 PLOT 20,43-X
61 PLOT 30,33-X
62 PLOT 49,33-X
65 PLOT 39,43-X
70 IF X>10 THEN GOTO 220
130 PLOT 39+X,43-X
160 PLOT 39+X,23-X
190 PLOT 20+X,23-X
215 PLOT 20+X,43-X
220 NEXT X
Blastoff
Glenn A. Osborn
“Blastoff,” which uses SCROLL with graphics for 16K, contains one of those serendipitous little accidents that I found amusing: the slow dispersion of the rocket smoke caused by the CLS command at line 260.
Type in the program, press RUN and ENTER, and you are on the way.
Graphics line notes:
- 70: Q,W.
- 80: Inverse U, inverse space.
- 90: Inverse S, inverse space.
- 100: Inverse A, inverse space.
- 110: Q, inverse space (2), W.
10 REM "BLASTOFF"
20 PRINT AT 10,10;"BLASTOFF"
30 PAUSE 50
40 CLS
50 LET A=16
60 LET B=10
70 PRINT AT A,B;" [gQ][gW]"
80 PRINT AT A+1,B;" [inv U][inv space]"
90 PRINT AT A+2,B;" [inv S][inv space]"
100 PRINT AT A+3,B;" [inv A][inv space]"
110 PRINT AT A+4,B;"[gQ][inv space x2][gW]"
120 PRINT AT 0,0;"ARE YOU READY TO BLASTOFF?"
130 PRINT "1=YES, 2=NO"
140 INPUT A
150 IF A=1 THEN GOTO 170
160 IF A=2 THEN GOSUB 300
170 PRINT AT 3,0;"COUNTDOWN"
180 FOR G=10 TO 0 STEP -1
190 PRINT G
200 NEXT G
210 PRINT AT 21,0;"BLASTOFF"
220 FOR H=1 TO 22
230 PRINT AT 21,10;" **"
240 SCROLL
250 NEXT H
260 CLS
270 PRINT AT 10,10;"""A-OK"""
280 STOP
300 PRINT AT 5,0;" TOO LATE"
305 PRINT AT 6,0;" ITS TAKING OFF ANYWAY."
310 PAUSE 25
320 RETURN
Train
Joe Chaiet
Type in the program, put the computer in SLOW mode and press RUN and ENTER. Watch the cute display. Then try constructing your own vehicle.
Graphic notes:
- 10: Inverse space (31).
- 50: Space; inverse space (2); space (2); inverse space.
- 60: Space (2); inverse space (6).
- 70: Space; inverse space (7).
- 80: Space (2); letter O; space; letter O; space (2); letter O; Y.
1 LET B=6
2 PRINT AT 5,5;"**HERE COMES THE TRAIN**"
3 FOR S=1 TO 50
4 NEXT S
10 PRINT AT 21,0;"[inv space x31]"
20 FOR A=0 TO 23
21 LET B=B+1
23 IF A>3 AND B<27 THEN PLOT (22-A),B
40 PRINT AT 17,A;
50 PRINT ;" [inv space x2] [inv space]"
60 PRINT TAB (A);" [inv space x6]"
70 PRINT TAB (A);" [inv space x7]"
80 PRINT TAB (A);" O O O[gY]"
90 IF A>3 AND B<27 THEN UNPLOT (22-A),B
100 NEXT A
105 CLS
106 FOR W=1 TO 20
107 NEXT W
110 GOTO 1
Random Rectangles
Joe Chaiet
Type in the program, type SLOW and ENTER, and then RUN and ENTER. Now sit back and enjoy the display. The program will continue generating the display until the computer runs out of memory. Therefore, the more memory you have the longer the program will run. Obviously, with 1K the run is rather short.
Graphic notes:
- 20: Inverse space.
- 56: Inverse space.
- 66: Inverse space.
- 90: Inverse space.
5 LET T=INT (RND*20+2)
6 LET D=INT (RND*14+2)
7 PRINT AT (10-D/2),(14-T/2);
10 FOR X=1 TO T
20 PRINT "[inv space]";
30 NEXT X
35 PRINT TAB (14-T/2);
50 FOR X=1 TO D
55 PRINT TAB (14-T/2);
56 PRINT "[inv space]";
57 FOR U=1 TO T-2
60 PRINT CHR$ D;
65 NEXT U
66 PRINT "[inv space]";
70 NEXT X
75 PRINT TAB (14-T/2);
80 FOR X=1 TO T
90 PRINT "[inv space]";
100 NEXT X
110 GOTO 5
Ricochet
James John Hollandsworth
Enter the listing as printed. Be sure your computer is in SLOW mode. If you do not have SLOW mode, type in 11 PAUSE 5. Press RUN and ENTER. Then observe the results. If the program gives error code 4, the letters H and E in lines 3 and 4 may be changed to letters with lower character codes.
Line notes:
5 and 21: PI is a Function on the M key.
[Figure: Four screen displays of Ricochet patterns]
3 LET N=CODE "H"
4 LET A=CODE "E"
5 LET G=NOT PI
6 LET E=RND*VAL "4"-VAL "2"
7 LET M=RND*VAL "4"-VAL "2"
8 LET X=RND*N
9 LET Y=RND*A
10 PLOT X,Y
13 LET X=X+E
14 LET Y=Y+M
15 IF X<G THEN LET X=G
16 IF Y<G THEN LET Y=G
17 IF X>N THEN LET X=N
18 IF Y>A THEN LET Y=A
19 IF X=G OR X=N THEN LET E=-E
20 IF Y=G OR Y=A THEN LET M=-M
21 GOTO PI*PI