;
; banner.sh
;
; A startup banner window
;
;  1994-1998 Straylight
;

;----- Licensing note -------------------------------------------------------
;
; This file is part of Straylight's Sapphire library.
;
; Sapphire is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2, or (at your option)
; any later version.
;
; Sapphire is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with Sapphire.  If not, write to the Free Software Foundation,
; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

;----- Overview -------------------------------------------------------------
;
; Functions provided:
;
;  banner
;  bnr_doBanner

		[	:LNOT::DEF:banner__dfn
		GBLL	banner__dfn

;+		LIB	sapphire:^.bsh.banner

; --- banner ---
;
; On entry:	R0 == pointer to definition block, or 0
;		R1 == R12 value to pass to setup routine, if present
;
; On exit:	--
;
; Use:		Displays a startup banner and initialises the library and
;		client.  This call should be used as a replacement for
;		sapphire_libInit.
;
;		If R0 is 0 on entry, no banner window is used; instead
;		an hourglass percentage is displayed to indicate the
;		amount of initialisation performed so far.
;
;		Alternatively, it should point to a table consisting of
;		a flags word and optional arguments specified by the flags
;		in order.  The options you can specify are a slider and
;		percentage count icon (used to display current progress),
;		a setup routine, and the leafname of a sprites file to
;		attach to the banner window.
;
;		The setup routine is passed the banner dialogue handle in
;		R0.  It should fill in parts of the banner window, such as
;		the licencee name and serial number that can't be determined
;		until runtime (for safeness), and maybe version information
;		too.

		IMPORT	banner

; --- bnr_doBanner ---
;
; On entry:	R0 == pointer to definition block, or 0
;		R1 == R12 value to pass to setup routine, if present
;		R2 == pointer to library initialisation table
;
; On exit:	--
;
; Use:		Displays a startup banner and initialises the library and
;		client.  This routine is used to support dynamic linking.

		IMPORT	bnr_doBanner

;----- Flags ----------------------------------------------------------------

bFlag_slider	EQU	(1<<0)			;Has a progress slider
						;+0 icon number for slider
						;+4

bFlag_counter	EQU	(1<<1)			;Has a percentage indicator
						;+0 icon number for indicator
						;+4

bFlag_setup	EQU	(1<<2)			;Needs a setup routine
						;+0 == address of routine
						;+4

bFlag_sprites	EQU	(1<<3)			;Load a sprite file
						;+0 == name of sprite file
						;+n

;----- Macros ---------------------------------------------------------------

		GBLA	bnr__f
		GBLA	bnr__c
bnr__c		SETA	0

; --- Macro: BANNER ---
;
; Arguments:	--
;
; Use:		Begins construction of a banner block.

		MACRO
$label		BANNER
bnr__f		SETA	0
		ALIGN
$label
		DCD	bnr__fl$bnr__c
		MEND

; --- Macro: BFLAG ---
;
; Arguments:	f == flag to set
;
; Use:		Sets a flag in the banner header, making sure they go in
;		order.

		MACRO
		BFLAG	$f
		[	bnr__f >= $f
		!	1,"Banner flags built in wrong order"
		]
bnr__f		SETA	bnr__f :OR: $f
		MEND

; --- Macro: BNSLIDE ---
;
; Arguments:	icon == icon number of slider in banner window
;
; Use:		Registers the banner window's slider.

		MACRO
		BNSLIDE	$icon
		BFLAG	bFlag_slider
		DCD	$icon
		MEND

; --- Macro: BNCOUNT ---
;
; Arguments:	icon == icon number of percentage counter
;
; Use:		Registers the banner window's percentage counter.

		MACRO
		BNCOUNT	$icon
		BFLAG	bFlag_counter
		DCD	$icon
		MEND

; --- Macro: BNSETUP ---
;
; Arguments:	rout == address of setup routine
;
; Use:		Registers the banner window's setup routine.

		MACRO
		BNSETUP	$rout
		BFLAG	bFlag_setup
		DCD	$rout
		MEND

; --- Macro: BNSPRT ---
;
; Arguments:	name == leafname of sprite file
;
; Use:		Registers the banner window's sprite file name.

		MACRO
		BNSPRT	$name
		BFLAG	bFlag_sprites
		DCB	"$name",0
		MEND

; --- Macro: BNEND ---
;
; Arguments:	--
;
; Use:		Terminates a banner window definition.

		MACRO
		BNEND
		ALIGN
bnr__fl$bnr__c	EQU	bnr__f
bnr__c		SETA	bnr__c+1
		MEND

		]

;----- That's all, folks ----------------------------------------------------

		END
