	xref	_timeout
	xref	_Chk_Abort
	xref	_fh
	xref	_getc
	xref	_Konvert
	xref	_fread
	xref	_Flag
	xref	_feof
	xref	_tabelle

;int transfer(UBYTE * data, char Option)
;{
	xdef	_transfer
_transfer:
	link	a5,#.31
	movem.l	a2-a3,-(a7)
	lea.l	_tabelle,a2
	sub.l	#128,a2
;    static       anf = 0;
	dseg
	ds	0
.32
	dc.l	$0000
	cseg
;    register int i,c;
;    int          flag;
;
;    timeout();
;   anf .32 "l"
;   i -4 "l"
;   c -8 "l"
;   flag -12 "l"
;   data 8 "*C"
;   Option 12 "c"
	move.l	d3,-4(a5)
	jsr	_timeout
;    Chk_Abort();
	jsr	_Chk_Abort
;    *data++ = 0;
	move.l	8(a5),a3
	clr.b	(a3)+
;    if (Option != 'B')
;    {
	cmp.b	#66,12(a5)
	beq	.10029
;        if (anf == 1)
;        {
	cmp.l	#1,.32
	bne	.10030
;            *data++ = 10;
	move.b	#10,(a3)+
;        }
;        for(i = anf; i < 128; i++)
.10030
	move.l	.32,d3
	bra	.10032
.10031
	addq.l	#1,d3
.10032
	cmp.l	#128,d3
	bge	.10033
;        {
;            c = getc(fh);
	move.l	_fh,-(sp)
	jsr	_getc
	add.w	#4,sp
	move.l	d0,-8(a5)
;            if (c == EOF)
;            {
	cmp.l	#-1,-8(a5)
	bne	.10034
;                break;
	bra	.10033
;            }
;            *data++ = Konvert(c,Option,(int *) &flag);
.10034
	pea	-12(a5)
	move.b	12(a5),-(sp)
	move.l	-8(a5),-(sp)
	jsr	_Konvert
	lea	10(sp),sp
	move.b	d0,(a3)+
;            if (flag)
;            {
	tst.l	-12(a5)
	beq	.10035
;                *data++ = 10;
	move.b	#10,(a3)+
;                i++;
	addq.l	#1,d3
;            }
;        }
.10035
	bra	.10031
.10033
;    }
;    else
	bra	.10036
.10029
;    {
;        i = fread((void *) data,sizeof(char),128,fh);
	move.l	_fh,-(sp)
	pea	128
	pea	1
	move.l	a3,-(sp)
	jsr	_fread
	lea	16(sp),sp
	move.l	d0,d3
;        data += i;
	add.l	d3,a3
;    }
.10036
;    data -= i;
	sub.l	d3,a3
;    data--;
	subq.l	#1,a3
;    *data = (i < 129) ? i : 128;
	cmp.l	#129,d3
	bge	.33
	move.l	d3,d0
	bra	.34
.33
	move.l	#128,d0
.34
	move.b	d0,(a3)
	move.l	_Flag,a3
;    if (i < 128)
;    {
	cmp.l	#128,d3
	bge	.10037
;        *Flag = LASTDATA;
	move.b	#48,(a3)
;        if (*Flag != LASTDATA && *Flag != 0)
;        {
	cmp.b	#48,(a3)
	beq	.10038
	tst.b	(a3)
	beq	.10038
;            *Flag = EMERGENCY;
	move.b	#80,(a3)
;        }
;        return(FALSE);
.10038
	move.l	#0,d0
.35
	move.l	-4(a5),d3
	movem.l	(a7)+,a2-a3
	unlk	a5
	rts
;    }
;    else if (i == 129)
.10037
;    {
	cmp.l	#129,d3
	bne	.10039
;        *Flag = NEWDATA;
	move.b	#32,(a3)
;        if (*Flag != NEWDATA && *Flag != 0)
;        {
	cmp.b	#32,(a3)
	beq	.10040
	tst.b	(a3)
	beq	.10040
;            *Flag = EMERGENCY;
	move.b	#80,(a3)
;        }
;        anf = 1;
.10040
	move.l	#1,.32
;        return(TRUE);
	move.l	#1,d0
	bra	.35
;    }
;    else
.10039
;    {
;        anf = 0;
	clr.l	.32
;        if (feof(fh))
;        {
	move.l	_fh,-(sp)
	jsr	_feof
	addq.w	#4,sp
	tst.l	d0
	beq	.10041
;            *Flag = LASTDATA;
	move.b	#48,(a3)
;            if (*Flag != LASTDATA && *Flag != 0)
;                *Flag = EMERGENCY;
	cmp.b	#48,(a3)
	beq	.10042
	tst.b	(a3)
	beq	.10042
	move.b	#80,(a3)
;            return(FALSE);
.10042
	moveq	#0,d0
	bra	.35
;        }
;        *Flag = NEWDATA;
.10041
	move.b	#32,(a3)
;        if (*Flag != NEWDATA && *Flag != 0)
;            *Flag = EMERGENCY;
	cmp.b	#32,(a3)
	beq	.10043
	tst.b	(a3)
	beq	.10043
	move.b	#80,(a3)
;        return(TRUE);
.10043
	moveq	#1,d0
	bra	.35
;    }
;    return(FALSE);
	moveq	#0,d0
	bra	.35
;}
.30
.31	equ	-12
;
