;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (c) 2001-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:    core.h
;
; Module Names: None
;                                  
; Purpose:      Header file for the core module
;
; Dependencies: xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;               xxxxxxxxxxxxxxxxxxxxxxxx
;
; File Change History:
;
;               05/10/2000 HSB - Created coreVars.h
;
; M851 - Development:
;
;               11/06/2001 NLS - Renamed file to core.h
;                              - Modified for M851 Development
;               05/31/2002 NLS - ECR# 851-20020531-310
;                                Add redefinition for COREEVENT_UPDATEDATABASEHEADER
;               06/19/2002 NLS - ECR# 851-20020531-351
;                                Add lcd scrolling contrast control.
;                                - Add new label COREICB_LCDSCROLLINGCONTRASTOFFSET
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; VARIABLE BIT DEFINITIONS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; COREInterruptFlag1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORE1HZInt                     EQU 00000001B       ; 1 = 1Hz interrupt occurred, set by HW ISR
bCORE2HZInt                     EQU 00000010B       ; 1 = 2Hz interrupt occurred, set by HW ISR
bCORE4HZInt                     EQU 00000100B       ; 1 = 4Hz interrupt occurred, set by HW ISR
bCORE8HZInt                     EQU 00001000B       ; 1 = 8Hz interrupt occurred, set by HW ISR
bCOREODD16HZInt                 EQU 00010000B       ; 1 = 16Hz odd interrupt occurred, set by HW ISR
bCOREEVEN16HZInt                EQU 00100000B       ; 1 = 16Hz even interrupt occurred, set by HW ISR
bCORE32HZInt                    EQU 01000000B       ; 1 = 32Hz interrupt occurred, set by HW ISR


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; COREInterruptFlag2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORESWITCHInt                  EQU 00000001B       ; 1 = Switch interrupt occurred, set by HW ISR
bCORERingDataReady              EQU 00000010B       ; 1 = Ring data available
bCOREMelodyDone                 EQU 00000100B       ; 1 = Melody done event
bCORESERIALInt                  EQU 00001000B       ; 1 = Serial byte received interrupt occurred
bCORESERIALERRInt               EQU 00010000B       ; 1 = Serial overrun error occurred
bCOREProgTimer0Int              EQU 00100000B       ; 1 = Programmable Timer 0 interrupt occurred, set by HW ISR
bCOREProgTimer1Int              EQU 01000000B       ; 1 = Programmable Timer 1 interrupt occurred, set by HW ISR
bCORECommLinkInt                EQU 10000000B       ; 1 = Pending serial task to be processed

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORETaskFlag1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORESecondTask                 EQU 00000001B       ; 1 = 1Hz based post interrupt processing - second
bCOREMinuteTask                 EQU 00000010B       ; 1 = 1Hz based post interrupt processing - minute
bCOREHourTask                   EQU 00000100B       ; 1 = 1Hz based post interrupt processing - hour
bCOREDailyTask                  EQU 00001000B       ; 1 = 1Hz based post interrupt processing - daily
bCORESwitchTask                 EQU 00010000B       ; 1 = Switches available for post interrupt processing
bCORERingTask                   EQU 00100000B       ; 1 = Ring data available for post interrupt processing
bCOREEightHzTask                EQU 01000000B       ; 1 = 8Hz based post interrupt processing
bCORECommLinkConnectTask        EQU 10000000B       ; 1 = Communication Link Connected processing

COREONEHZBASEDTASKMASK          EQU (bCORESecondTask|bCOREMinuteTask|bCOREHourTask|bCOREDailyTask)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORETaskFlag2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCOREUpdateDisplayTODTask       EQU 00000001B       ; 1 = TOD resource update display event
bCOREUpdateDisplayTMRTask       EQU 00000010B       ; 1 = TMR resource update display event
bCOREUpdateDisplaySTPTask       EQU 00000100B       ; 1 = STP resource update display event
bCOREUpdateDisplaySYNTask       EQU 00001000B       ; 1 = SYN resource update display event
bCORECommTransmitCompleteTask   EQU 00010000B       ; 1 = Communication Transmit completed processing
bCORECommLinkDisconnectedTask   EQU 00100000B       ; 1 = Communication Link Disconnected processing
bCORECommPacketReceivedTask     EQU 01000000B       ; 1 = Communication Packet Data Available for processing
bCORECommPacketFirstByteRecTask EQU 10000000B       ; 1 = Communication First Byte of Packet Received


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORETaskFlag3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCOREEndOfScrollMessageTask     EQU 00000001B       ; 1 = Request an scroll end event to be passed to the application
bCOREMelodyDoneTask             EQU 00000010B       ; 1 = The last requested melody have ended
bCOREGenerateEventTask          EQU 00000100B       ; 1 = Resource Event generation (only to foreground application)
bCOREIconRefreshEventTask       EQU 00001000B       ; 1 = Sends an ICON_REFRESH event to the foreground application
bCOREAutoReturnToPrimaryTask    EQU 00010000B       ; 1 = initiate a mode change to the primary mode
bCORECrownOutWarningTask        EQU 00100000B       ; 1 = initiate a display of crown out warning 
;bxxxxxxxxxxxxxxxxxx            EQU 01000000B
;bxxxxxxxxxxxxxxxxxx            EQU 10000000B


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORERequestFlag1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORERequestModeChange              EQU 00000001B       ; 1 = app req change to primary mode
bCORERequestModeChangeNext          EQU 00000010B       ; 1 = app req change to next mode
bCORERequestModeChangeNextNoPeek    EQU 00000100B       ; 1 = app req change to next mode with no primary mode peek
bCORERequestStateChange             EQU 00001000B       ; 1 = app req change to specified state
bCORERequestStateChangeNoClear      EQU 00010000B       ; 1 = app req change to specified state w/o clear display
bCORERequestPopdown                 EQU 00100000B       ; 1 = request that a popdown sequence be initiate.
;xxxxxxxxxxxxxxxxxxxxxxxxxx         EQU 01000000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx         EQU 10000000B



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORESystemFlag1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bHWKBDRingDirection             EQU 00000001B       ; 1 = CW, 0 = CCW
bCOREWarningPopupMode           EQU 00000010B       ; 1 = all events are processed in warning popup state handler
bCOREAutoReturnToPrimaryMode    EQU 00000100B       ; 1 = tracking an autoreturn to primary mode
bCORETrackingTimeoutLowRes      EQU 00001000B       ; 1 = Tracking low resolution timeout
bCORE2HzBlinking                EQU 00010000B       ; 1 = request that core executes the LCD 2Hz blinking routine
bHWCORERingDirection            EQU 00100000B       ; 1 = CW, 0 = CCW Buffered status of bHWKBDRingDirection
bCOREPrimaryModePeekCancel      EQU 01000000B       ; 1 = when mode switch release event is detected, it will make
                                                    ;     the primary mode as the current mode
bCOREAnySwitchEventEnabled      EQU 10000000B       ; 1 = Any switch activity will be passed as a single event
                                                    ; 0 = switch activity is passed as unique events




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORESystemFlag2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORESuspendRingEvents          EQU 00000001B       ; 1 = No ring events to app
bCORESuspendRingLeadingEvents   EQU 00000010B       ; 1 = No ring Leading edge to app
bCORESuspendReleaseEvents       EQU 00000100B       ; 1 = No release events to app
bHWKBDKeyDepressed              EQU 00001000B       ; 1 = system detected a key depression for tracking a release
                                                    ; 0 = no key depression detected

bCOREPopupWarning               EQU 00010000B       ; 1 = Warning popup tracking (COREWarningDuration)
                                                    ;     Warning popup is serviced it the 
                                                    ;     crown is pulled for a certain duration
                                                    ; 0 = El Depressed tracking (COREWarningDuration)
bCORECommModeActive             EQU 00100000B       ; 1 = Watch is currently in communications mode
;bxxxxxxxxxxxxxxxxx             EQU 01000000B
;bxxxxxxxxxxxxxxxxx             EQU 11000000B



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORESystemFlag3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORESetMode                    EQU 00000001B       ; 1 = Set Mode
bCOREPulseMode                  EQU 00000010B       ; 1 = Request the hardware to pass pulse events on ring movement
bCORESuspendTimeout             EQU 00000100B       ; 1 = Suspend all timeouts
bCOREAlreadySentCommADisconnect EQU 00001000B       ; 1 = Indicates that the core has already sent a comm link
                                                    ;     disconnect event.
bCOREHighSpeedClockActive       EQU 00010000B       ; 1 = High speed clock is currently enabled
bCORESpecificPopdownState       EQU 00100000B       ; 1 = Specific popdown state was request by foreground state
bCOREGotTheRelease              EQU 01000000B       ; 1 = Indicates we have recieved a release in sticky timeout req
bCOREPrimaryModePeekActive      EQU 10000000B       ; 1 = The system is currently peeking at the primary mode


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORESystemFlag4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORELCDIconRefreshEventRequest EQU 00000001B       ; 1 = the foreground application requires an icon refresh
bCOREPopupMode                  EQU 00000010B       ; 1 = Popup active 0 = inactive
bCOREPopupAcknowledgeRequest    EQU 00000100B       ; 1 = popup acknowledge is required to cancel current melody
                                                    ;     and send out event to forground application a popup
                                                    ;     cancel event
bCORESuspendPopup               EQU 00001000B       ; 1 = Popups are suspended (Initialized at 0)
bCOREPopupClockActive           EQU 00010000B       ; 1 = Popclock  mechanism is still active 
bCOREScrolling                  EQU 00100000B       ; 1 = lcd message scrolling required
bCOREPendingBackgroundAppTask   EQU 01000000B       ; 1 = A pending background application task awaits to be
                                                    ;     to be processed.

bCOREFirstTimeInDefaultState    EQU 10000000B       ; 1 = Indicates that it is the first time it has entered
                                                    ;     an application default state.  This bit will always
                                                    ;     be set by the core during a mode change.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORESystemFlag5
;
;    All flags in this variable are using the 8Hz interrupt.  This will be one of the criteria to determine
;    if the core should turn off 8HZ interrupt.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORETrackingTimeoutHiRes       EQU 00000001B       ; 1 = Tracking timeout using 8hz
bCORETrackingStickyTimeout      EQU 00000010B       ; 1 = Tracking Sticky Timeout
bHWKBDRingFreeTracking          EQU 00000100B       ; 1 = Looking for Ring to "unstick"
bCORE4HzBlinking                EQU 00001000B       ; 1 = Call the 4Hz blinking routine
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 00100000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 01000000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 10000000B


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORETimeKeepingBits
;
; Updated by an update of the primary time zone resource, this is used by the core to keep track of
; all the 1Hz based activities (minunte, hour, daily).
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORESecondUpdate               EQU bKRESSecUpd       ; 1 = on a second roll over
bCOREMinuteUpdate               EQU bKRESMinUpd       ; 1 = on a minute roll over
bCOREHourUpdate                 EQU bKRESHrUpd        ; 1 = on a Hour roll over
bCOREDayUpdate                  EQU bKRESDayUpd       ; 1 = on a Day roll over
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 00010000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 00100000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 01000000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 10000000B


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; COREPTZFormat
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCOREPTZDateFormat0             EQU bTODDateFormat0   ; b0 & b1: 00 - DMY   
bCOREPTZDateFormat1             EQU bTODDateFormat1   ;        : 01 - YMD
                                                      ;        : 10 - MDY

bCOREPTZ24HourFormat            EQU bTOD24HourFormat  ; b2     : 0 - 12HR format
                                                      ;        : 1 - 24HR format

bCOREPTZWeekNumberDisplayed     EQU bTODWeekNumber    ; b3     : 0 - DOW is displayed
                                                      ;        : 1 - Week Number is displayed

;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 00010000B

bCOREPTZEuroFormat              EQU bTODEuroFormat    ; b5     : 0 - US format
                                                      ;        : 1 - European format

;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 01000000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 10000000B


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORENightModeStatus
; COREChimeStatus
; CORESwitchBeepStatus
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORENightModeEnabled           EQU 00000001B           ; 1 = Nightmode active, 0 = Nightmode inactive
bCORENightModeAuto              EQU 00000010B           ; 1 = Nightmode will be active at certain hours
bCORENightModeAutoStatus        EQU 00000100B           ; 0 = Nightmode current auto status -- OFF
                                                        ; 1 = Nightmode current auto status -- ON
bCORENightModeManuallyActivated EQU 00001000B           ; 1 = Nightmode is activated manually

bCOREChimeEnabled               EQU 00010000B           ; 1 = Chime is active, 0 = Chime is inactive
bCOREChimeAuto                  EQU 00100000B           ; 1 = Chime will be active at certain hours 
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 01000000B

bCORESwitchBeepEnabled          EQU 10000000B           ; 1 = Switch Beep is active, 0 = Switch Beep is inactive



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORETimelineControl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORETimeLineTracking0          EQU 01000000B       ; Timeline Icon Tracking 
bCORETimeLineTracking1          EQU 10000000B       ; 00 = No Timeline displayed in primary mode
                                                    ; 01 = Timeline data for first application owner of timeline
                                                    ; 10 = Timeline data for second application owner of timeline
                                                    ; 11 - Timeline data for both application owners of timeline


;;; TIMELINE DISPLAY EQUATE using [bCORETimeLineTracking1:bCORETimeLineTracking0]

CORETIMELINEDISPLAYMASK         EQU (bCORETimeLineTracking0|bCORETimeLineTracking1)
CORETIMELINEDISPLAYNONE         EQU 0
CORETIMELINEDISPLAYAPP_1ONLY    EQU (bCORETimeLineTracking0)
CORETIMELINEDISPLAYAPP_2ONLY    EQU (bCORETimeLineTracking1)
CORETIMELINEDISPLAYAPP_BOTH     EQU (bCORETimeLineTracking0|bCORETimeLineTracking1)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; COREPeriodicTaskControl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCORESecondTaskLoaded           EQU 00000001B           ; indicates the task is currently loaded in overlay area
bCOREMinuteTaskLoaded           EQU 00000010B           ;
bCOREHourlyTaskLoaded           EQU 00000100B           ;
bCOREDailyTaskLoaded            EQU 00001000B           
bCORESecondTaskAvailable        EQU 00010000B           ; indicates the task code is integrated into the system
bCOREMinuteTaskAvailable        EQU 00100000B           ;
bCOREHourlyTaskAvailable        EQU 01000000B           ;
bCOREDailyTaskAvailable         EQU 10000000B           

CORETASKAVAILABLEMASK           EQU (bCORESecondTaskAvailable|bCOREMinuteTaskAvailable|bCOREHourlyTaskAvailable|bCOREDailyTaskAvailable)


; Record number definition to locate and load periodic task code into overlay
COREPERIODICTASK_RECNUM_SECOND  EQU 0                   ; *** NOT SUPPORTED ***
COREPERIODICTASK_RECNUM_MINUTE  EQU 1
COREPERIODICTASK_RECNUM_HOUR    EQU 2
COREPERIODICTASK_RECNUM_DAY     EQU 3



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; APPLICATION CONTROL DEFINITIONS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


; Maximum Number of Resources in Popup queue
COREPOPUPQUEUEENTRIES           EQU (KTZCNUMOFRESOURCE+KTMRNUMOFRESOURCE+KSTPNUMOFRESOURCE+KSYNNUMOFRESOURCE+KBCKNUMOFRESOURCE)

; Indicates that a popup queue entry is empty
COREPOPUPQUEUEEMPTY             EQU 0

; Use to mask off the application index data
COREPOPUPAPPINDEXMASK           EQU 00001111B

; Mode List Control Equates
COREMAXAPPNUMBER                EQU 16                  ; Maximum number of active applications supported

; Indicates a mode list entry is available
COREFREEBYTE                    EQU 0FFH

; Indicates that a application configuration data is unused
CORENULL                        EQU 000H

; Indicates error return values for core functions
COREERRORCODE                   EQU 0FFH


; Index values for applications that are not removed from the system once it is initialized
COREPRIMARYMODEINDEX            EQU 0
CORECOMMUNICATIONMODEINDEX      EQU 1
COREUSERMODESTARTINDEX          EQU 2


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Application Configuration Data
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCOREACDReserved                EQU 00000001B       ; 0 = Application Index is Avalaible 
                                                    ; 1 = Application Index is Reserved 
bCOREACDCodeLocation            EQU 00000010B       ; 0 = Code Located in Internal memory (RAM/ROM)
                                                    ; 1 = Code Located in External memory (EEPROM)
bCOREACDDatabaseDataLocation    EQU 00000100B       ; 0 = Database Located in Internal Memory (RAM)
                                                    ; 1 = Database Located in External Memory(EEPROM)

bCOREACDInvalidCode             EQU 00001000B       ; 1 = Code is marked invalid.
bCOREACDDatabaseModified        EQU 00010000B       ; 1 = Database has been modified by user action
bCOREACDInvalidDatabase         EQU 00100000B       ; 1 = Database is marked invalid
bCOREACDPasswordRequired        EQU 01000000B       ; 1 = Password is required to access the database
bCOREACDUserSpecifiedModeName   EQU 10000000B       ; 1 = mode name is located in the EEPROM


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ACD Byte Miscellaneous Equates for Application Configuration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Code internal. ASD internal. ADD internal.
COREACDROMAPP                   EQU 0

;Code internal. ASD internal. ADD internal. Invalid ADD.
COREACDROMAPPINVALIDDB          EQU bCOREACDInvalidDatabase

;Code internal. ASD internal. ADD external.
COREACDROMAPPDBINEEPROM         EQU bCOREACDDatabaseDataLocation

;Code external. ASD internal. ADD external.
COREACDEEPROMAPP                EQU (bCOREACDCodeLocation+bCOREACDDatabaseDataLocation)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Application Control Block (ACB) Definitions
;
;   A structure that provides the kernel with information (along with the Application Configuration Data)
;   about the structure and implementation of an active application.  It provides info on where code and the
;   data is located.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREAPPIDOFFSET                     EQU 0   ; Application ID offset (Instance:Type)
COREADDRESSAPPSYSDATAOFFSET         EQU 2   ; Application System Data Address/offset
COREADDRESSAPPDBDATAOFFSET          EQU 4   ; Application Database Data Address/offset
COREADDRESSMODESTATEMANAGEROFFSET   EQU 6   ; Application State Manager Address/offset
COREADDRESSBACKGROUNDHANDLEROFFSET  EQU 8   ; Application Background Handler Address/offset
COREADDRESSMODENAMEOFFSET           EQU 10  ; Application Mode name definition table address/offset
COREADDRESSCODEOFFSET               EQU 12  ; Application Address of Code section (external wristapp only)

COREACBSIZE                         EQU 14


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ACB: Application Offset Flag Definitions
;
;   These bits (if one) indicates whether the values specified in the application parameter table for the
;   application control block values are offsets from the base address in the internal heap where the system
;   has allocated for the application during application initialization.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCOREAppSystemDataOffset        EQU 00000001B
bCOREAppDatabaseDataOffset      EQU 00000010B
bCOREAppStateManagerOffset      EQU 00000100B
bCOREAppBackgroundHandlerOffset EQU 00001000B
bCOREAppModeNameOffset          EQU 00010000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 00100000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 01000000B
;xxxxxxxxxxxxxxxxxxxxxxxxxx     EQU 10000000B




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; External WristApp Control
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CORELoadedExternalAppIndex
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; COREExternalAppLoadingControl
;   Indicates what is currently loaded into the overlay area.  This prevents the system from RE-LOADING
;   the common and state code for an EEPROM based application.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bCOREWristAppCommonCodeInHeap       EQU 10000000B   ;common code already loaded in overlay area
bCOREWristAppStateCodeInHeap        EQU 01000000B   ;state code already loaded in overlay area

COREWRISTAPPSTATEINDEXINHEAPMASK    EQU 00111111B   ;Bits 5-0 indicates the state handler already present in heap


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; External WristApp Miscellaneous Equates
;
;   Specifies the record number to access different sections stored in an external wristapp code file
;   stored in EEPROM.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

CORERECORDNUMBER_COMMONCODE         EQU 0
CORERECORDNUMBER_STATE0CODE         EQU 1


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; APPLICATION PARAMETER TABLE DEFINITIONS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREPAROFFSETMASKOFFSET         EQU 0       ; Application Control Block Offset Mask (1 byte)

COREPARREQUIREDRESTODOFFSET     EQU 1       ; Number of TOD resources required offset (1 byte)
COREPARREQUIREDRESBCKOFFSET     EQU 2       ; Number of BCK resources required offset (1 byte)
COREPARREQUIREDRESTZCOFFSET     EQU 3       ; Number of TZC resources required offset (1 byte)
COREPARREQUIREDRESTMROFFSET     EQU 4       ; Number of TMR resources required offset (1 byte)
COREPARREQUIREDRESSTPOFFSET     EQU 5       ; Number of STP resources required offset (1 byte)
COREPARREQUIREDRESSYNOFFSET     EQU 6       ; Number of SYN resources required offset (1 byte)

COREPARREQUIREDFLAGSOFFSET      EQU 7       ; LCD Flags required offset (2 bytes)
COREPARHEAPSIZECODEOFFSET       EQU 9       ; Heap size required offset (2 bytes)
COREPARHEAPSIZEASDOFFSET        EQU 11      ; Heap size required offset (2 bytes)
COREPARHEAPSIZEADDOFFSET        EQU 13      ; Heap size required offset (2 bytes)

COREPARCONFIGMASKOFFSET         EQU 15      ; Application configuration offset (1 byte)

COREPARUNIQUEIDOFFSET           EQU 16      ; Application unique ID offset  (2 bytes)
COREPARSYSTEMDATAOFFSET         EQU 18      ; Application system Data offset (2 bytes)
COREPARDATABASEDATAOFFSET       EQU 20      ; Application Database Data offset (2 bytes)
COREPARSTATEMANAGEROFFSET       EQU 22      ; Application State Manager Address offset (2 bytes)
COREPARRESHANDLEROFFSET         EQU 24      ; Application Background Handler Address offset (2 bytes)
COREPARMODENAMEOFFSET           EQU 26      ; Application Mode Name table Address offset (2 bytes)

COREPARNUMBEROFBYTES            EQU 28      ; Size of application parameter table

CORENUMBEROFRESOURCES           EQU (COREPARREQUIREDRESSYNOFFSET-COREPARREQUIREDRESTODOFFSET+1)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; APPLICATION TYPES FOR UNIQUE ID
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREAPPTYPESYSTEM               EQU 000H
COREAPPTYPECOMM                 EQU 001H
COREAPPTYPEOPTION               EQU 002H

COREAPPTYPETOD                  EQU 010H
COREAPPTYPEDATE                 EQU 011H

COREAPPTYPECHRONO               EQU 020H
COREAPPTYPETIMER                EQU 021H
COREAPPTYPESYNCHROTIMER         EQU 022H
COREAPPTYPECOUNTER              EQU 023H

COREAPPTYPECONTACT              EQU 040H

COREAPPTYPETASK                 EQU 050H

COREAPPTYPENOTES                EQU 060H

COREAPPTYPESCHEDULE             EQU 070H
COREAPPTYPETIDE                 EQU 080H

COREAPPTYPEDEMO                 EQU 090H

COREAPPTYPEGAME                 EQU 0A0H


; Application Type Dependent upon the Primary Time Zone Data

COREAPPTYPEALARM                EQU 0E0H
COREAPPTYPEAPPOINTMENT          EQU 0E1H
COREAPPTYPEOCCASION             EQU 0E2H



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; LCD FLAG/ICON BIT DEFINITION (COREPARREQUIREDFLAGSOFFSET)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; FIRST BYTE ;;;

bCOREAppFlag_L                  EQU bLCDBlinkLFlag      ; 1 = L flag requested
bCOREAppFlag_A                  EQU bLCDBlinkAFlag      ; 1 = A flag requested  
bCOREAppFlag_P                  EQU bLCDBlinkPFlag      ; 1 = P flag requested  
bCOREAppFlag_NOTE               EQU bLCDBlinkNoteFlag   ; 1 = NOTE flag requested  
bCOREAppFlag_HOURGLASS          EQU bLCDBlinkTmrFlag    ; 1 = HOURGLASS flag requested
bCOREAppFlag_RING               EQU bLCDBlinkTailFlag   ; 1 = RING flag requested
bCOREAppFlag_ARROW              EQU bLCDBlinkArrowFlag  ; 1 = ARROW flag requested  
bCOREAppFlag_ALARM              EQU bLCDBlinkAclkFlag   ; 1 = ALARM flag requested  
                      

;;; SECOND BYTE ;;;

bCOREAppFlag_MOON_Flag          EQU bLCDBlinkMoonFlag   ; 1 = MOON flag requested
bCOREAppFlag_STP                EQU bLCDBlinkChrFlag    ; 1 = STP flag requested  
bCOREAppFlag_TIMELINE_Flag      EQU bLCDTimelineFlag    ; 1 = TIMELINE flag requested  



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; SYSTEM DEFINITIONS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; APPLICATION SYSTEM EVENTS
;   System events passed to the foreground application state handler.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREEVENT_CROWN_EL_DEPRESS      EQU 000H 

COREEVENT_CROWN_HOME            EQU 001H
COREEVENT_CROWN_SET1            EQU 002H
COREEVENT_CROWN_SET             EQU 002H

IF CORESUPPORT_CROWNSET2 == 1
COREEVENT_CROWN_SET2            EQU 003H
ENDIF
                                     
COREEVENT_CW_EDGE_LEADING       EQU 004H
COREEVENT_CCW_EDGE_LEADING      EQU 005H
COREEVENT_SWITCH1DEPRESS        EQU 006H
COREEVENT_SWITCH2DEPRESS        EQU 007H
COREEVENT_SWITCH3DEPRESS        EQU 008H

COREEVENT_MELODYPOPUPCANCEL     EQU 00FH

COREEVENT_CROWN_EL_RELEASE      EQU 080H         

COREEVENT_CW_EDGE_TRAILING      EQU 084H
COREEVENT_CCW_EDGE_TRAILING     EQU 085H
COREEVENT_SWITCH1RELEASE        EQU 086H
COREEVENT_SWITCH2RELEASE        EQU 087H
COREEVENT_SWITCH3RELEASE        EQU 088H

COREEVENT_CW_PULSES             EQU 010H
COREEVENT_CCW_PULSES            EQU 011H

COREEVENT_ANYSWITCHDEPRESS      EQU 012H
COREEVENT_ANYSWITCHRELEASE      EQU 013H

COREEVENT_TIMEOUTDONE_LOWRES    EQU 020H
COREEVENT_TIMEOUTDONE_HIGHRES   EQU 021H
COREEVENT_STICKY_TIMEOUTDONE    EQU 022H

COREEVENT_STATEENTRY            EQU 031H
COREEVENT_MELODY_DONE           EQU 032H
COREEVENT_END_OF_SCROLLING_MESS EQU 033H
COREEVENT_EVENTGENERATION       EQU 034H
COREEVENT_ICON_REFRESH          EQU 035H

COREEVENT_DISPLAY_UPDATE_TODRES EQU 040H
COREEVENT_DISPLAY_UPDATE_STPRES EQU 041H
COREEVENT_DISPLAY_UPDATE_TMRRES EQU 042H
COREEVENT_DISPLAY_UPDATE_SYNRES EQU 043H

COREEVENT_COMMDATAPACKETREADY   EQU 050H
COREEVENT_COMMFIRSTBYTERECEIVED EQU 051H
COREEVENT_COMMDISCONNECTED      EQU 052H
COREEVENT_COMMTRANSMITCOMPLETE  EQU 053H


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Background Handler EVENTS
;   These events are only sent to the Resource background handler
;   NOTE: Do not use 0x00 (indicates no pending background task requests)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREEVENT_NULL                          EQU 00H ; Reserved.  Do not reassign to any event since this will be
                                                ; used by the background task routine to determine if there
                                                ; is an active background task.

COREEVENT_PORINIT                       EQU 01H ; Power Reset Initialization for powerup enabled applications
COREEVENT_INIT                          EQU 02H ; Requests the application to initialize new downloaded database
COREEVENT_TASKEXIT                      EQU 03H ; Request current application for clean up app environment
COREEVENT_PEEK                          EQU 04H ; Request to display application specific data
COREEVENT_UPDATEDATABASEHEADER          EQU 05H ; Requests the application to update the application specific
                                                ; parameters stored in the database header section


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ECR# 851-20020531-310
; Add redefinition for COREEVENT_UPDATEDATABASEHEADER
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Allows application to enable cleanup task
COREEVENT_APP_SHUTDOWN_FOR_COMM         EQU COREEVENT_UPDATEDATABASEHEADER

; End of ECR# 851-20020531-310
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


COREEVENT_TIMERFINISHED                 EQU 06H ; A kernel resource requires immediate attention from owner app
                                                ; to process and reintialize resource variables and flags.

COREEVENT_TIMERHALFWAYACHIEVED          EQU 07H ; A timer resource countdown/countup operation has reached
                                                ; its halfway mark.

COREEVENT_STP_FORCIBLY_STARTED          EQU 08H ; A stopwatch resource was started internally by a timer resource
                                                ; due to a countdown action chrono operation.

COREEVENT_STP_RUNOUT                    EQU 09H ; Stopwatch resource data has reached 100hrs


COREEVENT_TZC_EXPIRED_NOPOPUP           EQU 0AH ; Time zone check resource has expired.  No popup requested in
                                                ; the resource.
COREEVENT_TZC_EXPIRED_POPUP             EQU 0BH ; Time zone check resource has expired.  A popup is requested
                                                ; by the resource.



COREEVENT_PRIMARY_TIME_CHANGE           EQU 82h ; Request by a TOD application to indicate that the primary
                                                ; time has been modified by the user.

COREEVENT_REFRESH_START                 EQU 81H ; Requests the application to update its data/resource due to
                                                ; change in system conditions (e.g. user update TOD primary time.
                                                ; This will be the initial event passed to start off a background
                                                ; task process.

COREEVENT_REFRESH_CONTINUE              EQU 80H ; Requests the application to update its data/resource due to
                                                ; change in system conditions eg user update TOD primary time.
                                                ; This will be used to continue the processing initiated
                                                ; previously by the background handler.

COREEVENT_PEEK_SEARCH_START             EQU 41H ; Request the application to setup the variables required for
                                                ; for an application peek operation.
                                                ; This will be the initial event passed to start off a background
                                                ; task process.

COREEVENT_PEEK_SEARCH_CONTINUE          EQU 40H ; Request the application to setup the variables required for
                                                ; for an application peek operation.
                                                ; This will be used to continue the processing initiated
                                                ; previously by the background handler.



COREEVENT_DAY_UPDATE                    EQU 21h ; Request the appointment and occasion type applications
COREEVENT_DAY_UPDATE_START              EQU 21h ; to update system variables or flags due to a day update
                                                ; condition.
                                                ; This will be the initial event passed to start off a background
                                                ; task process.nd

COREEVENT_DAY_UPDATE_CONTINUE           EQU 20h ; Request the appointment and occasion type applications
                                                ; to update system variables or flags due to a day update
                                                ; condition.
                                                ; This will be used to continue the processing initiated
                                                ; previously by the background handler.



COREEVENT_HOUR_UPDATE                   EQU 11h ; Request the appointment and alarm type applications
COREEVENT_HOUR_UPDATE_START             EQU 11h ; to update system variables or flags due to an hour update
                                                ; condition.
                                                ; This will be the initial event passed to start off a background
                                                ; task process.nd

COREEVENT_HOUR_UPDATE_CONTINUE          EQU 10h ; Request the appointment and alarm type applications
                                                ; to update system variables or flags due to an hour update
                                                ; condition.
                                                ; This will be used to continue the processing initiated
                                                ; previously by the background handler.



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; REQUEST ARGUMENTS - LOW RESOLUTION TIMEOUT
;   These timeout values are computed using a 1 second resolution base counter.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

TIMEOUTLORES_2SEC               EQU 2
TIMEOUTLORES_3SEC               EQU 3
TIMEOUTLORES_4SEC               EQU 4
TIMEOUTLORES_10SEC              EQU 10
TIMEOUTLORES_20SEC              EQU 20


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; REQUEST ARGUMENTS - HIGH RESOLUTION TIMEOUT
;   These timeout values are computed using a 125msecond resolution base counter.
;   TimeoutValue = RequiredTimeInSeconds / 0.125
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

TIMEOUTHIRES_P250SEC            EQU 2       ; 0.25 seconds
TIMEOUTHIRES_P5SEC              EQU 4       ; 0.50 seconds
TIMEOUTHIRES_1SEC               EQU 8       ; 1.00 seconds
TIMEOUTHIRES_1P5SEC             EQU 12      ; 1.50 seconds
TIMEOUTHIRES_2SEC               EQU 16      ; 2.00 seconds
TIMEOUTHIRES_3SEC               EQU 24      ; 3.00 seconds
TIMEOUTHIRES_4SEC               EQU 32      ; 4.00 seconds
TIMEOUTHIRES_5SEC               EQU 40      ; 5.00 seconds
TIMEOUTHIRES_6SEC               EQU 48      ; 6.00 seconds


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CROWN POSITION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; the index values are made as such to match the crown hardware

CORECROWNPOS_HOME               EQU 8
CORECROWNPOS_SET1               EQU 1

IF CORESUPPORT_CROWNSET2 == 1
CORECROWNPOS_SET2               EQU 2
ENDIF

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; STATE INDEX
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREBANNERSTATE                 EQU 00H     ; Mode Banner State index
COREDEFAULTSTATE                EQU 01H     ; Default State index
CORESET1BANNERSTATE             EQU 02H     ; Set 1 banner state index
CORESET1STATE                   EQU 03H     ; Set 1 state definition index
COREPOPUPSTATE                  EQU 04H     ; Popup state definition index


COREPASSWORDDEFAULTSTATE        EQU 05H     ; password entry default state handler
COREPASSWORDSETBANNERSTATE      EQU 06H     ; password entry set banner state handler
COREPASSWORDSETSTATE            EQU 07H     ; password entry set state handler


COREMISCSTATE0                  EQU 05H     ; Misc state index
COREMISCSTATE1                  EQU 06H     ; Misc state index
COREMISCSTATE2                  EQU 07H     ; Misc state index
COREMISCSTATE3                  EQU 08H     ; Misc state index
COREMISCSTATE4                  EQU 09H     ; Misc state index
COREMISCSTATE5                  EQU 0AH     ; Misc state index
COREMISCSTATE6                  EQU 0BH     ; Misc state index
COREMISCSTATE7                  EQU 0CH     ; Misc state index
COREMISCSTATE8                  EQU 0DH     ; Misc state index
COREMISCSTATE9                  EQU 0EH     ; Misc state index
COREMISCSTATE10                 EQU 0FH     ; Misc state index
COREMISCSTATE11                 EQU 10H     ; Misc state index
COREMISCSTATE12                 EQU 11H     ; Misc state index
COREMISCSTATE13                 EQU 12H     ; Misc state index
COREMISCSTATE14                 EQU 13H     ; Misc state index
COREMISCSTATE15                 EQU 14H     ; Misc state index
COREMISCSTATE16                 EQU 15H     ; Misc state index
COREMISCSTATE17                 EQU 16H     ; Misc state index
COREMISCSTATE18                 EQU 17H     ; Misc state index
COREMISCSTATE19                 EQU 18H     ; Misc state index
COREMISCSTATE20                 EQU 19H     ; Misc state index
                                        
CORESETBANNERSTATE              EQU CORESET1BANNERSTATE
CORESETSTATE                    EQU CORESET1STATE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; MISCELLANEOUS EQUATES - MODEL SPECIFIC
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SYSTEM COUNTER ARGUMENTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;high speed clock duration (in seconds)
COREHIGHSPEEDCLOCKDURATION      EQU 5

;highest value we can go with the mode number
COREMODETERMINATOR              EQU COREMAXAPPNUMBER-1

;default suspend flag mask
;  SuspendRingEvents = SuspendSwitchRelease = 0; SuspendRingLeadingEvents = 1
COREDEFAULTSUSPENDMASK          EQU bCORESuspendRingLeadingEvents

; The TOD Resource index fixed for the POPCLOCK mechanism
COREPOPCLOCKRESINDEX            EQU KRESPOPUPCLOCKRESOURCEINDEX

; Autoreturn to Primary mode (in minutes)
COREAUTORETURNDURATION          EQU 3

; Time allotted to be in a mode before a mode change request will proceed to the primary mode (in seconds)
COREINMODEDURATIONMAX           EQU 6

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; LAMP AND NIGHTMODE TIMEOUT ARGUMENTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;duration lamp will remain on when nightmode is active (in seconds) when the crown is in the home position
CORELAMPONDURATION              EQU 3

;nightmode duration in hours
CORENIGHTMODEDURATION           EQU 8

; duration EL is depressed to toggle nightmode
CORENIGHTMODETOGGLEDURATION     EQU 4

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WARNING TIMEOUT ARGUMENTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; After 1 minute pressing on the EL we should turn it off (second resolution)
COREMAXDURATIONELDEPRESSED      EQU 60

; After pulling the crown for 90 seconds without any activity we will initiate a warning popup (minute resolution)
COREMAXDURATIONCROWNPULLEDOUT   EQU 3
                                        
                                        
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SWITCHES, CROWN AND RING EQUATES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Maximum number of pulses detected by the hw ring system for accelaration purposes
COREMAXRINGPULSES               EQU 4

;Maximum number of pulses detected by the hw crown system for accelaration purposes
COREMAXCROWNPULSES              EQU 4

;bit position that indicates the switch event is a release
CORERELEASEMASK                 EQU 10000000B


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; KEY MASK DEFINITIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; COREKeyMask default is all enabled (all 1)
bCORESwitch1                    EQU 00000001B       ; 1 = send the event to Application, 0 = Don't send it
bCORESwitch2                    EQU 00000010B       ; 1 = send the event to Application, 0 = Don't send it
bCORESwitch3                    EQU 00000100B       ; 1 = send the event to Application, 0 = Don't send it
bCORECWSwitch                   EQU 00001000B       ; 1 = send the event to Application, 0 = Don't send it
bCORECCWSwitch                  EQU 00010000B       ; 1 = send the event to Application, 0 = Don't send it
bCOREELSwitch                   EQU 00100000B       ; 1 = send the event to Application, 0 = Don't send it
;bxxxxxxxxxxxx                  EQU 01000000B
;bxxxxxxxxxxxx                  EQU 10000000B

; Switch redefinitions for the M851
bCOREModeSwitch                     EQU bCORESwitch1
bCOREStopResetSwitch                EQU bCORESwitch2    
bCOREStartSplitSwitch               EQU bCORESwitch3

COREALLOWALLSWITCHES                EQU (bCORESwitch1|bCORESwitch2|bCORESwitch3|bCORECWSwitch|bCORECCWSwitch|bCOREELSwitch)
COREALLOWALLSWITCHESEXCEPTINDIGLO   EQU (bCORESwitch1|bCORESwitch2|bCORESwitch3|bCORECWSwitch|bCORECCWSwitch)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; HEAP DEFINITIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

CORETOTALRAMSIZE                EQU 2048
CORERAMTOPADDRESS               EQU 0F800H
CORESTACKMAXSIZE                EQU 131
COREKERNELSYSTEMRAMSIZE         EQU (CORERAMSIZE+DBRAMSIZE+HWRAMSIZE+KRESRAMSIZE+LCDRAMSIZE+UTLRAMSIZE+AUDRAMSIZE+USGRAMSIZE)
COREHEAPMAXSIZE                 EQU (CORETOTALRAMSIZE-CORESTACKMAXSIZE-COREKERNELSYSTEMRAMSIZE)
COREHEAPEEPROMOVERLAYSIZE       EQU 900
COREHEAPEEPROMOVERLAYADDRESS    EQU (COREHeapTop+TODSYSTEMDATASIZE+TODDATABASEDATASIZE+COMMASDHEAPSIZEREQUIREMENTS+COMMADDHEAPSIZEREQUIREMENTS)
COREPERIODICTASKOVERLAYADDRESS  EQU COREHEAPEEPROMOVERLAYADDRESS
coreCodeOverlayBaseAddress      EQU COREHEAPEEPROMOVERLAYADDRESS


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WORK BUFFER SIZE DEFINITIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREWORKBUFFERMAXNUMBER                 EQU 101
CORECOMMONFOREGROUNDVARIABLESMAXNUMBER  EQU 24
CORECOMMONBACKGROUNDVARIABLESMAXNUMBER  EQU 38
CORECOMMONSYSTEMVARIABLESMAXNUMBER      EQU 14

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; COMMUNICATION MODULE DEFINITIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Maximum size for communication packet
COREMAXIMUMPACKETSIZE           EQU 70

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ECR# 851-20020531-351
; Add lcd scrolling contrast control.
; - Add new label COREICB_LCDSCROLLINGCONTRASTOFFSET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; EEPROM INFORMATION AND CONFIGURATION BLOCK DEFINITION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREICBADDRESSINEEPROM                  EQU 0000H

COREICB_VERSIONNUMBEROFFSET             EQU 0
COREICB_SERIALNUMBEROFFSET              EQU 6
COREICB_BONDOPTIONOFFSET                EQU 9
COREICB_BATTERDETECTIONOFFSET           EQU 10
COREICB_LCDCONTRASTOFFSET               EQU 10
COREICB_SCROLLSPEEDDIVISOROFFSET        EQU 11
COREICB_PASSWORDOFFSET                  EQU 12
COREICB_SETTINGCHARACTEROFFSET          EQU 14
COREICB_NIGHTMODEDURATIONOFFSET         EQU 15
COREICB_EEPROMSIZEOFFSET                EQU 16
COREICB_PERIODICTASKCONTROLOFFSET       EQU 18
COREICB_PERIODICTASKEEPROMADDRESSOFFSET EQU 19
COREICB_BUSINESSCONFIGURATIONOFFSET     EQU 21
COREICB_DEFAULTPORAPPLICATIONOFFSET     EQU 22
COREICB_USAGEFLAGOFFSET                 EQU 38
COREICB_LCDSCROLLINGCONTRASTOFFSET      EQU 39
COREICB_CHECKSUMOFFSET                  EQU 47
COREICB_PAGESIZE                        EQU (COREICB_CHECKSUMOFFSET+1)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End of ECR# 851-20020531-351
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


; PC Sychronization ID section (Cleared on POR. Used and modified by PC only)
COREICB_PCSYNCID                        EQU (COREICB_CHECKSUMOFFSET+1)
COREICB_PCSYNCID_SIZE                   EQU (HWEEPROM_PAGESIZE_64-COREICB_CHECKSUMOFFSET-2)


; Indicates the end of the POR application initialization list
COREICB_ENDOFPORLIST                    EQU 0FFH
CORE_INDEX_COMMMODE                     EQU 1


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ICB ROM BASED APPLICATION OFFSETS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREROMAPPOFFSET_TOD            EQU 0
COREROMAPPOFFSET_COMM           EQU 2
COREROMAPPOFFSET_CHR            EQU 4
COREROMAPPOFFSET_TMR            EQU 6
COREROMAPPOFFSET_INT            EQU 8
COREROMAPPOFFSET_ALM            EQU 10
COREROMAPPOFFSET_APPT           EQU 12
COREROMAPPOFFSET_NOTE           EQU 14
COREROMAPPOFFSET_OPT            EQU 16
COREROMAPPOFFSET_OCC            EQU 18
COREROMAPPOFFSET_CONT           EQU 20
COREROMAPPOFFSET_SCH            EQU 22
COREROMAPPOFFSET_SYNC           EQU 24
COREROMAPPOFFSET_CNTR           EQU 26


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MODE BANNER MESSAGE DEFINITIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Specifies the number of bytes allocated for a mode banner message stored in the EEPROM
COREMAXSIZEMODEBANNERMSG        EQU 27

; Absolute address in EEPROM where the user defined mode banner messages are stored
COREMODENAMEADDRESSINEEPROM     EQU 0040H


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; USAGE COUNTER RAM USAGE DEFINITION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREUSAGEBUFFERSIZE             EQU 14
COREUSAGEADDRESSINEEPROM        EQU 01C0H


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MELODY DATABASE IN EEPROM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREMELODYADDRESSINEEPROM       EQU 02C0H


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; START ADDRESS OF DATABASES IN EEPROM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREADDADDRESSINEEPROM          EQU 0440H



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; RESOURCE POPUP QUEUE INDEX DEFINITION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

CORE_RESOURCE_TMR_OFFSET        EQU 0
CORE_RESOURCE_STP_OFFSET        EQU (CORE_RESOURCE_TMR_OFFSET+KTMRNUMOFRESOURCE)
CORE_RESOURCE_SYN_OFFSET        EQU (CORE_RESOURCE_STP_OFFSET+KSTPNUMOFRESOURCE)
CORE_RESOURCE_BCK_OFFSET        EQU (CORE_RESOURCE_SYN_OFFSET+KSYNNUMOFRESOURCE)
CORE_RESOURCE_TZC_OFFSET        EQU (CORE_RESOURCE_BCK_OFFSET+KBCKNUMOFRESOURCE)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PASSWORD STATE DEFINITIONS AND REDEFINITIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

COREPasswordByte0               EQU (COREForegroundCommonBuffer+0)
COREPasswordByte1               EQU (COREForegroundCommonBuffer+1)
COREPasswordByteSetPosition     EQU (COREForegroundCommonBuffer+2)

COREPASSWORDSETPOSITIONSTART    EQU 0
CORETOGGLESETPOSITION           EQU 1



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; BATTERY CHECK EQUATES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; hour to check for battery level (00H-23H) (default=02H)
CORE_BATTERY_CHECK_HOUR         EQU 2


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; VARIABLE REDEFINITIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Used only as temporary variable during the application allocation
CORETempAppIndex:               EQU (CORESystemCommonBuffer+0)
CORETempRequiredHeapSize        EQU (CORESystemCommonBuffer+1)
CORETempRequiredSize:           EQU (CORESystemCommonBuffer+3)
CORETempHeapTopAddress:         EQU (CORESystemCommonBuffer+5)

; Used to store temporary variables during background task processing
CORETemp:                       EQU (CORESystemCommonBuffer+7)


; Variable usage of core module
CORERAMSIZE:                    EQU (COREEND-CORESTART)
