
********************************************************************************
*
* 	Dummy1 - A test program for the KISSED demo
*
*	copyright Keith Enge  Dec 20 1990
*
********************************************************************************


	opt	p=68030

	xref	_LVOOpenLibrary,_LVOOpenScreen,_LVOOpenWindow,_LVOForbid
	xref	_LVOGetMsg,_LVOReplyMsg,_LVOCloseWindow,_LVODelay
	xref	_LVOCloseScreen,_LVOCloseLibrary,_LVOFindTask,_LVOWaitPort
	xref	_LVOMove,_LVOText


*	the following incdir and includes are designed for the batch file
*	 copyrad.bat

	incdir	"ram:"

	include	"exec/types.i"		;macros
	include	"intuition/screens.i"	;window stuff
	include "intuition/intuition.i"	;window stuff
	include "libraries/dos.i"	;warnings
	include	"libraries/dosextens.i"	;pr_CLI


	text,public

mytext:
	move.l	(4).w,a6
	sub.l	a1,a1
	jsr	_LVOFindTask(a6)
	move.l	#thistask,a4
	move.l	d0,(a4)
	move.l	d0,a2			;our task =>a2

	tst.l	pr_CLI(a2)
	bne.s	fromcli			;go if program run from CLI
	lea	pr_MsgPort(a2),a0
	jsr	_LVOWaitPort(a6)	;wait for workbench message
	lea	pr_MsgPort(a2),a0
	jsr	_LVOGetMsg(a6)			; and get it
	move.l	d0,startmsg-thistask(a4)	;save it for later reply upon exit

fromcli:
	moveq	#RETURN_FAIL,d7
	lea	libdos(pc),a1
	moveq	#33,d0
	jsr	_LVOOpenLibrary(a6)
	move.l	d0,dosbase-thistask(a4)	;dos base =>dosbase
	beq	nolibdos
	lea	libint(pc),a1
	moveq	#33,d0			;kickstart 1.2
	jsr	_LVOOpenLibrary(a6)
	move.l	d0,intbase-thistask(a4)	;intuition base =>intbase
	beq	nolibint
	move.l	d0,a6			;		=>a6
	move.l	#myscreen,a0
	jsr	_LVOOpenScreen(a6)
	move.l	d0,scrptr		;place screen ptr into window structure
	move.l	d0,a3			; =>a3
	beq	noscreen
	move.l	#mywindow,a0
	jsr	_LVOOpenWindow(a6)
	move.l	d0,winptr-thistask(a4)	;window ptr =>winptr,d4
	move.l	d0,d4
	beq	nowindow

	lea	graftext(pc),a1
	moveq	#33,d0
	move.l	(4).w,a6
	jsr	_LVOOpenLibrary(a6)
	move.l	d0,grafbase-thistask(a4)	;graphics base =>grafbase
	beq	nolibgra



	move.l	d0,a6
	move.l	winptr,a1
	move.l	wd_RPort(a1),a1
	move.l	a1,a2
	moveq	#100,d0
	moveq	#30,d1
	jsr	_LVOMove(a6)
	move.l	a2,a1
	lea	hworld(pc),a0
	moveq	#hworldl,d0
	jsr	_LVOText(a6)
	move.l	dosbase,a6
	move.l	#50*10,d1
	jsr	_LVODelay(a6)



	move.l	grafbase,a1		;graphics base
	move.l	(4).w,a6
	jsr	_LVOCloseLibrary(a6)

nolibgra:
	move.l	winptr,a0		;window
	move.l	intbase,a6		;inituition base
	jsr	_LVOCloseWindow(a6)

nowindow:
	move.l	scrptr,a0		;screen, still intuition base =>a6
	jsr	_LVOCloseScreen(a6)

noscreen:
	move.l	(4).w,a6
	move.l	intbase,a1		;intuition base
	jsr	_LVOCloseLibrary(a6)

nolibint:
	move.l	dosbase,a1
	jsr	_LVOCloseLibrary(a6)

nolibdos:
	move.l	startmsg,d2		;_AbsExecBase still in a6
	beq.s	wascli			;go if run from CLI

	jsr	_LVOForbid(a6)		;disable multitasking
	move.l	d2,a1
	jsr	_LVOReplyMsg(a6)	; and reply to workbench message

wascli:
	move.l	d7,d0
nosig:
	rts


libint:		dc.b	'intuition.library',0
graftext:	dc.b	'graphics.library',0
libdos:		dc.b	'dos.library',0
parent:		dc.b	'Demonstration task for KISSED',0
hworld:		dc.b	'Hello World, I self-destruct in 10 seconds'
hworldl		equ	*-hworld

********

		data,public

		blanks

myscreen:	dc.w	0,0,640,200		;left,top,width,heigth
		dc.w	2			;planes
		dc.b	0,1			;pens
		dc.w	V_HIRES
		dc.w	CUSTOMSCREEN
		dc.l	0			;font
		dc.l	0
		dc.l	0,0			;no gadgets or custom bit map

mywindow:	dc.w	0,0,640,200			;left,top,width,heigth
		dc.b	-1,-1					;pens
		dc.l	0					;IDCMP flags
		dc.l	BORDERLESS | NOCAREREFRESH | ACTIVATE
		dc.l	0,0				     ;gadgets, checkmark
		dc.l	parent					;title

scrptr:		dc.l	0		;screen ptr
		dc.l	0		;bitmap ptr
		dc.w	-1,-1,-1,-1	;min width,heigth ; max w,h
		dc.w	CUSTOMSCREEN

********

	bss,public

thistask:	ds.l	1	;KISSED task
winptr:		ds.l	1	;window structure ptr

*	don't change order of intbase,grafbase,dosbase

intbase:	ds.l	1	;intuition base ptr
grafbase:	ds.l	1	;graphics base ptr
dosbase:	ds.l	1	;dos base ptr
startmsg:	ds.l	1	;workbench startup message

	end
