home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / libraries / gameport / my_include / devicetoolkits / gameport.h next >
C/C++ Source or Header  |  1991-01-03  |  6KB  |  191 lines

  1. /*
  2. ****************************************************************************
  3.  
  4.       GamePort Device ToolKit Subroutines.
  5.       Standard Include File.
  6.  
  7.       GamePort.h.
  8.       Version 1.1.
  9.  
  10.       Paris E. Bingham Jr.
  11.       Copyright © 1986 - 1990  All Rights Reserved.
  12.  
  13.  
  14.       History:
  15.  
  16.     Version      Date      Comments
  17.     -------    --------    -----------------------------------------------
  18.       1.0      10/01/89    PEB - Created.
  19.       1.1      08/12/90    PEB - Add support for Manx C V5.0.
  20.                09/18/90    PEB - Add support for SAS C V5.10.
  21.                12/19/90    PEB - Added hardware interface routines.
  22.  
  23. ****************************************************************************
  24. */
  25.  
  26. #ifndef  DT_GAMEPORT_H
  27. #define  DT_GAMEPORT_H
  28.  
  29. /*
  30.       Compiler Definitions
  31. */
  32.  
  33. #ifdef   SAS
  34. #define  ANSI_PROTO        1
  35. #endif
  36.  
  37. #ifdef   MANXV3
  38. #undef   ANSI_PROTO
  39. #undef   NO_PRAGMAS
  40. #define  NO_PRAGMAS        1
  41. #define  MANX              1
  42. #endif
  43.  
  44. #ifdef   MANXV5
  45. #define  ANSI_PROTO        1
  46. #define  MANX              1
  47. #endif
  48.  
  49. /*
  50.       Include Files
  51. */
  52.  
  53. #include <exec/types.h>
  54. #include <exec/exec.h>
  55. #include <exec/execbase.h>
  56. #include <devices/gameport.h>
  57. #include <devices/inputevent.h>
  58.  
  59. #ifdef   SAS
  60. #include <proto/exec.h>
  61. #endif
  62.  
  63. #ifdef   MANX
  64. #ifndef  NO_PRAGMAS
  65. #include <pragmas.h>
  66. #else
  67. #include <functions.h>
  68. #endif
  69. #endif
  70.  
  71. /*
  72.       Definitions
  73. */
  74.  
  75. /*
  76. ****************************************************************************
  77.       DTGamePort - GamePort Control Structure
  78. ****************************************************************************
  79. */
  80.  
  81. struct   DTGamePort  {
  82.    ULONG             gp_flags;               /* Control flags */
  83.    ULONG             gp_unit;                /* Gameport unit */
  84.    struct   MsgPort  *gp_wport;              /* Write reply port */
  85.    struct   IOStdReq *gp_wreq;               /* Write request block */
  86.    struct   MsgPort  *gp_rport;              /* Read reply port */
  87.    struct   IOStdReq *gp_rreq;               /* Read request block */
  88.    LONG              gp_error;               /* Error on request */
  89. };
  90.  
  91. /*  Flag bits  */
  92. #define  DTGPB_GOTUNIT     0                 /* Got unit */
  93. #define  DTGPF_GOTUNIT     (1 << DTGPB_GOTUNIT)
  94.  
  95. #define  DTGPB_GOTWPORT    1                 /* Got write reply port */
  96. #define  DTGPF_GOTWPORT    (1 << DTGPB_GOTWPORT)
  97.  
  98. #define  DTGPB_GOTWREQB    2                 /* Got write request block */
  99. #define  DTGPF_GOTWREQB    (1 << DTGPB_GOTWREQB)
  100.  
  101. #define  DTGPB_GOTRPORT    3                 /* Got read reply port */
  102. #define  DTGPF_GOTRPORT    (1 << DTGPB_GOTRPORT)
  103.  
  104. #define  DTGPB_GOTRREQB    4                 /* Got read request block */
  105. #define  DTGPF_GOTRREQB    (1 << DTGPB_GOTRREQB)
  106.  
  107. #define  DTGPB_GOTDEVICE   5                 /* Got device */
  108. #define  DTGPF_GOTDEVICE   (1 << DTGPB_GOTDEVICE)
  109.  
  110. #define  DTGPB_READQUEUED  6                 /* Read queued */
  111. #define  DTGPF_READQUEUED  (1 << DTGPB_READQUEUED)
  112.  
  113. #define  DTGPB_INIT        7                 /* All done */
  114. #define  DTGPF_INIT        (1 << DTGPB_INIT)
  115.  
  116. #define  DTGPB_COPY        8                 /* Is copy */
  117. #define  DTGPF_COPY        (1 << DTGPB_COPY)
  118.  
  119. /*  Typedef for User */
  120. typedef  struct   DTGamePort  *DTGamePort_t;
  121.  
  122.  
  123. /*
  124. ****************************************************************************
  125.       DTGamePortDJoy Bits (Digital Joystick)
  126. ****************************************************************************
  127. */
  128.  
  129. #define  DTGPB_DJUP        0
  130. #define  DTGPF_DJUP        (1 << DTGPB_DJUP)
  131. #define  DTGPB_DJDOWN      1
  132. #define  DTGPF_DJDOWN      (1 << DTGPB_DJDOWN)
  133. #define  DTGPB_DJLEFT      2
  134. #define  DTGPF_DJLEFT      (1 << DTGPB_DJLEFT)
  135. #define  DTGPB_DJRIGHT     3
  136. #define  DTGPF_DJRIGHT     (1 << DTGPB_DJRIGHT)
  137. #define  DTGPB_DJLB        4                 /* Left Button */
  138. #define  DTGPF_DJLB        (1 << DTGPB_DJLB)
  139. #define  DTGPB_DJRB        5                 /* Right Button */
  140. #define  DTGPF_DJRB        (1 << DTGPB_DJRB)
  141. #define  DTGPB_DJMB        6                 /* Middle Button */
  142. #define  DTGPF_DJMB        (1 << DTGPB_DJMB)
  143.  
  144.  
  145. /*
  146. ****************************************************************************
  147.       Error Codes
  148. ****************************************************************************
  149. */
  150.  
  151. #define  DTGPE_NO_ERROR       0L             /* No error */
  152. #define  DTGPE_NO_STRUCTURE   1L             /* No control structure */
  153. #define  DTGPE_NO_WPORT       2L             /* Write reply port not alloc. */
  154. #define  DTGPE_NO_WREQB       3L             /* Write req. not alloc. */
  155. #define  DTGPE_NO_RPORT       4L             /* Read reply port not alloc. */
  156. #define  DTGPE_NO_RREQB       5L             /* Read req. not alloc. */
  157. #define  DTGPE_NO_DEVICE      6L             /* Device not opened */
  158. #define  DTGPE_NO_INIT        7L             /* Control not initialized */
  159. #define  DTGPE_NO_DATA        8L             /* No pointer to data */
  160. #define  DTGPE_NO_LENGTH      9L             /* No data length */
  161. #define  DTGPE_ALREADY_QUEUED 10L            /* Read already queued */
  162. #define  DTGPE_NO_READ        11L            /* No read queued */
  163.  
  164.  
  165. /*
  166. ****************************************************************************
  167.       Useful Macros
  168. ****************************************************************************
  169. */
  170.  
  171. #define  DTGamePortFree(g)       { DTGamePortDestroy(g); g = NULL; }
  172. #define  DTGamePortReadLength(g) ((g)->gp_rreq->io_Actual)
  173.  
  174. #ifndef  DTBuildStdRequest
  175. #define  DTBuildStdRequest(r,c,f,o,d,l) \
  176.    { (r)->io_Command = (UWORD) c; \
  177.      (r)->io_Flags = (UBYTE) f; \
  178.      (r)->io_Offset = (ULONG) o; \
  179.      (r)->io_Data = (APTR) d; \
  180.      (r)->io_Length = (ULONG) l; }
  181. #endif
  182.  
  183. /*
  184. ****************************************************************************
  185.       End of GamePort.h
  186. ****************************************************************************
  187. */
  188.  
  189. #endif
  190.  
  191.