Classic Computer Magazine Archive A.N.A.L.O.G. ISSUE 62 / JULY 1988 / PAGE 47

48k disk

Cryptogram
Solver

by Kevin Peck

I have always had a lot of fun solving cryptograms out of puzzle books and magazines. However, some of the fun was lost through the multiple erasing and rewriting as guess after guess led to the solution of the puzzle.

    But no more! The following program has put all the fun back into solving cryptograms-and has saved me a fortune in erasers.
    After typing in the program using the ML Editor, you will be ready to use your computer to solve your first cryptogram. The program includes full onscreen prompts and command key summaries to make the program as easy to use as possible.
    The first screen is the title screen. Press any key to begin the puzzlesolving process.
    The main puzzle entry and solving screen now appears. The cursor is on the second line of the screen's blue area. This is the first position of puzzle text entry. You are now ready to start typing your puzzle text from the puzzle book. A summary of valid editing keys is shown in the grey area on the bottom of the screen. You are only allowed to enter text on every other line, giving you nine lines for puzzle text. The other nine lines in the blue area are for the solved puzzle text. All editing keys operate as they do in BASIC. You may insert and delete characters or whole lines. The one addition is a confirming prompt when you press SHIFT-CLEAR to clear the screen. This will save you from accidental loss of puzzle text. I usually like to type in all of the puzzle text, and then insert lines (SHIFT-INSERT) to center the puzzle on the screen.



    When you have entered all of the puzzle text, press the START key to begin solving the puzzle. A new set of commands will appear in the grey area at the bottom of the screen. The top two lines of the screen- the green area-will come into play now. The first line is the alphabet in order, and the line below that will contain the replacement set of letters as you try and solve the puzzle. I included this so you can quickly see whether you are trying to substitute the same letter in two different places or to see which letters are still available for use in solving the puzzle.
    You are now prompted for the puzzle letters you wish to replace on the red prompt line near the bottom of the screen. The cursor is an underline to let you know that the only text-editing keys available are the backspace, space bar and return keys. To use the special commands in the grey area at the bottom of the screen, press and hold CONTROL while pressing the highlighted letter key of the command that you wish to use. I will explain each command in detail for you in a moment.
    To actually solve the cryptogram you must type at the "Replace" prompt the letters of the puzzle-the letters that you entered in the edit phase-that you wish to change. After pressing RETURN, you will be asked what to replace those letters with. Type the letters you want substituted and press RETURN at the "With" prompt. All changes will be reflected in the lines above your puzzle text in inverse video. The second line of the display will also be updated at this time. Notice that you may not type in more characters at the "With" prompt than you typed in at the "Replace" prompt. You may also not press RETURN without any input at the "Replace" prompt nor may you enter any spaces. You are allowed to press RETURN only at the "With" prompt. Doing so will cause the program to blank out all characters from the "Replace" prompt. Do this to clear out mistakes. You may selectively blank out characters by typing a space also. If you type less characters at the "With" prompt than you typed in at the "Replace" prompt, the extra characters will be changed to be spaces.
    What about all of those command keys at the bottom of the screen? Well, the first command key listed is the Back key. If you notice a mistake in the letters at the "Replace" prompt while typing the "With" letters, press CNTRL-B to go back to the "Replace" prompt and fix the mistakes.
    If you have made multiple misguesses while attempting to solve the puzzle, you may wish to use the Clear command. After a confirming prompt, the program clears out the changes to the puzzle only, not the puzzle text itself.
    "Edit" allows you to go back to the edit screen, to make changes to the puzzle text. All changes up to this point are erased, but they will be restored when you return to puzzle solving. Make all changes necessary, and press START when you are done.
    "New" allows you to start a new puzzle. There is a confirming prompt for this command because it is rather drastic. It clears out all puzzle text along with all changes made to that puzzle and deposits you back into the puzzle text-editing screen. Only use this command when you have completely solved the current puzzle or when you are ready to give up on the current puzzle. Warning! There is no way to undo this command!
    "Quit" is used only when you are completely done with the program. There is a confirming prompt. If you answer yes to the "Quit?" question, you will be returned to DOS.
    Undo is a handy feature that allows you to undo the last change you made to the puzzle. If you use undo a second time, you will undo the undo. You can use this command to toggle between two possible changes to a puzzle to see which is going to work better.
    I have included a sample puzzle to get you started. The puzzle appears in Figure 1. The puzzle includes a hint if you need it. The answers appear upside down in Figure 2. A list of common, easy-to-recognize words appear in Figure 3. I have tried to include as many oddball, easy-to-spot words from the word list as possible in the sample puzzles, so you can see how the word list will help you in solving your puzzles.

Writing Your
First Machine
Language Program

    This project started out as a small, slow, BASIC program five years ago on a HeathKit H-89 computer. It had no editing commands, no fancy graphics and no mistake fixers. It did the job and was better than solving the puzzle on paper, but it was lacking as far as useful computer programs go. It was one of the few programs that I had converted from the H-89 to my new Atari. When I converted it two years back, it was identical in features and functions to the H-89 version. I decided to fix that.
    First, I wanted to use some of the fancy color graphics of the Atari. Since this is a text-oriented program I knew I would be using Graphics mode 0. The only way to add color was to use Display List Interrupts. I read all I could on them and wrote one for the program and had it up and running with BASIC. Next, I decided that the letter replacement routine had to be fast, so I wrote a short ML routine for that also. Then I started on the editing features. Unfortunately, BASIC was starting to drag. I looked at the program and said, "Hey! I have two machine-language routines already. Why not do the whole thing in assembly?" I had been trying to get myself to write an all-assembly language program for the longest time, and here it was half done (or so I thought at the time).
    I ended up spending the next five days typing source code into Action! from OSS. Wait a minute! Action!, BASIC, assembly. What the heck is going on here? Time for a confession. I love MAC/65, but I hate line numbers, especially since MAC/65 never uses them except to keep source code in order. MAC/65 does have a nice feature that will take unnumbered ASCII text and append line numbers to it. Using this feature, I was able to type the source code in with the Action! editor. Action! allowed for source code manipulation, with the extra feature of scrolling around to find routine names and various labels without having to remember what line number each routine started at.
    The next big help was my 130XE with SpartaDOS and its RAMdisk capabilities. I could never live without a RAMdisk again. It is a great place to keep temporary files, and it sure sped up assembly with INCLUDE files. It also helped when I entered the unnumbered text files into MAC/65.
    The largest object file that I had ever compiled to date was 192 bytes. This program is just over 3,000 bytes, which just goes to show that you can make the big jump into major assembly language programming without going through byte by byte upgrades. What I am getting at is this: go for it and write that first big all assembly project. You can do it, and you will be proud and have a lot more confidence in yourself after you do.
    Okay, I must admit that I did do one special thing in the program. I did bypass the normal way of reading the Atari keyboard. At first I opened the keyboard for input the normal way, but that caused problems with the display list interrupts, especially on the older Atari 800. The first place to look for a solution was De Re Atari, but that was no help. It said, "Another solution is to disable the OS keyboard service routine and provide your own keyboard routine." This would be a tedious job. Oh, great! I thought.
    It turned out to be fairly simple. All I did was use the value in RAM location 764, the last key pressed value, to look up the ATASCII code in a table that sits in ROM. This table resides in different locations in the 400/800 than in the XL/XEs, but it was easy to have the program adjust for that. The program's screens are crystal clear now. I only had to change one ten-line subroutine in the program to accomplish this, and now no annoying key click sounds occur on any of the Atari machines while running the program.
    I was able to produce 27 pages of working source code in five days, which is a record for me, and even more impressive in that it was my first full-blown program in a new language.

FIGURE 1.

N WTBQDFKX  FVNF AE FDXIKJ  TMM

AE HDAFX DFEKUKEE. CTD IKKJ FT

FDXI CTDX *NFNXA TI FT ETUZK

FVKEK QDDOUKE!

Words marked with "*" are proper nouns. The title of the puzzle may be of some help but ...

HINT
The pattern FVNF can only be one word. Check the word list.

FIGURE 2.

A COMPUTER THAT IS TURNED OFF

IS OUITE USELESS. YOU NEED TO

TURN YOUR *ATARI ON TO SOLVE

THESE PUZZLES!

FIGURE 3.
Word List


1. A I
.
2. AN AS AT BE BY DO GO HE HI IF IN IS
   IT ME MY NO OF OH ON DR SO TO US WE

3. ALL AND ANY ARE ATE BAD BIG BUT CAN
   CAT COW DAY DID FAT FOR HAD HAS HER
   HIS HIM HOW KID LAD LIE LOT MAY NOR
   NOT NOW OFF ONE OUR OUT SAD SAY SHE
   SIN SIX SON THE TOO TWO WAS WHO YOU

4. AWAY BOTH CALL COME DOES EVEN FEEL
   FIND FIVE FORM FOUR FROM FULL GOOD
   HAVE IDEA KNEW KEEP KEPT KNOW LESS
   LONG LOSE MANY MESS MORE MUST NEED
   ONCE REAL SAID THAN THAT THEM THEN
   THEY UPON WHEN WILL WITH YEAR YOUR

5. AFTER ALLOW AWARE BRING EVERY GOING
   HAPPY KNOWN LIMIT LOCAL OFTEN OFFER
   PIZZA RULER SIDES STYLE THEIR THERE
   THESE THOSE THREE TOOTH VALUE WHERE

6. ACCEPT COFFEE LADDER LITTLE OFFICE
   PEOPLE PEPPER PLEASE REALLY MATTER

7. ELEMENT GENERAL. HAPPINESS USELESS


Cryptogram
Solver



Listing 1:
M/L Editor data


1000 DATA 255,255,0,64,251,64,76,158,6
9,112,112,66,46,64,0,2,747
1010 DATA 144,2,2,0,2,2,0,2,2,0,2,2,0,
2,2,0,1324
1020 DATA 2,2,0,2,2,0,2,2,0,2,2,144,2,
144,2,0,4916
1030 DATA 2,65,3,64,0,0,0,0,0,33,34,35
,36,37,38,13,4315
1040 DATA 39,40,41,42,43,44,45,13,46,4
7,48,49,50,51,52,13,6700
1050 DATA 53,54,55,56,57,58,0,0,0,0,0,
0,0,0,0,0,2233
1060 DATA  0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1060
1070 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1070
1080 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1080
1090 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1090
1100 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1100
1110 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1110
1120 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1120
1130 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1130
1140 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1140
1150 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1150
1160 DATA 0,0,252,64,247,65,0,0,0,0,0,
35,50,57,48,52,7217
1170 DATA 47,39,50,33,45,0,51,47,44,54
,37,50,0,0,0,0,4478
1180 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1180
1190 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1190
1200 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1200
1210 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1210
1220 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1220
1230 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1230
1240 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1240
1250 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1250
1260 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,98
,121,0,4447
1270 DATA 43,101,118,105,110,0,48,101,
99,107,0,0,0,0,0,0,5944
1280 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,8,1280
1290 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1290
1300 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1300
1310 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1310
1320 DATA 0,0,248,65,243,66,0,0,0,0,0,
0,0,0,0,0,3935
1330 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1330
1340 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1340
1350 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1350
1360 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,48
,114,101,5358
1370 DATA 115,115,0,97,110,121,0,187,1
01,121,0,116,111,0,98,101,2275
1380 DATA 103,105,110,0,0,0,0,0,0,0,0,
0,0,0,0,0,2023
1390 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1390
1400 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1400
1410 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1410
1420 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1420
1430 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1430
1440 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1440
1450 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1450
1460 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1460
1470 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1470
1480 DATA 0,0,244,66,239,67,0,0,0,0,0,
0,0,0,0,0,4073
1490 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1490
1500 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1500
1510 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1510
1520 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1520
1530 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1530
1540 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1540
1550 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1550
1560 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1560
1570 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1576
1580 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1580
1590 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1598
1600 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1600
1610 DATA 0,0,0,0,0,0,0,0,0,0,0,53,115
,101,0,128,7203
1620 DATA 163,172,165,161,178,128,0,12
8,169,174,179,165,178,180,128,0,9912
1630 DATA 128,164,165,172,165,180,165,
128,0,93,92,94,95,0,0,0,1658
1640 DATA 0,0,240,67,101,68,0,0,0,0,0,
128,162,171,128,179,4361
1650 DATA 176,128,0,128,178,165,180,18
1,178,174,128,0,116,111,0,101,6610
1660 DATA 110,116,181,114,0,116,181,12
8,116,0,0,0,0,0,128,163,696
1670 DATA 180,178,172,128,0,0,0,128,16
2,128,97,99,107,0,0,0,642
1680 DATA 0,128,163,128,108,101,97,114
,0,0,0,128,165,128,100,105,4327
1690 DATA 116,0,0,0,0,0,128,171,165,18
5,179,128,0,0,0,128,2958
1700 DATA 174,128,101,119,0,0,0,0,0,12
8,177,128,117,105,116,0,2403
1710 DATA 0,0,0,128,181,128,110,100,11
1,0,0,0,196,68,191,69,3933
1720 DATA 50,101,112,108,97,99,101,30,
55,105,116,104,30,48,114,101,3223
1730 DATA 115,115,0,128,179,180,161,17
8,180,128,0,119,104,101,110,0,5857
1740 DATA 100,111,110,101,35,108,101,9
7,114,0,48,117,122,122,108,101,4590
1750 DATA 0,52,101,120,116,31,35,108,1
01,97,114,0,33,108,108,0,1206
1760 DATA 35,184,97,110,103,101,115,31
,33,114,101,0,121,111,117,0,2338
1770 DATA 115,117,114,101,0,8,57,15,46
,9,0,0,0,0,128,165,8496
1780 DATA 228,233,244,233,238,231,128,
176,245,250,250,236,229,128,164,225,13
4
1790 DATA 244,225,128,0,0,0,0,49,117,1
05,116,12,0,37,120,105,781
1800 DATA 116,0,116,111,0,36,47,51,31,
51,116,97,114,116,0,46,732
1810 DATA 101,119,0,48,117,122,122,108
,101,31,0,44,97,115,116,0,1734
1820 DATA 35,104,97,110,103,181,0,53,4
6,36,47,46,37,14,69,58,8822
1830 DATA 155,38,31,255,128,48,2,72,13
8,72,173,11,212,201,40,176,7659
1840 DATA 5,162,255,142,119,69,174,119
69,232,189,120,69,141,10,212,9554
1850 DATA 141,24,208,142,119,69,184,17
0,104,64,173,254,254,201,108,208,3919
1860 DATA 6,169,254,133,121,133,122,16
2,32,169,3,157,66,3,169,114,6205
1870 DATA 157,68,3,169,69,157,69,3,169
,12,157,74,192,69,203,69,6509
1880 DATA 3,169,0,157,75,3,32,86,228,7
6,154,70,204,69,199,70,7223
1890 DATA 162,39,189,198,67,157,118,67
,189,238,67,157,158,67,202,16,9108
1900 DATA 241,32,234,73,169,1,133,85,1
69,3,133,84,141,240,2,169,7610
1910 DATA 32,32,189,72,162,28,189,30,6
9,157,91,64,202 16,247,169,8621
1920 DATA 0,141,240,2,32,34,72,32,3,72
,162,22,189,209,68,157,5762
1930 DATA 86,67,202,16,247,173,31,208,
201,6,208,3,76,227,70,169,9087
1940 DATA 8,141,31,288,173,252,2,201,2
55,240,234,32,167,73,201,155,3495
1950 DATA 208,3,76,84,72,201,156,208,3
,76,209,72,201,157,208,3,8979
1960 DATA 76,24,73,201,254,240,45,201,
255,208,3,76,113,73,201,125,566
1970 DATA 208,3,76,14,74,201,126,240,2
7,41,127,201,28,144,182,201,9634
1980 DATA 32,144,2,176,3,76,107,72,201
,96,240,169,144,6,281,123,9182
1990 DATA 176,163,233,31,32,189,72,165
,85,201,38,208,162,165,84,281,1014
2000 DATA 19,208,10,169,37,133,85,32,3
,72,76,17,70,169,1,133,2181
2010 DATA 85,24,165,84,105,2,133,84,32
,3,72,76,17,70,169,0,872
2020 DATA 141,47,2,169,192,141,14,212,
169,123,141,0,2,169,69,141,6522
2030 DATA 1,2,169,3,141,48,2,169,64,14
1,49,2,169,0,141,200,4974
2040 DATA 2,169,192_,141,198,2,169,34,1
41,47,2,169,200,70,195,71,7407
2050 DATA 46,133,88,169,64,133,89,169,
255,141,252,2,173,252,2,201,1919
2060 DATA 255,240,249,169,255,141,252,
2,32,111,74,169,1,141,240,2,7978
2070 DATA 169,19,133,84,169,38,133,85,
169,32,32,189,72,162,39,189,6970

2080 DATA 22,68,157,118,67,189,62,68,1
57,158,67,169,0,157,86,64,5898
2090 DATA 202,16,236,32,86,75,32,34,72
,162,7,189,196,68,157,80,6284
2100 DATA 67,202,16,247,162,0,169,78,1
57,88,67,142,195,68,32,180,7805
2110 DATA 71,174,195,68,201,2,240,243,
201,32,240,239,201,155,208,6,3663
2120 DATA 224,0,240,231,208,28,281,126
,208,12,224,0,240,221,169,0,816
2130 DATA 157,88,67,202,16,208,224,11,
240,209,233,31,157,88,67,232,1631
2140 DATA 208,196,142,195,68,169,0,157
,88,67,162,4,189,204,68,157,8693
2150 DATA 101,67,202,16,247,162,0,169,
78,157,106,67,142,168,68,32,6586
2160 DATA 180,71,174,168,68,201,32,240
,38,201,2,208,3,76,79,76,5740
2170 DATA 281,155,208,11,169,0,157,106
,67,32,195,75,76,14,71,201,5574
2180 DATA 126,208,12,224,0,240,213,169
,0,157,106,67,202,16,200,236,1103
2190 DATA 195,68,240,200,233,31,157,10
6,67,232,208,187,32,167,73,201,1859
2200 DATA 126,208,1,96,201,155,208,1,9
6,201,2,208,196,71,191,72,9479
2210 DATA 1,96,201,32,208,1,96,201,3,2
88,3,76,193,73,201,5,6138
2220 DATA 208,5,104,104,76,284,69,281,
14,208,3,76,81,74,201,17,5388
2230 DATA 208,3,76,173,74,201,21,208,3
,76,29,75,281,65,144,192,7512
2240 DATA 281,91,144,10,201,123,176,18
4,201,97,144,180,233,32,96,162,1574
2250 DATA 32,169,11,157,66,3,169,117,1
57,68,3,169,69,157,69,3,4080
2260 DATA 169,2 157,72,3,169,0,157,73,
3,32,86,228,96,169,0,4391
2270 DATA 162,39,157,78,67,202,16,258,
96,162,18,189,12,69,157,98,6947
2280 DATA 67,282,16,247,32,167,73,160,
0,41,127,201,78,240,14,201,8759
2290 DATA 118,240,10,201,89,240,8,201,
121,208,233,240,2,160,1,96,9692
2300 DATA 165,84,201,19,208,3,76,204,6
9,230,84,230,84,169,2,133,8755
2310 DATA 85,32,3,72,76,17,70,201,28,2
40,24,201,29,240,36,201,8157
2320 DATA 30,240,48,164,85,192,37,208,
61,160,2,132,85,32,3,72,3635
2330 DATA 76,17,70,164 84,192,3,208,42
,160,19,132,84,32,3,72,3071
2340 DATA 76,17,70,164,84,192,19,208,2
6,160,3,132,84,32,3,72,2873
2350 DATA 76,17,70,164,85,192,2,208,13
,160,37,132,85,32,3,72,3039
2360 DATA 76,17,70,32,189,72,76,112,70
,72,162,32,192,72,187,73,6606
2370 DATA 169,11,157,66,3,169,0,157,72
,3,157,73,3,104,76,86,2873
2380 DATA 228,32,127,73,166,84,165,203
24,105,80,133,205,165,204,105,915
2390 DATA 0,133,206,232,232,224,21,240
,19,160,39,177,205,145,203,136,3813
2400 DATA 208,249,165,205,133,203,165,
206,133,204,208,218,160,39,169,0,2409
2410 DATA 145,203,136,208,251,169,2,13
3,85,32,127,73,160,2,177,203,8917
2420 DATA 133,93,32,3,72,76,17,70,166,
84,224,19,240,56,169,1,5823
2430 DATA 141,240,2,32,3,72,169,38,133
,203,169,67,133,204,162,21,8360
2440 DATA 202,202,228,84,240,32,165,20
3,56,233,80,133,205,165,204,233,5310
2450 DATA 0,133,206,160,39,177,205,145
203,136,208,249,165,205,133,203,6547
2460 DATA 165,206,133,204,208,218,32,1
27,73,160,39,169,0,133,93,141,8067
2470 DATA 240,2,145,203,136,208,251,16
9,2,133,85,32,3,72,76,17,4124
2480 DATA 70,72,32,127,73,169,0,160,36
,145,203,104,76,112,70,166,7474
2490 DATA 84,165,88,133,203,165,89,133
,204,165,203,24,105,40,133,203,567
2500 DATA 165,204,105,0,133,204,202,20
8,240,96,169,8,141,31,208,173,1585
2510 DATA 31,208,201,6,208,244,96,169,
64,141,190,2,169,0,141,182,9436

2520 DATA 2,173,252,2,201,255,240,249,
168,169,255,141,188,73,183,74,4933
2530 DATA 252,2,177,121,96,32,171,75,3
2,34,72,162,17,189,250,68,7339
2540 DATA 157,79,67,202,16,247,32,45,7
2,192,1,208,6,32,183,75,5556
2550 DATA 76,iB0,71,32,234,73,32,159,7
4,104,104,76,227,70,169,126,8675
2560 DATA 133,263,169,64,133,204,162,9
,169,0,160,39,145,203,136,16,7729
2570 DATA 251,165,203,24,105,80,133,20
3,165,204,105,0,133,204,202,208,3039
2580 DATA 231,96,32,34,72,162,17,189,2
32,68,157,79,67,202,16,247,9532
2590 DATA 32,45,72,192,1,208,3,76,251,
69,165,88,24,105,120,133,7108
2600 DATA 203,165,89,105,0,133,204,162
,9,169,0,166,39,145,203,136,8791
2610 DATA 16,251,165,203,24,105,80,133
,203,165,204,105,0,133,204,202,1944
2620 DATA 268,231,76,204,69,32,171,75,
32,34,72,162,17,189,77,69,5158
2630 DATA 157,79,67,202,16,247,32,45,7
2,192,1,208,6,32,183,75,5646
2640 DATA 76,180,71,104,104,165,88,24,
105,40,133,203,165,89,105,0,6233
2650 DATA 133,204,162,19,169,0,160,39,
145,203,136,16,251,165,203,24,55
2660 DATA 105,40,133,203,165,204,105,0
,133,204,202,288,231,32,159,74,1815
2670 DATA 76,204,69,162,26,169,0,157,1
02,6,,157,169,68,202,16,247,9666
2680 DATA 96,32,171,75,32,34,72,162,17
,189,59,69,184,74,179,75,6650
2690 DATA 157,79,67,202,16,247,32,45,7
2,192,1,208,6,32,183,75,5706
2700 DATA 76,180,71,104,104,162,16,169
,12,157,66,3,32,86,228,162,6793
2710 DATA 32,169,12,157,66,3,32,86,228
,169,64,141,14,212,173,229,551

2720 DATA 2,24,105,1,141,48,2,133,203,
173,230,2,141,49,2,133,5948
2730 DATA 204,160,4,177,203,133,88,200
,177,203,133,89,169,0,141,240,2309
2740 DATA 2,169,148,141,198,2,169,202,
141,197,2,169,2,133,85,169,9045
2750 DATA 12,141,252,2,96,32,171,75,32
,34,72,162,18,189,95,69,5050
2760 DATA 157,88,67,202,16,247,162,25,
189,169,68,72,189,102,68,157,9418
2770 DATA 169,68,104,157,102,68,202,16
,239,32,86,75,169,0,133,19,5288
2780 DATA 133,20,165,20,201,100,208,25
0,32,183,75,76,180,71,32,240,98
2790 DATA 75,169,126,133,203,169,64,13
3,204,169,9,141,168,68,160,2,8539
2800 DATA 24,165,203,105,40,133,205,16
5,204,105,0,133,206,177,205,201,3865

2810 DATA 0,240,24,201,33,176,7,9,128,
145,203,76,147,75,56,233,8704
2820 DATA 33,170,189,102,68,281,0,288,
238,240,238,200,192,38,208,221,6622
2830 DATA 24,165,203,105,80,133,203,16
5,204,105,0,133,204,206,168,68,1778
2840 DATA 208,188,96,162,39,189,78,67,
157,128,68,202,180,75,94,76,8652
2850 DATA 16,247,96,162,39,189,128,68,
157,78,67,202,16,247,96,162,117
2860 DATA 25,189,102,68,157,169,68,202
,16,247,174,195,68,202,138,168,3070
2870 DATA 189,106,67,141,168,68,56,189
,88,67,233,33,170,173,168,68,9849
2880 DATA 157,102,68,152,170,202,16,23
0,32,86,75,96,162,25,160,33,6576
2890 DATA 189,102,68,201,0,240,2,9,128
,153,86,64,202,136,192,27,8055
2900 DATA 208,238,169,13,153,86,64,136
,189,102,68,201,0,240,2,9,6375
2910 DATA 128,153,86,64,202,136,192,19
,208,238,169,13,153,86,64,136,9776
2920 DATA 189,102,68,201,0,240,2,9,128
,153,86,64,202,136,192,11,7829
2930 DATA 208,238,169,13,153,86,64,136
,189,102,68,201,0,240,2,9,6405
2940 DATA 128,153,86,64,202,136,192,4,
208,238,96,169,0,162,16,157,9446
2950 DATA 101,67,202,16,250,174,195,68
,76,30,71,224,2,225,2,0,5717
2960 DATA 64,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,3024


Listig 2:
Assembly


10       .OPT NO LIST
20       .OPT OBJ
30       .TITLE      CRYPTOGRAM SOLVER
40 ;
50       *=  $8000
60 ;
70 START JMP OPNKYSCR
80 ;
90       .INCLUDE #D:CRYPT02.M65
0100 ;
0110 ;
0120 ENTERTEXT
0130 ;
0140     LDX #39
0150 DSPELN
0160     LDA ELN1,X
0170     STA PMPTLINE+40,X
0180     LDA ELN2,X
0190     STA PMPTLINE+80,X
0200     DEX
0210     BPL DSPELN
0220     JSR CHNGCLRS
0230     LDA #1      ;set row and
0240     STA COLCRS  ;col for entry
0250     LDA #3      ;upper-left
0260     STA ROWCRS  ;pos of entry
0270     STA CRSINH
0280     LDA #32
0290     JSR PRNTCHR
0300     LDX #28
0310 Wl  LDA EDTPMPT,X
0320     STA REPLINE+5,X
0330     DEX
0340     BPL W1
0350 ;
0360 SAYSTART
0370     LDA #0
0380     STA CRSINH
0390     JSR CLRPRMPT
0400     JSR MVECRS
0410     LDH #22
0420 W2  LDA ENTPMPT,X
0430     STA PMPTLINE+8,X
0440     DEX
0450     BPL W2
0460 GETKEY
0470     LDA CONSOL   ;read console
0480     CMP #6       ;if START
0490     BNE GETKEY2
0500     JMP ENTERDONE ;then DONE
0510 GETKEY2
0520     LDA #8      ;RESET console
0530     STA CONSOL
0540     LDA KEYPRS
0550     CMP #$FF
0560     BEQ GETKEY
0570 GETIT
0580     JSR GETLET
0590     CMP #$9B   ;RETURN?
0600     BNE G1
0610     JMP RTN
0620 G1  CMP #$9C   ;DEL LINE?
0630     BNE G2
0640     JMP DELINE
0650 G2  CMP #$9D
0660     BNE G3
0670     JMP INLINE
0680 G3  CMP #$FE   ;DEL CHR?
0690     BEQ PRNTIT
0700     CMP #$FF
0710     BNE G4
0720     JMP INSCHR
0730 G4  CMP #$7D   ;CLS issued
0740     BNE G5
0750     JMP CLREDT
0760 G5  CMP #$7E
0770     BEQ PRNTIT
0780     AND #$7F   ;turn off HI bit
0790     CMP #$1C
0800     BCC GETKEY
0810     CMP #$20
0820     BCC CC
0830     BCS G6
0840 CC  JMP CRSCTRL
0850 G6  CMP #$60
0860     BEQ GETKEY
0870     BCC PRNTIT
0880     CMP #$78
0890     BCS GETKEY
0900     SBC #$IF
0910 PRNTIT JSR PRNTCHR
0920     LDA COLORS
0930     CMP #38
0940     BNE GETKEY2
0950     LDA ROWCRS
0960     CMP #19
0970     BNE NXTLINE
0980     LDA #37
0990     STA COLORS
1000     JSR MVECRS
1010     JMP GETKEY
1020 NXTLINE
1030     LDA #1
1040     STA COLORS
1050     CLC
1060     LDA ROWCRS
1070     ADC #2
1080     STA ROWCRS
1090     JSR MVECRS
1100     JMP GETKEY
1110 ;
1120 ;-----------------------
1130 ; Set the Shown screen
1140 ; and the write to
1150 ; screen to the main
1160 ; puzzle entry screen
1170 ;-----------------------
1180 ;
1190 SETMAIN
1200     LDA #8     ;Screen off
1210     STA DMA
1220     LDA #192
1230     STA DLIENA
1240     LDA # <DLI1 ;Activate
1250     STA DLIVEC  ;DLI 1
1260     LDA # >DLI1
1270     STA DLIVEC+1
1280     LDA # <DLST1 ;and DLIST 1
1290     STA DLI
1300     LDA # >DLST1
1310     STA DLI+1
1320     LDA #0     ;reset colors
1330     STA BRD
1340     LDA #192
1350     STA BCK
1360     LDA #34    ;and screen
1370     STA DMA
1380     LDA # <MANSCR
1390     STA SCREEN
1400     LDA # >MANSCR
1410     STA SCREEN+1
1420     LDA #255
1430     STA KEYPRS
1440 WTKEY
1450     LDA KEYPRS
1460     CMP #255
1465     BEQ WTKEY
1470     LDA #255
1480     STA KEYPRS
1490     JSR DONEW
1500 ;
1510 ;---------------------------
1520 ; The START key has been
1530 ; pressed and we are ready
1540 ; to start solving the
1550 ; puzzle. We have to put
1560 ; the CNTRL prompts on the
1570 ; bottom of the screen and
1580 ; ask for the puzzle lettrs
1590 ; on the prompt line.
1600 ;---------------------------
1610 ;
1620 ENTERDONE
1630     LDA #l
1640     STA CRSINH
1650     LDA #19
1660     STA ROWCRS
1670     LDA #38
1680     STA COLORS
1690     LDA #32
1700     JSR PRNTCHR
1710     LDX #39
1720 E2  LDA CMD1,X
1730     STA PMPTLINE+40,X
1740     LDA CMD2,X
1750     STA PMPTLINE+80,X
1760     LDA #0
1770     STA REPLINE,X
1780     DEX
1790     BPL E2
1800     JSR DOREP
1810 ;
1820 ;---------------------------
1830 ; The CNTRL commands are now
1840 ; on the screen. Time to
1850 ; clear the prompt line and
1860 ; put up the REPLACE> prompt
1870 ; for the user to start
1880 ; entering text.
1890 ;---------------------------
1900 ;
1910 PRNTREP
1920     JSR CLRPRMPT
1930     LDX #7
1940 El  LDA REPPMPT,X
1950     STA PMPTLINE+2,X
1960     DEX
1970     BPL E1
1980     LDX #0
1990 PRNTCHS
2000     LDA #$4E
2010     STA REPLCHRS,X
2020 GETMORE
2030     STX REPLEN
2040     JSR GETEM
2050     LDX REPLEN
2060     CMP #$02
2070     BEQ GETMORE
2080     CMP #$20
2090     BEQ GETMORE
2100     CMP #$9B
2110     BNE GE24
2120     CPX #0
2130     BEQ GETMORE
2140     BNE GETWITH
2150 GE24
2160     CMP #$7E
2170     BNE SHOWREPCHR
2180     CPX #0
2190     BEQ GETMORE
2200 BCKREP
2210     LDA #0
2220     STA REPLCHRS,X
2230     DEX
2240     BPL PRNTCRS
2250 SHOWREPCHR
2260     CPX #11
2270     BEQ GETMORE
2280     SBC #$IF
2290     STA REPLCHRS,X
2300     INX
2310     BNE PRNTCRS
2320 ;
2330 ;--------------------------
2340 ; This will print the WITH>
2350 ; prompt on the screen and
2360 ; get the replacement chars
2370 ; up to the length of the
2380 ; puzzle chrs and then wait
2390 ; for the RETURN or BK SP
2400 ; key to be pressed. The
2410 ; CNTRL-B is now valid and
2420 ; will have to be dealt with
2430 ; too.
2440 ;---------------------------
2450 ;
2460 GETWITH
2470     STX REPLEN
2480     LDA #0
2490     STA REPLCHRS,X
2500     LDX #4
2510 PRNWITH LDA WTHPMPT,X
2520     STA WITHCHRS-5,X
2530     DEX
2540     BPL PRNWITH
2550     LOX #0
2560 PRNWCRS
2570     LOA #$4E
2580     STA WITHCHRS,X
2590 GETWLET
2600     STX ROWTMP
2610     JSR GETEM
2620     LDX ROWTMP
2630     CMP #$20
2640     BEQ WPRNT
2650     CMP #$02
2660     BNE GW5
2670     JMP BCKTOREP
2680 GW5
2690     CMP #$9B
2700     BNE GET2
2710 FINENT
2720     LDA #0
2730     STA WITHCHRS,X
2740     JSR STOREREP
2750     JMP PRNTREP
2760 GET2 CMP #$7E
2770     BNE WPRNT
2780     CPX #0
2790     BEQ GETWLET
2800 GETBACK
2810     LDA #0
2820     STA WITHCHRS,X
2830     DEX
2840     BPL PRNWCRS
2850 WPRNT
2860     CPX REPLEN
2870     BEQ GETWLET
2880     SBC #$1F
2890     STA WITHCHRS,X
2900     INX
2910     BNE PRNWCRS
2920 ;
2930 ;-----------------------------
2940 ; This is where we enter the
2950 ; puzzle lettrs to be changed
2960 ;-----------------------------
2970 ;
2980 GETEM
2990     JSR GETLET
3000     CMP #$7E
3010     BNE GE10
3020     RTS
3030 GE10 CMP #$9B
3040     BNE GE11
3050     RTS
3060 GE11 CMP #$02
3070     BNE GE12
3080     RTS
3090 GE12 CMP #$20
3100     BNE GE1
3110     RTS
3120 GEL CMP #$03
3130     BNE GE2
3140     JMP CLRCHG
3150 GE2 CMP #$05
3160     BNE GE4
3170     PLA
3180     PLA
3190     JMP ENTERTEXT
3200 GE4 CMP #$0E
3210     BNE GE5
3220     JMP NEWPUZ
3230 GE5 CMP #$11
3240     BNE GE6
3250     JMP QUIT
3260 GE6 CMP #$15
3270     BNE GE8
3280     JMP UNDOIT
3290 GE8 CMP #$41
3300     BCC GETEM
3310     CMP #$5B
3320     BCC ISOK
3330     CMP #$7B
3340     BCS GETEM
3350     CMP #$61
3360     BCC GETEM
3370     SBC #$20
3380 ISOK
3390     RTS
3400 ;
3410 ;---------------------------
3420 ; Move the cursor so it will
3430 ; show up on the screen
3440 ; after inhibiting it.
3450 ;---------------------------
3460 ;
3470 MUECRS
3480     LDX #$20
3490     LDA #PUTCHR
3500     STA ICCMD,X
3510     LDA # <LFRT
3520     STA ICBAL,X
3530     LDA # >LFRT
3540     STA ICBAH,X
3550     LDA #2
3560     STA ICBLL,X
3570     LDA #0
3580     STA ICBLH,X
3590     JSR CIOV
3600     RTS
3610 ;
3620 ;-------------------
3630 ;    Clear the prompt
3640 ;    line on Main
3650 ;    entry screen.
3660 ;-------------------
3670 ;
3680 CLRPRMPT
3690     LDA #0
3700     LDX #39
3710 CLR1
3720     STA PMPTLINE,X
3730     DEX
3740     BPL CLR1
3750     RTS
3760 ;
3770 ;--------------------
3780 ; Confirm the Clear
3790 ; Screen command.
3800 ;--------------------
3810 ;
3820 CHKSURE
3830     LDX #18
3840 S1  LDA AYSPMPT,X
3850     STA PMPTLINE+20,X
3860     DEX
3870     BPL S1
3880 GETYN
3890     JSR GETLET
3900     LDY #0
3910     AND #127
3920     CMP #'N
3930     BEQ NOSURE
3940     CMP #'n
3950     BEQ NOSURE
3960     CMP #'Y
3970     BEQ ISSURE
3980     CMP #'y
3990     BNE GETYN
4000     BEQ ISSURE
4010 NOSURE
4020     LDY #1
4030 ISSURE
4040     RTS
4050 ;
4060 ;--------------------------
4070 ; We make it here if the
4080 ; RETURN key was pressed
4090 ; We will have to jump
4100 ; down 2 lines unless we
4110 ; are on the last line in
4120 ; which case we will have
4130 ; to return to the top line
4140 ;--------------------------
4150 ;
4160 RTN
4170     LDA ROWCRS
4180     CMP #19
4190     BNE R1
4200     JMP ENTERTEXT
4210 R1  INC ROWCRS
4220     INC ROWCRS
4230     LDA #2
4240     STA COLCRS
4250     JSR MVECRS
4260     JMP GETKEY
4270 ;
4280 ;----------------------------
4290 ; This is where we end up
4300 ; if one of the cursor
4310 ; control keys is pressed.
4320 ; We will move in the desired
4330 ; direction with full wrap-
4340 ; around where required.
4350 ;----------------------------
4360 ;
4370 CRSCTRL
4380     CMP #$1C
4390     BEQ CRSUP
4400     CMP #$1D
4410     BEQ CRSDN
4420     CMP #$1E
4430     BEQ CRSLT
4440 ;
4450 ; A cursor right will fall in
4460 ; to this part of routine.
4470 ;
4480     LDY COLCRS
4490     CPY #37
4500     BNE CRSDONE
4510     LDY #2
4520     STY COLCRS
4530     JSR MVECRS
4540     JMP GETKEY
4550 ;
4560 CRSUP
4570     LDY ROWCRS
4580     CPY #3
4590     BNE CRSDONED
4600     LDY #19
4610     STY ROWCRS
4620     JSR MVECRS
4630     JMP GETKEY
4640 ;
4650 CRSDN
4660     LDY ROWCRS
4670     CPY #19
4680     BNE CRSDONED
4690     LDY #3
4700     STY ROWCRS
4710     JSR MVECRS
4720     JMP GETKEY
4730 ;
4740 CRSLT
4750     LDY COLCRS
4760     CPY #2
4770     BNE CRSDONE
4780     LDY #37
4790     STY COLCRS
4800     JSR MVECRS
4810     JMP GETKEY
4820 ;
4830 CRSDONED
4840     JSR PRNTCHR  ;Do double
4850 CRSDONE
4860     JMP PRNTIT   ;print.
4870 ;
4880 ;---------------------------
4890 ; This routine will print a
4900 ; single character stored in
4910 ; the Accumulator
4920 ;---------------------------
4930 ;
4940 PRNTCHR
4950     PHA
4960     LDX #$20
4970     LDA #PUTCHR
4980     STA ICCMD,X
4990     LDA #0
5000     STA ICBLL,X
5010     STA ICBLH,X
5020     PLA
5030     JMP CIOV     ;auto return
5040 ;
5050 ;--------------------------
5060 ; Delete a line of puzzle
5070 ; text from the screen.
5080 ; Move all lines below this
5090 ; line up one and erase the
5100 ; last puzzle text line
5110 ; completely.
5120 ;--------------------------
5130 ;
5140 DELINE
5150    JSR FINDLINE
5160     LDX ROWCRS
5170 D1  LDA ZSCR
5180     CLC
5190     ADC #80
5200     STA ZSCR1
5210     LDA ZSCR+1
5220     ADC #0
5230     STA ZSCR1+1
5240     INX
5250     INK
5260     CPX #21
5270     BEQ DBLNK
5280     LDY #39
5290 D2  LDA CZSCRI),Y
5300     STA (ZSCR),Y
5310     DEY
5320     BNE D2
5330     LDA ZSCR1
5340     STA ZSCR
5350     LDA ZSCR1+1
5360     STA ZSCR+1
5370     BNE D1
5380 DBLNK LDY #39
5390     LDA #0
5400 D3  STA (ZSCR),Y
5410     DEY
5420     BNE D3
5430     LDA #2
5440     STA COLCRS
5450     JSR FINDLINE
5460     LDY #2
5470     LDA (ZSCR),Y
5480     STA OLDCHR
5490     JSR MVECRS
5500     JMP GETKEY
5510 ;
5520 ;---------------------------
5530 ; Insert a blank puzzle
5540 ; line on the screen by
5550 ; Moving this line and all
5560 ; others below it down one
5570 ; Fill this line with blanks
5580 ;---------------------------
5590 ;
5600 INLINE
5610     LDX ROWCRS
5620     CPX #19
5630     BEQ IBLNK
5640     LDA #1
5650     STA CRSINH
5660     JSR MVECRS
5670     LDA # <LINE19
5680     STA ZSCR
5690     LDA # >LINE19
5700     STA ZSCR+1
5710     LDX #21
5720 I1  DEX
5730     DEX
5740     CPX ROWCRS
5750     BEQ IBLNK
5760     LDA ZSCR
5770     SEC
5780     SBC #80
5790     STA ZSCR1
5800     LDA ZSCR+1
5810     SBC #0
5820     STA ZSCR1+1
5830     LDY #39
5840 I2  LDA (ZSCR1),Y
5850     STA (ZSCR),Y
5860     DEY
5870     BNE I2
5880     LDA ZSCR1
5890     STA ZSCR
5900     LDA ZSCR1+1
5910     STA ZSCR+1
5920     BNE I1
5930 IBLNK JSR FINDLINE
5940     LDY #39
5950     LDA #0
5960     STA OLDCHR
5970     STA CRSINH
5980 I3  STA (ZSCR),Y
5990     DEY
6000     BNE I3
6010     LDA #2
6020     STA COLCRS
6030     JSR MVECRS
6040     JMP GETKEY
6050 ;
6060 ;--------------------------
6070 ; Insert a character at the
6080 ; cursor position. Delete
6090 ; the last character on the
6100 ; line also.
6110 ;--------------------------
6120 ;
6130 INSCHR
6140     PHA
6150     JSR FINDLINE
6160     LDA #0
6170     LDY #36
6180     STA (ZSCR),Y
6190     PLA
6200     JMP PRNTIT
6210 ;
6220 ;-------------------------
6230 ; Find the current line of
6240 ; text on the screen. It
6250 ; will be found in ZSCR
6260 ; when we are done here.
6270 ;-------------------------
6280 ;
6290 FINDLINE
6300     LDX ROWCRS
6310     LDA SCREEN
6320     STA ZSCR
6330     LDA SCREEN+1
6340     STA ZSCR+1
6350 F1  LDA ZSCR
6360     CLC
6370     ADC #40
6380     STA ZSCR
6390     LDA ZSCR+1
6400     ADC #0
6410     STA ZSCR+1
6420     DEX
6430     BNE F1
6440     RTS
6450 ;
6460 ;---------------------------
6470 ; This routine will wait and
6480 ; do nothing until START is
6490 ; pressed.
6500 ;---------------------------
6510 ;
6520 PRSSTRT
6530     LDA #8       ;reset CONSOLE
6540     STA CONSOL   ;keys with 8
6550     LDA CONSOL   ;now read key
6560     CMP #6       ;6=START
6570     BNE PRSSTRT  ;not yet!
6580     RTS          ;got it. RETURN
6590 ;
6600 ;----------------------------
6610 ; This routine locks on CAPS
6620 ; and turns off INVERSE and
6630 ; then gets one key from the
6640 ; keyboard. The calling
6650 ; routine will have to do
6660 ; the range checks.
6670 ;----------------------------
6680 ;
6690 GETLET
6700     LDA #64     ;UPPERCASE
6710     STA SHFLOK  ;lock
6720     LDA #0      ;INVERSE
6730     STA INVFLG  ;off
6740 NOPRS
6750     LDA KEYPRS
6760     CMP #$FF
6770     BEQ NOPRS
6780     TAY
6790     LDA #$FF
6800     STA KEYPRS
6810     LDA ($79),Y
6820     RTS
6830 ;
6840 ;---------------------------
6850 ; We come here when the user
6860 ; wants to clear out all
6870 ; changes to the puzzle.
6880 ;---------------------------
6890 ;
6900 CLRCHG
6910     JSR SVEPMPT
6920     JSR CLRPRMPT
6930     LDX #17
6940 CL  LDA CCGPMPT,X
6950     STA PMPTLINE+1,X
6960     DEX
6970     BPL CL
6980     JSR CHKSURE
6990     CPY #1
7000     BNE CP
7010     JSR RSTPMPT
7020     JMP GETEM
7030 CP  JSR CHNGCLRS
7040     JSR CLRBUF
7050     PLA
7060     PLA
7070     JMP ENTERDONE
7080 ;
7090 ; Clear the changes line
7100 ;
7110 CHNGCLRS
7120     LDA # <FRSTLINE
7130     STA ZSCR
7140     LDA # >FRSTLINE
7150     STA ZSCR+1
7160     LDX #9
7170 CP1 LDA #0
7180     LDY #39
7190 CP2 STA (ZSCR),Y
7200     DEY
7210     BPL CP2
7220     LDA ZSCR
7230     CLC
7240     ADC #80
7250     STA ZSCR
7260     LDA ZSCR+1
7270     ADC #0
7280     STA ZSCR+1
7290     DEX
7300     BNE CPI
7310     RTS
7320 ;
7330 ;----------------------------
7340 ; We make it here when the
7350 ; user wants to clear out the
7360 ; edit screen.
7370 ;----------------------------
7380 ;
7390 CLREDT
7400     JSR CLRPRMPT
7410     LDX #17
7420 CE10 LDA CPZPMPT,X
7430     STA PMPTLINE+1,X
7440     DEX
7450     BPL CE10
7460     JSR CHKSURE
7470     CPY #1
7480     BNE CE
7490     JMP SAYSTART
7500 CE  LDA SCREEN
7510     CLC
7520     ADC #120
7530     STA ZSCR
7540     LDA SCREEN+1
7550     ADC #0
7560     STA ZSCR+1
7570     LDX #9
7580 CLRLINE
7590     LDA #0
7600     LDY #39
7610 NL
7620     STA (ZSCR),Y
7630     DEY
7640     BPL ML
7650     LDA ZSCR
7660     CLC
7670     ADC #80
7680     STA ZSCR
7690     LDA ZSCR+1
7700     ADC #0
7710     STA ZSCR+1
7720     DEX
7730     BNE CLRLINE
7740     JMP ENTERTEXT
7750 ;
7760 ;----------------------------
7770 ; The user wants to start a
7780 ; new puzzle. We have to
7790 ; prompt the user to be sure
7800 ; of this.
7810 ;----------------------------
7820 ;
7830 NEWPUZ
7840     JSR SVEPMPT
7850     JSR CLRPRMPT
7860     LDX #17
7870 NP1 LDA NEWPMPT,X
7880     STA PMPTLINE+1,X
7890     DEX
7900     BPL NP1
7910     JSR CHKSURE
7920     CPY #1
7930     BNE DONEW
7940     JSR RSTPMPT
7950     JMP GETEM
7960 DONEW
7970     PLA
7980     PLA
7996     LDA SCREEN
8000     CLC
8010     ADC #40
8020     STA ZSCR
8030     LDA SCREEN+1
8040     ADC #0
8050     STA ZSCR+1
8060 ;
8070 ;------------------------
8080 ; Clear the entire screen
8090 ;------------------------
8100 ;
8110     LDX #19
8120 DO1 LDA #0
8130     LDY #39
8140 DO2 STA (ZSCR),Y
8150     DEY
8160     BPL DO2
8170     LDA ZSCR
8180     CLC
8190     ADC #40
8200     STA ZSCR
8210     LDA ZSCR+1
8220     ADC #0
8230     STA ZSCR+1
8240     DEX
8250     BNE DO1
8260     JSR CLRBUF
8270     JMP ENTERTEXT
8280 ;
8290 ;-----------------------
8300 ; Clear the replacement
8310 ; letter buffers.
8320 ;-----------------------
8330 ;
8340 CLRBUF
8350     LDX #26
8360     LDA #0
8370 DO3 STA REPSET,X
8380     STA UNDOBUF,X
8390     DEX
8400     BPL DO3
8410     RTS
8420 ;
8430 ;-------------------------------
8440 ; This routine will QUIT the
8450 ; puzzle after prompting the
8460 ; user and then exit to DOS
8470 ;-------------------------------
8480 ;
8490 QUIT
8500     JSR SVEPMPT
8510     JSR CLRPRMPT
8520     LDX #17
8530 Q1  LDA QUTPMPT,X
8540     STA PMPTLINE+1,X
8550     DEX
8560     BPL Q1
8570     JSR CHKSURE
8580     CPY #1
8590     BNE EXIT
8600     JSR RSTPMPT
8610     JMP GETEM
8620 EXIT
8630     PLA
8640     PLA
8650     LDX #$10
8660     LDA #$0C
8670     STA ICCMD,X
8680     JSR CIOV
8690     LDX #$20
8700     LDA #$0C
8710     STA ICCMD,X
8720     JSR CIOV
8730     LDA #64
8740     STA DLIENA
8750     LDA 741
8760     CLC
8770     ADC #1
8780     STA 560
8790     STA ZSCR
8800     LDA 742
8810     STA 561
8820     STA ZSCR+1
8830     LDY #4
8840     LDA (ZSCR),Y
8850     STA 88
8860     INY
8870     LDA (ZSCR),Y
8880     STA 89
8890     LDA #0
8900     STA CRSINH
8910     LDA #$94
8920     STA BCK
8930     LDA #$CA
8940     STA LUM
8950     LDA #2
8960     STA COLCRS
8970     LDA $12
8980     STA KEYPRS
8990     RTS
9000 ;
9010 ;-----------------------------
9020 ; We need to UNDO the last
9030 ; change made by the user. We
9040 ; will have to swap the old
9050 ; rep buffer with the current
9060 ; buffer. This way you can
9070 ; UNDO the UNDO. Great uh??
9080 ;-----------------------------
9090 ;
9100 UNDOIT
9110     JSR SVEPMPT
9120     JSR CLRPRMPT
9130     LDX #18
9140 U1  LDA UNDPMPT,K
9150     STA PMPTLINE+10,X
9160     DEX
9170     BPL U1
9180     LDX #25
9190 U7  LDA UNDOBUF,X
9200     PHA
9210     LDA REPSET,X
9220     STA UNDOBUF,X
9230     PLA
9240     STA REPSET,X
9250     DEX
9260     BPL U7
9270     JSR DOREP
9280     LDA #0
9290     STA 19
9300     STA 20
9310 U2  LDA 20
9320     CMP #100
9330     BNE U2
9340     JSR RSTPMPT
9350     JMP GETEM
9360 ;
9370 ;-----------------------------
9380 ; Come in here to do the
9390 ; actual changes to the puzzle
9400 ; We have to check each screen
9410 ; location to see if there
9420 ; is a match in the REPSET. We
9430 ; also need to move 'special'
9440 ; characters right on up with
9450 ; no changes. All 'SPACE'S are
9460 ; left alone.
9470 ;-----------------------------
9480 ;
9490 DOREP
9500     JSR PRNTREPSET
9510     LDA # <FRSTLINE
9520     STA ZSCR
9530     LDA # >FRSTLINE
9540     STA ZSCR+1
9550     LDA #9
9560     STA ROWTMP
9570 NRTLNE
9580     LDY #2
9590     CLC
9600     LDA ZSCR
9610     ADC #40
9620     STA ZSCR1
9630     LDA ZSCR+1
9640     ADC #0
9650     STA ZSCRI+1
9660 CHKNKT
9670     LDA (ZSCR1),Y
9680     CMP #0
9690     BEQ NKTCHR
9700     CMP #$21
9710     BCS CHKREP
9720 INVIT
9730     ORA #$80
9740 CH5
9750     STA (ZSCR),Y
9760     JMP NXTCHR
9770 CHKREP
9780     SEC
9790     SBC #$21
9800     TAX
9810     LDA REPSET,X
9820     CMP #0
9830     BNE INVIT
9840     BEQ CH5
9850 NXTCHR
9860     INY
9870     CPY #30
9880     BNE CHKNXT
9890     CLC
9900     LDA ZSCR
9910     ADC #80
9920     STA ZSCR
9930     LDA ZSCR+1
9940     ADC #0
9950     STA ZSCR+1
9960     DEC ROWTMP
9970     BNE NXTLNE
9980     RTS
9990 ;
010000 ;-----------------------------
010010 ; We need to save the PROMPT
010020 ; line in temp storage before
010030 ; we prompt the user with same
010040 ; kind of Yes/No question. We
010050 ; will then be able to restore
010060 ; the prompt line to it's
010070 ; original condition if they
010080 ; answer NO.
010090 ;-----------------------------
010100 ;
010110 SVEPMPT
010120     LDX #39
010130 SV1 LDA PMPTLINE,X
010140     STA PMPTLN,X
010150     DEX
010160     BPL SV1
010170     RTS
010180 ;
010190 ;------------------------------
010200 ; Time to replace the SAVED
010210 ; prompt line back onto the
010220 ;screen.
010230 ;------------------------------
010240 ;
010250 RSTPMPT
010260     LOX #39
010270 RS1 LDA PMPTLN,K
010280     STA PMPTLINE,K
010290     DEX
010300     BPL RS1
010310     RTS
010320 ;
010330 ;------------------------------
010340 ; This will take the REPLACE
010350 ; letters from the prompt line
010360 ; and use them to point into
010370 ; REPSET to store the WITH
010380 ; chars from the prompt line
010390 ; so that the DOREP routine can
010400 ; make changes to the puzzle
010410 ;
010420 ; Also going to save the old re
p
010430 ; set into the UNDO buffer.
010440 ;------------------------------
010450 ;
010460 STOREREP
010470     LDX #25
010480 TOUNDO LDA REPSET,X
010490     STA UNDOBUF,X
010500     DEX
010510     BPL TOUNDO
010520 ;
010530     LDX REPLEN
010540     DEX
010550 TORS TXA
010560     TAY
010570     LDA WITHCHRS,X
010580     STA ROWTMP
010590     SEC
010600     LDA REPLCHRS,X
010610     SBC #$21
010620     TAX
010630     LDA ROWTMP
010640     STA REPSET,X
010650     TYA
010660     TAX
010670     DEX
010680     BPL TORS
010690     JSR DOREP
010700     RTS
010710 ;
010720 ;------------------------------
010730 ; This routine will print the
010740 ; current replacement set on
010750 ; second line of the screen.
010760 ;------------------------------
010770 ;
010780 PRNTREPSET
010790     LDX #25
010800     LDY #33
010810 PR1
010820     LDA REPSET,X
010830     CMP #0
010840     BEQ PR11
010850     ORA #80
010860 PR11 STA REPLINE,Y
010870     DEX
010880     DEY
010890     CPY #27
010900     BNE PR1
010910     LDA #13
010920     STA REPLINE,Y
010930     DEY
010940 PR2
010950     LDA REPSET,X
010960     CMP #0
010970     BEQ PR22
010980     ORA #$80
010990 PR22 STA REPLINE,Y
011000     DEX
011010     DEY
011020     CPY #19
011030     BNE PR2
011040     LDA #13
011050     STA REPLINE,Y
011060     DEY
011070 PR3
011080     LDA REPSET,X
011090     CMP #0
011100     BEQ PR33
011110     ORA #$80
011120 PR33 STA REPLINE,Y
011130     DEX
011140     DEY
011150     CPY #11
011160     BNE PR3
011170     LDA #13
011180     STA REPLINE,Y
011190     DEY
011200 PR4
011210     LDA REPSET,X
011220     CMP #0
011230     BEQ PR44
011240     ORA #$80
011250 PR44 STA REPLINE,Y
011260     DEX
011270     DEY
011280     CPY #4
011290     BNE PR4
011300     RTS
011310 ;
011320 ;------------------------
011330 ; The user wants to go
011340 ; back to the REPLACE>
011350 ; prompt. We have to clear
011360 ; out the WITH> area of
011370 ; the line and do it
011380 ;-------------------------
011390 ;
011400 BCKTOREP
011410     LDA #8
011420     LDX #16
011430 BR1 STA WITHCHRS-5,X
011440     DEX
011450     BPL BR1
011460     LDX REPLEN
011470     JMP PRNTCRS
011480     *= $02E0
011490     .WORD START
011500     .END

Listig 3:
Assembly

 
10 ; CRYPT02.M65
20 ;
30 DLST1
40       .BYTE 112,112,66
50       .WORD MANSCR
60       .BYTE 0,2,144,2
70       .BYTE 2,0,2,2,0,2,2,0
80       .BYTE 2,2,0,2,2
90       .BYTE 0,2,2,0,2,2,0,2,2,0,2,2
0100     .BYTE 144,2,144,2,0,2,65
0110     .WORD DLST1
0120 ;
0130 ;-------------------------
0140 ; The MAIN text entry and
0150 ; puzzle solving screen
0160 ;-------------------------
0170 ;
0180 MANSCR
0190     .SBYTE "     ABCDEF-GHIJKLM-"
0200     .SBYTE "NOPGRST-UVWXYZ      "
0210 REPLINE
0220     .SBYTE "                    "
0230     .SBYTE "                    "
0240 FRSTLINE
0250     .SBYTE "                    "
0260     .SBYTE "                    "
0270     .SBYTE "                    "
0280     .SBYTE "                    "
0290     .SBYTE "                    "
0300     .SBYTE "                    "
0310     .SBYTE "           CRYPTOGRA"
0320     .SBYTE "M SOLVER            "
0330     .SBYTE "                    "
0340     .SBYTE "                    "
0350     .SBYTE "                    "
0360     .SBYTE "                    "
0370     .SBYTE "                    "
0380     .SBYTE "                    "
0390     .SBYTE "             by Kevi"
0400     .SBYTE "n Peck              "
0410     .SBYTE "                    "
0420     .SBYTE "                    "
0430     .SBYTE "                    "
0440     .SBYTE "                    "
0450     .SBYTE "                    "
0460     .SBYTE "                    "
0470     .SBYTE "         Press any k"
0480     .SBYTE "ey to begin         "
0490     .SBYTE "                    "
0500     .SBYTE "                    "
0510     .SBYTE "                    "
0520     .SBYTE "                    "
0530     .SBYTE "                    "
0540     .SBYTE "                    "
0550     .SBYTE "                    "
0560     .SBYTE "                    "
0570     .SBYTE "                    "
0580     .SBYTE "                    "
0590 LINE19
0600     .SBYTE "                    "
0610     .SBYTE "                    "
0620 PMPTLINE
0630     .SBYTE "                    "
0640     .SBYTE "                    "
0650     .SBYTE "                    "
0660     .SBYTE "                    "
0670     .SBYTE "                    "
0680     .SBYTE "                    "
0690 ELN1
0700     .SBYTE "   Use "
0710     .SBYTE "  ↓↑←→"
0720 ELN2
0730     .SBYTE "      "
0740     .SBYTE " to enter text    "
0750 REPLCHRS = PMPTLINE+10
0760 WITHCHRS = PMPTLINE+28
0770 CMD1
0780     .SBYTE "   ack  "
0790     .SBYTE " dit  "
0800 CMD2
0810     .SBYTE "  ew   "
0820     .SBYTE " ndo  "
0830 ;
0840 ;-------------------------
0850 ; Define memory locations
0860 ;-------------------------
0870 ;
0880 LUM =    $02C5    ;Char luminance
0890 BCK =    $02C6    ;Background color
0900 BRD =    $02C8    ;Broder color
0910 DMA =    $022F    ;DMA enable
0920 DLI =    $0238    ;Dsply List Addr
0930 INVFLG = $02B6    ;Inv Video Flag
0940 SHFLOK = $02BE    ;Shft Lck 64=uppr
0950 COLORBK = $D018   ;Hrdwre Backgrnd
0960 WSYNC = $D40A     ;Line Sync
0970 DLIVEC = $0200    ;DLI vector
0980 DLIENA = $D4BE    ;DLI enable=192
0990 CONSOL = $D01F
1000 SCREEN = $58
1010 VCOUNT = $D408    ;Vert line count
1020 KEYPRS = $02FC    ;Last key press
1030 ROWCRS = $54      ;Cursor Row
1040 COLCRS = $55      ;Cursor Column
1050 OLDCHR = $5D      ;Chr under Crsr
1060 ZSCR = $C0        ;Z-page scrn pntr
1070 ZSCR1 = $CD       ;2nd Z scrn pntr
1080 CRSINH = $02F8    ;Cursor ON/OFF
1090 OPEN =  $03       ;CIO open
1100 CLOSE = $0C       ;CIO close
1110 GETCHR = $07      ;CIO get
1120 PUTCHR = $0B      ;CIO put
1130 ICCMD = $0342     ;CIO cmd
1140 ICBAL = $0344     ;CIO buff HI
1150 ICBAH = $0345     ;CIO buff LO
1160 ICBLL = $8348     ;CIO len buf
1170 ICBLH = $0349     ;CIO len buf HI
1180 ICAH1 = $0340     ;CIO aux 1
1190 ICAH2 = $034B     ;CIO aux 2
1200 CIOV =  $E456     ;CIO entry pnt
1210 ;
1220 ;--------------------------------
1230 ; We have to set aside some space
1240 ; for various temporary variables
1250 ; All of that is done here.
1260 ;--------------------------------
1270 ;
1280 REPSET  .DS 26    ;rplcment le#ers
1290 PMPTLN  .DS 40    ;Save u rep line
1300 ROWTMP  .DS 1
1310 UNDOBUF .DS 26    ;undo buffer
1320 REPLEN  .DS 1     ;Length of reps
1330 ;
1340 ;--------------------------------
1350 ; Now we have some screen prompts
1360 ;--------------------------------
1370 ;
1380 REPPMPT .SBYTE "Replace>"
1390 WTHPMPT .SBYTE "With>"
1400 ENTPMPT .SBYTE "Press "
1410     .SBYTE " when done"
1420 CPZPMPT
1430     .SBYTE "Clear Puzzle Text?"
1440 CCGPMPT
1450     .SBYTE "Clear All Changes?"
1460 AYSPMPT .SBYTE "Are you sure"
1470     .SBYTE " (Y/N)"
1480 EDTPMPT
1490     .SBYTE "    "
1500     .SBYTE "    "
1510 QUTPMPT
1520     .SBYTE "Quit, Exit to DOS?"
1530 NEWPMPT
1540     .SBYTE "Start New Puzzle? "
1550 UNDPMPT .SBYTE "Last Change"
1560     .SBYTE " UNDONE."
1570 SCRN .BYTE "E:",$9B
1580 LFRT .BYTE "←→"
1590 ;

1600 ;----------------------------
1610 ; The first DLI starts here
1620 ;----------------------------
1630 ;
1640 COUNT1 .BYTE $FF
1650 COLOR1 .BYTE $80,$30,$02
1660 ;
1670 DLI1
1680     PHA          ;Interupt, Save A
1690     TXA          ;get X reg
1700     PHA          ;and save
1710     LDA VCOUNT   ;Get V line
1720     CMP #40      ;count and
1730     BCS CONT     ;reset count
1740     LDX #$FF     ;on top of
1750     STX COUNT1   ;screen
1760 CONT
1770      LDX COUNT1  ;Get color count
1780      INX         ;add one
1790      LDA COLORI,X ;get the color
1800      STA WSYNC   ;wait for horiz
1810      STA COLORBK ;stuff color
1820      STX COUNT1  ;save new count
1830      PLA         ;Get saved X
1840      TAR         ;put in X
1850      PLA         ;Get saved A
1860      RTI         ;RETURN
1870 ;
1880 ;-------------------------------
1890 ; This section of code will open
1900 ; the screen editor for I/O
1910 ; to write characters to the
1920 ; screen.
1930 ;-------------------------------
1940 ;
1950 OPNKYSCR
1960    LDA $FEFE
1970    CMP #$6C
1980    BNE ISXL
1990    LDA #$FE
2000    STA $79
2010    STA $7A
2020 ISXL
2030    LDH #$20
2040    LDA #OPEN
2050    STA ICCMD,X
2060    LDA # <SCRN
2070    STA ICBAL,X
2080    LDA # >SCRN
2090    STA ICBAH,X
2100    LDA #12
2110    STA ICAX1,X
2120    LDA #0
2130    STA ICAX2,X
2140    JSR CIOV
2150    JMP SETMAIN