Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/dive_icons.asm @ 217:ce6f16711567
BUGFIX gas switch
+ Make sure not to pass gas switch
+ Don't clobber ratio N2/He when canceling ascent passing gas switch.
+ Build-up GF_low history during the whole dive.
author | JeanDo |
---|---|
date | Thu, 24 Feb 2011 23:22:32 +0100 |
parents | 8bda2452a532 |
children | 420e62cd88ad |
rev | line source |
---|---|
110 | 1 ;============================================================================= |
2 ; | |
3 ; File dive_icons.asm | |
4 ; | |
5 ; Draw Air/Nitrox/Trimix colored icon on surface mode. | |
6 ; | |
7 ; This program is free software: you can redistribute it and/or modify | |
8 ; it under the terms of the GNU General Public License as published by | |
9 ; the Free Software Foundation, either version 3 of the License, or | |
10 ; (at your option) any later version. | |
11 ; | |
12 ; This program is distributed in the hope that it will be useful, | |
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ; GNU General Public License for more details. | |
16 ; | |
17 ; You should have received a copy of the GNU General Public License | |
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 ; | |
20 ; Copyright (c) 2010, JD Gascuel. | |
21 ;============================================================================= | |
22 ; HISTORY | |
23 ; 2010-12-21 : [jDG] Creation | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
24 ; 2011-01-03 : [jDG] Force first gas to be active from depth=0. |
110 | 25 ; |
26 ; RATIONALS: Enabled gazes are used to predict TTS in divemode, hence they | |
27 ; are a critical aspect that should be double-checked before dive. | |
28 ; | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
29 ; Known bug: |
110 | 30 ;============================================================================= |
123 | 31 mixtype_icons code |
32 | |
33 ;============================================================================= | |
110 | 34 ; Display either Air, Nitrox, or Trimix icon (in surface mode). |
35 ; Inputs: None: explore the gaz list. | |
36 ; Ouputs: None. | |
37 ; Trashed: hi:lo, PROD, and registers trashed by color_processor.asm | |
38 dive_type_icons: | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
39 ;---- Don't display when not in the right deco mode -------------- |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
40 btfsc FLAG_apnoe_mode ; Apnoe selected ? |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
41 return ; YES: just return. |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
42 btfsc gauge_mode ; gauge mode ? |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
43 return ; YES: also return. |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
44 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
45 ;---- Don't display CF#41 is false ------------------------------- |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
46 GETCUSTOM8 d'41' ; Read CF#41 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
47 btfss WREG,0 ; Set ? |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
48 return ; NO: return |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
49 |
110 | 50 ;---- Common setup ----------------------------------------------- |
51 movlw .170 | |
123 | 52 movff WREG, win_top |
110 | 53 movlw .110 |
123 | 54 movff WREG, win_leftx2 |
110 | 55 movlw UPPER(dive_air_block) |
56 movwf TBLPTRU | |
57 | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
58 ;---- Explore gas list ------------------------------------------- |
145 | 59 ; EEADR <-- 4*gas# + 6 |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
60 ; EEADR-2 = default O2% |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
61 ; EEADR-1 = default He% |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
62 ; EEADR+0 = current O2% |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
63 ; EEADR+1 = current He% |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
64 ; EEADR+4 = next gaz current O2% |
110 | 65 |
145 | 66 clrf EEADRH ; read gas flag register --> hi |
67 movlw .27 | |
68 movwf EEADR | |
69 call read_eeprom | |
110 | 70 movff EEDATA,hi |
145 | 71 rlcf hi,F ; Push a dummy bit. |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
72 setf lo ; Start with gas# -1 |
110 | 73 clrf PRODL ; =0 : no nitrox found yet. |
74 | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
75 movlw .33 ; Read first gas #. |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
76 movwf EEADR |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
77 call read_eeprom |
145 | 78 movff EEDATA,PRODH ; first --> PRODH (1..5) |
79 | |
80 dive_type_loop: | |
81 incf lo,F ; Next gaz number. Range 0..4 | |
82 | |
83 rrcf hi,F ; Rotate BEFORE checking active gas! | |
84 | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
85 incf lo,W ; Current gas# 1..5 |
145 | 86 subwf PRODH,W ; == first gas ? |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
87 bz dive_type_loop_2 ; YES: analyse that gas ! |
145 | 88 |
89 btfss hi,0 ; Is this gas enabled ? | |
90 bra dive_type_loop_9 ; No: disabled. | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
91 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
92 movlw .28 ; Switch depth is at gas#+28 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
93 addwf lo,W |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
94 movwf EEADR ; address in EEPROM. |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
95 call read_eeprom ; Read depth |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
96 clrf WREG |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
97 cpfsgt EEDATA ; is depth > 0 ? |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
98 bra dive_type_loop_9 ; NO: disabled too. |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
99 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
100 dive_type_loop_2: |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
101 rlncf lo,W ; Gas# times 4 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
102 rlncf WREG |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
103 addlw 4+2 ; 6 + 4 * gas# |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
104 movwf EEADR ; address in EEPROM for current O2. |
110 | 105 call read_eeprom ; Read O2 % |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
106 |
110 | 107 movlw .21 |
108 cpfseq EEDATA ; O2 == 21% ? | |
109 setf PRODL ; NO: not simple air ! | |
110 | |
111 incf EEADR ; Read He % | |
112 call read_eeprom | |
113 decf EEADR | |
114 clrf WREG ; H2 == 0% ? | |
115 cpfseq EEDATA | |
116 bra dive_trimix_icon ; No: go for the Tx icon, now. | |
117 | |
118 dive_type_loop_9: | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
119 movlw 4 ; Already done all gas ? (index 0..4) |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
120 cpfseq lo ; gas# == 4 ? |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
121 bra dive_type_loop ; NO: loop... |
110 | 122 |
123 btfsc PRODL,0 ; Did we find a nitrox gaz ? | |
124 bra dive_nitrox_icon ; YES: display nitrox icon.;. | |
125 | |
126 ;---- Draw air --------------------------------------------------- | |
127 dive_air_icon: | |
128 movlw HIGH(dive_air_block) | |
129 movwf TBLPTRH | |
130 movlw LOW(dive_air_block) | |
131 movwf TBLPTRL | |
132 bra dive_gaz_99 | |
133 | |
134 dive_nitrox_icon: | |
135 movlw HIGH(dive_nitrox_block) | |
136 movwf TBLPTRH | |
137 movlw LOW(dive_nitrox_block) | |
138 movwf TBLPTRL | |
139 bra dive_gaz_99 | |
140 | |
141 dive_trimix_icon: | |
142 movlw HIGH(dive_trimix_block) | |
143 movwf TBLPTRH | |
144 movlw LOW(dive_trimix_block) | |
145 movwf TBLPTRL | |
146 | |
147 dive_gaz_99: | |
123 | 148 call color_image |
110 | 149 movlb 1 ; Back to bank 1. |
150 return | |
151 | |
152 ;============================================================================= | |
153 | |
154 #include dive_air.inc | |
155 #include dive_nitrox.inc | |
156 #include dive_trimix.inc | |
157 |