home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / CDOR0811.ZIP / SOURCE.ZIP / ANSICHAT.BAS < prev    next >
Encoding:
BASIC Source File  |  1993-04-10  |  18.9 KB  |  383 lines

  1. ' $segment
  2. ' $title: 'ANSIChat Split Screen Chat for RBBS-PC v17.4'
  3. '          By Dan Drinnon 8:903/2 1:313/6
  4. '              The Cellar Door RBBS (505) 763-1795 9600 v32
  5. '             Scott McNay 1:395/11
  6. '              The Wizard's II RBBS   (817) 554-5331 9600 v32
  7. '
  8. '          Copyright (c) 1992 by Daniel T. Drinnon   All Rights Reserved
  9. '
  10. '          DO NOT Distribute in Modified Form!
  11. '
  12. 'REVISIONS:
  13. '1.00  -  06-28-92 Initial Release
  14. '1.01  -  06-29-92 Fix for F2 Shell to DOS from ANSICHAT
  15. '1.02  -  07-04-92 Prevent F10 from Loading another ANSIChat
  16. '                  Keep ANSIChat from showing 'RBBS' if that is already
  17. '                  part of the BBS name.
  18. '                  added support for Sysop's PgUp/PgDn (RBBSSUB3.BAS)
  19. '                  combined local and remote input routines
  20. '1.03  -  07-09-92 Greater control over ANSI colors independent of RBBS colors
  21. '1.04  -  07-13-92 Added control to keep ANSICHAT from popping up when
  22. '                  the sysop does not have ANSI installed according to
  23. '                  CONFIG.
  24. '1.05  -  07-19-92 Modified RBBSSUB3 to get status of ANSIChat Capability
  25. '                  in DRSTx.DEF after return from a DOOR.
  26. '                  Removed redundant code in RBBS-PC.BAS.
  27. '                  Included ANSIFUN - a mod to make a Ring instead of a BEEP
  28. '                  for Sysop Page.
  29. '1.06  -  07-04-92 Gave the remote the option to terminate the chat by
  30. '                  pressing ESC.
  31. '1.07  -  08-10-92 Fixed BackSpace routine to properly locate the cursor.
  32. '1.08  -  08-13-92 Fixed the wordwrap/color mix problem and tweaked the
  33. '                  ANSI commands and a couple other things to speed up
  34. '                  the I/O.
  35. '1.09  -  08-18-92 Changed the bottom line of the remote screen to not go
  36. '                  past line 23.
  37. '                  Changed ZIP distribution file name to ACHATxxx.ZIP where xxx
  38. '                  denotes the version number.
  39. '1.10  -  08-26-92 Removed "STATIC" from SUB headers to force string space to
  40. '                  be released after use.
  41. '                  Added GetUserScreenSize sub to determine user's screen size
  42. '                  so that screen layout can be determined dynamically.  Makes
  43. '                  ANSIChat more compatible with non-standard (25x80) screens.
  44. '                  Changed exit method to require ESC key to be pressed twice.
  45. '                  This is compatible with ANSIED, and prevents accidents when
  46. '                  user hits a cursor key.
  47. '
  48. '1.11  -  09-09-92 Put the STATIC back in for QB3.0 compilers!  Took out the
  49. '                  GetUserScreenSize routines until a bug with certain modems
  50. '                  which returns 1,1 as the size is squashed.
  51. '
  52. '1.12  -  02-09-93 Fixed colors for the "Chat Over..." String.
  53. '                  Added a Current Time Clock in the Upper Right and an
  54. '                  Elapsed Time Clock in the Upper Left screen
  55. '                  Added support for CTRL-F to cycle through the ForeGround
  56. '                  text colors.  This is independent on the local and remote.
  57. '                  Background color cycling was tested out, but although it
  58. '                  worked, it just made for a sloppy looking screen and did
  59. '                  not seem worth the extra code space.
  60. '
  61. '1.13  -  02-13-93 Added a little string optimization.
  62. '         03-30-93 Turned of ANSI color if Caller has Color turned off.
  63. '
  64. '1.14  -  04-02-93 Changed Lower ASCII characters in Line Bars to resolve
  65. '                  conflicts with Aavtar Commands
  66. '
  67. '1.15  -  04-10-93 Turned off the Elapsed Time and Time display for connects
  68. '                  that are at 2400 bps or less.
  69. '
  70. ' $INCLUDE: 'RBBS-VAR.MOD'
  71. '
  72. ' $SUBTITLE: 'ANSIChat - ANSI Split Screen Chat Routine'
  73. '
  74. ' $PAGE
  75. '
  76. '  SUBROUTINE NAME    -- ANSIChat
  77. '
  78. '  INPUT PARAMETERS   -- None
  79. '
  80. '  OUTPUT PARAMETERS  -- None
  81. '
  82. '  SUBROUTINE PURPOSE -- Allows Split Screen ANSI Chat for RBBS
  83. '
  84. '
  85. DIM ANSIRow(1), ANSICol(1), ACColor$(1), HoldInput$(1), StartRow(1)
  86. DIM MaxRow(1), WasX$(1), LastChar$(1), ForeGround(8), ForeRotate(1)  ' 1.12
  87. DIM ForeHiLite(1)                                                    ' 1.12
  88.  
  89. Common Shared ANSIRow(), ANSICol(), ACColor$(), HoldInput$(), StartRow()
  90. Common Shared MaxRow(), WasX$(), LastChar$()                         ' 1.10
  91. Common Shared LocalOut, RemoteOut, SideOut
  92. Common Shared MenuColor1$, MenuColor2$
  93. Common Shared StartTime!, ElapsedTime!, ForeGround(), ForeRotate()   ' 1.12
  94. Common Shared ForeHiLite()                                           ' 1.12
  95. '
  96. 1000 SUB ANSIChat STATIC
  97. '
  98.      StartTime! = TIMER                                              ' 1.12
  99.      FOR count = 0 TO 7                                              ' 1.12
  100.         ForeGround(count) = count + 30                               ' 1.12
  101.      NEXT                                                            ' 1.12
  102.      LocalOut = 0
  103.      RemoteOut = 1
  104.      SideOut = LocalOut
  105.      TimeChatStarted! = TIMER                                        ' 1.10
  106.      ANSIRow(LocalOut) = 2
  107.      ANSIRow(RemoteOut) = 14
  108.      ANSICol(LocalOut) = 1
  109.      ANSICol(RemoteOut) = 1
  110.      IF ZWasGR > 1 THEN                                              ' 1.13
  111.         ACColor$(LocalOut) = CHR$(27) + "[;1;32;40m"                 ' 1.13
  112.         ACColor$(RemoteOut) = CHR$(27) + "[;1;33;40m"                ' 1.13
  113.      ELSE                                                            ' 1.13
  114.         ACColor$(LocalOut) = ""                                      ' 1.13
  115.         ACColor$(RemoteOut) = ""                                     ' 1.13
  116.      END IF                                                          ' 1.13
  117.      ForeRotate(LocalOut) = 2                                        ' 1.12
  118.      ForeHiLite(LocalOut) = 1                                        ' 1.12
  119.      ForeRotate(RemoteOut) = 3                                       ' 1.12
  120.      ForeHiLite(RemoteOut) = 1                                       ' 1.12
  121.      ZWasCM = ZTrue
  122.      ZSubParm = 1
  123.      HoldColorReset$ = ZColorReset$
  124.      IF ZWasGR > 1 THEN                                              ' 1.13
  125.         MenuColor1$ = CHR$(27) + "[;1;33;44m"                        ' 1.13
  126.         MenuColor2$ = CHR$(27) + "[;1;36;44m"                        ' 1.13
  127.      ELSE                                                            ' 1.13
  128.         MenuColor1$ = ""                                             ' 1.13
  129.         MenuColor2$ = ""                                             ' 1.13
  130.      END IF                                                          ' 1.13
  131.      ZColorReset$ = MenuColor2$                                      ' 1.03
  132.      CALL ANSIMenu
  133.      CALL ANSILocate (ANSIRow(LocalOut),ANSICol(LocalOut))
  134.      CALL QuickTPut1 (ACColor$(LocalOut) + ZSysopGreeting$)
  135.      CALL SplitScreenChat
  136.      ZWasCM = 0
  137.      CALL CheckTime(TimeChatStarted!,Elapsed!, 2)
  138.      ZSecsPerSession! = ZSecsPerSession! + Elapsed!
  139.      IF NOT ZLocalUser THEN _
  140.         ZAutoLogoff! = TIMER + ZWaitBeforeDisconnect
  141.      CALL ClearANSIScreen
  142.      ZColorReset$ = HoldColorReset$
  143.      ZoutTxt$ = ""                                                   ' 1.13
  144.      CALL SkipLine (1)                                               ' 1.13
  145.      CALL QuickTPut1(ZEmphasizeOff$ + _                              ' 1.13
  146.           "Chat over.  BBS resuming" + ZColorReset$)                 ' 1.12
  147.      END SUB
  148. '
  149. 4000 SUB ANSIMenu STATIC
  150. '
  151.      LineBar$ = STRING$(80,177)                                      ' 1.08
  152.      CALL ClearANSIScreen
  153.      CALL ANSILocate (1,1)
  154.      CALL QuickTPut (MenuColor2$ + LineBar$,0)                       ' 1.03
  155.      IF INSTR(ZRBBSName$,"BBS") <> 0 THEN _                          ' 1.02
  156.         ZOutTxt$ = "░*>>> " + ZRBBSName$ + " ANSI Chat <<<*░" _      ' 1.02
  157.      ELSE _                                                          ' 1.02
  158.         ZOutTxt$ = "░*>>> " + ZRBBSName$ + " RBBS ANSI Chat <<<*░"   ' 1.02
  159.      temppos = (40 - (LEN(ZOutTxt$)/2))
  160.      CALL ANSILocate (1,temppos)
  161.      CALL QuickTPut (MenuColor1$ + ZOutTxt$,0)                       ' 1.03
  162.      CALL ANSILocate (13,1)
  163.      CALL QuickTPut (MenuColor2$ + LineBar$,0)                       ' 1.03
  164.      CALL ANSILocate (13,3)
  165.      CALL QuickTPut (MenuColor2$ + "░" + ZSysopFirstName$ + _       ' 1.14
  166.           SPACE$(1) + ZSysopLastName$ + "░",0)                      ' 1.14
  167.      CALL ANSILocate (13,43)
  168.      CALL QuickTPut (MenuColor2$ + "░" + ZActiveUserName$ + "░",0) ' 1.14
  169.      CALL Line25
  170.      END SUB
  171. '
  172. 5000 SUB ClearANSIScreen STATIC
  173. '
  174.      CALL QuickTPut (CHR$(27) + "[2J",0)                             ' 1.13
  175.      ZSubParm = 2
  176.      CALL Line25
  177.      ZSubParm = 0
  178.      CALL ANSILocate (1,1)
  179.      END SUB
  180. '
  181. 6000 SUB ANSILocate (ANSIRow,ANSICol) STATIC
  182. '
  183.      CALL QuickTPut (CHR$(27) + CHR$(91) + MID$(STR$(ANSIRow),2) + CHR$(59) + _ ' 1.13
  184.           MID$(STR$(ANSICol),2) + CHR$(72),0)                        ' 1.13
  185.      END SUB
  186. '
  187. 8000 SUB SplitScreenChat STATIC
  188. '
  189. 8001 HoldInput$(LocalOut) = ""                                       ' 1.01
  190.      HoldInput$(RemoteOut) = ""
  191.      MaxLen = 78
  192.      StartRow(LocalOut) = 2
  193.      StartRow(RemoteOut) = 14
  194.      MaxRow(LocalOut) = 12
  195.      MaxRow(RemoteOut) = 23                                          ' 1.09
  196.      ANSICol(LocalOut) = 1
  197.      ANSICol(RemoteOut) = 1
  198.      ANSIRow(LocalOut) = StartRow(LocalOut) + 1
  199.      ANSIRow(RemoteOut) = StartRow(RemoteOut)
  200.      WasX$(LocalOut) = ""
  201.      WasX$(RemoteOut) = ""
  202.      ZWaitExpired = ZFalse
  203. '
  204. 8010 ZAutoLogoff! = TIMER + ZWaitBeforeDisconnect
  205.      CALL Carrier
  206.      IF ZSubParm < 0 THEN _
  207.         CALL QuickTPut1 (ZEmphasizeOff$) : _                         ' 1.12
  208.         EXIT SUB
  209. '
  210. 8020 CALL FindFKey
  211.      TimeNow! = TIMER                                                ' 1.12
  212.      IF ZWasCM = 0 THEN _                                            ' 1.01
  213.         CALL FlushCom (ZCommPortStack$) : _                          ' 1.01
  214.         ZKeyPressed$ = "" : _                                        ' 1.01
  215.         CALL ANSIMenu : _                                            ' 1.01
  216.         ZWasCM = ZTrue : _                                           ' 1.01
  217.         GOTO 8001                                                    ' 1.01
  218.      IF TimeNow! - PrevTI! > 1.0 AND VAL(ZCBaud$) > 2400 THEN        ' 1.15
  219.         ElapsedTime! = TIMER                                         ' 1.12
  220.         CALL CheckTime (StartTime!,ElapsedTime!,2)                   ' 1.12
  221.         ChatHour = ElapsedTime! / 3600                               ' 1.12
  222.         ChatMin = (ElapsedTime! - ChatHour * 3600!) / 60             ' 1.12
  223.         ChatSec = ElapsedTime! - (ChatHour * 3600! + ChatMin * 60!)  ' 1.12
  224.         IF ChatSec < 0 THEN                                          ' 1.12
  225.            ChatSec = ChatSec + 60                                    ' 1.12
  226.            ChatMin = ChatMin - 1                                     ' 1.12
  227.         END IF                                                       ' 1.12
  228.         IF ChatMin < 0 THEN                                          ' 1.12
  229.            ChatMin = ChatMin + 60                                    ' 1.12
  230.            ChatHour = ChatHour - 1                                   ' 1.12
  231.         END IF                                                       ' 1.12
  232.         Hours$ = STR$(ChatHour)                                      ' 1.12
  233.         Mins$ = STR$(ChatMin)                                        ' 1.12
  234.         Secs$ = STR$(ChatSec)                                        ' 1.12
  235.         CALL Trim (Hours$)                                           ' 1.12
  236.         CALL Trim (Mins$)                                            ' 1.12
  237.         CALL Trim (Secs$)                                            ' 1.12
  238.         IF ChatHour < 10 THEN Hours$ = CHR$(48) + Hours$             ' 1.13
  239.         IF ChatMin < 10 THEN Mins$ = CHR$(48) + Mins$                ' 1.13
  240.         IF ChatSec < 10 THEN Secs$ = CHR$(48) + Secs$                ' 1.13
  241.         CALL ANSILocate (1,1)                                        ' 1.12
  242.         CALL QuickTPut (MenuColor1$ + Hours$ + CHR$(58) + _          ' 1.13
  243.                         Mins$ + CHR$(58) + Secs$,0)                  ' 1.13
  244.         DisplayTime$ = LEFT$(TIME$,8)                                ' 1.12
  245.         CALL ANSILocate (1,73)                                       ' 1.12
  246.         CALL QuickTPut (MenuColor1$ + DisplayTime$ + _               ' 1.12
  247.                         ZEmphasizeOff$,0)                            ' 1.12
  248.         CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))          ' 1.12
  249.         PrevTI! = TimeNow!                                           ' 1.12
  250.      END IF                                                          ' 1.12
  251.      SideOut = LocalOut
  252.      WasX$(LocalOut) = ZKeyPressed$
  253.      IF ZKeyPressed$ = ZEscape$ THEN _
  254.         CALL QuickTPut1 (ZEmphasizeOff$) : _                         ' 1.12
  255.         EXIT SUB
  256.      IF WasX$(LocalOut) <> "" THEN _
  257.         GOTO 8060
  258. '
  259. 8030 IF ZLocalUser THEN _
  260.         GOTO 8010
  261.      SideOut = RemoteOut
  262.      IF ZCommPortStack$ <> "" THEN _
  263.         WasX$(RemoteOut) = LEFT$(ZCommPortStack$,LEN(ZCommPortStack$)-1) : _
  264.         GOTO 9000
  265.      CALL EofComm (Char)
  266.      IF Char <> -1 THEN _
  267.         GOTO 8050 _
  268.      ELSE _
  269.         GOTO 8010
  270. '
  271. 8050 ZAutoLogoff! = TIMER + ZWaitBeforeDisconnect
  272.      CALL GetCom (WasX$(RemoteOut))
  273. '
  274. 8060 'Control keys
  275.      LastChar$(SideOut) = RIGHT$(LastChar$(SideOut),1) + _           ' 1.10
  276.                           WasX$(SideOut)                             ' 1.10
  277.      IF WasX$(SideOut) = CHR$(8) THEN _
  278.         GOTO 8500 _
  279.      ELSE IF WasX$(SideOut) = CHR$(9) THEN _
  280.         GOTO 8510 _
  281.      ELSE IF WasX$(SideOut) = CHR$(13) THEN _
  282.         GOTO 8520
  283.      IF WasX$(SideOut) = CHR$(6) AND ZWasGR > 1 THEN 'CTRL-F color   ' 1.13
  284.         ForeRotate(SideOut) = ForeRotate(SideOut) + 1                ' 1.12
  285.         IF ForeRotate(SideOut) > 7 AND ForeHiLite(SideOut) = 1 THEN  ' 1.12
  286.            ForeHiLite(SideOut) = 0                                   ' 1.12
  287.            ForeRotate(SideOut) = 0                                   ' 1.12
  288.         END IF                                                       ' 1.12
  289.         IF ForeRotate(SideOut) > 7 THEN                              ' 1.12
  290.            ForeHiLite(SideOut) = 1                                   ' 1.12
  291.            ForeRotate(SideOut) = 0                                   ' 1.12
  292.         END IF                                                       ' 1.12
  293.         hilite$ = STR$(ForeHiLite(SideOut))                          ' 1.12
  294.         CALL Trim (hilite$)                                          ' 1.12
  295.         colorstr$ = STR$(ForeGround(ForeRotate(SideOut)))            ' 1.12
  296.         CALL Trim (colorstr$)                                        ' 1.12
  297.         ACColor$(SideOut) = ZEscape$ + CHR$(91) + _                  ' 1.13
  298.                             hilite$ + CHR$(59) + _                   ' 1.13
  299.                             colorstr$ + CHR$(109)                    ' 1.13
  300.         GOTO 8010                                                    ' 1.12
  301.      END IF                                                          ' 1.12
  302.      GOTO 9000
  303. '
  304. 8500 'BackSpace
  305.      IF HoldInput$(SideOut) <> "" THEN _                             ' 1.07
  306.         HoldInput$(SideOut) = LEFT$(HoldInput$(SideOut), _           ' 1.07
  307.                               LEN(HoldInput$(SideOut))-1)            ' 1.07
  308.      IF ANSICol(SideOut) > 1 THEN _
  309.         ANSICol(SideOut) = ANSICol(SideOut) - 1 : _                  ' 1.07
  310.         GOTO 8501                                                    ' 1.07
  311.      IF ANSICol(SideOut) = 1 THEN _                                  ' 1.07
  312.         GOSUB 8502 : _                                               ' 1.07
  313.         ANSICol(SideOut) = MaxLen - 1 : _                            ' 1.07
  314.         ANSIRow(SideOut) = ANSIRow(SideOut) - 1                      ' 1.03
  315.      IF ANSIRow(SideOut) < StartRow(SideOut) THEN _                  ' 1.07
  316.         ANSIRow(SideOut) = MaxRow(SideOut)                           ' 1.07
  317. 8501 GOSUB 8502                                                      ' 1.07
  318.      GOTO 8010
  319. 8502 CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))             ' 1.07
  320.      tempstr$ = ACColor$(SideOut) + SPACE$(1)                        ' 1.13
  321.      IF NOT ZLocalUser THEN _                                        ' 1.07
  322.         CALL PutCom (tempstr$)                                       ' 1.12
  323.      CALL LPrnt (tempstr$,0)                                         ' 1.12
  324.      CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))             ' 1.07
  325.      RETURN                                                          ' 1.07
  326. '
  327. 8510 'TAB
  328.      HoldInput$(SideOut) = ""
  329.      IF ANSICol(SideOut) + 5 > MaxLen THEN _
  330.         CALL AddRow (StartRow(SideOut),MaxRow(SideOut)) _
  331.      ELSE _
  332.         ANSICol(SideOut) = ANSICol(SideOut) + 5 : _
  333.         CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))
  334.      GOTO 8010
  335. '
  336. 8520 'CR
  337.      HoldInput$(SideOut) = ""
  338.      CALL AddRow (StartRow(SideOut),MaxRow(SideOut))
  339.      GOTO 8010
  340. '
  341. 9000 'Character Placement
  342.      IF LastChar$(SideOut) = ZEscape$ + ZEscape$ THEN _              ' 1.10
  343.            CALL QuickTPut1 (ZEmphasizeOff$) : _                      ' 1.12
  344.            EXIT SUB
  345.      HoldInput$(SideOut) = HoldInput$(SideOut) + WasX$(SideOut)
  346.      IF WasX$(SideOut) = SPACE$(1) THEN _                            ' 1.13
  347.         HoldInput$(SideOut) = ""
  348.      IF ANSICol(SideOut) = MaxLen AND WasX$(SideOut) <> SPACE$(1) THEN _ ' 1.13
  349.         CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut) - _
  350.                          LEN(HoldInput$(SideOut))) : _
  351.         CALL QuickTput(ACColor$(SideOut) + CHR$(27) + "[K", 0) : _   ' 1.13
  352.         CALL AddRow (StartRow(SideOut),MaxRow(SideOut)) : _
  353.         CALL QuickTPut (HoldInput$(SideOut),0) : _
  354.         ANSICol(SideOut) = ANSICol(SideOut) + LEN(HoldInput$(SideOut)) - 1 : _
  355.         WasX$(SideOut) = "" : _
  356.         HoldInput$(SideOut) = ""
  357.      CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))
  358.      IF NOT ZLocalUser THEN _
  359.         CALL PutCom (ACColor$(SideOut) + WasX$(SideOut))
  360.      CALL LPrnt (ACColor$(SideOut) + WasX$(SideOut),0)
  361.      ANSICol(SideOut) = ANSICol(SideOut) + 1
  362.      IF ANSICol(SideOut) > MaxLen THEN _
  363.         CALL AddRow (StartRow(SideOut),MaxRow(SideOut))
  364.      WasX$(SideOut) = ""
  365.      GOTO 8010
  366.      END SUB
  367. '
  368. 10000 SUB AddRow (StartRow,MaxRow) STATIC
  369. '
  370.       ANSICol(SideOut) = 1
  371.       ANSIRow(SideOut) = ANSIRow(SideOut) + 1
  372.       IF ANSIRow(SideOut) > MaxRow THEN _
  373.          ANSIRow(SideOut) = StartRow
  374.       IF ANSIRow(SideOut) < MaxRow THEN _
  375.          CALL ANSILocate (ANSIRow(SideOut) + 1,ANSICol(SideOut)) : _
  376.          CALL QuickTput(ACColor$(SideOut) + CHR$(27) + "[K", 0)      ' 1.13
  377.       IF ANSIRow(SideOut) = MaxRow THEN _
  378.          CALL ANSILocate (StartRow,ANSICol(SideOut)) : _
  379.          CALL QuickTput(ACColor$(SideOut) + CHR$(27) + "[K", 0)      ' 1.13
  380.       CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))
  381.       END SUB
  382. '
  383.