10
20 DIM mem% &4000,type$(3):type$(0)="Program":type$(3)="Code"
30 :
40 INPUT"Input .TAP file: "in$:in%=OPENIN(in$):IFin%=0:PRINT"'"in$"' not found":END
50 ON ERROR REPORT:PROCclose:PRINT:END
60 :
70 REPEAT
80 len%=BGET#in%+256*BGET#in%
90 FOR a%=0 TO len%-1:mem%?a%=BGET#in%:NEXT
100 IF?mem%=0:PROCheader
110 IF?mem%=&FF:PROCdata
120 UNTILEOF#in%:PRINT':CLOSE#in%:in%=0:END
130 :
140 DEFPROCclose:IFin%:A%=in%:CLOSE#A%
150 ENDPROC
160 :
170 DEFFNh(A%,N%)=RIGHT$("0000000"+STR$~A%,N%)
180 :
190 DEFPROCheader
200 IFmem%?1<4:PRINT'type$(mem%?1);": "; ELSE PRINT'"Type ";mem%?1;": ";
210 m%=mem%?12:mem%?12=13:n$=$(mem%+2):mem%?12=m%:num%=mem%!12 AND &FFFF
220 start%=mem%!14 AND &FFFF:exec%=mem%!16 AND &FFFF
230 PRINTn$" "FNh(num%,4)" "FNh(start%,4)" "FNh(exec%,4);
240 VDU11:ENDPROC
250 :
260 DEFPROCdata:IFINKEY-1:PRINT:ENDPROC
270
280 FOR a%=1 TO num%:IF(a%AND15)=1:PRINT''FNh(a%-1,4)": ";
290 PRINT" "FNh(mem%?a%,2);CHR$8;CHR$10;
300 IFmem%?a%=127 OR mem%?a%<32:VDU46 ELSE VDUmem%?a%
310 VDU11,32:NEXT:PRINT':ENDPROC