;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 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:    utlvars.h
;
; Purpose:      ALARM and APPT Application Variable Offsets
;
; File Change History:
;
;               02/09/2002 JDS - Created for M851.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This def needs to follow the file utlSrch.asm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; ASD field APPLICATION FLAGS bit definitions
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bUTLASDSetResolution       equ 00000001B  ; bit0 - 1 = 1-MIN Alarm/Appt Set resolution per CROWN PULSE,
                                          ;        0 = 5-MIN Alarm/Appt Set Resolution.
bUTLASDScanTravDirection   equ 00000010B  ; bit1 - 1 = Reverse Scan through Char positions in LCD
                                          ;             message (STOP\RESET SW HOLD) or Reverse
                                          ;             traverse throught alarm/appt record list.
                                          ;        0 = Forward Scan (MODE SW HOLD).
bUTLASD1SecDelay           equ 00000100B  ; bit2 - 1 = The 1 Sec Pre Scan Delay has been started.
                                          ;        0 = the 1/4 sec Scan delay has been started.
bUTLASDBackupPopup         equ 00001000B  ; bit3 - 1 = The Popup was caused by a backup Resource expiration,
                                          ;        0 = The Popup was caused by a TZ Check Resource expiration.
bUTLASDCrownHomeFromPopupSet equ 00010000B  ; bit4 - 1 = A crown home was seen from within Popup Set or
                                          ;            Popup Set Banner states.
bUTLASDSubPrenotification  equ 00100000B  ; bit5 - 1 = Must subtract Prenotification during search algorithm.
                                          ;        0 = Do NOT subtract Prenotification during search algorithm.
bACLKIconIsOn              equ 01000000B  ; bit6 - 1 = The ACLK Icon resource has been set to ON by the last search.
                                          ;        0 = The ACLK Icon resource has been set to OFF by the last search.
                                          ; This flag is needed to ensure the ACLK ICon does not Flash in TOD when 
                                          ; returning from TOD set when a backup popup was pending on entry into TOD set.

;
; ASD field APPLICATION FLAGS bit definition equates.
;

UTLNO                      equ 00H
UTLYES                     equ 01H
UTL250MSEC_DELAY           equ 00H 
UTL1SEC_DELAY              equ 01H
UTLPOP_DUE_TO_TZCHECK      equ 00H 
UTLPOP_DUE_TO_BACKUP       equ 01H 
UTLFORWARD                 equ 00H

UTLSETRESOLUTION_5MIN      equ 00H
UTLSETRESOLUTION_1MIN      equ 01H


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Record field STATUS bit definitions
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

bUsed                      equ 00000001B  ; 1 = Record is used (has Alarm data in it.)
                                          ;     Set by either the PC pre dload or by the
                                          ;     Set Mode after User Edit via Watch UI.
bArmed                     equ 00000010B  ; 1 = Record has been Enabled (ARMED).
bModified                  equ 00000100B  ; 1 = Record has been modified by the user.
bDeleted                   equ 00001000B  ; 1 = Record has been deleted by the user 
                                          ;     via watch UI.
bRecordType                equ 00010000B  ; 1=Appt Record type.
                                          ; 0=Alm Record type.
                                          ; Used by the background search routines
                                          ; to distinguish between which application
                                          ; has called the proc in order to provide
                                          ; special processing for each application.
                                          ; Set or cleared by the PC prior to dload.
                                          ; Never edited by the watch.
bEndOfList                 equ 00100000B  ; 1 = This is the END-OF-LIST Record.
                                          ;     Build as temp record.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Record field STATUS bit definition equates.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UTLNOT_ENDOFLIST           equ 00H
UTLENDOFLIST               equ 01H        ; Another approach is to set
                                          ; the UTLTmpFgCurrentlyViewedRecordPtr = NULL.
UTLUNUSED                  equ 00H
UTLUSED                    equ 01H
UTLUNARMED                 equ 00H
UTLARMED                   equ 01H

UTLAPPTYPE_ALM         EQU    COREAPPTYPEALARM
UTLAPPTYPE_APPT        EQU    COREAPPTYPEAPPOINTMENT


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; COMMON SYSTEM DATA (Used only during foreground execution)
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UTLTmpFgInsertAfterRecordPtr               equ     (COREForegroundCommonBuffer +  0)
UTLTmpFgCurrentlyViewedRecordPtr           equ     (COREForegroundCommonBuffer +  2)

;; Starting address for this temp record
;; These vars are used to hold the display record (default, popup)
;; Not peek record. That will be in the background vars.
UTLTmpFgCurrentlyViewedRecordDataStart     equ     (COREForegroundCommonBuffer +  4)
UTLTmpFgCurrentlyViewedRecordNextRecord    equ     (COREForegroundCommonBuffer +  4)
UTLTmpFgCurrentlyViewedRecordPrevRecord    equ     (COREForegroundCommonBuffer +  6)
UTLTmpFgCurrentlyViewedRecordLengthOfMessage equ   (COREForegroundCommonBuffer +  8)
UTLTmpFgCurrentlyViewedRecordStatus        equ     (COREForegroundCommonBuffer +  9)
UTLTmpFgCurrentlyViewedRecordFreq          equ     (COREForegroundCommonBuffer + 10)
UTLTmpFgCurrentlyViewedRecordPrenotification equ   (COREForegroundCommonBuffer + 11)
UTLTmpFgCurrentlyViewedRecordMin           equ     (COREForegroundCommonBuffer + 12)
UTLTmpFgCurrentlyViewedRecordHr            equ     (COREForegroundCommonBuffer + 13)
UTLTmpFgCurrentlyViewedRecordDate          equ     (COREForegroundCommonBuffer + 14)
;UTLTmpFgCurrentlyViewedRecordMonth         equ     (COREForegroundCommonBuffer + 15)
;UTLTmpFgCurrentlyViewedRecordYrLo          equ     (COREForegroundCommonBuffer + 16)
;UTLTmpFgCurrentlyViewedRecordYrHi          equ     (COREForegroundCommonBuffer + 17)
;UTLTmpFgCurrentlyViewedRecordDOW           equ     (COREForegroundCommonBuffer + 18)

UTLTmpFgSetSnoozeTime                      equ     (COREForegroundCommonBuffer + 19)
UTLTmpFgSetPosition                        equ     (COREForegroundCommonBuffer + 19)

;; CAUTION - Use caution with the next 4 background variables. +20 thru +23 Because
;;           They are being used by the common Lcd DM message edit routines.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; APPT COMMON SYSTEM DATA (Used only during background execution)
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This temp var is used by the delete record proc.
;; This variable is the same address as UTLTmpBgASDBaseAddress and 
;; UTLTmpBgBestGuessRecordPtr.
UTLTmpBgRecordPtr                          equ     (COREBackgroundCommonBuffer +  0)

;; This temp var is used by the utlDisplayUpdate proc.
;; It holds either COREinitialazationASDAddress or CORECurrentASDAddress, depending
;; on whether utlDisplayUpdate() was called from a foreground or background proc.
;; This variable is the same address as UTLTmpBgBestGuessRecordPtr and UTLTmpBgRecordPtr.
UTLTmpBgASDBaseAddress                     equ     (COREBackgroundCommonBuffer +  0)

;; This temp var is used by the background search proc to find next occurrence.
;; This variable is the same address as UTLTmpBgASDBaseAddress and UTLTmpBgRecordPtr.
UTLTmpBgBestGuessRecordPtr                 equ     (COREBackgroundCommonBuffer +  0)
;; Starting address for this temp record
;; This temp area will be used for PEEK Display in APPT and OCC modes.
UTLTmpBgBestGuessRecordDataStart           equ     (COREBackgroundCommonBuffer +  2)
UTLTmpBgBestGuessRecordNextRecord          equ     (COREBackgroundCommonBuffer +  2)
UTLTmpBgBestGuessRecordPrevRecord          equ     (COREBackgroundCommonBuffer +  4)
UTLTmpBgBestGuessRecordLengthOfMessage     equ     (COREBackgroundCommonBuffer +  6)
UTLTmpBgBestGuessRecordStatus              equ     (COREBackgroundCommonBuffer +  7)
;UTLTmpBgBestGuessRecordFreq                equ     (COREBackgroundCommonBuffer +  8)
;UTLTmpBgBestGuessRecordPrenotification     equ     (COREBackgroundCommonBuffer +  9)
UTLTmpBgBestGuessRecordMin                 equ     (COREBackgroundCommonBuffer + 10)
;UTLTmpBgBestGuessRecordHr                  equ     (COREBackgroundCommonBuffer + 11)
;UTLTmpBgBestGuessRecordDate                equ     (COREBackgroundCommonBuffer + 12)
;UTLTmpBgBestGuessRecordMonth               equ     (COREBackgroundCommonBuffer + 13)
UTLTmpBgBestGuessRecordYrLo                equ     (COREBackgroundCommonBuffer + 14)
UTLTmpBgBestGuessRecordYrHi                equ     (COREBackgroundCommonBuffer + 15)

UTLTmpBgBestGuessRecordDOW                 equ     (COREBackgroundCommonBuffer + 16)

;; This temp var is used by the utlDisplayUpdate proc.
;; It holds the base RAM address of the alarm/appt being displayed.
;; This may be either foreground or background temp RAM.
;; This variable is the same address as UTLTmpBgSearchRecordPtr.
UTLTmpBgDisplayRecordBaseAddress           equ     (COREBackgroundCommonBuffer + 17)

;; This temp var is used by the background search proc to find next occurrence.
;; This variable is the same address as UTLTmpBgDisplayRecordBaseAddress.
UTLTmpBgSearchRecordPtr                    equ     (COREBackgroundCommonBuffer + 17)

;; This temp 1 byte var is used by utlDisplayUpdate proc to store the argument
;; which tells the proc whether the update is due to a peek (background task)
;; or a popup\default (foreground task).
;; This var is same RAM address as UTLTmpBgSearchRecordNextRecord. Which should
;; not be in used during a peek operation or a default\popup display update.
UTLTmpBgCalledbyPeek                       equ     (COREBackgroundCommonBuffer + 19)

;; Starting address for this temp record
UTLTmpBgSearchRecordDataStart              equ     (COREBackgroundCommonBuffer + 19)
UTLTmpBgSearchRecordNextRecord             equ     (COREBackgroundCommonBuffer + 19)
UTLTmpBgSearchRecordPrevRecord             equ     (COREBackgroundCommonBuffer + 21)
;UTLTmpBgSearchRecordLengthOfMessage        equ     (COREBackgroundCommonBuffer + 23)
UTLTmpBgSearchRecordStatus                 equ     (COREBackgroundCommonBuffer + 24)
;UTLTmpBgSearchRecordFreq                   equ     (COREBackgroundCommonBuffer + 25)
;UTLTmpBgSearchRecordPrenotification        equ     (COREBackgroundCommonBuffer + 26)
UTLTmpBgSearchRecordMin                    equ     (COREBackgroundCommonBuffer + 27)
UTLTmpBgSearchRecordHr                     equ     (COREBackgroundCommonBuffer + 28)
UTLTmpBgSearchRecordDate                   equ     (COREBackgroundCommonBuffer + 29)
;UTLTmpBgSearchRecordMonth                  equ     (COREBackgroundCommonBuffer + 30)
UTLTmpBgSearchRecordYrLo                   equ     (COREBackgroundCommonBuffer + 31)
UTLTmpBgSearchRecordYrHi                   equ     (COREBackgroundCommonBuffer + 32)
UTLTmpBgSearchRecordDOW                    equ     (COREBackgroundCommonBuffer + 33)

UTLTmpBgSessionRecordCount                 equ     (COREBackgroundCommonBuffer + 34)


;; This temp 2 byte var is used by utlDisplayUpdate() to convert the hex value
;; of Number of unused records to BCD. The address to the LSB variable of BCD data
;; is passed to an LCD display macro.
UTLTmpBgNumberUnusedRecords                equ     (COREBackgroundCommonBuffer + 35)
;; This temp 1 byte var holds the original DOW for the utlReadAndCalcDate and utlCalcDate procs.
UTLTmpBgOriginalDOW                        equ     (COREBackgroundCommonBuffer + 37)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; OFFSETS within Structures in common background (Foreground or background)
; as well as OFFSETS to fields of a record (Rev 11) stored in the ADD.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Offsets used for display routine and any access into record data when given
;; the start address of the data.
;UTLTEMPRECORDATASTARTOFFSET                equ 00H  ; Offset to start of Record data from TEMPRECORDPTROFFSET
                                                     ; Yes, This is the same as the NEXT Record PTR Offset.
;UTLTEMPRECORDNEXTRECORDPTROFFSET           equ 00H  ; 2-bytes, Temp Record Next Record Ptr
                                                     ; Offset from the start of the record to this field,
                                                     ; which holds the value for the Next Record Ptr from this Record.
                                                     ; (Record ptrs are Offsets to a Record from ADD Start)
;UTLTEMPRECORDPREVRECORDPTROFFSET           equ 02H  ; 2-bytes, Temp Record Prev Record Ptr
                                                     ; Offset from the start of the record to this field,
                                                     ; which holds the value for the Prev Record Ptr from this Record.
                                                     ; (Record ptrs are Offsets to a Record from ADD Start)
UTLTEMPRECORDLENGTHOFMESSAGEOFFSET         equ 04H  ; 1-byte, Length Of LCD Message for Temp Record (in Bytes)
                                                     ; Offset from the start of the record to this field,
                                                     ; which holds the value for the Length
                                                     ; of this records LCD message.
UTLTEMPRECORDSTATUSOFFSET                  equ 05H  ; 1-byte, Status bit flags byte for this Record. 
UTLTEMPRECORDFREQOFFSET                    equ 06H  ; 1-byte, Record appl Frequency for Temp Record.
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the application record 
                                                    ; Frequency.
UTLTEMPRECORDPRENOTIFICATIONOFFSET         equ 07H  ; 1-byte, The appointment prenotification time.     
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the prenotification
                                                    ; table index for this Record.
UTLTEMPRECORDMINOFFSET                     equ 08H  ; 1-byte, Minutes Set value for Temp  Record (0-60).
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the Minutes Set value
                                                    ; for Currently Viewed Record (0-60).
UTLTEMPRECORDHROFFSET                      equ 09H  ; 1-byte, Hour Set value for Temp Record. (0-23)
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the Hour Set value
                                                    ; for Currently Viewed Record. (0-23)
UTLTEMPRECORDDATEOFFSET                    equ 0AH  ; 1-byte, Date value for Temp Record. (1-31)
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the Date Set value
                                                    ; for Currently Viewed Record. (1-31)
UTLTEMPRECORDMONTHOFFSET                   equ 0BH  ; 1-byte, Month for Temp Record. (1-12)
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the Month Set value
                                                    ; for Currently Viewed Record. (1-12)
UTLTEMPRECORDYRLOOFFSET                    equ 0CH  ; 1-byte, Year Lo byte for Temp Record. (00-99)
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the Year-Lo Set value
                                                    ; for Currently Viewed Record. 
UTLTEMPRECORDYRHIOFFSET                    equ 0DH  ; 1-byte, Year Hi for Temp Record. (20)
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the Year-Hi Set value
                                                    ; for Currently Viewed Record. 
UTLTEMPRECORDDOWOFFSET                     equ 0EH  ; 1-byte, Day-Of-Week for Temp Record. (0-6) Sunday = 0.
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the Day-Of-Week value
                                                    ; for Currently Viewed Record. This Field is NOT saved
                                                    ; in the ADD.

;UTLTEMPRECORDPCRECORDIDOFFSET              equ 0EH  ; 2-byte, 13th-14th field in a record.
                                                     ; Offset from the start of the record to this field,
                                                     ; This field is used by the PC but not the watch.

; Size of an alarm or appointment Record less the LCDScrollMessage
UTLSIZEOFRECORDHEADERLESSPCRECORDID        equ 0EH
UTLRECORDSTARTOFLCDSCROLLMESSAGEOFFSET     equ 10H  ; 1-byte, 15th field in a record.
                                                    ; Offset from the start of the record to this field,
                                                    ; which holds the value for the first character
                                                    ; in the LCDScrollMessage for this record.



UTLPRENOTOFICATIONMINUTESMAXINDEX          equ 05H  ; The index in the
                                                    ; apptPrenotificationTable
                                                    ; that the largest Minutes
                                                    ; value is found
                                                    ; All values at indexes above
                                                    ; This index are hours numbers.
UTLPRENOTOFICATIONMININDEX                 equ 00H  ; The Min apptPrenotificationTable
                                                    ; index.
UTLPRENOTOFICATIONMAXINDEX                 equ 0FH  ; The Max apptPrenotificationTable
                                                    ; index.
