/*
		MAND.H -- The Constants and Definitions
		Mandelbrot Self-Squared Dragon Generator
			For the Commodore Amiga
			    Version 2.05

			  Accompanies MAND.C

		Copyright (c) 1985, Robert S. French
		    Placed in the Public Domain

		Vastly Enhanced by =RJ Mical=  1985
	Further Feached and even considerably optimized by >>SDB<< 1986

This program may be distributed free of charge as long as the above
notice is retained.

*/


/*-------------------*/
/* Lots of includes! */

#include <exec/types.h>
#include <exec/tasks.h>
#include <exec/libraries.h>
#include <exec/devices.h>
#include <devices/keymap.h>
#include <graphics/copper.h>
#include <graphics/display.h>
#include <graphics/gfxbase.h>
#include <graphics/text.h>
#include <graphics/view.h>
#include <graphics/gels.h>
#include <graphics/regions.h>
#include <hardware/blit.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <ctype.h>
#include <stdio.h>
#include <clib/macros.h>
#include <libraries/dos.h>
#include <workbench/workbench.h>

/* ================== */
/* A redefinition...  */
#undef TRUE
#undef FALSE
#define TRUE			1
#define FALSE			0
/* Works better this way... */

/*-------------------*/
/* Misc. definitions */
#define VERSION			"2.05"

#define F_INTUITION		0x000001
#define F_GRAPHICS		0x000002
#define F_CONSOLE		0x000010
#define F_COLORTAB		0x000020
#define F_ICON			0x000080


#define EVER			;;
#define MAXX			640
#define MAXY			400
#define PROCESS_STACKSIZE	6000


/* === these definitions are for the color_mode variable ================= */
#define NOT_HOLDANDMODIFY	0x0001
#define INTERLACE_MODE		0x0002
#define HIRES_MODE		0x0004
/* This is for a mode not all Amiga's have. So sue me, I put it in anyway. */
#define HALFBRITE_MODE		0x0008

/* === these definitions are for the menu strips ========================= */
#define ITEM_HEIGHT		10
#define MENU_PROJECT		0	/* first menu */
#define MENU_OPTIONS		1	/* next menu */
#define MENU_ZOOM		2	/* next menu */
#define MENU_COUNT		3

/* for the PROJECT Menu ... */
#define PROJECT_WIDTH		176
#define PROJECT_SAVEPICTURE	0
#define PROJECT_READPICTURE	1
#define PROJECT_PRINTPICTURE	2
#define PROJECT_COUNT		3

/* for the OPTIONS Menu ... */
#define OPTIONS_WIDTH		176
#define OPTIONS_LEFT		(-24)
#define OPTIONS_QUARTER		0
#define OPTIONS_FULL		1
#define OPTIONS_GENERATE	2
#define OPTIONS_RESUME		3
#define OPTIONS_COLORS		4
#define OPTIONS_STOP		5
#define OPTIONS_CLOSE		6
#define OPTIONS_COUNT		7

/* for the ZOOM Menu ... */
#define ZOOM_WIDTH		222
#define ZOOM_LEFT		(-60)
#define ZOOM_SETCENTER		0
#define ZOOM_SIZEBOX		1
#define ZOOM_SIZEPROP		2
#define ZOOM_ZOOMIN		3
#define ZOOM_ZOOMIN10		4
#define ZOOM_ZOOMOUT2		5
#define ZOOM_ZOOMOUT10		6
#define ZOOM_COUNT		7


/* === the definitions for the ColorWindow =============================== */
#define COLOR_KNOB_BODY		0x1111

#define COLORWINDOW_WIDTH	208
#define COLORWINDOW_HEIGHT	91

#define DEFAULT_WINDOW_LEFT	(320 - COLORWINDOW_WIDTH)
#define DEFAULT_WINDOW_TOP	(200 - COLORWINDOW_HEIGHT)

#define CHARACTER_WIDTH		8
#define CHARACTER_HEIGHT	8

#define COLOR_BOX_LEFT		7
#define COLOR_BOX_TOP		6
#define COLOR_BOX_RIGHT		(COLOR_BOX_LEFT + 15)
#define COLOR_BOX_BOTTOM	(COLOR_BOX_TOP + 29)
#define COLOR_COLOR_TOP		45
#define COLOR_PROP_LEFT		38
#define COLOR_PROP_TOP		4
#define COLOR_PROP_WIDTH	165
#define COLOR_PROP_HEIGHT	10
#define COLOR_CLUSTER_LEFT	141
#define COLOR_CLUSTER_TOP	41
#define COLOR_CLUSTER_WIDTH	(CHARACTER_WIDTH * 6 + 4)
#define COLOR_CLUSTER_HEIGHT	9
#define COLOR_HSL_TOP		(COLOR_BOX_TOP - 2)
#define COLOR_HSL_LEFT		(COLOR_BOX_RIGHT + 3)

/* GREEN and RED are out of order.  Do you wonder why?  Some day I'll 
 * tell you.  =RJ=
 */
#define COLOR_COPY		32
#define COLOR_RANGE		33
#define COLOR_OK		34
#define COLOR_CANCEL		35
#define COLOR_GREEN		36
#define COLOR_RED		37
#define COLOR_BLUE		38
#define COLOR_HSL_RGB		39
#define COLOR_GADGETS_COUNT	40



/* === Our Definitions for the IFF Format ================================ */

struct	BitMapHeader
{
	USHORT	w;
	USHORT	h;
	SHORT	x, y;
	UBYTE	nPlanes, masking, compression, pad1;
	USHORT	TransparentColor;
	UBYTE	xAspect, yAspect;
	SHORT	PageWidth, PageHeight;
};

struct	PaintingHeader
{
	LONG	IFFID, FileLength, ILBMID, BMHDID, BitMapSize;
	struct	BitMapHeader BitMapHeader;
	LONG	CMAPID, CMAPlength;
};

/* Structure used to resume after a picture save/load or STOP */
/* This is stored as the last chunk of the IFF file */

struct MandelInfo {
	FLOAT	mi_start_r, mi_end_r, mi_start_i, mi_end_i;
	SHORT	mi_max_x, mi_max_y;
	SHORT	mi_max_count, mi_color_inc, mi_color_offset;
	SHORT	mi_color_set, mi_color_mode, mi_color_div;
	SHORT	mi_color_inset, mi_func_num;
	SHORT	mi_starty;
};

/* Macros for access to PaintingHeader fields */
/* All these macros require a local or global
 * struct PaintingHeader PaintingHeader to be declared */


#define IFF_ID		PaintingHeader.IFFID
#define ILBM_ID		PaintingHeader.ILBMID
#define BMHD_ID		PaintingHeader.BMHDID
#define CMAP_ID		PaintingHeader.CMAPID
#define CMAP_LENGTH	PaintingHeader.CMAPlength
#define FILE_LENGTH	PaintingHeader.FileLength

#define BM_W		PaintingHeader.BitMapHeader.w
#define BM_H		PaintingHeader.BitMapHeader.h
#define BM_X		PaintingHeader.BitMapHeader.x
#define BM_Y		PaintingHeader.BitMapHeader.y
#define N_PLANES	PaintingHeader.BitMapHeader.nPlanes
#define COMPRESSION	PaintingHeader.BitMapHeader.compression
#define X_ASPECT	PaintingHeader.BitMapHeader.xAspect
#define Y_ASPECT	PaintingHeader.BitMapHeader.yAspect
#define PAGE_WIDTH	PaintingHeader.BitMapHeader.PageWidth
#define PAGE_HEIGHT	PaintingHeader.BitMapHeader.PageHeight

/* Macros for an Amiga struct BitMap */
/* These require a local struct BitMap *bitmap to be declared */

#define BPR		bitmap->BytesPerRow
#define ROWS		bitmap->Rows
#define DEPTH		bitmap->Depth
#define Plane( i )	bitmap->Planes[ (i) ]

/* IFF id's */

#define FORM			('FORM')
#define ILBM                    ('ILBM')
#define BMHD                    ('BMHD')
#define BODY                    ('BODY')
#define CMAP                    ('CMAP')
#define CAMG                    ('CAMG')

/* Our own ID, for the special information needed by Mandelbrot */

#define MNDL			('MNDL')

/* IFF Aspect definitions - not used by us, but maybe by other folks, so
 * we have to set them.
 */

#define X320x200	10
#define Y320x200	11
#define X320x400	20
#define Y320x400	11
#define X640x200	5
#define Y640x200	11
#define X640x400	10
#define Y640x400	11

/*===Function Definitions =================================================*/

extern struct Window		*OpenWindow();
extern struct Screen		*OpenScreen();
extern struct Library		*OpenLibrary();
extern struct IntuiMessage	*GetMsg();
extern LONG			GetRGB4();
extern LONG			PutDiskObject();
extern LONG			Open();
extern LONG			Write();
extern LONG			IoErr();
extern LONG			Read();
extern LONG			Seek();
