home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Includes / games / games.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-16  |  15.9 KB  |  462 lines

  1. #ifndef GAMES_GMS_H
  2. #define GAMES_GMS_H TRUE
  3.  
  4. /*
  5. **   $VER: games.h 0.5 (15.02.97)
  6. **
  7. **   General include file for programs using the Games Master System.
  8. **
  9. **   (C) Copyright 1996-1997 DreamWorld Productions.
  10. **       All Rights Reserved
  11. */
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include <exec/types.h>
  15. #endif
  16.  
  17. #ifndef UTILITY_TAGITEM_H
  18. #include <utility/tagitem.h>
  19. #endif
  20.  
  21. #ifndef GMS_SOUND_H
  22. #include <games/sound.h>
  23. #endif
  24.  
  25. #ifndef GMS_MISC_H
  26. #include <games/misc.h>
  27. #endif
  28.  
  29. #ifndef GMS_IMAGE_H
  30. #include <games/image.h>
  31. #endif
  32.  
  33. /***************************************************************************/
  34.  
  35. #define LIST       0x4C495354
  36. #define OBJECTLIST 0x4F4C5354
  37. #define SKIPENTRY  0
  38. #define LISTEND    -1
  39. #define ENDLIST    -1
  40. #define TAGEND     0
  41.  
  42. /****************************************************************************
  43. ** Helpful macros and structures.
  44. */
  45.  
  46. struct PixelEntry {
  47.   WORD  XCoord;
  48.   WORD  YCoord;
  49.   LONG  Colour;
  50. };
  51.  
  52. #define SKIPPIXEL -32000
  53. #define PIXELLIST(a) struct PixelList { WORD Entries; UWORD EntrySize; struct PixelEntry Entry[(a)]; } PixelList
  54.  
  55. #define GetX(a) (BYTE)((a)>>8)  /* Decompress ZBXY format */
  56. #define GetY(a) (BYTE)(a)
  57.  
  58. /****************************************************************************
  59. **
  60. ** Universal errorcodes returned by certain functions.
  61. **
  62. */
  63.  
  64. #define ERR_OK       0    /* Function went OK (also NULL) */
  65. #define ERR_NOMEM    1    /* Not enough memory available */
  66. #define ERR_NOPTR    2    /* Required pointer not present */
  67. #define ERR_INUSE    3    /* Previous allocations have not been freed */
  68. #define ERR_NOVER    4    /* Structure version not supported or not found */
  69. #define ERR_FAILED   5    /* General failure */
  70. #define ERR_FILE     6    /* File error, eg file not found */
  71. #define ERR_DATA     7    /* There is an error in the given data */
  72. #define ERR_SEARCH   8    /* A search routine in this function failed */
  73. #define ERR_SCRTYPE  9    /* Screen type not recognised */
  74. #define ERR_GPI     10    /* Trouble initialising/using a GPI */
  75.  
  76. /****************************************************************************
  77. ** Memory types used by AllocMemBlock().  This is generally identical to the
  78. ** exec definitions but CHIP is renamed to VIDEO (displayable memory) and
  79. ** there is an addition of BLIT and SOUND specific memory.
  80. */
  81.  
  82. #define MEM_ANY   0
  83. #define MEM_CLEAR 0
  84. #define MEM_VIDEO (1L<<1)
  85. #define MEM_BLIT  (1L<<2)
  86. #define MEM_SOUND (1L<<3)
  87.  
  88. /****************************************************************************
  89. **
  90. ** Universal joystick status bits returned from Read_Joystick, Sega,
  91. ** JoyPad, etc...
  92. **
  93. */
  94.  
  95. #define JT_SWITCH 0
  96. #define JT_ZBXY   1
  97.  
  98. #define JS_LEFT   (1L<<0)          /* X axis */
  99. #define JS_RIGHT  (1L<<1)
  100. #define JS_UP     (1L<<2)          /* Y axis */
  101. #define JS_DOWN   (1L<<3)
  102. #define JS_ZIN    (1L<<4)          /* Z axis!  Reserved for later... */
  103. #define JS_ZOUT   (1L<<5)
  104. #define JS_FIRE1  (1L<<6)          /* Fire Buttons */
  105. #define JS_FIRE2  (1L<<7)          /* For 2 button joysticks */
  106. #define JS_FIRE3  (1L<<11)         /* For 3 button joysticks */
  107.  
  108. #define JS_RED    (1L<<6)          /* CD32 buttons here */
  109. #define JS_BLUE   (1L<<7)
  110. #define JS_PLAY   (1L<<8)
  111. #define JS_RWD    (1L<<9)
  112. #define JS_FFW    (1L<<10)
  113. #define JS_GREEN  (1L<<11)
  114. #define JS_YELLOW (1L<<12)
  115.  
  116. #define JB_FIRE1  (1L<<16)         /* For the ZBXY style return type */
  117. #define JB_FIRE2  (1L<<17)         /*  (analog joysticks) */
  118. #define JB_FIRE3  (1L<<18)
  119.  
  120. #define MB_LMB    (1L<<16)         /* Mouse button flags returned from */
  121. #define MB_RMB    (1L<<17)         /*  Read_Mouse(), in ZBXY format */
  122. #define MB_MMB    (1L<<18)
  123.  
  124. /* Joyport specifications for calling Read_JoyStick/Mouse/JoyPad...() */
  125.  
  126. #define JPORT1    0*2
  127. #define JPORT2    1*2
  128. #define JPORT3    2*2
  129. #define JPORT4    3*2
  130.  
  131. /****************************************************************************
  132. ** GPI ID numbers
  133. */
  134.  
  135. #define GPI_SCREENS 0
  136. #define GPI_BLITTER 4
  137. #define GPI_SOUND   8
  138. #define GPI_NETWORK 12
  139. #define GPI_VECTORS 16
  140. #define GPI_DEBUG   20
  141. #define GPI_ANIM    24
  142. #define GPI_REKO    28
  143. #define GPI_TEXT    32
  144. #define GPI_OBJECTS 38
  145.  
  146. /****************************************************************************
  147. ** Standard screen structure
  148. */
  149.  
  150. #define GSV1 0x47530000,0
  151.  
  152.   struct   GameScreen
  153.     {
  154.     ULONG  VERSION;       /* Structure version */
  155.     APTR   Stats;         /* Private */
  156.     APTR   MemPtr1;       /* Ptr to screen 1 */
  157.     APTR   MemPtr2;       /* Ptr to screen 2 (double buffer) */
  158.     APTR   MemPtr3;       /* Ptr to screen 3 (triple buffer) */
  159.     APTR   ScreenLink;    /* Ptr to a linked screen */
  160.     APTR   Palette;       /* Ptr to the screen palette */
  161.     APTR   RasterList;    /* Ptr to a rasterlist */
  162.     ULONG  AmtColours;    /* The amount of colours in the palette */
  163.     UWORD  ScrWidth;      /* The width of the visible screen */
  164.     UWORD  ScrHeight;     /* The height of the visible screen */
  165.     UWORD  PicWidth;      /* The width of the picture (pixels) */
  166.     UWORD  PicByteWidth;  /* The width of the picture (bytes) */
  167.     UWORD  PicHeight;     /* The height of the entire screen */
  168.     UWORD  Planes;        /* The amount of planes in da screen */
  169.     WORD   ScrXOffset;    /* Hardware co-ordinate for TOS */
  170.     WORD   ScrYOffset;    /* Hardware co-ordinate for LOS */
  171.     UWORD  PicXOffset;    /* Offset of the horizontal axis */
  172.     UWORD  PicYOffset;    /* Offset of the vertical axis */
  173.     ULONG  Attrib;        /* Special Attributes are? */
  174.     UWORD  ScrMode;       /* What screen mode is it? */
  175.     UWORD  ScrType;       /* Interleaved/Planar/Chunky? */
  176.     };
  177.  
  178. /* Screen Buffer names, these are asked for in the blitter functions */
  179.  
  180. #define BUFFER1  8
  181. #define BUFFER2  12
  182. #define BUFFER3  16
  183.  
  184. /* SCREEN ATTRIBUTES (Attrib) */
  185.  
  186. #define DBLBUFFER  0x00000001   /* For double buffering */
  187. #define TPLBUFFER  0x00000002   /* Triple buffering!! */
  188. #define PLAYFIELD  0x00000004   /* Set if it's part of a playfield */
  189. #define HSCROLL    0x00000008   /* Gotta set this to do scrolling */
  190. #define VSCROLL    0x00000010   /* For vertical scrolling */
  191. #define SPRITES    0x00000020   /* Set this if you want sprites */
  192. #define SBUFFER    0x00000040   /* Create a buffer for horiz scrolling */
  193. #define CENTRE     0x00000080   /* Centre the screen (sets XOffset/YOffset) */
  194. #define BLKBDR     0x00000100   /* Gives a blackborder on AGA machines */
  195. #define NOSCRBDR   0x00000200   /* For putting sprites in the border */
  196.  
  197. /* SCREEN TYPES (ScrType) */
  198.  
  199. #define INTERLEAVED  1              /* These are numbers, not bits */
  200. #define ILBM         1
  201. #define PLANAR       2
  202. #define CHUNKY8      3
  203. #define CHUNKY16     4
  204. #define TRUECOLOUR   5
  205.  
  206. /* SCREEN MODES (ScrMode) */
  207.  
  208. #define LORES      0x0000       /* Low resolution (default) */
  209. #define HIRES      0x0001       /* High resolution */
  210. #define SHIRES     0x0002       /* Super-High resolution */
  211. #define LACED      0x0004       /* Interlaced */
  212. #define EXTRAHB    0x0010       /* Extra Half-Brite */
  213. #define HAM        0x0040       /* For HAM mode */
  214. #define COL12BIT   0x0080       /* 12 Bit colours */
  215. #define COL24BIT   0x0000       /* 24 Bit colours (default) */
  216.  
  217. /* Screen Attribute tags */
  218.  
  219. #define TAGS 0x54414753
  220.  
  221. #define TBYTE 0
  222. #define TWORD (1L<<30)
  223. #define TLONG (1L<<31)
  224. #define TAPTR (1L<<30)|TLONG
  225.  
  226. #define GSA_MemPtr1       (8|TAPTR)
  227. #define GSA_MemPtr2      (12|TAPTR)
  228. #define GSA_MemPtr3      (16|TAPTR)
  229. #define GSA_ScreenLink   (20|TAPTR)
  230. #define GSA_Palette      (24|TAPTR)
  231. #define GSA_RasterList   (28|TAPTR)
  232. #define GSA_AmtColours   (32|TLONG)
  233. #define GSA_ScrWidth     (36|TWORD)
  234. #define GSA_ScrHeight    (38|TWORD)
  235. #define GSA_PicWidth     (40|TWORD)
  236. #define GSA_PicByteWidth (42|TWORD)
  237. #define GSA_PicHeight    (44|TWORD)
  238. #define GSA_Planes       (46|TWORD)
  239. #define GSA_ScrXOffset   (48|TWORD)
  240. #define GSA_ScrYOffset   (50|TWORD)
  241. #define GSA_PicXOffset   (52|TWORD)
  242. #define GSA_PicYOffset   (54|TWORD)
  243. #define GSA_Attrib       (56|TLONG)
  244. #define GSA_ScrMode      (60|TWORD)
  245. #define GSA_ScrType      (62|TWORD)
  246.  
  247. /****************************************************************************
  248. **                 Raster/Copper commands for RasterLists.
  249. **
  250. **     Example of initialising a 24 bit colourlist:
  251. **
  252. **     LONG RasterList[] = {
  253. **          COL24LIST(0,1,0,&ColourList),
  254. **          RASTEND
  255. **     };
  256. **
  257. ** COL12      (ColourNumber,0xRGB)
  258. ** COL24      (ColourNumber,0xRRGGBB)
  259. ** COL12LIST  (StartLine,Skip,Colour,&ColourList)
  260. ** COL24LIST  (StartLine,SKip,Colour,&ColourList)
  261. ** SPRITE     (Sprite)
  262. ** SCROLL     (Fields,PixelOffset0-16,PixelQuarterOffset 1-4)
  263. ** FLOOD      ()
  264. ** REPOINT    (&BitplanePtr)
  265. ** MIRROR     ()
  266. ** NEWPALETTE (ColStart,AmtCols,&Palette)
  267. ** WAITLINE   (Line)
  268. ** RASTEND    ()
  269. **
  270. ** Warn: With colour related commands you must use the same amount of colour
  271. ** bits as specified in your GameScreen structure (COL12BIT or COL24BIT)
  272. */
  273.  
  274. #define COL12(a,b)         (00<<16)|(a),(b<<16),0
  275. #define COL24(a,b)         (02<<16),(a),(b),0
  276. #define COL12LIST(a,b,c,d) (04<<16)|(a),(b<<16)|(c),(LONG)(d),0
  277. #define COL24LIST(a,b,c,d) (06<<16)|(a),(b<<16)|(c),(LONG)(d),0
  278. #define SPRITE(a)          (08<<16),(a),0
  279. #define SCROLL(a,b,c)      (10<<16)|(a),(b<<16)|(c),0
  280. #define FSCROLL(a,b,c,d)   (12<<16)|(a),(b<<16)|(c),(d<<16),0
  281. #define FLOOD              (14<<16),0
  282. #define REPOINT(a)         (16<<16),(LONG)(a),0
  283. #define MIRROR             (18<<16),0
  284. #define NEWPALETTE(a,b,c)  (20<<16),(a),(b),(LONG)(c),0
  285. #define WAITLINE(a)        (22<<16)|(a),0
  286. #define RASTEND            0xffffffff
  287.  
  288. /***************************************************************************
  289. ** Sprite Structure.
  290. */
  291.  
  292. #define SPV1 0x53500000,0
  293.  
  294.   struct Sprite
  295.    {
  296.    ULONG VERSION;        /* Structure version */
  297.    APTR  Stats;          /* Private */
  298.    UWORD Number;         /* Bank number to access */
  299.    APTR  Data;           /* Pointer to Sprite graphic */
  300.    WORD  XPos;           /* X position */
  301.    WORD  YPos;           /* Y position */
  302.    UWORD Frame;          /* Frame number */
  303.    UWORD Width;          /* Width in pixels */
  304.    UWORD Height;         /* Height in pixels */
  305.    UWORD AmtColours;     /* 4 or 16 */
  306.    UWORD ColStart;       /* Colour bank to access, increments of 16 */
  307.    UWORD Planes;         /* Amount of planes per bank */
  308.    UWORD ScrMode;        /* HiRes/LoRes/SHiRes */
  309.    UWORD FieldPri;       /* Field position in relation to playfields */
  310.    UWORD Attrib;         /* Attributes (XLONG) */
  311.    };
  312.  
  313. #define XLONG   0x0001
  314.  
  315. /***************************************************************************
  316. ** BOB Structure.
  317. */
  318.  
  319. #define BBV1 0x42420000,0
  320. #define MBV1 0x424D0000,0
  321.  
  322. struct FrameList { /* Standard FrameList layout if pointing to BOBs */
  323.   WORD GFX_XCoord; /* contained in a Picture structure. */
  324.   WORD GFX_YCoord;
  325.   WORD MSK_XCoord;
  326.   WORD MSK_YCoord;
  327. };
  328.  
  329. struct DirectList { /* Special FrameList layout for pointing directly */
  330.   APTR Graphic;     /* to the raw address of a BOB (use DIRECT flag). */
  331.   APTR Mask;
  332. };
  333.  
  334.   struct BOB
  335.    {
  336.    ULONG  VERSION;          /* Structure version */
  337.    APTR   Stats;            /* Private */
  338.    APTR   GfxData;          /* Pointer to graphics source */
  339.    APTR   MaskData;         /* Pointer to mask source */
  340.    UWORD  Frame;            /* Current frame */
  341.    APTR   FrameList;        /* Pointer to frame list */
  342.    WORD   SrcWidth;         /* Source Page Width in bytes */
  343.    UWORD  Width;            /* Width in pixels */
  344.    UWORD  ByteWidth;        /* Width in bytes */
  345.    UWORD  Height;           /* Height in pixels */
  346.    WORD   XCoord;           /* To X pixel */
  347.    WORD   YCoord;           /* To Y pixel */
  348.    UWORD  ClipLX;           /* Left X border in bytes (0/8) */
  349.    UWORD  ClipTY;           /* Top Y border (0) */
  350.    UWORD  ClipRX;           /* Right X border in bytes (320/8) */
  351.    UWORD  ClipBY;           /* Bottom Y border (256) */
  352.    UWORD  FPlane;           /* 1st Plane to blit to (planar only) */
  353.    UWORD  Planes;           /* Amount of planes */
  354.    ULONG  PlaneSize;        /* Size of source plane (planar only) */
  355.    ULONG  Attrib;           /* Attributes like CLIP and MASK */
  356.    struct Picture *Picture; /* Pointer to a picture struct */
  357.    };
  358.  
  359. #define BBA_GfxData    (8|TAPTR)
  360. #define BBA_MaskData  (12|TAPTR)
  361. #define BBA_Frame     (16|TWORD)
  362. #define BBA_FrameList (18|TAPTR)
  363. #define BBA_SrcWidth  (22|TWORD)
  364. #define BBA_Width     (24|TWORD)
  365. #define BBA_ByteWidth (26|TWORD)
  366. #define BBA_Height    (28|TWORD)
  367. #define BBA_XCoord    (30|TWORD)
  368. #define BBA_YCoord    (32|TWORD)
  369. #define BBA_ClipLX    (34|TWORD)
  370. #define BBA_ClipTY    (36|TWORD)
  371. #define BBA_ClipRX    (38|TWORD)
  372. #define BBA_ClipBY    (40|TWORD)
  373. #define BBA_FPlane    (42|TLONG)
  374. #define BBA_Planes    (46|TWORD)
  375. #define BBA_PlaneSize (48|TLONG)
  376. #define BBA_Attrib    (52|TWORD)
  377. #define BBA_Picture   (56|TAPTR)
  378.  
  379.   struct MBOB
  380.    {
  381.    ULONG  VERSION;          /* Structure version */
  382.    APTR   Stats;            /* Private */
  383.    APTR   GfxData;          /* Pointer to graphics source */
  384.    APTR   MaskData;         /* Pointer to mask source */
  385.    UWORD  AmtEntries;       /* Amount of entries in the list */
  386.    APTR   FrameList;        /* Pointer to frame list */
  387.    WORD   SrcWidth;         /* Source Page Width in bytes */
  388.    UWORD  Width;            /* Width in pixels (optional) */
  389.    UWORD  ByteWidth;        /* Width in bytes */
  390.    UWORD  Height;           /* Height in pixels */
  391.    APTR   EntryList;        /* Pointer to entry list */
  392.    UWORD  ClipLX;           /* Left X border in bytes (0/8) */
  393.    UWORD  ClipTY;           /* Top Y border (0) */
  394.    UWORD  ClipRX;           /* Right X border in bytes (320/8) */
  395.    UWORD  ClipBY;           /* Bottom Y border (256) */
  396.    UWORD  FPlane;           /* 1st Plane to blit to (planar only) */
  397.    UWORD  Planes;           /* Amount of planes */
  398.    ULONG  PlaneSize;        /* Size of source plane (planar only) */
  399.    ULONG  Attrib;           /* Attributes like CLIP and MASK */
  400.    struct Picture *Picture; /* Pointer to picture origin (optional) */
  401.    UWORD  EntrySize;        /* Entry size (sizeof(struct MBOBEntry)) */
  402.    };
  403.  
  404.   struct  MBOBEntry         /* MBOB Entry Structure */
  405.    {
  406.    WORD   XCoord;
  407.    WORD   YCoord;
  408.    UWORD  Frame;
  409.    };
  410.  
  411. #define BE_SIZEOF sizeof(struct BOBEntry)
  412.  
  413. /* BOB Attributes (BOB.Attrib) */
  414.  
  415. #define CLIP      0x00000001 /* Allow border clipping */
  416. #define MASK      0x00000002 /* Allow masking */
  417. #define STILL     0x00000004 /* This bob is not moving */
  418. #define CLEAR     0x00000008 /* Allow automatic clearing */
  419. #define RESTORE   0x00000010 /* Allow automatic background restore */
  420. #define DIRECT    0x00000020 /* Using direct graphics and mask pointers */
  421. #define FILLMASK  0x00000040 /* Fill any holes in the mask on generation */
  422. #define GENMASKS  0x00000082 /* Create and use masks for drawing this BOB */
  423. #define CLRMASK   0x00000100 /* Use masks when clearing */
  424. #define CLRNOMASK 0x00000000 /* Do not use masks when clearing (default) */
  425.  
  426. #define GENMASK GENMASKS /* Synonym */
  427.  
  428. #define SKIPIMAGE 32000
  429.  
  430. /****************************************************************************
  431. ** Map structure
  432. */
  433.  
  434. #define MPV1 'M','P',0,0,0
  435.  
  436.   struct Map
  437.    {
  438.    ULONG  VERSION;          /* The structure version, MPV1 */
  439.    ULONG  Stats;            /* Private */
  440.    UWORD  Buffer;           /* Destination buffer */
  441.    UWORD  Number;           /* Map number to access for data */
  442.    APTR   MapList;          /* Pointer to the map datalist */
  443.    UWORD  Width;            /* Total width of map */
  444.    UWORD  Height;           /* Total height of map */
  445.    UWORD  XStart;           /* Get block data starting from X [byte] */
  446.    UWORD  YStart;           /* Get block data starting from Y */
  447.    UWORD  EntrySize;        /* Byte/Word/Long */
  448.    ULONG  EntryMask;        /* For special cases */
  449.    UWORD  TileWidth;        /* The width/8 of each tile (bytes) */
  450.    UWORD  TileHeight;       /* The height of each tile */
  451.    UWORD  Options;          /* Applicable Map options, eg LOCKED */
  452.    struct Picture *Picture; /* Points to the map's graphics picture */
  453.    char   *File;            /* Where to get the map data */
  454.    };
  455.  
  456. #define LOCKED 0x0001   /* Blocks are blitted on 16 pixel boundaries  */
  457. #define ESIZE_BYTE 1    /* Entry size is in bytes */
  458. #define ESIZE_WORD 2    /* Entry size is in words */
  459. #define ESIZE_LONG 3    /* Entry size is in longs */
  460.  
  461. #endif
  462.