home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / PACKET / RLI120.ARK / MONITOR.MAC < prev    next >
Text File  |  1986-08-12  |  8KB  |  440 lines

  1. ; MONITOR.MAC - 1/11/86 - Monitor while MailBox/GateWay idle.
  2.  
  3.     .z80
  4.     maclib    TNC.LIB
  5.  
  6.     entry        chgca,mon,monini,moncon,prthrd,infm1,ncmsg
  7.     entry        chgca,cafcb,mofcb,seebea,mcalls,hrdmax,wtmon
  8.  
  9.     external    @prtx,@opena,@openr,tobuf,@closew,@ntobuf
  10.     external    cmd,cmdlen,$memry,rdcmd,bindec,@cmpcmd,@openw
  11.     external    waitc,@outch,@fill,@cmp,@move,muldec,@mcmd
  12.     external    @srct,@srcl,@srcn,@srcw,@srcc,@src
  13.     external    @adll,@adlm,@adlw,@adln,@adlt,@adlc,@adl
  14.     external    logtxt,mcall,curtime,date,time,rfcb,wfcb
  15.     external    ascitb,c.lc,c.alfa,c.num,eofs,leofs
  16.     external    fcb,fcb2,ckname,ername,erdone
  17.  
  18.     asciictl
  19.     tncdefs
  20.     timdef
  21.  
  22. ; call mon - check the line in cmd for new call.
  23. ; call moncon - add the call in mcall to J connected list.
  24. ; call monini - read the known calls from file, set up lists.
  25. ; call wtmon - save the J lists info in file MON.TNC
  26.  
  27.     dseg
  28. ; File control blocks filled by INIT.
  29. cafcb:    ds    fcbsize
  30. mofcb:    ds    fcbsize
  31. lencall    equ    8    ; # chars in a call, including ssid
  32. lentime    equ    5    ; # chars in HHMM, +1
  33. calls:    ds    2    ; Addr of list of calls
  34. ncalls:    ds    2    ; Number of calls in list
  35. mcalls:    ds    2    ; Max # in list
  36.  
  37. ncmsg:    ds    2
  38. ahrd:    ds    2    ; Heard on A tnc
  39. ahrdl:    ds    2    ; # in list
  40. bhrd:    ds    2    ; Heard on B tnc
  41. bhrdl:    ds    2    ; # in list
  42. chrd:    ds    2    ; Connected
  43. chrdl:    ds    2    ; # in list
  44. hrdmax:    ds    2    ; Max in the lists
  45. seebea:    ds    1    ; True means monitor beacons
  46.  
  47. monhr:    ds    1
  48. tcalls:    ds    2
  49. count:    ds    2
  50. lcall1:    ds    1
  51. lcall2:    ds    1
  52. call1:    ds    lencall+lentime
  53.  
  54.     cseg
  55. beacon:    db    'BEACON'
  56.  
  57.  
  58. ; Specify the file to use for call logging.
  59.  
  60. chgca:    ckname    fcb2
  61.     jp    z,ername
  62.     zmov    cafcb,fcb2,fcbsize
  63.     call    rdcall        ; Read up the new list of calls
  64.     jp    erdone
  65.  
  66. legal:    push    hl
  67.     push    de
  68.     ld    e,a        ; The char
  69.     ld    d,0
  70.     ld    hl,ascitb
  71.     add    hl,de
  72.     ld    a,(hl)
  73.     and    c.lc
  74.     jr    nz,legalb    ; Can't be lower case
  75.     ld    a,(hl)
  76.     and    c.alfa+c.num
  77.     jr    z,legala    ; Not alpha, not digit
  78.     xor    a        ; Clear zero
  79.     jr    legalb
  80. legala:    ld    a,e        ; Char back
  81.     cp    '-'
  82. legalb:    pop    de
  83.     pop    hl
  84.     ret
  85.  
  86. moncon:    zmov    logtxt,mcall,6
  87.     fill    logtxt+6,3,' '
  88.     zmov    logtxt+9,time,4
  89.     addlst    logtxt,chrd,chrdl,hrdmax,lencall+lentime,6
  90.     ret
  91.  
  92. mon:    ld    a,(cmdlen)
  93.     ld    c,a
  94.     and    80h
  95.     jr    z,mona
  96.     ld    c,7fh
  97. mona:    ld    hl,cmd
  98.     call    fnd        ; Find the '>'
  99.     ret    nz        ; Not found
  100.     ld    a,b
  101.     or    a
  102.     ret    z        ; Zero length call
  103.     ld    (lcall1),a    ; Length of first call
  104.     call    fndb        ; Find the ':'
  105.     ret    nz        ; Not found
  106.     ld    a,b
  107.     ld    (lcall2),a
  108.  
  109. ; 'From' call is the first lcall1 chars of cmd.
  110. ; 'To' call is from lcall1+2 for lcall2 chars.
  111.  
  112.     fill    call1,lencall+1,' '
  113.     ld    a,(lcall1)
  114.     ld    c,a
  115.     ld    b,0
  116.     ld    de,call1
  117.     ld    hl,cmd
  118.     ldir            ; Get the call
  119.  
  120. ; Look at the 'to' call. If it is BEACON then dont put
  121. ; the 'from' call on the 'calls recently heard' list.
  122.  
  123.     cmpm    seebea,true    ; Look at beacons?
  124.     jr    z,monb        ; Yes, beacons too
  125.     ld    a,(lcall2)
  126.     cp    6        ; Six chars?
  127.     jr    nz,monb        ; No, cant be BEACON
  128.     ld    a,(lcall1)
  129.     inc    a
  130.     ld    e,a
  131.     ld    d,0
  132.     ld    hl,cmd
  133.     add    hl,de        ; Start of second call
  134.     ld    de,beacon
  135.     comp    ,,6
  136.     jr    z,mond        ; Ignore beacons
  137.  
  138. ; Update list of calls seen on this tnc.
  139.  
  140. monb:    call    curtime
  141.     move    call1+lencall+1,time,4
  142.     cmpm    iobyte,rbiob
  143.     jr    z,monc
  144.     addlst    call1,ahrd,ahrdl,hrdmax,lencall+lentime,lencall
  145.     jr    mond
  146. monc:    addlst    call1,bhrd,bhrdl,hrdmax,lencall+lentime,lencall
  147.  
  148. ; Re-write mon.tnc if it is time.
  149.  
  150. mond:    ld    a,(hr)
  151.     ld    hl,monhr
  152.     cp    (hl)
  153.     ld    (hl),a
  154.     call    nz,wtmon
  155.  
  156. ; Update the list of known calls.
  157.  
  158.     srclst    call1,calls,ncalls,lencall,lencall
  159.     ret    z    ; Already had it
  160.  
  161. ; Add to list.
  162.  
  163.     ld    de,(ncalls)
  164.     ld    hl,(mcalls)
  165.     or    a        ; Clear carry
  166.     sbc    hl,de
  167.     ret    z        ; List full
  168.     ld    c,lencall
  169.     call    muldec
  170.     ld    hl,(calls)
  171.     add    hl,de
  172.     move    ,call1,lencall
  173.     inxm    ncalls
  174.  
  175. ; Add to file.
  176.  
  177.     opena    cafcb
  178.     ld    a,(lcall1)
  179.     ld    e,a
  180.     ld    hl,cmd
  181.     call    wtstr
  182.     jp    clsfil        ; eof and close file
  183.  
  184. ; Search for '>' starting at (HL) for (lencall) chars.
  185. ; Return (B)=# chars from (HL) the match was found.
  186. ; Return zero set for find.
  187.  
  188. fnd:    ld    b,0
  189.     ld    e,lencall+1
  190. fnda:    dec    c
  191.     ret    m        ; No more chars to search
  192.     dec    e
  193.     ret    m        ; Searched far enough
  194.     ld    a,(hl)
  195.     inc    hl
  196.     cp    '>'
  197.     ret    z        ; Found it
  198.     call    legal
  199.     ret    nz        ; Not legal char
  200.     inc    b        ; Count the character
  201.     jr    fnda
  202.  
  203. ; Search for ' ', ':', or ',' starting at (HL) for (lencall) chars.
  204. ; Return (B)=# chars from (HL) the match was found.
  205. ; Return zero set for find.
  206.  
  207. fndb:    ld    b,0
  208.     ld    e,lencall+1
  209. fndc:    dec    c
  210.     ret    m        ; No more chars to search
  211.     dec    e
  212.     ret    m        ; Searched far enough
  213.     ld    a,(hl)
  214.     inc    hl
  215.     cp    ' '
  216.     ret    z        ; Found it
  217.     cp    ','
  218.     ret    z        ; Found it
  219.     cp    ':'
  220.     ret    z
  221.     call    legal
  222.     ret    nz
  223.     inc    b        ; Count the character
  224.     jr    fndc
  225.  
  226. ; Allocate memory for the lists.
  227.  
  228. monini:    inxm    hrdmax        ; Increment # items
  229.     maklst    ahrd,hrdmax,lencall+lentime,' '
  230.     maklst    bhrd,hrdmax,lencall+lentime,' '
  231.     maklst    chrd,hrdmax,lencall+lentime,' '
  232.     dcxm    hrdmax        ; Reset max...
  233.     maklst    calls,mcalls,lencall,' '
  234.  
  235.     ld    hl,0
  236.     ld    (ahrdl),hl
  237.     ld    (bhrdl),hl
  238.     ld    (chrdl),hl
  239.     openr    mofcb        ; Open J list file
  240.     jr    z,rdcall    ; File not exist.
  241.     movw    tcalls,ahrd
  242.     call    rdmona
  243.     movw    ahrdl,count
  244.  
  245.     movw    tcalls,bhrd
  246.     call    rdmona
  247.     movw    bhrdl,count
  248.  
  249.     movw    tcalls,chrd
  250.     call    rdmona
  251.     movw    chrdl,count
  252. ; Init hour last wrote mon.tnc
  253.     ld    a,(hr)
  254.     ld    (monhr),a
  255.  
  256. ; Read list of known calls.
  257.  
  258. rdcall:    lxim    ncalls,0
  259.     openr    cafcb        ; Open the file of known calls
  260.     jr    z,rdclb        ; File not exist.
  261.     movw    tcalls,calls
  262. rdcla:    call    rdcmd
  263.     jr    z,rdclb        ; End of file.
  264.     ld    hl,(tcalls)
  265.     fill    ,lencall,' '
  266.     ld    hl,(tcalls)
  267.     movcmd    ,0,lencall
  268.     inxm    ncalls
  269.     ld    de,(mcalls)
  270.     or    a        ; Clear carry
  271.     sbc    hl,de
  272.     jr    z,rdclb        ; List full
  273.     ld    hl,(tcalls)
  274.     ld    de,lencall
  275.     add    hl,de
  276.     ld    (tcalls),hl
  277.     jr    rdcla
  278. rdclb:    ld    hl,(ncalls)
  279.     call    bindec
  280.     ld    hl,(ncmsg)
  281.     jp    @prtx
  282.  
  283. ; Read a list of calls.
  284.  
  285. rdmona:    lxim    count,0
  286. rdmonb:    call    rdcmd
  287.     ret    z        ; End of file.
  288.     cmpcmd    eofs,leofs
  289.     ret    z        ; End of list
  290.     ld    hl,(tcalls)
  291.     movcmd    ,0,lencall+lentime
  292.     inxm    count
  293.     ld    de,(hrdmax)
  294.     or    a        ; Clear carry
  295.     sbc    hl,de
  296.     jr    z,rdmonc    ; List full
  297.     ld    hl,(tcalls)
  298.     ld    de,lencall+lentime
  299.     add    hl,de
  300.     ld    (tcalls),hl
  301.     jr    rdmonb
  302.  
  303. ; Read the rest of this list.
  304.  
  305. rdmonc:    call    rdcmd
  306.     ret    z        ; End of file.
  307.     cmpcmd    eofs,leofs
  308.     ret    z        ; End of list
  309.     jr    rdmonc
  310.  
  311. ; Write the "J" list of calls heard to file MON.TNC
  312.  
  313. wtmon:    openw    mofcb
  314.     ret    z
  315.  
  316.     movw    count,ahrdl
  317.     movw    tcalls,ahrd
  318.     call    wtmona
  319.  
  320.     movw    count,bhrdl
  321.     movw    tcalls,bhrd
  322.     call    wtmona
  323.  
  324.     movw    count,chrdl
  325.     movw    tcalls,chrd
  326.     call    wtmona
  327.  
  328. ; Stick the date and time at the end of the file.
  329.  
  330.     call    curtime
  331.     ntobuf    date,6
  332.     ntobuf    time,4
  333.     call    wtcrlf        ; CR,LF
  334.     jr    clsfil        ; eof and close file
  335.  
  336. wtmona:    dtz    count        ; Wrote em all?
  337.     jr    z,wteof    ; Yes
  338.     ld    hl,(tcalls)
  339.     ld    e,lencall+lentime
  340.     call    wtstr        ; Write the string, CR, LF
  341.     dcxm    count        ; Count this call
  342.     ld    hl,(tcalls)
  343.     ld    de,lencall+lentime
  344.     add    hl,de
  345.     ld    (tcalls),hl
  346.     jr    wtmona
  347.  
  348. ; Put "*** EOF",CR,LF into file.
  349. wteof:    ld    hl,eofs
  350.     ld    e,leofs
  351. ; Put (E) chars at (HL) plus CR,LF into file.
  352. wtstr:    ld    c,(hl)
  353.     call    tobuf
  354.     inc    hl
  355.     dec    e
  356.     jr    nz,wtstr
  357. ; Put CR,LF into file.
  358. wtcrlf:    ld    c,cr
  359.     call    tobuf
  360.     ld    c,lf
  361.     jp    tobuf
  362. ; Put eof in file, close file.
  363. clsfil:    ld    c,eof
  364.     call    tobuf
  365.     closew
  366.     ret
  367.  
  368. ; Display calls recently heard lists.
  369.  
  370.     dseg
  371. infm1:    ds    2
  372. l1:    ds    2
  373. l2:    ds    2
  374. l3:    ds    2
  375.     cseg
  376. prthrd:    prtx    infm1        ; Print the header
  377. ; Find length of longest list.
  378.     ld    a,(bhrdl)
  379.     ld    e,a
  380.     ld    a,(ahrdl)
  381.     cp    e
  382.     jr    c,pha
  383.     ld    e,a
  384. pha:    ld    a,(chrdl)
  385.     cp    e
  386.     jr    c,phb
  387.     ld    e,a
  388. phb:    ld    d,0
  389. ; Point to start of each list.
  390.     movw    l1,chrd
  391.     movw    l2,ahrd
  392.     movw    l3,bhrd
  393. ; Print next line.
  394. phc:    ld    a,d
  395.     cp    e
  396.     jp    z,waitc        ; No more lines to print
  397.     ld    hl,(l1)
  398.     call    phd        ; Print item from list 1
  399.     call    phf        ; and 5 spaces
  400.     ld    hl,(l2)
  401.     call    phd        ; Print item from list 2
  402.     call    phf        ; and 5 spaces
  403.     ld    hl,(l3)
  404.     call    phd        ; Print item from list 3
  405.     ld    c,cr
  406.     call    @outch        ; and a CR at end of line
  407. ; Point to next item in each list.
  408.     ld    bc,lencall+lentime
  409.     ld    hl,(l1)
  410.     add    hl,bc
  411.     ld    (l1),hl
  412.     ld    hl,(l2)
  413.     add    hl,bc
  414.     ld    (l2),hl
  415.     ld    hl,(l3)
  416.     add    hl,bc
  417.     ld    (l3),hl
  418.     dec    de
  419.     jr    phc
  420.  
  421. ; Print one item from one list.
  422.  
  423. phd:    ld    b,lencall+lentime    ; # chars in item
  424. phe:    ld    c,(hl)
  425.     call    @outch
  426.     inc    hl
  427.     dec    b
  428.     jr    nz,phe
  429.     ret
  430.  
  431. ; Print 5 spaces.
  432.  
  433. phf:    ld    b,5        ; # spaces after item
  434.     ld    c,' '
  435. phg:    call    @outch
  436.     dec    b
  437.     jr    nz,phg
  438.     ret
  439.     end
  440.