diff code_part1/OSTC_code_asm_part1/dive_icons.asm @ 121:e0f29e20bd24

Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
author JeanDo
date Sun, 26 Dec 2010 23:49:11 +0100
parents 8aa8acada0fd
children 6a94f96e9cea
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/dive_icons.asm	Sun Dec 26 18:34:28 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/dive_icons.asm	Sun Dec 26 23:49:11 2010 +0100
@@ -21,16 +21,29 @@
 ;=============================================================================
 ; HISTORY
 ;  2010-12-21 : [jDG] Creation
+;  2011-01-03 : [jDG] Force first gas to be active from depth=0.
 ;
 ; RATIONALS: Enabled gazes are used to predict TTS in divemode, hence they
 ;            are a critical aspect that should be double-checked before dive.
 ;
+; Known bug:
 ;=============================================================================
 ; Display either Air, Nitrox, or Trimix icon (in surface mode).
 ; Inputs:  None: explore the gaz list.
 ; Ouputs:  None.
 ; Trashed: hi:lo, PROD, and registers trashed by color_processor.asm
 dive_type_icons:
+            ;---- Don't display when not in the right deco mode --------------
+            btfsc   FLAG_apnoe_mode     ; Apnoe selected ?
+            return                      ; YES: just return.
+            btfsc   gauge_mode          ; gauge mode ?
+            return                      ; YES: also return.
+            
+            ;---- Don't display CF#41 is false -------------------------------
+            GETCUSTOM8  d'41'           ; Read CF#41
+            btfss   WREG,0              ; Set ?
+            return                      ; NO: return
+
             ;---- Common setup -----------------------------------------------
             movlw   .170
             movff   WREG, img_top
@@ -39,26 +52,48 @@
             movlw   UPPER(dive_air_block)
             movwf   TBLPTRU
 
-            ;---- Explore gazlist --------------------------------------------
-            ; EEADR+0 = O2%
-            ; EEADR+1 = He%
-            ; EEADR+4 = next gaz O2%
+            ;---- Explore gas list -------------------------------------------
+            ; EEADR <-- gas# + 6
+            ; EEADR-2 = default O2%
+            ; EEADR-1 = default He%
+            ; EEADR+0 = current O2%
+            ; EEADR+1 = current He%
+            ; EEADR+4 = next gaz current O2%
             
           	read_int_eeprom		d'27'	; read gas flag register --> hi
           	movff   EEDATA,hi
-          	movlw   5                   ; Number of gas to check --> lo
-          	movwf   lo
-          	movlw	6-4                 ; Gas list start in eeprom.
-	        movwf	EEADR
+            rrcf    hi                  ; Dummy shift first... why does it works ?
+          	setf    lo                  ; Start with gas# -1
 	        clrf    PRODL               ; =0 : no nitrox found yet.
 
 dive_type_loop:
-            movlw   4                   ; Advance to next gas data in EEPROM.
-            addwf   EEADR,F
+            incf    lo,F                ; Next gaz number.
+
+            movlw   .33                 ; Read first gas #.
+            movwf   EEADR
+            call    read_eeprom
+            incf    lo,W                ; Current gas# 1..5
+            subwf   EEDATA,W            ; == first ?
+            bz      dive_type_loop_2    ; YES: analyse that gas !
+            
             rrcf    hi                  ; Check next enabled flag ?
             bnc     dive_type_loop_9    ; Disabled.
-            
+
+            movlw   .28                 ; Switch depth is at gas#+28
+            addwf   lo,W
+            movwf   EEADR               ; address in EEPROM.
+            call    read_eeprom         ; Read depth
+            clrf    WREG                
+            cpfsgt  EEDATA              ; is depth > 0 ?
+            bra      dive_type_loop_9   ; NO: disabled too.
+
+dive_type_loop_2:
+            rlncf   lo,W                ; Gas# times 4
+            rlncf   WREG
+            addlw   4+2                 ; 6 + 4 * gas#
+            movwf   EEADR               ; address in EEPROM for current O2.
             call    read_eeprom         ; Read O2 %
+
             movlw   .21
             cpfseq  EEDATA              ; O2 == 21% ?
             setf    PRODL               ; NO: not simple air !
@@ -71,8 +106,9 @@
             bra     dive_trimix_icon    ; No: go for the Tx icon, now.
             
 dive_type_loop_9:
-            decfsz  lo                  ; More gas ?
-            bra     dive_type_loop      ; YES: loop...
+            movlw   4                   ; Already done all gas ? (index 0..4)
+            cpfseq  lo                  ; gas# == 4 ?
+            bra     dive_type_loop      ; NO: loop...
 	        
 	        btfsc   PRODL,0             ; Did we find a nitrox gaz ?
 	        bra     dive_nitrox_icon    ; YES: display nitrox icon.;.