home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / OSTRUCT.ZIP / COM.H next >
Encoding:
C/C++ Source or Header  |  1993-01-04  |  10.3 KB  |  205 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*               The Opus Computer-Based Conversation System                */
  4. /*                              FOSSIL INTERFACE                            */
  5. /*                                                                          */
  6. /*                             by Wynn Wagner III                           */
  7. /*                                                                          */
  8. /*                                                                          */
  9. /* This material is available for use by anybody for any reason with no     */
  10. /* strings attached and no guarantees.                                      */
  11. /*                                                                          */
  12. /* Your best source of thorough technical information about FOSSIL is       */
  13. /* a file called DECCOMM.DOC by Vince Perriello.                            */
  14. /*                                                                          */
  15. /*--------------------------------------------------------------------------*/
  16.  
  17.  
  18.  
  19. /*--------------------------*/
  20. /* Init information         */
  21. /*--------------------------*/
  22. #define BITS_8          0x03
  23.  
  24. /*--------------------------*/
  25. /* Supported baud rates     */
  26. /*--------------------------*/
  27. #define BAUD_300        0x040
  28. #define BAUD_1200       0x080
  29. #define BAUD_2400       0x0A0
  30. #define BAUD_4800       0x0C0
  31. #define BAUD_9600       0x0E0
  32. #define BAUD_19200      0x000
  33. #define BAUD_38400      0x020
  34.  
  35. /*--------------------------*/
  36. /* Line Status Register     */
  37. /*--------------------------*/
  38. #define DATA_READY         0x0100
  39. #define OVERRUN_ERR         0x0200
  40. #define PARITY_ERR         0x0400
  41. #define FRAMING_ERR         0x0800
  42. #define BREAK_INT             0x1000
  43. #define TX_HOLD_EMPTY     0x2000
  44. #define TX_SHIFT_EMPTY    0x4000
  45.  
  46. /*--------------------------*/
  47. /* Driver Flags             */
  48. /*--------------------------*/
  49. #define USE_XON            0x01
  50. #define USE_CTS            0x02
  51. #define USE_DSR            0x04
  52.  
  53. #define BRK             0x01
  54. #define MDM             0x02
  55.  
  56.  
  57.  
  58. /*--------------------------------------------------------------------------*/
  59. /* MACROS that call the low-level assembly language routines:               */
  60. /*--------------------------------------------------------------------------*/
  61. extern      Com_           (byte,...);
  62. extern      Cominit        (byte);
  63.  
  64. extern  int pascal READBYTE(void);
  65.  
  66.  
  67. #define M_INSTALL(b)       {Cominit(ctl.com_port);Com_(0x0f,0);Com_(0x0f,ctl.handshake_mask);new_baud(0,b);}
  68.  
  69.  
  70.                            /*-----------------------------------------------*/
  71.                            /* Service 0: SET BAUD(etc)                      */
  72.                            /*            Also sets NO PARITY, 1 STOP BIT    */
  73.                            /*            because we aren't telling it       */
  74.                            /*            otherwise.                         */
  75.                            /*-----------------------------------------------*/
  76. #define MDM_ENABLE(b)      (Com_(0x00,b|BITS_8))
  77.  
  78.                            /*-----------------------------------------------*/
  79.                            /* Service 1: SEND CHAR (wait)                   */
  80.                            /*-----------------------------------------------*/
  81.  
  82.                            /*-----------------------------------------------*/
  83.                            /* Service 2: GET CHAR (wait)                    */
  84.                            /*-----------------------------------------------*/
  85. #define MODEM_IN()         (Com_(0x02)&0x00ff)
  86.  
  87.                            /*-----------------------------------------------*/
  88.                            /* Service 3: GET STATUS                         */
  89.                            /*-----------------------------------------------*/
  90. #define MODEM_STATUS()     (Com_(0x03))
  91. #define CARRIER            (Com_(0x03)&ctl.carrier_mask)
  92. #define CHAR_AVAIL()       (Com_(0x03)&DATA_READY)
  93. #define OUT_EMPTY()        (Com_(0x03)&TX_SHIFT_EMPTY)
  94. #define OUT_FULL()         (!(Com_(0x03)&TX_HOLD_EMPTY))
  95.  
  96.                            /*-----------------------------------------------*/
  97.                            /* Service 4: INIT/INSTALL                       */
  98.                            /*-----------------------------------------------*/
  99.  
  100.                            /*-----------------------------------------------*/
  101.                            /* Service 5: UNINSTALL                          */
  102.                            /*-----------------------------------------------*/
  103. #define MDM_DISABLE()      (Com_(0x05,BAUD_2400|BITS_8))
  104.  
  105.                            /*-----------------------------------------------*/
  106.                            /* Service 6: SET DTR                            */
  107.                            /*-----------------------------------------------*/
  108. #define DTR_OFF()          (Com_(0x06,0))
  109. #define DTR_ON()           (Com_(0x06,1))
  110.  
  111.                            /*-----------------------------------------------*/
  112.                            /* Service 7: GET TIMER TICK PARMS               */
  113.                            /*-----------------------------------------------*/
  114.  
  115.                            /*-----------------------------------------------*/
  116.                            /* Service 8: FLUSH OUTBOUND RING-BUFFER         */
  117.                            /*-----------------------------------------------*/
  118.  
  119.                            /*-----------------------------------------------*/
  120.                            /* Service 9: NUKE OUTBOUND RING-BUFFER          */
  121.                            /*-----------------------------------------------*/
  122. #define CLEAR_OUTBOUND()   (Com_(0x09))
  123.  
  124.                            /*-----------------------------------------------*/
  125.                            /* Service a: NUKE INBOUND RING-BUFFER           */
  126.                            /*-----------------------------------------------*/
  127. #define CLEAR_INBOUND()    (Com_(0x0a))
  128.  
  129.                            /*-----------------------------------------------*/
  130.                            /* Service b: SEND CHAR (no wait)                */
  131.                            /*-----------------------------------------------*/
  132. #define Com_Tx_NW(c)       (Com_(0x0b,c))
  133.  
  134.                            /*-----------------------------------------------*/
  135.                            /* Service c: GET CHAR (no wait)                 */
  136.                            /*-----------------------------------------------*/
  137. #define PEEKBYTE()         (Com_(0x0c))
  138.  
  139.                            /*-----------------------------------------------*/
  140.                            /* Service d: GET KEYBOARD STATUS                */
  141.                            /*-----------------------------------------------*/
  142. #define KEYPRESS()         (Com_(0x0d)!=(-1))
  143. #define FOSSIL_PEEKKB()    (Com_(0x0d))
  144.  
  145.                            /*-----------------------------------------------*/
  146.                            /* Service e: GET KEYBOARD CHARACTER (wait)      */
  147.                            /*-----------------------------------------------*/
  148. #define READKB()           (Com_(0x0e)&0xff)
  149. #define READSCAN()         (Com_(0x0e))
  150. #define FOSSIL_CHAR()      (Com_(0x0e))
  151.  
  152.  
  153.                            /*-----------------------------------------------*/
  154.                            /* Service f: SET/GET FLOW CONTROL STATUS        */
  155.                            /*-----------------------------------------------*/
  156. #define XON_ENABLE()       (Com_(0x0f,ctl.handshake_mask))
  157. #define XON_DISABLE()      (Com_(0x0f,(ctl.handshake_mask&(~USE_XON))))
  158.  
  159.                            /*-----------------------------------------------*/
  160.                            /* Service 10: SET/GET CTL-BREAK CONTROLS        */
  161.                            /*             Note that the "break" here refers */
  162.                            /*             to ^C and ^K rather than the      */
  163.                            /*             tradition modem BREAK.            */
  164.                            /*-----------------------------------------------*/
  165. #define _BRK_ENABLE()      (Com_(0x10,BRK))
  166. #define _BRK_DISABLE()     (Com_(0x10,0))
  167. #define RECVD_BREAK()      (Com_(0x10,BRK)&BRK)
  168.  
  169.                            /*-----------------------------------------------*/
  170.                            /* Service 11: SET LOCAL VIDEO CURSOR POSITION   */
  171.                            /*-----------------------------------------------*/
  172.  
  173.                            /*-----------------------------------------------*/
  174.                            /* Service 12: GET LOCAL VIDEO CURSOR POSITION   */
  175.                            /*-----------------------------------------------*/
  176.  
  177.                            /*-----------------------------------------------*/
  178.                            /* Service 13: WRITE LOCAL ANSI CHARACTER        */
  179.                            /*-----------------------------------------------*/
  180.  
  181.                            /*-----------------------------------------------*/
  182.                            /* Service 14: WATCHDOG on/off                   */
  183.                            /*-----------------------------------------------*/
  184. #define WATCHDOG(x)        (Com_(0x14,x))
  185.  
  186.  
  187. /*--------------------------------------------------------------------------*/
  188. /*                                                                          */
  189. /* A no-stall ReadByte routine might look like this:                        */
  190. /*                                                                          */
  191. /*    int READBYTE()                                                        */
  192. /*       begin                                                              */
  193. /*          return (CHAR_AVAIL())? (MODEM_IN()) : (-1);                     */
  194. /*       end                                                                */
  195. /*                                                                          */
  196. /* Or for whose with lots of code space to kill off...                      */
  197. /*                                                                          */
  198. /*    #define READBYTE() ((Com_(0x03)&DATA_READY)?(Com_(0x02)&0x00ff):(-1)) */
  199. /*                                                                          */
  200. /*--------------------------------------------------------------------------*/
  201.  
  202.  
  203. /* END OF FILE: com.h */
  204.  
  205.