;----------------------------------------------------------------------------
;File name:	UNCOMPRE.S			Revision date:	1997.07.27
;C->S Port by:	Ulf Ronald Andersson		Port begun:	1996.08.02
;Original C by:	Dan Ackerman & Steve Adam
;----------------------------------------------------------------------------
;
	include	"uran\STRUCT.SH"
	include	"uran\URAn_SYS.SH"
	include	"stik\CSLIP_HD.SH"
	include	"stik\GLOBDEFS.SH"
;
;----------------------------------------------------------------------------
;
	XREF	slc_type
	XREF	slc_unco
;
;----------------------------------------------------------------------------
;
uncompre:				;short uncompress (b, slp)
;					;GPKT *b; struct slip *slp; {
	XDEF	uncompre		;extern short uncompress (GPKT *b, struct slip *slp);
	lv_init	a6			;link local variables through a6
	movem.l	d3-d7/a2-a5,-(sp)	;protect entry registers for Pure_C
;Pure_C_def;	movea.l	8(a6),a0	;reg a0 has 'b'
;Pure_C_def;	movea.l	12(a6),a1	;reg a1 has 'slp'
;
;erase each ';Pure_C_def;' sequence above for CDECL function
;
	movea.l	a0,a5			;reg a5 is GPKT *b           (arg 1)
	movea.l a1,a4			;reg a4 is struct slip *slp  (arg 2)
;---------------------------------------;reg d7 is octet type
;
	jsr	slc_type
	move	d0,d7			;type = slc_type(b);
;
;					;switch (type) {
	cmpi.b	#TYPE_IP,d7
	bne.s	.past_IP		;case TYPE_IP:
	clr.l	d0
	bra	.exit			;  return 0;
;
.past_IP:
	cmpi.b	#TYPE_COMPRESSED_TCP,d7
	bne.s	.past_COMPRESSED_TCP	;case TYPE_COMPRESSED_TCP:
	move	slip_flags(a4),d0
	andi	#SLF_COMPRESS,d0
	beq.s	.done_SLF_COMPRESS_1	;  if (slp->flags & SLF_COMPRESS) {
;
	move.l	a5,a0
	clr.l	d0
	move.b	d7,d0
	move.l	slip_comp(a4),a1
	jsr	slc_unco
	moveq	#0,d1
	tst.l	d0
	bne.s	.keep_d1_1
	moveq	#1,d1
.keep_d1_1:
	move.l	d1,d0
	bra.s	.exit			;    return !slc_uncompress (b, type, slp->comp); }
;
.done_SLF_COMPRESS_1:
	bra.s	.break_switch		;  break;
;
.past_COMPRESSED_TCP:
	cmpi.b	#TYPE_UNCOMPRESSED_TCP,d7
	bne.s	.past_UNCOMPRESSED_TCP	;case TYPE_UNCOMPRESSED_TCP:
	move	slip_flags(a4),d0
	andi	#SLF_COMPRESS,d0
	beq.s	.done_SLF_COMPRESS_2	;  if (slp->flags & SLF_COMPRESS) {
;
	move.l	a5,a0
	clr.l	d0
	move.b	d7,d0
	move.l	slip_comp(a4),a1
	jsr	slc_unco
	moveq	#0,d1
	tst.l	d0
	bne.s	.keep_d1_2
	moveq	#1,d1
.keep_d1_2:
	move.l	d1,d0
	bra.s	.exit			;    return !slc_uncompress (b, type, slp->comp); }
;
.done_SLF_COMPRESS_2:
	move	slip_flags(a4),d0
	andi	#SLF_AUTOCOMP,d0
	beq.s	.not_AUTOCOMP			;if (slp->flags & SLF_AUTOCOMP &&
	move.l	a5,a0
	clr.l	d0
	move.b	d7,d0
	move.l	slip_comp(a4),a1
	jsr	slc_unco
	tst.l	d0
	beq.s	.not_AUTOCOMP			;    slc_uncompress (b, type, slp->comp)) {
	ori	#SLF_COMPRESS,slip_flags(a4)	;  slp->flags |= SLF_COMPRESS;
	clr.l	d0
	bra.s	.exit				;  return 0; }
;
.not_AUTOCOMP:
	bra.s	.break_switch			;break;
;
	nop	;just here to avoid a redundant short branch warning
;
.past_UNCOMPRESSED_TCP:			;}
.break_switch:
	moveq	#1,d0			;return 1; }
.exit:
	movem.l	(sp)+,d3-d7/a2-a5	;restore entry registers for Pure_C
	lv_exit	a6			;unlink local variables through a6
	rts
;
;----------------------------------------------------------------------------
;End of file:	UNCOMPRE.S
;----------------------------------------------------------------------------
