*********************************************************
*							*
* UD.a - Unlocks the current directory and sets it to	*
*	the root of the initial startup disk (normally	*
*	DF0:						*
*							*
* usage: UD	(no other parameters needed)		*
*							*
* a freely-redistributable program			*
*							*
* by: W. Wesley Howe  (bix: whowe  plink: WHOWE)	*
*							*
*     31-Jul-88						*
*							*
*********************************************************
*
* Assembled with CAPE 2.0
*
	EXEOBJ
	NORMOBJ		;we don't want PC-relative references to data
*
* First some equates to eliminate includes...
*
AbsExecBase	EQU	4		;THE fixed location in the Amiga
*
OldOpenLibrary	EQU	-408		;needed exec library offsets
CloseLibrary	EQU	-414
*
UnLock		EQU	-90		;DOS library offsets needed
CurrentDir	EQU	-126
*
	CODE
*************************************************************************
*									*
* This routine is the whole program. We will set the current directory	*
* to the root of the filing system (the boot disk), and unlock the old	*
* current directory, unless is already was the root.			*
*									*
************************************************************************* 
UD:	move.l	a6,-(sp)		;save registers per convention
	movea.l	AbsExecBase,a6
	moveq	#0,d0			;any version of DOS is O.K.
	lea	DOSName(PC),a1		;name of our library
	jsr	OldOpenLibrary(a6)	;compatible with older DOS versions
	tst.l	d0			;a zero means we didn't find DOS
	beq.s	998$			;big problem - no DOS
	movea.l	d0,a6
	moveq	#0,d1
	jsr	CurrentDir(a6)		;set to root and get old lock
	tst.l	d0
	beq.s	10$			;already at root directory
	move.l	d0,d1
	jsr	UnLock(a6)		;unlock old current dir
10$:	movea.l	a6,a1
	movea.l	AbsExecBase,a6
	jsr	CloseLibrary(a6)	;close the DOS library
	moveq	#0,d0			;success return code
	bra.s	999$
998$:	moveq	#20,d0			;failure return code
999$:	move.l	(sp)+,a6		;restore the register we saved
	rts				;this takes us back to DOS
*************************************************************************
*									*
* Our only instance of static data.					*
*									*
*************************************************************************
DOSName:
	CSTRING	'dos.library'
	DS.W	0
*
		END
*

