/* Modified for ARexx-support by E. Schwan 23.1.2002 */
/* added ppc g3/g4/g5 support by D. Papararo 30.3.2002 */

#ifndef FLASHMANDEL_H
#define FLASHMANDEL_H

#include "compilerspecific.h"

#define Lib_Version 40L

typedef long double LDouble;

struct MandelChunk { LONG LeftEdge,TopEdge,Width,Height;
                     ULONG Iterations,Colors,Modulo,Flags,Power;
                     ULONG Reserved_Integer [5];
                     LDouble RMin,RMax,IMin,IMax;
                     LDouble JKre,JKim;
                     LDouble Reserved_Real [6];
                   };

/* prototypes */
UWORD  SetPubScreenName (TEXT *);
ULONG  CheckCPU         (ULONG CpuFlags);
void   FreeBitMapSafety (struct BitMap *);
void   PutPointer       (struct Window *,UWORD *,LONG,LONG,LONG,LONG,UBYTE);
void   ClipIt           (WORD,WORD,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,BOOL);
ULONG  ModeFallBack     (ULONG,WORD,WORD,WORD);
void   SystemInfo       (struct Window *Win);
LONG   About            (struct Window *);
LONG   Choice           (struct Window *,TEXT *,TEXT *);
LONG   CheckGFX         (void);
UBYTE  GetMaxPlanes     (ULONG);
void   AdjustRatio      (LDouble *,LDouble *,LDouble *,LDouble *,WORD,WORD,BOOL);
void   ShowTime         (struct Window *,TEXT *,ULONG);
ULONG  IntegerGad       (struct Window *,TEXT *,TEXT *,TEXT *,ULONG);
void   CloseDisplay     (struct ILBMInfo *,CPTR *);
LONG   MakeDisplay      (struct ILBMInfo *);
BOOL   NewCoords        (struct Window *,const WORD,const WORD,const WORD,const WORD);
BOOL   DrawFrame        (struct Window *,const WORD,const WORD,const WORD,const WORD);
ULONG  DrawFractal      (struct Window *,const WORD,const WORD,const WORD,const WORD, BOOL);
BOOL   Preview          (struct Window *,LONG,LONG);
BOOL   ShowCoords       (struct Window *);
void   RestoreCoords    (struct Window *);
void   SaveCoords       (struct Window *,BOOL);
BOOL   FileRequest      (struct Window *,TEXT *,TEXT *,BOOL,BOOL);
BOOL   FontRequest      (struct Window *);
BOOL   SMRequest        (struct ILBMInfo *);
void   SetMenuStart     (struct Window *);
void   SetMenuStop      (struct Window *);
ULONG  ProcessMenu      (struct Window *,UWORD);
BOOL   PickJuliaK       (struct Window *);
void   CheckMenu        (struct Window *);
void   ProcessMouse     (struct Window *,WORD,WORD);
ULONG  HandleEvents     (struct ILBMInfo *);
LONG   WinDump          (struct Window *);
ULONG  Fail             (UBYTE *,ULONG);
BOOL   PasteBitMap      (struct BitMap *,struct Window *,WORD,WORD);
void   wbmain           (struct WBStartup *ArgMsg);
LONG   main             (LONG,CONST_STRPTR *);
LONG   MainProg         (void);

struct Screen *OpenIdScreen (struct ILBMInfo *,WORD,WORD,WORD,ULONG);
struct Window *OpenDisplay  (struct ILBMInfo *,WORD,WORD,WORD,ULONG);
struct BitMap *CopyBitMap   (struct Window *,WORD,WORD,WORD,WORD);

#ifdef NO_68K_FPU
IMPORT WORD Mandeln68K_NoFPU (ULONG,ULONG,LDouble,LDouble);
IMPORT WORD Julian68K_NoFPU  (ULONG,ULONG,LDouble,LDouble,LDouble,LDouble);
#endif

#ifdef FIXEDPOINT_MATH
IMPORT WORD Mandeln68K_Fixed (ULONG,ULONG,LDouble,LDouble);
IMPORT WORD Julian68K_Fixed  (ULONG,ULONG,LDouble,LDouble,LDouble,LDouble);
#endif

#ifdef USE_68K_FPU_MATH
IMPORT WORD ASMCALL Mandeln68K (REG (d0,ULONG),REG (d1,ULONG),REG (fp0,LDouble),REG (fp1,LDouble));
IMPORT WORD ASMCALL Julian68K (REG (d0,ULONG),REG (d1,ULONG),REG (fp0,LDouble),REG (fp1,LDouble),REG (fp2,LDouble),REG (fp3,LDouble));
#endif

IMPORT void SAVEDS CalcFractalPPC (struct MandelChunk *,UBYTE *);

IMPORT BOOL ModifyPalette (struct Window *,WORD,WORD,ULONG *);
IMPORT BOOL ScalePalette (struct Window *,ULONG *,ULONG,ULONG);
IMPORT BOOL Fade (struct Window *,ULONG *,ULONG,ULONG,BOOL);
IMPORT BOOL Cycle (struct Window *,ULONG,BOOL);
IMPORT LONG QueryMandPic (struct ILBMInfo *,struct MandelChunk *,UBYTE *);
IMPORT LONG LoadMandPic (struct ILBMInfo *,UBYTE *, BOOL);
IMPORT LONG SaveMandPic (struct ILBMInfo *,struct Chunk *,struct Chunk *,UBYTE *);
IMPORT LONG LoadPalette (struct ILBMInfo *,UBYTE *, BOOL);
IMPORT LONG SavePalette (struct ILBMInfo *,struct Chunk *,UBYTE *);


#define MIN_ITERATIONS 31
#define MAX_ALLOWED_ITERATIONS 32767

#define MINLIMIT 2
#define RESERVED_PENS 4L

#define CPU_000  0x1
#define CPU_010  0x2
#define CPU_020  0x4
#define CPU_030  0x8
#define CPU_040  0x10
#define CPU_060  0x20
#define FPU_000  0x100   /* No 68k Fpu */
#define FPU_881  0x200
#define FPU_882  0x400
#define FPU_040  0x800
#define CPU_603  0x1000
#define CPU_603e 0x2000
#define CPU_604  0x4000
#define CPU_604e 0x8000
#define CPU_620  0x10000
#define CPU_G3   0x20000
#define CPU_G4   0x40000
#define CPU_G5   0x80000


#ifndef AFF_68060
#define AFF_68060 1L << 7
#endif


#define INIT_DEF_RMIN      -2.0
#define INIT_DEF_RMAX      +1.0
#define INIT_DEF_IMIN      -1.125
#define INIT_DEF_IMAX      +1.125
#define INIT_DEF_RMINSTR   "-2.0"
#define INIT_DEF_RMAXSTR   "+1.0"
#define INIT_DEF_IMINSTR   "-1.125"
#define INIT_DEF_IMAXSTR   "+1.125"
#define INIT_DEF_JKRE      -0.72
#define INIT_DEF_JKIM      -0.26
#define INIT_DEF_JKRESTR   "-0.72"
#define INIT_DEF_JKIMSTR   "-0.26"

//#define DEF_WIDTH        640
//#define DEF_HEIGHT       480
//#define DEF_DEPTH        4
#define DEF_WIDTH        800
#define DEF_HEIGHT       600
#define DEF_DEPTH        8
#define DEF_MONITOR      0x40D20003
#define DEF_MONITORSTR  "0x40D20003"
//#define DEF_MONITOR      0x50011000      // UAE & P96 support
//#define DEF_MONITORSTR  "0x50011000"     // UAE & P96 support
#define DEF_USERNAMESTR "Unknown"
#define DEF_FONTNAMESTR "topaz.font\0"
#define DEF_FONTSIZE     8
#define DEF_STARTPRI    -3

#define MIN_WIDTH  640
#define MIN_HEIGHT 480
#define MAX_WIDTH  16368
#define MAX_HEIGHT 16384
#define MIN_DEPTH  3
#define MAX_DEPTH  8

#define MAX_FONTSIZE 24
#define MIN_FONTSIZE 8

#define MAX_FILELEN 30
#define MAX_DIRLEN  230
#define MAX_PATHLEN 260
#define BARLEN      100  /* more for reaction-support !! */

#define TOBLACK   1
#define FROMBLACK 0

#define RAW_ESC      0x045
#define VAN_ESC      0x01B
#define TAB          0x042
#define HELP         0x05f

#define BLACK      (0)
#define LIGHT_GREY (2)
#define WHITE      (1)
#define DARK_GREY  (3)

#define POINTS       4
#define PAIRS        5

#define BLINKTIMES   5L

#define ONESEC        (50L * 1L)
#define TWOSECS       (50L * 2L) /* 2 secondi */

#define SHIFTRIGHT   FALSE
#define SHIFTLEFT    TRUE

#define INITIALZOOM  18

#define CLEAR_POINTER 0
#define BUSY_POINTER  1
#define ZOOM_POINTER  2

#define ZPW          15
#define ZPH          15
#define ZPXO         -8
#define ZPYO         -7

#define MAXCHARS     20

#define ACCEPT       (1)
#define RATIO        (2)
#define RESET        (3)
#define CANCEL       (4)
#define KEEP         (5)

#define WMASK  0x1
#define FMASK  0x2
#define VMASK  0x4
#define SMASK  0x8
#define BMASK  0x10
#define ZMASK  0x20
#define TMASK  0x40
#define MMASK  0x80
#define LMASK  0x100
#define PMASK  0x200

#define LOADPICTURE_MSG 0x1
#define SAVEPICTURE_MSG 0x2
#define DUMP_MSG        0x4
#define REDRAW_MSG      0x8
#define UNDO_MSG        0x10
#define DRAW_MSG        0x20
#define PREVIEW_MSG     0x40
#define NEWDISPLAY_MSG  0x80
#define STOP_MSG        0x100
#define EXIT_MSG        0x200
#define COORDS_MSG      0x400
#define ITER_MSG        0x800
#define ABOUT_MSG       0x1000
#define TITLE_MSG       0x2000
#define TIME_MSG        0x4000
#define PALETTE_MSG     0x8000
#define CYCLERIGHT_MSG  0x10000
#define CYCLELEFT_MSG   0x20000
#define DELAY_MSG       0x40000
#define COLOR_MSG       0x80000
#define LOADPALETTE_MSG 0x100000
#define SAVEPALETTE_MSG 0x200000
#define FONTREQ_MSG     0x400000
#define SHOWGUIDE_MSG   0x800000
#define SYSINFO_MSG     0x1000000
#define AREXX_MSG       0x2000000  /* new for arexx-support */

#define PICTURES_DRAWER 0
#define PALETTES_DRAWER 1

#define IDCMP_STANDARD  IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE|IDCMP_MENUPICK

#define WFLG_STANDARD WFLG_ACTIVATE|WFLG_BACKDROP|WFLG_NOCAREREFRESH|WFLG_SMART_REFRESH|WFLG_BORDERLESS|WFLG_REPORTMOUSE|WFLG_NEWLOOKMENUS

#define MODE_ID_MASK (LACE|HIRES|HAM|EXTRA_HALFBRITE)

#define PRINTERDEVICE "printer.device"
#define FMCATALOGNAME "FlashMandel.catalog"

#define VERSION  "FlashMandelWOS 2.1 "
#define AUTHOR   "Dino Papararo"
#define COPYRIGHT_DATE "©1995-2002"
#define ADDRESS  "Via Manzoni, 184\n  80123 Napoli\n  Italy"
#define EMAIL    "E-Mail address:\n  DinoP@InWind.It\n\n"

#ifdef  __SASC
#define DATE     __AMIGADATE__
#else
#define DATE     __DATE__
#endif

#define TITLE_BIT    (1L << 10)

#define FOUR_BIT     (1L << 15)
#define LINEAR_BIT   (1L << 16)
#define REPEATED_BIT (1L << 17)
#define LOG_BIT      (1L << 18)
#define SQUARE_BIT   (1L << 19)
#define ONE_BIT      (1L << 20)
#define TWO_BIT      (1L << 21)
#define THREE_BIT    (1L << 22)

#define FIXED_BIT    (1L << 23)
#define REAL_BIT     (1L << 24)

#define MC68K_BIT    (1L << 25)
#define PPC_BIT      (1L << 26)

#define JULIA4_BIT   (1L << 27)
#define JULIA_BIT    (1L << 28)
#define MANDEL_BIT   (1L << 29)
#define MANDEL4_BIT  (1L << 30)

#define ID_MAND MAKE_ID ('M','A','N','D')

//TEXT VERSION_STRING [] = "\0$VER: " VERSION " " COPYRIGHT_DATE " by " AUTHOR " compiled in " DATE "\n\0";

//TEXT CMD_Guide [] = "Run >NIL: SYS:Utilities/MultiView FlashMandel:Docs/FlashMandel.guide";

#endif /* FLASHMANDEL_H */
