*
*	EasyColor_Demo
*	by Preben Nielsen
*
*
*	Tests the EasyColor routine
*
*	Linked as 'blink EasyColor_Demo.o EasyColor.o TO EasyColor'
*
*  Made with Hisoft Devpac V2.12
*

	OPT O+
	OPT O1+		; Tells when a branch could be optimised to short
	OPT i+		; Tells when '#' is probably missing

		incdir		"AsmInc:"
		include		"EasyColor.i"
		include		"P.i"
		include		"exec/exec_lib.i"
		include		"intuition/intuitionbase.i"
		include		"libraries/dosextens.i"

		XREF		_EasyColor
		XREF		_EasyColorA
		

CStyle		; If you remove this line then EasyColorA will be
		; called with arguments in registers.


WBMsg		EQUR		D2
IntuiBase	EQUR		D3

Start		Prepare		Exec_Call
		moveq		#0,WBMsg
		suba.l		A1,A1
		CallLib		FindTask		; Find us
		move.l		D0,A2
		tst.l		pr_CLI(A2)
		bne.S		DoColors
		lea		pr_MsgPort(A2),A0	; Started from WB !
		CallLib		WaitPort
		lea		pr_MsgPort(A2),A0
		CallLib		GetMsg
		move.l		D0,WBMsg
DoColors	lea		IntuiName(PC),A1
		CallLib		OldOpenLibrary
		move.l		D0,IntuiBase
		beq.S		Exit
		move.l		IntuiBase,A0
	IFD CStyle
*»»» Call EasyColor with arguments on stack (C style)
		pea		12.W			; Move the number 12 onto the stack
		pea		16.W			; Move the number 16 onto the stack
		pea		Title(PC)
		move.l		ib_FirstScreen(A0),-(SP)
		jsr		_EasyColor
		lea		16(SP),SP		; Remove arguments
	ENDC
	IFND CStyle
*»»» Call EasyColorA with arguments in registers stack (assembler style)
		moveq		#12,D1
		moveq		#16,D0
		lea		Title(PC),A1
		move.l		ib_FirstScreen(A0),A0
		jsr		_EasyColorA
	ENDC
Exit		Prepare		Exec_Call
		tst.l		IntuiBase
		beq.S		ReplyWB
		move.l		IntuiBase,A1
		CallLib		CloseLibrary
ReplyWB		tst.l		WBMsg
		beq.S		AllDone
		CallLib		Forbid
		move.l		WBMsg,A1
		CallLib		ReplyMsg		; Reply WBMsg if we are started from WB
AllDone		moveq		#0,D0
		rts

Title		dc.b		'Change the colors please',0
IntuiName	dc.b		'intuition.library',0
		END

