*****************************************
*		MicroGuide		*
*	Small AmigaGuide-viewer		*
*	V1.0 by Martin Gierich		*
*	uj3w@rz.uni-karlsruhe.de	*
*	Last change:02.03.95		*
*****************************************

;Copyright: Public Domain, use it at your own risk !
;Usage (CLI only): microguide <filename>
; Spaces in the filename are OK, but do not enclose it in quotes and
; do not include unneccessary spaces around the filename.

;This is optimized for size, please tell me if you know how to make
;it even smaller. It is now 132 bytes long.
;Look out for my 488 bytes MiniXpkGuide with XPK- and WB-support.

;Tabsize=8
;Local labels named .A to .C

;exec.library
_LVOOldOpenLibrary	= -408
_LVOCloseLibrary	= -414

;amigaguide.library
_LVOOpenAmigaGuideA	= -54
_LVOCloseAmigaGuide	= -66

	RSRESET
;NewAmigaGuide-structure
nag_Lock	RS.L	1	Lock on the document directory
nag_Name	RS.L	1	Name of document file
nag_Screen	RS.L	1	Screen to place windows within
nag_PubScreen	RS.L	1	Public screen name to open on
nag_HostPort	RS.L	1	Application's ARexx port name
nag_ClientPort	RS.L	1	Name to assign to the clients ARexx port
nag_BaseName	RS.L	1	Base name of the application
nag_Flags	RS.L	1	Flags
nag_Context	RS.L	1	NULL terminated context table
nag_Node	RS.L	1	Node to align on first (defaults to Main)
nag_Line	RS.L	1	Line to align on
nag_Extens	RS.L	1	Tag array extens
nag_Client	RS.L	1	Private! MUST be NULL
NewAmigaGuide_SIZEOF	RS.W	0


;Entry:	a0=pointer to LF-ended argumentline
;	d0=length of argument-line
start:	moveq	#20,d3		;set return-code to FAIL
	clr.b	-1(a0,d0.l)	;null-end argumentline
	moveq	#NewAmigaGuide_SIZEOF/4-1,d0
.C	clr.l	-(sp)		;get some space for nag
	dbra	d0,.C
	move.l	a0,nag_Name(sp)	;argumentline into nag

	move.l	4.w,a6		;exec-base to a6
	lea	GuideName(pc),a1
	jsr	_LVOOldOpenLibrary(a6)
	tst.l	d0
	beq.s	.B		;opened amigaguide.library ?
	move.l	d0,a6
	move.l	sp,a0		;nag to a0
	sub.l	a1,a1		;must be zero
	jsr	_LVOOpenAmigaGuideA(a6)	;open guide
	tst.l	d0
	beq.s	.A		;failed to open guide ?
	move.l	d0,a0
	jsr	_LVOCloseAmigaGuide(a6)	;wait till user closes guide
	moveq	#0,d3		;set return-code to OK
.A	move.l	a6,a1		;Free all stuff
	move.l	4.w,a6
	jsr	_LVOCloseLibrary(a6)
.B	lea	NewAmigaGuide_SIZEOF(sp),sp
	move.l	d3,d0		;set return-code
	rts			;THE END !

GuideName	dc.b	"amigaguide.library",0

