;a-bbs.442 ==1c01== 10000 print "{home}{home}{clr}441" 10020 clr 10040 sd%=peek(186):rem sys files drive 10060 ml%=9: rem user files drive 10080 close 4:open 4,3 10100 print"running a-bbs ...{CTRL-G}" 10120 print chr$(27)+"e" :rem non-flashing 10140 print chr$(14);:rem lower case 10160 poke 53280,0:poke 53281,0 10180 rem basic 128 compiler directives 10200 rem @tlc 10220 rem @ i=f <- loop cntr 4 file header routine 10240 rem @ i=i,j,k,l,su leave as float, for non-interrupt for loops 10260 rem @ i=n,o,p,q,r,ee leave as float, for interrupt for loops 10280 rem @ i=ex,max,ef can be % 10300 rem @ i=ty,ky,lt,kt can be % 10320 rem xt <- leave as float 10340 trap 44580:rem trap line when compiling 10360 rem********** programming conventions / notes *********** 10380 rem single letter vars and t1$ t2% t1 etc are local (non-interrupt) 10400 rem i1$,i2% i1 etc are interrupt temporary/local 10420 rem double letter vars are global/permanent 10440 rem use i,j,k,l,m loop counters in non-interrupt routines 10460 rem use n,o,p,q,r loop counters of interrupt 10480 rem important that interrupt routines not interfere 10500 rem with regular ones 10520 : 10540 rem file #'s 8 dskin,9 dskout,126 submitin,127 conin,128 conout,10 header 10560 rem 4 printer/monitor output 10580 rem*init 10600 if rwindow(2)=80 then fast:else slow 10620 ver$="1.0 r1":ser$="0000001":rem version, serial number 10640 cx%=0:rem collision interupt run flag, ci% will toggle between 1 and 0 10660 : 10680 print"init: initializing variables" 10700 rem args , number, letter, type map map 10720 dim ar$(30), dv%(30), dv$(30), dt$(30),dr$(5), dr%(5) 10740 dim sa$(30), sv%(30), sv$(30) :rem submits own argument array 10760 dim ca$(30), cv%(30), cv$(30) :rem sced's own argument array 10780 : rem alarm loop arrays 10800 dim ad%(5) :rem alarm delay 10820 dim mn%(5) :rem monitor stat 10840 dim ms%(5) :rem byte written to output port 10860 dim id%(5) :rem entry delay time for loop 10880 dim od%(5) :rem exit delay time for loop 10900 dim ln$(5) :rem loop name english description 10920 dim ln%(5) :rem loop stat, 0 is closed, >0 is open 10930 : for i=0 to 3:ms%(i)=-1:next i 10940 : 10960 dim pn$(5) :rem pot name 10980 dim pn%(5) :rem pot minimum 11000 dim px%(5) :rem pot max 11020 dim ps%(5) :rem pot status 11040 dim sl(5) :rem pot slope 11060 dim bi(5) :rem pot bias 11080 : for i=0 to 3:pn%(i)=0:px%(i)=9999:sl(i)=1:bi(i)=0:next i 11100 : 11120 dim me$(5):rem alarm message buffer 11140 dim nt$(5):rem note buffer 11160 dim tm$(10),tm%(10) :rem tod clock, each element is a digit 11180 dim mm$(12):rem month name array 11200 dim fi$(7):rem file info header 11220 dim fi%(7):rem file info header 11240 mm$(1)="jan":rem this array indexed by mm% 11260 mm$(2)="feb" 11280 mm$(3)="mar" 11300 mm$(4)="apr" 11320 mm$(5)="may" 11340 mm$(6)="jun" 11360 mm$(7)="jul" 11380 mm$(8)="aug" 11400 mm$(9)="sep" 11420 mm$(10)="oct" 11440 mm$(11)="nov" 11460 mm$(12)="dec" 11480 : 11500 mm%=1 :rem january 11520 dd%=1 :rem first day of month 11540 yy%=1989:rem a good year 11560 ap%=0:rem 0 is am, 1 is pm, used to check am->pm which means a new day! 11580 hr$="":rem hour string 11600 mn$="":rem minute string 11620 sh$="0":rem sched hour time 11640 sm$="0":rem sched min time 11660 sp%=0:rem sched am/pm , 0=am 1=pm 11680 sh%=0:rem sched flag, 0 not happened today, 1=has happened today 11700 se%=0:rem sched enable flag, 0=off/1=on 11720 ca$(0)="submit" :cv%(0)=sd%:rem sched 11740 ca$(1)="etc/auto":cv%(1)=8:rem system sched script 11760 : 11780 ba$=chr$(32)+chr$(32)+chr$(71)+chr$(1):rem baud rate 11800 ti$="000000" :rem set software clock (used for time of each session) 11820 pi%=0:rem input port data 11840 id%=0:rem entry delay flag 11860 od%=0:rem exit delay flag 11880 it%=0:rem entry delay ticks counter 11900 ot%=0:rem exit delay ticks counter 11920 ad%=5:rem alarm time in seconds 11940 ul%=0:rem upload flag (uload in prog) 11960 po%=0:rem printer online flag, set by interrrupt 11980 pe%=0:rem printer enable flag 12000 pu%=3:rem access level for printer/log 12010 bk%=0:rem break on/off flag 12020 : 12040 pc%=0:rem pot counter 12060 pq%=1:rem pot quit, max for count 12080 : 12100 da$="[da$-not-set]":rem updated by clock 12120 tm$="[tm$-not-set]" 12140 cm$="":rem command line string 12144 ci%=0 :rem index 4 cmd line 12145 dim co$(50):rem old command strings 12146 cr%=0 :rem index recall 12147 co%=0 :rem index 4 old cmds 12148 ed%=0 :rem command line edit flag 12160 : 12180 : 12200 md$="ATE0":rem modem init 12205 hg$="+++":rem modem hangup 12210 lg$="#send control-c or delete to login" 12215 ip$="":rem string for input command, %! 12220 su=0: rem arg counter 4 submit, never alter except in submit 12240 ol%=0: rem old level, temp store 12260 ou$="": rem old user name, temp store 12280 sv%=0 :rem temp store for port two ddr 12300 vb%=0:rem verbose flag 12320 ln%=0:rem index current loop number 12340 pn%=0:rem index current pot 12360 ah%=0:rem alarm happen flag 12380 pt%=0:rem pot triggered flag 12400 al%=0:rem greater than 0 then alarm will 12420 : rem sound! set when the first monitored loop is closed 12440 fu%=0:rem user found flag, 1 if found 12460 un$="":rem user name 12480 pw$="":rem password 12500 lv%=0 :rem level 12520 fr$="":rem first 12540 ln$="":rem last 12560 ad$="":rem addr 12580 ct$="":rem city 12600 st$="":rem state 12620 zp$="":rem zip 12640 vn$="":rem voice 12660 dn$="":rem data 12680 me$="":rem memo 12700 : 12720 rl%=0:rem read level 12740 wl%=0:rem write 12760 : 12780 tr%=0 :rem login attempts counter 12800 yr%=10:rem max number of login attempts 12820 : 12840 rem max for timers, hang up if max is exceeded 12860 xx=0 :rem timeout loops initial start time 12880 lt=4000:rem login time out, 40 sec 12900 kt=30000:rem key press time out, 5 min 12920 : 12940 ty=0:rem tty flag, 1 if console is tty 12960 ky=0:rem key flag, 1 if console is keyboard 12980 nc%=127:rem modem not connected 13000 cn%=47:rem modem connected 13020 : 13040 ex=0:rem exit flag, if 1 then logout 13060 eb$="no errors":rem error buffer 13080 ec%=0:rem error counter 4 error trap 13100 hl%=0:rem halt flag 13120 ef%=0:rem error flag 13140 ts=0:rem temp save area for st 13160 ei%=0:rem end of input flag, when reading files 13180 rv%=0:rem return value (any command may set) 13200 : 13220 dy$="":rem directory 13240 id$="[id$-not-set]":rem system id 13260 : 13280 rem dev #: dev type 13300 dr%(0)=sd%:rem a: 13320 dr%(1)=ml%:rem b: 13340 dr%(2)=ml%:rem c: 13360 dr%(3)=ml%:rem d: 13380 dr%(4)=ml%:rem e: 13400 : 13420 rem number type letter 13440 dv%=dr%(0):dt$=dr$(0):dv$="a" :rem startup drive 13460 : 13480 rem dim the ed buffer last 13500 max=1000:dim bu$(1000):rem ed buffer, max and dim are the same! 13520 : 13540 print"init: enable interrupt" 13580 sprite 1,1,1,1,0,0,0 :rem projectile 13600 sprite 2,1,1,1,0,0,0 :rem target 13620 movspr 1,10,74 :rem position sprites (little dots) 13640 movspr 2,170,74 13660 movspr 1,90#5 :rem begin movment of #1 13680 collision 1,39980 :rem interupt service routine 13700 rem*a-bbs main 13720 rem etc/config 13740 close 127:close 128: open 127,0:open 128,3 13760 print#128,"main: submitting etc/config" 13780 lv%=4:rem config has system admin permission 13800 ar$(1)="etc/config":ar%=1:dv%(1)=sd%:gosub 20240 13820 lv%=0:rem reset permission 13840 close 127:close 128 13860 : 13880 do 13900 : do 13920 : ti$="000000" 13940 : ex=0:un$="":dy$="":rem clear out some stuff 13960 : ty=0:ky=0:tr%=0 13980 : print "{home}{home}{clr}"; 14000 : print " a-bbs ver:";ver$;":";ser$ 14020 : print " (c) Copyright 1989 - Andrew Gaunt" 14040 : print " {rvon}a{rvof}-answer : {rvon}o{rvof}-originate : {rvon}{rvof}-login" 14060 : 14080 : print " date:";da$;" time:";tm$ 14100 : print " ----------------------------------------" 14120 : gosub 32780 : rem window setup 14140 : lv%=0 :rem unblock sched'ed scripts 14160 : print "{clr}"; 14180 : gosub 14840 : rem idle 14200 : gosub 15660 : rem login 14220 : loop until lv%>0 14240 : print "{home}{home}{clr}"+chr$(15)+" {rvon} a-bbs [";id$;"] in - use {rvon} " 14260 : print chr$(143);:rem blink off 14280 : print " date:";da$;" time:";tm$ 14300 : print " user:";un$;" level:";lv% 14320 : print " city:";ct$;" state:";st$ 14340 : print " ----------------------------------------" 14360 : print chr$(27)+"f":rem flashing cursor 14380 : gosub 32780 :rem window 14400 : gosub 39680 :rem hard coded intro screen 14420 : ar$(0)="main":dy$="" 14440 : ol%=lv%:lv%=4:bk%=0 14460 : ar$(1)="etc/profile":ar%=1:dv%(1)=sd%:gosub 20240 :rem sys profile 14480 : lv%=ol%:rl%=0:wl%=0 14500 : ar$(0)="main":ar$(1)="etc/issue":ar%=1:dv%(1)=sd%:gosub 26680 14520 : ar$(0)="main":ar$(1)="etc/motd":ar%=1:dv%(1)=sd%:gosub 26680 14540 : dy$=un$+"/":rem dir "user name +/" 14560 : ar$(1)="profile":ar%=1:dv%(1)=ml%:gosub 20240 :rem user startup 14580 : gosub 17060 :rem shell 14600 : gosub 32320 :for i=0 to 50:co$(i)="":next i:rem zap edit&recall buf 14620 : slow 14640 : dy$="":ex=0:bk%=0 14660 : lv%=4:ar$(1)="etc/exit":ar%=1:dv%(1)=sd%:gosub 20240 :rem exit script 14680 : ex=0:lv%=0:rem just in case 14700 loop :rem do forever 14740 : 14760 rem** end a-bbs main 14780 : 14800 : 14820 rem*idle 14840 close 1:open 1,2,0,ba$ 14860 close 2:open 2,0 14880 print chr$(15)+"{home}{rvon}disconnecting and initializing modem{rvof}"+chr$(143) 14900 print#1,hg$;:sleep 4:print#1,hg$;:sleep 4:rem disconnect 14920 print#1,md$;:rem init the modem 14940 print "{home} " 14960 : 14980 rem check for input, keyboard - rs232 (1200 baud) 15000 do 15020 : ex=0:lv%=0:un$="":dy$="" 15040 : 15060 : get#2,t1$ 15080 : if t1$ <> "" then begin 15100 : print "key: 0x"+hex$(asc(t1$))+" : "+t1$ 15120 : ky=1:ty=0 15140 : bend 15160 : if t1$="a" then print#1,"ATA":t1$="" 15180 : if t1$="o" then print#1,"ATDT":t1$="" 15200 : if t1$="s" then print "*slow*":slow 15220 : if t1$="f" then print "*fast*":fast 15240 : if t1$="x" then print chr$(27);"x"; 15260 : 15280 : get#1,t2$ 15300 : if t2$ <> "" then begin 15320 : print "{rvon}tty{rvof}: 0x"+hex$(asc(t2$))+" : "+t2$ 15340 : if t2$=chr$(13) then print#1,lg$;chr$(10) 15360 : ty=1:ky=0 15380 : bend 15400 : 15420 : if t2$=chr$(3) or t1$=chr$(3) or t2$=chr$(127) or t1$=chr$(13) then begin 15440 : print#1,chr$(13);chr$(10); 15460 : print#1,chr$(13);chr$(10); 15480 : sleep 1 15500 : close 1:close 2:close 127:close 128:exit 15520 : bend 15540 loop 15560 return 15580 rem*end idle 15600 : 15620 : 15640 rem*login 15660 if ty=1 then begin 15680 : close 127:open 127,2,0,ba$ 15700 : close 128:open 128,2,0,ba$ 15760 bend 15780 : 15800 if ky=1 then begin 15820 : close 127:open 127,0 15840 : close 128:open 128,3 15900 bend 15920 : 15940 xt=ti 15960 rem*login and validate 15980 do 16000 : 16020 : do 16040 : un$="":t2$="" 16060 : print#128 16080 : print#128,"login:"; 16100 : do 16120 : get#127,t1$ 16140 : if t1$=chr$(13) then exit 16160 : if t1$<>"" then print#128,t1$;:if len(t2$)<=3 then t2$=t2$+t1$ 16180 : 16200 : if ti>(xt+lt) then print#128:print#128,"#timeout: ti=";ti;" xt=";xt:ex=1:return 16220 : loop 16240 : un$=t2$ 16260 : print#128 16280 loop until un$<>"" :rem no null user name 16300 : 16320 : pw$="":t2$="" 16340 : print#128 16360 : print#128,"password:"; 16380 : do 16400 : get#127,t1$ 16420 : if t1$=chr$(13) then exit 16440 : if t1$<>"" then t2$=t2$+t1$:print#128,"."; 16460 : if len(t2$)>10 then exit 16480 : if ti>(xt+lt) then print#128:print#128,"#timeout: ti=";ti;" xt=";xt:ex=1:return 16500 : loop 16520 : pw$=t2$ 16540 : print#128 16560 : 16580 : rem*validate user 16600 : 16620 : ar$(1)=un$:ar$(2)=pw$:gosub 34940:rem user 16640 : rem if found user with level greater than zero then let them in 16660 : if lv%<>0 and fu%=1 then begin 16680 : print#128,"#user name:"+un$+" access level:";lv% 16700 : return :rem ****** user ok 16720 : bend: else begin 16740 : tr%=tr%+1 16760 : if tr%>yr% then begin 16780 : print#128,"#too many invalid attempts" 16800 : sleep 1 16820 : print#128,"+++"; 16840 : sleep 3:ex=1:return 16860 : bend 16880 : bend 16900 : 16920 loop 16960 : 16980 rem*end of login 17000 : 17020 : 17040 rem*shell 17060 print#128,"#shell":rem entry point 17080 : 17120 ex=0 17140 : 17160 do 17200 : print#128,dv$+":"+dy$+"> "; 17220 : gosub 32960:rem input 17240 : gosub 33540:rem convt to upper case 17260 : gosub 17460:rem acknowledge 17280 : gosub 21460:rem parse 17300 : gosub 22480:rem find devices 17320 : 17340 : gosub 18300 :rem execute commands 17360 loop until ex=1 17380 return 17400 : 17420 : 17440 rem*acknowledge entry 17460 if ty%=1 then print#128 17480 if vb%=1 then print#128,"<";id$;":";da$+":"+tm$+":"+ti$+":"+un$+":";lv%;":"+chr$(34)+cm$+chr$(34) 17500 if ty%=1 then print "<";id$;":";da$+":"+tm$+":"+ti$+":"+un$+":";lv%;":"+chr$(34)+cm$+chr$(34):print 17520 if vb%=1 then print#128 17540 return 17560 : 17580 : 17600 rem 17620 rem*ls, dir 17640 print#128,"#control-c or delete to stop" 17660 ef=0 17680 for i=1 to ar% 17700 : 17760 if dv$(i)="" then dv%(i)=dv% 17780 if ar$(i)="" then ar$(i)="*" 17800 close 8:open 8,dv%(i),0,"$"+dy$+ar$(i) 17820 rem close 15:close 8:open 15,dv%(i),15,"i0:":open 8,dv%(i),0,"$"+dy$+ar$(i) 17840 if ef or ds>=20 then print#128,ar$(0)+": ";dv$(i);" bad directory":goto 18180 17860 get#8 ,a$,b$:n$=chr$(0) 17880 : 17900 do 17920 : get#8,a$,b$:if b$="" then exit 17940 : get#8,a$,b$:a=asc(a$+n$):b=asc(b$+n$) 17960 : c$=mid$(str$(a+256*b),2)+chr$(32) 17980 : print#128, c$;:get#8,c$ 18000 : if c$=chr$(199) then exit 18020 : if c$<>"" then goto 17980 18040 : print#128 18060 : for j=1 to 5 18080 : get#127,t1$:if t1$<>" " then 18120 18100 : get#127,t1$:if t1$="" then 18100 18120 : if t1$=chr$(127) or t1$=chr$(3) then print#128:exit 18140 : next j 18160 loop until ef 18180 close8:close15 :rem this line ref'ed 18200 next i 18220 return 18240 : 18260 : 18280 :rem*built-in cmds 18300 if ty=1 then for i=0 to ar%:print dv$(i);ar$(i);" ";:next i:print 18320 if ar$(0)="" and dv$(0)="a:" then dv%=dr%(0):dv$="a":dt$=dr$(0):return 18340 if ar$(0)="" and dv$(0)="b:" then dv%=dr%(1):dv$="b":dt$=dr$(1):return 18360 if ar$(0)="" and dv$(0)="c:" then dv%=dr%(2):dv$="c":dt$=dr$(2):return 18380 if ar$(0)="" and dv$(0)="d:" then dv%=dr%(3):dv$="d":dt$=dr$(3):return 18400 if ar$(0)="" and dv$(0)="e:" then dv%=dr%(4):dv$="e":dt$=dr$(4):return 18420 : 18440 if dv$(0)="" then begin 18460 if ar$(0)="?" or ar$(0)="help" then gosub 39460:return 18480 if ar$(0)="ls" or ar$(0)="dir" or ar$(0)="directory" then gosub 17640:return 18500 if ar$(0)="cp" or ar$(0)="copy" then gosub 23760:return 18520 if ar$(0)="mv" or ar$(0)="rename" then gosub 25220:return 18540 if ar$(0)="rm" or ar$(0)="scratch" then gosub 23480:return 18560 if ar$(0)="loop" then gosub 27960:return 18580 if ar$(0)="type" or ar$(0)="cat" then gosub 26680:return 18600 if ar$(0)="concat" then gosub 20100:return 18610 if ar$(0)="mode" then gosub 28740:return 18620 if ar$(0)="read" then gosub 28740:return 18640 if ar$(0)="write" then gosub 28740:return 18660 if ar$(0)="uload" then gosub 38740:return 18680 if ar$(0)="xmit" then gosub 20100:return 18685 if ar$(0)="xrcv" then gosub 20100:return 18700 if ar$(0)="submit" or ar$(0)="<" then gosub 20240:return 18720 if ar$(0)="mail" then gosub 33740:return 18740 if ar$(0)="play" then gosub 21080:return 18760 if ar$(0)="port" then gosub 27260:return 18765 if ar$(0)="input" then gosub 19600:return 18800 if ar$(0)="dump" or ar$(0)="disp" then gosub 37340:return 18820 if ar$(0)="set" or ar$(0)="clear" then gosub 36220:return 18840 if ar$(0)="exit" then ex=1:return 18860 if ar$(0)="ed" then gosub 28980:return 18880 if ar$(0)="dos" or ar$(0)="@" then gosub 23220:return 18900 if ar$(0)="cd" then gosub 22880:return 18920 if ar$(0)="time" then gosub 25600:return 18940 if ar$(0)="date" then gosub 26320:return 18960 if ar$(0)="user" then gosub 34940:return 18980 if ar$(0)="echo" or ar$(0)="print" or ar$(0)="log" then gosub 19400:return 19000 if ar$(0)="40" and lv%>3 then graphic 0 :return 19020 if ar$(0)="80" and lv%>3 then graphic 5 :return 19040 if ar$(0)="verbose" then vb%=1 :return 19060 if ar$(0)="terse" then vb%=0 :return 19080 if ar$(0)="breakon" then bk%=1 :return 19100 if ar$(0)="nobreak" then bk%=0 :return 19120 if ar$(0)="fast" then fast :return 19140 if ar$(0)="slow" then slow :return 19160 if ar$(0)="sleep" then gosub 27780:return 19180 if ar$(0)="rerun" and lv%>3 then run:end 19200 if ar$(0)="find" or ar$(0)="grep" then gosub 19660:return 19220 if ar$(0)="restart" and lv%>3 then run"p-a-bbs.*",u(sd%):end 19240 if ar$(0)="exec" and ar$(1)<>"" and lv%>3 then run (ar$(1)),u(dv%(1)):end 19260 if left$(ar$(0),1)="#" then :return:rem comment 19280 if ar$(0)<>"" then print#128,"shell: "+ar$(0)+" not found" 19300 bend 19340 return 19345 rem*end built-in 19360 : 19365 : 19380 rem*echo 19400 if ar$(0)="echo" then:for i=1 to ar%:print#128,ar$(i);:next i 19420 if ar$(0)="print" and lv%>=pu% then:for i=1 to ar%:print#4,ar$(i);:next i 19440 if ar$(0)="log" and lv%>=pu% then begin 19460 : close 9:open 9,sd%,9,"etc/log,s,a": print "ds:";ds:rem log file 19480 : if ef% or ds>=20 then print#128,ar$(0);": can't open etc/log":goto 19520 19500 : for i=1 to ar%:print#9,ar$(i);:next i 19520 : close 9:rem this line ref'ed 19540 bend 19560 return 19580 rem*end echo 19595 : 19596 rem*input 19600 gosub 32960 :rem gp input 19603 if ar$(1)="-c" or ar$(2)="-c" then gosub 33540:rem convert 19605 if ar$(1)="-p" or ar$(2)="-p" then gosub 21460:rem parse 19610 ip$=cm$ 19612 for i=1 to len(ip$) 19615 : if mid$(ip$,i,1)=" " then mid$(ip$,i,1)="{ensh}" 19617 next i 19620 return 19630 : 19640 rem*find 19660 if ar$(2)="" then print#128,"usage: ";ar$(0);" pattern file ...":return 19680 for i=2 to ar% 19700 : rv%=0:t1$="":t2$="":t0%=0:t1%=1:t2%=0:t3%=1:t4%=len(ar$(1)) 19720 : fi$(0)=dy$+ar$(i):fi%(0)=dv%(i):gosub 28260:if fi%(3)=0 then goto 19980 19740 : close 8:open 8,dv%(i),8,dy$+ar$(i)+",m,r" 19760 : if ef or ds>20 then print#128,ar$(0);": can't access ";ar$(i):goto 19980 19780 : do 19800 : get#8,t1$:if t1$=chr$(199) then exit 19820 : if t1$=chr$(13) and t0%=1 then print#128,"#line ";t1%:print#128,t2$:t0%=0 19840 : t2$=t2$+t1$ 19845 : if len(t2$)>254 then t2$="":print#128,ar$(0);": line ";t1%;" too long (255 chars) ; splitting":t1%=t1%+1 19860 : if t1$=chr$(13) then t2$="":t1%=t1%+1 19880 : if t1$=mid$(ar$(1),t3%,1) then t2%=1:t3%=t3%+1:else t2%=0:t3%=1 19900 : if t3%>t4% then t0%=1:rv%=1 19920 : get#127,t5$:if t5$=chr$(3) or t5$=chr$(127) then exit 19940 loop until ef or ex=1 19960 if t0%=1 then print#128,t2$ 19980 close 8 :rem ref'ed 20000 next i 20020 return 20040 : 20060 : 20080 rem*not imp 20100 print#128,ar$(0)+": not implemented yet" 20120 return 20140 : 20160 : 20180 rem*submit 20200 rem copy args to submits own special arg buffers 20240 for i=0 to ar%:sa$(i)=ar$(i):sv$(i)=dv$(i):sv%(i)=dv%(i):next i:sa%=ar% 20260 if hl%=1 then print "submit: blocked! system halted":return 20280 bk%=0:rem nobreak 20300 for su = 1 to sa% 20320 ef=0:ei%=0:ex=0 20340 fi$(0)=dy$+sa$(su):fi%(0)=sv%(su):gosub 28260 20345 if fi%(0)=0 then print#128,ar$(0);": file has no header":goto 20920 20350 if fi%(3)=0 then print#128,ar$(0);": file can't be read":goto 20920 20360 close 126:open 126,sv%(su),126,dy$+sa$(su)+",s,r" 20380 if ef or ds>=20 then print#128,ar$(0);": can't open ";dy$;sa$(su):goto 20920 20400 : 20420 do 20440 : 20460 : cm$="":ei%=0 20480 : for i=0 to 30:dv$(i)="":dv%(i)=0:ar$(i)="":dt$(i)="":next i:rem clear out args, devs for submitted commands 20500 : if vb%=1 then print#128,dv$+":"+dy$+"] "; 20520 : do 20540 : get#126,a$:if a$=chr$(199) then a$="":ei%=1 20560 : if vb%=1 then print#128,a$; 20580 : if lv%>0 and bk%=1 then get#127,t1$:if t1$=chr$(3) or t1$=chr$(127) then ei%=1 20600 : if a$>=chr$(32) and a$160 then exit 20700 : loop until ef or ei%=1 20720 : 20740 : gosub 33540 rem convert 20760 : 20780 : gosub 17460 :rem acknowledge 20800 : 20820 : gosub 21460 rem find arguments 20840 : gosub 22480 rem find devices 20860 : if ar$(0)="<" or ar$(0)="submit" then print#128,sa$(0)+": "+ar$(0)+" blocked!":else gosub 18300 :rem if not self then execute command 20880 : 20900 loop until ex=1 or ef or ei%=1 20920 close 126 :rem ref'ed 20940 next su 20960 return 20980 : 21000 rem*end submit 21020 : 21040 : 21060 rem*play 21080 if lv%<3 then print#128,ar$(0)+": permission denied":return 21100 t1$="":t2$="abcdefg 0123456789 votux#$whqis.rm" 21120 for i=1 to ar% 21140 : for j=1 to len(ar$(i)) 21160 : for k=1 to len(t2$) 21180 : if mid$(ar$(i),j,1)=mid$(t2$,k,1) then t1$=t1$+mid$(ar$(i),j,1) 21200 : next k 21220 : next j 21240 next i 21260 play t1$ 21280 return 21300 rem*end play 21320 : 21340 : 21360 rem*parse 21420 rem ar$(0..n) are the arguments, ar%=number of arguments 21440 rem separate cm$ into arguments 21460 j=0:e1%=0:q1%=0 21480 for i=1 to 160 21500 if mid$(cm$,i,1)=chr$(34) and q1%=0 then q1%=1:cm$=left$(cm$,i-1)+right$(cm$,len(cm$)-i) 21520 if mid$(cm$,i,1)=chr$(34) and q1%=1 then q1%=0:cm$=left$(cm$,i-1)+right$(cm$,len(cm$)-i) 21530 t1$=mid$(cm$,i,1) 21540 if t1$=" " and q1%=1 then mid$(cm$,i,1)="{ensh}" 21560 if e1%=1 and len(cm$)<160 then begin 21580 : if t1$="d" then cm$=left$(cm$,i-1)+da$+right$(cm$,len(cm$)-i):goto 22040 21600 : if t1$="t" then cm$=left$(cm$,i-1)+tm$+right$(cm$,len(cm$)-i):goto 22040 21620 : if t1$="i" then cm$=left$(cm$,i-1)+id$+right$(cm$,len(cm$)-i):goto 22040 21625 : if t1$="!" then cm$=left$(cm$,i-1)+ip$+right$(cm$,len(cm$)-i):goto 22040 21640 : if t1$="u" then cm$=left$(cm$,i-1)+un$+right$(cm$,len(cm$)-i):goto 22040 21660 : if t1$="v" then cm$=left$(cm$,i-1)+me$+right$(cm$,len(cm$)-i):goto 22040 21680 : if t1$="o" then cm$=left$(cm$,i-1)+mm$(mm%)+right$(cm$,len(cm$)-i):goto 22040 21700 : if t1$="a" then cm$=left$(cm$,i-1)+right$(str$(dd%),len(str$(dd%))-1)+right$(cm$,len(cm$)-i):goto 22040 21720 : if t1$="h" then cm$=left$(cm$,i-1)+hr$+right$(cm$,len(cm$)-i):goto 22040 21740 : if t1$="m" and len(cm$)<160 then cm$=left$(cm$,i-1)+mn$+right$(cm$,len(cm$)-i):goto 22040 21760 : if t1$="n" then cm$=left$(cm$,i-1)+chr$(13)+chr$(10)+right$(cm$,len(cm$)-i):goto 22040 21780 : if t1$="0" then cm$=left$(cm$,i-1)+str$(ps%(0))+right$(cm$,len(cm$)-i):goto 22040 21800 : if t1$="1" then cm$=left$(cm$,i-1)+str$(ps%(1))+right$(cm$,len(cm$)-i):goto 22040 21820 : if t1$="2" then cm$=left$(cm$,i-1)+str$(ps%(2))+right$(cm$,len(cm$)-i):goto 22040 21840 : if t1$="3" then cm$=left$(cm$,i-1)+str$(ps%(3))+right$(cm$,len(cm$)-i):goto 22040 21860 : if t1$="p" then cm$=left$(cm$,i-1)+str$(pi%)+right$(cm$,len(cm$)-i):goto 22040 21880 : if t1$="g" then mid$(cm$,i,1)="{CTRL-G}":goto 22040 21900 : if t1$="r" then mid$(cm$,i,1)=chr$(13) 21920 : if t1$="e" then mid$(cm$,i,1)=chr$(27) 21940 : if t1$="b" then mid$(cm$,i,1)=chr$(8) 21960 : if t1$="s" then mid$(cm$,i,1)="{ensh}" 21980 : if t1$="j" then mid$(cm$,i,1)=chr$(10) 22000 : if t1$="f" then mid$(cm$,i,1)=chr$(12) 22020 : if t1$="q" then mid$(cm$,i,1)=chr$(34) 22040 : e1%=0:rem this line ref'ed 22060 bend 22080 if mid$(cm$,i,1)="%" and q1%=0 and e1%=0 then cm$=left$(cm$,i-1)+right$(cm$,len(cm$)-i):i=i-1:e1%=1 22100 if i30 then j=30:rem max # of args 22220 : next i 22240 : bend 22260 : bend 22280 : rem tab to forces spaces into arguments 22300 : if mid$(cm$,i,1)="{ensh}" then mid$(cm$,i,1)=" " 22320 : ar$(j)=ar$(j)+mid$(cm$,i,1):ar%=j 22340 if i=2 then begin 22540 : t1$=left$(ar$(i),2) 22560 : if t1$="a:" then dv$(i)="a:":dv%(i)=dr%(0):dt$(i)=dr$(0):gosub 22740 22580 : if t1$="b:" then dv$(i)="b:":dv%(i)=dr%(1):dt$(i)=dr$(1):gosub 22740 22600 : if t1$="c:" then dv$(i)="c:":dv%(i)=dr%(2):dt$(i)=dr$(2):gosub 22740 22620 : if t1$="d:" then dv$(i)="d:":dv%(i)=dr%(3):dt$(i)=dr$(3):gosub 22740 22640 : if t1$="e:" then dv$(i)="e:":dv%(i)=dr%(4):dt$(i)=dr$(4):gosub 22740 22660 : bend 22680 next i 22700 return 22720 : 22740 t1%=len(arg$(i))-2 22760 arg$(i)=right$(arg$(i),t1%) 22780 return 22800 rem end of pick device specifiers 22820 : 22840 : 22860 rem*cd 22880 if mid$(ar$(1),2,1)="/" then begin 22900 : t1%=val(left$(ar$(1),1)) 22920 : if t1%<1 or t1%>3 then print#128,"cd: invalid directory name":return 22940 : if t1% > lv% then print#128,"cd: can't cd beyond "+str$(lv%)+"/":return 22960 : dy$=ar$(1)+"/":return 22980 bend :else begin 23000 : if ar$(1)<>"" and lv%>=3 then dy$=ar$(1)+"/" 23020 : if ar$(1)="" and lv%>=3 then dy$="" 23040 : if ar$(1)="" and lv%<3 then dy$=un$+"/"+ar$(1) 23060 : if ar$(1)<>"" and lv%<3 then print#128,ar$(0);": permission denied" 23080 bend 23100 print#128,"#current directory is: ";dy$ 23120 return 23140 rem*end cd 23160 : 23180 : 23200 rem*@,dos 23220 if ar%>=1 then: for i=1 to ar%: t1$=ar$(i):gosub 23280:next i:else print#128,ds$ 23240 return 23260 : 23280 if lv% < 4 then print#128,ar$(0);": permission denied":return 23300 close 15:open 15,dv%(i),15,t1$:close15 23320 sd$=ds$:print#128,sd$ 23340 return 23360 rem*end @,dos 23380 : 23400 : 23420 : 23440 rem*rm 23460 : 23480 if ar%>=1 then: for i=1 to ar%: t1$=ar$(i):gosub 23540:next i:else print#128,"usage: "+ar$(0)+" [d:]file[,file] [[d:]file]" 23500 return 23520 : 23540 if lv%<2 then print#128,ar$(0)+": permission denied":return 23560 if t1$="mail" then print#128,ar$(0)+": can't remove mail":return 23580 fi$(0)=dy$+t1$:fi%(0)=dv%(i):gosub 28260 23582 if fi%(0)=0 and lv%<4 then print#128,ar$(0);": file has no header":return 23585 if fi%(4)=0 then print#128,ar$(0);": can't remove ";ar$(i):return 23600 close 15:open 15,dv%(i),15,"s0:"+dy$+t1$:close15 23620 print#128,"#removed ";t1$ 23640 return 23660 rem*end rm 23680 : 23700 : 23720 rem*cp, copy files 23740 : 23760 us$=ar$(0)+" [d:]source <[d:][dest]> [<-s,-u,-p>]" 23780 if ar$(1)<>"" and ar$(2)="" then:if dv%(1)<>dv%(2) then ar$(2)=ar$(1) 23785 if ar$(1)<>"" and ar$(2)="" then:if dv%(1)=dv%(2) then print#128,us$:return 23787 if ar$(3)="-p" and lv%<4 then print#128,ar$(0);": permission denied":return 23790 fi$(0)=dy$+ar$(1):fi%(0)=dv%(1):gosub 28260 23793 if fi%(0)=0 then print#128,ar$(0);": file has no header":return 23795 if fi%(3)=0 then print#128,ar$(0);": can't read source file":return 23796 fi$(0)=dy$+ar$(2):fi%(0)=dv%(2):gosub 28260 23797 if fi%(4)=0 then print#128,ar$(0);": can't write destination file":return 23800 if ar$(1)<>"" and ar$(2)<>"" then begin 23820 : if dv%(1)<>dv%(2) then begin 23840 : gosub 24120:rem multi drive copy 23860 : bend:else begin 23880 : t1$=ar$(1):t2$=ar$(2) 23885 : print#128,"#copying on same device ..." 23920 : close 15:open 15,dv%(1),15,"c0:"+dy$+t2$+"="+dy$+t1$:close15 23940 : print#128,ds$ 23960 : bend 23980 bend: else print#128,us$ 24000 return 24020 rem*end cp 24040 : 24060 : 24080 rem*cp between drives , called by mv and cp 24100 rem next line is point of entry 24120 ef=0 24140 if ar$(1)="" or ar$(2)="" then print#128,us$:return 24160 if ar$(3)="" then ar$(3)="-s" 24180 if ar$(3)="-s" then t1$="s" 24200 if ar$(3)="-u" then t1$="u" 24220 if ar$(3)="-p" then t1$="p" 24240 : 24260 if t1$="s" or t1$="u" then begin 24300 : close 8:open 8,dv%(1),8,dy$+ar$(1)+",m,r" 24320 : ifds>=20 then close 8:print#128,ar$(0)+": disk error: ";ar$(1):goto 24580 24360 : close 15:open 15,dv%(2),15,"s0:"+dy$+ar$(2):close 15 24380 : close 9:open 9,dv%(2),9,dy$+ar$(2)+","+t1$+",w" 24400 : if ef or ds>=20 then close 8:close 9:print#128,ar$(0)+": disk error: ";ar$(2) 24420 : 24425 : print#128,"#copying between devices ..." 24440 : do 24460 : get#8,a$:ef=st:if a$=chr$(199) or ds>=20 then exit 24480 : print#9,a$; 24500 : get#127,t1$:if t1$=chr$(3) or t1$=chr$(127) then print#128,ar$(0)+": aborted":exit 24510 : if vb%=1 and ty=1 then print#128,"."+chr$(8); 24515 : if vb%=1 and ky=1 then print#128,".{left}"; 24520 : loop until ef 24540 : print#128,"#done" 24560 : 24580 : close 8:close 9 :rem ref'ed 24600 bend:else 24620 : 24640 if t1$="p" and lv%>3 then begin 24660 : mem=4000 :rem after here in bank 1 may get zapped! 24680 : print#128,"#bank 1" 24700 : print#128,"#start address 0x";hex$(mem) 24720 : 24740 : bload(dy$+ar$(1)),u(dv%(1)),b1,p(mem) 24760 : if ds>=20 then goto 25060 24780 : 24800 : sal=(peek(173)*256)+peek(172):rem start addr load 24820 : eal=(peek(175)*256)+peek(174):rem end addr load 24840 : 24860 : print#128,"#end address 0x";hex$(eal) 24880 : print#128,"#saving..."+dy$+ar$(2); 24900 : 24920 : close 15:open 15,dv%(2),15,"s0:"+dy$+ar$(2):close 15 24940 : bsave(dy$+ar$(2)),u(dv%(2)),b1,p(mem) to p(eal) 24960 : print#128,"#done!" 24980 bend 25000 : 25020 : 25060 if left$(sd$,2)="62" then print#128,ar$(0);": check file type":rem ref'd 25080 close 8:close 9:close 15 25100 return 25120 rem*end cp across 25140 : 25160 : 25180 :rem*mv 25200 : 25220 usage$="usage: "+ar$(0)+" [d:]source [d:]dest [-s] [-u] [-p]" 25240 if ar$(1)<>"" and ar$(2)="" then:if dv%(1)<>dv%(2) then ar$(2)=ar$(1) 25260 if ar$(1)="mail" or ar$(2)="mail" then print#128,ar$(0)+": can't remove mail":return 25263 if ar$(3)="-p" and lv%<4 then print#128,ar$(0);": permission denied":return 25265 fi$(0)=dy$+ar$(1):fi%(0)=dv%(1):gosub 28260 25267 if fi%(0)=0 and lv%<4 then print#128,ar$(0);":source file has no header":return 25269 if fi%(3)=0 then print#128,ar$(0);": can't read source file":return 25273 if fi%(4)=0 then print#128,ar$(0);": can't remove source file":return 25275 fi$(0)=dy$+ar$(2):fi%(0)=dv%(2):gosub 28260 25277 if fi%(4)=0 then print#128,ar$(0);": can't write destination file":return 25280 if ar$(1)<>"" and ar$(2)<>"" then begin 25300 : if dv%(1)<>dv%(2) then begin 25340 : gosub 24120:rem multi drive copy 25360 : close 15:open 15,dv%(1),15,"s0:"+dy$+ar$(1):close15 25380 : bend:else begin 25400 : t1$=dy$+ar$(1):t2$=dy$+ar$(2) 25440 : fi$(0)=t2$:fi%(0)=dv%(2):gosub 28260:if fi%(4)=0 then return 25460 : close 15:open 15,dv%(1),15,"r0:"+t2$+"="+t1$:close15:print#128,ds$ 25480 : bend 25500 bend:else print#128,usage$ 25520 return 25540 rem*end of mv 25560 : 25580 rem*time 25600 if lv%<4 or ar%<1 then print#128,tm$:return 25620 if ar%<>2 or len(ar$(1))<>6 then print#128,"usage: ";ar$(0);" [hhmmss am or pm]":return 25640 : 25660 tm$(6)=mid$(ar$(1),6,1):rem sec 1 25680 tm$(5)=mid$(ar$(1),5,1):rem sec 2 25700 tm$(4)=mid$(ar$(1),4,1):rem min 1 25720 tm$(3)=mid$(ar$(1),3,1):rem min 2 25740 tm$(2)=mid$(ar$(1),2,1):rem hour 1 25760 tm$(1)=mid$(ar$(1),1,1):rem hour 2 25780 tm$(0)=mid$(ar$(2),1,2):rem am/pm 25800 if tm$(0)<>"pm" then tm$(0)="am" 25820 if tm$(0)="pm" then tm%(0)=128:else tm%(0)=0 25840 : 25860 t1$=tm$(1)+tm$(2):rem fix for setting am/pm for 12'th hour 25880 if tm$(0)="pm" and t1$="12" then tm%(0)=0 25900 if tm$(0)="am" and t1$="12" then tm%(0)=128 25920 : 25940 if val(tm$(6))<=9 and val(tm$(6))>=0 then tm%(6)=val(tm$(6)) 25960 if val(tm$(5))<=5 and val(tm$(5))>=0 then tm%(5)=val(tm$(5)) 25980 if val(tm$(4))<=9 and val(tm$(4))>=0 then tm%(4)=val(tm$(4)) 26000 if val(tm$(3))<=5 and val(tm$(3))>=0 then tm%(3)=val(tm$(3)) 26020 if val(tm$(2))<=9 and val(tm$(2))>=0 then tm%(2)=val(tm$(2)) 26040 if val(tm$(1))<=1 and val(tm$(1))>=0 then tm%(1)=val(tm$(1)) 26060 : 26080 : 26100 poke 56329,(16*tm%(5))+tm%(6):rem seconds 26120 poke 56330,(16*tm%(3))+tm%(4):rem minutes 26140 poke 56331,tm%(0)+(16*tm%(1))+tm%(2):rem am/pm flag and hours 26160 : 26180 poke 56328,0:rem write to tenths to start clock 26200 tm$="[updating]":rem will be updated by interrupt routine 26220 return 26240 rem*end time 26260 : 26280 : 26300 rem*date 26320 if ar%=0 or lv%<4 then print#128,da$:return 26340 t1$="usage: "+ar$(0)+" [mm dd yyyy]" 26360 if ar%<3 then print#128,t1$:return:rem check format 26380 if len(ar$(1))>2 then print#128,t1$:return 26400 if len(ar$(2))>2 then print#128,t1$:return 26420 if len(ar$(3))>4 then print#128,t1$:return 26440 : 26460 rem invalid numbers set date to first month/day/year 01/01/1989 26480 mm%=val(ar$(1)):if mm%<0 or mm%>12 then mm%=1 26500 dd%=val(ar$(2)):if dd%<0 or dd%>31 then dd%=1 26520 yy%=val(ar$(3)):if yy%<1989 then yy%=1989 26540 da$="[updating]" 26560 return 26580 rem*end date 26600 : 26620 : 26640 rem*type 26660 : 26680 usage$="usage: "+ar$(0)+" [d:]file ..." 26700 if ar$(1)="" then print#128,usage$:return 26720 : 26740 for i=1 to ar% 26760 : ef=0 26780 : fi$(0)=dy$+ar$(i):fi%(0)=dv%(i):gosub 28260 26785 : if fi%(0)=0 and lv%<4 then print#128,ar$(0);": file has no header": goto 27080 26787 : if fi%(3)=0 then print#128,ar$(0);": can't read ";ar$(i):goto 27080 26800 : close 8:open 8,dv%(i),8,dy$+ar$(i)+",m,r" 26820 : 26840 : if ef or ds>=20 then print#128,ar$(0);": disk error: ";ar$(i):close 8: goto 27080 26860 : ef=0 26880 : do 26900 : get#8,a$(1),a$(2),a$(3),a$(4):ei=st 26920 : 26940 : for j=1 to 4 26960 : if a$(j)=chr$(199) then print#128,"#eof":exit 26980 : if a$(j)<>chr$(13) then print#128,a$(j);:else print#128 27000 : next j 27020 : get#127,t1$:if t1$=chr$(3) or t1$=chr$(127) then exit 27040 : loop until ef or ei or ex=1 27060 : 27080 : close 8:rem ref'ed 27100 next i 27120 : 27140 : 27160 return 27180 rem*end type 27200 : 27220 : 27240 rem*port 27260 if lv%<4 then print#128,ar$(0)+": permission denied":return 27280 if ar%<1 then print#128,"usage: "+ar$(0)+" byte [address] [bank]":return 27300 : 27320 t1%=val(ar$(2)) :rem byte 27340 if t1%>255 then t1%=255 27360 if t1%<255 then t1%=0 27380 : 27400 if ar$(3)="" then t2=56321:else t2=val(ar$(3)):rem address 27420 if t2<0 or t2>65536 then t2=56321 27440 : 27460 if ar$(4)<>"" then begin 27480 : t3%=val(ar$(4)) 27500 : if t3%<0 or t3%>15 then t3%=15 :rem bank 27520 : bank t3% 27540 bend 27560 : 27580 if left$(ar$(1),2)="an" then poke t2,(peek(t2) and t1%) 27600 if left$(ar$(1),2)="or" then poke t2,(peek(t2) or t1%) 27620 if left$(ar$(1),2)="xo" then poke t2,(xor(peek(t2),t1%)) 27640 if left$(ar$(1),2)="re" then t1%=peek(t2):print#128,"+";t1%;": 0x";right$(hex$(t1%),2) 27660 if left$(ar$(1),2)="wr" then poke t2,t1% 27680 return 27700 rem*end port 27720 : 27740 : 27760 rem*sleep 27780 ar$(1)=left$(ar$(1),4):t1=abs(val(ar$(1))) 27800 if t1>5 and lv%<4 then t1=5:rem 5 sec max 27820 if t1>1200 then t1=1200:rem 20 minutes max 27840 sleep t1 27860 return 27880 rem*end sleep 27900 : 27920 : 27940 rem*loop 27960 print#128,"#hit a key to abort" 27980 t1%=val(ar$(1)) 28000 if lv%<3 and t1%>50 then t1%=50 28020 do 28040 : print#128,using "#####:";t1%; 28060 : print#128,"j0=";"0x";right$(hex$(joy(1)),2);" j1=";"0x";right$(hex$(joy(2)),2);" p0=";ps%(0);" p1=";ps%(1);" p2=";ps%(2);" p3=";ps%(3);" ";chr$(13); 28080 : t1%=t1%-1 28100 : get#127,t1$:if t1$<>"" then exit 28120 loop until t1%<=0 28140 return 28160 rem*end loop 28180 : 28200 : 28220 rem*file header;read/write permission 28240 rem pass in drive fi%(0), file fi$(0) / will be cleared 28260 if lv%<4 then begin 28263 : for f=1 to len(fi$(0)) 28265 : if mid$(fi$(0),f,1)="*" or mid$(fi$(0),f,1)="?" or mid$(fi$(0),f,1)="," then fi$(0)="\wild" 28267 : next f 28269 bend 28270 close 10:open 10,fi%(0),10,fi$(0)+",m,r" 28280 : 28300 for f=0 to 6:fi$(f)="":fi%(f)=0:next f 28320 for f=1 to 6:get#10,fi$(1):fi$(0)=fi$(0)+fi$(1):next f 28340 rem ver name user read write date time 28360 if fi$(0)="#@(1)#" then input#10,fi$(1),fi$(2),fi$(3),fi$(4),fi$(5),fi$(6) 28380 close 10 28400 if ty=1 then:for f=0 to 6:print fi$(f);",";:next f:print 28420 if fi$(0)="#@(1)#" then fi%(0)=1:else fi%(0)=0 :rem headerflag 28440 if fi$(1)<>"" then fi%(1)=1:else fi%(1)=0 :rem name flag 28460 if fi$(2)=un$ or fi$(2)="" then fi%(2)=1:else fi%(2)=0 :rem owner flag 28480 if val(fi$(3))>lv% and fi%(2)<>1 then fi%(3)=0:else fi%(3)=1:rem read flag 28500 if val(fi$(4))>lv% and fi%(2)<>1 then fi%(4)=0:else fi%(4)=1:rem writeflag 28520 if fi%(0)=0 then fi%(2)=1:fi%(3)=1:fi%(4)=1:rem no header, read write ok 28540 : 28560 if fi%(0)=1 then print#128,fi$(1) 28580 if fi%(2)=0 then print#128,"#owner: ";fi$(2) 28600 if fi%(3)=0 then print#128,"#read : ";fi$(3) 28620 if fi%(4)=0 then print#128,"#write: ";fi$(4) 28640 : 28660 return 28680 : 28700 : 28720 rem*read,write,mode 28740 ar$(1)=left$(ar$(1),1):rem no big numbers 28760 if ar$(0)="read" and ar$(1)<>"" then rl%=val(ar$(1)) 28780 if ar$(0)="write" and ar$(1)<>"" then wl%=val(ar$(1)) 28785 if ar$(0)="mode" and ar$(1)<>"" and ar$(2)<>"" then rl%=val(ar$(1)):wl%=val(ar$(2)) 28800 if rl%>4 then rl%=5 28820 if rl%<0 then rl%=0 28840 if wl%>4 then wl%=5 28860 if wl%<0 then wl%=0 28880 if ar$(1)="" then print#128,"read=";rl%;" write=";wl% 28900 return 28920 : 28940 : 28960 rem*ed 28980 if ar$(1)<>"" then gosub 29360 29000 print#128,"#"+ar$(0)+": ? for help" 29020 : 29040 rem*ed main 29060 q=0 29080 do 29100 : print#128,str$(bu%+1)+"/"+str$(lp%)+" "+dv$+":"+dy$+"* "; 29120 : gosub 32960:rem input 29140 : gosub 33540:rem conver to upper case ascii 29160 : gosub 21460:rem args 29180 : gosub 22480:rem devs 29200 : if ar$(0)<>"" then gosub 29760 29220 loop until q=1 or ex=1:rem user has typed x or q 29240 print#128 29260 return 29280 rem*end main 29300 : 29320 : 29340 rem*read 29360 if ar$(1) <> "" then fi$=dy$+ar$(1) :else print#128,"ed: r [d:]file":return 29400 fi$(0)=fi$:fi%(0)=dv%(1):gosub 28260:if fi%(3)=0 then goto 29640 29410 if fi%(0)=0 and lv%<4 then print#128,ar$(0);": file has no header":goto 29640 29415 if fi%(3)=0 then print#128,ar$(0);": can't read ";ar$(1):goto 29640 29417 print#128,"#reading" 29420 close 8:open 8,dv%(1),8,fi$+",m,r" 29460 if ds>=20 then print#128,ar$(0);": disk error: ";fi$:goto 29640 29480 ef=0 29500 do 29520 : get#8,a$:if a$=chr$(199) or st=64 then exit 29540 : get#127,t2$:if t2$=chr$(3) or t2$=chr$(127) then print#128,ar$(0)+": read aborted":exit 29560 : t1$=str$(lp%) 29580 : ifa$=chr$(13)thenlp%=lp%+1:gosub 31600:print#128,"#line "+t1$+chr$(13);:goto29520 29600 : bu$(lp%)=bu$(lp%)+a$ 29620 loop until ef or ts 29640 close 8:rem this line referenced 29660 print#128,"#last line is "+str$(bu%) 29680 return 29700 : 29720 : 29740 rem*commands 29760 if ar$(0)="p" then gosub 31840 :goto 30140 29780 if ar$(0)="l" then gosub 32480 :goto 30140 29800 if ar$(0)="?" then gosub 30240 :goto 30140 29820 if ar$(0)="x" then q=1:return 29840 if ar$(0)="q" then q=1:return 29860 if ar$(0)="r" then gosub 29360 :goto 30140 29880 if ar$(0)="d" then gosub 31320 :goto 30140 29900 if ar$(0)="w" then gosub 30700 :goto 30140 29920 if ar$(0)="i" then gosub 31600 :goto 30140 29940 if ar$(0)="$" then lp%=bu% :goto 30140 29960 if ar$(0)="a" then gosub 32120 :goto 30140 29980 if ar$(0)="e" then gosub 31180 :goto 30140 30000 if ar$(0)="z" then gosub 32320 :goto 30140 30020 if ar$(0)="read" then gosub 28740 :goto 30140 30040 if ar$(0)="write" then gosub 28740 :goto 30140 30045 if ar$(0)="mode" then gosub 28740 :goto 30140 30060 if ar$(0)="" then goto 30140 30080 if val(ar$(0))>=0 and val(ar$(0))<=bu% then lp%=val(ar$(0)) 30100 if val(ar$(0))<=0 and val(ar$(0))>=bu% then print#128,"ed: invalid command" 30120 if lp%<=0 or lp%>bu% then lp%=0 :rem keep lp% sane 30140 print#128 30160 return 30180 : 30200 : 30220 rem*help 30240 print#128:print#128,"? - help" 30260 print#128,"prompt, x/y x=total lines, y=current Line" 30280 print#128,"print and list mark current line with a ->" 30300 print#128," p - print +- 6 lines to terminal" 30320 print#128," l [n1 [n2]] - list all lines or lines n1 to n2" 30340 print#128," w [d:]- write buffer to disk" 30360 print#128," r [d:]- read file into buffer" 30380 print#128," d [n] - delete one or n line" 30400 print#128," i [n] - insert one or n blank lines" 30420 print#128," e - edit current line" 30440 print#128," a - append text into buffer" 30460 print#128," $ - goto end of buffer" 30480 print#128," z - zap buffer(no warning)" 30500 print#128," x,q - exit editor" 30520 print#128," read n - set read permission to level n 30540 print#128," write n - set write permission to level n 30560 print#128,"nn - point to line nn" 30580 print#128:print#128,"maximum buffer size is "+str$(max)+" lines " 30600 print#128,str$((bu%/max)*100)+"% full" 30620 return 30640 : 30660 : 30680 rem*write 30700 if ar$(1) <>"" then fi$=dy$+ar$(1):else print#128,"ed: w [d:]file":return 30720 ef=0 30740 : 30760 fi$(0)=fi$:fi%(0)=dv%(1):gosub 28260 30765 if fi%(4)=0 then print#128,ar$(0);": can't write ";ar$(1):return 30780 print#128,"#removing "+dv$(1)+" "+fi$ 30800 close 15:open 15,dv%(1),15,"s0:"+fi$:close 15 30820 print#128,"#writing "+fi$+" to disk" 30840 close 8:open 8,dv%(1),8,fi$+",s,w" 30860 if ef then close 8:close 15:return 30880 : 30900 print#8,"#@(1)#" 30920 print#8,"# ";fi$;",";un$;",";rl%;",";wl%;",";da$;",";tm$ 30940 for i=0 to bu% 30960 : get#127,t2$:if t2$=chr$(3) or t2$=chr$(127) then print#128,ar$(0)+": write aborted":goto 31060 30980 : print#128,"#line "+str$(i)+chr$(13); 31000 : print#8,bu$(i) 31020 next i 31040 : 31060 close 8 :rem ref'ed 31080 print#128,"#"+str$(i-1)+" lines written" 31100 return 31120 : 31140 : 31160 rem*edit line 31180 print#128,"":print#128,"#edit line [";lp%;"] , ^b ^f ^p ":print#128,bu$(lp%) 31185 k$=bu$(lp%) 31200 gosub 32960:rem input 31220 if cm$<>"" then bu$(lp%)=cm$ 31240 if lp%bu% then lp%=bu% 31500 next j 31520 return 31540 : 31560 : 31580 rem*insert line 31600 for j=1 to abs(val(ar$(1))) 31615 : if bu%=>max then print#128 "#buffer full "+str$(max)+" lines":bu%=max:return 31620 : for i=bu% to lp% step -1 31640 : bu$(i+1)=bu$(i) 31660 : next i 31680 : bu%=bu%+1 31720 : bu$(lp%)="" 31740 next j 31760 return 31780 : 31800 : 31820 rem*print a screen full 31840 if bu%-lp%>=6 then t1=6 31860 if bu%-lp%<=6 then t1=bu%-lp% 31880 if lp%>6 then t2=6 31900 if lp%<=6 then t2=lp% 31920 print#128 31940 for i=lp%-t2 to lp%+t1 31960 : if i=lp% then t3$="->" 31980 : if i<>lp% then t3$=" " 32000 : print#128,t3$+str$(i)+") "+bu$(i) 32020 next 32040 return 32060 : 32080 : 32100 rem*append mode 32120 print#128,"#enter a period . on a line by itself to end append" 32140 : gosub 32960:t1$=cm$ 32160 : if t1$="." then goto 32240 32180 : ar$(1)="1":gosub 31600 32200 : bu$(lp%)=t1$:lp%=lp%+1 32220 : print#128,"":goto 32140 32240 return 32260 : 32280 : 32300 rem*zap buffer 32320 for i=0 to bu% 32340 : bu$(i)="" 32360 next 32380 lp%=0:bu%=0 32400 return 32420 : 32440 : 32460 rem*list 32480 print#128,"#control-c or delete to stop" 32500 if ar$(2)<>"" and val(ar$(2))<=bu% and val(ar$(2))>0 then t2%=val(ar$(2)):else t2%=bu% 32520 if ar$(1)<>"" and val(ar$(1))>=0 and val(ar$(1))lp% then t3$=" " 32600 : get#127,t1$:if t1$=chr$(3) or t1$=chr$(127) then return 32620 : print#128,t3$+str$(i)+") "+bu$(i) 32640 next i 32660 return 32680 : 32700 rem*end ed 32720 : 32740 : 32760 rem*screen init 32780 if rwindow(2) = 40 then window 0,5,39,24,1 32800 if rwindow(2) = 80 then window 0,5,79,24,1 32840 return 32860 rem*end screen init 32880 : 32900 : 32920 rem*general purpose input 32940 rem gets a line from file#127 and puts it into cm$ 32960 t1$="":rem call this line 32970 if k$<>"" then print#128,k$; 32980 ci%=len(k$):ed%=0 33020 : 33040 do 33060 : rem get a char and check to see if modem still has carrier 33100 : xt=ti 33120 : do 33140 : get#127,t1$ 33160 : if ty=1 and peek(56577)=nc% then ex=1:return: rem hung up the phone 33180 : if ti>(xt+kt) then print#128:print#128,"#keyboard timeout: ti=";ti;" xt=";xt:ex=1:return 33200 : loop until t1$<>"" 33240 : 33260 : if t1$=chr$(127) or t1$=chr$(3) then k$="":print#128:exit 33280 : if t1$=chr$(13) then print#128:print "{rvof}":exit 33285 : if ty=1 and (t1$=chr$(8) or t1$=chr$(20)) then print chr$(20);" ";chr$(20); 33287 : if t1$=chr$(16) then begin :rem ^p 33289 : k$=co$(cr%):ci%=len(k$):ed%=0 33291 : cr%=cr%-1:if cr%<0 then cr%=50 33293 : print#128:print#128,chr$(13);k$; 33294 : goto 33400 33297 : bend 33300 : if t1$=chr$(2) then ed%=1:rem ^b 33305 : if t1$=chr$(6) then ed%=1:rem ^f 33310 : if (t1$=chr$(8) or t1$=chr$(20)) and len(k$)>0 and ed%=0 then begin 33312 : k$=left$(k$,len(k$)-1):ci%=len(k$) 33313 : print#128,t1$;" ";t1$; 33315 : goto 33400 33317 : bend 33320 : if (t1$=chr$(8) or t1$=chr$(20)) and len(k$)<=0 then print#128,"{CTRL-G}";:goto 33400 33325 : if ci%=chr$(32) and t1$<=chr$(126) then print#128,t1$;:else print#128,"{CTRL-G}%"; 33385 : if ty=1 and t1$>=chr$(32) and t1$<=chr$(126) then print "{rvon}";t1$;"{rvof}"; 33400 loop :rem ref'ed 33420 cm$=k$:co$(co%)=k$:k$="" 33425 if co$(co%)<>"" then co%=co%+1:if co%>50 then co%=0 33427 cr%=co% 33440 return 33460 rem*end general purpose input 33463 : 33465 : 33467 rem*edit mode, gp input 33469 if t1$=chr$(27) then ci%=len(k$):print#128,chr$(13);k$;:cr%=co%:ed%=0:return 33471 if t1$=chr$(6) then t1$="":ci%=ci%+1:goto 33500 33473 if t1$=chr$(2) then t1$="":ci%=ci%-1:goto 33500 33475 if (t1$=chr$(8) or t1$=chr$(20)) and ci%>0 then begin 33476 : ci%=ci%-1:t1$="" 33477 : t1%=len(k$) 33478 : if t1%>0 then k$=left$(k$,ci%)+right$(k$,t1%-(ci%+1)) 33479 : goto 33500 33480 bend 33481 if (t1$=chr$(8) or t1$=chr$(20)) and ci%<=1 then print#128,chr$(7);:t1$="":goto 33500 33483 t1%=len(k$) 33485 if t1%<160 then k$=left$(k$,ci%)+t1$+right$(k$,t1%-ci%):else print#128,"{CTRL-G}";:rem 160 chars 33488 ci%=ci%+1 33493 : 33495 : 33500 if ci%<0 then ci%=len(k$):rem ref'ed 33503 if ci%>len(k$) then ci%=0 33505 if ci%=len(k$) then begin 33506 : print#128,chr$(13);k$; 33507 bend:else begin 33508 : print#128,chr$(13); 33509 : for k=1 to len(k$) 33511 : if ci%=k-1 then print#128,">"; 33512 : print#128,mid$(k$,k,1); 33513 : next k 33514 bend 33515 print#128,"< "; 33516 return 33517 rem*end edit mode 33518 : 33519 : 33520 rem*convert 33540 q1%=0 33543 for t1=1 to len(cm$) 33545 : t1$=mid$(cm$,t1,1) 33560 : if t1$=chr$(34) and q1%=0 then q1%=1:goto 33620 33565 : if t1$=chr$(34) and q1%=1 then q1%=0:goto 33620 33570 : if asc(t1$) >=97 and asc(t1$) <=122 then begin 33580 : if q1%=0 then mid$(cm$,t1,1)=chr$(asc(mid$(cm$,t1,1))-32) 33600 : bend 33620 next:rem this line ref'ed 33625 q1%=0 33640 return 33660 rem*end convert 33680 : 33700 : 33720 rem*mail 33740 if dy$<> un$+"/" then dy$=un$+"/":print#128,"mail: current directory is: ";dy$ 33760 if dv%<> ml% then print#128,ar$(0)+": invalid drive for mail: ";dv$:return 33780 if ar$(1)<>"" then gosub 33960:return:rem if arguments, then send mail 33800 gosub 32320:rem zap edit buffer 33820 print#128,"#editing mail file for "+un$ 33840 ar$(1)="mail":dv%(1)=ml%:gosub 28980 33860 return 33880 rem*end rmail 33900 : 33920 : 33940 rem*smail 33960 if dy$<>un$+"/" then print#128,ar$(0)+": must cd to ";un$:return 33980 if ar$(3)="" then print#128,"usage:";ar$(0);" [user subject file]":return 34000 mu$=ar$(1) 34020 su$=ar$(2):rem subject 34040 mf$=ar$(3):rem file 34060 ar$(2)="":ar$(3)="" 34080 print#128,"#searching for user "+ar$(1)+"...." 34100 gosub 34940 :rem check for valid user 34120 if fu%<>1 then print#128,"#"+ar$(1)+" not found":return 34140 if fu%=1 then print#128,"#found" 34160 : 34180 : 34200 ef=0 34220 fi$(0)=un$+"/"+mf$:fi%(0)=ml%:gosub 28260 34223 if fi%(0)=0 then print#128,ar$(0);": source file has no header":return 34225 if fi%(3)=0 then print#128,ar$(0);": can't read source file":return 34280 fi$(0)=mu$+"/mail":fi%(0)=ml%:gosub 28260 34283 if fi%(0)=0 then print#128,ar$(0);": dest file has no header":return 34284 if fi%(4)=0 then print#128,ar$(0);": can't write to dest file":return 34290 close 8:open 8,ml%,8,un$+"/"+mf$+",m,r":print "ds:";ds 34295 if ef or ds>=20 then close 8:print#128,"mail: can't open ";mf$:return 34300 close 9:open 9,ml%,9,mu$+"/mail,s,a":print "ds:";ds 34320 if ef or ds>=20 then close 8:close 9:print#128,"mail: can't open ";mu$;"/mail":return 34340 : 34360 print#128,"#writing sub header: ";un$;"/";mf$;" to ";mu$;"/mail" 34380 if ef or ds>=20 then close 8:close 9:print#128,"mail: fatal error":return 34400 : 34420 print#9 34440 print#9,"#############################" 34460 print#9,"# date: ";da$ 34480 print#9,"# time: ";tm$ 34500 print#9,"# to: ";mu$ 34520 print#9,"# from: ";un$ 34540 print#9,"# subject: ";su$ 34560 print#9,"# file: ";mf$ 34580 print#9 34600 : 34620 print#128,"#sending..."; 34640 : 34660 do 34680 : get#8,a$ 34700 : if (a$<=chr$(126) and a$>=chr$(32)) or a$=chr$(13) then print#9,a$;:rem filter out non-printables 34720 loop until st or a$=chr$(199) 34740 close 8:close 9 34760 print#128,"#done" 34780 : 34800 : 34820 return 34840 rem*end smail 34860 : 34880 : 34900 rem*user, search 34920 rem usage: user [user-name [password]]" 34940 : ef=0 :close 8:open 8,sd%,8,"etc/passwd,m,r" 34960 : fu%=0:rem reset found user flag 34980 : if ef then return 35000 : input#8,a$:input#8,a$:rem skip first two lines (header) 35020 do 35040 : get#127,t1$:if t1$=chr$(3) or t1$=chr$(127) then exit:rem user aborted 35060 : input#8,a$,b$,c$,d$,e$,f$,g$,h$,i$,j$,k$,l$ 35080 : if a$="eof" then exit:rem the last user record should be "eof" 35100 : if st then exit:rem two lines should never happen 35120 : if a$=chr$(199) then exit:rem but just in case something goes wrong! 35140 : 35160 : if ar$(1)=a$ or ar$(1)="" then begin 35180 : fu%=1:rem found a valid user 35200 : if lv%>0 then begin 35220 : print#128,"-----------" 35240 : print#128," user:";a$ 35260 : if lv%>=4 then print#128," password:";b$ 35280 : print#128," level:";c$ 35300 : print#128,"first name:";d$ 35320 : print#128,"last name:";e$ 35340 : if lv%>=4 then print#128," addr:";f$ 35360 : print#128," city:";g$ 35380 : print#128," state:";h$ 35400 : if lv%>=3 then print#128," zip:";i$ 35420 : if lv%>=3 then print#128," voice:";j$ 35440 : if lv%>=3 then print#128," data:";k$ 35460 : print#128," memo:";l$ 35480 : print#128,"-----------" 35500 : bend 35520 : bend 35540 : if ar$(1)=a$ and ar$(2)="" then exit 35560 : 35580 : rem user logging in 35600 : if (ar$(1)<>"" and ar$(2)<>"") or lv%=0 then begin 35620 : if ar$(1)=a$ then begin 35640 : if ar$(2)=b$ then begin 35660 : fu%=1 35680 : un$=a$ 35700 : pw$=b$ 35720 : lv%=val(c$) 35740 : fr$=d$ 35760 : ln$=e$ 35780 : ad$=f$ 35800 : ct$=g$ 35820 : st$=h$ 35840 : zp$=i$ 35860 : vn$=j$ 35880 : dn$=k$ 35900 : me$=l$ 35920 : 35940 : print#128,"#ok - logging in..." 35960 : close 9:open 9,sd%,9,"etc/ulog,s,a" 35980 : print#9,un$,str$(lv%),da$,tm$ 36000 : close 9 36020 : bend :else if lv%<>0 then print#128,"#password incorrect" 36040 : bend 36060 : bend 36080 loop until ef 36100 close 8 36110 k$="":rem hack 36120 return 36140 rem*end user 36160 : 36180 : 36200 rem*set 36220 if lv%<4 then print#128,ar$(0)+": permission denied":return 36240 if ar%<1 then print#128,"usage: "+ar$(0)+" variables":return 36260 for i=1 to ar% :rem alias on/off to 1/0 36280 : if val(ar$(i))>32000 then ar$(i)="0":rem filter out large num's 36300 : if ar$(i)="on" or ar$(i)="pm" then ar$(i)="1" 36320 : if ar$(i)="off" or ar$(i)="am" then ar$(i)="0" 36340 next i 36360 ar$(1)=left$(ar$(1),3):rem first three letter are signficant, ignore rest 36380 if ar$(1)="mod" then md$="":for i=2 to ar%:md$=md$+ar$(i)+chr$(13)+chr$(10):next i 36385 if ar$(1)="han" then hg$="":for i=2 to ar%:hg$=hg$+ar$(i)+chr$(13)+chr$(10):next i 36400 if ar$(1)="ver" then vb%=val(ar$(2)):rem verbose mode 36420 if ar$(1)="log" then lt=val(ar$(2)):rem login timeout 36440 if ar$(1)="key" then kt=val(ar$(2)):rem keyboard timeout 36460 if ar$(1)="con" then cn%=val(ar$(2)):rem connected byte 36480 if ar$(1)="bau" then ba$="":for i=1 to 4:ba$=ba$+chr$(abs(val(left$(ar$(i),2)))):next i:rem baud rate,parity etc 36485 if ar$(1)="int" then lg$=ar$(2):rem intro message at login 36500 if ar$(1)="dis" then nc%=val(ar$(2)):rem not connected byte 36520 if ar$(1)="cou" then pc%=val(ar$(2)):rem pot counter 36540 if ar$(1)="qui" then pq%=val(ar$(2)):rem pot counter max 36560 if ar$(1)="pri" then pe%=val(ar$(2)):rem printer enable 36580 if ar$(1)="lev" then pu%=val(ar$(2)):rem printer level 36600 if ar$(1)="err" then ec%=val(ar$(2)):ef=0:rem error count/flag 36620 if ar$(1)="sys" then sd%=val(ar$(2)):rem system drive 36640 if ar$(1)="mai" then ml%=val(ar$(2)):rem mail/user drive 36660 if ar$(1)="ide" then id$=ar$(2):rem system id 36680 rem allow setting of alarm loop arrays (dim'ed at 5) 36700 if val(ar$(2)) <0 or val(ar$(2))>5 then t1%=0: else t1%=val(ar$(2)):rem check for bad indexes! 36720 if ar$(1)="ala" then ad%(t1%)=val(ar$(3)) :rem alarm delay 36740 if ar$(1)="mon" then mn%(t1%)=val(ar$(3)) :rem monitor flag 36760 if ar$(1)="ent" then id%(t1%)=val(ar$(3)) :rem entry delay 36780 if ar$(1)="mas" then ms%(t1%)=val(ar$(3)) :rem mask byte 36800 if ar$(1)="exi" then for i=0 to 3:od%(i)=val(ar$(3)):next i:rem one exit delay for all loops 36820 if ar$(1)="dri" then dr%(t1%)=val(ar$(3)) :rem disk drive map 36840 if ar$(1)="nam" then ln$(t1%)=ar$(3) :rem name of loop 36860 : 36880 if ar$(1)="pot" then pn$(t1%)=ar$(3) :rem name of pot 36900 if ar$(1)="max" then px%(t1%)=val(ar$(3)) :rem max for pot 36920 if ar$(1)="min" then pn%(t1%)=val(ar$(3)) :rem min for pot 36940 if ar$(1)="slo" then sl(t1%)=val(ar$(3)) :rem slope 36960 if ar$(1)="bia" then bi(t1%)=val(ar$(3)) :rem bias 36980 if ar$(1)="mes" then me$(t1%)=ar$(3)+ar$(4)+ar$(5)+ar$(6)+ar$(7):rem alm 37000 if ar$(1)="not" then nt$(t1%)=ar$(3)+ar$(4)+ar$(5)+ar$(6)+ar$(7):rem note 37020 : 37040 if ar$(1)="sch" then begin 37060 : if val(ar$(2))=0 then se%=0:else se%=1:sh%=0:rem set enable,reset done 37080 : sh$=ar$(2):sm$=ar$(3):if val(ar$(4))=1 then sp%=1:else sp%=0:rem sched time 37100 : ca%=1:rem default 37120 : if ar%>4 then begin 37140 : ca%=ar%-3 37160 : for i=5 to ar% 37180 : ca$(i-3)=ar$(i):cv$(i-3)=dv$(i):cv%(i-3)=dv%(i) 37200 : next i 37220 : bend 37240 bend 37260 return 37280 rem*end set 37300 : 37320 rem*dump 37340 if lv%<3 then print#128,ar$(0)+": permission denied":return 37360 ar$(1)=left$(ar$(1),3) 37380 if ar$(1)="" or ar$(1)="loo" then begin 37400 print#128,"---------------------------------------" 37420 print#128,"loop#";" loop-name" 37440 print#128,"- - - - - - - - - - - - - - - - - - - -" 37460 print#128,"monitor entry exit mask alarm last read" 37480 print#128,"on/off ticks ticks byte duratn status" 37500 print#128,"---------------------------------------" 37520 for i=0 to 3 :rem four loops 37540 : print#128,str$(i);" ";ln$(i) 37560 : print#128,"- - - - - - - - - - - - - - - - - - - -" 37580 : print#128, mn%(i);" ";id%(i);" ";od%(i);" ";ms%(i);" ";ad%(i);" ";ln%(i) 37600 : print#128,"---------------------------------------" 37620 next i 37640 bend 37660 if ar$(1)="" or ar$(1)="pot" then begin 37680 print#128,"---------------------------------------" 37700 print#128,"pot#";" pot-name" 37720 print#128,"- - - - - - - - - - - - - - - - - - - -" 37740 print#128,"min max stat slope bias" 37760 print#128,"---------------------------------------" 37780 for i=0 to 3 37800 : print#128,str$(i);" ";pn$(i) 37820 : print#128,"- - - - - - - - - - - - - - - - - - - -" 37840 : print#128, pn%(i);" ";px%(i);" ";ps%(i);" ";sl(i);" ";bi(i) 37860 : print#128,"---------------------------------------" 37880 next i 37900 bend 37920 if ar$(1)="" or ar$(1)="sys" then begin 37960 print#128,"system id:";id$ 37980 print#128,"port, 1=0x";right$(hex$(peek(56321)),2);" 2=0x";right$(hex$(peek(56320)),2) 38000 print#128,"prntr, enab=";pe%;" online=";po%;" print/log level=";pu% 38020 print#128,"pot, 1=";pot(1);" 2=";pot(2);" 3=";pot(3);" 4=";pot(4) 38040 print#128," count=";pc%;" quit=";pq% 38060 print#128,"alarm, flag=";al%;" exit=";od%;" entry=";id% 38080 print#128," hist=";ah%;" last trig: ";ah$ 38100 print#128,"memry, bank0=";fre(0);" bank1=";fre(1) 38120 print#128,"systm, vrbse=";vb%;" sd=";sd%; "md=";ml% 38140 print#128,"timeout, login=";lt;" keyboard=";kt 38160 print#128,"drive, ";:for i=0 to 4:print#128,i;"=";dr%(i);" ";:next i:print#128 38180 print#128,"error, flag=";ef;" count=";ec% 38200 print#128,"last error:":print#128," ";eb$ 38210 bend 38215 if ar$(1)="" or ar$(1)="mod" then begin 38220 print#128,"modem, connect=";cn%;" disconnect=";nc% 38221 print#128,"baud-rate: " 38223 for i=1 to len(ba$) 38225 : print#128,asc(mid$(ba$,i,1));":"; 38226 next i 38227 print#128 38230 print#128,"introduction: ":print#128,lg$ 38240 print#128,"modem-init: ":print#128,md$ 38250 print#128,"modem-hang: ":print#128,hg$ 38280 bend 38300 if ar$(1)="" or ar$(1)="sch" then begin 38340 print#128,"sched, ";val(sh$);":";val(sm$);:if sp%=0 then print#128,"am";:else print#128,"pm"; 38360 if se%=1 then print#128," enabled & ";:else print#128," disabled & "; 38380 if sh%=1 then print#128," done":else print#128," waiting" 38400 print#128,"scripts:" 38420 for i=1 to ca%:print#128," ";chr$(34);cv$(i);ca$(i);chr$(34);" dev=";cv%(i):next i 38460 bend 38480 if ar$(1)="" or ar$(1)="buf" then begin 38520 : print#128,"alarm message:" 38540 : for i=0 to 5:print#128,str$(i);") ";me$(i):next i 38560 : print#128,"note message:" 38580 : for i=0 to 5:print#128,str$(i);") ";nt$(i):next i 38620 bend 38640 return 38660 rem*end dump 38680 : 38700 : 38720 rem*uload 38740 if ar$(1)="" then print#128,"usage: "+ar$(0)+" file":return 38745 if lv%<2 then print#128,ar$(0);": permission denied":return 38760 : ef=0 38780 : fi$(0)=dy$+ar$(1):fi%(0)=dv%(1):gosub 28260:if fi%(4)=0 then return 38800 : print#128,"#removing "+ar$(1) 38820 : close 15:open 15,dv%(1),15,"s0:"+dy$+ar$(1):close 15 38840 : print#128,"#opening "+ar$(1)+" for write" 38860 : close 15:open 8,dv%(1),8,dy$+ar$(1)+",s,w" 38880 : print#8,"#@(1)#" 38900 : print#8,"# ";dy$+ar$(1);",";un$;",";rl%;",";wl%;",";da$;",";tm$ 38920 : if ds>=20 or ef then close 8:print#128,ar$(0)+": can't write to ";ar$(1):sd%=1 38940 : 38960 : 38980 print#128,"#ready to recieve: type control-d to close file" 39000 if sd%=1 or ef then close 8:print#128,ar$(0)+": access error:";:return 39020 ul%=1:ef=0:ei=0 39040 do 39060 : xt=ti 39080 : do 39100 : get#127,a$ 39120 : if ti>(xt+lt) then print#128:print#128,"#timeout: ti=";ti;" xt=";xt:ei=1:exit 39140 : loop until a$<>"" 39160 : if a$=chr$(4) then print#128,"#eof";:exit 39180 : 39200 : t1%=asc(a$) 39220 : if t1%=13 then print#128 :goto 39260 39240 : print#128,a$; 39260 : print#8,a$;:rem this line referenced 39280 loop until ef or ei=1 39300 ul%=0 39320 close 8 39340 print#128,"#file closed" 39360 return 39380 rem*end uload 39400 : 39420 : 39440 rem*help, ? 39460 if ar$(1)="" then print#128,"usage: ";ar$(0)+" subject [subject] ... - eg. ";ar$(0);" help for help on ";ar$(0):return 39480 od$=dy$:dy$="hlp/" :rem temporarily change dir 39500 for i=1 to ar%:dv%(i)=sd%:next i:rem stuff the system drive into dv%(n) 39520 gosub 26680:rem call type subroutine 39540 dy$=od$:rem restore original directory 39560 return 39580 rem*end help 39600 : 39620 : 39640 : 39660 rem*intro 39680 print#128,"# a-bbs: alarm - bulletin board system" 39700 print#128,"# version ";ver$;": serial# ";ser$ 39720 print#128,"# written for you by andrew gaunt, 1989" 39740 print#128,"# (c) copyright 1989 - andrew w gaunt" 39760 print#128,"# all rights reserved" 39780 return 39800 rem*end intro 39820 : 39840 : 39860 : 39880 rem*interrupt * main 39900 rem subroutines called from here are labeled *interrupt * sub-name 39920 rem for clarity 39940 : 39960 : 39980 collision 1 :rem point of entry 40000 if cx%=0 then print chr$(27)+"u";:cx%=1:else print chr$(27)+"s";:cx%=0 40020 if ty=1 and peek(56577)=nc% then ex=1: rem hung up the phone 40040 pi%=peek(56320):rem port 2 is input port 40060 : 40080 rem if alarm has been set 40100 if al%=1 and ah%=0 then begin 40120 : if od%=1 and id%=0 then gosub 44180:rem tick the entry delay 40140 : if id%=1 and od%=1 then gosub 43220:rem this is it, alarm! 40160 bend 40180 : 40200 rem if armed and exit delay passed, monitor the loops 40220 if joy(2)>128 and al%=0 and od%=1 then begin 40240 : print"interrupt: pi%=",pi% 40260 : gosub 42400:rem check, if alarm then al% will be 1 ln% will = loop # 40280 bend 40300 : 40320 rem if armed and exit delay not passed, tick exit delay 40340 if joy(2)>=128 and od%=0 then gosub 44340:rem count down exit 40360 : 40380 rem if disarmed, reset flags, counters, alarm 40400 if joy(2)<128 then begin 40420 : if al%=1 or id%=1 or od%=1 then poke 56320,255:print"interrupt: alarm reset" 40440 : al%=0:ah%=0:id%=0:od%=0:it%=0:ot%=0: rem reset flags and tick counters 40460 bend 40480 : 40500 if ul%=1 then collision 1,39980:return:rem uload in prog, end interrupt 40520 if tm$<>"[tm$-not-set]" then gosub 41540:rem up-date/time 40540 : 40560 gosub 42940:if pt%=1 and pc%0 then begin 40627 : close 4:open 4,3:po%=0:pe%=0 40629 : if lv%>0 then print#128,"interrupt: printer off-line; disabled" 40630 : print "interrupt: printer off-line; disabled" 40631 : bend 40635 bend 40640 : 40660 if pe%=1 and po%=0 then begin 40680 : close 4:open 4,4:print#4,chr$(0); 40700 : if st=0 then begin 40710 : print#4,"interrupt: printer on-line:{rght}";da$;": ";tm$:po%=1 40711 : if lv%>0 then print#128,"interrupt: printer on-line" 40712 : bend:else begin 40714 : if lv%>0 then print#128,"interrupt: printer not on-line; disabled" 40715 : print "interrupt: printer not on-line; disabled":pe%=0 40716 : bend 40717 bend 40719 : 40740 if pe%=0 and po%=1 then close 4:open 4,3:po%=0 40760 : 40780 : 40800 rem sched submit, if no-one is logged on and time is passed sched time 40820 if se%=1 and lv%=0 and sh%=0 and val(hr$)=val(sh$) and val(mn$)>val(sm$) and ap%=sp% then begin 40840 : close 127:close 128: open 127,0:open 128,3 40860 : un$="sch":dy$="":lv%=4:ar$(0)="schedule":dv%=sd% 40880 : rem copy sched's arg arrays into regular arg arrays 40900 : for i=1 to ca%:ar$(i)=ca$(i):dv$(i)=cv$(i):dv%(i)=cv%(i):next i:ar%=ca% 40920 : print "interrupt: submitting scheduled scripts on ";da$;" at ";tm$ 40940 : for i=1 to ar%:print dv$(i);ar$(i):next i 40960 : sh%=1:rem sched happen flag 40980 : gosub 20240 :rem call submit 41000 : lv%=0 41020 bend 41040 : 41060 if lv%=0 then begin 41080 : print chr$(27);"x{home}{home}{clr}"; 41100 : print "system id:";id$ 41120 : print "date:";da$;" time:";tm$ 41140 : print "-------0--1--2--3---------------------" 41160 : print " mon: ";mn%(0);mn%(1);mn%(2);mn%(3) 41180 : print "stat: ";ln%(0);ln%(1);ln%(2);ln%(3) 41200 : print " pot: ";ps%(0);ps%(1);ps%(2);ps%(3) 41220 : print "--------------------------------------" 41240 : print "flags, alarm=";al%;" exit =";od%;" entry=";id% 41280 : print "ticks, exit =";ot%;" limit=";od%(ln%) 41300 : print " entry=";it%;" limit=";id%(ln%) 41310 : print "hist=";ah%;": ";ah$ 41320 : print "-------- n o t e ---- p a d ----------" 41340 : for n=0 to 5:print str$(n);") ";nt$(n):next n 41360 : print chr$(27);"t";chr$(27);"x"; 41380 bend 41400 collision 1,39980 41420 return 41440 rem*end interrupt * main 41460 : 41480 : 41500 rem*interrupt * clock 41520 rem update tm$ and da$ using tod clock 41540 tm%(0)=peek(56331) :rem am/pm flag 41560 tm%(1)=(peek(56331) and 16) /16 :rem hours 41580 tm%(2)=(peek(56331) and 15) 41600 tm%(3)=(peek(56330) and 240)/16 :rem min 41620 tm%(4)=(peek(56330) and 15) 41640 tm%(5)=(peek(56329) and 240)/16 :rem sec 41660 tm%(6)=(peek(56329) and 15) 41680 tm%(7)=(peek(56328) and 240) /16 :rem tenths 41700 tm%(8)=(peek(56328) and 15) 41720 : 41740 for n=1 to 8 41760 : i1$=str$(tm%(n)):i1%=len(i1$)-1 41780 : tm$(n)=right$(i1$,i1%) 41800 next n 41820 hr$=tm$(1)+tm$(2):mn$=tm$(3)+tm$(4) :rem build hr$, mn$ 41840 tm$=hr$+":"+mn$+":"+tm$(5)+tm$(6)+"."+tm$(7)+tm$(8) 41860 : 41880 rem if pm->am then increment day etc, ap% is set to 1 when am->pm 41900 if tm%(0)<128 and ap%>0 then begin 41920 : ap%=0:sh%=0:rem set to am, reset sched happen flag, allow for today 41940 : dd%=dd%+1 41960 : if mm%=2 then begin 41980 : if dd%>28 then mm%=mm%+1:dd%=1 :rem february, non-leap year 42000 : bend 42020 : if mm%=4 or mm%=6 or mm%=9 or mm%=11 then begin 42040 : if dd%>30 then mm%=mm%+1:dd%=1 :rem 30 day months 42060 : bend 42080 : if mm%<>2 and mm%<>4 and mm%<>6 and mm%<>9 and mm%<>11 then begin 42100 : if dd%>31 then mm%=mm%+1:dd%=1 :rem 31 day months 42120 : bend 42140 : if (ty=1 or ky=1) and mm%>12 then yy%=yy%+1:mm%=1:print#128,"#happy new year!{CTRL-G}" 42160 : if mm%>12 then yy%=yy%+1:mm%=1:print#4,"#happy new year!" 42180 : print#4,"clock: ";da$;": ";tm$ 42200 bend 42220 rem update tm$ and da$ 42240 if tm%(0)<128 then tm$=tm$+":am":else tm$=tm$+":pm":ap%=1 42260 : 42280 if da$<>"[da$-not-set]" then da$=mm$(mm%)+":"+str$(dd%)+":"+str$(yy%) 42300 return 42320 rem*****end clock 42340 : 42360 : 42380 rem*interrupt * monitor alarm 42400 print chr$(27)+"xmonitor: check monitored loop closures" 42420 : 42440 ln%(0)=pi% and 1 42460 ln%(1)=pi% and 2 42480 ln%(2)=pi% and 4 42500 ln%(3)=pi% and 8 42520 : 42540 for n=3 to 0 step -1 42560 : print " loop=";n;": mon=";mn%(n);" stat="; 42580 : if ln%(n)=0 then print"{rvon}";ln%(n):else print ln%(n) 42600 : 42620 : rem if closure on monitored loop, then set alarm flag to loop # 42640 : rem this will give loop 0 higest priority, 3 lowest 42660 : if ln%(n)=0 and mn%(n)>0 then al%=1:ln%=n 42680 : 42700 next n 42720 print chr$(27)+"x"; 42740 : 42760 if al%=0 then print "monitor: loops clear":return 42780 : 42800 if al%=1 then print "monitor: alarm set, loop=";ln%;":";ln$(ln%):return 42820 : 42840 print "{CTRL-G}monitor: error! al% in bad state: al%=";al%:return:rem should not happen 42860 rem*interrupt * end monitor alarm 42880 : 42900 : 42920 rem*interrupt * monitor pots 42940 for n=1 to 4:o%=pot(n):if o%<255 then ps%(n-1)=((255-o%)*sl(n-1))+bi(n-1):next n 42960 pt%=0 42980 rem print chr$(27)+"x"; 43000 for n=3 to 0 step -1 43020 : if ps%(n)px%(n) then pt%=1:pn%=n 43040 next n 43060 : 43080 if pt%=1 and lv%=0 then print chr$(27)+"xpotmon: ";pn%;"=";ps%(pn%);":";pn$(pn%);":"da$;":";tm$;chr$(13);chr$(27);"x"; 43100 return 43120 : 43140 rem*interrupt * end monitor pots 43160 : 43180 : 43200 rem*interrupt * alarm 43220 rem this code takes control, if the program gets here then a monitored 43240 rem loop has been closed. could be a break-in. alarms will sound if not 43260 rem stopped opening the arm loop 43280 print#4,"{CTRL-G}alarm: wheeeeee!, loop=";ln%;":"ln$(ln%);": ";da$": ";tm$ 43300 if ty=1 or ky=1 then begin 43320 : print#128 "{CTRL-G}" 43340 : print#128,"{CTRL-G}-------------------------------------" 43360 : print#128,"{CTRL-G} a-bbs is being interrupted " 43380 : print#128,"{CTRL-G}-------------------------------------" 43400 : print#128,"{CTRL-G} * alarm system has been triggered * " 43420 : for n=0 to 5 43440 : print#128,me$(n) 43460 : next n 43480 : print#128,"{CTRL-G}-------------------------------------" 43500 : print#128 43520 bend 43540 : 43560 ar$(0)="alarm":ar$(1)="loop"+right$(str$(ln%),1):dv%(1)=sd%:ar%=1 43580 print#128,"alarm: submitting alarm script ";ar$(1);" on ";da$;": ";tm$ 43600 ol%=lv%:ou$=un$:lv%=4:un$="alm":dy$=un$+"/":rem user is alm (temp) 43620 gosub 20240 :rem call submit 43640 if ex=1 then goto 43740 43660 sv%=peek(56323):poke 56323,255:rem port two ddr 43680 if ms%(ln%)>=0 and ms%(ln%)<256 then poke 56321,ms%(ln%) 43700 print "sleeping for ";ad%(ln%);" seconds ...";:sleep ad%(ln%):print "done !" 43720 poke 56323,sv%:rem restore ddr 43740 ah%=1:ah$=da$+" : "+tm$ :rem alarm has happened !!! this line ref'ed 43760 lv%=ol%:un$=ou$:dy$=un$+"/": rem restore old user settings 43780 return 43800 rem*end alarm 43820 : 43840 : 43860 rem*pot triggered 43880 if lv%>0 then print chr$(27);"xpot: waiting for user to exit";chr$(13);chr$(27);"x";:return 43900 pc%=pc%+1 43920 print "pot: count is ";pc%;" will quit at ";pq% 43940 print "pot: submitting pot script ";ar$(1);" on ";da$;": ";tm$ 43960 ol%=lv%:ou$=un$:lv%=4:un$="alm":dy$=un$+"/":rem user is alm (temp) 43980 ar$(0)="pot":ar$(1)="pot"+right$(str$(pn%),1):dv%(1)=sd%:ar%=1 44000 gosub 20240 :rem call submit 44020 : 44040 lv%=ol%:un$=ou$:dy$=un$+"/": rem restore old user settings 44060 pt%=0 44080 return 44100 rem*end pot triggered 44120 : 44140 : 44160 rem*interrupt * entry delay 44180 if it%>=id%(ln%) then id%=1:print "{CTRL-G}entry: count finished":else id%=0:print"{CTRL-G}entry: count = ";it%,"limit = ";id%(ln%) 44200 it%=it%+1 :rem tick up entry delay 44220 play "o"+str$(ln%+1)+"v1o6u8t0#ib" 44240 return 44260 rem*interrupt * end entry delay 44280 : 44300 : 44320 rem*interrupt * exit delay 44340 if ot%>=od%(ln%) then od%=1:al%=0:print "{CTRL-G}exit: alarm ready":else od%=0:print"exit: count = ";ot%,"limit = ";od%(ln%) 44360 ot%=ot%+1 :rem count down exit ticks 44380 play "o3v1u8t9$ib" 44400 return 44420 rem*interrupt * end exit delay 44440 : 44460 : 44480 : 44500 : 44520 : 44540 : 44560 rem*error handler 44580 ef=1:ec%=ec%+1 44600 if er=5 then ec%=ec%-1 :rem don't count dev not present 44620 if ec%>10 then begin 44640 : close 127:close 128:close 4:open 127,0:open 128,3:open 4,3 44660 : collision 1,39980 44680 : 44700 : do 44720 : hl%=1:rem halt flag 44740 : print chr$(27)+"x" 44760 : print "{rvon} error: system halted, too many errors! {rvof}" 44780 : print err$(er);" at line:";el;" " 44800 : print "{rvon} "+da$;": ";tm$;" {rvof}{up}{up}{up}{up}" 44820 : loop 44840 bend 44860 : 44880 eb$=err$(er)+" at line: "+str$(el) 44900 if ty=1 and lv%>0 then print#128,"error: #";ec%;": ";err$(er);" at line: ";el;" ";da$;" ";tm$ 44920 : 44940 dy$=un$+"/":rem force user to home directory if error 44960 : 44980 close 4:if po%=1 and pe%=1 then open 4,4:else open 4,3 :rem open file 4 45000 print#4,"error: #";ec%;": ";err$(er);" at line: ";el;" ";da$;" ";tm$ 45020 : 45040 for ee=0 to 4:dclose u(dr%(ee)):next ee :rem close files on all drives 45060 : 45080 rem lv%=0:rem reset level, user will have to login again (user command) 45100 collision 1,39980:rem restore interrupt if neccesary 45120 resume next 45140 rem*end error handler 45160 rem*end of a-bbs