
#include "errcodes.h"

#define BIOS 0
#define HARD 1

SHORT MaxSpeed[2] = { MAXBIOSSPEED, MAXHARDSPEED};

#define min(a,b) (((a) <= (b)) ? (a) : (b))

#define FPEN 2
#define DPEN 1


#define LEFT  0
#define RIGHT 1
#define UP    2
#define DOWN  3

#define COMM     1 
#define PARENT   2
#define DELETE   3
#define MKDIR    4
#define CONFIG   5
#define TEXTBIN  5
#define OVRWRITE 6
#define EXIT     7

#define PCUP     8
#define PCDOWN   9
#define AMUP    10 
#define AMDOWN  11 
#define PCLEFT  12
#define PCRIGHT 13
#define AMLEFT  14
#define AMRIGHT 15
#define PCPATH  16
#define AMPATH  17
#define PCVPROP 18
#define AMVPROP 19
#define PCHPROP 20
#define AMHPROP 21

#define MAXFILENUM 9

#define MAXDISPLAY 35

#define AM1  31
#define AM2  32
#define AM3  33
#define AM4  34
#define AM5  35
#define AM6  36
#define AM7  37
#define AM8  38
#define AM9  39

#define PC1  41
#define PC2  42
#define PC3  43
#define PC4  44
#define PC5  45
#define PC6  46
#define PC7  47
#define PC8  48
#define PC9  49

#define DIRSTRGAD 100


USHORT chip WaitPointerData[]=
{
 0x0000, 0x0000,
 0x0300, 0x0000,
 0x1F9C, 0x0300,
 0x3FFE, 0x1F9C,
 0x63E3, 0x3FFE,
 0x7A3B, 0x3FFE,
 0xF7B7, 0x7FFE,
 0xEF63, 0x7FFE,
 0xE23F, 0x7FFE,
 0x7FFE, 0x3FC0,
 0x3fC0, 0x0F80,
 0x0FB0, 0x0000,
 0x0078, 0x0030,
 0x0030, 0x0000,
 0x0004, 0x0000,
 0x000E, 0x0004,
 0x0004, 0x0000,
 0x0000, 0x0000  
};

static UWORD ColourTable[] = {0xaab,0xfff,0x000,0xacf};

struct TextAttr MyFont = {
 (STRPTR)"topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT};




USHORT Right[] = {
0x8000,             /* 1000000000000000 */
0xe000,             /* 1110000000000000 */
0xf800,             /* 1111100000000000 */
0xfe00,             /* 1111111000000000 */
0xf800,             /* 1111100000000000 */
0xe000,             /* 1110000000000000 */
0x8000              /* 1000000000000000 */
};

USHORT Left[] = {
0x0200,           /* 0000001000000000 */
0x0e00,           /* 0000111000000000 */
0x3e00,           /* 0011111000000000 */
0xfe00,           /* 1111111000000000 */
0x3e00,           /* 0011111000000000 */
0x0e00,           /* 0000111000000000 */
0x0200            /* 0000001000000000 */
};


USHORT  Up[] = {
0x0200,                     /* 0000001000000 */
0x0700,                     /* 0000011100000 */
0x0f80,                     /* 0000111110000 */
0x1fc0,                     /* 0001111111000 */
0x3fe0,                     /* 0011111111100 */
0x7ff0                      /* 0111111111110 */
}; 

USHORT  Down[] = {
0x7ff0,                     /* 0111111111110 */
0x3fe0,                     /* 0011111111100 */
0x1fc0,                     /* 0001111111000 */
0x0f80,                     /* 0000111110000 */
0x0700,                     /* 0000011100000 */
0x0200                      /* 0000001000000 */
};

USHORT *UpData = NULL, *DownData = NULL, *LeftData = NULL, *RightData = NULL;

struct Image LeftArrow = {1,84,8,7,1,Left,1,0,NULL};
struct Image RightArrow = {274,84,8,7,1,Right,1,0,(struct Image *)&LeftArrow};

struct Image UpArrow = {1,23,13,6,1,Up,1,0,NULL};
struct Image DownArrow = {1,92,13,6,1,Down,1,0,(struct Image *)&UpArrow};

struct PropInfo PGHInfo[2] = { {AUTOKNOB|FREEHORIZ,0,0,MAXBODY,0,0,0,0,0,0,0},
                               {AUTOKNOB|FREEHORIZ,0,0,MAXBODY,0,0,0,0,0,0,0} }; 
 
struct PropInfo PGVInfo[2] = { {AUTOKNOB|FREEVERT,0,0,0,MAXBODY,0,0,0,0,0,0},
                               {AUTOKNOB|FREEVERT,0,0,0,MAXBODY,0,0,0,0,0,0} };

struct Image VImage[2] = { {0,0,12,67,0,NULL,0x0000,0x0000,NULL}, 
                           {0,0,12,67,0,NULL,0x0000,0x0000,NULL} };

struct Image HImage[2] = { {0,0,12,10,0,NULL,0x0000,0x0000,NULL},
                           {0,0,12,10,0,NULL,0x0000,0x0000,NULL} };

SHORT BorderPairs[][6] = {
 {0,11, 0,0, 61,0}, /* 0: bool gadgets */
 {61,0, 61,11, 0,11},
 {0,12, 0,0, 62,0},
 {62,0, 62,12, 0,12},

 {0,8,0,0,18,0}, /* 4: up & down arrays */
 {18,0,18,8,0,8},

 {0,8,0,0,18,0}, /* 6: left & right arrays */
 {18,0,18,8,0,8},

 {0,10, 0,0, 286,0},   /* 8: string */
 {286,0, 286,10, 0,10},
 {0,11, 0,0, 288,0},      
 {288,0, 288,11, 0,11},

 {0,10, 0,0, 120,0},   /* 12: dir string */
 {120,0, 120,10, 0,10},
 {0,11, 0,0, 122,0},      
 {122,0, 122,11, 0,11},

 {316,38, 316,94, 298,94}, /* 16: prop gadgets */
 {315,38, 315,94, 298,94},
 {347,38, 347,94, 329,94}, 
 {346,38, 346,94, 329,94},

 {270,107, 270,115, 28,115}, /* 20: horiz prop gadgets */
 {269,107, 269,115, 28,115},
 {618,107, 618,115, 376,115}, 
 {617,107, 617,115, 376,115},

 {2,174, 2,130, 275,130}, /* 24: message */
 {275,130, 275,174, 2,174},
 {4,173, 4,131, 273,131},
 {273,131, 273,173, 4,173},

 {360,174, 360,130, 638,130}, /* 28: telecommunication */
 {638,130, 638,174, 360,174}, 
 {362,173, 362,131, 636,131},
 {636,131, 636,173, 362,173}, 

 { 2,129, 2,119, 275,119}, /* 30 'MESSAGE' text */
 {275,119, 275,129, 2,129},

 { 360,129, 360,119, 638,119}, /* 32 'TELECOMMUNICATION' text */
 {638,119, 638,129, 360,129},

 { 370,168, 370,158, 628,158}, /* 32 file transfer remainder */
 {628,158, 628,168, 370,168},

 {2,103, 2,26, 290,26}, /* 34: PC dir */
 {290,26, 290,103, 2,103},

 {350,103,350,26, 638,26}, /* 36: Amiga dir */
 {638,26, 638,103, 350,103} };



struct Border RevBorder[] = {
 /* bool gadgets */ 
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[0],NULL},
 {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[1],&RevBorder[0]},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[2],&RevBorder[1]},
 {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[3],&RevBorder[2]},

 /* up & down gadgets */
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[4],NULL},
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[5],&RevBorder[4]},

 /* left & right gadgets */
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[6],NULL},
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[7],&RevBorder[6]}};

struct Border Borders[] = {
 /* bool gadgets */
 {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[0],NULL},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[1],&Borders[0]}, 
 {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[2],&Borders[1]},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[3],&Borders[2]},

 /* up & down gadgets */
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[4],NULL},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[5],&Borders[4]},

 /* left & right gadgets */
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[6],NULL},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[7],&Borders[6]},

 /* string gadgets */
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[8],NULL},
 {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[9],&Borders[8]},
 {-3,-2,1,0,JAM1,3,(SHORT *) BorderPairs[10],&Borders[9]},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[11],&Borders[10]},

 /* dir string gadgets */
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[12],NULL},
 {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[13],&Borders[12]},
 {-3,-2,1,0,JAM1,3,(SHORT *) BorderPairs[14],&Borders[13]},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[15],&Borders[14]},

 /* prop gadgets */
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[16],NULL},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[17],&Borders[16]},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[18],&Borders[17]},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[19],&Borders[18]},

 /* prop gadgets */
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[20],&Borders[19]},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[21],&Borders[20]},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[22],&Borders[21]},
 {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[23],&Borders[22]},

 /* message */
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[24],&Borders[23]},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[25],&Borders[24]},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[26],&Borders[25]},
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[27],&Borders[26]},

 /* telecommunication */
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[28],&Borders[27]},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[29],&Borders[28]},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[30],&Borders[29]},
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[31],&Borders[30]},

 /* MESSAGE text */
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[32],&Borders[31]},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[33],&Borders[32]},

 /* TELECOMMUNICATION text */
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[34],&Borders[33]},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[35],&Borders[34]},

 /* file transfer remainder  */
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[36],&Borders[35]},
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[37],&Borders[36]},

 /* dirs */
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[38],&Borders[37]},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[39],&Borders[38]},
 {0,0,1,0,JAM1,3,(SHORT *) BorderPairs[40],&Borders[39]},
 {0,0,2,0,JAM1,3,(SHORT *) BorderPairs[41],&Borders[40]} }; 
 
struct IntuiText Texts[] = { 
 {2,0,JAM2,2,1,&MyFont,"CONNECT",NULL}, /*  0 */
 {2,0,JAM2,3,1,&MyFont," SEND  ",NULL}, /*  1 */
 {2,0,JAM2,2,1,&MyFont,"RECEIVE",NULL}, /*  2 */
 {2,0,JAM2,5,1,&MyFont,"PARENT",NULL},  /*  3 */
 {2,0,JAM2,5,1,&MyFont,"DELETE",NULL},  /*  4 */
 {2,0,JAM2,9,1,&MyFont,"MKDIR",NULL},   /*  5 */
 {2,0,JAM2,5,1,&MyFont," TEXT ",NULL},  /*  6 */
 {2,0,JAM2,5,1,&MyFont,"BINARY",NULL},  /*  7 */
 {2,0,JAM2,5,1,&MyFont,"CONFIG",NULL},  /*  8 */
 {2,0,JAM2,2,1,&MyFont,"PROTECT",NULL}, /*  9 */
 {2,0,JAM2,2,1,&MyFont,"OVR WRT",NULL}, /* 10 */
 {2,0,JAM2,13,1,&MyFont,"EXIT",NULL},   /* 11 */
 {2,0,JAM2,1,1,&MyFont,"MESSAGE",NULL}, /* 12 */
 {2,0,JAM2,1,1,&MyFont,"TELECOMMUNICATION",NULL}  /* 13 */
};  

char String[2][MAXFILENUM][MAXDISPLAY + 1];

struct IntuiText SelTexts[2][MAXFILENUM] = {
 {
  {FPEN,0,JAM2,0,0,&MyFont,String[0][0],NULL}, /* 0 */
  {FPEN,0,JAM2,0,0,&MyFont,String[0][1],NULL}, /* 1 */
  {FPEN,0,JAM2,0,0,&MyFont,String[0][2],NULL}, /* 2 */
  {FPEN,0,JAM2,0,0,&MyFont,String[0][3],NULL}, /* 3 */
  {FPEN,0,JAM2,0,0,&MyFont,String[0][4],NULL}, /* 4 */
  {FPEN,0,JAM2,0,0,&MyFont,String[0][5],NULL}, /* 5 */
  {FPEN,0,JAM2,0,0,&MyFont,String[0][6],NULL}, /* 6 */
  {FPEN,0,JAM2,0,0,&MyFont,String[0][7],NULL}, /* 7 */
  {FPEN,0,JAM2,0,0,&MyFont,String[0][8],NULL}  /* 8 */
 },
 {
  {FPEN,0,JAM2,0,0,&MyFont,String[1][0],NULL}, /* 0 */
  {FPEN,0,JAM2,0,0,&MyFont,String[1][1],NULL}, /* 1 */
  {FPEN,0,JAM2,0,0,&MyFont,String[1][2],NULL}, /* 2 */
  {FPEN,0,JAM2,0,0,&MyFont,String[1][3],NULL}, /* 3 */
  {FPEN,0,JAM2,0,0,&MyFont,String[1][4],NULL}, /* 4 */
  {FPEN,0,JAM2,0,0,&MyFont,String[1][5],NULL}, /* 5 */
  {FPEN,0,JAM2,0,0,&MyFont,String[1][6],NULL}, /* 6 */
  {FPEN,0,JAM2,0,0,&MyFont,String[1][7],NULL}, /* 7 */
  {FPEN,0,JAM2,0,0,&MyFont,String[1][8],NULL}  /* 8 */
 }
};

USHORT DirLen[2] = { MAXPCINFOLEN, MAXAMINFOLEN };

char Wheel[2][4]; 

struct IntuiText TransferWheel[] = 
{
 {1,0,JAM2,595,133,&MyFont,Wheel[0],NULL},
 {1,0,JAM2,446,133,&MyFont,Wheel[1],NULL}
};

char TransFileName[35];

struct IntuiText TransFileText = 
         {1,0,JAM2,380,142,&MyFont,TransFileName,NULL};

#define MAXMESSAGE 4

char  MTextAddr[MAXMESSAGE][33] = {{NULL}, {NULL}, {NULL}, {NULL}};

struct IntuiText MessIntuiText[] = {
 {1,0,JAM2,0,134,&MyFont,MTextAddr[0],NULL},  /* 0 */
 {1,0,JAM2,0,144,&MyFont,MTextAddr[1],NULL},  /* 1 */
 {1,0,JAM2,0,154,&MyFont,MTextAddr[2],NULL},  /* 2 */
 {1,0,JAM2,0,164,&MyFont,MTextAddr[3],NULL}   /* 3 */
}; 


char *MessageT[] = {
 "No Errors Encountered           ",
 "Can Not Open Serial Device      ",
 "Can Not Create IORequest        ",
 "Can Not Create Message Port     ",
 "Serial Device Is Not Open       ",
 "Can Not Write The Receiving File",
 "Synchronization Lost            ",
 "User Break Encountered          ",
 "Can Not Create Receiving File   ",
 "Receiving File Already Exists   ",

 "File Already Exists On Server   ",
 "Can Not Get File Information    ",
 "Can Not Open File To Send       ",
 "Server Is Not Responding        ",
 "Can't Open Server Source File   ",
 "Can't Open Server Target File   ",
 "Can Not Setup Timer             ",
 "Can Not Setup Serial Port       ",
 "Can Not Find a suitable Speed   ",
 "Error Hadling Directory         ",
 "MKDIR On Workstation Failed     ",
 "CHDIR On Workstation Failed     ",
 "Can Not Delete Workstation File ",
 "Can Not Delete Workstation Dir  ",

 "CHDIR On Server Failed          ",
 "MKDIR On Server Failed          ",
 "RMDIR On Server Failed          ",
 "Can Not Delete Server File      ",
 "Can Not Read The File To Send   ",

 "Enter Dir Name in String Gadget ",
 "Operation Canceled              ",
 "Operation Successful            ",
 "Not Enough Memory               ",
 "Trying 000000 bps               ",
 "Server Rejected the speed       ",
 "Server Agreed With The Speed    ",
 "Amiga Rejected The speed        ",
 "Amiga Agreed With The Speed     ",
 "Agreed Upon 000000 bps          ",
 "Couldn't Read Valid Config File ",
 "Could Not Write Config File     ",
 "BLANK ERROR!!!!!!!!!!!!!!!!!!!! ",

 "Receive Operation Failed        ",
 "Informing The Server Of Quit    ",
 "No Response Over Link           ",
 "Bad CheckSum In Received Packet "
};

#define BUFFLEN 255

UBYTE PCUndoBuff[BUFFLEN],AMUndoBuff[BUFFLEN],DirUndoBuff[BUFFLEN];
UBYTE PCBuff[BUFFLEN] = {0}, AMBuff[BUFFLEN] = {0}, DirBuff[BUFFLEN] = {0};

struct StringInfo GadInfo[2] = {
 {PCBuff,PCUndoBuff,0,BUFFLEN,0,0,0,0,0,0,0,0,NULL},
 {AMBuff,AMUndoBuff,0,BUFFLEN,0,0,0,0,0,0,0,0,NULL} };

struct StringInfo DirGadInfo = 
 {DirBuff,DirUndoBuff,0,BUFFLEN,0,0,0,0,0,0,0,0,NULL};

struct Gadget Gads[] = {
 { &Gads[1],290,125,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&Borders[3],(APTR)&RevBorder[3],
   &Texts[0],NULL,NULL,COMM,NULL},

 { &Gads[2],290,140,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&Borders[3],(APTR)&RevBorder[3],
   &Texts[3],NULL,NULL,PARENT,NULL},

 { &Gads[3],290,155,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&Borders[3],(APTR)&RevBorder[3],
   &Texts[4],NULL,NULL,DELETE,NULL},

 { &Gads[4],290,170,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&Borders[3],(APTR)&RevBorder[3],
   &Texts[5],NULL,NULL,MKDIR,NULL},

 { &Gads[6],493,185,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&Borders[3],(APTR)&RevBorder[3],
   &Texts[8],NULL,NULL,CONFIG,NULL},

 { &Gads[6],423,185,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&Borders[3],(APTR)&RevBorder[3],
   &Texts[9],NULL,NULL,OVRWRITE,NULL},

 { &Gads[7],573,185,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&Borders[3],(APTR)&RevBorder[3],
   &Texts[11],NULL,NULL,EXIT,NULL},

 /* up & down gadgets */
  { &Gads[8],295,27,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
    BOOLGADGET,(APTR)&Borders[5],(APTR)&RevBorder[5],NULL,NULL,NULL,PCUP,NULL},

 { &Gads[9],295,95,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
   BOOLGADGET,(APTR)&Borders[5],(APTR)&RevBorder[5],NULL,NULL,NULL,PCDOWN,NULL},

 { &Gads[10],326,27,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
   BOOLGADGET,(APTR)&Borders[5],(APTR)&RevBorder[5],NULL,NULL,NULL,AMUP,NULL},

 { &Gads[11],326,95,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
   BOOLGADGET,(APTR)&Borders[5],(APTR)&RevBorder[5],NULL,NULL,NULL,AMDOWN,NULL},


 /* left & right gadgets */
  { &Gads[12],2,106,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
   BOOLGADGET,(APTR)&Borders[7],(APTR)&RevBorder[7],NULL,NULL,NULL,PCLEFT,NULL},

 { &Gads[13],271,106,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
   BOOLGADGET,(APTR)&Borders[7],(APTR)&RevBorder[7],NULL,NULL,NULL,PCRIGHT,NULL},

 { &Gads[14],351,106,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
   BOOLGADGET,(APTR)&Borders[7],(APTR)&RevBorder[7],NULL,NULL,NULL,AMLEFT,NULL},

 { &Gads[15],620,106,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
   BOOLGADGET,(APTR)&Borders[7],(APTR)&RevBorder[7],NULL,NULL,NULL,AMRIGHT,NULL},

 /* string gadgets */

 { &Gads[16],4,15,286,9,NULL,RELVERIFY,STRGADGET,
  (APTR)&Borders[11],NULL,NULL,NULL,(APTR)&GadInfo[PC],PCPATH,NULL},

 { &Gads[17],352,15,286,9,NULL,RELVERIFY,STRGADGET,
  (APTR)&Borders[11],NULL,NULL,NULL,(APTR)&GadInfo[AM],AMPATH,NULL},

 /* prop gadgets */

 { &Gads[18],295,37,20,57,NULL,RELVERIFY,PROPGADGET,
   (APTR)&VImage[PC],NULL,NULL,NULL,(APTR)&PGVInfo[PC],PCVPROP,NULL},

 { &Gads[19],326,37,20,57,NULL,RELVERIFY,PROPGADGET,
  (APTR)&VImage[AM],NULL,NULL,NULL,(APTR)&PGVInfo[AM],AMVPROP,NULL},
 
 { &Gads[20],24,106,245,9,NULL,RELVERIFY,PROPGADGET,
  (APTR)&HImage[PC],NULL,NULL,NULL,(APTR)&PGHInfo[PC],PCHPROP,NULL},

 { NULL,372,106,245,9,NULL,RELVERIFY,PROPGADGET,
  (APTR)&HImage[AM],NULL,NULL,NULL,(APTR)&PGHInfo[AM],AMHPROP,NULL} };


struct Gadget AMSelect[] = {
 { &AMSelect[1],354,29,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[AM][0],NULL,NULL,AM1,NULL},

 { &AMSelect[2],354,37,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[AM][1],NULL,NULL,AM2,NULL},

 {&AMSelect[3],354,45,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[AM][2],NULL,NULL,AM3,NULL},

 {&AMSelect[4],354,53,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[AM][3],NULL,NULL,AM4,NULL},

 {&AMSelect[5],354,61,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[AM][4],NULL,NULL,AM5,NULL},

 {&AMSelect[6],354,69,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[AM][5],NULL,NULL,AM6,NULL},

 {&AMSelect[7],354,77,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[AM][6],NULL,NULL,AM7,NULL},

 {&AMSelect[8],354,85,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[AM][7],NULL,NULL,AM8,NULL},

 {NULL,354,93,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[AM][8],NULL,NULL,AM9,NULL}
};

struct Gadget PCSelect[] = {
 {&PCSelect[1],6,29,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[PC][0],NULL,NULL,PC1,NULL},

 {&PCSelect[2],6,37,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[PC][1],NULL,NULL,PC2,NULL},

 {&PCSelect[3],6,45,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[PC][2],NULL,NULL,PC3,NULL},

 {&PCSelect[4],6,53,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[PC][3],NULL,NULL,PC4,NULL},

 {&PCSelect[5],6,61,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[PC][4],NULL,NULL,PC5,NULL},

 {&PCSelect[6],6,69,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[PC][5],NULL,NULL,PC6,NULL},

 {&PCSelect[7],6,77,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[PC][6],NULL,NULL,PC7,NULL},

 {&PCSelect[8],6,85,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[PC][7],NULL,NULL,PC8,NULL},

 {NULL,6,93,280,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,
  BOOLGADGET,NULL,NULL,&SelTexts[PC][8],NULL,NULL,PC9,NULL}
};


struct Gadget DirGad =  
 { NULL,290,186,119,9,SELECTED,RELVERIFY,STRGADGET,
 (APTR)&Borders[15],NULL,NULL,NULL,(APTR)&DirGadInfo,DIRSTRGAD,NULL};


struct NewScreen MyScreen = {0,0,640,200,2,0,1,HIRES,CUSTOMSCREEN,NULL,
"        Server                Easy Transfer V2.0ß            Amiga",
NULL,NULL};

struct NewWindow MyWindow = {0,0,640,200,0,1,GADGETDOWN|GADGETUP|RAWKEY,
       RMBTRAP|SIMPLE_REFRESH|BACKDROP|BORDERLESS|ACTIVATE,&Gads[0],NULL,
       NULL,NULL,NULL,5,5,640,200,CUSTOMSCREEN };



/* config information */

struct IntuiText ConfigTexts[] = {
 {2,0,JAM2,23,2,&MyFont,"OK",NULL},   /* 0  */ 
 {2,0,JAM2,15,2,&MyFont,"SAVE",NULL},   /* 1  */
 {2,0,JAM2,7,2,&MyFont,"CANCEL",NULL},   /* 2  */
 {1,0,JAM2,6,2,&MyFont,"USING BIOS",NULL}, /* 3 */
 {1,0,JAM2,6,2,&MyFont," DIRECTLY ",NULL}, /* 4 */

 {2,0,JAM2,10,25,&MyFont,"Serial Port Name:",NULL},
 {2,0,JAM2,10,45,&MyFont,"Serial Port Unit:",&ConfigTexts[5]},
 {2,0,JAM2,10,65,&MyFont,
                     "Wait For A Reply For",&ConfigTexts[6]},

 {2,0,JAM2,205,65,&MyFont,"Seconds",&ConfigTexts[7]},
 {2,0,JAM2,10,85,&MyFont,
       "Try Communication Speeds Starting At:",&ConfigTexts[8]},
 {2,0,JAM2,10,105,&MyFont,
                   "Program Serial Port Hardware On Server",&ConfigTexts[9]},
 {2,0,JAM2,10,125,&MyFont,
                   "Check Link Availability Every",&ConfigTexts[10]},
 {2,0,JAM2,280,125,&MyFont,"Seconds",&ConfigTexts[11]},
 {2,0,JAM2,10,145,&MyFont,
                   "On CheckSum Errors, Retransmit Packets",&ConfigTexts[12]},
 {2,0,JAM2,350,145,&MyFont,"Times",&ConfigTexts[13]}

};

struct IntuiText SpeedTexts[] = { 
 {1,0,JAM2,1,1,&MyFont,"   300 bps",NULL},   /* 0  */
 {1,0,JAM2,1,1,&MyFont,"   600 bps",NULL},   /* 1  */
 {1,0,JAM2,1,1,&MyFont,"  1200 bps",NULL},    /* 2  */
 {1,0,JAM2,1,1,&MyFont,"  2400 bps",NULL},   /* 3  */
 {1,0,JAM2,1,1,&MyFont,"  4800 bps",NULL},   /* 4  */
 {1,0,JAM2,1,1,&MyFont,"  9600 bps",NULL},  /* 5  */
 {1,0,JAM2,1,1,&MyFont," 19200 bps",NULL},  /* 6  */
 {1,0,JAM2,1,1,&MyFont," 38400 bps",NULL},  /* 7  */
 {1,0,JAM2,1,1,&MyFont," 57600 bps",NULL},  /* 8  */
 {1,0,JAM2,1,1,&MyFont,"115200 bps",NULL} };  /* 9  */

SHORT ConfigBorderPairs[][6] = {
 {0,8,0,0,18,0}, /* 0: left & right arrays */
 {18,0,18,8,0,8},

 {0,11, 0,0, 61,0}, /* 2: bool gadget */
 {61,0, 61,11, 0,11},

 {0,10, 0,0, 91,0}, /* 4: bios gadget */
 {91,0, 91,10, 0,10},
 
 {0,9, 0,0, 280,0}, /* 6: big string */
 {280,0, 280,9, 0,9},

 {0,9, 0,0, 27,0,}, /* 8: small string */
 {27,0, 27,9, 0,9},

 {0,9, 0,0, 85,0}, /* 10: speed */
 {85,0, 85,9, 0,9}
};


struct Border ConfigRevBorders[] = {
 /* left & right gadgets */
 {0,0,2,0,JAM1,3,(SHORT *) ConfigBorderPairs[0],NULL},
 {0,0,1,0,JAM1,3,(SHORT *) ConfigBorderPairs[1],&ConfigRevBorders[0]}, 

 {0,0,2,0,JAM1,3,(SHORT *) ConfigBorderPairs[2],NULL},
 {0,0,1,0,JAM1,3,(SHORT *) ConfigBorderPairs[3],&ConfigRevBorders[2]}, 

 {0,0,2,0,JAM1,3,(SHORT *) ConfigBorderPairs[4],NULL},
 {0,0,1,0,JAM1,3,(SHORT *) ConfigBorderPairs[5],&ConfigRevBorders[4]},

};


struct Border ConfigBorders[] = {
 /* left & right gadgets */
 {0,0,1,0,JAM1,3,(SHORT *) ConfigBorderPairs[0],NULL},
 {0,0,2,0,JAM1,3,(SHORT *) ConfigBorderPairs[1],&ConfigBorders[0]}, 

 {0,0,1,0,JAM1,3,(SHORT *) ConfigBorderPairs[2],NULL},
 {0,0,2,0,JAM1,3,(SHORT *) ConfigBorderPairs[3],&ConfigBorders[2]}, 

 {0,0,1,0,JAM1,3,(SHORT *) ConfigBorderPairs[4],NULL},
 {0,0,2,0,JAM1,3,(SHORT *) ConfigBorderPairs[5],&ConfigBorders[4]},

 /* big string gadget */
 {-2,-1,2,0,JAM1,3,(SHORT *) ConfigBorderPairs[6],NULL},
 {-2,-1,1,0,JAM1,3,(SHORT *) ConfigBorderPairs[7],&ConfigBorders[6]},

 /* small string gadget */
 {-2,-1,2,0,JAM1,3,(SHORT *) ConfigBorderPairs[8],NULL},
 {-2,-1,1,0,JAM1,3,(SHORT *) ConfigBorderPairs[9],&ConfigBorders[8]},

 {0,0,2,0,JAM1,3,(SHORT *) ConfigBorderPairs[10],NULL},
 {0,0,1,0,JAM1,3,(SHORT *) ConfigBorderPairs[11],&ConfigBorders[10]},

};
#define SPEEDL   0
#define SPEEDR   1
#define USEBIOS  2
#define SERNAME  3
#define UNIT     4
#define DELAY    5
#define CHECK    6
#define CHECKSUM 7

#define OK       8
#define SAVE     9
#define CANCEL  10


#define SERNAMELEN 34
#define UNITLEN     3
#define DELAYLEN    3
#define CHECKLEN    3
#define CHECKSUMLEN 3

UBYTE SerNameUndoBuff[SERNAMELEN + 1],UnitUndoBuff[UNITLEN + 1];
UBYTE DelayUndoBuff[DELAYLEN + 1];
UBYTE SerNameBuff[SERNAMELEN + 1], UnitBuff[UNITLEN + 1];
UBYTE DelayBuff[DELAYLEN + 1];
UBYTE CheckBuff[CHECKLEN + 1],CheckUndoBuff[CHECKLEN + 1];
UBYTE CheckSumBuff[CHECKSUMLEN + 1],CheckSumUndoBuff[CHECKSUMLEN + 1];

struct StringInfo SerNameInfo = 
    {SerNameBuff,SerNameUndoBuff,0,SERNAMELEN,0,0,0,0,0,0,0,0,NULL};
struct StringInfo UnitInfo = 
    {UnitBuff,UnitUndoBuff,0,UNITLEN,0,0,0,0,0,0,0,0,NULL};
struct StringInfo DelayInfo = 
    {DelayBuff,DelayUndoBuff,0,DELAYLEN,0,0,0,0,0,0,0,0,NULL};
struct StringInfo CheckInfo = 
    {CheckBuff,CheckUndoBuff,0,CHECKLEN,0,0,0,0,0,0,0,0,NULL};
struct StringInfo CheckSumInfo = 
    {CheckSumBuff,CheckSumUndoBuff,0,CHECKSUMLEN,0,0,0,0,0,0,0,0,NULL};


struct Gadget ConfigGads[] = {
 {&ConfigGads[1],307,84,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
  BOOLGADGET,(APTR)&ConfigBorders[1],(APTR)&ConfigRevBorders[1],
  NULL,NULL,NULL,SPEEDL,NULL},

 {&ConfigGads[2],420,84,18,8,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
  BOOLGADGET,(APTR)&ConfigBorders[1],(APTR)&ConfigRevBorders[1],
  NULL,NULL,NULL,SPEEDR,NULL},

 {&ConfigGads[3],320,103,90,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&ConfigBorders[5],(APTR)&ConfigRevBorders[5],
   NULL,NULL,NULL,USEBIOS,NULL},

 {&ConfigGads[4],50,180,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&ConfigBorders[3],(APTR)&ConfigRevBorders[3],
   &ConfigTexts[0],NULL,NULL,OK,NULL},

 {&ConfigGads[5],290,180,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&ConfigBorders[3],(APTR)&ConfigRevBorders[3],
   &ConfigTexts[1],NULL,NULL,SAVE,NULL},

 {&ConfigGads[6],510,180,60,10,GADGHIMAGE,
   RELVERIFY,BOOLGADGET,(APTR)&ConfigBorders[3],(APTR)&ConfigRevBorders[3],
   &ConfigTexts[2],NULL,NULL,CANCEL,NULL},

 /* string gadgets */

 {&ConfigGads[7],150,25,286,9,NULL,RELVERIFY,STRGADGET,
 (APTR)&ConfigBorders[7],NULL,NULL,NULL,(APTR)&SerNameInfo,SERNAME,NULL},

 {&ConfigGads[8],150,45,28,9,NULL,RELVERIFY|LONGINT,STRGADGET,
 (APTR)&ConfigBorders[9],NULL,NULL,NULL,(APTR)&UnitInfo,UNIT,NULL},

 {&ConfigGads[9],175,65,28,9,NULL,RELVERIFY|LONGINT,STRGADGET,
 (APTR)&ConfigBorders[9],NULL,NULL,NULL,(APTR)&DelayInfo,DELAY,NULL},

 {&ConfigGads[10],250,125,28,9,NULL,RELVERIFY|LONGINT,STRGADGET,
 (APTR)&ConfigBorders[9],NULL,NULL,NULL,(APTR)&CheckInfo,CHECK,NULL},

 {NULL,320,145,28,9,NULL,RELVERIFY|LONGINT,STRGADGET,
 (APTR)&ConfigBorders[9],NULL,NULL,NULL,(APTR)&CheckSumInfo,CHECKSUM,NULL} };


struct NewWindow ConfigWindow = {0,0,640,200,0,1,GADGETUP,
       SIMPLE_REFRESH|WINDOWDRAG|ACTIVATE,&ConfigGads[0],NULL,
       "EasyTransfer Configuration Window",NULL,NULL,5,5,640,200,
       CUSTOMSCREEN };


UWORD chip NameData[132] =
{
 0x0FE0,0xF870,0x0000,0x0000,0x0000,0x0000,
 0x001F,0x0E00,0x0000,0x1C00,0x0007,0x0000,
 0x3018,0x70C0,0x0000,0x0000,0x0000,0x0000,
 0x000E,0x1800,0x0000,0x1C00,0x0007,0x0000,
 0x600C,0x7180,0x0000,0x0000,0x0000,0x0000,
 0x000E,0x3000,0x0000,0x0000,0x0000,0x0000,
 0xC3C6,0x7300,0x0000,0x0000,0x0000,0x0000,
 0x000E,0x6000,0x0000,0x0000,0x0000,0x0000,
 0xC666,0x7601,0xFC6F,0x3F1B,0xF83F,0x8EF8,
 0x000E,0xC03F,0x8DFC,0x3C6F,0x3F0F,0x0000,
 0xCE06,0x7C06,0x0E38,0xE38F,0x0CC1,0xC78E,
 0x000F,0x80C1,0xC786,0x1C38,0xE387,0x0000,
 0xCE06,0x7E00,0x0E38,0xE38E,0x0E01,0xC707,
 0x000F,0xC001,0xC707,0x1C38,0xE387,0x0000,
 0xC666,0x7701,0xFE38,0xE38E,0x003F,0xC707,
 0x000E,0xE03F,0xC700,0x1C38,0xE387,0x0000,
 0x63CC,0x7383,0x0E38,0xE38E,0x0061,0xC707,
 0x000E,0x7061,0xC700,0x1C38,0xE387,0x0000,
 0x3018,0x71C7,0x0E38,0xE38E,0x00E1,0xC707,
 0x000E,0x38E1,0xC700,0x1C38,0xE387,0x0000,
 0x0FE0,0xF9F3,0xFF79,0xF7DF,0x007F,0xEF8F,
 0x801F,0x3E7F,0xEF80,0x3E79,0xF7CF,0x8000
};

struct Image NameImage =
{
 0,0,
 177,11,
 1,
 &NameData[0],
 0x1,0x0,
 NULL
};


