Let me start out by saying what this program does NOT do. In spite of the title, it does not solve cryptograms. I enjoy working those little fellows far too much to surrender the fun to a computer. This program is designed, rather, to do the clerical jobs for me, while I save the creative work for myself.
If you have ever worked cryptograms, you know that the solutions are sometimes obvious. If, for example, the encrypted text begins like
BA BI ASLO AVEA EJJ…
you can tell, almost by intuition, that the solution is going to start out
IT IS TRUE THAT ALL…
Other patterns are easy to recognize. JOCJEO is very likely to be PEOPLE, unless the word before it is EO, in which case it is probably INDIAN. BCDBEF will be ALWAYS. Well, almost always.
But the majority of crypto texts take more work than that. At least, for amateurs like me. If they didn’t, it wouldn’t be any fun. That single letter, for example: is it I or A? Is that BCC going to be ALL or SEE or OFF or ASS or TOO, or what? If there’s a BC somewhere in the exercise, you can (probably) eliminate ALL and SEE, but the other three are still possible. So are BEE and INN and WEE. There may be others. At any rate, you’re likely to run into a lot of trial-and-error work, leaving the page pretty well scrubbed up by your eraser. This program lets you do the erasing on your screen. Here’s how it works.
First, you are told to enter the program in 32-character lines. If you try to make the line longer than that, the computer will just chop it back to 32. There has been an unfortunate lack of co-ordination between Sir Clive and most cryptogram publishers in this area, as the magazines almost always print lines a little longer than 32 characters. We’ll just have to live with their lack of foresight.
When you have the 32 characters ready, press “ENTER”, and start on the next line. When all of the lines have been typed in, signal this fact by pressing an extra “ENTER”. The computer will then print the lines of text, triple-spaced, with a “<” and a “>” indicating the positions of the plain text (the part you can read) and the encrypted text. These symbols are vital to the operation of the machine code part of the program. (I used a slightly different system for the TS1000, due to the straightforward simplicity of that computer’s display file.)
As you can see, the plain text (which is blank for the moment) will appear above the encrypted version.
At the same time, a prompt at the bottom of the screen will ask for the OLD LETTER. Now it’s your turn to do some work. Look at the encrypted text, put your brain in gear, and figure out one substitution. In the example above (BA BI ASLO etc), you expect to replace B with I. The “old” letter, then, is B. Press B. You will get a new prompt, asking for the NEW LETTER–in this case, I. So press I. Immediately, all of the B’s in the encrypted text have I’s printed above them. And the prompt again asks for an “old” letter. If you change your mind about the B’s, press B again, followed by your new choice. Or followed by a space, if you want to blank out the letters above the B’s. On the other hand, if you’re satisfied with your choice for B, work on another letter.
If you garble things so badly that you want to start over, press “ENTER” in lieu of an OLD letter. With the 2068, the program then gives you a chance to reprint the encrypted text (by pressing Y) or to quit that cryptogram entirely (by pressing any other letter). With the TS1000 program, this response gives you a STOP. If this makes you unhappy, you can easily modify the program to emulate the 2068 routine.
If you choose not to repeat (2068), you can either start at the beginning for a new cryptogram (press Y) or quit entirely (press any other letter).
The Machine Code Section
I should mention here a warning that applies whenever you are using machine code: DON’T try to use the same memory bytes to hold more than one machine code routine. That should be obvious, but I found myself making just that mistake, when I tried to LOAD my printer software into the same memory locations that I was using for the CRYPTO bytes. It didn’t work.
Before I go into a discussion of the machine code section, permit me one short digression. That is to point out that line 10 makes sure that the computer is in the CAPS mode–that all the letters entered from the keyboard will be capitals, following the convention of printed cryptograms.
The machine code for the TS 2068, which is listed in Figure 1, is quite straightforward. The code is stored above RAMTOP by lines 9300 on, in bytes beginning with 65280. You will notice that the USR call (line 3260) is to byte 65290, and the bytes from 65280 to 65287 are taken up by a subroutine, with two nulls at 65288 and 65289.
The machine code program first searches the VARS area of the computer memory to find where “<” (the beginning of the string of encrypted text) is stored, and records this number in HL. Then it goes through a similar procedure for the string of plain text (beginning with “>”), and records that number in DE. The length of the line being worked on is held in BC. From then on, it is a simple matter of working through the two strings, byte by byte (the duration of the procedure governed by the bytes beginning with 65315) and POKEing the designated “new” character into the plain text string every time the selected “old” character is encountered in the encrypted string.
The TS1000 machine code works a little differently, POKEing the appropriate data directly into the display file at the proper place.
And there you are. Here is one of my limericks to get you started.
BA BSI BL LOI VEE JBCY “NELOIT,
DI JFTIGH WBA LTFJL IBWO ELOIT:
HEF DETTH JE NFWO
BXEFL YBTDCA BAY JFWO–
BN C LOIA NH UIISIT’J XTELOIT?”
Those of you who are as inexperienced as I am about machine code might be interested in the “rough draft” I wrote for the TS1000 routine, simulating in BASIC the m/c operation.
Memory Byte Mnemonic Remarks
65280 42 LD HL, Vars area
1 75 (23627)
2 92
3 35 INC HL Look for a
4 190 CP(HL) match
5 200 RET Z
6 24 JR,-5
7 251
8 0 NOP nulls
9 0
65290 62 LDA, USR to here
1 62 62 (<)
2 205 CALL 65280
3 0
4 255
5 235 EX DE,HL
6 62 LD A,
7 60 60 (>)
8 205 CALL 65280
9 0
65300 255
1 1 LD BC, LEN A$, by
2 x lines 3000 and
3 x 3010
4 62 LD A, Old ltr, by
5 x 3190
6 190 CP(HL)
7 32 JR NZ, 4
8 4
9 235 EX DE,HL
65310 54 LD(HL), New ltr, by
1 x 3240
2 235 EX DE,HL
3 35 INC HL
4 19 INC DE
5 11 DEC BC
6 62 LD A, 0
7 0
8 184 CP B
9 32 JR NZ,-17
65320 239
1 185 CPC
2 200 RET Z
3 24 JR,-21
4 235
Figure 1. The 2068 machine code
1 POKE 23658,8
10 GO TO 9000
1000 PAUSE 10
1005 IF INKEY$="" THEN GO TO 1005
1010 RETURN
1500 CLS
1510 PRINT ''"ENTER ENCRYPTED TEXT, ONE LINE"
1520 PRINT "AT A TIME. THE COMPUTER WILL"
1530 PRINT "LOP OFF EACH LINE TO 32 CHARAC-"
1540 PRINT "TERS IN LENGTH."
1550 PRINT ''"WHEN YOU HAVE TYPED IN ALL THE"
1560 PRINT "TEXT, PRESS N/L"
1570 PRINT ''"READY? PRESS N/L TO BEGIN"
1580 INPUT A$
1590 CLS
2000 LET A$="<"
2010 LET B$=">"
2020 LET N=31
2030 INPUT T$
2040 IF T$="" THEN GO TO 3000
2050 LET T$=(T$+" ")( TO N)
2060 LET U$=" "( TO N)
2070 LET B$=B$+U$
2080 LET A$=A$+T$
2090 LET N=32
2100 PRINT ''T$
2110 GO TO 2030
3000 POKE 65303,INT (LEN A$/256)
3010 POKE 65302,LEN A$-256*PEEK 65303
3100 CLS
3110 LET I=INT (LEN A$/32)
3120 FOR F=0 TO I-1
3130 PRINT 'B$(32*F+1 TO 32*(F+1))
3140 PRINT A$(32*F+1 TO 32*(F+1))
3150 NEXT F
3160 PRINT AT 19,0;"OLD LETTER? - ";
3170 GO SUB 1000
3180 IF INKEY$=CHR$ 13 THEN GO TO 3500
3190 POKE 65305,CODE INKEY$
3200 PRINT INKEY$;"; ";
3210 PRINT "NEW LETTER - ";
3220 GO SUB 1000
3230 IF INKEY$=CHR$ 13 THEN GO TO 3500
3240 POKE 65311, CODE INKEY$
3250 PRINT INKEY$
3260 RANDOMIZE USR 65290
3270 CLS
3280 GO TO 3110
3500 CLS : PRINT ''"TRY THIS CRYPTOGRAM AGAIN? Y- N-"
3510 GO SUB 1000
3520 IF INKEY$<>"Y" AND INKEY$<>"y" THEN GO TO 3560
3530 LET B$=">"
3540 FOR F=1 TO LEN A$-1: LET B$=B$+" ": NEXT F
3550 GO TO 3100
3560 CLS : PRINT ''"TRY ANOTHER CRYPTOGRAM? Y- N-"
3570 GO SUB 1000
3580 IF INKEY$="Y" OR INKEY$="y" THEN GO TO 1500
3590 CLS : PRINT ''"TS 2068 THANKS YOU; BASIL LOVES"
3600 PRINT '"JOCELYN"
3610 PRINT ''''" BIBI"
8999 STOP
9000 CLEAR 65270
9010 LET F=65279
9020 LET F=F+1
9030 READ A: IF A=64 THEN RESTORE : RUN 1500
9040 POKE F,A: GO TO 9020
9050 DATA 42,75,92,35,190,200,24,251,0,0,62,62,205,0,255,235
9060 DATA 62,60,205,0,255
9070 DATA 1,0,0,62,0,190,32,4,235,54,0,235,35,19,11
9080 DATA 62,0,184,32,239,185,200,24,235
9400 DATA 64
9499 STOP
9500 REM SAVE
9510 SAVE "CRYPTOLIST" LINE 1
9520 BEEP .3,12: BEEP 1,12
9530 VERIFY "CRYPTOLIST"
9540 BEEP .3,16: BEEP 1,16
CRYPTO–TS2068 LISTING
1 REM E£RND-4▒INKEY$ ▒7+ASN ▒RNDY<▒COS YS▒TAB ▒RND▒5 GOSUB PI0 ▒7▒RND
10 GOTO 1000
100 INPUT T$
110 IF T$="" THEN LET R=1
150 LET T$=(T$+" ")( TO 32)
160 RETURN
999 STOP
1000 LET L=2
1010 LET R=0
1100 PRINT AT 19,0;"ENTER ENCRYPTED TEXT, 32 LETTERSAT A TIME.";
1105 PRINT " (LESS THAN 6 LINES.)";
1110 PRINT " PRESS ""ENTER"" TO STOP"
1120 GOSUB 100
1130 IF R THEN GOTO 2000
1140 PRINT AT L,0;T$
1150 LET L=L+3
1160 GOTO 1020
2000 PRINT AT L,0;"<"
2010 PRINT AT 19,0;"INPUT OLD LETTER - "
2015 PRINT " "
2020 PRINT "PRESS ""ENTER"" TO STOP "
2030 INPUT L$
2050 IF L$="" THEN GOTO 5000
2060 POKE 16533,CODE L$
2110 PRINT AT 19,0;"INPUT NEW LETTER - "
2130 INPUT L$
2150 IF L$="" THEN GOTO 5000
2160 POKE 16544,CODE L$
2500 PRINT USR 16514
2510 GOTO 2010
8999 STOP
9000 REM SAVE
9010 CLS
9020 PRINT AT 15,0;"START RECORDER; THEN PRESS ANY KEY"
9030 PAUSE 4E4
9100 SAVE "CRYPT▒"
9110 CLS
9120 RUN
CRYPTO–TS1000 BASIC PROGRAM
16514 42 LD HL,
16515 12 (16396)
16516 64
16517 22 LD D,
16518 32 32
16519 1 LD BC,
16520 65 65
16521 0
16522 9 ADD HL,BC
16523 35 INC HL
16524 21 DEC D
16525 202 JP Z,
16526 133 16517
16527 64
16528 62 LD A,
16529 19 19
16530 190 CP(HL)
16531 200 RET Z
16532 62 LD A,
16533 49 49*
16534 190 CP(HL)
16535 194 JNZ,
16536 139 16523
16537 64
16538 1 LD BC,
16539 33 33
16540 0
16541 237 SBC HL,BC
16542 66
16543 54 LD(HL),
16544 61 61**
16545 9 ADD HL,BC
16546 195 JP,
16547 139 16523
16548 64
* OLD LETTER
** NEW LETTER
CRYPTO–TS1000 MACHINE CODE
10 PRINT
20 PRINT
30 PRINT "BASIL LOVES JOCELYN. "
40 PRINT
50 PRINT
60 PRINT "BASIL LOVES JOCELYN. "
70 PRINT
80 PRINT
90 PRINT "<"
100 LET HL=PEEK 16396+256*PEEK 16397
110 LET D=32
120 LET BC=65
130 LET HL=HL+BC
140 LET HL=HL+1
150 LET D=D-1
160 IF D=0 THEN GOTO 110
170 LET A=19
175 REM CODE "<"
180 IF PEEK HL=A THEN STOP
190 LET A=CODE "L"
195 REM OLD LETTER
200 IF PEEK HL<>A THEN GOTO 140
210 LET BC=33
220 LET HL=HL-BC
230 POKE HL,CODE "X"
235 REM NEW LETTER
240 LET HL=HL+BC
250 GOTO 140
“ROUGH DRAFT” OF CRYPTO–TS1000 PROGRAM
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.