;: pronet-page.s
;:
;: Macht auf dem anderen Amiga einen 'DisplayAlert' !!
;:
;: 27-10-94
;:
;: 18-06-95	unitnumber argument. v34.0

		include	"exec/exec.i"
		include	"A:ProNET/include/devices/pronet.i"
		include	"A:ProNET/source/network.i"
		include	"exec_lib.i"
		include	"A:OSmacros.i"

j		cmp.l	#2,d0
		bcs.s	nopronet

		lea	buffer,a1
.lp		move.b	(a0)+,(a1)+
		subq.l	#1,d0
		bne.s	.lp
		clr.b	(a1)+

		lea	buffer,a0
		bsr	dec2long
		move.l	d1,unit

		move.l	a0,a5
		moveq	#-1,d5
.count		tst.b	(a0)+
		dbeq	d5,.count
		neg.w	d5
		subq.w	#1,d5
		ext.l	d5

		move.l	4.w,a6
		bsr	startpronet
		tst.w	d0
		bne	nopronet

		move.l	4.w,a6
		move.l	pronetio(pc),a1
		move.w	#0,pnr_NetDestPort(a1)
		move.w	#PND_WRITE,IO_COMMAND(a1)
		move.l	#testbuf,pnr_Data1(a1)
		move.l	#4,pnr_Length1(a1)
		move.l	a5,pnr_Data2(a1)
		move.l	d5,pnr_Length2(a1)
		LIBCALL	DoIO

		bsr	stoppronet
nopronet	moveq	#0,d0
		rts

		dc.b	"$VER: pronet-page 34.0 (18-06-95)",13,10,0
		even

startpronet	moveq	#pnr_Size,d0
		bsr	GetIORequest
		move.l	d0,pronetio
		beq	spnoioreq
		bsr	CreatePort
		move.l	d0,msgport
		beq	spnomsgport
		lea	pronetname,a0
		move.l	unit(pc),d0
		moveq	#0,d1
		move.l	pronetio(pc),a1
		move.w	#PNP_NEXTFREE,pnr_NetSourcePort(a1)
		move.l	msgport(pc),pnr_MsgPort(a1)
		move.l	4.w,a6
		LIBCALL	OpenDevice
		tst.l	d0
		bne	spnodev
		moveq	#0,d0
		rts

stoppronet	move.l	4.w,a6
		move.l	pronetio(pc),a1
		LIBCALL	CloseDevice
spnodev		move.l	msgport(pc),a0
		bsr	DeletePort
spnomsgport	move.l	pronetio(pc),a0
		bsr	FreeIORequest
spnoioreq	moveq	#-1,d0
		rts

pronetname	dc.b	"pronet.device",0
		even
testbuf		dc.l	ACTION_PAGE

pronetio	dc.l	0
msgport		dc.l	0
unit		dc.l	0

dec2long	; konvertiert Dezimalstring ab (a0) zu Longword in D1 !!
		moveq	#0,d1
.loop		moveq	#0,d0
		move.b	(a0)+,d0
		sub.b	#"0",d0
		cmp.b	#9,d0
		bhi.s	.oki
		move.l	d1,d2
		lsl.l	#3,d1
		add.l	d2,d1
		add.l	d2,d1
		add.l	d0,d1
		bra.s	.loop
.oki		rts

		include	"A:ProNET/source/devio.s"

		section	b,bss

buffer		ds.b	256
