home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 37
/
037.d81
/
enigma
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
5KB
|
174 lines
10 gosub1290:poke53280,4:poke53281,3:print"[147]";
20 clr:gosub1200
30 print"[147][156] e n i g m a ";
32 print" german cipher machine of world war ii "
35 print" -- main menu --"
40 print"e[146][144] - encipher a message"
50 print"d[144][146] - decode an enciphered message"
60 print"s[144][146] - show message in both clear and code"
80 print"p[144][146] - printer output"
90 print"q[144][146] - quit"
92 print" current code key:";:ifl$<>""thenz1$=l$:z2$=di$:goto94
93 z1$="no code key yet":z2$=""
94 printz1$"-"z2$
100 print d$ spc(10) "[144]select a letter":gosub 1160:poke198,.
110 get n$:if n$="" then gosub 1130:goto 110
112 ifn$="e"orn$="[197]"thenn=1:goto170
113 ifn$="d"orn$="[196]"thenn=2:goto170
114 ifn$="s"orn$="[211]"thenn=3:goto800
115 ifn$="p"orn$="[208]"thenn=4:goto1060
116 ifn$="q"orn$="[209]"thengosub60100:goto110
120 goto110
170 i=0:x=0:gg=5
180 print"[147] enter secret code key:"
190 print" letter of code (a-z)":gosub 1160
200 get l$:if l$="" then gosub 1130:goto 200
210 ll=asc(l$):if ll<65 or ll>90 then gosub 1160:goto 200
220 ke=ll-64
230 print" number of code (1-9)":gosub 1160
240 get di$:if di$="" then gosub 1130:goto 240
250 if di$ < "1" or di$ > "9" then gosub1160:goto 240
260 di=val(di$):printc$
270 print spc(6) "press any alpha-numeric keys"
280 print spc(10) "or the space bar."
290 print x$ "(for menu, or to end, press <return>)" d$
300 gosub 960:gosub 1160:if n=2 then 610
310 print"enter clear text:"
320 get k$(i):if k$(i)="" then 320
321 if(k$(i)<>chr$(20))or(i=.)then330
322 ifx>.then324
323 printh$;:forg=1togg+7:printd$;:next:printspc(39)" [157]":x=40:gg=gg-1:goto325
324 printh$;:forg=1togg+8:printd$;:next:printspc(x-1)" [157]"
325 i=i-1:x=x-1:ifi>.thenke=ke(i-1):goto320
326 ke=ll-64:goto320
330 ifi=.then360
340 i=i-1:z$="":e=a:e$(i)=a$(i):if k=32 then w$=x$
350 gosub 500:w$="*":i=i+1
360 l=0:k=asc(k$(i))
370 if k=13 then j=i:goto 800
380 if k=32 then a=32:ke(i)=ke:goto 480
390 if k<48 or k>90 then 320
400 if k>57 and k<65 then 320
410 if k>64 then l=26
420 if k<58 then l=10
430 print h$;:for g=1 to gg+8:print d$;:next
440 print spc(x) k$(i):gosub 590
450 a=k+ke
460 if l=26 and a>90 then a=a-26
470 if l=10 and a>57 then a=a-10
480 a$(i)=chr$(a):z$=i$:e=a:e$(i)=a$(i)
490 gosub 500:gosub 560:goto 320
500 print h$;:for g=1 to 5:print d$;:next
510 if e=32 then print d$ d$ d$ d$ z$ tab(23) w$
520 if l=10 then print spc(2*e-88) d$ z$ e$(i)
530 if l=26 and e<78 then print d$ d$ spc(2*e-125) z$ e$(i)
540 if l=26 and e>77 then print d$ d$ d$ spc(2*e-151) z$ e$(i)
550 print b$:return
560 i=i+1:x=x+1:if i=40 or i=80 or i=120 then x=0:gg=gg+1
570 if i=160 then j=i:print c$ "long enough - select 3":goto 30
580 return
590 ke=ke+(di*i):ifke>lthenke=ke-(int(ke/l)*l)
600 ke(i)=ke:return
610 print"enter ciphered text:"
620 get a$(i):if a$(i)="" then 620
621 if(a$(i)<>chr$(20))or(i=.)then630
622 ifx>.then624
623 printh$;:forg=1togg+7:printd$;:next:printspc(39)" [157]":x=40:gg=gg-1:goto625
624 printh$;:forg=1togg+8:printd$;:next:printspc(x-1)" [157]"
625 i=i-1:x=x-1:ifi>.thenke=ke(i-1):goto620
626 ke=ll-64:goto620
630 if i=0 then print u$:for g=1 to 20:print x$;:next:goto 660
640 i=i-1:z$="":e=k:e$(i)=k$(i):if k=32 then w$=x$
650 gosub 500:w$="*":i=i+1
660 l=0:a=asc(a$(i))
670 if a=13 then j=i:goto 800
680 if a=32 then k=32:goto 780
690 if a<48 or a>90 then 620
700 if a>57 and a<65 then 620
710 if a>64 then l=26
720 if a<58 then l=10
730 print h$;:for g=1 to gg+8:print d$;:next
740 print spc(x) r$ i$ a$(i) b$:gosub 590
750 k=a-ke
760 if l=26 and k<65 then k=k+26
770 if l=10 and k<48 then k=k+10
780 k$(i)=chr$(k):z$=r$:e=k:e$(i)=k$(i)
790 gosub 500:gosub 560:goto 620
800 print c$;:if i>0 then 850
810 print spc(9) i$ "no message yet!"
820 print "select 1 or 2 from menu first:"
830 if pr$="open" then return
840 goto 30
850 print"your message not coded:"
860 print:for i=0 to j-1:print k$(i);:next
870 print:print
880 print "your message coded:"
890 print:for i=0 to j-1
900 if n=5 then print a$(i);:goto 930
910 if a$(i) <> x$ then print a$(i);
920 if a$(i)=x$ then print b$ x$;
930 next:print:if n=4 then return
952 print"[144] press space for main menu":poke198,.
954 ifpeek(203)<>60then954
956 goto30
960 for g=1 to 40:print chr$(184);:next
970 print spc(8)
980 for g=48 to 57:print chr$(g) x$;:next
990 print:print spc(5)
1000 for g=65 to 77:print chr$(g) x$;:next
1010 print:print spc(5)
1020 for g=78 to 90:print chr$(g) x$;:next
1030 print:print spc(13) "space bar"
1040 for g=1 to 40:print chr$(185);:next
1050 print:return
1060 open15,4,15:close15:ifst=.then1070
1062 print" error!! printer not online!! "
1064 fora=1to2000:next:print"[145] [145][145]"
1066 goto110
1070 print c$ spc(10) "printing"
1075 pr$="open":open 4,4:cmd 4
1080 gosub 800:print#4
1090 print#4,"warning: never transmit code by radio!"
1100 pr$="closed":print# 4:close 4
1110 print spc(10) u$ "finished printing":fora=1to2000:next
1120 goto 30
1130 print u$ spc(24) w$
1140 for g=1 to 200:next:print u$ spc(24) x$
1150 for g=1 to 100:next:return
1160 poke s+24,15:poke s+1,110:poke s+5,9:poke s+6,9
1170 poke s+4,17:poke s+4,16:return
1180 print u$ spc(10) "end of program."
1190 for jj=0 to 24:poke s+24,0:next:end
1200 s=54272:gosub1160
1210 dim k$(160),a$(160),e$(160),ke(160)
1220 c$="[147]":h$="":x$=" ":b$="[144]":i$=""
1230 u$="[145]":d$="":r$="":y$="":w$="*"
1240 return
1270 for jj=0 to 24:poke s+24,0:next
1280 print u$ spc(10) "end of program.":end
1290 poke53280,14:poke53281,14
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]";
1310 fora=1to23:print"[221]"spc(38)"[221]";:next
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]"
1330 fora=217to242:pokea,peek(a)or128:next
1340 print" loadstar presents:"
1350 print" "
1360 print" enigma "
1370 print" "
1380 print" by gerhard schilling "
1390 print" "
1400 print" (c)opyright 1987 "
1410 print" "
1420 print" "
1430 print" press space to continue."
1440 ifpeek(203)<>60then1440
1450 return
60100 print"[145] are you sure you want to quit? (y/n)"
60110 a=peek(203):ifa<>25anda<>39then60110
60120 ifa=25then60150
60130 print"[145] select number "
60140 print"[145]":return
60150 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
60160 ifer<>63thenend
60170 load"hello connect",8