Just for Fun

See all articles from SYNC v2 n3

In general SYNC prefers articles in some depth so that we can help you develop your programming skills and get more out of your computer. However, a number of readers have shared with us some of their favorite short programs which are too long for our “Try This” column and too short for the kind of tutorial that we often use. Some of these programs illustrate a point or demonstrate a technique that the reader has found helpful. Others do something the reader has found interesting. So we have collected a number of these short programs “Just for Fun.” If you learn something, great. If you have some fun, great. If you have some that you want to share, send them in. We will have a “Just for Fun” column as often as we have the material.


Renumbering by a USR Routine

Jon Passler

Enter the following program:

1 REM [g1][g5]#5[inv $][RND]YV[gE]7[inv Y][TAB]"[RND]7[inv Y][COS]P7P[g7][g7][g7][g7][g7][TAB][inv "][RND]
2 REM
3 LET L=USR 16514
4 STOP

See “SYNC Notes” for the conventions used here. In addition, the overline indicates inverse characters.

(Transcriber’s note: in line 1, [gX] is an underlined character, i.e. the graphic on key X; [RND], [TAB], [COS] are underlined keywords entered as single tokens; [inv X] is an overlined (inverse) character.)

Then in the immediate mode (i.e., without a line number) enter

POKE 16531,112
POKE 16533,113

RUN the program and note the changes in the listing. Then add five more of the graphics on the 7 key after the five already given in 1 REM and run the program again. Then in the immediate mode:

POKE 16515,10

and RUN again.

Delete all the lines except 1 REM and save it for future use. It will SAVE and LOAD more quickly without the 16K RAM pack attached. The subroutine can be called in the immediate mode by

LET L=USR 16514

Note:

     LD BC,5
LD HL,16525
LD A,59
ADD A,A
LOOP INC HL
CP (HL)
JPNZ, LOOP
INC HL
CP (HL)
RET Z
LD (HL),B
INC HL
LD (HL),C
INC BC
INC BC
INC BC
INC BC
INC BC
JPNZ, LOOP

Sweeper

Bernard Bush

Some uses for UNPLOT, TAB, and SCROLL that are not given directly in the manual can be extremely useful:

1) UNPLOT can be used in a FOR NEXT LOOP to keep the print position on a given line.

2) There are two PLOT (or UNPLOT) positions for a given line. UNPLOT 0,42 or UNPLOT 0,43 will both work for the top line.

3) SCROLL can also be followed by UNPLOT to keep the print position on a given line. Without it SCROLL moves the print position to the bottom left side of the screen.

4) SCROLL can be used in a loop to SCROLL several lines. E.g.,

10 FOR J=1 TO 10
20 SCROLL
30 NEXT J

The following programs show some uses for UNPLOT and TAB.

SWEEPER

 10 LET A=INT (RND*3)+1
20 LET B=INT (RND*20)+5
30 IF A=1 THEN LET A$="■>NO"
40 IF A=2 THEN LET A$=" HI"
50 IF A=3 THEN LET A$=" O"
60 FOR K=1 TO B
70 PRINT TAB K;A$;
80 GOSUB 190
110 NEXT K
120 FOR J=30 TO 1 STEP -1
130 PRINT TAB J;"/GO "
140 GOSUB 190
170 NEXT J
180 GOTO 10
190 IF A=1 THEN UNPLOT 0,42
200 IF A=2 THEN UNPLOT 0,40
210 IF A=3 THEN UNPLOT 0,38
220 RETURN
  2 GOSUB 200
5 FOR J=10 TO 1 STEP -1
10 LET A=A+1
11 IF A>=10 THEN CLS
22 PRINT TAB J;"HELLO"
30 NEXT J
35 PRINT
40 FOR K=1 TO 10
50 PRINT TAB K;"ZX81"
60 NEXT K
65 IF A>=20 THEN GOSUB 200
70 GOTO 5
200 LET A=0
210 CLS
220 RETURN

Ed, the Head

Basil Wentworth

In lines 180 to 210 an action technique is illustrated which might be useful in a number of programs, for example, a moving target, a flashing signal, alternating graphics for rotary motion.

 10 FAST
20 PRINT
30 PRINT
40 FOR A=1 TO 3
50 IF A=2 THEN GOTO 140
60 FOR B=1 TO 4
70 FOR C=1 TO 10
80 PRINT "▒";
90 NEXT C
100 PRINT
110 NEXT B
120 NEXT A
130 GOTO 170
140 FOR B=1 TO 2
150 FOR C=1 TO 12
160 GOTO 80
170 PRINT AT 5,7;" "
180 SLOW
190 PRINT AT 9,8;" "
200 PRINT AT 9,8;"▒▒"
210 GOTO 190

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.