#ifndef GRAFFITI_INTERN_H
#define GRAFFITI_INTERN_H

#ifndef GRAFFITI_H
#   include "graffiti.h"
#endif

#define GH(gd)      ((struct GraffitiHandle *)gd)
#define GD(gd)      ((struct GraffitiData *)gd)

struct GraffitiData
{
    struct GraffitiHandle gh; /* Public part */

    struct Screen   * CommandScreen;	/* Commands are rendered here */
    struct UCopList * uCopListCommand;
    struct MsgPort  * SharedPort;
    struct Window   * CommandWindow;

    /* Display details */
    UWORD   Depth;	/* Depth of the display (1, 2 or 4) */
    UWORD   Width;	/* Width of one line in pixels. Used for clipping.
			    Valid coordinates are from 0 to width-1.
			    Possible values are 80-92, 160-184, 320-369 and
			    640-738 */
    UWORD   Height;	/* Height of the display like width. Possible
			    values are from 200-283 and 400-576 */
    UWORD   BPR;	/* Width of one line in bytes. This value is
			    related to Width, but may be different from it. */
    UBYTE * Plane[4];	/* Shortcuts to the displayed bitplanes. You should
			    use these pointers instead of the ones on
			    GraphicScreen->BitMap.Planes[]. Also note that
			    only Depth pointers in this array are valid. */

    UBYTE   cmd[320];	/* The Graffiti lib uses this array to collect
			    commands before it sends them as a bulk to the
			    card. */
    UBYTE * cmdptr;	/* Pointer into cmd[] */
    UBYTE   startcmd;	/* Command to send to the Graffiti to start the
			    display */

    UWORD ClipLeft;	/* Cliprect */
    UWORD ClipTop;
    UWORD ClipRight;
    UWORD ClipBottom;

    BOOL    colorcache; /* Cache for Graffiti_FindBestMatch() valid ? */
    UBYTE   lastcolor;	/* The last color index returned */
    UWORD   lastmatch;	/* How far was this color from that the user wanted ? */

    /* Fonts */
    struct List FontList;   /* List of all fonts. */
    struct GraffitiFont * CurrentFont; /* The font currently in use */

    /* Buffers */
    UWORD BufferMode;	    /* Single, Double, Triple, Multi */
    UWORD NBuffers;	    /* The number of buffers */
    UWORD VisibleBuffer;    /* Which buffer is visible ? */
    UWORD RenderBuffer;     /* In which buffer do we render ? */
    struct Screen * Buffer[3];
    struct Window * BufferWindow[3];
    struct UCopList * uCopListBuffer[3];
    struct List UsedBufferList; /* Here are buffers for recycle */
    struct List NewBufferList;	/* Here are buffers which must still be
				    displayed. */

    /* 3D */
    WORD * ZBuffer;
};

#endif /* GRAFFITI_INTERN_H */
