	section	Expunge,CODE
	IDNT	ALL

**	LoadM68
**		for pre-loading the macro68.library during startup
**
**		Copyright ©1990 DigiSoft
**
**	Permission is granted to purchasers of Macro68 to modify this source
**	file.  Permission is further granted to distribute the source code that
**	they have modified subject to the following conditions:
**	1.  That the original, unaltered, source is included with the
**	    distribution.
**	2.  That no charge is made for the distribution, other than the cost of
**	    media.                    (Distribution via Fred Fish is permitted)
**	3.  That my copyright notice remains as part of this and any other
**	    file adapted from this file.
**                                               Paul Coward
**                                                         DigiSoft
**
**	Tabstops : 8
**	Assemble with Macro68


**	 2-08-90	** written


		OBJFILE		"ram:LoadM68"
	;	ERRORFILE	"ram:LoadM68.bugs"

	;	PALL
	;	HALL
		EXEOBJ
	;	LIST
	;	LISTSYMS
	;	ADDSYM
	;	LISTFILE	"ram:LoadM68.lst"
	;	CREFFILE	"ram:LoadM68.cref"
	;	DEBUG
		REALTIME
		STRICT


	ifnd	EXEC_TYPES_I
	if1
	PRINTX	Resident maclib not in use.
	endc
_AbsExecBase		equ	4
_LVOAlert		equ	-108	;exec
_LVOCloseLibrary	equ	-414	;exec
_LVOOpenLibrary		equ	-552	;exec
RETURN_OK		equ	0
RETURN_FAIL		equ	20
AT_Recovery		equ	$00000000
AG_OpenLib		equ	$00030000
	endc


	ifnd	csd_DSSBase
csd_DSSBase		equ	16
csd_IntuitionBase	equ	8
AO_DSSLib		equ	$00008099	;alert number id support library can't be opened
Tab			equ	$09
Lf			equ	$0a
CSI			equ	$9b
	endc

csd_SIZEOF		equ	84


Release			equ	'1.0 '
VerNo			equ	'0.01'

*************************
*	COLD ENTRY	*
*************************


START:		moveq		#9,d0			;version #
		lea	 	(macro68LibName,pc),a1	;point to library name
		movea.l		(_AbsExecBase).w,a6
		jsr		(_LVOOpenLibrary,a6)	;exec
		tst.l		d0
		bne.b		.m68LibOpen
		lea		(intuitionLibName,pc),a1
		jsr		(_LVOOldOpenLibrary,a6)
		tst.l		d0
		bne.b		.intuitionAvailable
		move.l		#AT_Recovery!AG_OpenLib!AO_Intuition,d7
		jsr		(_LVOAlert,a6)
		moveq		#RETURN_FAIL,d0
		rts

.intuitionAvailable:
		lea.l		(m68LibLost_AlertMsg,pc),a0
		moveq		#0,d0
		moveq		#50,d1
		jsr		(_LVODisplayAlert,a6)
		movea.l		a6,a1
		movea.l		(_AbsExecBase).w,a6
		jsr		(_LVOCloseLibrary,a6)
		moveq		#RETURN_FAIL,d0
		rts					;exit to DOS

.m68LibOpen:	movea.l		d0,a6
		moveq		#8,d2
		jsr		(-84,a6)
		movea.l		a6,a1
		movea.l		(_AbsExecBase).w,a6
		jsr		(_LVOCloseLibrary,a6)
		moveq		#RETURN_OK,d0
		rts					;exit to DOS


***************************************
***************************************
***************************************


	oddok

macro68LibName:
	cstr	'macro68.library'
intuitionLibName:
	cstr	'intuition.library'


m68LibLost_AlertMsg:
	dw	169
	db	15
	db		'macro68.library -------- MISSING',0
	db	-1
	dw	43
	db	35
	db		'LEFT = OK',0
	db	-1
	dw	489
	db	35
	db		'RIGHT = RETRY',0,0
	odderror


*******************************************************************************

	END
