home *** CD-ROM | disk | FTP | other *** search
-
-
- C O D E M E I S T E R 1 2 8
-
- Program and Text by Ray Parrish
-
-
- CODEMEISTER 128 is a program that will apply a code to any PETASCII
- text file and print it to the screen, disk or the printer. Before I go on
- about the program, I would like to explain the method of coding used. To
- start, pick a word without any repeating letters, like COMPUTER. Write it
- down with the remaining letters of the alphabet following it, in order.
- Then write the normal alphabet underneath, like so:
-
- C O M P U T E R A B D F G H I J K L N Q S V W X Y Z
- A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
-
- To encode the message, find the letter in the bottom row, and replace
- it with the corresponding letter in the top row. LOADSTAR would become
- FICPNQCL. Decoding is the same process in reverse. This process is very
- time-consuming, so we let the computer do the work.
-
- In addition to encoding and decoding text, CODEMEISTER shows off the
- use of INSTR in a number of ways. Those familiar with the BRANCHER
- function in LS 64's Toolboxes will see its parallel here. To create a set
- of "hotkeys," use the command like this:
-
- 10 getkeya$:oninstr("hotkeys",a$)goto100,200,300
- 20 goto10
-
- Line 10 checks the last key pressed to see if it is a hotkey. If not,
- it tries again. If it is, then it branches according to the list of GOTOs.
- Another use is for creating flipped-case strings. See the section of the
- BASIC code that asks for the codeword. The last use of INSTR is in the
- coding/decoding process. It checks the incoming byte to see if it is a
- letter. If not, it passes through unaffected. If it is a letter, upper or
- lowercase, then INSTR is used to code the byte.
-
- Now for the actual program itself. Upon startup, it checks the last
- device used by polling location 186. The hotkeys are shown in white
- reverse video. If the selected destination is PRINTER or SCREEN, the
- destination drive does not matter. If you are using a printer connected by
- GEOCABLE (or a similar device connected to the user port), then select
- SCREEN, turn the printer on, then press "O" again to select the printer.
- Once your preferences are in order, choose whether to encode or decode. The
- codeword MUST be all lowercase with no repeating letters. The program
- won't let you enter a codeword with a letter appearing more than once.
-
- NOTE: If you just press RETURN at the "codeword" prompt, it will use Bob
- Markland's RANDOM 2-254 from LS 128 #31 to completely scramble the whole
- alphabet. It's as if you had entered a codeword 26 letters long without a
- repeated letter. More on this in FENDER'S POSTMUMBLE below.
-
- NOTE II: The ML for handling parallel printing is found at $1300. Load it
- with
-
- 35 BLOAD"chrout.1300",u(dv),b0,p4864
-
- To send a character, use SYS4864,(ASCII character code)
-
- Then you will be presented with a file requestor (courtesy of Travis
- Parker). If the directory has more than 20 or so files, you can press the
- STOP key to stop the file you want from scrolling off the screen. To
- select a file, move the cursor to the desired file and press RETURN. Be
- sure the file is a text file. Using a program or non-text file would
- probably create garbage and force you to break out and rerun the program.
- If you want to change disks, select the "Blocks free" line, the header, or
- a file listed as 0 blocks long. If you want to exit here, press return on
- a blank line.
-
- After that, if the selected destination is DISK, you will be asked to
- provide a destination file. If the destination is the printer, CODEMEISTER
- goes right to coding/decoding. If you want to make sure that it's encoding
- or uncoding correctly, set the output to SCREEN first. Once you're
- satisfied that it's working properly, then do it for real to disk or
- printer. You can stop the process prematurely by pressing the STOP key.
- This part of the program would gain considerable speed if compiled.
-
- Other errors abort the program with a report of the error.
-
- That's all there is to it! This program can be useful if you want to
- apply mild encryption to your text. Or maybe you can use it to study the
- use of INSTR.
-
- FENDER'S POSTMUMBLE: I liked the simplicity of this program when I first
- saw it and the more I worked with it the more I saw its potential.
- Obviously, it's a straightforward "encryptor" for text. Ray calls it
- "mild" encryption, because it's not one of the many incredibly tricky
- techiques of encryption that have been invented.
-
- Ray suggested entering a 26-letter codeword to get the "best" encryption,
- but that seemed to me to be a lot of work, and it wouldn't be all that easy
- to make sure there were no duplicated letters. So I immediately thought of
- Bob Markland's RANDOM 2-254 from last issue. It's perfect for scrambling
- 26 letters without a repetition. It's simple to use. Just:
-
- 34 bload"random 2-254",u(dv),b0,p2816
-
- to load the ML into place at 2816. RANDOM 2-254 is completely relocatable
- and can be bloaded anywhere in free RAM in Bank 0. Then, to randomize the
- numbers from 1 to 26, do this:
-
- 500 poke176,0:poke177,11:poke178,26:sys2816
-
- The location of the ML (in lobyte/hibyte format) is POKEd into 176/177.
- Then the number of items to be randomized is POKEd into 178. Then SYS to
- the start of the ML. This scrambles the numbers from 1 to 26 and places
- them in the 26 bytes immediately following the ML routine at ADDR+94.
- CODEMEISTER required a 26-character string of the scrambled letters and
- line 504 of the program provides it:
-
- 504 lc$="":fori=1to26:lc$=lc$+chr$(64+peek(2816+94+i)):next
-
- That's how randomizing was added. It provides the best encryption
- possible with this technique but since it's a random string, if you don't
- write it down, you can't "uncode" it. And the program doesn't show you the
- random string! So don't use RANDOM 2-254 if you want the computer to
- uncode your message.
-
- By the way, Ray used the more proper term, "decode" but I changed it to
- "uncode" because I wanted to use D for Destination drive.
-
- The only way to get text into CODEMEISTER is to have it in a PETASCII text
- file on disk. It is assumed you will create this text with a word
- processor. Using the RANDOM 2-254 method of encoding you could have a
- bunch of quotes or quips in files on a disk and set the Output to PRINTER
- and print out some Cryptoquotes or Cryptoquips for your friends to solve.
- You've undoubtedly seen these types of puzzles in newspapers and
- magazines.
-
- You couldn't use Ray's "mild" form of encryption because it often leaves
- some letters alone without changing them. One of the laws of Cryptoquotes
- is that a letter CANNOT stand for itself. RANDOM 2-254 scrambles the
- letters quite well, but it merely randomizes them; it doesn't check to make
- sure that EVERY letter has moved somewhere else. So the following line has
- been added:
-
- 505 fori=1to26:ifmid$(lc$,i,1)=mid$(la$,i,1)theni=26:next:goto500:elsenext
-
- to make the program call RANDOM 2-254 over and over until it comes up with
- an encryption that hasn't left any letters in their original places. la$
- is defined early in the program as:
-
- abcdefghijklmnopqrstuvwxyz
-
- Jim Weiler, my compatriot across the hall, is often called "Dugym Qycfyl"
- (pronounced "duggum quickfill") by his friends. He came up with that name
- by creating an "alphabet wheel" on his Apple computer years ago. If you
- take the name, James Weiler, and shift the alphabet six letters so that A
- is G, B is H, C is I, etc. you get Dugym Qycfyl. It's like this:
-
- U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
- A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
-
- He tried all 25 possible shifts and shifting six created the most
- interesting encryption of his name. CODEMEISTER allows you to do the same
- thing. Have your name in a file on disk. Then pick any letter, say "R",
- and enter this as your codeword:
-
- rstuvwxyz
-
- This will do the same as shifting everything nine characters on the
- alphabet wheel. Since you're using the alphabet, you don't have to
- remember the whole codeword to uncode it later, just remember the letter
- you started with.
-
- I'm fascinated by little word games like this -- which is why my
- POSTMUMBLE is now longer than Ray's whole documentation. The program is in
- BASIC, and in my opinion, fast enough without compiling. Maybe you can
- come up with some new use for CODEMEISTER? Or maybe some nifty new
- features for it? If it had an input box, for instance, you could enter
- text to be encrypted, instead of having to get it from disk. Send me your
- ideas and maybe we can come up with a CODEMEISTER II somewhere down the
- road.
-
- Finally, Travis Parker's routine to display a directory on screen as a
- file requestor is very much like the one I've been using for a few years.
- Bob Markland is working on a sophisticated machine language file requestor
- for the C-128 but until he gets it done, I think Travis' routine does the
- job quite well. He uses TRAP to allow you to stop the scrolling of a large
- directory with the STOP key. It's not foolproof, but it works just dandy.
-
- \\\\\ R - Run RETURN - Menu \\\\\
-
-