/****************************************************************/
/*								*/
/* Reasm.c -- enthält den Reassembler, der aus der Jedec-Datei	*/
/* wieder ein Source-File (.pld) erstellt.			*/
/*								*/
/* compilieren: cc Reasm.c					*/
/*								*/
/****************************************************************/


#include <exec/memory.h>
#include <libraries/dos.h>
#include <intuition/intuition.h>
#include <ctype.h>
#include <functions.h>

#include "GALer.h"


extern	char	path[];
extern	int	JedecGALType;
extern	char	filename[];			/*Puffer für Filenamen*/
extern	struct	JedecStruct	Jedec;
extern	struct	Window		*window;


int FuseToPin16Mode1[] = { 2,1,3,19,4,18,5,17,6,14,7,13,8,12,9,11 };
int FuseToPin16Mode2[] = { 2,1,3,18,4,17,5,16,6,15,7,14,8,13,9,11 };
int FuseToPin16Mode3[] = { 2,19,3,18,4,17,5,16,6,15,7,14,8,13,9,12 };

int FuseToPin20Mode1[] = { 2,1,3,23,4,22,5,21,6,20,7,17,8,16,9,15,10,14,11,13 };
int FuseToPin20Mode2[] = { 2,1,3,23,4,21,5,20,6,19,7,18,8,17,9,16,10,14,11,13 };
int FuseToPin20Mode3[] = { 2,23,3,22,4,21,5,20,6,19,7,18,8,17,9,16,10,15,11,14 };



SHORT RBorderVec1a[] = { 0,14,77,14,77,0 };
SHORT RBorderVec1b[] = { 0,14,0,0,77,0 };

SHORT RBorderVec2a[] = { 0,9,83,9,83,0 };
SHORT RBorderVec2b[] = { 0,9,0,0,83,0 };

SHORT RBorderVec3a[] = { 0,11,51,11,51,0 };
SHORT RBorderVec3b[] = { 0,11,0,0,51,0 };

SHORT PinNameBorVeca[]  = { 0,179,309,179,309,0 };
SHORT PinNameBorVecb[]  = { 0,179,0,0,309,0 };

struct Border RBorder1b = { -1,-1,2,0,JAM1,3,RBorderVec1b,NULL };
struct Border RBorder1a = { -1,-1,1,0,JAM1,3,RBorderVec1a,&RBorder1b };

struct Border RBorder2b = { -1,-1,2,0,JAM1,3,RBorderVec2b,NULL };
struct Border RBorder2a = { -1,-1,1,0,JAM1,3,RBorderVec2a,&RBorder2b };

struct Border RBorder3b = { -1,-1,2,0,JAM1,3,RBorderVec3b,NULL };
struct Border RBorder3a = { -1,-1,1,0,JAM1,3,RBorderVec3a,&RBorder3b };

struct Border PinNameBorderb = { 0,0,2,0,JAM1,3,PinNameBorVecb,NULL };
struct Border PinNameBordera = { 0,0,1,0,JAM1,3,PinNameBorVeca,&PinNameBorderb};



struct IntuiText RIText27 = { 1,0,JAM1,10,7,NULL,(UBYTE *)"Pinnamen:",NULL };

struct IntuiText RIText26 = { 1,0,JAM1,10,3,NULL,(UBYTE *)"Abbruch",NULL };
struct IntuiText RIText25 = { 1,0,JAM1,15,3,NULL,(UBYTE *)"Weiter",NULL };
struct IntuiText RIText30 = { 1,0,JAM1,5,1,NULL,(UBYTE *)" Set",NULL };
struct IntuiText RIText31 = { 1,0,JAM1,5,1,NULL,(UBYTE *)"Clear",NULL };
struct IntuiText RIText29 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"12",NULL };
struct IntuiText RIText28 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"11",NULL };

struct IntuiText RIText24 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"24",NULL };
struct IntuiText RIText23 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"23",NULL };
struct IntuiText RIText22 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"22",NULL };
struct IntuiText RIText21 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"21",NULL };
struct IntuiText RIText20 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"20",NULL };
struct IntuiText RIText19 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"19",NULL };
struct IntuiText RIText18 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"18",NULL };
struct IntuiText RIText17 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"17",NULL };
struct IntuiText RIText16 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"16",NULL };
struct IntuiText RIText15 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"15",NULL };
struct IntuiText RIText14 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"14",NULL };
struct IntuiText RIText13 = { 1,0,JAM1,-22,0,NULL,(UBYTE *)"13",NULL };
struct IntuiText RIText12 = { 1,0,JAM1, 89,0,NULL,(UBYTE *)"12",NULL };
struct IntuiText RIText11 = { 1,0,JAM1, 89,0,NULL,(UBYTE *)"11",NULL };
struct IntuiText RIText10 = { 1,0,JAM1, 89,0,NULL,(UBYTE *)"10",NULL };
struct IntuiText RIText9  = { 1,0,JAM1, 97,0,NULL,(UBYTE *)"9", NULL };
struct IntuiText RIText8  = { 1,0,JAM1, 97,0,NULL,(UBYTE *)"8", NULL };
struct IntuiText RIText7  = { 1,0,JAM1, 97,0,NULL,(UBYTE *)"7", NULL };
struct IntuiText RIText6  = { 1,0,JAM1, 97,0,NULL,(UBYTE *)"6", NULL };
struct IntuiText RIText5  = { 1,0,JAM1,	97,0,NULL,(UBYTE *)"5", NULL };
struct IntuiText RIText4  = { 1,0,JAM1,	97,0,NULL,(UBYTE *)"4", NULL };
struct IntuiText RIText3  = { 1,0,JAM1, 97,0,NULL,(UBYTE *)"3", NULL };
struct IntuiText RIText2  = { 1,0,JAM1,	97,0,NULL,(UBYTE *)"2", NULL };
struct IntuiText RIText1  = { 1,0,JAM1, 97,0,NULL,(UBYTE *)"1", NULL };



UBYTE PinNames16[20][10] = { "A","B","C","D","E","F","G","H","I","GND",
			     "J","K","L","M","N","O","P","Q","R","VCC" };
UBYTE PinNames20[24][10] = { "A","B","C","D","E","F","G","H","I","J","K","GND",
			     "L","M","N","O","P","Q","R","S","T","U","V","VCC" };


struct StringInfo R16Gad24SInfo = { PinNames16[23],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad23SInfo = { PinNames16[22],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad22SInfo = { PinNames16[21],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad21SInfo = { PinNames16[20],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad20SInfo = { PinNames16[19],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad19SInfo = { PinNames16[18],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad18SInfo = { PinNames16[17],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad17SInfo = { PinNames16[16],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad16SInfo = { PinNames16[15],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad15SInfo = { PinNames16[14],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad14SInfo = { PinNames16[13],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad13SInfo = { PinNames16[12],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad12SInfo = { PinNames16[11],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad11SInfo = { PinNames16[10],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad10SInfo = { PinNames16[9],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad9SInfo  = { PinNames16[8],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad8SInfo  = { PinNames16[7],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad7SInfo  = { PinNames16[6],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad6SInfo  = { PinNames16[5],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad5SInfo  = { PinNames16[4],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad4SInfo  = { PinNames16[3],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad3SInfo  = { PinNames16[2],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad2SInfo  = { PinNames16[1],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R16Gad1SInfo  = { PinNames16[0],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };


struct StringInfo R20Gad24SInfo = { PinNames20[23],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad23SInfo = { PinNames20[22],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad22SInfo = { PinNames20[21],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad21SInfo = { PinNames20[20],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad20SInfo = { PinNames20[19],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad19SInfo = { PinNames20[18],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad18SInfo = { PinNames20[17],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad17SInfo = { PinNames20[16],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad16SInfo = { PinNames20[15],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad15SInfo = { PinNames20[14],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad14SInfo = { PinNames20[13],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad13SInfo = { PinNames20[12],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad12SInfo = { PinNames20[11],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad11SInfo = { PinNames20[10],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad10SInfo = { PinNames20[9],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad9SInfo  = { PinNames20[8],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad8SInfo  = { PinNames20[7],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad7SInfo  = { PinNames20[6],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad6SInfo  = { PinNames20[5],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad5SInfo  = { PinNames20[4],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad4SInfo  = { PinNames20[3],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad3SInfo  = { PinNames20[2],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad2SInfo  = { PinNames20[1],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };

struct StringInfo R20Gad1SInfo  = { PinNames20[0],NULL,0,10,0,
				    0,0,0,0,0,0,0,NULL };


/*ACHTUNG: zwischen R16/20Gad1 und R16/20Gad24 dürfen keine neuen Gadgets
	   hinzugefügt werden und an R16/20Gad24 keine angehängt werden!
*/


struct Gadget R16Gad20 = { NULL,192,21,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText20,NULL,
			   (APTR)&R16Gad20SInfo,20,NULL };

struct Gadget R16Gad19 = { &R16Gad20,192,32,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText19,NULL,
			   (APTR)&R16Gad19SInfo,19,NULL };

struct Gadget R16Gad18 = { &R16Gad19,192,43,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText18,NULL,
			   (APTR)&R16Gad18SInfo,18,NULL };

struct Gadget R16Gad17 = { &R16Gad18,192,54,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText17,NULL,
			   (APTR)&R16Gad17SInfo,17,NULL };

struct Gadget R16Gad16 = { &R16Gad17,192,65,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText16,NULL,
			   (APTR)&R16Gad16SInfo,16,NULL };

struct Gadget R16Gad15 = { &R16Gad16,192,76,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText15,NULL,
			   (APTR)&R16Gad15SInfo,15,NULL };

struct Gadget R16Gad14 = { &R16Gad15,192,87,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText14,NULL,
			   (APTR)&R16Gad14SInfo,14,NULL };

struct Gadget R16Gad13 = { &R16Gad14,192,98,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText13,NULL,
			   (APTR)&R16Gad13SInfo,13,NULL };

struct Gadget R16Gad12 = { &R16Gad13,192,109,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText29,NULL,
			   (APTR)&R16Gad12SInfo,12,NULL };

struct Gadget R16Gad11 = { &R16Gad12,192,120,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText28,NULL,
			   (APTR)&R16Gad11SInfo,11,NULL };

struct Gadget R16Gad10 = { &R16Gad11,36,120,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText10,NULL,
			   (APTR)&R16Gad10SInfo,10,NULL };

struct Gadget R16Gad9  = { &R16Gad10,36,109,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText9,NULL,
			   (APTR)&R16Gad9SInfo,9,NULL };

struct Gadget R16Gad8  = { &R16Gad9,36,98,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText8,NULL,
			   (APTR)&R16Gad8SInfo,8,NULL };

struct Gadget R16Gad7  = { &R16Gad8,36,87,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText7,NULL,
			   (APTR)&R16Gad7SInfo,7,NULL };

struct Gadget R16Gad6  = { &R16Gad7,36,76,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText6,NULL,
			   (APTR)&R16Gad6SInfo,6,NULL };

struct Gadget R16Gad5  = { &R16Gad6,36,65,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText5,NULL,
			   (APTR)&R16Gad5SInfo,5,NULL };

struct Gadget R16Gad4  = { &R16Gad5,36,54,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText4,NULL,
			   (APTR)&R16Gad4SInfo,4,NULL };

struct Gadget R16Gad3  = { &R16Gad4,36,43,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText3,NULL,
			   (APTR)&R16Gad3SInfo,3,NULL };

struct Gadget R16Gad2  = { &R16Gad3,36,32,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText2,NULL,
			   (APTR)&R16Gad2SInfo,2,NULL };

struct Gadget R16Gad1  = { &R16Gad2,36,21,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText1,NULL,
			   (APTR)&R16Gad1SInfo,1,NULL };



struct Gadget R20Gad24 = { NULL,192,21,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText24,NULL,
			   (APTR)&R20Gad24SInfo,24,NULL };

struct Gadget R20Gad23 = { &R20Gad24,192,32,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText23,NULL,
			   (APTR)&R20Gad23SInfo,23,NULL };

struct Gadget R20Gad22 = { &R20Gad23,192,43,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText22,NULL,
			   (APTR)&R20Gad22SInfo,22,NULL };

struct Gadget R20Gad21 = { &R20Gad22,192,54,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText21,NULL,
			   (APTR)&R20Gad21SInfo,21,NULL };

struct Gadget R20Gad20 = { &R20Gad21,192,65,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText20,NULL,
			   (APTR)&R20Gad20SInfo,20,NULL };

struct Gadget R20Gad19 = { &R20Gad20,192,76,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText19,NULL,
			   (APTR)&R20Gad19SInfo,19,NULL };

struct Gadget R20Gad18 = { &R20Gad19,192,87,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText18,NULL,
			   (APTR)&R20Gad18SInfo,18,NULL };

struct Gadget R20Gad17 = { &R20Gad18,192,98,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText17,NULL,
			   (APTR)&R20Gad17SInfo,17,NULL };

struct Gadget R20Gad16 = { &R20Gad17,192,109,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText16,NULL,
			   (APTR)&R20Gad16SInfo,16,NULL };

struct Gadget R20Gad15 = { &R20Gad16,192,120,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText15,NULL,
			   (APTR)&R20Gad15SInfo,15,NULL };

struct Gadget R20Gad14 = { &R20Gad15,192,131,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText14,NULL,
			   (APTR)&R20Gad14SInfo,14,NULL };

struct Gadget R20Gad13 = { &R20Gad14,192,142,82,8,NULL,
			   RELVERIFY,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText13,NULL,
			   (APTR)&R20Gad13SInfo,13,NULL };

struct Gadget R20Gad12 = { &R20Gad13,36,142,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText12,NULL,
			   (APTR)&R20Gad12SInfo,12,NULL };

struct Gadget R20Gad11 = { &R20Gad12,36,131,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText11,NULL,
			   (APTR)&R20Gad11SInfo,11,NULL };

struct Gadget R20Gad10 = { &R20Gad11,36,120,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText10,NULL,
			   (APTR)&R20Gad10SInfo,10,NULL };

struct Gadget R20Gad9  = { &R20Gad10,36,109,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText9,NULL,
			   (APTR)&R20Gad9SInfo,9,NULL };

struct Gadget R20Gad8  = { &R20Gad9,36,98,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText8,NULL,
			   (APTR)&R20Gad8SInfo,8,NULL };

struct Gadget R20Gad7  = { &R20Gad8,36,87,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText7,NULL,
			   (APTR)&R20Gad7SInfo,7,NULL };

struct Gadget R20Gad6  = { &R20Gad7,36,76,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText6,NULL,
			   (APTR)&R20Gad6SInfo,6,NULL };

struct Gadget R20Gad5  = { &R20Gad6,36,65,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText5,NULL,
			   (APTR)&R20Gad5SInfo,5,NULL };

struct Gadget R20Gad4  = { &R20Gad5,36,54,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText4,NULL,
			   (APTR)&R20Gad4SInfo,4,NULL };

struct Gadget R20Gad3  = { &R20Gad4,36,43,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText3,NULL,
			   (APTR)&R20Gad3SInfo,3,NULL };

struct Gadget R20Gad2  = { &R20Gad3,36,32,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText2,NULL,
			   (APTR)&R20Gad2SInfo,2,NULL };

struct Gadget R20Gad1  = { &R20Gad2,36,21,82,8,NULL,
			   RELVERIFY|STRINGRIGHT,STRGADGET|REQGADGET,
			   (APTR)&RBorder2a,NULL,&RIText1,NULL,
			   (APTR)&R20Gad1SInfo,1,NULL };


/* An RGadget4 keinen neuen Gadgets anhängen - oder Programm entsprechen
   ändern.
*/
struct Gadget RGadget4  = { NULL,130,155,50,10,NULL,
			    RELVERIFY,BOOLGADGET|REQGADGET,
			    (APTR)&RBorder3a,NULL,&RIText31,NULL,
			    NULL,28,NULL };

struct Gadget RGadget3  = { &RGadget4,130,167,50,10,NULL,
			    RELVERIFY,BOOLGADGET|REQGADGET,
			    (APTR)&RBorder3a,NULL,&RIText30,NULL,
			    NULL,27,NULL };

struct Gadget RGadget2  = { &RGadget3,209,161,76,13,NULL,
			    RELVERIFY,BOOLGADGET|REQGADGET,
			    (APTR)&RBorder1a,NULL,&RIText26,NULL,
			    NULL,26,NULL };

struct Gadget RGadget1  = { &RGadget2,25,161,76,13,NULL,
			    RELVERIFY,BOOLGADGET|REQGADGET,
			    (APTR)&RBorder1a,NULL,&RIText25,NULL,
			    NULL,25,NULL };



struct Requester PinNameReq = { NULL,165,2,310,180,0,0,
				&RGadget1,&PinNameBordera,&RIText27,
				NOISYREQ,3,NULL,NULL,NULL };




/* CheckPinNames: Pinnamen überprüfen
   Aufruf: result = CheckPinNames();
	   JedecGALType muß den GAL-Typ enthalten
   Ergebnis:  result = 0 : alles o.k.
	            sonst: entsprechende Fehlernummer
*/
int CheckPinNames()
{
UBYTE	*ptr, *pinnames;
int	numofpins, i, j, l, n;


 if (JedecGALType == GAL16V8) {
   numofpins = 20;
   pinnames  = PinNames16[0];
 }
 else {
   numofpins = 24;
   pinnames  = PinNames20[0];
 }

					/*Pinnamen überprüfen*/
 for (n=0; n<numofpins; n++) {
   ptr = pinnames+n*10;				/*überprüfen ob Pinname aus*/
   if (*ptr == '/')				/*gültigen Zeichen besteht*/
     ptr++;
   if (!*ptr) {					/*kein Zeichen da?->Fehler*/
     ReasmError(4,n+1);
     return(4);
   }
   while (isalpha(*ptr) || isdigit(*ptr))
     ptr++;
   if (*ptr == '/') {
     ReasmError(6,n+1);
     return(6);
   }
   if (*ptr) {
     ReasmError(3,n+1);
     return(3);
   }

   for (l=0; l<n; l++) {			/*Pinname doppelt?*/
     if (strcmp(pinnames+l*10,(UBYTE *)"NC")) {
       i = j = 0;
       if (*(pinnames+l*10) == '/') i = 1;
       if (*(pinnames+n*10) == '/') j = 1;
       if (!strcmp(pinnames+l*10+i,pinnames+n*10+j)) {
	 ReasmError(2,n+1);
	 return(2);
       }
     }
   }
					/*GND an entsprechenden Pin?*/
   if (!strcmp(pinnames+n*10,(UBYTE *)"GND")) {
     if (n+1 != numofpins/2) {
       ReasmError(5,n+1);
       return(5);
     }
   }
   if (n+1 == numofpins/2) {
     if (strcmp(pinnames+n*10,(UBYTE *)"GND")) {
       ReasmError(7,n+1);
       return(5);
     }
   }
					/*VCC an entsprechenden Pin?*/
   if (!strcmp(pinnames+n*10,(UBYTE *)"VCC")) {
     if (n+1 != numofpins) {
       ReasmError(5,n+1);
       return(5);
     }
   }
   if (n+1 == numofpins) {
     if (strcmp(pinnames+n*10,(UBYTE *)"VCC")) {
       ReasmError(8,n+1);
       return(5);
     }
    }
  }

 return(0);
}




/* PinNameRequster: Läßt Requester erscheinen, in dem die Pinnamen
		    für den Reassembler eingegeben werden können
   Aufruf   : result = PinNameRequester(galtype);
   Parameter: galtype: GAL16V8 oder GAL20V8
   Ergebnis : result = 0: Weiter angewählt
		     = 1: Abbruch angewählt oder Fehler
*/
int PinNameRequester(galtype)
int galtype;
{
struct	IntuiMessage	*imsg;
struct	Gadget		*gadget;
ULONG	class;
USHORT	code,gadID;
UBYTE	*pinnames;
int	n, numofpins;
char	name[2];

 if (galtype == GAL16V8) {
   RGadget4.NextGadget = &R16Gad1; 
   pinnames  = PinNames16[0];
   numofpins = 20;
 }
 else {
   RGadget4.NextGadget = &R20Gad1; 
   pinnames  = PinNames20[0];
   numofpins = 24;
 }


 if (Request(&PinNameReq,window)) {
   for (n=0; n<5; n++) {			/*Pin 1-Gadget aktivieren*/
     if (JedecGALType == GAL16V8)
       if (ActivateGadget(&R16Gad1,window,&PinNameReq))
	 break;
     if (JedecGALType == GAL20V8)
       if (ActivateGadget(&R20Gad1,window,&PinNameReq))
	 break;
   }

   for (;;) {
     imsg = (struct IntuiMessage *) GetMsg(window->UserPort); 
     if (!imsg) WaitPort (window->UserPort);
     else {
       class = imsg->Class;
       code  = imsg->Code;
       if (class==GADGETUP) {
	 gadget = (struct Gadget *)imsg->IAddress;
         gadID=gadget->GadgetID;
       }
       ReplyMsg(imsg);
       if (class == VANILLAKEY) {
	 if (code == 'w') {				/*Weiter*/
	   if (!CheckPinNames()) {
	     EndRequest(&PinNameReq,window);
	     return(0);
	   }
	 }
	 if (code == 'a') {				/*Abbruch*/
	   EndRequest(&PinNameReq,window);
	   return(1);
	 }
       }
       if (class == GADGETUP) {
	 if (gadID == 25) {				/*Weiter*/
	   if (!CheckPinNames()) {
	     EndRequest(&PinNameReq,window);
	     return(0);
	   }
	 }

	 if (gadID == 26) {				/*Abbruch*/
	   EndRequest(&PinNameReq,window);
	   return(1);
	 }

	 if (gadID == 27) {				/*Set*/
	   name[0] = 'A';
	   name[1] = 0x00;
	   for (n=0; n<numofpins; n++) {
	     if (n+1 == numofpins/2) {
	       strcpy (pinnames+(long)(n*10),"GND");
	       continue;
	     }
	     if (n+1 == numofpins) {
	       strcpy (pinnames+(long)(n*10),"VCC");
	       continue;
	     }
	     strcpy (pinnames+(long)(n*10),name);
	     name[0]++;
	   }
	   if (galtype == GAL16V8)
	     RefreshGadgets(&R16Gad1,window,&PinNameReq);
	   else
	     RefreshGadgets(&R20Gad1,window,&PinNameReq);
	 }

	 if (gadID == 28) {				/*Clear*/
	   for (n=0; n<numofpins; n++) {
	     if ((n+1 != numofpins) && (n+1 != numofpins/2))
	       *(pinnames+(long)(n*10)) = 0;
	   }
	   if (galtype == GAL16V8)
	     RefreshGadgets(&R16Gad1,window,&PinNameReq);
	   else
	     RefreshGadgets(&R20Gad1,window,&PinNameReq);
	 }

	 if ((gadID >= 1) && (gadID <=24)) {
	   gadget = gadget->NextGadget;		/*Ende der Gadgetliste?*/
	   if (!gadget)				/*dann von vorne beginnen*/
	     gadget = RGadget4.NextGadget;
	   for (n=0; n<5; n++) {		/*nächstes Gadget aktivieren*/
	     if (ActivateGadget(gadget,window,&PinNameReq))
	       break;
	   }
	 }
       }

     }
   }
 }
}







/*RowActive: gibt an, ob eine Zeile aktiviert oder deaktiviert ist
	     Überprüft PT-Bit und sucht nach Folge A * /A
  Aufruf:   result = RowActive(row,colsize);
  result = 0: Zeile ist deaktiviert
	 = 1: Zeile ist aktiviert
	 = 2: Zeile ist aktiviert, aber lauter 1en (VCC)
  row:     Zeile die überprüft werden soll
*/
int RowActive(row)
int row;
{
int n, colsize, flag;

 if (JedecGALType == GAL16V8)
   colsize   = MAX_FUSE_ADR16+1;
 else
   colsize   = MAX_FUSE_ADR20+1;

 if (!Jedec.GALPT[row])				/*PT-Bit überprüfen*/
   return(0);

 flag = 0;
 for (n=0; n<colsize; n++) {			/*nach "A * /A" suchen*/
   if (!Jedec.GALLogic[row*colsize+n]) {
     flag = 1;
     if (!(n % 2))
       if (!Jedec.GALLogic[row*colsize+n+1])
         return(0);
   }
 }

 if (flag)
   return(1);
 else
   return(2);
}





/*OLMCOutput: gibt an, ob OLMC als Ausgang programmiert ist
  Aufruf:     result = OLMCOutput(olmc);
  	      olmc:    die zu testende OLMC
	      mode:    Modus, in dem sich das GAL befindet
  Ergebnis:   result = 0:  kein Ausgang
	   	     = 1:  Ausgang (enthält sinnvolle Gleichung)
*/
int OLMCOutput(olmc, mode)
int olmc, mode;
{
int n, flag;

 if ((mode == 1) && (Jedec.GALAC1[olmc]))
   return(0);

 flag = 0;
 for (n=0; n<8; n++) {
   if (!n && ((mode == 2) || ((mode == 3) && Jedec.GALAC1[olmc]))) {
     if (!RowActive(olmc*8))		/*Tristatefreigabe = GND?*/
       return(0);			/*ja, dann Eingang*/
   }
   else {
     if (RowActive(olmc*8+n))
       flag = 1;
   }
 }

 return(flag);
}


/*MakeEquation: erstellt aus den angegebenen Zeilen der JEDEC-Struktur
		die entsprechende Gleichung
  Aufruf:     result = MakeEquation(buff, olmc, colsize, mode, numofrows);

  Ergebnis:   result =  0: alles o.k.
	   	     = -1: Fehler, kein Speicher mehr
*/
int MakeEquation(buff, olmc, colsize, mode, rowoffset, numofrows)
struct ActBuffer *buff;
int olmc,colsize, mode, rowoffset, numofrows;
{
int	ORflag, ANDflag, pin, m, n, result, numofchar;
struct	ActBuffer  startbuff;


 startbuff = *buff;				/*Zeiger merken*/

 numofchar = 8;
 n = rowoffset;

 ORflag = 0;
 while (n < numofrows) {
   result = RowActive(olmc*8 + n);
   if (result == 1) {				/*enthält die Zeile etwas*/
     if (ORflag) {				/*Sinnvolles? ja, dann OR*/
       if (AddString(buff," + "))
	 return(-1);
       numofchar += 3;				/*Zeichen mitzählen*/
     }
     ORflag  = 1;
     ANDflag = 0;
     for (m=0; m<colsize; m++) {
       if (!Jedec.GALLogic[(olmc*8+n)*colsize+m]) {
         if (ANDflag) {
           if (AddByte(buff,'*'))		    /*Produkterm auswerten*/
 	     return(-1);
	   numofchar++;
         }
         ANDflag = 1;
         if (JedecGALType == GAL16V8) {		/*GAL16V8*/
           if (mode == 1)				/*Pinnummer aus der*/
 	     pin = FuseToPin16Mode1[m/2];		/*Spaltennummer bes-*/
           if (mode == 2)				/*stimmen*/
	     pin = FuseToPin16Mode2[m/2];
           if (mode == 3)
	     pin = FuseToPin16Mode3[m/2];
	   if (((PinNames16[pin-1][0] == '/') && !(m % 2)) || /*Negation in*/
	       ((PinNames16[pin-1][0] != '/') &&  (m % 2))) { /*Pindek. be-*/
	     if (AddByte(buff,'/'))			      /*rücksichtigen*/
	       return(-1);
	     numofchar++;
	   }
	   if (PinNames16[pin-1][0] == '/') {   /*Pinnamen ohne '/' schreiben*/
	     if (AddString(buff,&PinNames16[pin-1][1]))
               return(-1);
	   }
	   else {
	     if (AddString(buff,PinNames16[pin-1]))
               return(-1);
	   }
	   numofchar += (int)strlen(PinNames16[pin-1]);
         }
         if (JedecGALType == GAL20V8) {		/*GAL20V8*/
           if (mode == 1)				/*Pinnummer aus der*/
 	     pin = FuseToPin20Mode1[m/2];		/*Spaltennummer bes-*/
           if (mode == 2)				/*stimmen*/
	     pin = FuseToPin20Mode2[m/2];
           if (mode == 3)
	     pin = FuseToPin20Mode3[m/2];
	   if (((PinNames20[pin-1][0] == '/') && !(m % 2)) || /*Negation in*/
	       ((PinNames20[pin-1][0] != '/') &&  (m % 2))) { /*Pindek. be-*/
	     if (AddByte(buff,'/'))			      /*rücksichtigen*/
	       return(-1);
	     numofchar++;
	   }
	   if (PinNames20[pin-1][0] == '/') {   /*Pinnamen ohne '/' schreiben*/
	     if (AddString(buff,&PinNames20[pin-1][1]))
               return(-1);
	   }
	   else {
	     if (AddString(buff,&PinNames20[pin-1][0]))
               return(-1);
	   }
	   numofchar += (int)strlen(&PinNames20[pin-1][0]);
         }
	 if (numofchar > 60) {				/*neue Zeile?*/
	   if (AddString(buff,"\n        "))
	     return(-1);
	   numofchar = 8;
	 }
       }
     }
   }
   if (result == 2) {			/*nur 1en in der Zeile, dann*/
     *buff = startbuff;			/*liegt VCC vor*/
     if (AddString(buff,"VCC"))
       return(-1);
       break;
   }
   n++;
 }
 if (AddString(buff,"\n\n"))			/*Gleichungsende*/
   return(-1);

 return(0);
}







/*Reasm: Erstellt aus der Jedec-Struktur wieder die Eingabe-Datei. Diese
	 wird in "buff" abelegt.
  Aufruf: result = Reasm(buff);
  	  buff: ActBuffer-Struktur für Speicher, in dem das File abgelegt
		werden soll
  Ergebnis: result = 0:     alles o.k.
		   = sonst: Fehler
*/
int Reasm(buff)
struct	ActBuffer buff;
{
int	mode, n, numofpins, byte;
int	olmc, colsize;
int	tricon[8];


 if (JedecGALType == GAL16V8) {		/*GAL-Typ bestimmen*/
   if (AddString(&buff,"GAL16V8\n"))
     return(-1);
   numofpins = 20;
   colsize   = MAX_FUSE_ADR16+1;
 }
 else {
   if (AddString(&buff,"GAL20V8\n"))
     return(-1);
   numofpins = 24;
   colsize   = MAX_FUSE_ADR20+1;
 }

 byte = 0;				/*Signatur erstellen*/
 for (n=0; n<SIG_SIZE; n++) {
   byte |= Jedec.GALSig[n];			/*8 Bits zu einem Byte*/
   if (!((n+1)%8)) {				/*zusammenfügen*/
     if (!isprint(byte))
       byte = '.';
     if (AddByte(&buff,byte))
       return(-1);
     byte = 0;
    }
   byte <<= 1;
 } 
 if (AddString(&buff,"\n\n"))
   return(-1);

					/*Pinnamen erstellen*/
 for (n=1; n<=numofpins; n++) {
   if (JedecGALType == GAL16V8)
     if (AddString(&buff,&PinNames16[n-1][0]))
       return(-1);
   if (JedecGALType == GAL20V8)
     if (AddString(&buff,PinNames20[n-1]))
       return(-1);
   if (n == numofpins/2) {
     if (AddString(&buff,"\n"))
       return(-1);
   }
   else {
     if (AddString(&buff," "))
       return(-1);
   }
 }

 if (AddString(&buff,"\n\n"))
   return(-1);



 if (!Jedec.GALAC0 && !Jedec.GALSYN) {	/*Modus überprüfen*/
   ReasmError(1,0);				/*Fehler, dann Ende*/
   return(1);
 }
					/*Modus bestimmen*/
 if (!Jedec.GALSYN) {				/*Wenn SYN = 0, dann Mode 3*/
   mode = 3;					/*Register-Modus*/
 }
 else {
   if (Jedec.GALSYN && Jedec.GALAC0)
     mode = 2;					/*Tristate-Modus*/
   else
      mode = 1;					/*kombinatorische Ausgänge*/
 }

 for (n=0; n<8; tricon[n++]=0);		/*Merker für Ausgänge mit Tristate-*/
					/*kontrolle initialisieren*/

					/*Gleichungen erstellen*/
 for (olmc=0; olmc<8; olmc++) {			/*8 OLMCs vorhanden*/
   if (OLMCOutput(olmc,mode)) {			/*OLMC als Ausgang?*/

     if (JedecGALType == GAL16V8) {
				      /*Negation in Pindek. berücksichtigen*/
       if (((PinNames16[19-olmc-1][0] == '/') && Jedec.GALXOR[olmc]) ||
	   ((PinNames16[19-olmc-1][0] != '/') && !Jedec.GALXOR[olmc])) {
	 if (AddByte(&buff,'/'))
	   return(-1);
       }

       if (PinNames16[19-olmc-1][0] == '/') {   /*Pinnamen ohne '/' schreiben*/
	 if (AddString(&buff,&PinNames16[19-olmc-1][1]))
           return(-1);
       }
       else {
	 if (AddString(&buff,PinNames16[19-olmc-1]))
           return(-1);
       }
     }

     if (JedecGALType == GAL20V8) {
				      /*Negation in Pindek. berücksichtigen*/
       if (((PinNames20[22-olmc-1][0] == '/') && Jedec.GALXOR[olmc]) ||
	   ((PinNames20[22-olmc-1][0] != '/') && !Jedec.GALXOR[olmc])) {
	 if (AddByte(&buff,'/'))
	   return(-1);
       }

       if (PinNames20[22-olmc-1][0] == '/') {   /*Pinnamen ohne '/' schreiben*/
	 if (AddString(&buff,&PinNames20[22-olmc-1][1]))
           return(-1);
       }
       else {
	 if (AddString(&buff,PinNames20[22-olmc-1]))
           return(-1);
       }
     }

     if ((mode == 2) || ((mode == 3) && (Jedec.GALAC1[olmc]))) {
       if (AddString(&buff,".T"))
         return(-1);
       tricon[olmc] = 1;			/*Merker setzen, daß Tri.-*/
     }						/*kontrolle vorhanden ist*/

     if ((mode == 3) && (!Jedec.GALAC1[olmc]))
       if (AddString(&buff,".R"))
         return(-1);

     if (AddString(&buff," = "))
       return(-1);

     n = 0;
     if ((mode == 2) || ((mode == 3) && Jedec.GALAC1[olmc])) /*bei Tri.*/
       n++;				   /*die erste Zeile überspringen*/
     if (MakeEquation(&buff, olmc, colsize, mode, n, 8))
       return(-1);
   }
 }

				/*Tristate-Kontrolle erzeugen*/
 for (olmc=0; olmc<8; olmc++) {
   if (tricon[olmc]) {
     if (JedecGALType == GAL16V8) {
       if (PinNames16[19-olmc-1][0] == '/') {   /*Pinnamen ohne '/' schreiben*/
	 if (AddString(&buff,&PinNames16[19-olmc-1][1]))
           return(-1);
       }
       else {
	 if (AddString(&buff,PinNames16[19-olmc-1]))
           return(-1);
       }
     }
     if (JedecGALType == GAL20V8) {
       if (PinNames20[22-olmc-1][0] == '/') {   /*Pinnamen ohne '/' schreiben*/
	 if (AddString(&buff,&PinNames20[22-olmc-1][1]))
           return(-1);
       }
       else {
	 if (AddString(&buff,PinNames20[22-olmc-1]))
           return(-1);
       }
     }
     if (AddString(&buff,".E"))			/*Tristate-Freigabe*/
       return(-1);
     if (AddString(&buff," = "))
       return(-1);

     if (MakeEquation(&buff, olmc, colsize, mode, 0, 1))
       return(-1);
   }
 }


					/*Abschlußtext schreiben*/
 if (AddString(&buff,"DESCRIPTION:\nDieses File wurde aus dem JEDEC-File '"))
   return(-1);
 if (AddString(&buff,&filename[0]))
   return(-1);
 if (AddString(&buff,"'\nerzeugt.\n"))
   return(-1);

 return(0);				/*kein Fehler aufgetreten, fertig*/
}




/*Reassembler: Jedec-File in Source-File zurückverwandeln
*/
void Reassembler()
{
struct	Buffer		*reasm_buff;
struct	ActBuffer	mybuff;
struct	FileHandle	*fh;
UBYTE	*filebuffer, *filebuffer2;
int	result;

 if (MyFileReq((char *)"JEDEC-File laden", (char *)".jed",YES)) {
   if (!(GetJedec(&path[0]))) {		/*JEDEC-File holen*/

     if (PinNameRequester(JedecGALType))
       return;


     if (!(reasm_buff = (struct Buffer *)AllocMem((long)sizeof(struct Buffer),MEMF_PUBLIC|MEMF_CLEAR))) {
       ErrorReq(2);			/*kein Speicher mehr->Fehlermeldung*/
       return;
     }
     mybuff.ThisBuff = reasm_buff;
     mybuff.Entry    = (UBYTE *)(&reasm_buff->Entries[0]);
     mybuff.BuffEnd  = (UBYTE *)reasm_buff + (long)sizeof(struct Buffer);


     if (!Reasm(mybuff) && MyFileReq((char *)"Source-File schreiben", (char *)".pld", YES)) {
       PrintText((UBYTE *)"schreibe Source-File...",1);
       if ((fh = Open(&path[0], MODE_NEWFILE))) {
         for (;;) {
	   filebuffer = filebuffer2 = mybuff.Entry;

	   while (filebuffer2 < mybuff.BuffEnd) {	/*Größe des Puffers bestimmen*/
	     if (!*filebuffer2) 
	       break;
             filebuffer2++;
	   }
						/*Puffer schreiben*/
	   result = Write(fh, filebuffer, (long)(filebuffer2-filebuffer));
	   if (result == -1L) {			/*Fehler beim Schreiben?*/
	     Close(fh);				/*ja, dann Ende*/
	     FreeBuffer(reasm_buff);
	     PrintText((UBYTE *)" Fehler!",0);
	     ErrorReq(13);
	     return;
	   }

	   if (!mybuff.ThisBuff->Next)		/*noch ein Puffer da?*/
	     break;					/*nein, dann for(;;)-Ende*/
	   mybuff.ThisBuff = mybuff.ThisBuff->Next;
	   mybuff.Entry    = (UBYTE *)(&mybuff.ThisBuff->Entries[0]);
	   mybuff.BuffEnd  = (UBYTE *)mybuff.ThisBuff + (long)sizeof(struct Buffer);
         }
         Close(fh);
       }
       else {
         FreeBuffer(reasm_buff);		/*Fehler?, dann Abbruch*/
         PrintText((UBYTE *)" Fehler!",0);
         ErrorReq(13);			/*Datei läßt sich nicht öffnen*/
         return;
       }

       PrintText((UBYTE *)" o.k.",0);
     }
     FreeBuffer(reasm_buff);			/*Speicher freigeben*/
   }
 }
}



/* gibt Fehlermeldungen des Reassemblers aus und gibt Speicher frei
*/
void ReasmError(errornum, pinnum)
int	errornum, pinnum;
{
UBYTE	*txtptr;

 switch (errornum) {
   case  1:
     MyRequest(ERR_REQ,(UBYTE *)"Fehler beim Reassemblieren!");
     PrintText((UBYTE *)"der Modus AC0 = SYN = 0 wird nicht unterstützt",1);
     break;
   case  2:
     txtptr = (UBYTE *)"Pin xx: Pinname doppelt";
     sprintf(txtptr+4L,"%2d",pinnum);
     *(txtptr+6L) = ':';
     MyRequest(ERR_REQ,txtptr);
     break;
   case  3:
     txtptr = (UBYTE *)"Pin xx: illegales Zeichen";
     sprintf(txtptr+4L,"%2d",pinnum);
     *(txtptr+6L) = ':';
     MyRequest(ERR_REQ,txtptr);
     break;
   case  4:
     txtptr = (UBYTE *)"Pin xx: kein Pinname vorhanden";
     sprintf(txtptr+4L,"%2d",pinnum);
     *(txtptr+6L) = ':';
     MyRequest(ERR_REQ,txtptr);
     break;
   case  5:
     txtptr = (UBYTE *)"Pin xx: VCC/GND am falschen Pin";
     sprintf(txtptr+4L,"%2d",pinnum);
     *(txtptr+6L) = ':';
     MyRequest(ERR_REQ,txtptr);
     break;
   case  6:
     txtptr = (UBYTE *)"Pin xx: illegales '/'";
     sprintf(txtptr+4L,"%2d",pinnum);
     *(txtptr+6L) = ':';
     MyRequest(ERR_REQ,txtptr);
     break;
   case  7:
     txtptr = (UBYTE *)"Pin xx: GND erwartet";
     sprintf(txtptr+4L,"%2d",pinnum);
     *(txtptr+6L) = ':';
     MyRequest(ERR_REQ,txtptr);
     break;
   case  8:
     txtptr = (UBYTE *)"Pin xx: VCC erwartet";
     sprintf(txtptr+4L,"%2d",pinnum);
     *(txtptr+6L) = ':';
     MyRequest(ERR_REQ,txtptr);
     break;

 }
}




