home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 37 / 037.d81 / enigma (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  5KB  |  174 lines

  1. 10 gosub1290:poke53280,4:poke53281,3:print"[147]";
  2. 20 clr:gosub1200
  3. 30 print"[147][156]               e n i g m a              ";
  4. 32 print" german cipher machine of world war ii  "
  5. 35 print"            -- main menu --"
  6. 40 print"e[146][144] - encipher a message"
  7. 50 print"d[144][146] - decode an enciphered message"
  8. 60 print"s[144][146] - show message in both clear and code"
  9. 80 print"p[144][146] - printer output"
  10. 90 print"q[144][146] - quit"
  11. 92 print"   current code key:";:ifl$<>""thenz1$=l$:z2$=di$:goto94
  12. 93 z1$="no code key yet":z2$=""
  13. 94 printz1$"-"z2$
  14. 100 print d$ spc(10) "[144]select a letter":gosub 1160:poke198,.
  15. 110 get n$:if n$="" then gosub 1130:goto 110
  16. 112 ifn$="e"orn$="[197]"thenn=1:goto170
  17. 113 ifn$="d"orn$="[196]"thenn=2:goto170
  18. 114 ifn$="s"orn$="[211]"thenn=3:goto800
  19. 115 ifn$="p"orn$="[208]"thenn=4:goto1060
  20. 116 ifn$="q"orn$="[209]"thengosub60100:goto110
  21. 120 goto110
  22. 170 i=0:x=0:gg=5
  23. 180 print"[147]         enter secret code key:"
  24. 190 print"   letter of code (a-z)":gosub 1160
  25. 200 get l$:if l$="" then gosub 1130:goto 200
  26. 210 ll=asc(l$):if ll<65 or ll>90 then gosub 1160:goto 200
  27. 220 ke=ll-64
  28. 230 print"   number of code (1-9)":gosub 1160
  29. 240 get di$:if di$="" then gosub 1130:goto 240
  30. 250 if di$ < "1" or di$ > "9" then gosub1160:goto 240
  31. 260 di=val(di$):printc$
  32. 270 print spc(6) "press any alpha-numeric keys"
  33. 280 print spc(10) "or the space bar."
  34. 290 print x$ "(for menu, or to end, press <return>)" d$
  35. 300 gosub 960:gosub 1160:if n=2 then 610
  36. 310 print"enter clear text:"
  37. 320 get k$(i):if k$(i)="" then 320
  38. 321 if(k$(i)<>chr$(20))or(i=.)then330
  39. 322 ifx>.then324
  40. 323 printh$;:forg=1togg+7:printd$;:next:printspc(39)" [157]":x=40:gg=gg-1:goto325
  41. 324 printh$;:forg=1togg+8:printd$;:next:printspc(x-1)" [157]"
  42. 325 i=i-1:x=x-1:ifi>.thenke=ke(i-1):goto320
  43. 326 ke=ll-64:goto320
  44. 330 ifi=.then360
  45. 340 i=i-1:z$="":e=a:e$(i)=a$(i):if k=32 then w$=x$
  46. 350 gosub 500:w$="*":i=i+1
  47. 360 l=0:k=asc(k$(i))
  48. 370 if k=13 then j=i:goto 800
  49. 380 if k=32 then a=32:ke(i)=ke:goto 480
  50. 390 if k<48 or k>90 then 320
  51. 400 if k>57 and k<65 then 320
  52. 410 if k>64 then l=26
  53. 420 if k<58 then l=10
  54. 430 print h$;:for g=1 to gg+8:print d$;:next
  55. 440 print spc(x) k$(i):gosub 590
  56. 450 a=k+ke
  57. 460 if l=26 and a>90 then a=a-26
  58. 470 if l=10 and a>57 then a=a-10
  59. 480 a$(i)=chr$(a):z$=i$:e=a:e$(i)=a$(i)
  60. 490 gosub 500:gosub 560:goto 320
  61. 500 print h$;:for g=1 to 5:print d$;:next
  62. 510 if e=32 then print d$ d$ d$ d$ z$ tab(23) w$
  63. 520 if l=10 then print spc(2*e-88) d$ z$ e$(i)
  64. 530 if l=26 and e<78 then print d$ d$ spc(2*e-125) z$ e$(i)
  65. 540 if l=26 and e>77 then print d$ d$ d$ spc(2*e-151) z$ e$(i)
  66. 550 print b$:return
  67. 560 i=i+1:x=x+1:if i=40 or i=80 or i=120 then x=0:gg=gg+1
  68. 570 if i=160 then j=i:print c$ "long enough - select 3":goto 30
  69. 580 return
  70. 590 ke=ke+(di*i):ifke>lthenke=ke-(int(ke/l)*l)
  71. 600 ke(i)=ke:return
  72. 610 print"enter ciphered text:"
  73. 620 get a$(i):if a$(i)="" then 620
  74. 621 if(a$(i)<>chr$(20))or(i=.)then630
  75. 622 ifx>.then624
  76. 623 printh$;:forg=1togg+7:printd$;:next:printspc(39)" [157]":x=40:gg=gg-1:goto625
  77. 624 printh$;:forg=1togg+8:printd$;:next:printspc(x-1)" [157]"
  78. 625 i=i-1:x=x-1:ifi>.thenke=ke(i-1):goto620
  79. 626 ke=ll-64:goto620
  80. 630 if i=0 then print u$:for g=1 to 20:print x$;:next:goto 660
  81. 640 i=i-1:z$="":e=k:e$(i)=k$(i):if k=32 then w$=x$
  82. 650 gosub 500:w$="*":i=i+1
  83. 660 l=0:a=asc(a$(i))
  84. 670 if a=13 then j=i:goto 800
  85. 680 if a=32 then k=32:goto 780
  86. 690 if a<48 or a>90 then 620
  87. 700 if a>57 and a<65 then 620
  88. 710 if a>64 then l=26
  89. 720 if a<58 then l=10
  90. 730 print h$;:for g=1 to gg+8:print d$;:next
  91. 740 print spc(x) r$ i$ a$(i) b$:gosub 590
  92. 750 k=a-ke
  93. 760 if l=26 and k<65 then k=k+26
  94. 770 if l=10 and k<48 then k=k+10
  95. 780 k$(i)=chr$(k):z$=r$:e=k:e$(i)=k$(i)
  96. 790 gosub 500:gosub 560:goto 620
  97. 800 print c$;:if i>0 then 850
  98. 810 print spc(9) i$ "no message yet!"
  99. 820 print "select 1 or 2 from menu first:"
  100. 830 if pr$="open" then return
  101. 840 goto 30
  102. 850 print"your message not coded:"
  103. 860 print:for i=0 to j-1:print k$(i);:next
  104. 870 print:print
  105. 880 print "your message coded:"
  106. 890 print:for i=0 to j-1
  107. 900 if n=5 then print a$(i);:goto 930
  108. 910 if a$(i) <> x$ then print a$(i);
  109. 920 if a$(i)=x$ then print b$ x$;
  110. 930 next:print:if n=4 then return
  111. 952 print"[144]       press space for main menu":poke198,.
  112. 954 ifpeek(203)<>60then954
  113. 956 goto30
  114. 960 for g=1 to 40:print chr$(184);:next
  115. 970 print spc(8)
  116. 980 for g=48 to 57:print chr$(g) x$;:next
  117. 990 print:print spc(5)
  118. 1000 for g=65 to 77:print chr$(g) x$;:next
  119. 1010 print:print spc(5)
  120. 1020 for g=78 to 90:print chr$(g) x$;:next
  121. 1030 print:print spc(13) "space bar"
  122. 1040 for g=1 to 40:print chr$(185);:next
  123. 1050 print:return
  124. 1060 open15,4,15:close15:ifst=.then1070
  125. 1062 print"    error!! printer not online!!       "
  126. 1064 fora=1to2000:next:print"[145]                                       [145][145]"
  127. 1066 goto110
  128. 1070 print c$ spc(10) "printing"
  129. 1075 pr$="open":open 4,4:cmd 4
  130. 1080 gosub 800:print#4
  131. 1090 print#4,"warning: never transmit code by radio!"
  132. 1100 pr$="closed":print# 4:close 4
  133. 1110 print spc(10) u$ "finished printing":fora=1to2000:next
  134. 1120 goto 30
  135. 1130 print u$ spc(24) w$
  136. 1140 for g=1 to 200:next:print u$ spc(24) x$
  137. 1150 for g=1 to 100:next:return
  138. 1160 poke s+24,15:poke s+1,110:poke s+5,9:poke s+6,9
  139. 1170 poke s+4,17:poke s+4,16:return
  140. 1180 print u$ spc(10) "end of program."
  141. 1190 for jj=0 to 24:poke s+24,0:next:end
  142. 1200 s=54272:gosub1160
  143. 1210 dim k$(160),a$(160),e$(160),ke(160)
  144. 1220 c$="[147]":h$="":x$=" ":b$="[144]":i$=""
  145. 1230 u$="[145]":d$="":r$="":y$="":w$="*"
  146. 1240 return
  147. 1270 for jj=0 to 24:poke s+24,0:next
  148. 1280 print u$ spc(10) "end of program.":end
  149. 1290 poke53280,14:poke53281,14
  150. 1300 print"[147]"chr$(142)"[153][213][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][201]";
  151. 1310 fora=1to23:print"[221]"spc(38)"[221]";:next
  152. 1320 print"[202][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][203][157][148][192]"
  153. 1330 fora=217to242:pokea,peek(a)or128:next
  154. 1340 print"         loadstar presents:"
  155. 1350 print"                               "
  156. 1360 print"               enigma           "
  157. 1370 print"                                "
  158. 1380 print"         by gerhard schilling   "
  159. 1390 print"                                "
  160. 1400 print"           (c)opyright 1987     "
  161. 1410 print"                                "
  162. 1420 print"                                "
  163. 1430 print"       press space to continue."
  164. 1440 ifpeek(203)<>60then1440
  165. 1450 return
  166. 60100 print"[145] are you sure you want to quit? (y/n)"
  167. 60110 a=peek(203):ifa<>25anda<>39then60110
  168. 60120 ifa=25then60150
  169. 60130 print"[145]          select number                "
  170. 60140 print"[145]":return
  171. 60150 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
  172. 60160 ifer<>63thenend
  173. 60170 load"hello connect",8
  174.