#include "exec/types.h"
#include "exec/execbase.h"
#include "exec/memory.h"
#include "intuition/intuition.h"
#include "Intuition/intuitionbase.h"
#include "libraries/dosextens.h"
#include "devices/audio.h"
#include "devices/trackdisk.h"

/* select drives */

#define GWIDTH		44
#define GHEIGHT		11
#define GHSPACE		12
#define GVSPACE		4
#define GLDIST		15
#define GTDIST		14

/* windows and positions inside them */

#define GGH		13

#define WD1		244
#define HD1		21
#define TD1		12
#define LD1		640-WD1

#define WD0		WD1
#define HD0		HD1
#define TD0		TD1+HD1+2
#define LD0		640-WD1

#define WHS		WD1
#define HHS		70
#define THS		TD0+HD0+2
#define LHS		640-WHS

#define WTM		332
#define HTM		HD1
#define TTM		TD1
#define LTM		LD1-3-WTM

#define WST		208
#define HST		7*GGH+2
#define TST		TTM+HTM+2
#define LST		LD0-3-WST

/* History array size */
#define MHIST		32
#define MVOLNAME	32

/* shorttime is the position of the \0 if depth gadgets are displayed  */
#define SHORTTIME	34
#define DESTCOLOR	3			/* color of dest drive */

/* defs about the disk and its format */
#define NUMCYLS		80
#define NUMHEADS	2
#define NUMTRACS	NUMHEADS*NUMCYLS
#define BPTRACK		NUMSECS*TD_SECTOR	/* bytes per track	*/
#define BPCYL		NUMHEADS*BPTRACK
#define LPSECTOR	TD_SECTOR/4		/* longs per sector	*/
#define ROOTSECTOR	880
#define ROOTCYL		40
#define ROOTTRACK	NUMHEADS*ROOTCYL
#define ROOT_CHKSUM	5
#define ROOT_BMFFLAG	78			/* adresses in root	*/
#define	ROOT_ALTDAYS	105
#define ROOT_ALTMINS	106
#define ROOT_ALTTICKS	107
#define ROOT_VOLNAME	108
#define ROOT_CRTDAYS	121
#define ROOT_CRTMINS	122
#define ROOT_CRTTICKS	123

/* some ..  */
#define PUBCLR		MEMF_PUBLIC|MEMF_CLEAR
#define NDRIVES		4
#define VOLNAMESIZE	64
#define WAIT		1
#define NOWAIT		-1
#define BEEP_PRI	85


/*  struct IOStdReq should have been: struct IOExtTD, but this is
 *  compensated by the definition of the missing fields in the
 *  DriveInfo structure. Membernames became too long.
 */
 
typedef struct DriveInfo{
  struct IOStdReq Req;			/*  (iotd_Req			*/
  ULONG  Count;				/*  (iotd_Count)		*/
  ULONG  SecLabel;			/*  (iotd_Seclabel)		*/
  char  *DevName;			/*  df0:, df1: etc.		*/
  char   DOSInhbt;			/*  Dos inhibited flag		*/
  char   xx;				/*				*/
  int    Device;			/*  Trackdisk return value	*/
  int    Error;				/*  High level error		*/
  char   VolName[VOLNAMESIZE];		/*  Volume name (of disk)	*/
  ULONG  ChgNum;			/*  Disk change count		*/
  char   DOSDisk;			/*  AmigaDos formatted disk	*/
  char   DOSBoot;			/*  AmigaDos look-a-like	*/
  char   Readable;			/*  No error during read	*/
  char   Present;			/*  Disk in unit present	*/
} DrInfo;

/*
 *  functions in pcopy.c
 */

extern int _main();
extern void MainLoop();
extern int GetDrive();
extern int ReadSec();
extern int CheckSum();
extern int DiskCopy();
extern int DIOCyl();
extern int Compare();
extern void MotorOff();
extern void ChangeRoot();
extern int Init();
extern void Quit();
extern DrInfo *OpenDrive();
extern void CloseDrive();
extern void CheckCopy();
extern void CheckControl();
extern void ShDName();

/*
 *  functions in pc1.c
 */

extern void MemCleanup();
extern void ConPutStr();
extern int Request();
extern int OpenUser();
extern void CloseUser();
extern void RefOneGadget();
extern int Beep();
extern void DoBeep();
extern long dos_packet();
extern int AskDrives();
extern void EnterHist();
extern void RefHist();

/*
 *  functions in unmerged.c
 */

extern UBYTE *GetSoundDataAddress();
extern ULONG GetSoundDataSize();

/*
 *  library functions
 */

extern struct IntuiMessage *GetMsg();
extern struct Window *OpenWindow();
extern struct MsgPort *CreatePort();
extern struct IOStdReq *CreateStdIO();

/*
 *  Fast globals in fast.c
 */

/* A bunch of globals */
extern struct IntuitionBase *IntuitionBase;
extern struct Window  *W0;	/* "Now in DF0:" window  */
extern struct Window  *W1;	/* "Now in DF1:" window  */
extern struct Window  *WH;	/* "Copy History" window  */
extern struct Window  *WT;	/* "Track-staff" window  */
extern struct Window  *WS;	/* "Status/Command" window */
extern struct IOStdReq *IOHist;	/* History uses a Console device  */
extern struct MsgPort  *MPHist;	/* Port used for Console device  */
extern struct IOAudio Sound;	/* */
extern ULONG *CopyBuffer;	/* ..  */
extern ULONG *CompBuffer;	/* compare buffer  */
extern DrInfo *D0, *D1; 	/* two drive descriptors  */
extern short EnAuto;		/* flag to prevent copy after copy after.. */
extern short NowCopy;		/* flag, shows which gadgets are displayed */
extern char *Hist;		/* pointer to one big (1k) char array  */
extern char *DriveName[NDRIVES];/* array with names of selected drives  */
extern ULONG DriveNr[NDRIVES];	/* array with #'s of selected drives  */

/***  - SELECT DRIVES - Border around gadgets  ***/
extern SHORT  XYBox[];
extern struct Border BDBox;

/***  - SELECT DRIVES -  Gadget and text DF0:  ***/
extern struct IntuiText ITDF0;
extern struct Gadget GDF0;

/***  - SELECT DRIVES -  Gadget and text DF1:  ***/
extern struct IntuiText ITDF1;
extern struct Gadget GDF1;

/***  - SELECT DRIVES -  Gadget and text DF2:  ***/
extern struct IntuiText ITDF2;
extern struct Gadget GDF2;

/***  - SELECT DRIVES -  Gadget and text DF3:  ***/
extern struct IntuiText ITDF3;
extern struct Gadget GDF3;

/***  - SELECT DRIVES -  Gadget and text "DONE"  ***/
extern struct IntuiText ITDONE;
extern struct Gadget GDONE;

/***  - SELECT DRIVES -  Window  ***/
extern struct NewWindow NwR;

/***  - SELECT DRIVES -  Gadgets indexed available  ***/
extern struct Gadget *GList[];


/***  - COPY INTERFACE -  Track mark Window and staff IM's   ***/
extern char           TxT[];
extern struct IntuiText ITT;
extern struct Image IMTTTL;
extern struct Image IMTmOn;
extern struct Image IMTmOf;
extern struct NewWindow NwT;

/***  - COPY INTERFACE -  "Now in" windows   ***/
extern char           Tx1[];
extern struct IntuiText IT1;
extern struct NewWindow Nw1;
extern char           Tx0[];
extern struct IntuiText IT0;
extern struct NewWindow Nw0;

/***  - COPY INTERFACE -  History Window    ***/
extern char           TxH[];
extern struct IntuiText ITH;
extern struct NewWindow NwH;


/***  - C.I. CONTROL -  Some general images and texts  ***/
extern struct Image  IMOFF;
extern struct Image   IMON;
extern struct IntuiText ITCCon;
extern struct Image IMBlnk;
extern struct Image IMEcla;
extern struct Image IMEcOf;

/***  - C.I. CONTROL -  Source/Destination Gadget   ***/
extern struct IntuiText  ITDr1;
extern struct IntuiText  ITDr0;
extern UBYTE  PenA;
extern UBYTE  PenB;
extern struct Image  IMARR;
extern struct Image  IMARL;
extern APTR ArrowA;
extern APTR ArrowB;
extern struct Gadget GD0D1;

/***  - C.I. CONTROL -  Manual start copy gadget  ***/
extern SHORT  XYCopy[];
extern struct Border BDCopy;
extern struct IntuiText ITCopy;
extern struct Gadget GCopy;

/***  - C.I. CONTROL -  Auto/Manual start switch gadget  ***/
extern struct IntuiText ITAuto;
extern struct Gadget GAuto;

/***  - C.I. CONTROL -  Verify switch gadget  ***/
extern struct IntuiText ITVerf;
extern struct Gadget GVerf;

/***  - C.I. CONTROL -  "Non DOS" switch gadget  ***/
extern struct IntuiText ITNDOS;
extern struct Gadget GNDOS;

/***  - C.I. CONTROL -  "Unreadable" switch gadget  ***/
extern struct IntuiText ITUnRd;
extern struct Gadget GUnRd;

/***  - C.I. CONTROL -  Control Window  ***/
extern struct NewWindow NwS;

/*
 *  Chip globals in chip.c
 */
 
extern USHORT OFFData[];
extern USHORT ONData[];
extern USHORT ARRData[];
extern USHORT ARLData[];
extern USHORT EclaData[];
extern UBYTE SoundData[];
extern UBYTE SoundData1[];
