I resorted to machine code in an effort to write a fast program to display a kaleidoscope pattern on the ZX/TS screen. The resulting images may be viewed on the screen and printed out at will.
In order to get random numbers for the plot locations in machine code, I used the FRAMES system variable (locations 16436 and 16437) to set a pointer into the ROM. The program reads bytes out of the ROM and increments the pointer for each random number. If the pointer goes too high, it is reset to 0. This method shows no visible signs of repetition.
To enter KALEIDOSCOPE, type in listing 1. Put 145 spaces after the message in line 1, and no space between “KALEIDOSCOPE” and “PRESS”. Line 20 contains 32 spaces. RUN the program and enter the numbers in table 1. For each number, the display will show an address and wait for you to enter the contents. After you enter a number it will appear on the screen. If correct, hit ENTER, otherwise press any letter key and reenter the number. After entering all 144 numbers, the Syntactic Sum should be 29651.
Now delete lines 10-100 by entering each line number. Type in lines 10-50 as shown in listing 2.
Be sure you are in SLOW mode, then set your cassette to record and RUN. The program SAVEs automatically and RUNs when LOADed. When done SAVEing, the title will appear on the screen for a few seconds, and then the screen will begin flashing somewhat random patterns. Press any key and the main part of the program will begin. To print a copy of the screen, hit any key. You can save a picture on tape by changing line 30 to SAVE “KALEIDOSCOPE”. The program stops if you press BREAK.
[This program can generate three-dimensional effects if you print out the screen twice with a small time for the pattern to change in between. Hold the output sideways and cross your eyes until the two patterns merge; some points appear to recede into the paper and some appear to jump out. –Ed.]
42 12 64 1 208 0 9 235 33 130 64 1 12 0 237 176 235 1 25 1 9 235 1 22 0 237 176 17 0 200 27 122 179 32 251 237 87 60 237 71 205 187 2 36 40 245 62 30 237 71 205 42 10 205 187 2 36 32 250 42 52 64 203 180 203 188 70 35 203 176 203 184 62 43 184 56 245 78 35 203 177 203 185 126 35 203 71 32 3 175 24 2 62 128 245 205 41 65 62 43 144 71 241 245 205 41 65 62 63 145 79 241 245 205 41 65 62 43 144 71 241 205 41 65 229 205 187 2 36 225 40 186 201 197 229 50 48 64 205 178 11 225 193 201
Table 1. Numbers to POKE
1 REM KALEIDOSCOPEPRESS ANY KEY TO BEGIN
10 FOR X=16548 TO 16691
20 PRINT AT 0,0;" "
30 PRINT AT 0,0;X,
40 INPUT A
50 PRINT A;" "
60 IF INKEY$<>"" THEN GOTO 60
70 IF INKEY$="" THEN GOTO 70
80 IF CODE INKEY$<>118 THEN GOTO 30
90 POKE X,A
100 NEXT X
SYNTACTIC SUM: 13143, 8K ROM

10 SAVE "KALEIDOSCOPE"
20 LET A=USR 16548
30 COPY
40 LET A=USR 16601
50 GOTO 30
SYNTACTIC SUM: 23177, 8K ROM
00001 ;KALEIDOSCOPE MACHINE CODE
00002
400C 00003 DFILE EQU 16396
4034 00004 FRAMES EQU 16436
4082 00005 ORG 16514
4082 2A0C40 00006 PRINT LD HL,(DFILE)
4085 01D000 00007 LD BC,208
4088 09 00008 ADD HL,BC
4089 EB 00009 EX DE,HL
408A 218240 00010 LD HL,16514 ;PRINT MESSAGE ON SCREEN
408D 010C00 00011 LD BC,12
4090 EDB0 00012 LDIR
4092 EB 00013 EX DE,HL
4093 011901 00014 LD BC,281
4096 09 00015 ADD HL,BC
4097 EB 00016 EX DE,HL
4098 011600 00017 LD BC,22
409B EDB0 00018 LDIR
409D 1100C8 00019 PAUSE LD DE,51200 ;TIMING LOOP
40A0 1B 00020 PLOOP DEC DE
40A1 7A 00021 LD A,D
40A2 B3 00022 OR E
40A3 20FB 00023 JR NZ,PLOOP
40A5 ED57 00024 DISP LD A,I ;DISPLAY SCRAMBLING
40A7 3C 00025 INC A ;ROUTINE
40A8 ED47 00026 LD I,A
40AA CDBB02 00027 CALL 699 ;KEY PRESS?
40AD 24 00028 INC H
40AE 28F5 00029 JR Z,DISP
40B0 3E1E 00030 FIX LD A,30 ;RETURN TO NORMAL
40B2 ED47 00031 LD I,A ;DISPLAY
40B4 CD2A0A 00032 CALL 2602 ;CLS
40B7 CDBB02 00033 WAIT CALL 699 ;WAIT UNTIL NO KEY
40BA 24 00034 INC H
40BB 20FA 00035 JR NZ,WAIT
40BD 2A3440 00036 LD HL,(FRAMES) ;POINTER INTO ROM
40C0 CBB4 00037 RESET RES 6,H ;TRIM OFF EXCESS BITS
40C2 CBBC 00038 RES 7,H
40C4 46 00039 VALS LD B,(HL) ;RANDOM Y VALUE
40C5 23 00040 INC HL
40C6 CBB0 00041 RES 6,B
40C8 CBB8 00042 RES 7,B
40CA 3E2B 00043 LD A,43
40CC B8 00044 CP B
40CD 38F5 00045 JR C,VALS ;GO BACK IF TOO HIGH
40CF 4E 00046 LD C,(HL) ;RANDOM X VALUE
40D0 23 00047 INC HL
40D1 CBB1 00048 RES 6,C
40D3 CBB9 00049 RES 7,C
40D5 7E 00050 LD A,(HL)
40D6 23 00051 INC HL
40D7 CB47 00052 BIT 0,A
40D9 2003 00053 JR NZ,UNPLOT
40DB AF 00054 XOR A ;0 FOR PLOT,
40DC 1802 00055 JR DOPLOT ;128 FOR UNPLOT
40DE 3E80 00056 UNPLOT LD A,128
40E0 F5 00057 DOPLOT PUSH AF ;SAVE AF
40E1 CD0741 00058 PLOT1 CALL PLOT ;PLOT THE POINT
40E4 3E2B 00059 LD A,43 ;GET SECOND POINT
40E6 90 00060 SUB B
40E7 47 00061 LD B,A
40E8 F1 00062 POP AF
40E9 F5 00063 PUSH AF
40EA CD0741 00064 PLOT2 CALL PLOT ;PLOT THE POINT
40ED 3E3F 00065 LD A,63 ;GET THIRD POINT
40EF 91 00066 SUB C
40F0 4F 00067 LD C,A
40F1 F5 00068 PUSH AF
40F2 F1 00069 POP AF
40F3 CD0741 00070 PLOT3 CALL PLOT ;PLOT THE POINT
40F6 3E2B 00071 LD A,43 ;GET FOURTH POINT
40F8 90 00072 SUB B
40F9 47 00073 LD B,A
40FA F1 00074 POP AF
40FB CD0741 00075 PLOT4 CALL PLOT ;PLOT THE POINT
40FE E5 00076 COPY PUSH HL
40FF CDBB02 00077 CALL 699 ;KEY PRESS?
4102 24 00078 INC H
4103 E1 00079 POP HL
4104 28BA 00080 JR Z,RESET ;LOOP IF NOT
4106 C9 00081 RET ;OTHERWISE RETURN
4107 C5 00082 PLOT PUSH BC ;SUBROUTINE TO PLOT
4108 E5 00083 PUSH HL
4109 323040 00084 LD (16432),A ;PLOT STATUS
410C CDB20B 00085 CALL 2994 ;PLOT/UNPLOT
410F E1 00086 POP HL
4110 C1 00087 POP BC
4111 C9 00088 RET
COPY 40FE 00076
DFILE 400C 00003 00006
DISP 40A5 00024 00029
DOPLOT 40E0 00057 00055
FIX 40B0 00030
FRAMES 4034 00004 00036
PAUSE 409D 00019
PLOOP 40A0 00020 00023
PLOT 4107 00082 00058 00064
00070 00075
PLOT1 40E1 00058
PLOT2 40EA 00064
PLOT3 40F3 00070
PLOT4 40FB 00075
PRINT 4082 00006
RESET 40C0 00037 00080
UNPLOT 40DE 00056 00053
VALS 40C4 00039 00045
WAIT 40B7 00033 00035

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