#ifndef DJGPP_H
#define DJGPP_H


#include <stdint.h>
#include <stdlib.h>


typedef uint32_t ColorT;

typedef struct SurfaceS {
	uint16_t width;
	uint16_t height;
	size_t   scanline;
	size_t   bytes;
	union {
		uint8_t  *bits8;
		uint16_t *bits16;
		uint32_t *bits32;
	} buffer;
} SurfaceT;

typedef struct EventS {
	int32_t flags;
	int32_t x;
	int32_t y;
	int32_t buttons;
	int32_t key;
	int32_t kbstat;
	int32_t dtime;
} EventT;


#define EVENT_FLAG_KEYPRESS      1
#define EVENT_FLAG_LEFT_DOWN     2
#define EVENT_FLAG_LEFT_UP       4
#define EVENT_FLAG_RIGHT_DOWN    8
#define EVENT_FLAG_RIGHT_UP      16

#define BUTTON_LEFT              1
#define BUTTON_RIGHT             2

#define META_ALT                 1
#define META_CTRL                2
#define META_SHIFT               4

#define KEY_ESC                  27


extern ColorT (*videoSurfacePixelGet)(SurfaceT *surface, int16_t x, int16_t y);
extern void   (*videoSurfacePixelSet)(uint16_t x, uint16_t y, ColorT color);


void      platformEventGet(EventT *event);
ColorT    videoColorMake(uint8_t red, uint8_t green, uint8_t blue);
uint16_t  videoDisplayHeightGet(void);
uint16_t  videoDisplayWidthGet(void);
void      videoSurfaceBlit(SurfaceT *target, int16_t targetX, int16_t targetY, SurfaceT *source);
void      videoSurfaceBlitWithTransparency(SurfaceT *target, int16_t targetX, int16_t targetY, SurfaceT *source, ColorT transparent);
void      videoSurfaceClear(ColorT color);
SurfaceT *videoSurfaceCreate(int16_t width, int16_t height);
void      videoSurfaceBox(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT c);
void      videoSurfaceBoxFilled(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT c);
void      videoSurfaceDestroy(SurfaceT *surface);
SurfaceT *videoSurfaceGet(void);
int16_t   videoSurfaceHeightGet(SurfaceT *surface);
void      videoSurfaceLineH(int16_t x1, int16_t y1, int16_t x, ColorT c);
void      videoSurfaceLineV(int16_t x, int16_t x2, int16_t y2, ColorT c);
void      videoSurfaceSet(SurfaceT *surface);
SurfaceT *videoSurfaceScreenGet(void);
int16_t   videoSurfaceWidthGet(SurfaceT *surface);


#endif // DJGPP_H
