#define  False 0
#define  True  !(False)

// Handles so that C checks if I abuse them
typedef int t_TaskHandle;
typedef int t_WindowHandle;
typedef int t_IconHandle;

// Pointers so that C checks if I abuse them
// even if I did not yet define the structs to go with
typedef int t_SpriteArea;

//****************************************************************
// Polling

#define TASK 0x4B534154
#define PollMask_Standard 0x3831

#define ReasonCode_MouseClick 6
#define ReasonCode_UserMessage 17
#define ReasonCode_UserMessageRecorded 18

#define WindowBackground (t_WindowHandle)(-1)
#define WindowIconbar (t_WindowHandle)(-2)

#define UserMessage_Quit 0

#define MouseButtonRight  0x1
#define MouseButtonMiddle 0x2
#define MouseButtonLeft   0x4

// Wimp Poll Block as a buffer
typedef struct {
	char Data[256];
} t_Buffer256;

// Wimp Poll block for a user message
typedef struct {
	int MessageLength;
	int SenderHandle;
	int MyRef;
	int YourRef;
	int MessageCode;
	char MessageData[236];
} t_WimpUserMessage;

// Wimp Poll block for a mouse click
typedef struct {
	int MouseX, MouseY;
	int Buttons;
	t_WindowHandle Window;
	t_IconHandle Icon;
	char MessageData[236];
} t_WimpMouseClick;


// Wimp Poll Block with multiple formats
typedef union {
	t_Buffer256 Block;
	t_WimpUserMessage UserMessage;
	t_WimpMouseClick MouseClick;
} t_WimpPollBlock;

//****************************************************************
// Icons

// Icon data
typedef union {
	char IconText[12];
	struct {
		char *Text;
		char *Validation;
		int Length;
	}	IconTextIndirect;
	struct {
		char *Sprite;
		t_SpriteArea *Area;
		int Length;
	}	IconSpriteIndirect;
} t_IconData;

// Icon block
typedef struct {
	int MinX, MinY, MaxX, MaxY;
	int IconFlags;
	t_IconData IconData;
} t_IconBlock;

// Block for SWI Wimp_CreateIcon
typedef struct {
	t_WindowHandle Window;
	t_IconBlock Icon;
} t_WimpCreateIconBlock;

// Block for SWI Wimp_DeleteIcon
typedef struct {
	t_WindowHandle Window;
	t_IconHandle Icon;
} t_WimpDeleteIconBlock;

// Some useful constants
#define IconBarIconFlags 0x3102
#define IconBarIconLeft (t_WindowHandle)(-2)
#define IconBarIconRight (t_WindowHandle)(-1)
#define WimpSpriteArea (t_SpriteArea*)1

//****************************************************************
// Keys
#define KeyShift 0
#define KeyCtrl 1
#define KeyAlt 2
#define KeyOffsetLeft 3
#define KeyoffsetRight 6

