****************************************************************************
*                             Shrink.asm                                   *
*                        Author: Buddy Retter                              *
*                                                                          *
*     Shrinks the current window (usually the CLI window) to its smallest  *
*  size.  This program was written to allow the automatic shrinking of a   *
*  window by a Startup-Sequence file on a VIP Professional disk.           *
****************************************************************************
	NOL

;	INCLUDE "intuition/intuitionbase.i"
;	INCLUDE "intuition/intuition.i"

	LIST

	XREF _AbsExecBase
	XREF _LVOOpenLibrary
	XREF _LVOCloseLibrary
	XREF _LVOSizeWindow

ib_ActiveWindow	EQU $34
wd_Width	EQU $08
wd_MinWidth	EQU $10
wd_Height	EQU $0A
wd_MinHeight	EQU $12

	move.l	_AbsExecBase,a6		;get address into a6 for indirect
	move.l	#intname,a1		;move address of name into a1
	clr.l	d0
	jsr	_LVOOpenLibrary(a6)	;open it
	move.l	d0,a6
	tst.l	d0
	beq	Abort

	move.l	ib_ActiveWindow(a6),a0

	move.w	wd_Width(a0),d0		; get current width
	sub.w	wd_MinWidth(a0),d0	; subtract minimum width
	neg.w	d0			; convert to negative offset
	move.w	wd_Height(a0),d1	; ditto for height
	sub.w	wd_MinHeight(a0),d1
	neg.w	d1

	jsr	_LVOSizeWindow(a6)	; do it

	movea.l	a6,a1			; cleanup
	move.l	4,a6
	jsr	_LVOCloseLibrary(a6)

Abort	clr.l	d0
	rts

	CNOP	0,4
intname	dc.b	'intuition.library',0
