#include "pcopy.h"

/* A bunch of globals */

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


/*************************************************************************/
/***                                                                   ***/
/***  - SELECT DRIVES - Window & Gear definitions.                     ***/
/***                                                                   ***/
/*************************************************************************/


/***  - SELECT DRIVES - Border around gadgets  ***/

SHORT  XYBox[]={
  0,0,
  0,GHEIGHT+1,
  1,GHEIGHT+1,
  1,0,
  GWIDTH+3,0,
  GWIDTH+3,GHEIGHT+1,
  GWIDTH+2,0,
  GWIDTH+2,GHEIGHT+1,
  0,GHEIGHT+1
};
struct Border BDBox={ -2,-1,1,0,JAM1,9,XYBox,0 };


/***  - SELECT DRIVES -  Gadget and text DF0:  ***/

struct IntuiText ITDF0={ 1,0,JAM1,7,2,0,"DF0:",0 };
struct Gadget GDF0={
  0,
  0*(GWIDTH+GHSPACE)+GLDIST,GTDIST,GWIDTH,GHEIGHT,
  GADGHCOMP,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&BDBox,
  0,
  &ITDF0,
  0,0,0,0
};

/***  - SELECT DRIVES -  Gadget and text DF1:  ***/

struct IntuiText ITDF1={ 1,0,JAM2,7,2,0,"DF1:",0 };
struct Gadget GDF1={
  &GDF0,
  1*(GWIDTH+GHSPACE)+GLDIST,GTDIST,GWIDTH,GHEIGHT,
  GADGHCOMP,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&BDBox,
  0,
  &ITDF1,
  0,0,0,0
};

/***  - SELECT DRIVES -  Gadget and text DF2:  ***/

struct IntuiText ITDF2={ 1,0,JAM2,7,2,0,"DF2:",0 };
struct Gadget GDF2={
  &GDF1,
  2*(GWIDTH+GHSPACE)+GLDIST,GTDIST,GWIDTH,GHEIGHT,
  GADGHCOMP,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&BDBox,
  0,
  &ITDF2,
  0,0,0,0
};

/***  - SELECT DRIVES -  Gadget and text DF3:  ***/

struct IntuiText ITDF3={ 1,0,JAM2,7,2,0,"DF3:",0 };
struct Gadget GDF3={
  &GDF2,
  3*(GWIDTH+GHSPACE)+GLDIST,GTDIST,GWIDTH,GHEIGHT,
  GADGHCOMP,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&BDBox,
  0,
  &ITDF3,
  0,0,0,0
};

/***  - SELECT DRIVES -  Gadget and text "DONE"  ***/

struct IntuiText ITDONE={ 1,0,JAM2,6,2,0,"DONE",0 };
struct Gadget GDONE={
  &GDF3,
  4*(GWIDTH+GHSPACE)+GHSPACE+GLDIST,GTDIST,GWIDTH,GHEIGHT,
  GADGHNONE,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&BDBox,
  0,
  &ITDONE,
  0,0,0,0
};


/***  - SELECT DRIVES -  Window  ***/

struct NewWindow NwR={
#define NWRWIDTH (5*GWIDTH+5*GHSPACE+2*GLDIST)
  640/2-NWRWIDTH/2,64,
  NWRWIDTH,GTDIST+GHEIGHT+5,
  0,1,
  0,
  WINDOWDRAG | SMART_REFRESH | ACTIVATE | NOCAREREFRESH ,
  &GDONE,
  0,
  "  Pcopy uses two drives. Which two?   ",
  0,0,0,0,0,0,
  WBENCHSCREEN
};

/***  - SELECT DRIVES -  Gadgets indexed available  ***/

struct Gadget *GList[]={ &GDF0,&GDF1,&GDF2,&GDF3 };


/*************************************************************************/
/***                                                                   ***/
/***  - COPY INTERFACE -  Windows & Gear definitions                   ***/
/***                                                                   ***/
/*************************************************************************/


/***  - COPY INTERFACE -  Track mark Window and staff IM's   ***/

char           TxT[]="     .    :    .    |    .    :    .     ";
struct IntuiText ITT={ 0,1,1,0,0,0,TxT,0 };
struct Image IMTTTL={ 0,0,332, 1,0,0,0,1,0 };
struct Image IMTmOn={ 6,0,  4,6,0,0,0,3,0 };
struct Image IMTmOf={ 6,0,320,6,0,0,0,0,0 };
struct NewWindow NwT={
  LTM,TTM,
  WTM,HTM,
  0,1,
  0,
  WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH,
  0,
  0,
  TxT,
  0,0,0,0,0,0,
  WBENCHSCREEN
};


/***  - COPY INTERFACE -  "Now in" windows   ***/

char           Tx1[]="  Now in        ";
struct IntuiText IT1={ 0,1,1,0,0,0,Tx1,0 };
struct NewWindow Nw1={
  LD1,TD1,
  WD1,HD1,
  0,1,
  0,
  WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH,
  0,
  0,
  Tx1,
  0,0,0,0,0,0,
  WBENCHSCREEN
};

char           Tx0[]="  Now in        ";
struct IntuiText IT0={ 0,1,1,0,0,0,Tx0,0 };
struct NewWindow Nw0={
  LD0,TD0,
  WD0,HD0,
  0,1,
  0,
  WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH,
  0,
  0,
  Tx0,
  0,0,0,0,0,0,
  WBENCHSCREEN
};

/***  - COPY INTERFACE -  History Window    ***/

char           TxH[]="  Copy History  ";
struct IntuiText ITH={ 0,1,1,0,0,0,TxH,0 };
struct NewWindow NwH={
  LHS,THS,
  WHS,HHS,
  0,1,
  0,
  WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | WINDOWSIZING,
  0,
  0,
  TxH,
  0,0,
  WHS,21,
  WHS,256,
  WBENCHSCREEN
};

/***/
/***  - COPY INTERFACE -  Control Window and its Gadgets   ***/
/***/

/***  - C.I. CONTROL -  Some general images and texts  ***/

struct Image  IMOFF={ 0,0,48,11,1, OFFData,1,0,0 };
struct Image   IMON={ 0,0,48,11,1,  ONData,3,0,0 };

struct IntuiText ITCCon={ 1,0,JAM2,0,0,0,"Auto Start Condition:",0 };
struct Image IMBlnk={ 0,0,176,38,0,0,0,0,0 };

struct Image IMEcla={ 0,0,32,24,2,EclaData,3,0,0 };
struct Image IMEcOf={ 0,0, 32,24,0,0,0,0,0 };

/***  - C.I. CONTROL -  Source/Destination Gadget   ***/

struct IntuiText  ITDr1={ DESTCOLOR,0,JAM2, 56,2,0,0,     0 };
struct IntuiText  ITDr0={         1,0,JAM2,-40,2,0,0,&ITDr1 };
/* flags which is in color (.FrontPen) and which in black */
UBYTE  PenA=1;
UBYTE  PenB=3;
struct Image  IMARR={ 0,0,48,11,1,ARRData,1,0,0 };
struct Image  IMARL={ 0,0,48,11,1,ARLData,1,0,0 };
APTR ArrowA=(APTR)&IMARR;
APTR ArrowB=(APTR)&IMARL;

struct Gadget GD0D1={
  0,
  104,2*GGH,48,11,
  GADGIMAGE | GADGHIMAGE,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&IMARR,
  (APTR)&IMARL,
  &ITDr0,
  0,0,0,0
};

/***  - C.I. CONTROL -  Manual start copy gadget  ***/

SHORT  XYCopy[]={ 0,0,0,23,1,23,1,0,46,0,46,23,0,23,47,23,47,0};
struct Border BDCopy={ -2,-1,1,0,JAM1,9,XYCopy,0 };
struct IntuiText ITCopy={ 1,0,JAM2,-88,6,0,"Start Copy",0 };
struct Gadget GCopy={
  &GD0D1,
  104+2,4*GGH+7,44,22,
  GADGHCOMP ,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&BDCopy,
  0,
  &ITCopy,
  0,0,0,0
};

/***  - C.I. CONTROL -  Auto/Manual start switch gadget  ***/

struct IntuiText ITAuto={ 1,0,JAM2,-88,2,0,"Auto Start",0 };
struct Gadget GAuto={
  &GCopy,
  104,3*GGH,48,11,
  GADGIMAGE | GADGHIMAGE,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&IMOFF,
  (APTR)&IMON,
  &ITAuto,
  0,0,0,0
};

/***  - C.I. CONTROL -  Verify switch gadget  ***/

struct IntuiText ITVerf={ 1,0,JAM2,-88,2,0,"    Verify",0 };
struct Gadget GVerf={
  &GAuto,
  104,1*GGH,48,11,
  GADGIMAGE | GADGHIMAGE | SELECTED ,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&IMOFF,
  (APTR)&IMON,
  &ITVerf,
  0,0,0,0
};

/***  - C.I. CONTROL -  "Non DOS" switch gadget  ***/

struct IntuiText ITNDOS={ 1,0,JAM2,-88,2,0,"   Non DOS",0 };
struct Gadget GNDOS={
  0,
  104,5*GGH,48,11,
  GADGIMAGE | GADGHIMAGE | SELECTED ,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&IMOFF,
  (APTR)&IMON,
  &ITNDOS,
  0,0,0,0
};

/***  - C.I. CONTROL -  "Unreadable" switch gadget  ***/

struct IntuiText ITUnRd={ 1,0,JAM2,-88,2,0,"Unreadable",0 };
struct Gadget GUnRd={
  0,
  104,6*GGH,48,11,
  GADGIMAGE | GADGHIMAGE | SELECTED ,
  TOGGLESELECT,
  BOOLGADGET,
  (APTR)&IMOFF,
  (APTR)&IMON,
  &ITUnRd,
  0,0,0,0
};

/***  - C.I. CONTROL -  Control Window  ***/

struct NewWindow NwS={
  LST,TST,
  WST,HST,
  0,1,
  CLOSEWINDOW,
  WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | WINDOWCLOSE | ACTIVATE,
  &GVerf,
  0,
  " Pcopy 1.0 ",
  0,0,
  0,0,0,0,
  WBENCHSCREEN
};

