#ifndef GAMES_GMS_H
#define GAMES_GMS_H TRUE

/*
**	$VER: games.h 0.3 (08.09.96)
**	Includes Release xx.xx
**
**	General include file for programs using the Games Master System.
**
**	(C) Copyright 1996 DreamWorld Productions.
**	    All Rights Reserved
*/

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef GMS_SOUND_H
#include <games/sound.h>
#endif

#define FILTER_OFF  0
#define FILTER_ON   1

#define LISTSTART   "LIST"
#define LISTEND     0
#define ENDLIST     0

/*
** --- Universal joystick status bits returned from Read_Joystick, Sega,
**     JoyPad, etc...
*/

#define JT_SWITCH 0
#define JT_ZBXY   1

#define JS_LEFT   (1L<<0)          /* X axis */
#define JS_RIGHT  (1L<<1)
#define JS_UP     (1L<<2)          /* Y axis */
#define JS_DOWN   (1L<<3)
#define JS_ZIN    (1L<<4)          /* Z axis!  Reserved for later... */
#define JS_ZOUT   (1L<<5)
#define JS_FIRE1  (1L<<6)          /* Fire Buttons */
#define JS_FIRE2  (1L<<7)          /* <-For 2 button joysticks */

#define JS_RED    (1L<<6)
#define JS_BLUE   (1L<<7)
#define JS_PLAY   (1L<<8)          /* CD32 buttons here */
#define JS_RWD    (1L<<9)
#define JS_FFW    (1L<<10)
#define JS_GREEN  (1L<<11)
#define JS_YELLOW (1L<<12)

#define JB_FIRE1  (1L<<16)         /* For the ZBXY style return type */
#define JB_FIRE2  (1L<<17)         /*  (analog joysticks) */

#define MB_LMB    (1L<<16)         /* Mouse button flags returned from */
#define MB_RMB    (1L<<17)         /*  Read_Mouse(), in ZBXY format */
#define MB_MMB    (1L<<18)

/* --- Joyport specifications for calling Read_JoyStick/Mouse/JoyPad...() */

#define JPORT1    0*2
#define JPORT2    1*2
#define JPORT3    2*2
#define JPORT4    3*2

/* --- Raster/Copper commands for RasterLists.
**
**     Example of initialising a 24 bit colourlist:
**
**     LONG RasterList[] = {
**          COL24LIST(0,1,0,&ColourList),
**          RASTEND
**     };
**
** COL12      (ColourNumber,0xRGB)
** COL24      (ColourNumber,0xRRGGBB)
** COL12LIST  (StartLine,Skip,Colour,(&ColourList)
** COL24LIST  (StartLine,SKip,Colour,(&ColourList)
** SPRITE     (SpriteStruct)
** SCROLL     (Fields,PixelOffset0-16,PixelQuarterOffset 1-4)
** FLOOD      
** REPOINT    (&BitplanePtr)
** MIRROR     
** NEWPALETTE (ColStart,AmtCols,&Palette)
** WAITLINE   (Line)
** RASTEND
**
** Warn: With colour related commands you must use the same amount of colour
** bits as specified in your GameScreen structure (_12BITCOL or _24BITCOL)
*/

#define COL12(a,b)         (00<<16)|a,(b<<16),0
#define COL24(a,b)         (02<<16)|a,b,0
#define COL12LIST(a,b,c,d) (04<<16)|a,(b<<16)|c,d,0
#define COL24LIST(a,b,c,d) (06<<16)|a,(b<<16)|c,(LONG)(d),0
#define SPRITE(a)          (08<<16),(a<<16),0
#define SCROLL(a,b,c)      (10<<16)|a,(b<<16)|c,0
#define FSCROLL(a,b,c,d)   (12<<16)|a,(b<<16)|c,(d<<16),0
#define FLOOD              (14<<16),0
#define REPOINT(a)         (16<<16),(LONG)(a),0
#define MIRROR             (18<<16),0
#define NEWPALETTE(a,b,c)  (20<<16)|a,(b<<16),(LONG)(c),0
#define WAITLINE(a)        (22<<16)|a,0
#define RASTEND            0xffffffff

/* --- GPI ID numbers --- */

#define GPI_SCREENS  0
#define GPI_BLITTER  4
#define GPI_SOUND    8
#define GPI_NETWORK  12
#define GPI_VECTORS  16
#define GPI_DEBUG    20
#define GPI_ANIM     24
#define GPI_REKO     28
#define GPI_TEXT     32

/* --- Standard screen structure --- */

#define GSV1 'G','S','V','1',0

  struct   GameScreen
    {
    char   VERSION[4];           /* Structure version - "GSV1" */
    APTR   Stats;                /* Private */
    APTR   MemPtr1;              /* Ptr to screen 1 */
    APTR   MemPtr2;              /* Ptr to screen 2 (double buffer) */
    APTR   MemPtr3;              /* Ptr to screen 3 (triple buffer) */
    APTR   ScreenLink;           /* Ptr to a linked screen */
    APTR   Palette;              /* Ptr to the screen palette */
    APTR   RasterList;           /* Ptr to a rasterlist */
    ULONG  AmtColours;           /* The amount of colours in the palette. */
    UWORD  ScrWidth;             /* The width of the visible screen */
    UWORD  ScrHeight;            /* The height of the visible screen */
    UWORD  PicWidth;             /* The width of the entire screen */
    UWORD  PicHeight;            /* The height of the entire screen */
    UWORD  Planes;               /* The amount of planes in da screen */
    WORD   ScrXOffset;           /* Hardware co-ordinate for TOS */
    WORD   ScrYOffset;           /* Hardware co-ordinate for LOS */
    WORD   PicXOffset;           /* Offset of the horizontal axis */
    WORD   PicYOffset;           /* Offset of the vertical axis */
    ULONG  ScrAttrib;            /* Special Attributes are? */
    UWORD  ScrMode;              /* What screen mode is it? */
    UBYTE  ScrType;              /* Interleaved/Planar/Chunky? */
    UBYTE  Displayed;            /* Private */
    };

/* SCREEN TYPES (flags for SS_ScrType) */

#define INTERLEAVED  0              /* These are actual numbers */
#define PLANAR       1              /* rather than bits */
#define CHUNKY       2

/* SCREEN ATTRIBUTES (flags and bits for SS_ScrAttrib) */

#define DBLBUFFER  0x00000001       /* For double buffering */
#define TPLBUFFER  0x00000002       /* Triple buffering!! */
#define PLAYFIELD  0x00000004       /* Set if it's part of a playfield */
#define HSCROLL    0x00000008       /* Gotta set this to do scrolling */
#define VSCROLL    0x00000010       /* For vertical scrolling */
#define SPRITES    0x00000020       /* Set this if you want sprites */
#define HBUFFER    0x00000040       /* Create a buffer for horiz scrolling */
/*                 0x00000080       */
#define BLKBDR     0x00000100       /* Gives a blackborder on AGA machines */
#define NOSPRBDR   0x00000200       /* For putting sprites in the border */

/* SCREEN MODES (flags for SS_ScrMode) */

#define LORES      0x0000           /* Low resolution (default) */
#define HIRES      0x0001           /* High resolution */
#define SHIRES     0x0002           /* Super-High resolution */
#define INTERLACED 0x0004           /* Interlaced */
#define EXTRAHB    0x0010           /* Extra Half-Brite */
#define NTSC       0x0020           /* Set if you wrote this game in NTSC */
#define HAM        0x0040           /* For HAM mode */
#define COL24BIT   0x0080           /* 24Bit colours (default is 12Bits) */

/* --- Universal errorcodes returned by certain functions --- */

#define ERR_OK     0           /* Function went OK (also NULL) */
#define ERR_NOMEM  1           /* Not enough memory available */
#define ERR_NOPTR  2           /* Required pointer not present */
#define ERR_INUSE  3           /* Previous allocations have not been freed */
#define ERR_NOVER  4           /* Structure version not supported or not found */
#define ERR_FAILED 5           /* General failure */
#define ERR_FILE   6           /* File error, eg file not found */

/* --- Sprite structure --- */

#define SPV1 'S','P','V','1',0

  struct Sprite
   {
   char  VERSION[4];
   APTR  Stats;
   UWORD Number;         /* Bank number to access */
   APTR  Data;           /* Pointer to Sprite graphic */
   WORD  XPos;           /* X position */
   WORD  YPos;           /* Y position */
   UWORD Frame;          /* Frame number */
   UWORD Width;          /* Width in pixels */
   UWORD Height;         /* Height in pixels */
   UWORD AmtColours;     /* 4 or 16 */
   UWORD ColStart;       /* Colour bank to access, increments of 16 */
   UWORD Planes;         /* Amount of planes per bank */
   UWORD Resolution;     /* HiRes/LoRes/SHiRes/XLONG */
   UWORD FieldPriority;  /* Field position in relation to playfields */
   ULONG SpriteSize;     /* Reserved */
   ULONG FrameSize;      /* Reserved */
   };

#define SPR_OCS 0x0010
#define SPR_AGA 0x0020
#define XLONG   0x0040

/* --- The picture structure for loading and depacking of pictures */

#define PCV1 'P','C','V','1',0

  struct Picture
   {
   char  VERSION[4];        /* "PCV1" */
   APTR  Stats;             /* Reserved */
   APTR  Data;              /* Destination or Source */
   UWORD Width;             /* Width */
   UWORD Height;            /* Height */
   UWORD Planes;            /* Amount of planes */
   ULONG AmtColours;        /* Amount of colours */
   APTR  Palette;           /* Original palette */
   UWORD ScrMode;           /* Intended screen mode for picture */
   UWORD Type;              /* Interleaved/Chunky/Planar */
   ULONG Attrib;            /* GETPALETTE/VIDEOMEM/ */
   };

/* --- Choose one of these for calling Set_Interrupt() --- */

#define INTB_INTEN   14   /* Master interrupt (enable only ) */
#define INTB_EXTER   13   /* External interrupt */
#define INTB_DSKSYNC 12   /* Disk re-SYNChronized */
#define INTB_RBF     11   /* serial port Receive Buffer Full */
#define INTB_AUD3    10   /* Audio channel 3 block finished */
#define INTB_AUD2     9   /* Audio channel 2 block finished */
#define INTB_AUD1     8   /* Audio channel 1 block finished */
#define INTB_AUD0     7   /* Audio channel 0 block finished */
#define INTB_BLIT     6   /* Blitter finished */
#define INTB_VERTB    5   /* start of Vertical Blank */
#define INTB_COPER    4   /* Coprocessor */
#define INTB_PORTS    3   /* I/O Ports and timers */
#define INTB_SOFTINT  2   /* software interrupt rest */
#define INTB_DSKBLK   1   /* Disk Block done */
#define INTB_TBE      0   /* serial port Transmit Buffer Empty */

/* --- Special Keypresses that can be returned from Read_Key().  All other
** keys can be considered to be in ASCII format.
*/

 struct Keys
  {
  WORD  KP_ID;
  BYTE  KP_Key1;
  BYTE  KP_Key2;
  BYTE  KP_Key3;
  BYTE  KP_Key4;
  };

#define K_SCS     0x80       /* Screen switch (LEFTAMIGA + M) */
#define K_DEL     0x81
#define K_HELP    0x82

#define K_LSHIFT  0x83
#define K_RSHIFT  0x84
#define K_CAPS    0x85
#define K_CTRL    0x86
#define K_LALT    0x87
#define K_RALT    0x88
#define K_LAMIGA  0x89
#define K_RAMIGA  0x8a

#define K_F1      0x8b
#define K_F2      0x8c
#define K_F3      0x8d
#define K_F4      0x8e
#define K_F5      0x8f
#define K_F6      0x90
#define K_F7      0x91
#define K_F8      0x92
#define K_F9      0x93
#define K_F10     0x94
#define K_F11     0x95
#define K_F12     0x96
#define K_F13     0x97
#define K_F14     0x98
#define K_F15     0x99
#define K_F16     0x9a
#define K_F17     0x9b
#define K_F18     0x9c
#define K_F19     0x9d
#define K_F20     0x9e

#define C_UP      0x9f
#define C_DOWN    0xa0
#define C_RIGHT   0xa1
#define C_LEFT    0xa2

#define K_SRIGHT  0xa3       /* Special key on right */
#define K_SLEFT   0xa4       /* Special key on left */

/* --- Special keys that are recognised under ASCII (here for convenience)*/

#define K_BAKSPC 08
#define K_TAB    09
#define K_ENTER  10
#define K_RETURN 10
#define K_ESC    ""

#endif
