; MONITOR.MAC - 1/11/86 - Monitor while MailBox/GateWay idle. .z80 maclib TNC.LIB entry chgca,mon,monini,moncon,prthrd,infm1,ncmsg entry chgca,cafcb,mofcb,seebea,mcalls,hrdmax,wtmon external @prtx,@opena,@openr,tobuf,@closew,@ntobuf external cmd,cmdlen,$memry,rdcmd,bindec,@cmpcmd,@openw external waitc,@outch,@fill,@cmp,@move,muldec,@mcmd external @srct,@srcl,@srcn,@srcw,@srcc,@src external @adll,@adlm,@adlw,@adln,@adlt,@adlc,@adl external logtxt,mcall,curtime,date,time,rfcb,wfcb external ascitb,c.lc,c.alfa,c.num,eofs,leofs external fcb,fcb2,ckname,ername,erdone asciictl tncdefs timdef ; call mon - check the line in cmd for new call. ; call moncon - add the call in mcall to J connected list. ; call monini - read the known calls from file, set up lists. ; call wtmon - save the J lists info in file MON.TNC dseg ; File control blocks filled by INIT. cafcb: ds fcbsize mofcb: ds fcbsize lencall equ 8 ; # chars in a call, including ssid lentime equ 5 ; # chars in HHMM, +1 calls: ds 2 ; Addr of list of calls ncalls: ds 2 ; Number of calls in list mcalls: ds 2 ; Max # in list ncmsg: ds 2 ahrd: ds 2 ; Heard on A tnc ahrdl: ds 2 ; # in list bhrd: ds 2 ; Heard on B tnc bhrdl: ds 2 ; # in list chrd: ds 2 ; Connected chrdl: ds 2 ; # in list hrdmax: ds 2 ; Max in the lists seebea: ds 1 ; True means monitor beacons monhr: ds 1 tcalls: ds 2 count: ds 2 lcall1: ds 1 lcall2: ds 1 call1: ds lencall+lentime cseg beacon: db 'BEACON' ; Specify the file to use for call logging. chgca: ckname fcb2 jp z,ername zmov cafcb,fcb2,fcbsize call rdcall ; Read up the new list of calls jp erdone legal: push hl push de ld e,a ; The char ld d,0 ld hl,ascitb add hl,de ld a,(hl) and c.lc jr nz,legalb ; Can't be lower case ld a,(hl) and c.alfa+c.num jr z,legala ; Not alpha, not digit xor a ; Clear zero jr legalb legala: ld a,e ; Char back cp '-' legalb: pop de pop hl ret moncon: zmov logtxt,mcall,6 fill logtxt+6,3,' ' zmov logtxt+9,time,4 addlst logtxt,chrd,chrdl,hrdmax,lencall+lentime,6 ret mon: ld a,(cmdlen) ld c,a and 80h jr z,mona ld c,7fh mona: ld hl,cmd call fnd ; Find the '>' ret nz ; Not found ld a,b or a ret z ; Zero length call ld (lcall1),a ; Length of first call call fndb ; Find the ':' ret nz ; Not found ld a,b ld (lcall2),a ; 'From' call is the first lcall1 chars of cmd. ; 'To' call is from lcall1+2 for lcall2 chars. fill call1,lencall+1,' ' ld a,(lcall1) ld c,a ld b,0 ld de,call1 ld hl,cmd ldir ; Get the call ; Look at the 'to' call. If it is BEACON then dont put ; the 'from' call on the 'calls recently heard' list. cmpm seebea,true ; Look at beacons? jr z,monb ; Yes, beacons too ld a,(lcall2) cp 6 ; Six chars? jr nz,monb ; No, cant be BEACON ld a,(lcall1) inc a ld e,a ld d,0 ld hl,cmd add hl,de ; Start of second call ld de,beacon comp ,,6 jr z,mond ; Ignore beacons ; Update list of calls seen on this tnc. monb: call curtime move call1+lencall+1,time,4 cmpm iobyte,rbiob jr z,monc addlst call1,ahrd,ahrdl,hrdmax,lencall+lentime,lencall jr mond monc: addlst call1,bhrd,bhrdl,hrdmax,lencall+lentime,lencall ; Re-write mon.tnc if it is time. mond: ld a,(hr) ld hl,monhr cp (hl) ld (hl),a call nz,wtmon ; Update the list of known calls. srclst call1,calls,ncalls,lencall,lencall ret z ; Already had it ; Add to list. ld de,(ncalls) ld hl,(mcalls) or a ; Clear carry sbc hl,de ret z ; List full ld c,lencall call muldec ld hl,(calls) add hl,de move ,call1,lencall inxm ncalls ; Add to file. opena cafcb ld a,(lcall1) ld e,a ld hl,cmd call wtstr jp clsfil ; eof and close file ; Search for '>' starting at (HL) for (lencall) chars. ; Return (B)=# chars from (HL) the match was found. ; Return zero set for find. fnd: ld b,0 ld e,lencall+1 fnda: dec c ret m ; No more chars to search dec e ret m ; Searched far enough ld a,(hl) inc hl cp '>' ret z ; Found it call legal ret nz ; Not legal char inc b ; Count the character jr fnda ; Search for ' ', ':', or ',' starting at (HL) for (lencall) chars. ; Return (B)=# chars from (HL) the match was found. ; Return zero set for find. fndb: ld b,0 ld e,lencall+1 fndc: dec c ret m ; No more chars to search dec e ret m ; Searched far enough ld a,(hl) inc hl cp ' ' ret z ; Found it cp ',' ret z ; Found it cp ':' ret z call legal ret nz inc b ; Count the character jr fndc ; Allocate memory for the lists. monini: inxm hrdmax ; Increment # items maklst ahrd,hrdmax,lencall+lentime,' ' maklst bhrd,hrdmax,lencall+lentime,' ' maklst chrd,hrdmax,lencall+lentime,' ' dcxm hrdmax ; Reset max... maklst calls,mcalls,lencall,' ' ld hl,0 ld (ahrdl),hl ld (bhrdl),hl ld (chrdl),hl openr mofcb ; Open J list file jr z,rdcall ; File not exist. movw tcalls,ahrd call rdmona movw ahrdl,count movw tcalls,bhrd call rdmona movw bhrdl,count movw tcalls,chrd call rdmona movw chrdl,count ; Init hour last wrote mon.tnc ld a,(hr) ld (monhr),a ; Read list of known calls. rdcall: lxim ncalls,0 openr cafcb ; Open the file of known calls jr z,rdclb ; File not exist. movw tcalls,calls rdcla: call rdcmd jr z,rdclb ; End of file. ld hl,(tcalls) fill ,lencall,' ' ld hl,(tcalls) movcmd ,0,lencall inxm ncalls ld de,(mcalls) or a ; Clear carry sbc hl,de jr z,rdclb ; List full ld hl,(tcalls) ld de,lencall add hl,de ld (tcalls),hl jr rdcla rdclb: ld hl,(ncalls) call bindec ld hl,(ncmsg) jp @prtx ; Read a list of calls. rdmona: lxim count,0 rdmonb: call rdcmd ret z ; End of file. cmpcmd eofs,leofs ret z ; End of list ld hl,(tcalls) movcmd ,0,lencall+lentime inxm count ld de,(hrdmax) or a ; Clear carry sbc hl,de jr z,rdmonc ; List full ld hl,(tcalls) ld de,lencall+lentime add hl,de ld (tcalls),hl jr rdmonb ; Read the rest of this list. rdmonc: call rdcmd ret z ; End of file. cmpcmd eofs,leofs ret z ; End of list jr rdmonc ; Write the "J" list of calls heard to file MON.TNC wtmon: openw mofcb ret z movw count,ahrdl movw tcalls,ahrd call wtmona movw count,bhrdl movw tcalls,bhrd call wtmona movw count,chrdl movw tcalls,chrd call wtmona ; Stick the date and time at the end of the file. call curtime ntobuf date,6 ntobuf time,4 call wtcrlf ; CR,LF jr clsfil ; eof and close file wtmona: dtz count ; Wrote em all? jr z,wteof ; Yes ld hl,(tcalls) ld e,lencall+lentime call wtstr ; Write the string, CR, LF dcxm count ; Count this call ld hl,(tcalls) ld de,lencall+lentime add hl,de ld (tcalls),hl jr wtmona ; Put "*** EOF",CR,LF into file. wteof: ld hl,eofs ld e,leofs ; Put (E) chars at (HL) plus CR,LF into file. wtstr: ld c,(hl) call tobuf inc hl dec e jr nz,wtstr ; Put CR,LF into file. wtcrlf: ld c,cr call tobuf ld c,lf jp tobuf ; Put eof in file, close file. clsfil: ld c,eof call tobuf closew ret ; Display calls recently heard lists. dseg infm1: ds 2 l1: ds 2 l2: ds 2 l3: ds 2 cseg prthrd: prtx infm1 ; Print the header ; Find length of longest list. ld a,(bhrdl) ld e,a ld a,(ahrdl) cp e jr c,pha ld e,a pha: ld a,(chrdl) cp e jr c,phb ld e,a phb: ld d,0 ; Point to start of each list. movw l1,chrd movw l2,ahrd movw l3,bhrd ; Print next line. phc: ld a,d cp e jp z,waitc ; No more lines to print ld hl,(l1) call phd ; Print item from list 1 call phf ; and 5 spaces ld hl,(l2) call phd ; Print item from list 2 call phf ; and 5 spaces ld hl,(l3) call phd ; Print item from list 3 ld c,cr call @outch ; and a CR at end of line ; Point to next item in each list. ld bc,lencall+lentime ld hl,(l1) add hl,bc ld (l1),hl ld hl,(l2) add hl,bc ld (l2),hl ld hl,(l3) add hl,bc ld (l3),hl dec de jr phc ; Print one item from one list. phd: ld b,lencall+lentime ; # chars in item phe: ld c,(hl) call @outch inc hl dec b jr nz,phe ret ; Print 5 spaces. phf: ld b,5 ; # spaces after item ld c,' ' phg: call @outch dec b jr nz,phg ret end