home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 128 #32 / q32side2.d64 / t.codemeister < prev    next >
Text File  |  2022-08-30  |  9KB  |  185 lines

  1.  
  2.  
  3.                        C O D E M E I S T E R    1 2 8
  4.  
  5.                       Program and Text by Ray Parrish
  6.  
  7.  
  8.     CODEMEISTER 128 is a program that will apply a code to any PETASCII
  9. text file and print it to the screen, disk or the printer.  Before I go on
  10. about the program, I would like to explain the method of coding used.  To
  11. start, pick a word without any repeating letters, like COMPUTER.  Write it
  12. down with the remaining letters of the alphabet following it, in order.
  13. Then write the normal alphabet underneath, like so:
  14.  
  15.       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
  16.       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
  17.  
  18.     To encode the message, find the letter in the bottom row, and replace
  19. it with the corresponding letter in the top row.  LOADSTAR would become
  20. FICPNQCL. Decoding is the same process in reverse.  This process is very
  21. time-consuming, so we let the computer do the work.
  22.  
  23.     In addition to encoding and decoding text, CODEMEISTER shows off the
  24. use of INSTR in a number of ways.  Those familiar with the BRANCHER
  25. function in LS 64's Toolboxes will see its parallel here.  To create a set
  26. of "hotkeys," use the command like this:
  27.  
  28.      10 getkeya$:oninstr("hotkeys",a$)goto100,200,300
  29.      20 goto10
  30.  
  31.     Line 10 checks the last key pressed to see if it is a hotkey.  If not,
  32. it tries again.  If it is, then it branches according to the list of GOTOs.
  33. Another use is for creating flipped-case strings.  See the section of the
  34. BASIC code that asks for the codeword.  The last use of INSTR is in the
  35. coding/decoding process.  It checks the incoming byte to see if it is a
  36. letter.  If not, it passes through unaffected.  If it is a letter, upper or
  37. lowercase, then INSTR is used to code the byte.
  38.  
  39.     Now for the actual program itself.  Upon startup, it checks the last
  40. device used by polling location 186.  The hotkeys are shown in white
  41. reverse video.  If the selected destination is PRINTER or SCREEN, the
  42. destination drive does not matter.  If you are using a printer connected by
  43. GEOCABLE (or a similar device connected to the user port), then select
  44. SCREEN, turn the printer on, then press "O" again to select the printer.
  45. Once your preferences are in order, choose whether to encode or decode. The
  46. codeword MUST be all lowercase with no repeating letters.  The program
  47. won't let you enter a codeword with a letter appearing more than once.
  48.  
  49.  NOTE: If you just press RETURN at the "codeword" prompt, it will use Bob
  50. Markland's RANDOM 2-254 from LS 128 #31 to completely scramble the whole
  51. alphabet.  It's as if you had entered a codeword 26 letters long without a
  52. repeated letter.  More on this in FENDER'S POSTMUMBLE below.
  53.  
  54.  NOTE II: The ML for handling parallel printing is found at $1300.  Load it
  55. with
  56.  
  57.    35 BLOAD"chrout.1300",u(dv),b0,p4864
  58.  
  59.   To send a character, use SYS4864,(ASCII character code)
  60.  
  61.     Then you will be presented with a file requestor (courtesy of Travis
  62. Parker).  If the directory has more than 20 or so files, you can press the
  63. STOP key to stop the file you want from scrolling off the screen.  To
  64. select a file, move the cursor to the desired file and press RETURN.  Be
  65. sure the file is a text file.  Using a program or non-text file would
  66. probably create garbage and force you to break out and rerun the program.
  67. If you want to change disks, select the "Blocks free" line, the header, or
  68. a file listed as 0 blocks long.  If you want to exit here, press return on
  69. a blank line.
  70.  
  71.     After that, if the selected destination is DISK, you will be asked to
  72. provide a destination file.  If the destination is the printer, CODEMEISTER
  73. goes right to coding/decoding.  If you want to make sure that it's encoding
  74. or uncoding correctly, set the output to SCREEN first.  Once you're
  75. satisfied that it's working properly, then do it for real to disk or
  76. printer.  You can stop the process prematurely by pressing the STOP key.
  77. This part of the program would gain considerable speed if compiled.
  78.  
  79.     Other errors abort the program with a report of the error.
  80.  
  81.     That's all there is to it!  This program can be useful if you want to
  82. apply mild encryption to your text.  Or maybe you can use it to study the
  83. use of INSTR.
  84.  
  85.  FENDER'S POSTMUMBLE:  I liked the simplicity of this program when I first
  86. saw it and the more I worked with it the more I saw its potential.
  87. Obviously, it's a straightforward "encryptor" for text.  Ray calls it
  88. "mild" encryption, because it's not one of the many incredibly tricky
  89. techiques of encryption that have been invented.
  90.  
  91.  Ray suggested entering a 26-letter codeword to get the "best" encryption,
  92. but that seemed to me to be a lot of work, and it wouldn't be all that easy
  93. to make sure there were no duplicated letters.  So I immediately thought of
  94. Bob Markland's RANDOM 2-254 from last issue.  It's perfect for scrambling
  95. 26 letters without a repetition.  It's simple to use.  Just:
  96.  
  97.   34 bload"random 2-254",u(dv),b0,p2816
  98.  
  99. to load the ML into place at 2816.  RANDOM 2-254 is completely relocatable
  100. and can be bloaded anywhere in free RAM in Bank 0.  Then, to randomize the
  101. numbers from 1 to 26, do this:
  102.  
  103.   500 poke176,0:poke177,11:poke178,26:sys2816
  104.  
  105. The location of the ML (in lobyte/hibyte format) is POKEd into 176/177.
  106. Then the number of items to be randomized is POKEd into 178.  Then SYS to
  107. the start of the ML.  This scrambles the numbers from 1 to 26 and places
  108. them in the 26 bytes immediately following the ML routine at ADDR+94.
  109. CODEMEISTER required a 26-character string of the scrambled letters and
  110. line 504 of the program provides it:
  111.  
  112.   504 lc$="":fori=1to26:lc$=lc$+chr$(64+peek(2816+94+i)):next
  113.  
  114.  That's how randomizing was added.  It provides the best encryption
  115. possible with this technique but since it's a random string, if you don't
  116. write it down, you can't "uncode" it.  And the program doesn't show you the
  117. random string!  So don't use RANDOM 2-254 if you want the computer to
  118. uncode your message.
  119.  
  120.  By the way, Ray used the more proper term, "decode" but I changed it to
  121. "uncode" because I wanted to use D for Destination drive.
  122.  
  123.  The only way to get text into CODEMEISTER is to have it in a PETASCII text
  124. file on disk.  It is assumed you will create this text with a word
  125. processor.  Using the RANDOM 2-254 method of encoding you could have a
  126. bunch of quotes or quips in files on a disk and set the Output to PRINTER
  127. and print out some Cryptoquotes or Cryptoquips for your friends to solve.
  128. You've undoubtedly seen these types of puzzles in newspapers and
  129. magazines.
  130.  
  131.  You couldn't use Ray's "mild" form of encryption because it often leaves
  132. some letters alone without changing them.  One of the laws of Cryptoquotes
  133. is that a letter CANNOT stand for itself.  RANDOM 2-254 scrambles the
  134. letters quite well, but it merely randomizes them; it doesn't check to make
  135. sure that EVERY letter has moved somewhere else.  So the following line has
  136. been added:
  137.  
  138. 505 fori=1to26:ifmid$(lc$,i,1)=mid$(la$,i,1)theni=26:next:goto500:elsenext
  139.  
  140. to make the program call RANDOM 2-254 over and over until it comes up with
  141. an encryption that hasn't left any letters in their original places.  la$
  142. is defined early in the program as:
  143.  
  144.  abcdefghijklmnopqrstuvwxyz
  145.  
  146.  Jim Weiler, my compatriot across the hall, is often called "Dugym Qycfyl"
  147. (pronounced "duggum quickfill") by his friends.  He came up with that name
  148. by creating an "alphabet wheel" on his Apple computer years ago.  If you
  149. take the name, James Weiler, and shift the alphabet six letters so that A
  150. is G, B is H, C is I, etc. you get Dugym Qycfyl.  It's like this:
  151.  
  152.     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
  153.     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
  154.  
  155. He tried all 25 possible shifts and shifting six created the most
  156. interesting encryption of his name.  CODEMEISTER allows you to do the same
  157. thing.  Have your name in a file on disk.  Then pick any letter, say "R",
  158. and enter this as your codeword:
  159.  
  160.    rstuvwxyz
  161.  
  162. This will do the same as shifting everything nine characters on the
  163. alphabet wheel.  Since you're using the alphabet, you don't have to
  164. remember the whole codeword to uncode it later, just remember the letter
  165. you started with.
  166.  
  167.  I'm fascinated by little word games like this