
#ifndef __SY2TYPES__
#define __SY2TYPES__

#ifndef __STRING__
#include <string.h>
#endif

/// TOPPE COMPILATORE DA TOGLIERE !!!!
#ifdef SYD_WIN
#define	ASSUREVOLATILE static
#else
#define	ASSUREVOLATILE static
#endif

#define kSy2VariableLengthArray	1

#ifdef SYD_WIN
/*** UNREFERENCED_PARAMETER gia' definita in wnnt.h ***/
#endif

#ifdef SYD_MAC
# ifdef SYD_MPW
#  ifdef SYD_PPC
#   define UNREFERENCED_PARAMETER(P)	(P) = (P)
#   define DBG_UNREFERENCED_PARAMETER(P)	(P) = (P)
#  else
#   define UNREFERENCED_PARAMETER(P)	(P) = (P)
#   define DBG_UNREFERENCED_PARAMETER(P)	(P) = (P)
#  endif
# else
#  define UNREFERENCED_PARAMETER(P)	(P) = (P)
#  define DBG_UNREFERENCED_PARAMETER(P)	(P) = (P)
# endif
#endif

//MixedMode
#ifdef SYD_MAC
#ifdef SYD_PPC
#define	MMRoutineAddress(p)	&mmrd ## p
#define	MakeMMRoutineAddress(p, type) static RoutineDescriptor mmrd ## p = BUILD_ROUTINE_DESCRIPTOR(type, p)
#define	MakeLocalMMRoutineAddress(p, type) RoutineDescriptor mmrd ## p = BUILD_ROUTINE_DESCRIPTOR(type, p)
#define	MakeRunTimeMMRoutineAddress(p, type) RoutineDescriptor mmrtrd ## p = BUILD_ROUTINE_DESCRIPTOR(type, nil)
#define	SetRunTimeMMRoutineAddress(p, value, codetype) mmrtrd ## p.routineRecords[0].procDescriptor = (ProcPtr)(value);\
						mmrtrd ## p.routineRecords[0].ISA = (codetype)
#define	RunTimeMMRoutineAddress(p)	&mmrtrd ## p
#else
#define	MMRoutineAddress(p)	p
#define	MakeMMRoutineAddress(p, type)
#define	MakeLocalMMRoutineAddress(p, type)
#define	MakeRunTimeMMRoutineAddress(p, type) static ProcPtr mmrtrd ## p = nil
#define	SetRunTimeMMRoutineAddress(p, value, codetype) mmrtrd ## p = (ProcPtr)(value)
#define	RunTimeMMRoutineAddress(p)	mmrtrd ## p
#endif
#endif

#ifdef SYD_OSX
#define	MMRoutineAddress(p)	mmrd ## p
#endif

#ifdef SYD_WIN
#define	MMRoutineAddress(p)	p
#define	MakeMMRoutineAddress(p, type)
#define	MakeLocalMMRoutineAddress(p, type)
#define	MakeRunTimeMMRoutineAddress(p, type) static ProcPtr mmrtrd ## p = nil
#define	SetRunTimeMMRoutineAddress(p, value, codetype) mmrtrd ## p = (ProcPtr)(value)
#define	RunTimeMMRoutineAddress(p)	mmrtrd ## p
#endif

typedef char Sy2BYTE;
typedef unsigned char Sy2UBYTE;
typedef short Sy2WORD;
typedef unsigned short Sy2UWORD;
typedef long Sy2DWORD;
typedef unsigned long Sy2UDWORD;
typedef unsigned char Bin6[6];
typedef unsigned char Bin8[8];
typedef Sy2UBYTE *Sy2Bin, *Sy2Fixed;
typedef Sy2UBYTE Fix6[6];
typedef Sy2UBYTE Fix8[8];
typedef long Sy2Size;

#define	Sy2Byte		Sy2BYTE
#define	Sy2UByte	Sy2UBYTE
#define	Sy2Word		Sy2WORD
#define	Sy2UWord	Sy2UWORD
#define	Sy2DWord	Sy2DWORD
#define	Sy2UDWord	Sy2UDWORD

// questo deve garantire che contiene un long e un void * !!
typedef	long	Sy2LParam;


//#define	Sy2Copy(dst, src, len)	memmove(dst, src, len)
//#define	Sy2Move(dst, src, len)	memmove(dst, src, len)
//#define	Sy2CopyData(dst, src, len)	memmove(dst, src, len)
//#define	Sy2MoveData(dst, src, len)	memmove(dst, src, len)
//#define	Sy2Set(dst, val, len)	memset(dst, val, len)
//#define	Sy2Cmp(dst, src, len)	memcmp(dst, src, len)
#ifdef	SYD_WIN
#define	Sy2Copy(dst, src, len)	CopyMemory(dst, src, len)
#define	Sy2Move(dst, src, len)	MoveMemory(dst, src, len)
#define	Sy2CopyData(dst, src, len)	CopyMemory(dst, src, len)
#define	Sy2MoveData(dst, src, len)	MoveMemory(dst, src, len)
#define	Sy2Set(dst, val, len)	FillMemory(dst, len, val)
#define	Sy2Cmp(dst, src, len)	memcmp(dst, src, len)
#define	Sy2ZeroData(dst, len)	ZeroMemory(dst, len)
#endif

#ifdef	SYD_MAC
#define	Sy2Copy(dst, src, len)	BlockMove(src, dst, len)
#define	Sy2Move(dst, src, len)	BlockMove(src, dst, len)
#define	Sy2CopyData(dst, src, len)	BlockMoveData(src, dst, len)
#define	Sy2MoveData(dst, src, len)	BlockMoveData(src, dst, len)
#define	Sy2Set(dst, val, len)	memset(dst, val, len)
#define	Sy2Cmp(dst, src, len)	memcmp(dst, src, len)
#define	Sy2ZeroData(dst, len)	memset(dst, 0, len)
#endif

#ifdef	SYD_OSX
//#define	Sy2Copy(dst, src, len)	memcpy(dst, src, len)
#define	Sy2Copy(dst, src, len)	memmove(dst, src, len)
#define	Sy2Move(dst, src, len)	memmove(dst, src, len)
//#define	Sy2CopyData(dst, src, len)	memcpy(dst, src, len)
#define	Sy2CopyData(dst, src, len)	memmove(dst, src, len)
#define	Sy2MoveData(dst, src, len)	memmove(dst, src, len)
#define	Sy2Set(dst, val, len)	memset(dst, val, len)
#define	Sy2Cmp(dst, src, len)	memcmp(dst, src, len)
#define	Sy2ZeroData(dst, len)	memset(dst, 0, len)
#endif

#define	Sy2ZeroStruct(sp)	Sy2ZeroData(&sp, sizeof((sp)))
#define	Sy2ZeroStructInd(sp)	Sy2ZeroData(sp, sizeof(*(sp)))


#ifdef	SYD_WIN
#define	Sy2Debug(s)	DebugBreak()
#endif

#ifdef	SYD_MAC
#define	Sy2Debug(s)	DebugStr(s)
#endif

#ifdef	SYD_OSX
#define	Sy2Debug(s)	DebugStr(s)
#endif

#ifdef SYD_WIN

// quello che su mac  short! che stress!
//typedef	int	STRESSINT;

#ifndef _WINDOWS_
#include	<windows.h>
#endif

#define	SYD_APPWCLASS "SydneAppWClass"
#define	SYD_CLIWCLASS "MDICLIENT"
#define	SYD_STDWCLASS "SydneStdWClass"
#define	SYD_PALWCLASS "SydnePalWClass"

typedef unsigned char Sy2MacStr255[256];
typedef unsigned char *Sy2MacStringPtr;
typedef Sy2MacStringPtr *Sy2MacStringHandle;
typedef const unsigned char *Sy2MacConstStr255Param;
typedef const unsigned char *Sy2MacConstStr63Param;
typedef const unsigned char *Sy2MacConstStr32Param;
typedef const unsigned char *Sy2MacConstStr31Param;
typedef const unsigned char *Sy2MacConstStr27Param;
typedef const unsigned char *Sy2MacConstStr15Param;

typedef unsigned char Sy2MacBoolean;
typedef UINT Sy2MacSize;
typedef	HLOCAL Sy2MacHandle;
typedef	signed char * Sy2MacPtr;
typedef long Sy2MacOSType;
typedef float Sy2MacFixed;
typedef long Sy2MacFixedEmul;
#define	Sy2MacLong2Fix(a)	((float)(a))
#define	Sy2MacFixRatio(a, b)	((float)(a) / (float)(b))
#define	Sy2MacFixDiv(a, b)	((float)(a) / (float)(b))
#define	Sy2MacFixMul(a, b)	((float)(a) * (float)(b))
#define Sy2MacFixRound(a)	((int)(a))
#define	NUMBER_ONE	(1.0)

typedef struct Sy2MacRect {short top; short left; short bottom; short right;} Sy2MacRect;
typedef struct Sy2MacPoint {short v; short h;} Sy2MacPoint;
typedef WORD Sy2MacPattern[8];

typedef struct Sy2MacRGBColor {
	unsigned short red;						/*magnitude of red component*/
	unsigned short green;						/*magnitude of green component*/
	unsigned short blue;						/*magnitude of blue component*/
} Sy2MacRGBColor;
typedef unsigned char Sy2MacStyle;
typedef Sy2MacStyle Sy2MacStyleField;
typedef struct Sy2MacScrpSTElement {
	long scrpStartChar;				/*starting character position*/
	short scrpHeight;
	short scrpAscent;
	short scrpFont;
	Sy2MacStyleField scrpFace;					/*unpacked byte*/
	short scrpSize;
	Sy2MacRGBColor scrpColor;
} Sy2MacScrpSTElement;
/* ARRAY [0..1600] OF ScrpSTElement */
typedef Sy2MacScrpSTElement Sy2MacScrpSTTable[1601];
typedef struct Sy2MacStScrpRec {
	short				scrpNStyles;				/*number of styles in scrap*/
	Sy2MacScrpSTTable 	scrpStyleTab;				/*table of styles for scrap*/
} Sy2MacStScrpRec;
typedef Sy2MacStScrpRec *Sy2MacStScrpPtr;
typedef Sy2MacStScrpPtr *Sy2MacStScrpHandle;
typedef struct Sy2MacTextRange {
	long fStart;
	long fEnd;
	short fHiliteStyle;
} Sy2MacTextRange;
typedef Sy2MacTextRange *Sy2MacTextRangePtr;
typedef Sy2MacTextRangePtr *Sy2MacTextRangeHandle;
typedef struct Sy2MacTextRangeArray {
	short 				fNumOfRanges;				/* specify the size of the fRange array */
	Sy2MacTextRange 	fRange[1];					/* when fNumOfRanges > 1, the size of this array has to be calculated */
} Sy2MacTextRangeArray;
typedef Sy2MacTextRangeArray *Sy2MacTextRangeArrayPtr;
typedef Sy2MacTextRangeArrayPtr *Sy2MacTextRangeArrayHandle;

typedef long (*Sy2MacProcPtr)();
typedef Sy2MacProcPtr Sy2MacUniversalProcPtr;

#define	Sy2PascalCallBackType
#define	Sy2MacDragReference void *
typedef WORD Sy2MacDragTrackingMessage;
#define	Sy2MacItemReference ULONG
typedef short Sy2MacJustStyleCode;
typedef signed char	Sy2MacStyledLineBreakCode;
typedef struct Sy2MacOffPair {
	WORD	offFirst;
	WORD	offSecond;
} Sy2MacOffPair;
typedef Sy2MacOffPair Sy2MacOffsetTable[3];
typedef WORD Sy2MacScriptCode;
typedef Sy2UDWord Sy2MacFourCharCode;
typedef Sy2UDWord Sy2MacResType;
typedef struct OpaqueTSMDocumentID* Sy2MacTSMDocumentID;

enum {	// font faces, or styles
    Sy2Macnormal = 0,
    Sy2Macbold = 1,
    Sy2Macitalic = 2,
    Sy2Macunderline = 4,
    Sy2Macoutline = 8,
    Sy2Macshadow = 0x10,
    Sy2Maccondense = 0x20,
    Sy2Macextend = 0x40
};

#define InitStaticPattern(a, b, c, d, e, f, g, h) {(a) ^ 0xff, (b) ^ 0xff, (c) ^ 0xff, (d) ^ 0xff, (e) ^ 0xff, (f) ^ 0xff, (g) ^ 0xff, (h) ^ 0xff}
#define SetPatternEntry(nome, index, value) ((WORD *)&(nome))[index] = ((value) ^ 0xff)
#define GetPatternEntry(nome, index) (nome[index] ^ 0xff)


typedef struct WinMessage {
	UINT message;
	UINT wPar;
	long lPar;
	int	 exit;
	int  result;
} WinMessage;

struct StdPens {
	HPEN black;
	HPEN dkGray;
	HPEN gray;
	HPEN ltGray;
	HPEN white;
};

typedef	HRGN Sy2RgnHandle;
typedef HBITMAP Sy2PicHandle;
typedef	COLORREF Sy2WinRGB;
typedef	struct Sy2MacRGB {unsigned short red; unsigned short blue; unsigned short green;} Sy2MacRGB;
typedef LOGPALETTE Sy2ColorTable;
typedef HPALETTE Sy2ColorTableHandle;
typedef	struct Sy2PixMap {
	BITMAPINFOHEADER bmih;
	int mode;
	int flags;
	Sy2UWord bytesPerRow;
	Sy2UWord numcolors;	// entries in color table
	RECT bounds;
	BITMAPINFO *colorInfo;
	void *baseAddr;
	HPALETTE hPal;
	HBITMAP hbm;
	Sy2UDWord sizecolors;
	Sy2UDWord sizebits;
} Sy2PixMap;

typedef struct Sy2OffScreenData {
    HDC hdcMem;
    HBITMAP hbmMem, hbmOld;
    HBRUSH hbrBkGnd;
    HFONT hfntOld;
} Sy2OffScreenData;

/**********************************
typedef	struct Sy2IconDesc {
	HICON hicon;
	int side;
	int flags;
} Sy2IconDesc, **Sy2IconHandle;
***********************************/

typedef	HICON Sy2IconHandle;

typedef struct Sy2ColorDesc { COLORREF color;} Sy2ColorDesc;
typedef struct Sy2PortSave {HWND op; HDC odc; int wassaved;} Sy2PortSave;
typedef struct Sy2FontSave {HFONT hf;} Sy2FontSave;
typedef struct Sy2PenSave {HPEN hp; HBRUSH hb; COLORREF bgcol; HBITMAP bm; int mode;/*HPEN op; HBRUSH ob;*/} Sy2PenSave;
typedef struct Sy2FontSpec {Sy2FontSave fsav; HFONT newf;} Sy2FontSpec;
typedef struct Sy2PenSpec {Sy2PenSave op; Sy2PenSave ps;} Sy2PenSpec;

#define	SY2SETCOLORDESC(cd, r, g, b) ((cd).color = (r >> 8) | (g & 0x0000ff00) | ((b << 8) & 0x00ff0000))
//#define	SY2INITCOLORDESC(r, g, b) {(r) >> 8, (g) >> 8, (b) >> 8}
#define	SY2INITCOLORDESC(r, g, b) {(r >> 8) | (g & 0x0000ff00) | ((b << 8) & 0x00ff0000)}
#define	SY2GET_RED_COMP(cd) (((cd).color & 0x00ff0000) >> 8)
#define	SY2GET_GREEN_COMP(cd) ((cd).color & 0x0000ff00)
#define	SY2GET_BLUE_COMP(cd) (((cd).color & 0x000000ff) << 8)

typedef struct Sy2DrawPrepEnv {
	Sy2RgnHandle rgnh;
	int type;
	POINT org;
	POINT brushorg;
} Sy2DrawPrepEnv;


#define	WINRGBCOLOR(scd)	(scd).color

#define	POINT_H(pt)	((pt).x)
#define	POINT_V(pt)	((pt).y)

enum {
	SY2_KEY_DELETE	=	VK_BACK,
	SY2_KEY_TAB		=	VK_TAB,
	SY2_KEY_ESC		=	VK_ESCAPE,
	//SY2_KEY_LEFT	=	VK_LEFT,
	//SY2_KEY_RIGHT	=	VK_RIGHT,
	//SY2_KEY_UP		=	VK_UP,
	//SY2_KEY_DOWN	=	VK_DOWN,
	SY2_KEY_LEFT	=	0x1c,
	SY2_KEY_RIGHT	=	0x1d,
	SY2_KEY_UP		=	0x1e,
	SY2_KEY_DOWN	=	0x1f,
	SY2_KEY_RETURN	=	VK_RETURN,
	SY2_KEY_ENTER	=	VK_RETURN,
	SY2_MOD_SHIFT	=	0x01,
	SY2_MOD_CMD		=	0x02,
	SY2_MOD_OPT		=	0x04,
	SY2_MOD_CTL		=	0x08,
	SY2_MOD_ALOCK	=	0x10,
	SY2_MOD_RSHIFT	=	0x20,
	SY2_MOD_ROPT	=	0x40,
	SY2_MOD_RCTL	=	0x80,

// For special business!
	SY2_MOD_DCLICK	=	0x8000,
	SY2_MOD_USER1	=	0x4000,
	SY2_MOD_USER2	=	0x2000,
	SY2_MOD_USER3	=	0x1000
};


#endif	/* SYD_WIN */

#ifdef SYD_MAC

#define Sy2MacStr255	Str255
#define	Sy2MacStringPtr	StringPtr
#define	Sy2MacStringHandle	StringHandle
#define	Sy2MacConstStr255Param	ConstStr255Param
#define	Sy2MacConstStr63Param	ConstStr63Param
#define	Sy2MacConstStr32Param	ConstStr32Param
#define	Sy2MacConstStr31Param	ConstStr31Param
#define	Sy2MacConstStr27Param	ConstStr27Param
#define	Sy2MacConstStr15Param	ConstStr15Param

#define Sy2MacBoolean	Boolean
#define Sy2MacSize Size
#define Sy2MacHandle Handle
#define Sy2MacPtr Ptr
#define Sy2MacOSType OSType
#define Sy2MacFixed Fixed
#define Sy2MacFixedEmul Fixed
#define	Sy2MacLong2Fix(a)	Long2Fix(a)
#define	Sy2MacFixRatio(a, b)	FixRatio(a, b)
#define	Sy2MacFixDiv(a, b)	FixDiv(a, b)
#define	Sy2MacFixMul(a, b)	FixMul(a, b)
#define Sy2MacFixRound(a)	FixRound(a)

#define Sy2MacRect Rect
#define Sy2MacPoint Point
#define Sy2MacPattern	Pattern

#define Sy2MacRGBColor	RGBColor
#define Sy2MacStyle	Style
#define Sy2MacStyleField	StyleField
#define	Sy2MacScrpSTElement ScrpSTElement
#define	Sy2MacScrpSTTable	ScrpSTTable
#define	Sy2MacStScrpRec	StScrpRec
#define	Sy2MacStScrpPtr StScrpPtr
#define	Sy2MacStScrpHandle	StScrpHandle
#define Sy2MacTextRange MacTextRange
#define Sy2MacTextRangePtr	TextRangePtr
#define Sy2MacTextRangeHandle	TextRangeHandle
#define Sy2MacTextRangeArray TextRangeArray
#define Sy2MacTextRangeArrayPtr	TextRangeArrayPtr
#define Sy2MacTextRangeArrayHandle	TextRangeArrayHandle

#define	Sy2MacProcPtr ProcPtr
#define	Sy2MacUniversalProcPtr UniversalProcPtr

#define	Sy2PascalCallBackType pascal
#define	Sy2MacDragReference DragReference
#define Sy2MacDragTrackingMessage DragTrackingMessage
#define	Sy2MacItemReference ItemReference
#define	Sy2MacJustStyleCode	JustStyleCode
#define	Sy2MacStyledLineBreakCode	StyledLineBreakCode
#define	Sy2MacOffPair	OffPair
#define	Sy2MacOffsetTable	OffsetTable
#define	Sy2MacScriptCode	ScriptCode
#define	Sy2MacFourCharCode FourCharCode
#define	Sy2MacResType	ResType
#define	Sy2MacTSMDocumentID TSMDocumentID

#define Sy2Macnormal	normal
#define Sy2Macbold		bold
#define Sy2Macitalic	italic
#define Sy2Macunderline	underline
#define Sy2Macoutline	outline
#define Sy2Macshadow	shadow
#define Sy2Maccondense	condense
#define Sy2Macextend	extend

#define UNREFERENCED_PARAMETER(P)	(P) = (P)


#define InitStaticPattern(a, b, c, d, e, f, g, h) {a, b, c, d, e, f, g, h}
#define SetPatternEntry(nome, index, value) ((unsigned char *)&(nome))[index] = (value)
#define GetPatternEntry(nome, index) (nome[index])
// quello che su win  int! che stress!
//typedef	short STRESSINT;

#ifndef __TYPES__
#include	<Types.h>
#endif

#ifndef __QUICKDRAW__
#include	<QuickDraw.h>
#endif

typedef	RgnHandle HRGN;
typedef struct GrafPort *HWND;
typedef struct MenuInfo **HMENU;
typedef void *HDC;
typedef void *HFONT;
typedef void *HPEN;
typedef void *HBRUSH;
typedef void *HBITMAP;
/*typedef void *HICON;*/
typedef struct {short cicn; Handle h;} *HICON;
typedef unsigned int UINT;
typedef long LONG;
typedef	Boolean BOOL;
/*typedef	void *HANDLE;*/
typedef	Sy2MacHandle HANDLE;
typedef struct Point POINT;
typedef struct Rect RECT;
typedef UINT WPARAM;
typedef LONG LPARAM;

#define	APIENTRY


typedef	RgnHandle Sy2RgnHandle;
typedef PicHandle Sy2PicHandle;
typedef struct Sy2ColorDesc { RGBColor color;} Sy2ColorDesc;
typedef struct Sy2PortSave {HWND op; int wassaved;} Sy2PortSave;
struct MacFontSpec {short a[4];};
typedef struct Sy2FontSave {struct MacFontSpec mof;} Sy2FontSave;
typedef struct Sy2PenSave {struct PenState pstate; RGBColor fgc; RGBColor bgc;} Sy2PenSave;
typedef struct Sy2FontSpec {Sy2FontSave fsav;} Sy2FontSpec;
typedef struct Sy2PenSpec {Sy2PenSave op;} Sy2PenSpec;

#define	SY2SETCOLORDESC(cd, r, g, b) ((cd).color.red = r, (cd).color.green = g, (cd).color.blue = b)
#define	SY2INITCOLORDESC(r, g, b) {r, g, b}
#define	SY2GET_RED_COMP(cd) ((cd).color.red)
#define	SY2GET_GREEN_COMP(cd) ((cd).color.green)
#define	SY2GET_BLUE_COMP(cd) ((cd).color.blue)

typedef struct Sy2DrawPrepEnv {
	Sy2RgnHandle rgnh;
	POINT org;
} Sy2DrawPrepEnv;


#define	MACRGBCOLOR(scd)	(scd).color

typedef	long Sy2WinRGB;
typedef	RGBColor Sy2MacRGB;
typedef struct ColorTable Sy2ColorTable;
typedef struct ColorTable **Sy2ColorTableHandle;
typedef	struct Sy2PixMap {
	PixMap map;
	int bytesPerRow;
	int mode;
	int flags;
} Sy2PixMap;

typedef struct Sy2OffScreenData {
	CGrafPtr pport;			// Returns a pointer to the new CGrafPort
	GDHandle pgdevice;		// Returns a handle to the new GDevice
} Sy2OffScreenData;

typedef Handle Sy2IconHandle;

#define	POINT_H(pt)	((pt).h)
#define	POINT_V(pt)	((pt).v)

enum {
	SY2_KEY_DELETE	=	0x08,
	SY2_KEY_TAB		=	0x09,
	SY2_KEY_ESC		=	0x1b,
	SY2_KEY_LEFT	=	0x1c,
	SY2_KEY_RIGHT	=	0x1d,
	SY2_KEY_UP		=	0x1e,
	SY2_KEY_DOWN	=	0x1f,
	SY2_KEY_RETURN	=	0x0d,
	SY2_KEY_ENTER	=	0x03,
/*****
	SY2_MOD_SHIFT	=	512,
	SY2_MOD_CMD		=	256,
	SY2_MOD_OPT		=	2048,
	SY2_MOD_CTL		=	4096,
	SY2_MOD_ALOCK	=	1024,
	SY2_MOD_RSHIFT	=	8192,
	SY2_MOD_ROPT	=	16384,
	SY2_MOD_RCTL	=	32768
*****/
	// oo famo strano ?
	SY2_MOD_SHIFT	=	0x01,
	SY2_MOD_CMD		=	0x02,
	SY2_MOD_OPT		=	0x04,
	SY2_MOD_CTL		=	0x08,
	SY2_MOD_ALOCK	=	0x10,
	SY2_MOD_RSHIFT	=	0x20,
	SY2_MOD_ROPT	=	0x40,
	SY2_MOD_RCTL	=	0x80,

// For special business!
	SY2_MOD_DCLICK	=	0x8000,
	SY2_MOD_USER1	=	0x4000,
	SY2_MOD_USER2	=	0x2000,
	SY2_MOD_USER3	=	0x1000
};

#endif	/* SYD_MAC */


#ifdef SYD_OSX

#define Sy2MacStr255	Str255
#define	Sy2MacStringPtr	StringPtr
#define	Sy2MacStringHandle	StringHandle
#define	Sy2MacConstStr255Param	ConstStr255Param
#define	Sy2MacConstStr63Param	ConstStr63Param
#define	Sy2MacConstStr32Param	ConstStr32Param
#define	Sy2MacConstStr31Param	ConstStr31Param
#define	Sy2MacConstStr27Param	ConstStr27Param
#define	Sy2MacConstStr15Param	ConstStr15Param

#define Sy2MacBoolean	Boolean
#define Sy2MacSize Size
#define Sy2MacHandle Handle
#define Sy2MacPtr Ptr
#define Sy2MacOSType OSType
#define Sy2MacFixed Fixed
#define Sy2MacFixedEmul Fixed
#define	Sy2MacLong2Fix(a)	Long2Fix(a)
#define	Sy2MacFixRatio(a, b)	FixRatio(a, b)
#define	Sy2MacFixDiv(a, b)	FixDiv(a, b)
#define	Sy2MacFixMul(a, b)	FixMul(a, b)
#define Sy2MacFixRound(a)	FixRound(a)

#define Sy2MacRect Rect
#define Sy2MacPoint Point
#define Sy2MacPattern	Pattern

#define Sy2MacRGBColor	RGBColor
#define Sy2MacStyle	Style
#define Sy2MacStyleField	StyleField
#define	Sy2MacScrpSTElement ScrpSTElement
#define	Sy2MacScrpSTTable	ScrpSTTable
#define	Sy2MacStScrpRec	StScrpRec
#define	Sy2MacStScrpPtr StScrpPtr
#define	Sy2MacStScrpHandle	StScrpHandle
#define Sy2MacTextRange MacTextRange
#define Sy2MacTextRangePtr	TextRangePtr
#define Sy2MacTextRangeHandle	TextRangeHandle
#define Sy2MacTextRangeArray TextRangeArray
#define Sy2MacTextRangeArrayPtr	TextRangeArrayPtr
#define Sy2MacTextRangeArrayHandle	TextRangeArrayHandle

#define	Sy2MacProcPtr ProcPtr
#define	Sy2MacUniversalProcPtr UniversalProcPtr

#define	Sy2PascalCallBackType pascal
#define	Sy2MacDragReference DragReference
#define Sy2MacDragTrackingMessage DragTrackingMessage
#define	Sy2MacItemReference ItemReference
#define	Sy2MacJustStyleCode	JustStyleCode
#define	Sy2MacStyledLineBreakCode	StyledLineBreakCode
#define	Sy2MacOffPair	OffPair
#define	Sy2MacOffsetTable	OffsetTable
#define	Sy2MacScriptCode	ScriptCode
#define	Sy2MacFourCharCode FourCharCode
#define	Sy2MacResType	ResType
#define	Sy2MacTSMDocumentID TSMDocumentID

#define Sy2Macnormal	normal
#define Sy2Macbold		bold
#define Sy2Macitalic	italic
#define Sy2Macunderline	underline
#define Sy2Macoutline	outline
#define Sy2Macshadow	shadow
#define Sy2Maccondense	condense
#define Sy2Macextend	extend

#define UNREFERENCED_PARAMETER(P)	(P) = (P)


#define InitStaticPattern(a, b, c, d, e, f, g, h) {a, b, c, d, e, f, g, h}
#define SetPatternEntry(nome, index, value) ((unsigned char *)&(nome))[index] = (value)
#define GetPatternEntry(nome, index) (nome[index])
// quello che su win  int! che stress!
//typedef	short STRESSINT;


typedef	RgnHandle HRGN;
//typedef GrafPtr HWND;
typedef WindowPtr HWND;
typedef struct MenuInfo **HMENU;
typedef void *HDC;
typedef void *HFONT;
typedef void *HPEN;
typedef void *HBRUSH;
typedef void *HBITMAP;
/*typedef void *HICON;*/
typedef struct {short cicn; Handle h;} *HICON;
typedef unsigned int UINT;
typedef long LONG;
typedef	Boolean BOOL;
/*typedef	void *HANDLE;*/
typedef	Sy2MacHandle HANDLE;
typedef struct Point POINT;
typedef struct Rect RECT;
typedef UINT WPARAM;
typedef LONG LPARAM;

#define	APIENTRY


typedef	RgnHandle Sy2RgnHandle;
typedef PicHandle Sy2PicHandle;
typedef struct Sy2ColorDesc { RGBColor color;} Sy2ColorDesc;
typedef struct Sy2PortSave {GrafPtr op; int wassaved;} Sy2PortSave;
struct MacFontSpec {
	short font;
	Style face;
	short mode;
	short size;
};
typedef struct Sy2FontSave {struct MacFontSpec mof;} Sy2FontSave;
typedef struct Sy2PenSave {struct PenState pstate; RGBColor fgc; RGBColor bgc;} Sy2PenSave;
typedef struct Sy2FontSpec {Sy2FontSave fsav;} Sy2FontSpec;
typedef struct Sy2PenSpec {Sy2PenSave op;} Sy2PenSpec;

#define	SY2SETCOLORDESC(cd, r, g, b) ((cd).color.red = r, (cd).color.green = g, (cd).color.blue = b)
#define	SY2INITCOLORDESC(r, g, b) {r, g, b}
#define	SY2GET_RED_COMP(cd) ((cd).color.red)
#define	SY2GET_GREEN_COMP(cd) ((cd).color.green)
#define	SY2GET_BLUE_COMP(cd) ((cd).color.blue)

typedef struct Sy2DrawPrepEnv {
	Sy2RgnHandle rgnh;
	POINT org;
} Sy2DrawPrepEnv;


#define	MACRGBCOLOR(scd)	(scd).color

typedef	long Sy2WinRGB;
typedef	RGBColor Sy2MacRGB;
typedef struct ColorTable Sy2ColorTable;
typedef struct ColorTable **Sy2ColorTableHandle;
typedef	struct Sy2PixMap {
	PixMap map;
	int bytesPerRow;
	int mode;
	int flags;
} Sy2PixMap;

typedef struct Sy2OffScreenData {
	CGrafPtr pport;			// Returns a pointer to the new CGrafPort
	GDHandle pgdevice;		// Returns a handle to the new GDevice
} Sy2OffScreenData;

typedef Handle Sy2IconHandle;

#define	POINT_H(pt)	((pt).h)
#define	POINT_V(pt)	((pt).v)

enum {
	SY2_KEY_DELETE	=	0x08,
	SY2_KEY_TAB		=	0x09,
	SY2_KEY_ESC		=	0x1b,
	SY2_KEY_LEFT	=	0x1c,
	SY2_KEY_RIGHT	=	0x1d,
	SY2_KEY_UP		=	0x1e,
	SY2_KEY_DOWN	=	0x1f,
	SY2_KEY_RETURN	=	0x0d,
	SY2_KEY_ENTER	=	0x03,
/*****
	SY2_MOD_SHIFT	=	512,
	SY2_MOD_CMD		=	256,
	SY2_MOD_OPT		=	2048,
	SY2_MOD_CTL		=	4096,
	SY2_MOD_ALOCK	=	1024,
	SY2_MOD_RSHIFT	=	8192,
	SY2_MOD_ROPT	=	16384,
	SY2_MOD_RCTL	=	32768
*****/
	// oo famo strano ?
	SY2_MOD_SHIFT	=	0x01,
	SY2_MOD_CMD		=	0x02,
	SY2_MOD_OPT		=	0x04,
	SY2_MOD_CTL		=	0x08,
	SY2_MOD_ALOCK	=	0x10,
	SY2_MOD_RSHIFT	=	0x20,
	SY2_MOD_ROPT	=	0x40,
	SY2_MOD_RCTL	=	0x80,

// For special business!
	SY2_MOD_DCLICK	=	0x8000,
	SY2_MOD_USER1	=	0x4000,
	SY2_MOD_USER2	=	0x2000,
	SY2_MOD_USER3	=	0x1000
};

#endif	/* SYD_OSX */



typedef struct Sy2BitMap {
	Sy2UDWord	bmType;
	Sy2UDWord	bmWidth;
	Sy2UDWord	bmHeight;
	Sy2UDWord	bmWidthBytes;
	Sy2UDWord	bmPlanes;
	Sy2UDWord	bmBitsPixel;
	Sy2UDWord	bmSizeImage;
	Sy2UDWord	bmNumColors;
	Sy2UDWord	bmSizeColors;
	Sy2UDWord	bmCompression;
	Sy2UDWord	bmXPelsPerMeter;
	Sy2UDWord	bmYPelsPerMeter;
	Sy2UDWord	bmClrUsed;
	Sy2UDWord	bmClrImportant;
	Sy2UByte	bmfree[32];
	Sy2UDWord	bmBitsLen;	// total size of bits that follow...
} Sy2BitMap;
#define	SY2BITMAPQUALIFIER	0

#define	SY2_MODIFIERS	(SY2_MOD_SHIFT + SY2_MOD_CMD + SY2_MOD_OPT + SY2_MOD_CTL)

//event masks
enum {
	SY2_CLICK_MESSAGES	=	1,
	SY2_KEY_MESSAGES		=	2,
	SY2_UPDATE_MESSAGES	=	4,
	SY2_ACTIVATE_MESSAGES	=	8,
	SY2_NO_IDLES		=	0x4000000,
	SY2_ALL_MESSAGES		=	0
};

#define	SY2_INPUT_MESSAGES	(SY2_CLICK_MESSAGES | SY2_KEY_MESSAGES)

typedef struct Sy2EnvSave {Sy2PortSave opo; Sy2PenSave ops; Sy2FontSave ofn;} Sy2EnvSave;

typedef void (*voidProcPtr)(void);

typedef struct Sy2EventData {
	long	when;
	POINT	where;
	short	modifiers;
	POINT	altwhere;
} Sy2EventData;
#define	Sy2EventWhere(p)	(((Sy2EventData *)(p))->where)
#define	Sy2EventModifiers(p)	(((Sy2EventData *)(p))->modifiers)

typedef struct Sy2FontDesc {
	unsigned char font;
	unsigned char face;
	short size;
	int color;
} Sy2FontDesc;


#define SetSy2FontDesc(fdp, fo, fa, si, co) (fdp).font = fo, (fdp).face = fa, (fdp).size = si, (fdp).color = co

typedef struct Sy2FontInfo {
	long ascent;
	long descent;
	long widmax;
	long leading;
	long height;
} Sy2FontInfo;

typedef struct Sy2PenDesc {
	short penSize;
    short penMode;
    long penPatp;
	Sy2ColorDesc penColor;
} Sy2PenDesc;


typedef	struct Sy2SaveLook {
	Sy2FontSave fsav;
	Sy2ColorDesc color;
	Sy2ColorDesc bkcolor;
} Sy2SaveLook;

typedef	struct Sy2TextLook {
	Sy2FontDesc fdesc;
	Sy2ColorDesc color;
	Sy2ColorDesc bkcolor;
	HFONT hf;
} Sy2TextLook;

#ifndef	true
#define	true	1
#endif

#ifndef	false
#define	false	0
#endif

#ifndef	word
typedef	short word;
#endif

#ifndef	dword
typedef	long dword;
#endif

#ifndef nil
#define	nil	(0)
#endif

// Usually useful macros
#define membersize(type,memb) (sizeof(((type *)0)->memb))
#define	Sy2IsPowerOf2(x)	(x == ((-(x)) & (x)))

#define Sy2CopyField(add_dest, type_dest, name_dest, add_src, type_src, name_src) \
			membersize(type_dest, name_dest) > membersize(type_src, name_src) ? \
			Sy2MoveData(((type_dest *)add_dest)->name_dest, ((type_src *)add_src)->name_src, membersize(type_src, name_src)) : \
			Sy2MoveData(((type_dest *)add_dest)->name_dest, ((type_src *)add_src)->name_src, membersize(type_dest, name_dest))
enum {
	TYSTR		=	0,
	TYBIN		=	3,
	TYDAT		=	5,
	TYTIM		=	7,
	TYASCIICOD	=	8,
	TYCOD		=	9,
	TYFIX		=	11,
	TY_UNSIGNED_FLAG	=	0x0080,
	TY_CARD_FLAG		=	0x8000,
	TY_NEWSTYLE_FLAG	=	0x4000,
	TY_USABLE_MASK		=	0x3fff
};
#define SYD_TYPE_BINARY_MASK	(1L)

enum {
	SY2_FMT_RJ			=	1,
	SY2_FMT_CJ			=	2,
	SY2_FMT_DOTS		=	4,
	SY2_FMT_SEPARATOR	=	4,
	SY2_FMT_SPECIAL		=	4,
	SY2_FMT_DECODE		=	4,
	SY2_FMT_RAG			=	8,
	SY2_FMT_SECONDS		=	8,
	SY2_FMT_YEAR		=	8,
	SY2_FMT_WIDE		=	16,
	SY2_FMT_ZEROES		=	32,
	SY2_FMT_ALTERNATE	=	64,
	SY2_FMT_NOBLZ		=	128
};

#define	SY2_FMT_FORMAT_MASK	0x03

//#define SYD_TYPE(len,type,lobit)	(((long)((type) | (lobit)) << 16L) | (long)(len))
//#define SYD_TYPE_BINARY_MASK	(1L << 16L)
//#define SYD_LEN(sydtype)	((int)((sydtype) & 0xffff))
//#define SYD_DATATYPE(sydtype)	((int)((sydtype) >> 16L))

#define	SYD_DSP_LEN_MASK	(0x000000ff)
#define	SYD_DSP_FMT_MASK	(0xfc)			// questa e quella sotto insieme fanno un byte
#define	SYD_DSP_FMT_JUST_MASK	(0x03)
#define	SYD_DSP_EXTRA_MASK	(0xffff0000)
#define	SYD_DSP_FMT_SHIFT	(8)
#define	SYD_DSP_EXTRA_SHIFT	(16)

#define SYD_DSP_LEN(appear)	((int)((appear) & 0xff))
#define SYD_DSP_FMT(appear)	((int)(((appear) >> 8L) & 0xff))
#define SYD_DSP_EXTRA(appear)	((int)((appear) >> 16L))
#define	SYD_DISPLAY(extra, opt, len) ((extra << 16L) + (opt << 8L) + len)
#define	SYD_SET_DSP_LEN(appear, len) ((appear) &= (~0x00ff), (appear) |= ((len) & 0x00ff))
#define	SYD_SET_DSP_FMT_JUST(appear, just) ((appear) &= (~(SYD_DSP_FMT_JUST_MASK << 8L)), (appear) |= (((just) & SYD_DSP_FMT_JUST_MASK) << 8L))
#define	SYD_SET_DSP_FMT(appear, fmt) ((appear) &= (~(SYD_DSP_FMT_MASK << 8L)), (appear) |= (((fmt) & SYD_DSP_FMT_MASK) << 8L))
#define	SYD_SET_DSP_EXTRA(appear, extra) ((appear) &= 0x0000ffff, (appear) |= ((extra) << 16L))

#define SYD_FILL_DATAPOINTER(p, a, b, c, d)	(p)->ptr = a; (p)->len = b; (p)->type = c; (p)->variant = d

typedef struct Sy2DataPointer {
	void *ptr;
	long len;
	short type;
	short variant;
} Sy2DataPointer;

typedef struct Sy2DataItem {
	long name;
	unsigned short xtype;
	unsigned short len;
	unsigned short dof;
	unsigned short extra;
} Sy2DataItem;

typedef struct Sy2Image {
	unsigned short nit;
	unsigned short totl;
	Sy2DataItem *syp;
	char *dp;
	//void *desc;
} Sy2Image;

// Descrizione estesa dei field: se data & 0xff000000  == 0  l'indice di un vettore ( 1 based);
//    se == 0x80, i 3 byte bassi sono l'indice del field ( 1 based); se no  il nome del field
typedef struct Sy2ExtendedFieldSpec {
	long num;
	long data[8];
} Sy2ExtendedFieldSpec;

// Nuova versione, strutturata cos
//	Sy2XCard
//	Sy2XCardInfo
//	nItems * Sy2XCardItem
//	altro
//  ----------
//	Sy2XCard deve poter essere copiata e usata coerentemente; per
//	questo quando la XCard  caricata in memoria bisogna "attualizzare"
//	itemPtr, e inoltre Sy2XCardInfo deve essere prima del primo item (cio
//	in memoria deve rimanere attaccata agli item)

typedef struct Sy2XCardItem {
	long itemID;
	unsigned short itemType;
	unsigned long itemLen;	// of an element
	unsigned long itemDataOffset;
	unsigned long itemVector;
	//unsigned short extra;
} Sy2XCardItem;

typedef struct Sy2XCard {
	long id;
	unsigned long nItems;
	unsigned long totalDataLen;
	int flags;
	Sy2XCardItem *itemPtr;
	char *dataPtr;
} Sy2XCard;
//flags
enum {
	SY2XCARD_UNION	=	1
};


typedef struct Sy2XCardInfo {
	unsigned long cardStructLen;		// Lunghezza totale di questa struttura
	unsigned long cardDescOffset;		// nome della struttura e lunghezza;
	unsigned long cardDescLen;		// dopo questa ci sono tutte le altre;
	unsigned long idIndexOffset;
	unsigned long descIndexOffset;
	unsigned long descIndexLen;
	unsigned long displayIndexOffset;
	unsigned long displayIndexLen;
	unsigned long nSubcards;
	unsigned long subcardListOffset;
} Sy2XCardInfo;


typedef struct Sy2XCardNameIndexEntry {
	long nameoffset;
	long itemoffset;
	unsigned char len;
	unsigned char hash;
} Sy2XCardNameIndexEntry;

#define	SY2_IMAGE_HAS_DESC	((void *)(-1))
//#define	DATA_ITEM_ENTRY(name,len,type,offset) (name, (((type) << 16L) | (len)), offset)
//#define	STRUCT_DATA_ITEM_ENTRY(name,type,struct,field) (name, (((type) << 16L) | (membersize((struct),(field)))), (sizeof((struct),(field))))

typedef struct Sy2DisplayItem {
	long appear;
} Sy2DisplayItem;


typedef struct Sy2XCardDisplayEntry {
	long id;		// use as a key;
	Sy2DisplayItem dispitem;
} Sy2XCardDisplayEntry;

typedef int (*IMAGE_FILLER_PROC)(Sy2Image *, void *);

#define	STATIC_IMAGE_DATA (nome, totl) char nome[(totl)];
#define	IMAGE(name,nit,totl,syp,dp) Sy2Image name = {(nit),(totl),(syp),(dp)};

typedef struct Display {
	unsigned short nit;
	unsigned short totl;
	Sy2DisplayItem *dyp;
	char *dp;
} Display;

typedef	unsigned short Sy2Date;
typedef	unsigned long Sy2Time;

typedef struct Sy2DateAndTime {
	Sy2Date date;
	Sy2Time time;
} Sy2DateAndTime;
#define	FlipSy2Date(p) FlipWordInd((short *)&(p))
#define	FlipSy2Time(p) FlipDWordInd((long *)&(p))
#define	FlipSy2DateAndTime(p) FlipSy2Date((p).date),FlipSy2Time((p).time)


typedef struct SizeBounds {
	RECT min;
	RECT max;
} SizeBounds;

//Small Version
typedef struct Sy2SmVersion {
	Sy2UDWord versx;
} Sy2SmVersion;
#define	SY2_SMALLVERSION_ID	'smve'

// Ever useful parameter block
typedef struct StdParam {
	HWND wp;
	RECT r;
	int flags;
	Sy2LParam ref;
	Sy2TextLook tl;
	Sy2TextLook exlook;
} StdParam;

// MultiSource Data
// MultiSource Entry
typedef struct Sy2MSEntry {		// ends when dataAddress == nil
	void *dataAddress;
	Sy2UDWord dataLen;
} Sy2MSEntry;

typedef struct Sy2MSData {
	Sy2MSEntry entry[4];
} Sy2MSData;

// Standard cursor
typedef struct Sy2Cursor {
	char data[32];
	char mask[32];
	short xHotSpot;
	short yHotSpot;
} Sy2Cursor;


typedef struct Sy2ContestEnvironment {
	Sy2PortSave sp;
	Sy2DrawPrepEnv dpe;
	Sy2DrawPrepEnv newdpe;
} Sy2ContestEnvironment;

// Long awaited number to string general conversion path
typedef struct StdIndexToString {
	unsigned short command;
	unsigned short len;
	long index;
	void *string;
	void *ref;
	void *proc;
} StdIndexToString;

enum {
	SY2_STD_ITS_OPEN	=	1,
	SY2_STD_ITS_CLOSE	=	2,
	SY2_STD_ITS_GET		=	3
};


enum {
	SY2_PASCALSTRING = -1,
	SY2_CSTRING = -2
};

// should go over OSType and became unsigned long !
typedef long Sy2IDType;
#define Sy2MacFlavorType Sy2MacOSType

typedef struct Sy2DefaultFileExtEntry {
	Sy2IDType id;
	char *defext;
} Sy2DefaultFileExtEntry;

// per adesso
typedef HANDLE Sy2Handle;

#define	SY2_VOL_SEPARATOR			':'
#define	SY2_DIR_SEPARATOR			'\\'
#define	SY2_EXTENSION_CHAR			'.'
#define	SY2_VOL_SEPARATOR_STRING	":"
#define	SY2_DIR_SEPARATOR_STRING	"\\"
#define	SY2_EXTENSION_STRING		"."

#ifdef SYD_WIN
#	define	SY2_LOCAL_VOL_SEPARATOR			':'
#	define	SY2_LOCAL_DIR_SEPARATOR			'\\'
#	define	SY2_LOCAL_EXTENSION_CHAR		'.'
#	define	SY2_LOCAL_VOL_SEPARATOR_STRING	":"
#	define	SY2_LOCAL_DIR_SEPARATOR_STRING	"\\"
#	define	SY2_LOCAL_EXTENSION_STRING		"."
#endif

#ifdef SYD_MAC
#	define	SY2_LOCAL_VOL_SEPARATOR			':'
#	define	SY2_LOCAL_DIR_SEPARATOR			':'
#	define	SY2_LOCAL_EXTENSION_CHAR		'.'
#	define	SY2_LOCAL_VOL_SEPARATOR_STRING	":"
#	define	SY2_LOCAL_DIR_SEPARATOR_STRING	":"
#	define	SY2_LOCAL_EXTENSION_STRING		"."
#endif

#ifdef SYD_OSX
#	define	SY2_LOCAL_VOL_SEPARATOR			':'
#	define	SY2_LOCAL_DIR_SEPARATOR			':'
#	define	SY2_LOCAL_EXTENSION_CHAR		'.'
#	define	SY2_LOCAL_VOL_SEPARATOR_STRING	":"
#	define	SY2_LOCAL_DIR_SEPARATOR_STRING	":"
#	define	SY2_LOCAL_EXTENSION_STRING		"."
#endif

#define	SY2_MAX_EXTENSION	8	// punto escluso, zero escluso

// Machine Type
#define	SY2_MT_OS_MASK	0x000000ff
#define	SY2_MT_PC_MASK	0x0000ff00
#define	SY2_MT_MACOS	0x01
#define	SY2_MT_WINDOWS	0x02
#define	SY2_MT_OSX		0x04
#define	SY2_MT_68K		0x0100
#define	SY2_MT_PPC		0x0200
#define	SY2_MT_X86		0x0400

#ifdef SYD_WIN
#	define	SY2_SYSTEM_ENVIRONMENT	(SY2_MT_X86 | SY2_MT_WINDOWS)
#endif	/* SYD_WIN */

#ifdef SYD_MAC
#	ifdef	SYD_PPC
#		define	SY2_SYSTEM_ENVIRONMENT	(SY2_MT_PPC | SY2_MT_MACOS)
#	else
#		define	SY2_SYSTEM_ENVIRONMENT	(SY2_MT_68K | SY2_MT_MACOS)
#	endif
#endif	/* SYD_MAC */

#ifdef SYD_OSX
#		define	SY2_SYSTEM_ENVIRONMENT	(SY2_MT_PPC | SY2_MT_OSX)
#endif	/* SYD_OSX */

#define	SY2_MAC_OS	((SY2_SYSTEM_ENVIRONMENT & SY2_MT_OS_MASK) == SY2_MT_MACOS)
#define	SY2_WIN_OS	((SY2_SYSTEM_ENVIRONMENT & SY2_MT_OS_MASK) == SY2_MT_WINDOWS)
#define	SY2_OSX_OS	((SY2_SYSTEM_ENVIRONMENT & SY2_MT_OS_MASK) == SY2_MT_OSX)

// A Mac-Only utility
#ifdef SYD_WIN
#	define	Sy2UseA5
#	define	Sy2OpenA5(x)
#	define	Sy2CloseA5()
#	define	Sy2GetA5()	0
#endif	/* SYD_WIN */

#ifdef SYD_OSX
#	define	Sy2UseA5
#	define	Sy2OpenA5(x)
#	define	Sy2CloseA5()
#	define	Sy2GetA5()	0
#endif	/* SYD_OSX */


#ifdef SYD_MAC
# ifdef	SYD_PPC
#	define	Sy2UseA5
#	define	Sy2OpenA5(x)
#	define	Sy2CloseA5()
#	define	Sy2GetA5()	0
#	define	Sy2MacCompletionProc(name, type, par)	void name(type * par)
#	define	Sy2MacCompletionProcProto(name, type)	void name(type *)
#	define	Sy2MacCompletionEnd()
/****
#	define	Sy2MacA1BasedCompletionProc(name, type, par)	void name(type * par)
#	define	Sy2MacA1BasedCompletionProcProto(name, type)	void name(type *)
****/
#	define	Sy2MacA1BasedCompletionProc(name, type, par)	void name(type par)
#	define	Sy2MacA1BasedCompletionProcProto(name, type)	void name(type)
#	define	Sy2MacA1BasedCompletionEnd()
# else
#	define	Sy2UseA5	long rega5
#	define	Sy2OpenA5(x)	rega5 = SetA5(x)
#	define	Sy2CloseA5()	SetA5(rega5)
#	pragma parameter __D0 Sy2GetA5()
	extern long Sy2GetA5(void) ONEWORDINLINE(0x200d);
#	pragma parameter __D0 Sy2GetA1()
	extern long Sy2GetA1(void) ONEWORDINLINE(0x2009);
#	pragma parameter __D0 Sy2GetA0()
	extern long Sy2GetA0(void) ONEWORDINLINE(0x2008);
	//extern void CN_raise_int_level(void) THREEWORDINLINE(0x40E7, 0x007C, 0x0700);
	//extern void CN_restore_int_level(void) ONEWORDINLINE(0x46DF);
	//for completion routines
#	define	Sy2MacCompletionProc(name, type, par)	void name(void) {type * par = (type *)Sy2GetA0();
#	define	Sy2MacCompletionProcProto(name, type)	void name(void)
#	define	Sy2MacCompletionEnd()	}
//#	define	Sy2MacA1BasedCompletionProc(name, type, par)	void name(void) {type * par = (type *)Sy2GetA1();
#	define	Sy2MacA1BasedCompletionProc(name, type, par)	void name(void) {type par = (type)Sy2GetA1();
#	define	Sy2MacA1BasedCompletionProcProto(name, type)	void name(void)
#	define	Sy2MacA1BasedCompletionEnd()	}
# endif
#endif

#ifdef SYD_OSX
#	define	Sy2UseA5
#	define	Sy2OpenA5(x)
#	define	Sy2CloseA5()
#	define	Sy2GetA5()	0
#	define	Sy2MacCompletionProc(name, type, par)	void name(type * par)
#	define	Sy2MacCompletionProcProto(name, type)	void name(type *)
#	define	Sy2MacCompletionEnd()

#	define	Sy2MacA1BasedCompletionProc(name, type, par)	void name(type par)
#	define	Sy2MacA1BasedCompletionProcProto(name, type)	void name(type)
#	define	Sy2MacA1BasedCompletionEnd()
#endif

// Provvisori
#define	Sy2NewRectRgn(rp) WPU_NewRectRgn(rp)
#define	Sy2NewRgn() WPU_NewRectRgn(nil)
#define	Sy2DisposeRgn(rgh) WPU_DisposeRgn(rgh)
#define	Sy2RectRgn(rgh, rp) WPU_RectRgn(rgh, rp)
#define	Sy2DiffRgn(rgdest, rg1, rg2) WPU_DiffRgn(rg1, rg2, rgdest)
#define	Sy2UnionRgn(rgdest, rg1, rg2) WPU_UnionRgn(rg1, rg2, rgdest)
#define	Sy2SectRgn(rgdest, rg1, rg2) WPU_SectRgn(rg1, rg2, rgdest)
#define	Sy2XorRgn(rgdest, rg1, rg2) WPU_XorRgn(rg1, rg2, rgdest)
#define	Sy2CopyRgn(rgdest, rg1) WPU_CopyRgn(rg1, rgdest)
#define	Sy2RgnIsEmpty(rg) WPU_IsRgnEmpty(rg)
#define	Sy2SetRgnEmpty(rg) WPU_SetEmptyRgn(rg)
#define	Sy2OffsetRgn(rgn, dx, dy) WPU_OffsetRgn(rgn, dx, dy)
#define	Sy2InsettRgn(rgn, dx, dy) WPU_InsetRgn(rgn, dx, dy)
#define	Sy2OffsetRgnByPoint(rgn, pt) WPU_OffsetRgnByPoint(rgn, pt)
#define	Sy2OffsetRgnByPointNegative(rgn, pt) WPU_OffsetRgnByPointNegative(rgn, pt)
#define Sy2GetRgnBox(rgh, rp) WPU_GetRgnBox(rgh, rp)

#endif
