0 goto14
1 print"         ";:geta$:ifa$<>""then7
2 get#5,a$:ifa$=""then1
3 a1=asc(a$+chr$(0))
4 print chr$(f%(a1));
5 if a$=chr$(34) then poke 244,0
6 a$="":goto1
7 ifa$=""then:scnclr 5:goto1
8 if a$="(" then 251
9 if a$="'" then 329
10 if a$=chr$(34) then poke 244,0
11 a1=asc(a$+chr$(0))
12 ifa1<>0thenprint#5,chr$(t%(a1));
13 a$="":goto2
14 fast:gosub 366
15 poke808,100:poke5125,0
16 bank15:poke58,192:clr:restore:print"  One Moment please...."
17 trap244
18 dimu%(64),n$(64),t$(64),vt$(50),a%(255),c%(255):printchr$(14);
19 dimr1%(20),r2%(18),r3%(17),r4%(16)
20 d1=12*4096:rem address of cp/m directory info bank 1
21 d2=d1+2048:rem address of cp/m disk record map
22 d3=d2+4080:rem address of cp/m disk block alloc map
23 fori=0to12:a%(0)=0:nexti:a%(13)=13:fori=14to31:a%(i)=0:nexti
24 fori=32to64:a%(i)=i:nexti:fori=65to90:a%(i)=i+128:nexti
25 fori=91to95:a%(i)=i:nexti:a%(96)=44:fori=97to122:a%(i)=i-32:nexti
26 a%(123)=179:a%(124)=125:a%(125)=171:a%(126)=96:a%(127)=0
27 fori=128to255:a%(i)=a%(i-128):nexti
28 fori=0to64:c%(i)=i:nexti:fori=65to90:c%(i)=i+32:nexti
29 fori=91to127:c%(i)=i:nexti:fori=128to255:c%(i)=i-128:nexti
30 fori=0to50:readvt$(i):ifvt$(i)="***"theni=50
31 nexti
32 fori=0to20:readr1%(i):nexti:fori=0to18:readr2%(i):nexti
33 fori=0to17:readr3%(i):nexti:fori=0to16:readr4%(i):nexti
34 print"Insert CP/M Disk in Drive 8"
35 print"Press any key to continue when disk is ready"
36 getkeya$
37 open14,8,15:print#14,"i0":close14
38 print"Reading CP/M Directory":print
39 open1,8,2,"#":open15,8,15
40 d=d1:fors=2to9:print#15,"b-p";2;0
41 ss=r1%(s):print#15,"u1";2;0;1;ss
42 fori=1to8:print".";
43 forj=1to32:get#1,x$:ifx$=""thenx$=chr$(0)
44 bank1:poked,asc(x$):d=d+1
45 nextj,i,s:close1:close15
46 d=d2:rem build record map
47 t=1:fors=2to20:ss=r1%(s)
48 bank1:poked,t:poked+1,ss:poked+2,0:poked+3,t:poked+4,ss:poked+5,128
49 d=d+6:nexts
50 fort=2to17:fors=0to20:ss=r1%(s)
51 bank1:poked,t:poked+1,ss:poked+2,0:poked+3,t:poked+4,ss:poked+5,128
52 d=d+6:nexts,t
53 t=18:fors=1to18:ss=r2%(s)
54 bank1:poked,t:poked+1,ss:poked+2,0:poked+3,t:poked+4,ss:poked+5,128
55 d=d+6:nexts
56 fort=19to24:fors=0to18:ss=r2%(s)
57 bank1:poked,t:poked+1,ss:poked+2,0:poked+3,t:poked+4,ss:poked+5,128
58 d=d+6:nexts,t
59 fort=25to30:fors=0to17:ss=r3%(s)
60 bank1:poked,t:poked+1,ss:poked+2,0:poked+3,t:poked+4,ss:poked+5,128
61 d=d+6:nexts,t
62 fort=31to35:fors=0to16:ss=r4%(s)
63 bank1:poked,t:poked+1,ss:poked+2,0:poked+3,t:poked+4,ss:poked+5,128
64 d=d+6:nexts,t
65 fori=d3+2tod3+169:bank1:pokei,0:nexti
66 bank1:poked3,255:poked3+1,255:rem directory blocks
67 d=d1:fori=1to64:bank1:u%(i)=peek(d):ifu%(i)=229then73
68 n$(i)="":forj=1to8:bank1:n$(i)=n$(i)+chr$(peek(d+j)):nextj
69 t$(i)="":forj=9to11:bank1:t$(i)=t$(i)+chr$(peek(d+j)):nextj
70 forj=16to31:bank1:ifpeek(d+j)=0then72
71 bank1:x=peek(d+j):poked3+x,i
72 nextj
73 d=d+32:nexti
74 print:print"Finished! DO NOT remove disk from drive"
75 print:print"unless logging a new one into the system."
76 print:print"press any key for menu":getkeya$:goto227
77 print"Smallterm -- CP/M Utility"
78 print"Functions are:"
79 print" 1 - List CP/M Directory"
80 print" 2 - List CP/M File"
81 print" 3 - Initialize for another CP/M Disk"
82 print" 4 - Return to MAIN menu"
83 print"Press key for desired function"
84 geta$:ifa$=""then84
85 ifval(a$)=4thenpoke5125,0
86 ifval(a$)=3thenpoke5125,1
87 onval(a$)goto89,107,16,251
88 goto77
89 print"USR  NAME       TYP   EXT   RECS   SIZE"
90 print"---  --------   ---   ---   ----   ----"
91 b=2:d=d1:fori=1to64
92 bank1:ifpeek(d)<>0then102
93 u$=right$("  "+str$(u%(i)),2)
94 n$=n$(i)
95 t$=t$(i)
96 bank1:e=peek(d+12)+1:e$=right$("   "+str$(e),2)
97 bank1:s=peek(d+15):s$=right$("   "+str$(s),3)
98 k=0:forj=16to31:bank1:ifpeek(d+j)<>0thenk=k+1
99 k$=right$("   "+str$(k),3)
100 nextj:b=b+k
101 print u$;"   ";n$;"   ";t$;"   ";e$;"    ";s$;"    ";k$;"k"
102 d=d+32:next i
103 print"---------------------------------------"
104 print"";str$(170-b);" 1K Blocks Available "
105 print"Press any key for menu"
106 getkeya$:goto77
107 open4,3:rem default to screen
108 print"CP/M File Print":print"User, File Name, TYP"
109 input u$,a$,b$
110 u%=val(u$):ifu%<0oru>15thenprint"User # INVALID":goto150
111 x=51:fori=0to50:ifb$=vt$(i)thenx=i:i=50:goto113
112 ifvt$(i)="***"theni=50
113 nexti:ifx=51thenprint"File TYPE INVALID":goto150
114 a$=left$(a$+"        ",8)
115 f=0:e=0:fori=1to64:ifu%(i)=229then117
116 ifu%=u%(i)anda$=n$(i)andb$=t$(i)thenf=i:i=64
117 nexti
118 iff=0thenprint"File NOT FOUND":goto150
119 pr=0:input"Screen (s) or Printer (p)  s";a$
120 ifa$="p"thenclose4:open4,4,7:pr=1:goto123
121 ifa$="s"then123
122 goto119
123 print#4,"";:bc=0
124 print"Press No Scroll key to Pause and Restart"
125 print"Press \ key to stop":print
126 open1,8,2,"#":open15,8,15
127 d=d1+(f-1)*32
128 ef=0:fork=d+16tod+31:bank1:b=peek(k):ifb=0thenk=d+31:goto145
129 b=d2+(b)*24
130 fori=btob+18step6:bank1:t=peek(i):s=peek(i+1):p=peek(i+2)
131 print#15,"b-p";2;0
132 print#15,"u1";2;0;t;s
133 forj=1to256
134 geta$:ifa$="\"thenk=d+31:i=b+18:j=256:ef=1:goto143
135 get#1,x$:ifx$=""thenx$=chr$(0)
136 ifasc(x$)=26thenj=256:i=b+18:k=d+31:goto143
137 ifasc(x$)<>9then140
138 x=int(bc/8)*8:x=bc-x:x=8-x:forxx=1tox:print#4," ";:nextxx
139 bc=bc+x:goto143
140 ifasc(x$)=12thenprint#4,"";:goto143
141 print#4,chr$(a%(asc(x$)));:ifa%(asc(x$))<>0thenbc=bc+1
142 ifasc(x$)=13thenbc=0
143 nextj
144 nexti
145 nextk
146 close1:close15:ifefthen150
147 ff=f:e=e+1:fori=fto64:ifu%(i)=229then149
148 bank1:ifu%=u%(i)anda$=n$(i)andb$=t$(i)andpeek(d1+((i-1)*32)+12)=ethenf=i:i=64
149 nexti:iff>ffthen126
150 print#4:close4
151 print:print"Press any key for menu"
152 getkeya$:goto77
153 print"Input file name and file type. File name should be no more than 8     characters. Then enter the type of file ie. com, lbr, asm, txt, doc  etc. etc."
154 u$="0":e=0:print:input"CP/M  file name, type -=> ";cp$,ty$
155 nr=1:pf=0:lf=0:ifcp$=""thenprint#5,"":goto325
156 if len(cp$)>8thenprint"file name to long. 8 characters max.":goto154
157 x=51:fori=0to50:if ty$=vt$(i)thenx=i:i=50:goto159
158 ifvt$(i)="***"theni=50
159 next i:ifx=51thenprint"File Type Invalid":goto154
160 n=0:fori=1to64:ifu%(i)=229thenn=i:i=64
161 nexti:ifn=0thenprint"ABORTING: CP/M Directory Full":sleep5:e2=1:return
162 return
163 open1,8,2,"#":open14,8,15
164 bank1:d=d1+(n-1)*32:poked,val(u$):fori=d+1tod+8:pokei,32:nexti
165 fori=1tolen(cp$):bank1:poked+i,asc(mid$(cp$,i,1)):nexti
166 fori=9to11:bank1:poked+i,asc(mid$(ty$,i-8,1)):nexti:poked+12,e
167 bank1:poked+13,0:poked+14,0
168 u%(n)=val(u$):n$(n)=left$(cp$+"        ",8):t$(n)=ty$
169 bank1:nr=d+15:ba=d+16:pokenr,0
170 fori=batoba+15:bank1:pokei,0:nexti
171 nb=170:fori=0to169:bank1:ifpeek(d3+i)=0thennb=i:i=169
172 nexti:bank1:ifnb=170thenpoked,229:print"ABORTING: CP/M Disk Full":gosub360:goto207
173 bank1:poked3+nb,n:pokeba,nb:goto211
174 forr=1to8
175 y$=""
176 ifx=1theny$=y$+chr$(10):x=0:goto181
177 get#3,x$:ifx$=""thenx$=chr$(0)
178 a=asc(x$):y$=y$+chr$(c%(a))
179 cs=st
180 ifx$=chr$(13)thenx=1
181 y=len(y$):ify=128then185
182 ifcs=64andx=0then184
183 goto176
184 fori=y+1to128:y$=y$+chr$(26):nexti
185 ra=d2+((nb)*24)+((r-1)*3):bank1:t=peek(ra):s=peek(ra+1):p=peek(ra+2)
186 print#14,"u1";2;0;t;s:print#14,"b-p";2;p
187 print#1,y$;:ifcs=64thenprint#14,"u2";2;0;t;s:print#14,"b-p";2;0
188 print#14,"u2";2;0;t;s:bank1:pokenr,(peek(nr)+1)
189 ifcs=64thenr=8
190 nextr:ifcs=64then196
191 ba=ba+1
192 bank1:ifpeek(nr)<128then171
193 n=0:fori=1to64:ifu%(i)=229thenn=i:i=64
194 nexti:ifn=0thenprint"ABORTING: CP/M Directory Full":gosub360:cs=1:sleep6:goto207
195 e=e+1:goto164
196 close3:close1:close14
197 cs=1:print:print"Writing CP/M Directory":print
198 open14,8,15:print#14,"i0":open 1,8,2,"#"
199 d=d1:fors=2to9:print#14,"b-p";2;0:ss=r1%(s)
200 fori=1to8:print".";
201 x$="":forj=1to32:bank1:x=peek(d):x$=x$+chr$(x):d=d+1:nextj
202 print#1,x$;:ifs=7andi=8andj=32thenprint#14,"u2";2;0;1;ss:print#14,"b-p";2,0
203 nexti
204 print#14,"u2";2;0;1;ss
205 nexts
206 close14:close1:print#5,chr$(17);:cs=1:goto325
207 close3:close1:close14:print#5,"";
208 print:print"Press any key for Terminal mode."
209 getkeya$
210 goto325
211 forr=1to8
212 e1=.:gosub336:ife1=1thenprint#5,"":gosub360:r=8:nextr:cs=1:goto325
213 ifcs<>64then215
214 fori=ct+1to128:bf$=bf$+chr$(26):next i
215 ra=d2+((nb)*24)+((r-1)*3):bank1:t=peek(ra):s=peek(ra+1):p=peek(ra+2)
216 print#14,"u1";2;0;t;s:print#14,"b-p";2;p
217 print#1,bf$;:ifcs=64thenprint#14,"u2";2;0;t;s:print#14,"b-p";2;0
218 print#14,"u2";2;0;t;s:bank1:pokenr,(peek(nr)+1)
219 ifcs=64thenr=8
220 nextr:ifcs=64then358:else191
221 data 2zb,asm,bak,bas,bin,c,com,cqm,dat,doc,dqc,hex,hlp,i80,lbr,lqr
222 data lib,lst,mac,pas,prn,prt,src,sub,sym,sys,tex,txt,***
223 data 0,5,10,15,20,4,9,14,19,3,8,13,18,2,7,12,17,1,6,11,16
224 data 0,5,10,15,1,6,11,16,2,7,12,17,3,8,13,18,4,9,14
225 data 0,5,10,15,2,7,12,17,4,9,14,1,6,11,16,3,8,13
226 data 0,5,10,15,3,8,13,1,6,11,16,4,9,14,2,7,12
227 dclear:printchr$(14):ifre=1then230
228 open5,2,3,chr$(6)+chr$(0)
229 poke 56579,38:poke56577,peek(56577)and32
230 rs=1:mh=2:bu=0:lm=64000:bb=44000:bp=bb
231 for ke=1 to 8:key ke,"":next
232 key1,"(":key3,"'"::key7,""+chr$(13):key5,""+chr$(13)
233 dimf%(255),t%(255):forj=32to64:t%(j)=j:next
234 t%(13)=13:t%(20)=8:t%(160)=32:t%(15)=15:t%(26)=26:t%(3)=3:t%(16)=16:t%(19=t)=19:t%(17)=17:xc=1
235 t%(21)=21:t%(22)=22:t%(26)=26:t%(24)=24
236 forj=65to90:t%(j)=j+32:next
237 forj=91to95:t%(j)=j:next
238 forj=193to218:t%(j)=j-128:next
239 t%(134)=19:t%(135)=17:t%(136)=27
240 forj=0to255:hk=t%(j)
241 ifhk<>0thenf%(hk)=j:f%(hk+128)=j
242 next
243 goto 251
244 scnclr 5:print:print:print"    Something's wrong!!!!    "
245 dclose:printchr$(143):printds$
246 print:print"             Error in line number  ";:printel:sleep 3
247 resume 251
248 scnclr:char,10,10,"    Please confirm exit command  -=>   (E) ",1
249 getkey ex$:if ex$="e" then print"":else 251
250 dclose:sleep3:print"":poke808,110:end
251 ifpeek(5125)=1then77
252 dclose:a$=""
253 print"":scnclr 5
254 print"             Smallterm CP/M Menu  "
255 print" =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
256 print
257 print"99999999999999999999999999999999999999999999999"
258 print"4     $$$$$                                   6"
259 print"4      <E>          Exit this program         6"
260 print"4     $$$$$                                   6"
261 print"4      <S>          Screen reverse toggle     6"
262 print"4     $$$$$                                   6"
263 print"4      <D>          Disk directory (8)        6"
264 print"4     $$$$$                                   6"
265 print"4      <R>          Read seq file from disk   6"
266 print"4     $$$$$                                   6"
267 print"4      <T>          Terminal mode             6"
268 print"4     $$$$$                                   6"
269 print"4      <C>          CP/M Utilities            6"
270 print"4     $$$$$                                   6"
271 print"4                                             6"
272 print"88888888888888888888888888888888888888888888888"
273 print:print"        ^ "chr$(143)"         Please choose one!   "
274 poke 208,0
275 getkey ch$
276 print"                                                                     "
277 if ch$="c" then77
278 if ch$="e" then goto248
279 if ch$="s" then rs=rs+1:else 284
280 :          if rs>2 then rs=1
281 :          if rs=1 then printchr$(27)"n"
282 :          if rs=2 then printchr$(27)"r"
283 goto 253
284 if ch$="d" then goto 289:else 285
285 if ch$="r" then goto 297:else 286
286 rem ...
287 if ch$="t" then poke 56577,(peek(56577)or32):goto 324:else 251
288 goto251
289 printchr$(7)
290 dclear:window47,2,79,23,1
291 print"                                 "
292 for c7=1 to 19:print"                                 ":next c7
293 print"                                 "
294 window50,4,77,21,1
295 catalog
296 sleep1:print"":goto 273
297 dclear
298 print""
299 input"What is the name of the file  -=>      ";f$
300 if f$="" then 251
301 print"What type of file is that?";:print"    <P>rogram <U>ser or <S>eq"
302 getkey o$
303 if o$="" then 251
304 t$=left$(o$,1)
305 if o$<>"s"then ifo$<>"p" then ifo$<>"u"then301
306 print"Use the 'no scroll' key to pause --- Any other will stop."
307 print"---------------------------------------------------------"
308 window 0,3,79,24
309 open 15,8,15
310 open 6,8,5,"0:"+f$+","+o$+",r"
311 gosub321
312 get#6,a$
313 if st=0 then 317
314 if st=64 then print"-=*=- End of file -=*=-"
315 dclose:sleep1:print:print:print:print"                  Hit any key to continue "
316 getkey y$:goto 251
317 if a$=chr$(34)then:a$=chr$(39)
318 print(a$+chr$(0));
319 get q$:if q$="" then 312:else print"Stopped":goto315
320 goto 312
321 input#15,a$,b$,c$,d$
322 if val(a$)>0 then:print"":printa$,b$,c$,d$
323 return
324 printchr$(7)
325 print"";
326 print"    F1=Options menu  F3=D/L CP/M File(s)  F5=^0+return  F7=^P+return"
327 print" #############################################################################"
328 window 0,2,79,24,1:print:goto 1
329 print"":cp$="":ty$="":dclear
330 print"      Recieve xmodem file.        Hit  'A'  during transfer to abort!"
331 print"888888888888888888888888888888888888888888888888888888888888888888888888888":print:print
332 gosub153:ife2then325
333 print:print"Starting disk status is -=> ";ds$:sleep5:print:print
334 bk=1:xx=1
335 tr=0:as=0:scnclr5:gosub363:print#5,chr$(21);:goto163
336 tt=0:ifas=1thenprint#5,chr$(6);
337 get#5,a$:ifa$=chr$(4)thenifbk>1thenprint#5,chr$(6);:print"* Download completed *":printchr$(7):cs=64:return
338 ifa$=chr$(1)thengosub363:goto342
339 tt=tt+1:iftt<400then337:print"++ timeout error++                    "
340 tr=tr+1:iftr<10thenprint#5,chr$(21);:goto336
341 print"++ Transfer aborted--too many errors          ":printchr$(7) :goto357
342 get ab$:if ab$="a" then 357
343 ck=0:bf$=""
344 get#5,w$:ifw$=""thenw$=chr$(0)
345 get#5,c$:ifc$=""thenc$=chr$(0)
346 ifasc(w$)<>(255-asc(c$))thenprint"++ invalid block header ++":forj=1to400:get#5,a$:nextj:goto340
347 if asc(w$)<>bk then print "++ block sync lost, aborting transfer":print#5,"";:goto357
348 ct=0
349 get#5,a$:ifa$=""thena$=chr$(0)
350 ck=ck+asc(a$)
351 bf$=bf$+a$:ct=ct+1:ifct<128then349
352 get#5,a$:ifa$=""thena$=chr$(0)
353 if(ck and 255)=asc(a$) then bk=bk+1:xx=xx+1:as=1:else 356
354 ifbk>255thenbk=0:tr=0:return
355 tr=0:return
356 print"++ checksum error ++":goto340
357 dclose:print#5,chr$(6);:a$="":e1=1:return
358 dclose:a$="":gosub361:print"Total CP/M space used = ";int(xx)"K":sleep5
359 goto196
360 bank1:d=d1+(n-1)*32:poked,229:bank15:return
361 xx=xx*128/1024:ifxx>int(xx)thenxx=xx+1:return
362 return
363 print"XModem Download in progress"
364 print"Downloading -=> ";cp$+"."+ty$
365 print"Receiving block number -=>";xx:return
366 print"                         Welcome to Smallterm CP/M"
367 print"     With this terminal program you can DOWNLOAD directly to your C128"
368 print"       cp/m disks provided they are 168k disks and NOT double sided."
369 print"          NOTE: C64 cp/m disks CANNOT be used with this program."
370 print"           This program uses XMODEM protocol for ALL downloads."
371 print"                 Terminal portions by Bombs Away Software."
372 print"               Transfer cp/m related portions by Mike McLawhorn."
373 print"           Hacked together for all cp/m 128 owners by Jim Broughton."
374 print"                          press any key to continue":getkeya$:return
