*****************************************************************************
*$RevHead_Start                                                             *
*                                                                           *
* Project Details                                                           *
* ---------------                                                           *
* Project Name:    SetPrefs                                                 *
* Project Version: 0.00                                                     *
* Copyright:       © David M. Balean, 1992                                  *
* Date:            Thursday 9th November 1989                               *
* Start DateStamp: 09-Nov-1989 01.42.00.21                                  *
* Project Manager: David M. Balean                                          *
*                                                                           *
*****************************************************************************
*                                                                           *
* This File:       SetPrefs.s                                               *
*$Author:          David M. Balean                                          *
*$File Version:    0.00                                                     *
*$DateStamp:       09-Nov-1989 01.33.34.25                                  *
*                                                                           *
*****************************************************************************
* File Summary:                                                             *
* Load devs:system-configuration and set preferences.  If impossible, use   *
* default setting.                                                          *
*****************************************************************************
*                                                                           *
* Date        Time         Version Author                                   *
*                                                                           *
* 09-Nov-1989 01.33.34.25  0.00    David M. Balean                          *
*                                                                           *
*$RevHead_End                                                               *
*****************************************************************************
		include	/system			use pre-assembled header

TRUE		equ	-1

start		move.l	#100,d4			Error default

* Get DOS
		lea	dosname(pc),a1
		moveq	#0,d0			any version
		CALLEXEC OpenLibrary
		move.l	d0,_DOSBase		save pointer
		beq.w	exit2

* Get Intuition
		lea	IntName(pc),a1
		moveq	#0,d0			Any version
		CALLEXEC OpenLibrary
		move.l	d0,_IntuitionBase	save the pointer
		beq.w	exit1
		
* Open devs:system-configuration	
		move.l	#fname,d1	
		move.l	#MODE_OLDFILE,d2
		CALLDOS	Open
		move.l	d0,d5			d5 = filehandle
		beq.b	GetDefault
		
* Read devs:system-configuration
		move.l	d0,d1			filehandle
		move.l	#PrefBuffer,d2
		move.l	#pf_SIZEOF,d3
		CALLDOS	Read
		move.l	d0,d6			d6 = length of read

		move.l	d5,d1
		CALLDOS	Close	
	
		cmp.l	#pf_SIZEOF,d6		? correct length
		beq.b	SetConfig

GetDefault	lea	PrefBuffer(pc),a0	If not, get default			
		move.l	#pf_SIZEOF,d0
		CALLINT	GetDefPrefs
		
* Now set preferences		
SetConfig	lea	PrefBuffer(pc),a0			
		move.l	#pf_SIZEOF,d0
		move.l	#TRUE,d1
		CALLINT	SetPrefs

* Close Intuition
		move.l	_IntuitionBase(pc),a1
		CALLEXEC CloseLibrary

* All OK therefore error is zero		
		moveq	#0,d4

* Close DOS
exit1		move.l	_DOSBase(pc),a1
		CALLEXEC CloseLibrary

exit2		move.l	d4,d0
		rts		


dosname		DOSNAME
IntName		INTNAME
fname		dc.b	"devs:system-configuration",0

		EVEN

PrefBuffer	dcb.b	pf_SIZEOF,0
	
_DOSBase	dc.l	0
_IntuitionBase	dc.l	0


		END

