A type-in checker for the TS1000, TS1500 and ZX81: Earl V. Dunnington’s adaptation, with Stan Lemke’s permission, of Lemke’s TS2068 program CK TYPE. It goes through the BASIC program in memory and prints, for each line, the line number, the number of bytes in the line and a checksum, on the screen and with LPRINT on the TS2040 printer. If a listing is published with its CK TYPE printout, you can run CK TYPE 1000 on your typed copy and see which lines differ. This version’s checksum adds each byte plus 2, 1, 2, 1 in turn (line 9992 is LET SM=(SM+OD+1)+PEEK BT), where the TS2068 original multiplies alternate bytes by 2. Its figures are therefore different from the TS2068 program’s, and it does not notice two characters swapped within a line. The article’s own printouts were made with it.
The main file is the final CK TYPE 1000, at line numbers 10000 to 10018 so that it does not clash with the program you type in. LOAD it, type in the program, then enter GOTO 1000 as the article prints it. That works as long as your program has no line 1000 or above; GOTO 10000 always works. When the screen fills you get report 5; press CONT (the C key) and ENTER for the rest, and the line it stopped on is printed again. Do not use line 9999 in your program. On the ZX81, lines numbered above 9999 cannot be edited or deleted, so the article gives a way to remove them. Enter PRINT (PEEK 16396+256*PEEK 16397)-358, POKE the address it gives with 15 and delete line 9999. Do that 19 times, once for each line.
The second file, marked Listing E, is the plain BASIC version at lines 9980 to 9999, as printed. Line 9999 RETURN is there for The ZX Compiler, and the article says to delete it if you do not have the compiler. As printed, RUN lists the 20 lines and then stops with report 7/9999. The article builds the final version from a second listing, Listing G: a shortened copy of the program (VAL “256”, NOT PI and SGN PI in place of numbers) plus a short routine at lines 10 to 100 that POKEs the new line numbers into place. The main file was made by following those steps exactly. Both BASIC versions run in 2K.
The third file, marked Machine Code, is the machine code version from Time Designs July/August 1988 (CKTYPE 1000 (Machine Code Version)). It was compiled from the BASIC version with The ZX Compiler, keeping only the parts of the compiler’s run-time package that the program uses. It needs 16K. LOAD it and it runs itself. It sets RAMTOP to 32085 and shows its instructions. Press a letter key and it moves the 682 bytes of machine code above RAMTOP, then clears the BASIC area. Then type in a program, or load one from tape with RAND USR 32394. That loader stops the loaded program from running itself, so it cannot overwrite the code. RAND USR 32086 prints the CK TYPE listing on the printer only, not on the screen. Its figures are the same as the BASIC version’s.
The machine code file was made by following that article’s steps. Listing L enters the 682 values of Listing K into A$ and prints them back for checking. The program is then edited into Listing N, GOTO 2 puts a short routine into the REM in line 1, lines 2 to 6 are deleted, and GOTO 20 saves it. Listing L has a slip: its check printout prints six values a row, and 682 is not a multiple of six. After the last row it stops with report 3/204, so the correction instructions in line 206 never appear. The data in A$ is not affected.
Published in Time Designs Magazine January/February 1988 (CK Type 1000) and July/August 1988 (CKTYPE 1000 (Machine Code Version)).
Source Code
Listing E (BASIC version, lines 9980-9999)
9980 LET ST=16509
9981 LET SP=256*PEEK 16397+PEEK 16396
9982 LET BT=ST
9983 LET LE=0
9984 LET LH=0
9985 LET SM=0
9986 LET LE=256*PEEK BT+PEEK (BT+1)
9987 LET BT=BT+2
9988 LET LH=256*PEEK (BT+1)+PEEK BT
9989 LET BT=BT+2
9990 LET OD=1
9991 FOR I=1 TO LH
9992 LET SM=(SM+OD+1)+PEEK BT
9993 LET OD=NOT OD
9994 LET BT=BT+1
9995 NEXT I
9996 PRINT LE;TAB 6;": ";LH;TAB 13;": ";SM
9997 LPRINT LE;TAB 6;": ";LH;TAB 13;": ";SM
9998 IF BT<SP THEN GOTO 9983
9999 RETURN
Listing G (lines 10-100 renumber lines 9980-9998 to 10000-10018; before RUN, line 9998 is changed to GOTO VAL "10003")
10 LET START=(256*PEEK 16397+PEEK 16396)-2
20 LET HIGHBYTE=39
30 LET LOWBYTE=34
40 FOR N=START TO START-358 STEP -1
50 IF PEEK N<>118 THEN GOTO 90
60 POKE N+1,HIGHBYTE
70 POKE N+2,LOWBYTE
80 LET LOWBYTE=LOWBYTE-1
90 NEXT N
100 STOP
9980 LET ST=VAL "16509"
9981 LET SP=VAL "256"*PEEK VAL "16397"+PEEK VAL "16396"
9982 LET BT=ST
9983 LET LE=NOT PI
9984 LET LH=NOT PI
9985 LET SM=NOT PI
9986 LET LE=VAL "256"*PEEK BT+PEEK (BT+SGN PI)
9987 LET BT=BT+VAL "2"
9988 LET LH=VAL "256"*PEEK (BT+SGN PI)+PEEK BT
9989 LET BT=BT+VAL "2"
9990 LET OD=SGN PI
9991 FOR I=SGN PI TO LH
9992 LET SM=(SM+OD+SGN PI)+PEEK BT
9993 LET OD=NOT OD
9994 LET BT=BT+SGN PI
9995 NEXT I
9996 PRINT LE;TAB VAL "6";": ";LH;TAB VAL "13";": ";SM
9997 LPRINT LE;TAB VAL "6";": ";LH;TAB VAL "13";": ";SM
9998 IF BT<SP THEN GOTO VAL "9983"
Machine code version (Time Designs July/August 1988)
Listing L (enters Listing K into A$)
20 DIM A$(682)
170 PRINT "WORKING FROM LEFT TO RIGHT, ENTER A DATA VALUE"
180 FOR N=1 TO 682
185 INPUT DATA
190 LET A$(N)=CHR$ DATA
200 NEXT N
201 PRINT AT 0,0;"TO OBTAIN A PRINTOUT OF A$, TURN ON PRINTER AND PRESS A LET-TER KEY OTHERWISE PRESS BREAK"
202 PAUSE 32768
203 FOR N=1 TO 682 STEP 6
204 LPRINT TAB 0;"A$(";N;")";TAB 8;CODE A$(N);TAB 12;CODE A$(N+1);TAB 16;CODE A$(N+2);TAB 20;CODE A$(N+3);TAB 24;CODE A$(N+4);TAB 28;CODE A$(N+5)
205 NEXT N
206 PRINT AT 0,0;"TO CORRECT AN ERRONEOUS VALUE, USE THE DIRECT COMMAND: LET A$(N)=CHR$ DATA WHERE N=THE CHARACTER NUMBER IN THE STRING AND DATA IS THE COR- RECT VALUE"
210 STOP
Listing N (final program; " CKTYPE 1000 " in line 140 is inverse video)
1 REM 1234
2 POKE 16510,0
3 POKE 16514,49
4 POKE 16515,81
5 POKE 16516,125
6 POKE 16517,201
10 RETURN
20 SAVE "CKTYPE"
30 FAST
40 POKE 16388,85
50 POKE 16389,125
60 POKE 32084,62
70 POKE 32083,0
80 POKE 32082,6
90 POKE 32081,118
100 POKE 16386,81
110 POKE 16387,125
120 RAND USR 16514
130 GOSUB 10
140 PRINT AT 0,9;" CKTYPE 1000 ";AT 2,0;"1. RAMTOP HAS BEEN SET AT 32085";AT 4,0;"2. PRESS A LETTER KEY TO MOVE M/C ABOVE RAMTOP AFTER MAKING A NOTE OF THE FOLLOWING"
150 PRINT AT 8,0;"3. WHEN CURSOR APPEARS, EITHER TYPE IN A PROGRAM OR LOAD A PRO-GRAM FROM TAPE USING THE DIRECT COMMAND: RAND USR 32394"
160 PRINT AT 13,0;"4. TO LPRINT A CKTYPE LISTING, USE THE DIRECT COMMAND: RAND USR32086"
170 PAUSE 32768
180 FOR N=1 TO 682
190 POKE N+32085,CODE A$(N)
200 NEXT N
210 NEW
Listing K (machine code: A$ character number, then that value and the next five)
A$(1) 33 125 64 34 116 126
A$(7) 33 13 64 205 252 127
A$(13) 235 33 0 1 205 173
A$(19) 126 229 33 12 64 205
A$(25) 252 127 235 225 25 34
A$(31) 118 126 42 116 126 34
A$(37) 120 126 33 0 0 34
A$(43) 122 126 33 0 0 34
A$(49) 124 126 33 0 0 34
A$(55) 126 126 42 120 126 205
A$(61) 252 127 235 33 0 1
A$(67) 205 173 126 229 17 1
A$(73) 0 42 120 126 25 205
A$(79) 252 127 235 225 25 34
A$(85) 122 126 17 2 0 42
A$(91) 120 126 25 34 120 126
A$(97) 17 1 0 42 120 126
A$(103) 25 205 252 127 235 33
A$(109) 0 1 205 173 126 229
A$(115) 42 120 126 205 252 127
A$(121) 235 225 25 34 124 126
A$(127) 17 2 0 42 120 126
A$(133) 25 34 120 126 33 1
A$(139) 0 34 128 126 33 1
A$(145) 0 34 130 126 42 124
A$(151) 126 34 132 126 33 1
A$(157) 0 34 134 126 33 252
A$(163) 125 34 136 126 237 91
A$(169) 128 126 42 126 126 25
A$(175) 17 1 0 25 229 42
A$(181) 120 126 205 252 127 235
A$(187) 225 25 34 126 126 42
A$(193) 128 126 205 10 127 34
A$(199) 128 126 17 1 0 42
A$(205) 120 126 25 34 120 126
A$(211) 205 201 127 130 126 253
A$(217) 203 1 206 42 122 126
A$(223) 205 44 127 33 6 0
A$(229) 205 163 127 205 108 127
A$(235) 14 0 112 42 124 126
A$(241) 205 44 127 33 13 0
A$(247) 205 163 127 205 108 127
A$(253) 14 0 112 42 126 126
A$(259) 205 44 127 62 118 215
A$(265) 253 203 1 142 237 91
A$(271) 118 126 42 120 126 205
A$(277) 24 127 205 148 127 124
A$(283) 125 205 248 127 0 0
A$(289) 0 0 0 0 0 0
A$(295) 0 0 0 0 0 0
A$(301) 0 0 0 0 0 0
A$(307) 0 0 205 231 2 205
A$(313) 211 27 205 67 8 201
A$(319) 1 0 0 195 117 11
A$(325) 197 6 16 124 77 33
A$(331) 0 0 41 203 17 23
A$(337) 48 1 25 16 247 193
A$(343) 201 14 0 124 170 230
A$(349) 128 71 213 205 0 127
A$(355) 227 205 0 127 235 225
A$(361) 121 167 40 54 120 177
A$(367) 229 237 98 237 82 229
A$(373) 193 209 33 0 0 55
A$(379) 63 245 122 83 30 8
A$(385) 41 48 5 143 237 74
A$(391) 24 9 135 237 74 56
A$(397) 3 237 66 61 60 29
A$(403) 32 236 95 241 48 226
A$(409) 203 79 32 1 235 203
A$(415) 127 200 24 11 205 154
A$(421) 126 203 16 208 24 3
A$(427) 124 7 208 235 167 237
A$(433) 98 237 82 201 124 181
A$(439) 33 0 0 192 44 201
A$(445) 1 0 128 24 4 235
A$(451) 1 1 128 124 168 103
A$(457) 122 168 87 237 82 38
A$(463) 0 121 111 216 238 1
A$(469) 111 201 58 33 64 203
A$(475) 71 32 26 203 79 32
A$(481) 10 203 124 40 6 62
A$(487) 22 215 205 3 127 1
A$(493) 240 216 30 255 197 205
A$(499) 225 7 205 173 10 229
A$(505) 193 33 93 64 87 30
A$(511) 28 112 203 122 40 1
A$(517) 113 151 237 111 131 215
A$(523) 151 237 111 131 215 203
A$(529) 122 203 250 40 239 201
A$(535) 225 126 35 254 112 40
A$(541) 47 254 118 32 3 215
A$(547) 24 243 205 148 126 24
A$(553) 238 151 24 2 62 144
A$(559) 75 69 33 48 64 86
A$(565) 119 213 229 205 178 11
A$(571) 225 209 114 201 205 10
A$(577) 127 124 181 227 94 35
A$(583) 86 35 227 192 225 235
A$(589) 233 125 230 31 79 253
A$(595) 203 1 78 40 10 253
A$(601) 150 56 203 255 198 60
A$(607) 212 113 8 253 134 57
A$(613) 254 33 58 58 64 222
A$(619) 1 205 250 8 253 203
A$(625) 1 198 201 225 94 35
A$(631) 86 35 229 213 33 7
A$(637) 0 25 6 4 86 43
A$(643) 94 43 213 16 249 225
A$(649) 193 209 122 25 235 225
A$(655) 227 115 35 114 197 225
A$(661) 7 48 1 235 205 18
A$(667) 127 225 216 193 233 235
A$(673) 115 201 193 229 193 201
A$(679) 110 38 0 201
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

