;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 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:    chrvars.h
;
; Purpose:      Chrono Mode Application Variable Offsets
;
; File Change History:
;
;               11/13/2001 RBR - Created chrvars.h for M851
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      
;******************************************************************************
;
; CHRONO APPLICATION SYSTEM DATA OFFSETS
;
; IMPORTANT NOTE!!!
;
; The chrono application system data offsets are arranged in such a way that
;   this coincides with the initialization tables done. Note that any change
;   in arrangements affects the ASD initialization table, so better be 
;   careful !!!
;
;******************************************************************************

CHRSYSTEMDATASTARTOFFSET        equ     0

;----------------------------------------------------------
; CHR Resource Index Variables. There are 2 STP Resourcess.
;   used.
;----------------------------------------------------------

; Stopwatch resource used for SPLIT Information.

CHRRESOURCEINDEX0OFFSET         equ     0
CHRRESSPLITRESOURCEINDEXOFFESET equ     CHRRESOURCEINDEX0OFFSET

; Stopwatch resource used for LAP Information.

CHRRESOURCEINDEX1OFFSET         equ     1
CHRRESLAPRESOURCEINDEXOFFESET   equ     CHRRESOURCEINDEX1OFFSET


;----------------------------------------------------------
; Working Copy of CHR Data structure for common processing
;   Note that th
;----------------------------------------------------------

CHRBESTLAPHUNDREDTHSOFFSET      equ     2           ; Best Lap Hundredths Storage
CHRBESTLAPSECONDOFFSET          equ     3           ; Best Lap Seconds Storage
CHRBESTLAPMINUTEOFFSET          equ     4           ; Best Lap Minutes Storage
CHRBESTLAPHOUROFFSET            equ     5           ; Best Lap Hours Storage
CHRBESTLAPNOOFFSET              equ     6           ; Best Lap Number Storage
CHRPREVIOUSBESTLAPNOOFFSET      equ     7           ; Previous Best Lap number.

CHRCURRENTWORKOUTRECNOOFFSET    equ     8          ; Current Workout Record Number offset

CHRDISPLAYFORMATOFFSET          equ     9           ; Display format Setting
CHRSYSTEMFLAGOFFSET             equ     10           ; Chrono Application System Flag
CHRLAPCOUNTOFFSET               equ     11          ; Current Lap Count
CHRLAPSFREECOUNTOFFSET          equ     12          ; Number of Laps Free Counter Offset
CHRMAXLAPCOUNTCONFIGOFFSET      equ     13          ; Maximum Lap Capacity offset
CHRFREEMEMRECNOOFFSET           equ     14          ; Next Available Free Memory Record Number
CHRLASTWORKOUTRECNOOFFSET       equ     15          ; Last Workout Record Number
CHRUNSTOREWORKOUTRECNOOFFSET    equ     16          ; Unstored workout record number offset.


CHRLASTASDOFFSET                equ     16


; Size if ASD that shall be copied to the database used for the PC to identify 
;   ASD related things of the MODE.

CHRSIZEOFDBTRANSFERASD          equ     (CHRLASTASDOFFSET - CHRDISPLAYFORMATOFFSET + 1);


; Size of the Chrono Application System Data. 

CHRSYSTEMDATASIZE               equ     CHRLASTASDOFFSET+1


  



;******************************************************************************
;
; CHRONO APPLICATION DATABASE OFFSETS
;
;******************************************************************************

CHRDATABASESTARTOFFSET          equ     0


;******************************************************************************
;
; CHRONO APPLICATION DATABASE RELATED EQUATES
;
;******************************************************************************


;---------------------------------------------------
; Allocation Size
;---------------------------------------------------

CHRDBALLOCATIONSIZE     equ  (((CHRDATABASEDATASIZE/CHRPAGEACCESSSIZE) + 1) * CHRPAGEACCESSSIZE)

;---------------------------------------------------
; Database Size
;---------------------------------------------------

CHRDATABASEDATASIZE     equ  (CHRDATABASEHEADERSIZE + CHRASD_DBHEADERINFO + (CHRRECORDSIZEINFO * CHRNOOFRECORDSINIT))
CHRDATABASEHEADERSIZE   equ     5

;---------------------------------------------------
; Chrono Application specific Header size
;---------------------------------------------------

CHRASD_DBHEADERSIZE     equ     1
CHRASD_DBHEADERINFO     equ     (CHRNOOFRECORDSFIELDSIZE+CHRRECORDSIZEFIELD + CHRNOOFAPPSPECIFICINFO)
CHRNOOFAPPSPECIFICINFO  equ     9

;---------------------------------------------------
; Chrono Default number of records
;---------------------------------------------------

CHRNOOFRECORDSINIT      equ     (CHRMAXNOOFLAPS + 1)
CHRNOOFRECORDSFIELDSIZE equ     2                   ; Allot 2 bytes for the number of records field

;---------------------------------------------------
; Chrono record size
;---------------------------------------------------

CHRRECORDSIZEINFO       equ     5                   ; There are 5 bytes in each record of Lap/workout
CHRRECORDSIZEFIELD      equ     1                   ; Allot 1 byte for the record size field



CHRHEADERANDAPPSSIZE    equ     (CHRNOOFRECORDSFIELDSIZE + CHRDATABASEHEADERSIZE +CHRRECORDSIZEFIELD)



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


; Storage for the current Lap/split record number.
                                    
CHRTempCurrentLapRecNo          equ     (COREForegroundCommonBuffer +  1)

; Storage for the Best Lap Record Number

CHRTempBestLapRecNo             equ     (COREForegroundCommonBuffer +  2)


;----------------------------------------------------------
; Storage for the data structure address for display
;   in the upper and lower regions (for Lap/Split 
;   and Split/Lap display format)
;----------------------------------------------------------
CHRTempLowerDispAdd             equ     (COREForegroundCommonBuffer + 3)
CHRTempUpperDispAdd             equ     (COREForegroundCommonBuffer + 5)



;******************************************************************************
; Chrono Temporary Foreground System Data utilizing the LCD Scroll  buffer.
;******************************************************************************

;----------------------------------------------------------
;   Buffer info.
;----------------------------------------------------------


; Previous Lap Counter Information

CHRTempWorkoutPrevLapCount      equ     COREWorkBuffer


;----------------------------------------------------------
; Buffer used to hold the workout date                     
;----------------------------------------------------------

CHRTempWorkoutDay               equ     (COREWorkBuffer + 1) ; Workout Day to be displayed  
CHRTempWorkoutMonth             equ     (COREWorkBuffer + 2) ; Workout Month to be displayed
CHRTempWorkoutYearLo            equ     (COREWorkBuffer + 3) ; Workout Year Low byte to be displayed
CHRTempWokroutYearHigh          equ     (COREWorkBuffer + 4) ; Unused but do not erase.
CHRTempWorkoutDOW               equ     (COREWorkBuffer + 5) ; Workout DOW to be displayed


;----------------------------------------------------------
; Workout Record Data Buffer storage used to store 
;   temporarily after reading from database.                       
;----------------------------------------------------------

;CHRTempWorkoutDay              equ     (COREWorkBuffer + 1) ; Workout Day buffer 
CHRTempWorkoutMonthNDOW         equ     (COREWorkBuffer + 2) ; Workout Month and DOW buffer
;CHRTempWorkoutYearLo           equ     (COREWorkBuffer + 3) ; Workout Year Low byte buffer
CHRTempWorkoutBestLapRecNo      equ     (COREWorkBuffer + 4) ; Workout Best lap Record No.
CHRTempWorkoutNoOfLaps          equ     (COREWorkBuffer + 5) ; Workout No. of Laps buffer





;----------------------------------------------------------
; Temporary Split Information storage. Includes the
;   display format (HH:MM.SS or MM.SS.hh) the split
;   information and the lap number corresponding the split.                    
;----------------------------------------------------------

CHRTempSplitDispFormat          equ     (COREWorkBuffer + 6)
CHRTempSplitHundredths          equ     (COREWorkBuffer + 7)
CHRTempSplitSeconds             equ     (COREWorkBuffer + 8)
CHRTempSplitMinutes             equ     (COREWorkBuffer + 9)
CHRTempSplitHours               equ     (COREWorkBuffer + 10)
CHRTempSplitLapNo               equ     (COREWorkBuffer + 11)


;----------------------------------------------------------
; Temporary Lap Information storage. Includes the
;   display format (HH:MM.SS or MM.SS.hh) and the lap
;   information.                   
;----------------------------------------------------------

CHRTempLapDispFormat            equ     (COREWorkBuffer + 12)
CHRTempLapHundredths            equ     (COREWorkBuffer + 13)
CHRTempLapSeconds               equ     (COREWorkBuffer + 14)
CHRTempLapMinutes               equ     (COREWorkBuffer + 15)
CHRTempLapHours                 equ     (COREWorkBuffer + 16)


;----------------------------------------------------------
; Buffer for Average Lap storage: Hundredths, seconds, 
;   minutes, and hours.
;----------------------------------------------------------

CHRAveLapHundredths             equ     (COREWorkBuffer + 21) 
CHRAveLapSeconds                equ     (COREWorkBuffer + 22) 
CHRAveLapMinutes                equ     (COREWorkBuffer + 23) 
CHRAveLapHours                  equ     (COREWorkBuffer + 24) 

















;----------------------------------------------------------
; Temporary storage for the workouts first and last
;   workout pointer.
;----------------------------------------------------------

CHRTempWorkoutLastSplitRecNo    equ     (COREWorkBuffer + 25)
CHRTempWorkoutFirstSplitRecNo   equ     (COREWorkBuffer + 26)


CHRSIZEOFBESTLAPANDLAPNUMBER    equ     (CHRTempWorkoutNoOfLaps - CHRTempWorkoutBestLapRecNo + 1)
CHRSIZEOFDATETOBECOPIED         equ     (CHRTempWorkoutDOW - CHRTempWorkoutDay +1)
CHRSIZEOFDATETOBESTORED         equ     (CHRTempWorkoutYearLo - CHRTempWorkoutDay +1)
CHRSIZEOFDATESTAMPTOREAD        equ     CHRSIZEOFDATETOBESTORED

CHRSIZEOFWORKOUTINFOTOREAD      equ     5
CHROFFSETOFNOOFLAPSFROMDAY      equ     (CHRTempWorkoutNoOfLaps - CHRTempWorkoutDay)
CHROFFSETOFBESTLAPRECFROMDAY	equ    	(CHRTempWorkoutBestLapRecNo - CHRTempWorkoutDay)
CHROFFSETOFLAPNUMBERFROMHUND    equ     (CHRTempSplitLapNo - CHRTempSplitHundredths)


CHRSIZEOFSPLITTOBESTORED        equ     (CHRTempSplitLapNo - CHRTempSplitHundredths)
CHRSIZEOFSPLITTOBEREAD          equ     CHRSIZEOFSPLITTOBESTORED


CHRSIZEOFSPLITTIMETOBEREAD      equ     (CHRTempSplitHours - CHRTempSplitHundredths + 1)


  

CHRSIZEOFWORKOUTENTRY           equ     (CHRTempWorkoutBestLapRecNo - CHRTempWorkoutDay)


CHRDBCHRONOSPECIFICDATAOFFSET_FOR_NO_OF_RECLO equ 1
CHRDBCHRONOSPECIFICDATAOFFSET_FOR_ASD equ 3







;----------------------------------------------------------
; General purpose buffer for Hundredths, seconds, minutes,
;   and hours. This is used only for the 
;----------------------------------------------------------

CHRTempBufferHundredths         equ     (KRESHundBuffer)
CHRTempBufferSeconds            equ     (KRESSecBuffer + 18)
CHRTempBufferMinutes            equ     (KRESMinBuffer + 19)
CHRTempBufferHours              equ     (KRESHrBuffer + 20)












;*******************************************************************************
; Chrono Temporary System Data utilizing the Kernel's
;   COREBackgroundCommonBuffer.
;*******************************************************************************


; Alloc Size Vars, High and Low Database Size address (2 bytes).

CHRTempAllocSize                equ     (COREBackgroundCommonBuffer + 0)
CHRTempAllocSizeLo              equ     (COREBackgroundCommonBuffer + 0)
CHRTempAllocSizeHi              equ     (COREBackgroundCommonBuffer + 1)



; Database size vars, High and Low Database Size address (2 bytes).

CHRTempDBSize                   equ     (COREBackgroundCommonBuffer + 2)
CHRTempDBSizeLo                 equ     (COREBackgroundCommonBuffer + 2)
CHRTempDBSizeHi                 equ     (COREBackgroundCommonBuffer + 3)

; Chrono Specific Header Size Info (1byte)

CHRTempDBCHRSpecificHeaderSize  equ     (COREBackgroundCommonBuffer + 4)

; Chrono Number of records Storage (2bytes)

CHRTempDBaseNumberOfRecords     equ     (COREBackgroundCommonBuffer + 5)
CHRTempDBaseNumberOfRecordsLo   equ     (COREBackgroundCommonBuffer + 5)
CHRTempDBaseNumberOfRecordsHi   equ     (COREBackgroundCommonBuffer + 6)

; Chrono Records size storage (1 byte)

CHRTempDBaseRecordSize          equ     (COREBackgroundCommonBuffer + 7)
   


;----------------------------------------------------------
; Buffer used to hold the started workout date stamp from
;   the primary timezone                       
;----------------------------------------------------------

CHRTempPTZDay                   equ     (COREBackgroundCommonBuffer + 1) ; PTZ Day Snapshot  
CHRTempPTZMonth                 equ     (COREBackgroundCommonBuffer + 2) ; PTZ Month Snapshot
CHRTempPTZYearLo                equ     (COREBackgroundCommonBuffer + 3) ; PTZ Year Low byte Snapshot
CHRTempPTZYearHigh              equ     (COREBackgroundCommonBuffer + 4) ; PTZ Year High byte Snapshot.
CHRTempPTZDOW                   equ     (COREBackgroundCommonBuffer + 5) ; PTZ DOW Snapshot

;----------------------------------------------------------
; Buffer used to hold the corrected date stamp to be saved 
;   in the database. Note that this buffer should have
;   the similar address to the PTZ buffer above.
;----------------------------------------------------------

CHRTempSaveWorkoutDay           equ     (COREBackgroundCommonBuffer + 1) ; Workout Day buffer 
CHRTempSaveWorkoutMonthNDOW     equ     (COREBackgroundCommonBuffer + 2) ; Workout Month and DOW buffer
CHRTempSaveWorkoutYearLo        equ     (COREBackgroundCommonBuffer + 3) ; Workout Year Low byte buffer
CHRTempSaveWorkoutBestLapRecNo  equ     (COREBackgroundCommonBuffer + 4) ; Workout Best lap Record No.
CHRTempSaveWorkoutNoOfLaps      equ     (COREBackgroundCommonBuffer + 5) ; Workout No. of Laps buffer







;----------------------------------------------------------
; Chrono System Flag Bit Definitions.
;----------------------------------------------------------

                                                    ;   
bCHRFreeMSGNotAllowed           equ     00000001b   ; Set when Free Memory message is
                                                    ;   not allowed to be displayed.    
                                                    ;

                                                    ;
bCHRWorkoutStorageNotAllowed    equ     00000010b   ; Set when the system is configured
                                                    ;   not to allow workout storage
                                                    ;   meaning there can be no laps
                                                    ;   free and no recall.
                                                    ;

                                                    ;               
bCHRMemoryFull                  equ     00000100b   ; Set when Memory is Full to indicate
                                                    ;   that a workout cannot be started.
                                                    ;

                                                    ;
bCHRDisableWorkoutDatabase      equ     00001000b   ; Set when workout storage capability
                                                    ;   is disabled.                                                    
                                                    ;

													
													;
bCHRDefaultStateNotFromModeBanner  equ     00001000b ; Set when the inside the default state
													;	and not coming from the mode banner.
													;


                                                    ;
bCHRAllowRecallAccess           equ     00010000b   ; Set when we allow recall access.
                                                    ;

                                                    ;
bCHRSplitHasBeenTaken           equ     00100000b   ; Set when a split has been taken previously.  
                                                    ;

bCHRStoppedSplitHeld            equ     01000000b   ; Set when a stopped split has been held in
                                                    ;   the database.


bCHRRunningSplitHeld			equ    	10000000b   ; Set when a running split has been held.


;----------------------------------------------------------
; Chrono Display Flags
;----------------------------------------------------------

bCHRDispLAPInLowerPortion       equ     00000001b   ; Set when we want to display the lap in 
                                                    ;   the lower portion.

bCHRDispWithTimeFormat          equ     00000010b   ; Set when we want to display TOD.




