	include	in:sys.i

Size	equ	12
X	equ	-12
Y	equ	-10
Buf	equ	-8

	link	a5,#-Size
	moveq	#20,d7				; This might be return code

	move.l	a5,a0				; Variables - cleanup
	clr.l	-(a0)
	clr.l	-(a0)
	clr.l	-(a0)

	move.l	4.w,d5
	move.l	d5,a6
	lea	inName(PC),a1
	moveq	#36,d0
	jsr	_LVOOpenLibrary(a6)		; ** Opening intuition.library
	move.l	d0,-(SP)
	beq	Fatal

	move.l	d0,a6				; intuition
	lea	WBName(PC),a0
	jsr	_LVOLockPubScreen(a6)
	tst.l	d0				; screen struct. of Workbench
	beq.s	clintu

	move.l	d0,a3				; A3 = screen

	move.l	d5,a6
	lea	dosName(PC),a1
	moveq	#36,d0
	jsr	_LVOOpenLibrary(a6)		; ** Opening dos.library
	move.l	d0,d6
	beq.s	clintu
	move.l	d6,a6

	lea	Templ(PC),a0			; Shell Template
	move.l	a0,d1
	lea	Buf(a5),a2			; Result
	move.l	a2,d2
	moveq	#0,d3				; Some optional arg
	jsr	_LVOReadArgs(a6)		; ** Reading command line
	move.l	d0,-(SP)			; Preparing for FreeArgs

	lea	X(a5),a1			; Here setting A1 !
	move.l	(a2)+,d0			; Address of PlusX => D0
	beq.s	NoArg				; Not set ?
	move.l	d0,a0				; Listen BATHORY - Blood on Ice ! Great music !
	move.w	2(a0),(a1)			; Setting X from 'PlusX'
	move.l	(a2),d0				; Address of PlusY
	beq.s	NoArg				; Not set ?
	move.l	d0,a0				; Input is in LONG,  so 2(a0)=WORD
	move.w	2(a0),Y(a5)			; Setting Y from 'PlusY'

NoArg	move.w	sc_LeftEdge(a3),d0		; Computing X
	sub.w	d0,(a1)+
	move.w	sc_TopEdge(a3),d0		;	and Y
	sub.w	d0,(a1)

	lea	PosYName(pc),a4			; A1 allready set
	bsr.s	SVar				; Set Y Position
	subq	#5,a4				; = lea	PosXName(pc),a4
	lea	X(a5),a1			; X ...
	bsr.s	SVar				; into PosX

	move.l	(SP)+,d1
	jsr	_LVOFreeArgs(a6)		; Release memory

	move.l	(SP),a6
	lea	WBName(pc),a0
	sub.l	a1,a1
	jsr	_LVOUnlockPubScreen(a6)		; ** I do not need it nevermore

	move.l	d6,a1
	move.l	d5,a6
	jsr	_LVOCloseLibrary(a6)		; ** Closing dos

	moveq	#0,d7				; All went OK...  RC=0

clintu	move.l	(SP),a1
	move.l	d5,a6
	jsr	_LVOCloseLibrary(a6)		; ** Closing intuition

Fatal	move.l	d7,d0
	unlk	a5				; This sets SP to the right value
	rts


SVar	lea	Fmat(PC),a0			; Format string
						; in A1 is pointer to valuea
	lea	OneChar(PC),a2			; Routine for every char
	lea	Buf(a5),a3			; Where to write
	move.l	d5,a6
	jsr	_LVORawDoFmt(a6)		; ** Decimal conversion

	move.l	a4,d1				; Name of local variable
	lea	Buf(a5),a0
	move.l	a0,d2				; Value in decadic
	moveq	#4,d3				; Only 4 digits
	moveq	#0,d4				; The variable will be local
	move.l	d6,a6
	jmp	_LVOSetVar(a6)			; ** Set local variable and RTS


OneChar	move.b	d0,(a3)+			;Put data to output string
	rts

Fmat	dc.b	'%d',0
WBName	dc.b	'Workbench',0
inName	dc.b	'intuition.library',0
dosName	dc.b	'dos.library',0
PosXName dc.b	'PosX',0
PosYName dc.b	'PosY',0
Version	dc.b	'$VER: WB Screen POSition 1.1 (29/08/96)',0
Templ	dc.b	'PlusX/N,PlusY/N',0
