comparison 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
comparison
equal deleted inserted replaced
119:f24137eb85de 121:e0f29e20bd24
19 ; 19 ;
20 ; Copyright (c) 2010, JD Gascuel. 20 ; Copyright (c) 2010, JD Gascuel.
21 ;============================================================================= 21 ;=============================================================================
22 ; HISTORY 22 ; HISTORY
23 ; 2010-12-21 : [jDG] Creation 23 ; 2010-12-21 : [jDG] Creation
24 ; 2011-01-03 : [jDG] Force first gas to be active from depth=0.
24 ; 25 ;
25 ; RATIONALS: Enabled gazes are used to predict TTS in divemode, hence they 26 ; RATIONALS: Enabled gazes are used to predict TTS in divemode, hence they
26 ; are a critical aspect that should be double-checked before dive. 27 ; are a critical aspect that should be double-checked before dive.
27 ; 28 ;
29 ; Known bug:
28 ;============================================================================= 30 ;=============================================================================
29 ; Display either Air, Nitrox, or Trimix icon (in surface mode). 31 ; Display either Air, Nitrox, or Trimix icon (in surface mode).
30 ; Inputs: None: explore the gaz list. 32 ; Inputs: None: explore the gaz list.
31 ; Ouputs: None. 33 ; Ouputs: None.
32 ; Trashed: hi:lo, PROD, and registers trashed by color_processor.asm 34 ; Trashed: hi:lo, PROD, and registers trashed by color_processor.asm
33 dive_type_icons: 35 dive_type_icons:
36 ;---- Don't display when not in the right deco mode --------------
37 btfsc FLAG_apnoe_mode ; Apnoe selected ?
38 return ; YES: just return.
39 btfsc gauge_mode ; gauge mode ?
40 return ; YES: also return.
41
42 ;---- Don't display CF#41 is false -------------------------------
43 GETCUSTOM8 d'41' ; Read CF#41
44 btfss WREG,0 ; Set ?
45 return ; NO: return
46
34 ;---- Common setup ----------------------------------------------- 47 ;---- Common setup -----------------------------------------------
35 movlw .170 48 movlw .170
36 movff WREG, img_top 49 movff WREG, img_top
37 movlw .110 50 movlw .110
38 movff WREG, img_left 51 movff WREG, img_left
39 movlw UPPER(dive_air_block) 52 movlw UPPER(dive_air_block)
40 movwf TBLPTRU 53 movwf TBLPTRU
41 54
42 ;---- Explore gazlist -------------------------------------------- 55 ;---- Explore gas list -------------------------------------------
43 ; EEADR+0 = O2% 56 ; EEADR <-- gas# + 6
44 ; EEADR+1 = He% 57 ; EEADR-2 = default O2%
45 ; EEADR+4 = next gaz O2% 58 ; EEADR-1 = default He%
59 ; EEADR+0 = current O2%
60 ; EEADR+1 = current He%
61 ; EEADR+4 = next gaz current O2%
46 62
47 read_int_eeprom d'27' ; read gas flag register --> hi 63 read_int_eeprom d'27' ; read gas flag register --> hi
48 movff EEDATA,hi 64 movff EEDATA,hi
49 movlw 5 ; Number of gas to check --> lo 65 rrcf hi ; Dummy shift first... why does it works ?
50 movwf lo 66 setf lo ; Start with gas# -1
51 movlw 6-4 ; Gas list start in eeprom.
52 movwf EEADR
53 clrf PRODL ; =0 : no nitrox found yet. 67 clrf PRODL ; =0 : no nitrox found yet.
54 68
55 dive_type_loop: 69 dive_type_loop:
56 movlw 4 ; Advance to next gas data in EEPROM. 70 incf lo,F ; Next gaz number.
57 addwf EEADR,F 71
72 movlw .33 ; Read first gas #.
73 movwf EEADR
74 call read_eeprom
75 incf lo,W ; Current gas# 1..5
76 subwf EEDATA,W ; == first ?
77 bz dive_type_loop_2 ; YES: analyse that gas !
78
58 rrcf hi ; Check next enabled flag ? 79 rrcf hi ; Check next enabled flag ?
59 bnc dive_type_loop_9 ; Disabled. 80 bnc dive_type_loop_9 ; Disabled.
60 81
82 movlw .28 ; Switch depth is at gas#+28
83 addwf lo,W
84 movwf EEADR ; address in EEPROM.
85 call read_eeprom ; Read depth
86 clrf WREG
87 cpfsgt EEDATA ; is depth > 0 ?
88 bra dive_type_loop_9 ; NO: disabled too.
89
90 dive_type_loop_2:
91 rlncf lo,W ; Gas# times 4
92 rlncf WREG
93 addlw 4+2 ; 6 + 4 * gas#
94 movwf EEADR ; address in EEPROM for current O2.
61 call read_eeprom ; Read O2 % 95 call read_eeprom ; Read O2 %
96
62 movlw .21 97 movlw .21
63 cpfseq EEDATA ; O2 == 21% ? 98 cpfseq EEDATA ; O2 == 21% ?
64 setf PRODL ; NO: not simple air ! 99 setf PRODL ; NO: not simple air !
65 100
66 incf EEADR ; Read He % 101 incf EEADR ; Read He %
69 clrf WREG ; H2 == 0% ? 104 clrf WREG ; H2 == 0% ?
70 cpfseq EEDATA 105 cpfseq EEDATA
71 bra dive_trimix_icon ; No: go for the Tx icon, now. 106 bra dive_trimix_icon ; No: go for the Tx icon, now.
72 107
73 dive_type_loop_9: 108 dive_type_loop_9:
74 decfsz lo ; More gas ? 109 movlw 4 ; Already done all gas ? (index 0..4)
75 bra dive_type_loop ; YES: loop... 110 cpfseq lo ; gas# == 4 ?
111 bra dive_type_loop ; NO: loop...
76 112
77 btfsc PRODL,0 ; Did we find a nitrox gaz ? 113 btfsc PRODL,0 ; Did we find a nitrox gaz ?
78 bra dive_nitrox_icon ; YES: display nitrox icon.;. 114 bra dive_nitrox_icon ; YES: display nitrox icon.;.
79 115
80 ;---- Draw air --------------------------------------------------- 116 ;---- Draw air ---------------------------------------------------