;	SetPubScreen
;
;	written by Michael Watzl in 1992
;
;	this is Public Domain
;

; lazy includes

OpenLib		= -552
Output		= -60
CloseLib		= -414
SetDefaultPubScreen	= -$21C
PutStr		= -948
LockPubScreen	= -$1FE
UnlockPubScreen	= -$204


Title		= 22

TAB	= 09
CR	= 10

******************************************
**				**
**	      MAIN		**
**				**
******************************************

_main	pea	(a0)		; save the argument pointer
	lea	DosName,a1	; open the libs
	move.l	4.w,a6
	moveq	#36,d0		; version
	jsr	OpenLib(a6)	; open dos.library
	tst.l	d0
	beq	_quit
	move.l	d0,_DosBase
	lea	IntName,a1
	move.l	4.w,a6
	moveq	#36,d0		; I think V36 should work
	jsr	OpenLib(a6)
	move.l	d0,_IntBase

	move.l	(sp)+,a0		; fetch argument pointer
	cmp.b	#CR,(a0)		; are any args out there!
	beq	_usage

	pea	(a0)
Loop	cmp.b	#CR,(a0)+
	bne.s	Loop
	move.b	#0,-(a0)
	movea.l	(sp)+,a0

	move.l	_IntBase,a6
	jsr	SetDefaultPubScreen(a6)	Name is alredy in a0

_usage	move.l	_IntBase,a6
	suba.l	a0,a0
	jsr	LockPubScreen(a6)
	move.l	d0,a3
	movea.l	Title(a3),a4	; save the title

	move.l	_DosBase,a6
	move.l	#usage,d1
	jsr	PutStr(a6)
	move.l	#author,d1
	jsr	PutStr(a6)
	move.l	#info,d1
	jsr	PutStr(a6)
	move.l	a4,d1
	jsr	PutStr(a6)
	move.l	#return,d1
	jsr	PutStr(a6)

	move.l	_IntBase,a6
	suba.l	a0,a0
	movea.l	a3,a1
	jsr	UnlockPubScreen(a6)

******************************************
**				**
**                 QUIT		**
**				**
******************************************

_quit	move.l	4.w,a6
	move.l	_DosBase,d0	if(DOSBase)
	tst.l	d0
	beq.s	next1
	movea.l	d0,a1
	jsr	CloseLib(a6)		Close
next1	move.l	_IntBase,d0	if(IntuitionBase)
	tst.l	d0
	beq.s	next2
	movea.l	d0,a1
	jsr	CloseLib(a6)		Close
	moveq	#0,d0
next2	rts			"My only friend, the end" (Doors...)


DosName	dc.b	"dos.library"		; this order saves 2 bytes (Wow!)
_DosBase	dc.l	0
IntName   dc.b	"intuition.library"
_IntBase	dc.l	0

usage	dc.b	"Usage:",TAB,"SetDefaultPubScreen <Name>",CR,TAB,TAB,"name",TAB,"the title of the new default public screen",CR,0
author	dc.b	TAB,TAB,27,"[32mWritten by Michael Watzl in 1992 (PD!)",27,"[31m",CR,0
info	dc.b	"Current default: »",27,"[33m",0
return	dc.b	27,"[31m«",CR,0

