;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 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:    utldef.h
;
; Purpose:      Definitions for ALARM and APPOINTMENT common routines
;
; File Change History:
;
;               02/09/2002 JDS - Created for M851.
;               06/11/2002 JDS - scr341 - Created UTLALMNAPPTYOUROCKSETSTATE for build 851010.
;               06/14/2002 JDS - Updated for built 851010.
;                                SCR#851-20020614-348 - need to set record status
;                                in utlCreateDefaultDB(). Cannot assume already 0.
;               07/12/2002 NLS - ECR# 851-20020712-409
;								 Inconsistent computation for 11 hours prior for ALCK display.
;                                UTLNUMBER_HRS_FOR_ACLK_CHECK must be specified in hex (11H)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; state definitions
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CAUTION!: ALM and APPT MUST have this same def in order
;           to use the SNOOZE 10 MIN 
;           and DELETE TIME OUT states.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UTLDEFAULTSTATE          equ     COREDEFAULTSTATE

UTLPOPUPSTATE            equ     COREPOPUPSTATE

UTLDELETETIMEOUTSTATE    equ     COREMISCSTATE3
UTLALMNAPPTYOUROCKSETSTATE  equ     COREMISCSTATE4
   
;; Use these if we use the set snooze feature then remove YOUROCK
;UTLPOPUPSETBANNERSTATE   equ     COREMISCSTATE4 
;UTLPOPUPSETSTATE         equ     COREMISCSTATE5
;UTLSNOOZE10MINSTATE      equ     COREMISCSTATE6
;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; OFFSETS to fields of the ASD 
; Should be the same as defs in ALARM mode.
; If not then there will be trouble.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UTLASDBACKUPRESOURCEINDEXOFFSET       EQU 00H  ; 1-byte, Backup Resource Index 
UTLASDTZCHECKRESOURCEINDEXPOPUPRECORDOFFSET EQU 01H  ; 1-byte, TZ Check Resource Index POPUP Record
UTLASDTZCHECKRESOURCEINDEXPEEKRECORDOFFSET  EQU 02H  ; 1-byte, TZ Check Resource Index PEEK Record
UTLASDTOTALNUMBEROFRECORDSOFFSET      EQU 03H  ; 2-byte, Total Number of RECORDs in the ADD
UTLASDNUMBERUNUSEDRECORDSOFFSET       EQU 05H  ; 2-byte, Total Number of UNused records in the ADD
UTLASDUSEDLISTHEADPTROFFSET           EQU 07H  ; 2-bytes, Display (Used) List Head Ptr
                                               ; (Record ptrs are Offsets to a Record from ADD Start)
UTLASDUSEDLISTTAILPTROFFSET           EQU 09H  ; 2-bytes, Display (Used) List Tail Ptr
                                               ; (Record ptrs are Offsets to a Record from ADD Start)
UTLASDUNUSEDLISTHEADPTROFFSET         EQU 0BH  ; 2-bytes, UNused List Head Ptr
                                               ; (Record ptrs are Offsets to a Record from ADD Start)
UTLASDFLAGSOFFSET                     EQU 0DH  ; 1-byte, appointment Mode Flags
UTLASDPOPUPRECORDPTROFFSET            EQU 0EH  ; 2-bytes, Ptr to record that is being Popup up.
                                               ; (Record ptrs are Offsets to a Record from ADD Start)
UTLASDTZCHECKRESOURCEPOPUPRECORDOFFSET     EQU 10H  ; 2-bytes, Ptr to Record that reserved the TZ Check Popup Resource
                                               ; (Record ptrs are Offsets to a Record from ADD Start)
UTLASD2NDTZCHECKRSOURCEPOPUPRECORDOFFSET   EQU 12H  ; 2-bytes, Ptr to Record that has the same time as the
                                               ;    TZCheck Popup Record. Stay in popup if this is != NULL.
                                               ; (Record ptrs are Offsets to a Record from ADD Start)
UTLASDBACKUPRESOURCERECORDOFFSET      EQU 14H  ; 2-bytes, Ptr to Record that reserved the Backup Resource
                                               ; (Record ptrs are Offsets to a Record from ADD Start)
UTLASDCURRENTLYVIEWEDRECORDPTROFFSET  EQU 16H  ; 2-bytes, Ptr to Currently viewed Record
                                               ; (Record ptrs are Offsets to a Record from ADD Start)
UTLASDNEXTBESTGUESSRECORDPTROFFSET    EQU 18H  ; 2-bytes, Ptr to Record that is the next
                                               ;   appointment best guess.
                                               ;   Data for this record ptr is in UTLTmpBgBestGuessRecord...
                                               ;   data variables
UTLASDSEARCHRECORDPTROFFSET           EQU 1AH  ; 2-bytes, Ptr to Record that is the search record.
                                               ;   Data for this record ptr is in UTLTmpBgSearchRecord...
                                               ;   data variables
UTLASDTZCHECKRESOURCEPEEKRECORDOFFSET EQU 1CH  ; 2-bytes, Ptr to Record that reserved the TZ Check PEEK Resource


UTLNUMBYTESRECORDDATA_PTR_THRU_DOW    EQU 11H  ; 17 bytes of time and Date data (plus record ptr) in ASD
                                               ;  Record (i.e., Best Guess or Search record) includes DOW.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Dbase init defines
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; NOTE: Make the ALARM ASD the SAME SIZE as APPT.
; This is so the common routines will work.
UTLASDSYSTEMDATASIZE            equ     30

; used in init Dbase at POR_INIT. This is the number of records
; in the default Dbase.
UTLNUMDEFAULTRECORDS            equ      10   ; common with alarm and appt

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; APPLICATION DATABASE
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UTLASDSYSTEMDATASTARTOFFSET     equ      0
UTLADDDATABASESTARTOFFSET       equ      0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; These few parameters are dependent upon the actual size of the
; appointment database.  If this is started as a ROM based application
; then we define the size at the default requirements of 10 appointments.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UTLADDHEADERSIZE                equ     5
UTLASDSPECIFICDATASIZE          equ     10
UTLADDSTARTOFASDSPECIFICDATA    equ     00 ; Start of Specific data with respect
                                           ; to 1st byte of specific data, used
                                           ; for INFOHEADER read \ write.

UTLDBASEHEADERSIZE              equ     UTLADDHEADERSIZE + UTLASDSPECIFICDATASIZE

UTLDEFAULTRECORDSIZE            equ     47 ;   47 bytes =
                                           ; ----- 
                                           ;   16 byte Record header
UTLDEFAULTLCDMESSAGELENGTH      equ     31 ; + 30 byte blank LCDScrollMessage
                                           ; +  1 Sentinal Char

;---------------------------------------------------------------
;   Status byte = UNused, Unarmed, Unmodified, Undeleted,
;                        Appt Record Type, Not Eol record
;---------------------------------------------------------------
UTLDEFAULTSTATUS                equ     0

UTLDATABASEDATASIZE             equ     UTLDBASEHEADERSIZE + (UTLNUMDEFAULTRECORDS * UTLDEFAULTRECORDSIZE)
UTLDATABASEALLOCATION           equ     (((UTLDATABASEDATASIZE / HWEEPROM_PAGESIZE_64) + 1) * HWEEPROM_PAGESIZE_64)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; OFFSETS to fields of the ADD
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;UTLADDALLOCATIONSIZEOFFSET               EQU 00H ; 2-bytes, Total number of EEPROM bytes allocated for the Dbase
                                             ; plus expansion.
;UTLADDSIZEOFDATABASEOFFSET               EQU 02H ; 2-bytes, Total number of EEPROM bytes allocated for the Dbase.
;UTLADDAPPLICATIONSPECIFICSIZEOFFSET      EQU 04H ; 1-byte, Total number of EEPROM bytes that follow for application
                                             ; specific ADD variables.
                                             ; Some of these bytes may be a copy of ASD RAM data.
;UTLADDAPPLICATIONSPECIFICDATASTARTOFFSET EQU 05H ; ADD address OFFSET def for start of ASD specific data.
                                             ; Same as UTLADDTOTALNUMBEROFRECORDS but it is more descriptive.
;UTLADDTOTALNUMBEROFRECORDSOFFSET         EQU 05H ; 2-bytes, The Total number of records stored in the Dbase.
                                             ; which are either USED or UNUSED.
;UTLADDNUMBEROFUNUSEDRECORDSOFFSET        EQU 07H ; 2-bytes, The Total number of records stored in the Dbase,
                                             ; which are UNUSED. This number should be less than or equal to the
                                             ; total number of records.
;UTLADDUSEDLISTHEADPTROFFSET              EQU 09H ; 2-bytes, The Head (Start of list) pointer for the used (Display) list.
;UTLADDUSEDLISTTAILPTROFFSET              EQU 0BH ; 2-bytes, The Tail (End of list) pointer for the used (Display) list.
;UTLADDUNUSEDLISTHEADPTROFFSET            EQU 0DH ; 2-bytes, The Head (Start of list) pointer for the UNused list.
UTLADDSTARTOFRECORDDATA                  EQU 0FH ; The offset for the start of record data in the Dbase.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; APPLICATION SET DEFINITIONS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UTLMAXHOURS          EQU    24H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; lcd display starting positions
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UTLDMSETPOSITIONPRENOTIFICATION     EQU     LCDMAINDMLINE1COL1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; POPUP SET SNOOZE Definitions
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UTLMINSNOOZETIME            EQU  05
UTLMAXSNOOZETIME            EQU  60
UTLSNOOZETIMEINCREMENT      EQU  05
UTLSNOOZEDFAULTTIME         EQU  10
UTLDEFAULTBACKUPALERTTIME   EQU  05


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Argument def for Display Update proc.
; These go with the temp variable UTLTmpBgCalledbyPeek.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UTLDEFAULTORPOPUP_UPDATE   EQU  0
UTLPEEK_UPDATE             EQU  1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Argument def for utlWriteRecordToADD() proc.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UTLWRITE_LCDMESSAGE        EQU  1
UTLSKIP_WRITE_LCDMESSAGE   EQU  0


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Argument def for utlAdjustNumberUnusedRecords() proc.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UTLADD_ONE_RECORD          EQU  1
UTLSUB_ONE_RECORD          EQU  0FFFFH


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This def needs to follow the file utlSrch.asm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Define for search for appointment in the next 12 hours
; in order to update the TOD ACLK Icon resource.
; The def is for 11 hours since 59 minutes in the last hour
; is considered the 12th hours. Very confusing. Talk with Ron
; he will either straigthen you out or get you more confused.
UTLNUMBER_HRS_FOR_ACLK_CHECK EQU  11H

; Define for search for appointment in the next 4 days
; in order to update the TOD AP Icon resource
; All of today plus 3 days equals 4 days at day rollover
UTLNUMBER_DAYS_FOR_AP_CHECK  EQU  03

; Defines for utlCalcDate()
UTLDAYS_FROM_SAT_TO_MONDAY   EQU  02
UTLNUMBER_RECORDS_TO_READ    EQU  10

; The number of bytes in a time structure
; (Min, Hr, Date, Month, Yr-Lo, Yr-Hi)
UTLNUMMINHRDATEDATABYTES     EQU   6
UTLNUMHRDATEDATABYTES        EQU   5
UTLNUMDATEDATABYTES          EQU   4
UTLNUMMONTHYEARDATABYTES     EQU   3
UTLNUMYEARDATABYTES          EQU   2

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; ALM \ APPT FREQUENCY DEFINITIONS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UTLONE_DAY             EQU    00H
UTLDAILY               EQU    01H
UTLWKDAYS              EQU    02H
UTLWKENDS              EQU    03H
UTLWKLYSU              EQU    04H
UTLWKLYMO              EQU    05H
UTLWKLYTU              EQU    06H
UTLWKLYWE              EQU    07H
UTLWKLYTH              EQU    08H
UTLWKLYFR              EQU    09H
UTLWKLYSA              EQU    0AH
UTLWEEKLY              EQU    0BH
UTLMONTHLY             EQU    0CH
UTLYEARLY              EQU    0DH


UTLMINAPPTFREQ         EQU    UTLONE_DAY - 1
UTLMAXAPPTFREQ         EQU    UTLYEARLY + 1

UTLMINALMFREQ          EQU    UTLDAILY - 1
UTLMAXALMFREQ          EQU    UTLWKLYSA + 1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Misc Defs
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UTLYEAR_2100           EQU    21H
UTLYEAR_2000           EQU    20H
UTLYEAR_1900           EQU    19H
UTLFIRST_DAY_OF_MONTH  EQU    01H
UTLNUMDAYSINAWEEK      EQU    07H
UTL_ONE                EQU    01H

; Defs for Db utils

;UTLUSEACCELERATION     EQU    100 ; record limit above which acceleration is used
                               ; to traverse from one to the next.

