home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 138.lha / Cycle / cycles.h < prev    next >
C/C++ Source or Header  |  1988-04-26  |  3KB  |  81 lines

  1. /*
  2.  * here we define all the structures and constants used in the server
  3.  */
  4. #include <exec/types.h>
  5. #include <exec/memory.h>
  6. #include <exec/nodes.h>
  7. #include <exec/ports.h>
  8. #include <devices/timer.h>
  9. #include <libraries/dos.h>
  10.  
  11. /* first some abbreviations that I like */
  12. typedef struct Node        NODE;
  13. typedef struct MsgPort     PORT;
  14. typedef struct Message     MSG;
  15. typedef struct List        LIST;
  16. typedef struct timerequest TIMEREQ;
  17.  
  18. /* info to describe each cycle */
  19. typedef struct {
  20.   NODE    node;         /* to keep things organized  */
  21.   struct  Order *msg;   /* place for pending message */
  22.   long status;          /* current status            */
  23.   long x,y;             /* current position          */
  24.   long dir;             /* current direction         */
  25.   long colour;          /* your colour designation   */
  26. } CYCLE;
  27.  
  28. typedef struct {
  29.   long x;      /* x size of screen image   */
  30.   long y;      /* y size of screen image   */
  31.   BYTE *buf;   /* position to buffer area  */
  32. } IMAGE;
  33.  
  34. /* specification for the massages we expect to recieve */
  35. typedef struct Order {
  36.   MSG   msg;    /* Exec message structure        */
  37.   long  order;  /* command to be performed       */
  38.   long  x,y;    /* parameters                    */
  39.   long  dir;    /* direction                     */
  40.   long  status; /* your current status           */
  41.   CYCLE *cycle; /* pointer to my cycle structure */
  42.   IMAGE *table; /* pointer to screen table       */
  43. } ORDER;
  44.  
  45. #define STATUS_NEED_NEW    0 /* no direction change specified yet          */
  46. #define STATUS_GOT_MOVE    1 /* direction change specified: will use       */
  47.  
  48. #define STATUS_DEAD      100 /* dummy entry -- bigger entries mean dead    */
  49. #define STATUS_LOSER     101 /* you've crashed -- out of this game         */
  50. #define STATUS_WINNER    102 /* you're the only remaining bike             */
  51. #define STATUS_AWAITING  103 /* waiting for a new game                     */
  52. #define STATUS_REMOVED   104 /* you are no longer in the game              */
  53.  
  54. #define ORD_DIRECTION      0 /* cycle change direction next move           */
  55. #define ORD_AWAIT          1 /* reply when the next game has begun         */
  56. #define ORD_RETIRE         2 /* I'm leaving -- forget all about me         */
  57.  
  58. #define TURN_LEFT(dir)   (((dir) - 1) & 3)
  59. #define TURN_RIGHT(dir)  (((dir) + 1) & 3)
  60.  
  61. #define DIR_UP             0 /* constants for directions                   */
  62. #define DIR_RIGHT          1 /* these are guaranteed never to change       */
  63. #define DIR_DOWN           2 /* in future revisions so you can do          */
  64. #define DIR_LEFT           3 /* things like adding 1 (mod 4) to turn       */
  65.                              /* right, -1 to turn left..                   */
  66.  
  67. #define MAX_COLOURS        5 /* maximum number of colours & players        */
  68. #define X_SIZE            40 /* clients are not allowed to look at         */
  69. #define Y_SIZE            23 /* these as the server may be compiled        */
  70.                              /* with different values. The server          */
  71.                              /* decides the size of the arena              */
  72. extern MSG       *GetMsg();
  73. extern PORT      *CreatePort();
  74. extern void      *AllocMem();
  75. extern void      *CreateExtIO();
  76. extern TIMEREQ   *Timer_Open();
  77. extern void      Timer_Close();
  78. extern void      Timer_Post();
  79.  
  80. extern long scores[];
  81.