1 cls:input"1=C=, 2=Apple, 3=PC : ";dn:if dn<1 or dn>3 then 1
5 dim dn$(3):dn$(1)="Murder Side B C64.txt":dn$(2)="Murder Side B Apple.txt":dn$(3)="Murder Side AB PC.txt"
7 ct=-1:sk=0:sk$="0":seek=249:restart=-1
8 dim of$(3):of$(1)="C64":of$(2)="Apple":of$(3)="PC"
10 gosub 7000:gosub 7100:gosub 4095:gosub 6000

15 ?"*************** [0]":rem 24f5
16 if restart=1 then caps=0:alt=0:goto 21 :rem changed some things that go here, maybe caps and alt shouldnt be changed here anymore, but may not affect anything on disk
20 gosub 6500
21 rem placeholder

23 a = byte:if a=32 then gosub 4060:gosub 1610:goto 23
24 restart=0:if len(text$)>32700 then text$=""
25 a = int(a/2) : a = int(a/2) : a = int(a/2):?a
30 gosub 1000:if restart=1 then 15
35 ?"--------------- [1]":rem 250c

40 a = byte:b=0
45 if a and 1 then b=4
50 if a and 2 then b=b+8
55 if a and 4 then b=b+16
60 gosub 6500 : a = byte
65if a and 128 then b=b+2
70if a and 64 then b=b+1
75 a=b
80 gosub 1000:if restart=1 then 15
85 ?"--------------- [2]":rem 2530 
90 a = byte : a = a and 62
95 a = int(a/2)
100 gosub 1000:if restart=1 then 15
105 ?"--------------- [3]":rem 253f 
110 a = byte
115 b=0:if a and 1 then b=16
120 gosub 6500 : a = byte
rem:if start=2 then 15
125 if a and 128 then b=b+8
130 if a and 64 then b=b+4
135 if a and 32 then b=b+2
140 if a and 16 then b=b+1
145a=b
150 gosub 1000:if restart=1 then 15
155 ?"--------------- [4]":rem 2561 
160 a=byte
165a=a and 15
170a=a*2
175gosub 6500:b=byte
rem:if start=2 then 15
180if b and 128 then a=a+1
185 gosub 1000:if restart=1 then 15
190 ?"--------------- [5]":rem 257d 
195 a=byte:a=a and 124
200 a=int(a/2):a=int(a/2)
210 gosub 1000:if restart=1 then 15
215 ?"--------------- [6]":rem 258d 
220 a=byte:b=0
225 if a and 1 then b=8
230 if a and 2 then b=b+16
235 gosub 6500:a=byte
rem:if start=2 then 15
240if a and 128 then b=b+4
245if a and 64 then b=b+2
250if a and 32 then b=b+1
255 a=b
260 gosub 1000:if restart=1 then 15
265 ?"--------------- [7]":rem 25b2 
270 a=byte
275 a=a and 31
280 gosub 1000:if restart=1 then 15
281 goto 15
285 ?:?"Most recently decoded text:":?text$:?:?"Started at:"sk$:?"Ended at:";right$("00000",5-len(hex$(sk+ct-1)));hex$(sk+ct-1)
290 ?:?:?"Decode summary:":?:?info$
295 close#1:close#2:end




1000 rem a=compressed code
1001 ?"                           code: ";right$("00",2-len(hex$(a)));hex$(a);
1002 gosub 1010
1003 if alt<>-1 and (a < 4 or a =27) then 1008
1004 ?"     ";right$(text$,1)
1005 if alt=-1 then alt=0
1008 return

1010 if alt=1 then gosub 3000:return:rem previous code was 2
1020 if a=5 then gosub 4050: return:rem space
1025 if a=4 then gosub 4050:rem space + caps (single letter)
1026 if a=4 and caps=0 then caps=4:return
1027 if a=4 then return
1030 if a=2 then ?:alt=1:return:rem alt char follows
1040 if a=1 then ?"  ++++++++++++++ special code":gosub 1500:return
1042 if a=0 then ?"  -------------- eol":gosub 1600:return
1045 if a=3 and caps=3 then caps=0:?:return:rem caps on/off
1047 if a=3 then caps=3:?:return
1050 a = a+59 : if caps=0 then a=a+32
1055 if caps=4 then caps=0
1100 gosub 4035:return


1500 rem encountered a 1
1505 gosub 4015
1510 ?:gosub 6500:gosub 4020:gosub 6500:gosub 4020:gosub 4025
1515 gosub 6500:restart=1:return


1600 rem encountered a 0
1603 gosub 4010:gosub 4015
1605 gosub 6500:if byte<>32 then gosub 4030:goto 1635
1610 twenty=1
1615 gosub 6500:if byte=32 then twenty=twenty+1:goto 1615
1620 if restart<>1 then gosub 4025:gosub 4060
1625 gosub 4045
1630 if restart<>1 then gosub 4010
1635 restart=1:return


3000 rem encountered a 2 previously (alt char set)
3005 alt=-1
3010 if a=27 then a=10-33:?"    CRLF":rem carriage return w linefeed (1b is return 0d is period)
3015 gosub 4055:return


4000 rem print additional info, byte = byte read, NOT code
4005 a$="{$"+byte$+"}"                   :goto 4500:rem output byte val with brackets, CRLF
4010 a$=chr$(10)                         :goto 4500:rem output CRLF
4015 a$="{code "+str$(a)                 :goto 4500:rem output code val with bracket 
4020 a$=" $"+byte$                       :goto 4500:rem space, byte 
4025 a$="}"                              :goto 4500:rem output closing bracket
4030 a$="}"+chr$(10)                     :goto 4500:rem output closing bracket + CRLF
4035 a$=chr$(a)                          :goto 4500:rem output current char 
4040 a$=" only"                          :goto 4500:rem no longer used
4045 a$=str$(twenty)+"x$20}"             :goto 4500:rem output $20 count
4050 a$=" "                              :goto 4500:rem output space
4055 a$=chr$(a+33)                       :goto 4500:rem output current alt char
4060 a$="{"                              :goto 4500:rem output opening bracket
4065 a$=" @ "+hex$(ct)+"}"+chr$(10)      :goto 4500:rem diagnosis, no longer used
4070 a$=chr$(10)+"{Skipped 16400-166FF (directory)}"+chr$(10):info$=info$+a$:?a$:return:rem c=
4075 a$=chr$(10)+"{Final Byte @ 217A5}"+chr$(10):info$=info$+a$:?a$:return:rem c=
4081 a$=chr$(10)+"{Final Byte @ 214A5}"+chr$(10):info$=info$+a$:?a$:return:rem apple
4085 a$=chr$(10)+"{Skipped 00000-011FF}"+chr$(10):info$=info$+a$:?a$:return:rem pc
4090 a$=chr$(10)+"{Final Byte @ 4BAA6}"+chr$(10):info$=info$+a$:?a$:return:rem pc
4095 a$="Decoding "+of$(dn)+" version"+chr$(10):info$=info$+a$:goto 4500
4100 a$=chr$(10)+"{Skipped "+hex$(sk1+1)+"-"+hex$(sk2-1)+"}"+chr$(10):info$=info$+a$:?a$:return:rem pc
4105 a$="Murder Party Decoder v1"+chr$(10)+chr$(10):info$=info$+a$:goto 4500
4500 print#2,a$;
4505 text$=text$+a$:if len(text$)>100 then text$=right$(text$,75)
4510 gosub 4600:return


4600 rem diagnostic routine, removed
4605 return


5000 rem disk correction routines
5005 if dn=2 then 5200
5010 if dn=3 then 5300
5100 rem Commodore
5105 if ct=0x16400 then ct=0x16700:rem counter correction
5110 if ct=0x217a6 then gosub 4025:gosub 4075:goto 285:rem end of data
5115 rem additional data at end of one MHI disk is duplicated data
5120 return
5150 if ct=0x163ff then fseek #1,(0x16700*3):gosub 4070:rem empty space
5155 return
5200 rem Apple
5206 if ct=0x214a7 then gosub 4025:gosub 4081:goto 285:rem end of data
5210 return
5300 rem PC
5305 if ct=sk0+1 then ct=sk2:rem counter correction
5310 if ct=0x4baa7 then gosub 4025:gosub 4090:goto 285:rem end of data
5315 return
5350 if ct=sk1 then sk2=sk1+0x1401:fseek #1,(sk2*3):gosub 4100:sk0=sk1:sk1=sk1+0x2400:rem empty/program space
5355 return


6000 rem seek to FIRST group
6005 if dn=3 then fseek #1,(0x1200*3):ct=0x11ff:sk1=0x21ff:gosub 4085:rem skip to pc data
6010 gosub 6500:if byte$<>"00" then gosub 4000:goto 6010
6015 gosub 6500:if byte$<>"20" then gosub 4000:goto 6010
6020 gosub 6500:if byte$<>"20" then gosub 4000:goto 6010
6025 gosub 4010:return

6100 rem seek to NEXT group (not used, maybe not needed)
6110 gosub 6500:if byte$<>"20" then 6110
6120 gosub 6500:if byte$<>"20" then 6110
6125 return
6200 rem seek to SPECIFIC byte
6210 fseek #1,(sk*3):return


6300 rem EOF
6305 ?:?:?"Encountered unexpected EOF!"
6310 close #1:close#2
6315 end


6400 rem no more data
6405 ?:?:?"Encountered unexpected end of data!"
6410 if dn=2 and ct-12<>0x1efff then 6450
6415 ?:?"(The data file is from a widely-shared but faulty
6420 ?"Apple II disk image which is missing data.)
6450 goto 6310


6500 rem get next byte
6502 ct=ct+1
6503 gosub 5000
6510 byte$=input$(2,1):pad$=input$(1,1):if eof then 6300
6515 ?right$("00000",5-len(hex$(sk+ct)));hex$(sk+ct);" : $";byte$
6520 byte=val("0x"+byte$)
6525 if dn=1 then gosub 5150
6530 if dn=3 then gosub 5350
6535 if oldbyte=byte then bytecount=bytecount+1
6537 if bytecount>10 then 6400
6540 if oldbyte<>byte then bytecount=0:oldbyte=byte
6550 return


7000 rem open file for reading
7002 close #1:close #2
7005 open ""+dn$(dn)+"" for input as #1
7010 return

7100 rem open file for writing
7105 open "Murder Party Text "+of$(dn)+".txt" for output as #2
7110 return