#ifndef GMS_SCREENS_H
#define GMS_SCREENS_H TRUE

/*
**    $VER: screens.h V0.8B
**
**    Screen Definitions
**
**    (C) Copyright 1996-1997 DreamWorld Productions.
**        All Rights Reserved
*/

#ifndef DPKERNEL_H
#include <games/dpkernel.h>
#endif

/****************************************************************************
** Screen Object.
*/

#define SCRVERSION  1
#define TAGS_SCREEN ((ID_SPCTAGS<<16)|ID_SCREEN)

struct GScreen {
  struct Head Head;        /* Standard structure header */
  APTR   MemPtr1;          /* Ptr to screen 1 */
  APTR   MemPtr2;          /* Ptr to screen 2 (double buffer) */
  APTR   MemPtr3;          /* Ptr to screen 3 (triple buffer) */
  struct GScreen *Next;    /* Ptr to a linked screen */
  LONG   *Palette;         /* Ptr to the screen palette */
  APTR   Rasterlist;       /* Ptr to a rasterlist */
  LONG   AmtColours;       /* The amount of colours in the palette */
  WORD   ScrWidth;         /* The width of the visible screen */
  WORD   ScrHeight;        /* The height of the visible screen */
  WORD   PicWidth;         /* The width of the picture (pixels) */
  WORD   PicByteWidth;     /* The width of the picture (bytes) READ ONLY */
  WORD   PicHeight;        /* The height of the entire screen */
  WORD   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 */
  LONG   Attrib;           /* Special Attributes are? */
  WORD   ScrMode;          /* What screen mode is it? */
  WORD   ScrType;          /* Interleaved/Planar/Chunky? */
  struct DPKTask *Task;    /* R: Task that owns this screen */
  LONG   PlaneSize;        /* R: Size of a plane (bytewidth*height) */
  struct Bitmap *Bitmap;   /* R: Bitmap */

  /* Private fields */

  APTR  prvTypeEmulator;   /* Emulation */
  APTR  prvMonitor;        /* Monitor driver */
  APTR  prvEMemPtr1;       /* Chunky driver */
  APTR  prvEMemPtr2;       /* Chunky driver */
  APTR  prvEMemPtr3;       /* Chunky driver */
  APTR  prvEFree1;         /* Chunky driver */
  APTR  prvEFree2;         /* Chunky driver */
  APTR  prvEFree3;         /* Chunky driver */
  BYTE  prvColBits;        /* 0 = 12bit, 1 = 24bit */
  BYTE  prvPad;            /* Unused */
  LONG  prvShowKey;        /* Resource key if the screen is shown */
  LONG  prvScratch;        /* Scratch address! */
  APTR  prvScreenPrefs;    /* Screen preferences for this screen */
  APTR  prvLineWait;       /* Line Wait till bitplanes start */
  APTR  prvEnd;            /* Ptr to the copper's jump end */
  WORD  prvBurstLevel;     /* FMode setting for bitplanes */
  APTR  prvControl;        /* BPLCON0 */
  APTR  prvModulo;         /* The screen modulo */
  APTR  prvScrPosition;    /* DIW's, DDF's, DIWHIGH */
  APTR  prvStart;          /* Start of main copperlist */
  APTR  prvSprites;        /* Pointer to the copper sprites */
  APTR  prvColours;        /* Pointer to the copper colours */
  WORD  prvAmtBankCols;    /* Amount of colours per bank (AGA) */
  WORD  prvAmtBanks;       /* Amount of banks in total (AGA) */
  WORD  prvHiLoOffset;     /* Offset between hi and lo bits (AGA) */
  APTR  prvBitplanes1;     /* Ptr to copper bitplane loaders #1 */
  APTR  prvBitplanes2;     /* Ptr to copper bitplane loaders #2 */
  APTR  prvBitplanes3;     /* Ptr to copper bitplane loaders #3 */
  APTR  prvColListJmp;     /* Jumper to RasterList */
  LONG  prvPicXOffset;     /* X offset for scrolling */
  LONG  prvPicYOffset;     /* Y offset for scrolling */
  WORD  prvScrollBWidth;   /* Set to 2 if scrolling */
  APTR  prvMemPtr1;        /* Original screen mem start (1) */
  APTR  prvMemPtr2;        /* Original screen mem start (2) */
  APTR  prvMemPtr3;        /* Original screen mem start (3) */
  WORD  prvBPLCON3;        /* BPLCON3 actual data (not a ptr) */
  WORD  prvAmtFields;      /* Amount of PlayFields on screen */
  WORD  prvFieldNum;       /* Number of this field */
  WORD  prvScrLRWidth;     /* ScrWidth, in lo-resolution */
  WORD  prvScrLRBWidth;    /* ScrByteWidth, in lo-resolution */
  WORD  prvPicLRWidth;     /* PicWidth, in lo-resolution */
  WORD  prvTOSX;           /* Top of screen X for this screen */
  WORD  prvTOSY;           /* Top of screen Y for this screen */
  LONG  prvLineMod;        /* The distance between lines */
  LONG  prvPlaneMod;       /* The distance between bitplanes */
  APTR  prvCopperMem;      /* Pointer to original screen mem start */
  APTR  prvRasterListMem;  /* Start of colour list memory */
  WORD  prvBlitXOffset;    /* Offset to use for blitting (hard-scroll) */
  LONG  prvAddScreenKey;   /* Resource key for AddScreen() */
};

/* Screen Buffer names, these are asked for in the blitter functions */

#define BUFFER1  12
#define BUFFER2  16
#define BUFFER3  20

/* SCREEN ATTRIBUTES (Attrib) */

#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 SBUFFER    0x00000040   /* Create a buffer for horiz scrolling */
#define CENTRE     0x00000080   /* Centre the screen (sets XOffset/YOffset) */
#define BLKBDR     0x00000100   /* Gives a blackborder on AGA machines */
#define NOSCRBDR   0x00000200   /* For putting sprites in the border */

/* SCREEN TYPES (ScrType) */

#define INTERLEAVED  1          /* These are numbers, not bits */
#define ILBM         1
#define PLANAR       2
#define CHUNKY8      3
#define CHUNKY16     4
#define TRUECOLOUR   5

/* SCREEN MODES (ScrMode) */

#define HIRES      0x0001       /* High resolution */
#define SHIRES     0x0002       /* Super-High resolution */
#define LACED      0x0004       /* Interlaced */
#define LORES      0x0008       /* Low resolution (default) */
#define EXTRAHB    0x0010       /* Extra Half-Brite */
#define SLACED     0x0020       /* Super-Laced resolution */
#define HAM        0x0040       /* For HAM mode */

/* Screen Attribute tags */

#define GSA_MemPtr1      (12|TAPTR)
#define GSA_MemPtr2      (16|TAPTR)
#define GSA_MemPtr3      (20|TAPTR)
#define GSA_Screenlink   (24|TAPTR)
#define GSA_Palette      (28|TAPTR)
#define GSA_Rasterlist   (32|TAPTR)
#define GSA_AmtColours   (36|TLONG)
#define GSA_ScrWidth     (40|TWORD)
#define GSA_ScrHeight    (42|TWORD)
#define GSA_PicWidth     (44|TWORD)
#define GSA_PicByteWidth (46|TWORD)
#define GSA_PicHeight    (48|TWORD)
#define GSA_Planes       (50|TWORD)
#define GSA_ScrXOffset   (52|TWORD)
#define GSA_ScrYOffset   (54|TWORD)
#define GSA_PicXOffset   (56|TWORD)
#define GSA_PicYOffset   (58|TWORD)
#define GSA_Attrib       (60|TLONG)
#define GSA_ScrMode      (64|TWORD)
#define GSA_ScrType      (66|TWORD)

/****************************************************************************
**                 Raster/Copper commands for RasterLists.
**
**     Example of initialising a colourlist:
**
**     LONG RasterList[] = {
**          COLOURLIST(0,1,0,&Colourlist),
**          RASTEND
**     };
**
** COLOUR     (ColourNumber,0xRRGGBB)
** COLOURLIST (StartLine,SKip,Colour,&Colourlist)
** SPRITE     (Sprite)
** SCROLL     (Fields,PixelOffset0-16,PixelQuarterOffset 1-4)
** FLOOD      ()
** REPOINT    (&BitplanePtr)
** MIRROR     ()
** NEWPALETTE (ColStart,AmtCols,&Palette)
** WAITLINE   (Line)
** RASTEND    ()
**
*/

#define WAITLINE(a)         (00<<16)|(a),0
#define COLOUR(a,b)         (02<<16),(a),(b),0
#define NEWPALETTE(a,b,c)   (04<<16),(a),(b),(LONG)(c),0
#define COLOURLIST(a,b,c,d) (06<<16)|(a),(b<<16)|(c),(LONG)(d),0
#define SPRITE(a)           (08<<16),(a),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 RASTEND             0xffffffff

/***************************************************************************
** Sprite Object.
*/

#define SPRVERSION  1
#define TAGS_SPRITE ((ID_SPCTAGS<<16)|ID_SPRITE)

struct Sprite {
  struct Head Head;       /* [00] Standard structure header */
  APTR   Data;            /* [12] Pointer to Sprite graphic */
  WORD   Number;          /* [16] Bank number to access */
  WORD   XPos;            /* [18] X position */
  WORD   YPos;            /* [20] Y position */
  WORD   Frame;           /* [22] Frame number */
  WORD   Width;           /* [24] Width in pixels */
  WORD   Height;          /* [26] Height in pixels */
  WORD   AmtColours;      /* [28] 4 or 16 */
  WORD   ColStart;        /* [30] Colour bank to access, increments of 16 */
  WORD   Planes;          /* [32] Amount of planes per bank */
  WORD   ScrMode;         /* [34] HiRes/LoRes/SHiRes */
  WORD   FieldPri;        /* [36] Field position in relation to playfields */
  WORD   Attrib;          /* [38] Attributes (XLONG) */
  struct GScreen *Owner;  /* [40] Screen structure */

  /*** Private fields below ***/

  LONG  prvFrameSize;     /* Amt of space used by one bank */
  LONG  prvSpriteSize;    /* Size of entire frame, incl XLONG */
  WORD  prvCtrlWidth;     /* Control word width */
  WORD  prvCopOffset;     /* Sprite offset in copper */
  WORD  prvXResShift;     /* The resolution shift, for hires/shires */
  WORD  prvYResShift;     /* The resolution shift, for laced */
};

#define SPA_Data       (12|TAPTR)
#define SPA_Number     (16|TWORD)
#define SPA_XCoord     (18|TWORD)
#define SPA_YCoord     (20|TWORD)
#define SPA_Frame      (22|TWORD)
#define SPA_Width      (24|TWORD)
#define SPA_Height     (26|TWORD)
#define SPA_AmtColours (28|TWORD)
#define SPA_ColStart   (30|TWORD)
#define SPA_Planes     (32|TWORD)
#define SPA_ScrMode    (34|TWORD)
#define SPA_FieldPri   (36|TWORD)
#define SPA_Attrib     (38|TWORD)
#define SPA_Owner      (40|TAPTR)

#define XLONG   0x0001

#endif
