***********************************************************************
*
* darts.aii -- Version 3.0  (Main Program)
*
* Copyright (c)
* Steven E. Glass and Apple Computer, Inc.  1986-1990
* All Rights Reserved.
*
* Developer Technical Support Apple II Sample Code
*
* The darts program has two dart game scoring modes.  The Robin mode
* does a simple running score.  The Crickett mode does the scoring
* for the darts game Crickett.
*
***********************************************************************

	case on
	longi on
	longa on

	INCLUDE 'e16.types'
	INCLUDE 'm16.gsos'
	INCLUDE 'm16.locator'
	INCLUDE 'm16.memory'
	INCLUDE 'm16.util2'
	INCLUDE 'darts.equ'

***********************************************************************

	EXPORT main
main	PROC
	import initGlobals, userID, setupMenus, setupWindows
	import mainEvent

	phb	;Save caller's data bank pointer.
	phd	;Save caller's direct page pointer.

	phk	;Switch data bank into program bank.
	plb

	jsr initGlobals	;Initialize our globals.

	pha	;Start up the tools	using
	pha	;resources.
	PushWord userID
	pea refIsResource
	PushLong #1	;Resource ID.
	_StartupTools
	PullLong initRef	;Handle used by ShutdownTools.
	bcs startFailed

	jsr setupMenus
	jsr setupWindows
	jsr mainEvent

startFailed	pea refIsHandle	;Now shut them all down.
	PushLong initRef
	_ShutdownTools

	pushword userID
	_MMShutDown
	_TLShutDown

	pld
	plb

	_QuitGS quitParms	;Leave here.

initRef	DC.L 0
quitParms	DC.W 0
	DC.L 0
	DC.W 0

	ENDP

	END
