#ifndef GFXLCD_H
#define GFXLCD_H

#define  COPY_PUT          0
#define  XOR_PUT           1
#define  OR_PUT            2
#define  AND_PUT           3
#define  NOT_PUT           4

#define  EMPTY_FILL        0
#define  SOLID_FILL        1
#define  LINE_FILL         2
#define  LTSLASH_FILL      3
#define  SLASH_FILL        4
#define  BKSLASH_FILL      5
#define  LTBKSLASH_FILL    6
#define  HATCH_FILL        7
#define  XHATCH_FILL       8
#define  INTERLEAVE_FILL   9
#define  WIDE_DOT_FILL    10
#define  CLOSE_DOT_FILL   11
#define  USER_FILL        12


typedef struct {
  unsigned  width;
  unsigned  height;
  char      bmBits[]; 
} Bitmap;


typedef struct {
  unsigned fontsize;      /// size of the font in bytes
  int      numchars;      /// total number of characters
  int      offset;        /// ascii offset for first character
  Bitmap  *bitmaps[256];  /// pointers into bmbits array
  char     bmbits[];      /// all bitmaps, concatenated
} BitmapFont;


typedef struct {
   int pattern;
   int color;
} fillsettingstype;


extern  void      initgraph();
extern  void      closegraph();

extern  void      graphdefaults();
extern  void      cleardevice();
extern  void      clearviewport();
extern  void      setbkcolor(char color);
extern  void      setcolor(char color);

extern  void      setfillpattern(char *upattern, char color);
extern  void      setfillstyle(int pattern, char color);
extern  void      getfillpattern(char *pattern);
extern  void      getfillsettings(fillsettingstype *fillinfo);

extern  int       getbkcolor();
extern  int       getcolor();
extern  int       getmaxx();
extern  int       getmaxy();
extern  int       getx();
extern  int       gety();
extern  char      getpixel(int x, int y);
extern  void      putpixel(int x, int y, char color);
extern  unsigned  imagesize(int left, int top, int right, int bottom);
extern  void      getimage(int left, int top, int right, int bottom, Bitmap *bitmap);
extern  void      putimage(int left, int top, Bitmap *bitmap, int op);
extern  void      bar(int left, int top, int right, int bottom);
extern  void      circle(int xc, int yc, int r);
extern  void      line(int x1, int y1, int x2, int y2);
extern  void      linerel(int dx, int dy);
extern  void      lineto(int x, int y);
extern  void      moverel(int dx, int dy);
extern  void      moveto(int x, int y);
extern  void      rectangle(int left, int top, int right, int bottom);

extern  BitmapFont *loadfont(char *filename);
extern  void        freefont(BitmapFont *font);
extern  void        setfont(const BitmapFont *font);
extern  const BitmapFont   *getfont();
extern  int         textwidth(const char *textstring);
extern  int         textheight(const char *textstring);
extern  void        outtext(const char *textstring);
extern  void        outtextxy(int x, int y, const char *textstring);
extern  int         gprintf(const char *format, ...);

#endif