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 / BBSING / PBBS / PCHAT11.MAC < prev    next >
Text File  |  2000-06-30  |  8KB  |  345 lines

  1. ;-----------------------------------------------------------------------------
  2. ;PCHAT.MAC version 1.0A        For use with PBBS v3.0 or later only.
  3. ; 07/16/86
  4. ;
  5. ; This program allows the user to CHAT chat with the sysop, if the bell
  6. ; flag in BYE is on and the Chat times are correct.  If either of these
  7. ; two conditions prevent him from chatting, PCHAT will ask the user if he
  8. ; wants to leave a note to the sysop, if he does, PCHAT will chain to
  9. ; PNOTE.
  10. ; You must set the name of your PNOTE program at the label PNOTE:.
  11. ; You may change the NOTE question at label NOTIN:.
  12. ; Assemble this program and place it on A0 as CHAT.COM.
  13. ;         Requires BYE5 or NUBYE and PBBS v3.0 or later.
  14. ;
  15. ; The Sysop my bypass the time and BYE check by entering CHAT C
  16. ; This was added to allow the sysop to talk to a user even though
  17. ; the chat time was not within the limits.
  18. ;
  19. ; PCHAT is based on code from PBBBS and used as part of:
  20. ;
  21. ;        The Public Bulletin Board System
  22. ;        Author: Russ Pencin
  23. ;            1301 Ridgeview Drive
  24. ;            Mail Stop 102
  25. ;            Lewisville, Texas 75067
  26. ;            The Dallas Connection RCPM
  27. ;            (214) 238-1016 (300/1200/2400)
  28. ;------------------------------------------------------------------
  29. ;
  30. ;--> 1.0 initial Public Release 07/15/86
  31. ;--> 1.1 enhancements and fixes submitted by Tom Brady
  32. ;          1) TOS defeated during CHAT mode, restored on exit.
  33. ;          2) More accurate message before PNOTE is loaded.
  34. ;            [accepted and added 07/16/86. RLP]
  35. ;
  36. ;------------------------------------------------------------------------------
  37. ;
  38. ;NOTE:
  39. ;    This file MUST be linked to PBBSUBS.REL....
  40. ;------------------------------------------------------------------------------
  41.     .Z80
  42.     ASEG
  43.     ORG    100H
  44. ;
  45.     JP    START        ;jump around the header and subs
  46. VER::
  47.     DB    1        ;version
  48. ;
  49. VERR::
  50.     DB    1        ;revision
  51. ;
  52. ;
  53.     INCLUDE    PBBSHDR.MAC    ;header info  (switches, etc.)
  54. ;
  55.     INCLUDE    BDOSHDR.MAC    ;Time and Date conversions
  56. ;
  57. PNOTE:    DB    4,'NOTE',0    ;Length and Name of your PNOTE program
  58.                 ;null terminated.
  59. NOTIN:    DB    CR,LF,LF
  60.     DB    'The Sysop is unavailable at this time..',CR,LF
  61.     DB    'Would you like to leave a private note? ',0
  62. ;
  63. VERDAT:    DB    ' 07/16/86',0
  64. ;
  65. START:
  66.     LD    C,32
  67.     LD    E,241
  68.     CALL    BDOS        ; See if BYE5 is active
  69.     CP    77
  70.     JP    Z,BEGIN        ; Yes, proceed
  71.     CALL    PRINT        ; Else abort
  72. ;
  73.     DB    CR,LF,'BYE not available, aborting...',CR,LF,0
  74.     RET
  75.  
  76. BEGIN:
  77.     LD    HL,0
  78.     ADD    HL,SP
  79.     LD    (CCPSTK),HL    ; save the return address
  80.     LD    SP,STACK    ; install our stack
  81.     LD    E,255
  82.     LD    C,81
  83.     CALL    BDOS        ; Get MXTIME from BYE
  84.     LD    (MXTIME),A    ; And store it
  85.     LD    E,0
  86.     LD    C,81
  87.     CALL    BDOS        ; Set unlimited time during CHAT
  88.     LD    C,32
  89.     LD    E,0FFH
  90.     CALL    BDOS        ; Get current user
  91.     LD    (OLDUSR),A    ; And save it
  92.     LD    C,25
  93.     CALL    BDOS        ; Get current drive
  94.     LD    (OLDDRV),A    ; And save it
  95. ;
  96.     CALL    PRINT        ; print all the neat stuff
  97.     DB    CR,LF,'PCHAT,  '
  98.     DB    'Version ',0
  99.     LD    HL,(VER)    ; l=version, h=revision
  100.     CALL    PVER        ; print the version
  101.     LD    HL,VERDAT    ; and the date
  102.     CALL    PRINTM        ;
  103.     LD    A,(SYSDRV)    ;system files are here
  104.     LD    E,A        ;
  105.     LD    C,LOGDRV    ;
  106.     CALL    BDOS        ;log to the drive
  107.     LD    A,(SYSUSR)    ;
  108.     LD    E,A        ;
  109.     LD    C,LOGUSR    ;log to the user area
  110.     CALL    BDOS        ;
  111. ;
  112. ;
  113. ;------------------------------------------------------------------------------
  114. ;
  115. YAK:
  116.     LD    A,(FCB+1)
  117.     CP    'C'
  118.     JP    Z,YAKSOP
  119.     LD    E,255        ; see if the bell is on..
  120.     LD    C,78
  121.     CALL    BDOS
  122.     OR    A
  123.     JP    Z,NOYAK        ;nope..sorry charlie...
  124. YAK0:
  125.     CALL    PRINT
  126.     DB    CR,LF,0
  127.     CALL    GETTIM        ; get time and convert to binary
  128.     LD    A,(BTIME)
  129.     CP    CHAT0        ;is it too early?
  130.     JP    M,NOYAK
  131.     CP    CHAT1        ;is it too LATE?
  132.     JP    P,NOYAK
  133. ;
  134. ;calculate the hash to insure proper state.
  135. ;
  136. CALHASH:
  137.     LD    HL,(USRS)
  138.     AND    A        ; clear carry flag
  139.     LD    DE,26        ; # of ascci chars
  140.     LD    BC,0        ; counter
  141. DIV:    SBC    HL,DE
  142.     JP    C,HASHSET    ;calculate the hash for this system
  143.     INC    BC
  144.     JR    DIV
  145. HASHSET:
  146.     LD    (HASH),BC
  147. ;
  148. ;----------------------------------------------------------------------------
  149. ;
  150. ;    User is on system, and has typed CHAT.    Allow the user to leave a
  151. ;    private note if CHAT not available and then exit back to cp/m.
  152. ;
  153. MAINT:
  154.     LD    HL,USERS    ;address the filename
  155.     CALL    OPEN        ;open the file
  156.     LD    HL,USRLEN    ;set the record size
  157.     LD    (RRSZ),HL    ;
  158.     LD    HL,(USREC)    ;reget the user record no. in hl
  159.     CALL    GET        ;get record into buffer
  160.     CALL    CLOSE        ;and close the file
  161.     LD    HL,AVAILF    ; save it for callers file update
  162.     LD    DE,AVAIL
  163.     LD    BC,USRLEN
  164.     LDIR
  165.     CALL    PRINT
  166.     DB    CR,LF,'Hold on,  ',0
  167.     LD    B,30
  168.     LD    HL,UNAME
  169.     CALL    PRINTN
  170.     CALL    PRINT        ; Print:
  171.     DB    '. You may use ^C or ^X to abort.'
  172.     DB    CR,LF,0
  173.     CALL    PRINT
  174.     DB    '        |',0
  175.     LD    A,ALERT        ; get the value
  176.     LD    (LINES),A
  177.     LD    IY,LINES
  178. ;
  179. BARS1:    CALL    PRINT        ; Print bar and space
  180.     DB    '-',0
  181.     DEC    (IY)        ; Done with bars?
  182.     JR    NZ,BARS1    ; Not done, do it again
  183.     CALL    PRINT
  184.     DB    '|',CR,LF,0
  185.     LD    A,ALERT        ; restore value
  186.     LD    (LINES),A    ; temp counter
  187. ;
  188.     CALL    PRINT
  189.     DB    'Ringing: ',0
  190. ;
  191. ;
  192. ; Attempt to alert operator
  193. ;
  194. YAK2:
  195.     CALL    PRINT        ; Print bell, period, space
  196.     DB    BEL,'.',0
  197.     CALL    DELAY
  198.     DEC    (IY)        ; Done with alert attempts?
  199.     JR    NZ,YAK2        ; Not done with attempts, do more
  200.     JP    NOYAK
  201. ; Delay routine to wait between beeps
  202. ;
  203. DELAY:
  204.     LD    B,CLOCK
  205. ;
  206. DELAY1:
  207.     LD    HL,DLAYV
  208.     LD    DE,1
  209. ;
  210. DELAY2:
  211.     PUSH    HL        ; Save the values, consume some time
  212.     PUSH    DE
  213.     PUSH    BC
  214.     LD    E,0FFH
  215.     LD    C,6
  216.     CALL    SPBDOS        ; Get console status
  217.     OR    A        ; Character ready?
  218.     JR    NZ,DELAY4    ; Let's check it out
  219. ;
  220. DELAY3:
  221.     POP    BC        ; Restore the values
  222.     POP    DE
  223.     POP    HL
  224.     ADD    HL,DE
  225.     JR    NC,DELAY2
  226.     DEC    B
  227.     JR    NZ,DELAY1
  228.     RET            ; Finished this time
  229. ;.....
  230. DELAY5:
  231.     LD    SP,STACK    ; fix the stack
  232.     JP    NOYAK
  233. ;
  234. ;
  235. DELAY4:
  236.     CP    'X'-040H    ; User has cold feet?
  237.     JP    Z,DELAY5    ; Yes? then go back to pbbs
  238.     CP    'K'-'@'        ; ^K
  239.     JP    Z,DELAY5
  240.     CP    03H        ; Used to using CTL-C to quit?
  241.     JP    Z,DELAY5    ; Ok, then back to pbbs
  242.     CP    ESC        ; Was it the right answer?
  243.     JR    NZ,DELAY3    ; If not, keep timing
  244. ;
  245. ;
  246. ; Operator is present
  247. ;
  248. YAKSOP:
  249.     LD    SP,STACK    ; Fix stack
  250.     CALL    PRINT
  251.     DB    CR,LF,LF
  252.     DB    'Operator is available, please go ahead...',CR,LF
  253.     DB    '(Use three <RETURNS> to exit)',CR,LF
  254.     DB    CR,LF,0
  255. YAK3:
  256.     LD    IY,LINES
  257.     LD    (IY),3
  258. YAK4:
  259.     CALL    PRINT
  260.     DB    CR,LF,0
  261.     LD    B,74        ;input length
  262.     XOR    A        ;allow echo
  263.     LD    C,A        ;no caps forced
  264.     LD    D,1        ;want word-wrap at 53rd character
  265.     CALL    INPUT        ;get line
  266.     OR    A
  267.     JR    NZ,YAK3
  268.     DEC    (IY)
  269.     JR    NZ,YAK4
  270.     JP    REXIT
  271. NOYAK:
  272.     LD    HL,NOTIN    ; Load nobody home message
  273.     CALL    PRINTM
  274.     CALL    GETCH
  275.     CALL    CAPS
  276.     CALL    ECHO
  277.     CP    'Y'
  278.     JP    NZ,REXIT
  279.     LD    A,(MXTIME)    ; Get MXTIME back
  280.     LD    E,A
  281.     LD    C,81
  282.     CALL    BDOS        ; Restore MXTIME to pre-chat status
  283.     CALL    PRINT
  284.     DB    CR,LF,'Loading NOTE...Please wait...',CR,LF,0
  285.     CALL    RESTR
  286.     LD    HL,PNOTE    ;load up command pointer
  287.     PUSH    HL        ;set up for command buffer
  288.     JP    CPM+30        ;move command without logging into INITAR.
  289. ;
  290. REXIT:
  291.     LD    A,(MXTIME)    ; Get MXTIME back
  292.     LD    E,A
  293.     LD    C,81
  294.     CALL    BDOS        ; Restore MXTIME to pre-chat status
  295.     CALL    RESTR
  296.     LD    HL,(CCPSTK)
  297.     LD    SP,HL        ; Restore original stack
  298.     RET            ; And exit
  299. ;
  300. ;
  301. ; subroutine
  302. ;
  303. RESTR:
  304.     LD    A,(OLDDRV)    ;subroutine to restore the user/drv areas
  305.     LD    E,A
  306.     LD    C,LOGDRV
  307.     CALL    BDOS        ; Restore original drive
  308.     LD    A,(OLDUSR)
  309.     LD    E,A
  310.     LD    C,LOGUSR
  311.     CALL    BDOS        ; Restore original user area
  312.     RET
  313. ;
  314. EATCHR:
  315.     LD    E,0FFH
  316.     LD    C,6
  317.     CALL    SPBDOS
  318.     OR    A
  319.     JR    NZ,EATCHR
  320.     RET
  321. ;.....
  322. ;
  323. NOMSG:    DB    'No ',CR,LF,0
  324. COLUMN:    DB    0        ;current column counter
  325. CRS:    DB    0        ;carriage return counter
  326. HSHREC:    DW    0
  327. HASH:    DB    0
  328. MXTIME:    DB    0        ; temporary storage for TOS
  329. ;
  330. OLDUSR:        DB    0
  331. OLDDRV:        DB    0
  332. LINES:        DB    0
  333. CCPSTK::    DW    0
  334. TMPSTK::    DW    0
  335. ;
  336.     DS    128        ;stack area
  337. STACK    EQU    $
  338. ;
  339. MSG::
  340.     DW    0        ;message entry storage starts after
  341.                 ;linked PBBSUBS.rel file
  342. MSGARR::
  343.     DW    0        ;storage for message pointers
  344.     END
  345.