
#ifdef __cplusplus
extern "C" {
#endif
// Compatibility layer with allegro

#include <SDL.h>

typedef struct BITMAP            /* a bitmap structure */
{
   int w, h;                     /* width and height in pixels */
   int clip;                     /* flag if clipping is turned on */
   int cl, cr, ct, cb;           /* clip left, right, top and bottom values */
   void *vtable;           /* drawing functions */
   void *write_bank;             /* C func on some machines, asm on i386 */
   void *read_bank;              /* C func on some machines, asm on i386 */
   void *dat;                    /* the memory we allocated for the bitmap */
   unsigned long id;             /* for identifying sub-bitmaps */
   void *extra;                  /* points to a structure with more info */
   int x_ofs;                    /* horizontal offset (for sub-bitmaps) */
   int y_ofs;                    /* vertical offset (for sub-bitmaps) */
   int seg;                      /* bitmap segment */
   Uint8 **line;
} BITMAP;

typedef struct {
  void *dat;
  int size;
} DATAFILE;

#ifdef __GLIBC__
#if __GLIBC__ >= 2
#define stricmp strcasecmp
#endif
#endif

typedef SDL_Color* PALETTE;
typedef long fixed; // What an idea !
#define RGB SDL_Color

extern Uint8 key[0x100];
// A few scan codes directly used (berk !)
#define KEY_F7 SDLK_F7
#define KEY_F8 SDLK_F8
#define KEY_J  SDLK_j
#define KEY_K  SDLK_k
#define KEY_I  SDLK_i
#define KEY_O  SDLK_o

extern int wants_switch_res;

void sdl_init();
void sdl_done();

void setup_gfx_modes();

// Bitmap functions
BITMAP *sdl_create_bitmap_ex(int bpp, int w, int h);
#define sdl_create_bitmap(w, h) sdl_create_bitmap_ex(display_cfg.bpp,w,h)
struct BITMAP *surface_to_bmp(SDL_Surface *s);

void destroy_bitmap(struct BITMAP *bmp);
// clear is normally useless... Hope so at least (if called after creation)
#define clear(x)
#define allegro_message logerror

// Mouse... Very different now... Just declare the vars, and see later...
extern int mouse_x,mouse_y,mouse_b;
void set_mouse_range(int x1, int y1, int x2, int y2); // does nothing !

// Strings
#ifndef strlwr
#define strlwr(s) while(s) if (*s>='A' && *s<='Z') *s+=32;
#endif
void put_backslash(char *s);
char *get_filename(char *f);

// Joystick
void init_joys(); // Does nothing for now

// GUI
void StartGUI(); // Does nothing

// Files
int exists(char *filename);

// Misc
int  save_pcx(const char *filename, BITMAP *bmp, const RGB
	      *pal);

#ifdef __cplusplus
}
#endif
