/******* MAGELORE - defines and Structure definitions *******/

#define nil 0L
#define BUTTON_PRESSED 232
#define NOT_ENOUGH_MEMORY -1000
#define MOUSE_BUTTON (BYTE *)0xbfe001L
#define PRESSED 64

#define TIMER_SIZE 4096
#define MAP_SIZE 65536
#define OBJECT_SIZE 32768
#define CREATURE_SIZE 40960
#define LAND_SIZE 0x1600

#define MAX_CHOICES 200
#define MAX_GMEMBER 50
#define TEXT_LENGTH 126
#define TEXT_HEIGHT 15
#define TEXT_TX 184
#define TEXT_TY 20
#define TEXT_BX 308
#define TEXT_BY 134
#define CHAR_X 16
#define CHAR_Y 195

#define KEY_LEFT 0x4f
#define KEY_RIGHT 0x4e
#define KEY_UP 0x4c
#define KEY_DOWN 0x4d
#define KEY_QUIT 0x45
#define DELETE_KEY 0x46
#define RETURN_KEY 0x44
#define BACKSPACE_KEY 0x41
#define NOKEY 0x7f

#define BKSP 2
#define TAB 3
#define ESC 1
#define DEL 4
#define CRSu 5
#define CRSd 6
#define CRSr 7
#define CRSl 8
#define CRT 9
#define Fn01 10
#define Fn02 11
#define Fn03 12
#define Fn04 13
#define Fn05 14
#define Fn06 15
#define Fn07 16
#define Fn08 17
#define Fn09 18
#define Fn10 19

struct Land {
	BYTE Name[10];
	WORD Pict[4];
	UBYTE Height;
	UBYTE Destroy;
	UWORD LFlags;
};

/* LFlags : macros for accessing flags */

#define LFmove(a) (land[a].LFlags&3)
#define LFsee(a) (land[a].LFlags&4)
#define LFdest(a) (land[a].LFlags&8)
#define LFpois(a) (land[a].LFlags&16)
#define LFsleep(a) (land[a].LFlags&32)
#define LFtype(a) ((land[a].LFlags>>6)&3)
#define LFfire(a) ((land[a].LFlags>>8)&3)
#define LFcolor(a) ((land[a].LFlags>>10)&15)

struct Inv_Item {
	UBYTE Item;
	UBYTE Special;
	UWORD Type;
};

struct People {
	UBYTE Type;				/* People Type */
	UBYTE Xpos, Ypos;		/* Map Position */
	UBYTE Alignment;		/* Good, Evil, Neutral, Illusion */
	UBYTE MType;			/* Movement Type */
	UBYTE Perception;		/* for finding you and disbelieve illusions*/
	UBYTE Strength;			/* normal - for missile damage */
							/* illusion - for discovery    */
	UBYTE Pic[4];			/* Animation Pictures */
	struct People *Next;	/* Next in list */
};

/* Alignment types */

#define P_ILLUSION 0	/* does not really exist */
#define P_EVIL 1		/* attacks - doesn't talk */
#define P_NEUTRAL 2		/* doesn't attack or talk */
#define P_GOOD 3		/* talks - doesn't attack */
#define P_DYING 4		/* will be deleted next move */

/* Movement types */

#define MV_RANDOM 0
#define MV_FOLLOW 1
#define MV_EVADE 2
#define MV_STILL 3
#define MV_FOLLOW_X 4
#define MV_FOLLOW_Y 5

struct Spell {
	UBYTE Spell;	/* spell number (from spell table) */
	UBYTE Casts;	/* number of casts still to go; 0=infinite */
	UWORD Level;	/* affects if spell works and spells power */

	struct Spell *Next;
};

/* Spell Type in spell table:
		- cast always
		- x times and then forget completely (memorise or mix)
		- x times and recharge at midnight */

struct Skill {
	UBYTE Skill;	/* skill number (from skill table) 		*/
	UBYTE Uses;     /* how many times the skill can be used */
	UWORD Level;	/* how well the skill is known			*/

	struct Skill *Next;
};

struct Person {
	BYTE Name[14];
	UBYTE Sex;		/* 0=Male, 1=Female, 2=Neuter */
	UBYTE Race;
	UBYTE Class;		/* Class can be: Monster or Illusion */
	UBYTE Level;
	ULONG Experience;
	ULONG BLANK;
	UBYTE Stats[8][2];	/* Str,Dex,Int,Wis,Chr,Luc,Stl,Per */
	UBYTE Attack;
	UBYTE Defence;
	UWORD Max_HP;
	UWORD Hit_Pts;
	UWORD Max_MP;
	UWORD Mag_Pts;
	ULONG Gold;
	struct Inv_Item Inv[10];
	UBYTE Condition;
	UBYTE Map;
	UBYTE x;
	UBYTE y;
	UBYTE Reagents[10];		/* how many of each reagent is owned */
	struct Skill *Skills;
	struct Spell *Spells;
};

/* for: Condition */

#define GOOD 0x0
#define HUNGRY 0x1
#define POISONED 0x2
#define WITHERED 0x4
#define ILL 0x8
#define MAD 0x10
#define SLEEPING 0x20
#define DEAD 0x40

/* Stats numbers */

#define CURR 0
#define MAX 1
#define STR 0
#define DEX 1
#define INT 2
#define WIS 3
#define CHR 4
#define LUC 5
#define STL 6
#define PER 7

/* for: Type */

#define CREATED 0
#define PREDEFINED 1


struct GuildFile {
	BYTE Name[14];
	UBYTE Map;
	UBYTE x;
	UBYTE y;
	UBYTE Class;
	UBYTE Type;
	UBYTE Condition;
};

struct MemoryPool {
	BYTE *Where;
	LONG Size;
};

#define MAX_MEMORYS 32

/* Non-Structure related definitions */

#define In_Domain(a,b,c) (((a)>=(b))&&((a)<=(c)))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define Draw_Curr() rasinfo.BitMap = rastport.BitMap = &bitmap[curr_scr]
#define Draw_Old() rasinfo.BitMap = rastport.BitMap = &bitmap[old_scr]

#define PIC_BIG 0
#define PIC_SMALL 1

#define FADE_ALL 0
#define FADE_SMALL 1
#define FADE_BIG 2
#define FADE_IN 1
#define FADE_OUT -1

#define BM_COPY 0xcc
