#ifndef BOMBER_H
#define BOMBER_H

#include "list.h"
#include <SDL.h>

typedef unsigned char uchar;
extern int xcolors[256];
#define NUMGFX 3
#define IXSIZE 640
#define IYSIZE 480

#define MYF1 0x180
#define MYF2 0x181
#define MYF3 0x182
#define MYF4 0x183
#define MYF5 0x184
#define MYF6 0x185
#define MYF7 0x186
#define MYF8 0x187
#define MYF9 0x188
#define MYF10 0x189
#define MYLEFT 0x190
#define MYRIGHT 0x191
#define MYUP 0x192
#define MYDOWN 0x193
#define MYPAGEUP 0x194
#define MYPAGEDOWN 0x195
#define MYHOME 0x196
#define MYEND 0x197
#define MYALTL 0x198
#define MYALTR 0x199

#define MYDELETE 0x7f

#define MYSHIFTED 0x40
#define MYALTED 0x200

typedef struct gfxset {
	uchar gs_colormap[768];
	uchar gs_inout[256];
	uchar* gs_pic;
	int gs_xsize;
	int gs_ysize;
} gfxset;

typedef struct figure {
	int xsize, ysize;
	int xdelta, ydelta;
	uchar* graphics;
} figure;

typedef struct solid {
	int xsize, ysize;
	uchar* graphics;
} solid;

typedef struct player {
	listhead list, list_all_players;
	int xpos, ypos;
	int flags;
	int abilities;
	int speed;
	int speedturtle_timeout;
	int bombsused;
	int bombsavailable;
	int flamelength;
	int* at;
	int figcount;
	int doing;
	int action;
	int color;
	int controller;
	int fixx, fixy;
	int kills, deaths;
	figure* figure;
} player;

#define FLG_CONTROL 1
#define FLG_DEAD 2


typedef struct sprite {
	int flags;
	int xpos, ypos;
	figure* fig;
} sprite;

typedef struct damage {
	int xpos, ypos;
	int xsize, ysize;
} damage;

typedef struct bomb {
	listhead list;
	int type;
	int xpos, ypos;
	int px, py;
	int power;
	int timer;
	int figcount;
	player* owner;
} bomb;


#define BOMB_OFF 0
#define BOMB_NORMAL 1
#define BOMB_CONTROLLED 2
#define BOMBLIFE 60
#define BOMB_CONTROLLED_LIFE 150
#define FLAMELIFE 15
#define DECAYLIFE 15

typedef struct flame {
	listhead list;
	int xpos, ypos;
	int px, py;
	int timer;
	int lurd;
	player* owner;
} flame;

#define FL_UP 2
#define FL_DOWN 8
#define FL_LEFT 1
#define FL_RIGHT 4

typedef struct brickdecay {
	listhead list;
	int xpos, ypos;
	int px, py;
	int timer;
} brickdecay;

typedef struct bonustile {
	listhead list;
	int xpos, ypos;
	int px, py;
	int type;
} bonustile;

typedef struct generic {
	listhead list;
	int xpos, ypos;
	int px, py;
	int timer;
	void (*process)(struct generic*);
	void (*draw)(struct generic*);
	void *ptr1, *ptr2;
	int data1, data2;
} generic;

enum tile_types {
	TILE_NONE = -1,
	TILE_DISEASE = 0,
	TILE_KICK = 1,
	TILE_FLAME = 2,
	TILE_PUNCH = 3,
	TILE_SKATES = 4,
	TILE_BOMB = 5,
	TILE_SPOOGE = 6,
	TILE_GOLDFLAME = 7,
	TILE_BAD_DISEASE = 8,
	TILE_TRIGGER = 9,
	TILE_RANDOM = 10,
	TILE_JELLY = 11,
	TILE_GRAB = 12,
	TILE_RANDOM2 = 13,
	TILE_TURTLE = 14
};


// #define ACT_INVALID 0x88
#define ACT_NONE 0
#define ACT_UP 1
#define ACT_DOWN 2
#define ACT_LEFT 3
#define ACT_RIGHT 4
#define ACT_ENTER 5
#define ACT_QUIT 6
#define ACT_MASK 0x1f
#define ACT_PRIMARY 0x40
#define ACT_SECONDARY 0x80


#define FIELD_EMPTY 0
#define FIELD_BORDER 1
#define FIELD_BOMB 2
#define FIELD_BRICK 3
#define FIELD_FLAME 4
#define FIELD_EXPLODING 5
#define FIELD_BONUS 6

#define CODE_CONT 0
#define CODE_QUIT 1
#define CODE_ALLDEAD 2


#define MAXTHINGS 500
#define MAXSETS 8
#define MAXSPRITES 256
#define MAXDAMAGES 512

extern volatile char exitflag;

extern uchar needwhole;
extern figure walking[MAXSETS][60];

#endif /* BOMBER_H */
