#ifndef GRAPHICS_SCREENS_H
#define GRAPHICS_SCREENS_H TRUE

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

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

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

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

struct GScreen {
  struct Head Head;       /* [00] Standard structure header */
  APTR   MemPtr1;         /* [12] Ptr to screen 1 */
  APTR   MemPtr2;         /* [16] Ptr to screen 2 (double buffer) */
  APTR   MemPtr3;         /* [20] Ptr to screen 3 (triple buffer) */
  struct GScreen *Next;   /* [24] Reserved */
  LONG   *Palette;        /* [28] Ptr to the screen palette */
  struct Raster *Raster;  /* [32] Ptr to a rasterlist */
  LONG   empemp;          /* [36] */
  WORD   Width;           /* [40] The width of the visible screen */
  WORD   Height;          /* [42] The height of the visible screen */
  WORD   XOffset;         /* [44] Hardware co-ordinate for TOS */
  WORD   YOffset;         /* [46] Hardware co-ordinate for LOS */
  WORD   BmpXOffset;      /* [48] Offset of the horizontal axis */
  WORD   BmpYOffset;      /* [50] Offset of the vertical axis */
  WORD   ScrMode;         /* [52] What screen mode is it? */
  WORD   Empty;           /* [54] Reserved. */
  LONG   Attrib;          /* [56] Special Attributes are? */
  struct DPKTask *Task;   /* [60] R: Task that owns this screen */
  struct Bitmap *Bitmap;  /* [64] Bitmap */
  WORD   Switch;          /* [68] Set to switch the buffers */

  /* Private fields */

  WORD   prv;                  /* */
  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! */
  struct ScreenPrefs *Prefs;   /* 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 */
  struct Control *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) */
  BYTE   *prvBitplanes1;       /* Ptr to copper bitplane loaders #1 */
  BYTE   *prvBitplanes2;       /* Ptr to copper bitplane loaders #2 */
  BYTE   *prvBitplanes3;       /* Ptr to copper bitplane loaders #3 */
  LONG   prvColListJmp;        /* Offset to RasterList */
  LONG   prvBmpXOffset;        /* X offset for scrolling */
  LONG   prvBmpYOffset;        /* 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 */
  APTR   prvCopperMem;         /* Pointer to original screen mem start */
  struct Bitmap *prvBitmap;    /* Allocated bitmap */
  WORD   prvBlitXOffset;       /* Offset to use for blitting (hard-scroll) */
  LONG   *prvPalette;          /* Allocated palette */
};

/* 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 */
#define BLANKPALETTE 0x00000400   /* For a blank (black) palette */

/* 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_INext      (24|TAPTR)
#define GSA_Palette    (28|TAPTR)
#define GSA_Raster     (32|TAPTR)
#define GSA_Width      (40|TWORD)
#define GSA_Height     (42|TWORD)
#define GSA_XOffset    (44|TWORD)
#define GSA_YOffset    (46|TWORD)
#define GSA_BmpXOffset (48|TWORD)
#define GSA_BmpYOffset (50|TWORD)
#define GSA_ScrMode    (52|TWORD)
#define GSA_Attrib     (56|TLONG)

#define GSA_BitmapTags (64|TSTEPIN)

/****************************************************************************
** Raster object.
*/

#define RASVERSION 1

struct Raster {
  struct Head Head;        /* Standard header */
  struct RHead   *Command; /* Pointer to the first command */
  struct GScreen *Screen;  /* Pointer to our Screen owner */
  LONG   Flags;            /* Special flags */

  /*** Private fields ***/

  APTR   prvRasterMem;
};

#define RSF_DISPLAYED 0x00000001   /* If the raster is currently on display */

/****************************************************************************
** Rasterlist command header format.
*/

struct RStats {
  LONG  CopSize;
  UWORD *CopPos;
};

struct RHead {
  WORD ID;
  WORD Version;
  struct RStats *Stats;
  struct RHead *Prev;
  struct RHead *Next;
};

/****************************************************************************
** These are the raster command structures.
*/

#define ID_RASTWAIT       1
#define ID_RASTFLOOD      2
#define ID_RASTCOLOUR     3
#define ID_RASTCOLOURLIST 4
#define ID_RASTMIRROR     5

#define ID_RASTEND        6

struct RWait {
  struct RHead Head;
  WORD Line;
};

struct RFlood {
  struct RHead Head;
};

struct RColour {
  struct RHead Head;
  LONG Colour;
  LONG Value;
};

struct RColourList {
  struct RHead Head;
  WORD YCoord;
  WORD Skip;
  LONG Colour;
  LONG *Values;
};

#endif /* GRAPHICS_SCREENS_H */
