************************************
* Code to spawn a new Console Task *
* (C) 1986 Commodore-Amiga
*
************************************
	include	"window.i"

	xdef	_NewConsole
	xdef	_CloseConsole
	xref	_DOSBase

startup	equ	28	DevList startup value

act_end		equ	1007

g_sendpkt	equ	48
g_loaddevice	equ	112
g_finddevice	equ	124

* task = NewConsole(Window)
* create a console task and return its id
_NewConsole:
	procst	#0,d2/a2/a5
	move.l	#conname,d1	d1 = mc address of "CON" string
	lsr.l	#2,d1		arg1 = BCPL address
	callg	g_finddevice	get console device node
	move.l	d0,d1		arg1 = node
	lsl.l	#2,d0		d0 = MC address of node
	move.l	d0,a2		save in a2
	move.l	#-1,startup(a2)	put magic value into node
	move.l	arg1(a6),d2	arg2 = window structure pointer
	callg	g_loaddevice
	clr.l	startup(a2)	re-zero magic value
	return	d2/a2/a5

* CloseConsole( task )
* shutdown the console task
_CloseConsole:
	procst	#0,d2-d4
	move.l	arg1(a6),d2	d2 = destination task
	move.l	#act_end,d3	d3 = action
	callg	g_sendpkt	send the pkt off
	return	d2-d4

	cnop	0,4

conname	dc.b	3,'C','O','N'

	end
