;***************************************************************
;	Things to do
;		1. Clean up error checking in child task
;			what little there is of it
;******************************************************************
;	Registers used in this section
;	d2	-	idcmpsig
;	d3	-	mainport2sig
;	d4	-	mainoridcmpsig
;	d5	-	wakeupsig
;	d6	-	secstoshowview

;	a2	-	control window address
;	a3	-	userquitmessage
;	a4	-	flipmessage
;	a5	-	closewindowgadget
;**************************************************************
	include "flip.h"
	include "flip.macros"
;***************************************************************
	xdef	execbase
	xdef	dosbase
	xdef	gfxbase
	xdef	intbase
	xdef	totalpause
	xref	_AbsExecBase
	xref	ud
	amiref	Alert
	amiref	Forbid
	amiref	FindTask
	amiref	OpenLibrary
	amiref	CloseLibrary
	amiref	OpenWindow
	amiref	CloseWindow
	amiref	GetMsg
	amiref	ReplyMsg
	amiref	Delay
	amiref	AllocMem
	amiref	FreeMem
	amiref	Permit
	amiref	AllocSignal
	amiref	AddPort
	amiref	RemPort
	amiref	FreeSignal
	amiref	AddTask
	amiref	RemTask
	amiref	Wait
	amiref	WaitPort
	amiref	PutMsg
	amiref	SendIO
	amiref	CheckIO
	amiref	OpenDevice
	amiref	CloseDevice
	amiref	SizeWindow
	amiref	OnGadget
	amiref	OffGadget
	amiref	SetMenuStrip
	amiref	Open
	amiref	Close
	amiref	ActivateWindow
	amiref	OffMenu
	amiref	OnMenu
	amiref	Write
	amiref	MoveWindow		;Found a way to use a lot
	amiref	WindowToFront		;of these didn't I?
;**************************************************************
start
	list

	move.l	SP,initialSP
	move.l	_AbsExecBase,a6
	move.l	a6,execbase
	zera	a1		;clear address reg - argument to FindTask
	execlib	FindTask
	move.l	d0,startask	;save the address of our task
	movea.l	startask,a0
	tst.l	pr_CLI(a0)	;if = 0 started from workbench
	beq	WBStart		;if = 1 do CLI Code - reminders for exit
CLI Code
	move.l	#1,clistart
	bsr	opendos
	bra.s	main
WBStart
	move.l	#1,wbstart
	bsr	opendos
	bsr	waitmsg
	move.l	d0,returnmsg	;save for exit
	bra.s	main
;*************************************************************************
waitmsg
	move.l	startask,a1
	lea	pr_MsgPort(a1),a0
	execlib	WaitPort
	move.l	startask,a1
	lea	pr_MsgPort(a1),a0	;wait for the wbench msg
	execlib	GetMsg
	rts
;***************************************************************
main
	bsr	openstuff	;simple program eh?
	bsr	getevent
;****************************************************************
opendos
	lea	dosname,a1
	zero	d0
	execlib	OpenLibrary	;open dos lib (for Delay())
	move.l	d0,dosbase	;is there any way to not busy wait
	beq	testwb		;without AmigaDos? sure would be nice
	rts			;if a task could delay
;***************************************************************
openstuff
	lea	intname,a1
	zero	d0
	execlib	OpenLibrary
	move.l	d0,intbase
	beq	testwb		;open int and graphics libs
	lea	gfxname,a1
	zero	d0
	execlib	OpenLibrary
	move.l	d0,gfxbase
	beq	testwb
	lea	NewWindowStructure1,a0
	intlib	OpenWindow		;open the window
	tst.l	d0
	beq	testwb
	move.l	d0,a2
	move.l	d0,a0
	lea	Menu1,a1
	intlib	SetMenuStrip
	move.l	wd_FirstGadget(a2),a0	;find the window close gadget
	move.l	gg_NextGadget(a0),a0	;and save adress so we can
	move.l	gg_NextGadget(a0),a0	;turn it off/on later
	move.l	gg_NextGadget(a0),a5	;it's the fourth gadget in the list

	CreatePort	sigbitx,mainport1,mainport1name,startask

	move.l	mainport1,d0
	beq	testwb
junka					;junks clear the local labels

	CreatePort	sigbitz,mainport2,mainport2name,startask

	move.l	mainport2,d0		;create the ports for the main task
	beq	testwb
	getmem	#MN_SIZE,#MEMF_CLEAR!MEMF_PUBLIC,a3
	move.l	a3,d0
	beq	testwb
					;get memory for a message to send
	move.b	#NT_MESSAGE,LN_TYPE(a3)	;to child task when user stops
					;this one wants a reply at
	move.l	mainport1,MN_REPLYPORT(a3)	;first main port

	bsr	createmask	;go create the main wakeup mask
	bsr	calcgad1	;go calculate the intial prop gadget	
	bsr	calcgad2	;pot values
	rts
;**************************************************************
createmask
	zero	d1
	move.b	sigbitz,d1	;get the signal bit for mainport2
	move.l	#1,d0
	lsl.l	d1,d0		;convert signal to # we can use
	move.l	d0,d3	;save it for later

				;same here, cept get sigbit from intuition
	movea.l	wd_UserPort(a2),a0	;opened port
	zero	d1		;we'll need this for idcmp msgs
	move.b	MP_SIGBIT(a0),d1
	move.l	#1,d0
	lsl.l	d1,d0
	move.l	d0,d2

	move.l	d3,d1		;create the mask so we can
	or.l	d0,d1			;wait for either signal
	move.l	d1,d4
	rts
;************************************************************************
calcgad1		;see the Intuition manual for where i got this
	lea	Gadget1SInfo,a0		;find gadget special info struct
	zero	d0
	move.w	pi_HorizPot(a0),d0	;get current value of pot
	bne	1$		;this effectively sets
	add.w	#75,d0		;the minimum time btwn flips to 3 secs
				;the screen can't flip much faster anyway
				;and you get into trouble if the user
				;hits start again before a queued up flip
				;request is finished processing
				;this forces the sychronization of the two
				;tasks,not elegant but it should work most
				;of the time
1$
	cmp.w	#$FFFF,d0		;if it is maxed, skip the next inst
	beq.s	2$		;if not maxed, add one (we don't want a
	addq.w	#1,d0		;value of zero or anything larger than a word
2$
	zero	d1
	move.w	#MAXSECSBTWNFLIPS,d1	;multiply the pot value by the
	mulu	d1,d0			;maximum value we want to set
	pushreg	d0			;save this value
	zero	d1
	move.w	#16,d1		;divide this value by 65,536 which is
	lsr.l	d1,d0		;the max value of the pot variable
	move.l	d0,secs		;this effectively loses the lower word

	pullreg	d0		;get the value back
	move.l	#$FFFF,d1	
	and.l	d1,d0		;get rid of the upper 16 bits 
	move.l	#1000,d1
	mulu	d1,d0		;multiply this value by 1,000,000
	mulu	d1,d0		;to get the number of microsecs
	zero	d1
	move.w	#16,d1
	lsr.l	d1,d0		;this is really not required since we
	move.l	d0,microsecs	; are dealing in minutes but what
	rts			; the heck
;****************************************************************
calcgad2		;similar to above with minor changes
	lea	Gadget2SInfo,a0
	zero	d0
	move.w	pi_HorizPot(a0),d0
	cmp.w	#$FFFF,d0
	beq.s	1$
	addq.w	#1,d0
1$
	zero	d1
	move.w	#MAXSECSTOSHOW,d1
	mulu	d1,d0
	pushreg	d0
	zero	d1
	move.w	#16,d1
	lsr.l	d1,d0
	move.l	d0,d6

	pullreg	d0
	move.l	#$FFFF,d1
	and.l	d1,d0
	move.l	#1000,d1
	mulu	d1,d0
	mulu	d1,d0
	zero	d1
	move.w	#16,d1
	lsr.l	d1,d0
	cmp.l	#500000,d0	;here the microsecs are more important
	ble	2$		;so we'll test if we are greater than
	addq.l	#1,d6		; one-half sec and round up if so
2$
	move.l	d6,d1
	addq.l	#1,d1		;this seems to improve the accuracy of
	move.l	d1,totalpause	;timing a bit,besides we can't flip the
	rts			;screen is less than a sec anyway
;****************************************************************
getevent
	move.l	d4,d0	;wait for sig at mainport2 or at UserPort from
	execlib	Wait			;intuition. the mainport2 signal
	move.l	d0,d5			;is from chtask telling us to
	move.l	d2,d1			;flip the screen
	and.l	d0,d1
	bne	handidcmp		;handle intuition signal
;	move.l	d5,d0
	move.l	d3,d1
	and.l	d0,d1
	bne.s	chaskedforflip		;chtask asked us to flip
	bra.s	getevent		;just in case, should not get here

chaskedforflip
	move.l	mainport2,a0		;chtask told us to flip
	execlib	GetMsg			;get the msg
	pushreg	d0			;flip the screen and then reply
	bsr	ud			;we'll let it wait until we're
	pullreg	d0			;definitely through
	move.l	d0,a1
	execlib	ReplyMsg	;now that we've flipped the screen and
	bra.s	getevent	;replied we can go back for more

handidcmp			;must have received an intuimessage
	movea.l	wd_UserPort(a2),a0	;get window's Intuition port
	execlib	GetMsg			;get the message
	beq.s	getevent		;just in case

	movea.l	d0,a1			;copy the message pointer to a1
	pushreg	d4-d5/a2	;we'll need these now, so save for later
	move.l	im_Class(a1),d4		;get the message class
	zero	d5
	move.w	im_Code(a1),d5		;and code
	movea.l	im_IAddress(a1),a2	;and address (for gadget)
	execlib	ReplyMsg		;reply to it so it's happy

	cmpi.l	#CLOSEWINDOW,d4		;is it a close window?
	beq.s	clowinevent

	cmpi.l	#MENUPICK,d4		;menu selection?
	beq.s	menuevent

	cmpi.l	#GADGETUP,d4		;was a gadget selected?
	beq.s	gadevent
					;should not reach this point
	pullreg	d4-d5/a2		;remember to pull these from stack
	bra	getevent		;again, just in case

clowinevent
	pullreg	d4-d5/a2		;it's a closewindow,therefore
	bra	testwb			;go to the exit routine

menuevent
	cmpi.w	#MENUNULL,d5
	bne	notnullmenu	;if it's not null, deal with it
	pullreg	d4-d5/a2	;if it is, go back and wait for more msgs
	bra	getevent

gadevent
	zero	d0			;a gadget was selected
	move.w	gg_GadgetID(a2),d0	;find out which one, I numbered them
	pullreg	d4-d5/a2		;1,2,3 in the gadget ID field

	cmpi.w	#1,d0			;is it gad#1(user changed time btwn
	bne.s	notgad1			;flips)
gad1
	bsr	calcgad1		;if it was, then recalculate pot
	bra	getevent		;and go get another event
notgad1
	cmpi.w	#2,d0		;is it gad#2(user changed time to display
	bne.s	notgad12	;flipped screen)

	bsr	calcgad2	;if so, go recalculate pot for gad #2
	bra	getevent	;and then get another event
notgad12
	cmpi.w	#3,d0		;is it gad#3,(must be if we got here)
	bne	getevent	;if not we're in trouble

	lea	Gadget3,a0	;now find out the state of the gadget
	zero	d0		;to decide if it was a start or a stop
	move.w	gg_Flags(a0),d0
	zero	d1
	move.w	#SELECTED,d1	;test for the toggle state
	and.w	d1,d0
	tst.w	d0		;user just pushed start and gadget is now
	bne	launch		;in selected mode,go start chtask

	bsr	killchild	;otherwise, user hit stop,so kill the child
				;and go get another event since
	bra	getevent	;we are now effectively at position
				;equivalent to start of program
;***************************************************************************
;		These routines handle the menu item requests
;**************************************************************************
notnullmenu		;this is simple, test which item and then
	lsr.w	#5,d5		;branch to a routine that deals with the item
	andi.w	#$3f,d5
	cmpi.w	#0,d5
	beq	handitem0
	cmpi.w	#1,d5
	beq	handitem1
	cmpi.w	#2,d5
	beq	handitem2
	cmpi.w	#3,d5
	beq	handitem3
	cmpi.w	#4,d5
	beq	handitem4
	cmpi.w	#5,d5
	beq	handitem5

	bra	getevent		;just in case
;***************************************************************************
handitem0			;user asked for instructions
	pullreg	d4-d5/a2
	opencon	intconsole,intfh	;open a dos console window
	move.l	wd_Descendant(a2),a1	;find this window's address
					;it is always the primary descendant
					;of our control window
	move.l	wd_FirstGadget(a1),a0	;what we want is the sizing gadget
	move.l	gg_NextGadget(a0),a0	;of this con window
	move.l	gg_NextGadget(a0),a0	;it is the third in the list
	pushreg	a2
	zera	a2
	intlib	OffGadget		;say bye to it
	pullreg	a2	;if we don't turn it off then we'll
				;have to refresh it every time user
				;resizes it, too much trouble

	move.l	a2,a0		;since our new con window has no menus
	intlib	ActivateWindow	;let's deactivate it and activate main win

	move.l	a2,a0		;no we turn off the instructions menu
	zero	d0		;and turn on the bye instructions menu
	intlib	OffMenu		;don't want the user to get two sets
	move.l	a2,a0		;of instructions
	move.l	#$40,d0
	intlib	OnMenu

	conout	intfh,instrtext,instrtextend	;print the text to the
	bra	getevent		;con window and go back for more

handitem1			;totally analogous to handitem0
	pullreg	d4-d5/a2	;except this is the about con window
	opencon	abtconsole,abtfh
	move.l	wd_Descendant(a2),a1
	move.l	wd_FirstGadget(a1),a0
	move.l	gg_NextGadget(a0),a0
	move.l	gg_NextGadget(a0),a0
	pushreg	a2
	zera	a2
	intlib	OffGadget
	pullreg	a2

	move.l	a2,a0
	intlib	ActivateWindow
	move.l	a2,a0
	move.l	#$20,d0
	intlib	OffMenu
	move.l	a2,a0
	move.l	#$60,d0
	intlib	OnMenu
	conout	abtfh,abtext,abtextend
	bra	getevent

handitem2			;this item closes the instruction window
	pullreg	d4-d5/a2
	tst.l	intfh		;check if it's there
	beq.s	1$
	closecon	intfh	;if it is close it
1$
	move.l	a2,a0		;now turn off the bye instructions menu
	move.l	#$40,d0		;and turn on the instructions menu
	intlib	OffMenu		;so user can ask for them again if desired
	move.l	a2,a0		;and then go back for more events
	zero	d0
	intlib	OnMenu
	bra	getevent

handitem3			;analogous to handitem2 except this
	pullreg	d4-d5/a2	;closes the about con window
	tst.l	abtfh
	beq.s	1$
	closecon	abtfh
1$
	move.l	a2,a0
	move.l	#$60,d0
	intlib	OffMenu
	move.l	a2,a0
	move.l	#$20,d0
	intlib	OnMenu
	bra	getevent

handitem4			;user want's the concealed window exposed
	pullreg	d4-d5/a2
	bsr	enlargewin	;go enlarge it and go back for more events
	bra	getevent

handitem5			;easy, user wants to quit so go to exit
	pullreg	d4-d5/a2	;routine
	bra	testwb
;**************************************************************************
enlargewin		;can't get here unless the window was shrunk

	move.l	a2,a0		;make sure window is in front, if user
	intlib	WindowToFront	;hit the window to back gadget while
				;concealed it could end up hidden and
				;leave user confused (happened to me
				;once and I wrote the damn thing)

	move.l	a2,a0		;find out how wide the user has his screen
	move.l	gfxbase,a1	;set to,normally this will be 640
	zero	d0
	move.w	gb_NormalDisplayColumns(a1),d0

	sub.w	#50,d0		;subtract 50 from the width (our window width)
	neg.w	d0		;and reverse the sign of this value
				;this will move window to left by this amount
				;and place it at left edge = 0
	zero	d1
	move.w	#20,d1		;we'll place it at top edge = 20
	intlib	MoveWindow	;call the function to move it

	move.l	a2,a0		;now we want to resize it to 360 by 110
				;remember, the width is now fixed at 50
				;and the height can be any value from
				;10 to 110
	zero	d0
	move.w	#310,d0		;the width increment to resize is fixed
				;user cannot adjust this in shrunk state
	zero	d1
	move.w	#110,d1		;the height value we want
	sub.w	wd_Height(a2),d1	;subtract the current height
				;to get the increment to increase by
	intlib	SizeWindow	;go to work

	move.l	a2,a0		;now we turn off this menu since once
	move.l	#$80,d0		;window is enlarged it is useless
	intlib	OffMenu
	rts
;*************************************************************************
launch
	move.l	a5,a0			;must have recvd a message to
	move.l	a2,a1			;start the program
	pushreg	a2		;not safe to exit the program while the
	zera	a2		;chtask is running so we'll turn off
	intlib	OffGadget	;the window close gadget
	pullreg	a2

	move.l	a2,a0		;and we'll also turn off the Quit
	move.l	#$a0,d0		;menu item
	intlib	OffMenu

	bsr	shrinkwindow	;go shrink and conceal the control window

	move.l	a2,a0		;turn on the enlarge menu so user can
	move.l	#$80,d0		;get back to original size window
	intlib	OnMenu

	bsr	ud		;let's flip the screen once at the start

	MakeTask	chstsize,chstack,chtask,chtaskname,hello

	move.l	chtask,d0		;start the child task which
	beq	testwb		;will do the timing for us and inform
				;us when it is time to flip
	bra	getevent	;go back and wait for an event
;***************************************************************************
shrinkwindow
	move.l	a2,a0		;window address to a0
	zero	d0
	zero	d1
	move.w	wd_Width(a2),d0	;current window width in d0
	subi.w	#50,d0		;we want to shrink it to width = 50

	move.w	wd_Height(a2),d1	;current height in d1
	subi.w	#10,d1		;we want to shrink it to height = 10
	neg.w	d0		;negate these values to get increments
	neg.w	d1		;to resize by
	intlib	SizeWindow	;go resize

	move.l	a2,a0		;window address in a0
	zero	d0
	zero	d1
	move.w	wd_LeftEdge(a0),d1	;find out current left edge

	move.l	gfxbase,a1		;find out normal width (usually 640)
	move.w	gb_NormalDisplayColumns(a1),d0

	sub.w	d1,d0		;subtract the left edge from normal width
	sub.w	#50,d0		;subtract desired width from that
				;to get final x increment to MoveWindow

	move.w	wd_TopEdge(a0),d1	;get the current top edge
	neg.w	d1			;negate it since we want the top
					;edge to become zero

	intlib	MoveWindow		;move the window
	rts
;**************************************************************************
killchild
	move.l	chport1,a0	;if we get here user must have hit the
	move.l	a3,a1		;stop gadget,and since we have
	execlib	PutMsg		;chtask looking for a stop message
	move.l	mainport1,a0	;at chport1,we can send it a message to stop
	execlib	WaitPort	;we expect a reply from chtask so wait
				;if we get a reply,chtask is stopped and
				;waiting for us to say bye to it
junkb
	ByeTask		chstsize,chstack,chtask	;again error check in macro
junkc
	DeletePort	chport1,sigbity		;error check in macro
junkd						;we've killed the task
	DeletePort	chport2,sigbitq		;and gotten rid of the
	move.l	a5,a0			;child ports so it is safe
	move.l	a2,a1			;if user wants to exit program now
	pushreg	a2			;so we can turn on the closewindow
	zera	a2			;gadget
	intlib	OnGadget
	pullreg	a2			;and turn on the quit menu
	move.l	a2,a0
	move.l	#$a0,d0
	intlib	OnMenu
	rts
;**************************************************************************
testwb			;the exit routine
	tst.l	intfh		;close the console windows if they are
	beq.s	1$		;still open
	closecon	intfh
1$
	tst.l	abtfh
	beq.s	2$
	closecon	abtfh
2$
	movea.l	initialSP,SP
	zero	d0
	pushreg	d0			;save return code on stack
junke
	DeletePort	mainport1,sigbitx
junkf						;delete the mainports
	DeletePort	mainport2,sigbitz
junkg
	move.l	a3,d0			;recover memory
	beq	1$
	byemem	#MN_SIZE,a3
1$
	move.l	a2,d0
	beq.s	2$
	movea.l	d0,a0			;close the window
	intlib	CloseWindow
2$
	move.l	intbase,d0
	beq.s	3$
	clolib	intbase
3$
	move.l	gfxbase,d0
	beq.s	4$
	clolib	gfxbase
4$
	movea.l	execbase,a6
	move.l	dosbase,d0
	beq.s	5$
	clolib	dosbase
5$
	tst.l	wbstart		;start from wb? if not, branch to exit
	beq.s	6$
	tst.l	returnmsg	;see if there was a wb message
	beq.s	6$
	execlib	Forbid			;so workbench won't UnLoadSeg
	movea.l	returnmsg,a1
	execlib	ReplyMsg
6$
	pullreg	d0			;restore return (success) code
	rts				;back to operating system
;************************************************************************
				DATA
;***********************************************************************
		evenpc
dosname		dc.b	'dos.library',0
		evenpc
intname		dc.b	'intuition.library',0
		evenpc
gfxname		dc.b	'graphics.library',0
		evenpc
startask	dc.l	0
clistart	dc.l	0
wbstart		dc.l	0
execbase	dc.l	0
dosbase		dc.l	0
intbase		dc.l	0
gfxbase		dc.l	0
initialSP	dc.l	0
returnmsg	dc.l	0
mainport1	dc.l	0
mainport2	dc.l	0
chstsize	dc.l	$7d0
chstack		dc.l	0
chtask		dc.l	0
totalpause	dc.l	0
secs		dc.l	0
microsecs	dc.l	0
intfh		dc.l	0
abtfh		dc.l	0
sigbitx		dc.b	0
		evenpc
sigbitz		dc.b	0
		evenpc
mainport1name	dc.b	'cjb.mainport1',0
		evenpc
mainport2name	dc.b	'cjb.mainport2',0
		evenpc
chtaskname	dc.b	'cjbtask',0
		evenpc
intconsole	dc.b	'CON:140/70/500/130/',0
		evenpc
abtconsole	dc.b	'CON:0/50/500/150/',0
		evenpc
instrtext
		dc.b	$9b,$31,$3b,$33,$33,$3b,$34,$30,$6d,'How to Operate Flip',10
		dc.b	$9b,$30,$3b,$33,$31,$3b,$34,$30,$6d
		dc.b	'  1. The top gadget is used to set the amount of time      '
		dc.b	'between screen flips.  This value can vary from a few      '
		dc.b	'seconds for a setting of 0 to about 40 minutes at the      '
		dc.b	'maximum setting.',10
		dc.b	'  2. The middle gadget is used to set the length of time   '
		dc.b	'that the flipped view will be displayed.  This value can   '
		dc.b	'vary from about 1 second to a maximum of 9 seconds.',10
		dc.b	'  3. The bottom gadget is used to start or stop the timing '
		dc.b	'process.  Note that it is impossible to exit the program   '
		dc.b	'while the timer is running.  You must stop the timer first '
		dc.b	'and then you will be able to exit the program by selecting '
		dc.b	'Quit from the menu or by clicking the CloseWindow gadget.  '
instrtextend
		evenpc
abtext
		dc.b	$9b,$31,$3b,$33,$33,$3b,$34,$30,$6d,'About Flip',10
		dc.b	$9b,$30,$3b,$33,$31,$3b,$34,$30,$6d
		dc.b	'I started this project in order to learn a little bit about'
		dc.b	'assembly language programming on the Amiga.  It sort of    '
		dc.b	'slowly ballooned into what you see here.  I should warn all'
		dc.b	'programmers to look elsewhere for instructive code.  I know'
		dc.b	'very little about programming and what little I do know is '
		dc.b	'self-taught.  I also have a tendency of finding the time to'
		dc.b	'produce this junk in the wee hours of the evening, long    '
		dc.b	'after my brain has had the good sense to shift into low    '
		dc.b	'gear until the morning.  In any case, if anyone feels the  '
		dc.b	'need to comment on this production, you can reach me on    '
		dc.b	'Compuserve (75226,1266), People Link (ops433 or something  '
		dc.b	'like that, I''ve never bothered to get a personal ID), or on'
		dc.b	'the CA-AUG BBS (216-581-2284).',10
		dc.b	$9b,$33,$3b,$33,$33,$3b,$34,$30,$6d
		dc.b	'                                        Charles J. Besecker'
abtextend
		evenpc
;***************************************************************************
NewWindowStructure1:
	dc.w	0,12	;window XY origin relative to TopLeft of screen
	dc.w	360,110	;window width and height
	dc.b	0,1	;detail and block pens
	dc.l	MENUPICK+GADGETUP+CLOSEWINDOW	;IDCMP flags
	dc.l	WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH	;other window flags
	dc.l	GadgetList1	;first gadget in gadget list
	dc.l	NULL	;custom CHECKMARK imagery
	dc.l	NewWindowName1	;window title
	dc.l	NULL	;custom screen pointer
	dc.l	NULL	;custom bitmap
	dc.w	50,10	;minimum width and height
	dc.w	360,110	;maximum width and height
	dc.w	WBENCHSCREEN	;destination screen type
NewWindowName1:
	dc.b	'  Flip Control Window',0
	cnop 0,2
Menu1:
	dc.l	NULL	;*NextMenu
	dc.w	3,0	;LeftEdge,TopEdge
	dc.w	54,0	;Width,Height
	dc.w	MENUENABLED	;Flags
	dc.l	MenuName1	;*MenuName
	dc.l	Item0	;*FirstItem
	dc.w	NULL,NULL,NULL,NULL	;intuition defined
MenuName1:
	dc.b	'Flip                                              by Charles J. Besecker',0
	evenpc
Item0:
	dc.l	Item1	;*NextItem
	dc.w	0,0	;LeftEdge,TopEdge
	dc.w	144,10	;Width,Height
	dc.w	ITEMENABLED!ITEMTEXT!HIGHCOMP
	dc.l	NULL	;mutualexclude
	dc.l	ITextItem0	;*ItemFill
	dc.l	NULL	;SelectFill
	dc.b	NULL	;Command
	dc.l	NULL	;*SubItem
	dc.w	NULL	;NextSelect
	evenpc
ITextItem0:
	dc.b	0,1,RP_JAM1,0	;front and back text pens, drawmode and fill byte
	dc.w	0,1	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	Item0Text	;pointer to text
	dc.l	NULL	;next IntuiText structure
Item0Text:
	dc.b	'Instructions',0
	evenpc
Item1:
	dc.l	Item2	;*NextItem
	dc.w	0,10	;LeftEdge,TopEdge
	dc.w	144,10	;Width,Height
	dc.w	ITEMENABLED!ITEMTEXT!HIGHCOMP
	dc.l	NULL	;mutualexclude
	dc.l	ITextItem1	;*ItemFill
	dc.l	NULL	;SelectFill
	dc.b	NULL	;Command
	dc.l	NULL	;*SubItem
	dc.w	NULL	;NextSelect
	evenpc
ITextItem1:
	dc.b	0,1,RP_JAM1,0	;front and back text pens, drawmode and fill byte
	dc.w	0,1	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	Item1Text	;pointer to text
	dc.l	NULL	;next IntuiText structure
Item1Text:
	dc.b	'About',0
	evenpc
Item2:
	dc.l	Item3	;*NextItem
	dc.w	0,20	;LeftEdge,TopEdge
	dc.w	144,10	;Width,Height
	dc.w	ITEMTEXT!HIGHCOMP
	dc.l	NULL	;mutualexclude
	dc.l	ITextItem2	;*ItemFill
	dc.l	NULL	;SelectFill
	dc.b	NULL	;Command
	dc.l	NULL	;*SubItem
	dc.w	NULL	;NextSelect
	evenpc
ITextItem2:
	dc.b	0,1,RP_JAM1,0	;front and back text pens, drawmode and fill byte
	dc.w	0,1	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	Item2Text	;pointer to text
	dc.l	NULL	;next IntuiText structure
Item2Text:
	dc.b	'Bye Instructions',0
	evenpc
Item3:
	dc.l	Item4	;*NextItem
	dc.w	0,30	;LeftEdge,TopEdge
	dc.w	144,10	;Width,Height
	dc.w	ITEMTEXT!HIGHCOMP
	dc.l	NULL	;mutualexclude
	dc.l	ITextItem3	;*ItemFill
	dc.l	NULL	;SelectFill
	dc.b	NULL	;Command
	dc.l	NULL	;*SubItem
	dc.w	NULL	;NextSelect
	evenpc
ITextItem3:
	dc.b	0,1,RP_JAM1,0	;front and back text pens, drawmode and fill byte
	dc.w	0,1	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	Item3Text	;pointer to text
	dc.l	NULL	;next IntuiText structure
Item3Text:
	dc.b	'Bye About',0
	evenpc
Item4:
	dc.l	Item5	;*NextItem
	dc.w	0,40	;LeftEdge,TopEdge
	dc.w	144,10	;Width,Height
	dc.w	ITEMTEXT!HIGHCOMP
	dc.l	NULL	;mutualexclude
	dc.l	ITextItem4	;*ItemFill
	dc.l	NULL	;SelectFill
	dc.b	NULL	;Command
	dc.l	NULL	;*SubItem
	dc.w	NULL	;NextSelect
	evenpc
ITextItem4:
	dc.b	0,1,RP_JAM1,0	;front and back text pens, drawmode and fill byte
	dc.w	0,1	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	Item4Text	;pointer to text
	dc.l	NULL	;next IntuiText structure
Item4Text:
	dc.b	'Enlarge Window',0
	evenpc
Item5:
	dc.l	NULL	;*NextItem
	dc.w	0,50	;LeftEdge,TopEdge
	dc.w	144,10	;Width,Height
	dc.w	ITEMENABLED!ITEMTEXT!HIGHCOMP
	dc.l	NULL	;mutualexclude
	dc.l	ITextItem5	;*ItemFill
	dc.l	NULL	;SelectFill
	dc.b	NULL	;Command
	dc.l	NULL	;*SubItem
	dc.w	NULL	;NextSelect
	evenpc
ITextItem5:
	dc.b	0,1,RP_JAM1,0	;front and back text pens, drawmode and fill byte
	dc.w	0,1	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	Item5Text	;pointer to text
	dc.l	NULL	;next IntuiText structure
Item5Text:
	dc.b	'Quit',0
	evenpc
GadgetList1:
Gadget1:
	dc.l	Gadget2	;next gadget
	dc.w	50,25	;origin XY of hit box relative to window TopLeft
	dc.w	250,8	;hit box width and height
	dc.w	NULL	;gadget flags
	dc.w	RELVERIFY	;activation flags
	dc.w	PROPGADGET	;gadget type flags
	dc.l	Image1	;gadget border or image to be rendered
	dc.l	NULL	;alternate imagery for selection
	dc.l	IText1	;first IntuiText structure
	dc.l	NULL	;gadget mutual-exclude long word
	dc.l	Gadget1SInfo	;SpecialInfo structure
	dc.w	1	;user-definable data
	dc.l	NULL	;pointer to user-definable data
Gadget1SInfo:
	dc.w	AUTOKNOB+FREEHORIZ	;PROPINFO flags
	dc.w	1638,-1	;horizontal and vertical pot values
	dc.w	1638,-1	;horizontal and vertical body values
	dc.w	0,0,0,0,0,0	;previous requester (filled in by Intuition)
Image1:
	dc.w	0,0	;XY origin relative to container TopLeft
	dc.w	7,4	;Image width and height in pixels
	dc.w	0	;number of bitplanes in Image
	dc.l	NULL	;pointer to ImageData
	dc.b	$0000,$0000	;PlanePick and PlaneOnOff
	dc.l	NULL	;next Image structure
IText1:
	dc.b	3,0,RP_JAM2,0	;front and back text pens, drawmode and fill byte
	dc.w	-15,-10	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	ITextText1	;pointer to text
	dc.l	IText2	;next IntuiText structure
ITextText1:
	dc.b	'Time Between Screen Flips In Minutes',0
	cnop 0,2
IText2:
	dc.b	3,0,RP_JAM2,0	;front and back text pens, drawmode and fill byte
	dc.w	-6,9	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	ITextText2	;pointer to text
	dc.l	NULL	;next IntuiText structure
ITextText2:
	dc.b	'0      10      20      30      40',0
	cnop 0,2
Gadget2:
	dc.l	Gadget3	;next gadget
	dc.w	50,56	;origin XY of hit box relative to window TopLeft
	dc.w	250,8	;hit box width and height
	dc.w	NULL	;gadget flags
	dc.w	RELVERIFY	;activation flags
	dc.w	PROPGADGET	;gadget type flags
	dc.l	Image2	;gadget border or image to be rendered
	dc.l	NULL	;alternate imagery for selection
	dc.l	IText3	;first IntuiText structure
	dc.l	NULL	;gadget mutual-exclude long word
	dc.l	Gadget2SInfo	;SpecialInfo structure
	dc.w	2	;user-definable data
	dc.l	NULL	;pointer to user-definable data
Gadget2SInfo:
	dc.w	AUTOKNOB+FREEHORIZ	;PROPINFO flags
	dc.w	0,-1	;horizontal and vertical pot values
	dc.w	1638,-1	;horizontal and vertical body values
	dc.w	0,0,0,0,0,0	;previous requester (filled in by Intuition)
Image2:
	dc.w	0,0	;XY origin relative to container TopLeft
	dc.w	7,4	;Image width and height in pixels
	dc.w	0	;number of bitplanes in Image
	dc.l	NULL	;pointer to ImageData
	dc.b	$0000,$0000	;PlanePick and PlaneOnOff
	dc.l	NULL	;next Image structure
IText3:
	dc.b	3,0,RP_JAM2,0	;front and back text pens, drawmode and fill byte
	dc.w	-31,-10	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	ITextText3	;pointer to text
	dc.l	IText4	;next IntuiText structure
ITextText3:
	dc.b	'Time Before Flip View Disappears in Secs',0
	cnop 0,2
IText4:
	dc.b	3,0,RP_JAM2,0	;front and back text pens, drawmode and fill byte
	dc.w	-6,9	;XY origin relative to container TopLeft
	dc.l	TOPAZ80	;font pointer or NULL for default
	dc.l	ITextText4	;pointer to text
	dc.l	NULL	;next IntuiText structure
ITextText4:
	dc.b	'1       3       5       7      9',0
	cnop 0,2
Gadget3:
	dc.l	NULL	;next gadget
	dc.w	127,78	;origin XY of hit box relative to window TopLeft
	dc.w	101,21	;hit box width and height
	dc.w	GADGHIMAGE+GADGIMAGE	;gadget flags
	dc.w	RELVERIFY+TOGGLESELECT	;activation flags
	dc.w	BOOLGADGET	;gadget type flags
	dc.l	Image3	;gadget border or image to be rendered
	dc.l	Image4	;alternate imagery for selection
	dc.l	NULL	;first IntuiText structure
	dc.l	NULL	;gadget mutual-exclude long word
	dc.l	NULL	;SpecialInfo structure
	dc.w	3	;user-definable data
	dc.l	NULL	;pointer to user-definable data
Image3:
	dc.w	0,0	;XY origin relative to container TopLeft
	dc.w	101,21	;Image width and height in pixels
	dc.w	2	;number of bitplanes in Image
	dc.l	ImageData3	;pointer to ImageData
	dc.b	$0003,$0000	;PlanePick and PlaneOnOff
	dc.l	NULL	;next Image structure
ImageData3:
	dc.w	$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$FFE0,$0000,$FFC0,$0000,$0000,$0000,$0000
	dc.w	$001F,$F800,$FFC0,$0000,$F020,$0000,$2000,$001F
	dc.w	$F800,$FFC0,$0001,$9860,$0000,$6000,$001F,$F800
	dc.w	$FFC0,$0001,$C0F8,$F3B0,$F800,$001F,$F800,$FFC0
	dc.w	$0000,$E060,$19D8,$6000,$001F,$F800,$FFC0,$0000
	dc.w	$3860,$7998,$6000,$001F,$F800,$FFC0,$0001,$9869
	dc.w	$9980,$6800,$001F,$F800,$FFC0,$0000,$F030,$EFC0
	dc.w	$3000,$001F,$F800,$FFC0,$0000,$0000,$0000,$0000
	dc.w	$001F,$F800,$FFC0,$0000,$0000,$0000,$0000,$001F
	dc.w	$F800,$FFC0,$0000,$0000,$0000,$0000,$001F,$F800
	dc.w	$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$FFE0,$0000,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$0FDF
	dc.w	$FFFF,$DFFF,$FFFF,$F800,$FFFF,$FFFE,$679F,$FFFF
	dc.w	$9FFF,$FFFF,$F800,$FFFF,$FFFE,$3F07,$0C4F,$07FF
	dc.w	$FFFF,$F800,$FFFF,$FFFF,$1F9F,$E627,$9FFF,$FFFF
	dc.w	$F800,$FFFF,$FFFF,$C79F,$8667,$9FFF,$FFFF,$F800
	dc.w	$FFFF,$FFFE,$6796,$667F,$97FF,$FFFF,$F800,$FFFF
	dc.w	$FFFF,$0FCF,$103F,$CFFF,$FFFF,$F800,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
Image4:
	dc.w	0,0	;XY origin relative to container TopLeft
	dc.w	101,21	;Image width and height in pixels
	dc.w	2	;number of bitplanes in Image
	dc.l	ImageData4	;pointer to ImageData
	dc.b	$0003,$0000	;PlanePick and PlaneOnOff
	dc.l	NULL	;next Image structure
ImageData4:
	dc.w	$FFC0,$0000,$0000,$0000,$0000,$001F,$F800,$FFC0
	dc.w	$0000,$0000,$0000,$0000,$001F,$F800,$FFC0,$0000
	dc.w	$0000,$0000,$0000,$001F,$F800,$FFC0,$0000,$0000
	dc.w	$0000,$0000,$001F,$F800,$FFC0,$0000,$0000,$0000
	dc.w	$0000,$001F,$F800,$003F,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0
	dc.w	$0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000
	dc.w	$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0
	dc.w	$0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000
	dc.w	$FFC0,$0000,$0000,$0000,$0000,$001F,$F800,$FFC0
	dc.w	$0000,$0000,$0000,$0000,$001F,$F800,$FFC0,$0000
	dc.w	$0000,$0000,$0000,$001F,$F800,$FFC0,$0000,$0000
	dc.w	$0000,$0000,$001F,$F800,$FFC0,$0000,$0000,$0000
	dc.w	$0000,$001F,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$C3F7
	dc.w	$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$99E7,$FFFF
	dc.w	$FFFF,$FFFF,$F800,$FFFF,$FFFF,$8FC1,$C323,$FFFF
	dc.w	$FFFF,$F800,$FFFF,$FFFF,$C7E7,$9999,$FFFF,$FFFF
	dc.w	$F800,$FFFF,$FFFF,$F1E7,$9999,$FFFF,$FFFF,$F800
	dc.w	$FFFF,$FFFF,$99E5,$9983,$FFFF,$FFFF,$F800,$FFFF
	dc.w	$FFFF,$C3F3,$C39F,$FFFF,$FFFF,$F800,$FFFF,$FFFF
	dc.w	$FFFF,$FF0F,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	dc.w	$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800

TOPAZ80:
	dc.l	TOPAZname
	dc.w	TOPAZ_EIGHTY
	dc.b	0,0
TOPAZname:
	dc.b	'topaz.font',0
	cnop 0,2
; end of PowerWindows source generation
;************************************************************************
;	Code for Child Task Starts Here
;**************************************************************************
hello
	CreatePort	sigbity,chport1,chport1name,chtask
	move.l	chport1,d0	;create the ports for the child
	beq	chwait		;this is an ugly exit, I know
junkh
	CreatePort	sigbitq,chport2,chport2name,chtask
junki
	move.l	chport2,d0
	beq	chwait		;this is messy here but I can't see
				;an obvious way out at the moment

	getmem	#MN_SIZE,#MEMF_CLEAR!MEMF_PUBLIC,a4
	move.l	a4,d0		;get some memory for the message we'll
	beq	chwait		;send to main when its time to flip		

	move.b	#NT_MESSAGE,LN_TYPE(a4)
	move.l	chport2,MN_REPLYPORT(a4)	;we want a reply

	move.l	timioreq,d0		;get some memory for a time request
	bne	tagain
	getmem	#IOTV_SIZE,#MEMF_CLEAR!MEMF_PUBLIC,timioreq
	beq	chwait		;horrible exit,but???

	lea	timname,a0
	move.l	#UNIT_VBLANK,d0
	move.l	timioreq,a1
	move.l	#0,d1
	execlib	OpenDevice		;open the timer device

tagain
	move.l	timioreq,a0		;have timer reply to us at
	move.l	chport1,MN_REPLYPORT(a0)	;chport1
	move.w	#TR_ADDREQUEST,IO_COMMAND(a0)
	add.l	#IO_SIZE,a0
	move.l	secs,TV_SECS(a0)	;these are from the gad#1 pot value
	move.l	microsecs,TV_MICRO(a0)	;obtained in calcgad1

	move.l	timioreq,a1
	execlib	SendIO		;asynchronous request,we've got other things
				;to do while the timer is at work

waitagain
	move.l	chport1,a0	;here we'll get one of two messages,either
	execlib	WaitPort	;from the timer or from main telling
				;us to stop
	movea.l	chport1,a0
	execlib	GetMsg			;get the message

	move.l	d0,a0		;we can tell which message it is by the
	move.l	d0,chrecvdmsg		;task it came from
	move.l	MN_REPLYPORT(a0),a0
	move.l	MP_SIGTASK(a0),d0
	move.l	startask,d1		;is it from the main task?
	cmp.l	d1,d0
	beq	handuserquitmsg		;if so it must be a stop message
					;so go deal with that

	move.l	chrecvdmsg,a0		;otherwise it is a timer msg
	move.l	MN_REPLYPORT(a0),a0	;but we'll check replyport to be
	move.l	MP_SIGTASK(a0),d0	;sure
	move.l	chtask,d1
	cmp.l	d1,d0
	bne	waitagain		;just to be safe

	move.l	mainport2,a0	;ok, we must tell main to flip the screen
	move.l	a4,a1		;love to be able to flip the screen here
		;in the child task but the ud routine uses the damn Delay
		;function in AmigaDos which we can't call from a lowly task
		;silly isn't it?

	execlib	PutMsg		;tell main to flip and wait for a reply
	move.l	chport2,a0	;saying that it has,we use chport2 for this
	execlib	WaitPort	;while chport1 is busy queuing up timer/stop
	bra	tagain		;messages,when we get reply, go back and
				;wait for another message at chport1

handuserquitmsg		;ok, user wants to stop the flipping
	move.l	timioreq,a1
	execlib	CheckIO		;check to see if timer is still timing
	bne	requestcomplete	;if not we don't have to abort the timer
	ABORTIO	timioreq	;request, if so, abort it (I went south
				;here many times trying to figure this out)
			;still not sure if correct, but it seems to work
requestcomplete
	move.l	timioreq,d0	;timer device is now quiet so we can say
	move.l	d0,a1		;bye to it
	execlib	CloseDevice

	move.l	timioreq,d0	;we can also free up the time request memory
	byemem	#IOTV_SIZE,timioreq

	byemem	#MN_SIZE,a4		;and the flip message memory

	move.l	#0,timioreq		;set these to zero since
	zera	a4			;they don't exist anymore

	move.l	chrecvdmsg,a1	;now we can finally reply to main that
	execlib	ReplyMsg	;we're closed up tight and ready to be
				;put to sleep
chwait
	zero	d0		;endless wait,so main can close us down
	execlib	Wait		;I think this is correct?
;**************************************************************************
;             Data for Child Task
;**************************************************************************
	evenpc
chport1		dc.l	0
chport2		dc.l	0
timioreq	dc.l	0
chrecvdmsg	dc.l	0
sigbity		dc.b	0
	evenpc
sigbitq		dc.b	0
	evenpc
chport1name	dc.b	'cjb.childport1',0
	evenpc
chport2name	dc.b	'cjb.childport2',0
	evenpc
timname		dc.b	'timer.device',0
	evenpc
	end
