;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (c) 2002 TIMEX Corporation.
; 
; This document is the property of, and contains information proprietary to
; TIMEX Corporation.  It is to be returned upon request.  Reproduction by any
; means, disclosure, or use of its contents for other than the expressed
; purpose for which it is loaned, without the written consent of TIMEX
; Corporation, is strictly prohibited.
;
; File Name     : cntBckHd.asm
; Purpose       : Handles the following application specific functions:
;                   - application initialization
;                   - resource refresh
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Module Name : cntBackgroundHandler
; Description : Handles application initialization and refresh resource handlers.
; Assumptions : COREInitializationASDAddress is already set by kernel.
;               COREInitializationADDAddress is already set by kernel.
; Input(s)    : None
; Output(s)   : None
;               ( Destroyed: All registers )
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                IF @DEF('SUBROUTINE')
                    UNDEF SUBROUTINE
                ENDIF
                DEFINE  SUBROUTINE      "'cntBackgroundHandler'"

                GLOBAL  cntBackgroundHandler

cntBackgroundHandler:

                ; Load the event to be process to AReg.
                ld      A, [COREBackgroundEvent]

                ; Check if INIT event.
                cp      A, #COREEVENT_INIT
                jr      NZ, cntBackgroundProcessExit

cntBackgroundInitEvent:
                ;**************************************************************
                ;
                ;               INITIALIZATION THROUGH COMM MODE
                ;
                ;**************************************************************

                ;--------------------------------------------------------------
                ; Counter initial data.
                ;   Data - 0
                ;   Count up
                ;--------------------------------------------------------------
                
                ld      A, #0
                ld      IY, [COREInitializationASDAddress]
                ld      [IY + CNTFLAGSOFFSET], A
                ld      [IY + CNTDATALOOFFSET], A
                ld      [IY + CNTDATAHIOFFSET], A

cntBackgroundProcessExit:

                ret

