annotate src/gaslist.asm @ 1:e4e662746c02

init2
author heinrichsweikamp
date Wed, 24 Apr 2013 19:39:39 +0200
parents 11d4fc797f74
children 440e537e19d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File gaslist.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Managing OSTC3 gas list
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-08-11 : [jDG] Creation.
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 #include "ostc3.inc" ; Mandatory header
heinrichsweikamp
parents:
diff changeset
13 #include "convert.inc"
heinrichsweikamp
parents:
diff changeset
14 #include "math.inc" ; div16x16 for MOD calculations
heinrichsweikamp
parents:
diff changeset
15 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
16 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "tft_outputs.inc"
heinrichsweikamp
parents:
diff changeset
18
heinrichsweikamp
parents:
diff changeset
19 #include "shared_definitions.h"
heinrichsweikamp
parents:
diff changeset
20
heinrichsweikamp
parents:
diff changeset
21 CBLOCK tmp+0x40 ; Keep space for menu processor
heinrichsweikamp
parents:
diff changeset
22 gaslist_gas
heinrichsweikamp
parents:
diff changeset
23 gaslist_O2
heinrichsweikamp
parents:
diff changeset
24 gaslist_He
heinrichsweikamp
parents:
diff changeset
25 gaslist_depth
heinrichsweikamp
parents:
diff changeset
26 gaslist_Type
heinrichsweikamp
parents:
diff changeset
27 ; Reserved to tmp+0x5F
heinrichsweikamp
parents:
diff changeset
28 ENDC
heinrichsweikamp
parents:
diff changeset
29
heinrichsweikamp
parents:
diff changeset
30 extern convert_mbar_to_feet
heinrichsweikamp
parents:
diff changeset
31
heinrichsweikamp
parents:
diff changeset
32 gui CODE
heinrichsweikamp
parents:
diff changeset
33 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
34 ; Append gas description to current string.
heinrichsweikamp
parents:
diff changeset
35 ; Input: PRODL : gas number (0..4)
heinrichsweikamp
parents:
diff changeset
36 ; FSR2 : Current string position.
heinrichsweikamp
parents:
diff changeset
37 ; Output: Text appended into buffer pointed by FSR2.
heinrichsweikamp
parents:
diff changeset
38 extern customview_show_mix
heinrichsweikamp
parents:
diff changeset
39 global gaslist_strcat_gas
heinrichsweikamp
parents:
diff changeset
40 gaslist_strcat_gas:
heinrichsweikamp
parents:
diff changeset
41 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents)
heinrichsweikamp
parents:
diff changeset
42 ; Retrieve gas definition:
heinrichsweikamp
parents:
diff changeset
43 gaslist_strcat_gas_0:
heinrichsweikamp
parents:
diff changeset
44 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
45 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
46 movff PLUSW1,gaslist_O2
heinrichsweikamp
parents:
diff changeset
47 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
48 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
49 movff PLUSW1,gaslist_He
heinrichsweikamp
parents:
diff changeset
50
heinrichsweikamp
parents:
diff changeset
51 movff gaslist_O2,lo
heinrichsweikamp
parents:
diff changeset
52 movff gaslist_He,hi
heinrichsweikamp
parents:
diff changeset
53 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
heinrichsweikamp
parents:
diff changeset
54 return
heinrichsweikamp
parents:
diff changeset
55
heinrichsweikamp
parents:
diff changeset
56
heinrichsweikamp
parents:
diff changeset
57 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
58 ; Append current mix to current string (For divemode)
heinrichsweikamp
parents:
diff changeset
59 ; Input: FSR2 : Current string position.
heinrichsweikamp
parents:
diff changeset
60 ; Output: Text appended into buffer pointed by FSR2.
heinrichsweikamp
parents:
diff changeset
61 global gaslist_strcat_gasx
heinrichsweikamp
parents:
diff changeset
62 gaslist_strcat_gasx: ; Show current O2/He mix
heinrichsweikamp
parents:
diff changeset
63 STRCAT_TEXT tGas
heinrichsweikamp
parents:
diff changeset
64 STRCAT ": "
heinrichsweikamp
parents:
diff changeset
65 movff char_I_O2_ratio,lo
heinrichsweikamp
parents:
diff changeset
66 movff char_I_He_ratio,hi
heinrichsweikamp
parents:
diff changeset
67 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
heinrichsweikamp
parents:
diff changeset
68 return
heinrichsweikamp
parents:
diff changeset
69
heinrichsweikamp
parents:
diff changeset
70 global gaslist_show_type
heinrichsweikamp
parents:
diff changeset
71 extern tGasDisabled
heinrichsweikamp
parents:
diff changeset
72 extern tDilDisabled
heinrichsweikamp
parents:
diff changeset
73 gaslist_show_type:
heinrichsweikamp
parents:
diff changeset
74 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
75 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG]
heinrichsweikamp
parents:
diff changeset
76 movff PLUSW1,gaslist_Type
heinrichsweikamp
parents:
diff changeset
77 STRCAT_TEXT tType
heinrichsweikamp
parents:
diff changeset
78 lfsr FSR1,tGasDisabled ; Base text number
heinrichsweikamp
parents:
diff changeset
79 btfsc ccr_diluent_setup ; In CCR setup?
heinrichsweikamp
parents:
diff changeset
80 lfsr FSR1,tDilDisabled ; Base text number
heinrichsweikamp
parents:
diff changeset
81 movff gaslist_Type,WREG ; 0-3
heinrichsweikamp
parents:
diff changeset
82 rlncf WREG ; x2
heinrichsweikamp
parents:
diff changeset
83 addwf FSR1L,F
heinrichsweikamp
parents:
diff changeset
84 movlw .0
heinrichsweikamp
parents:
diff changeset
85 addwfc FSR1H,F
heinrichsweikamp
parents:
diff changeset
86 call strcat_text
heinrichsweikamp
parents:
diff changeset
87 return
heinrichsweikamp
parents:
diff changeset
88
heinrichsweikamp
parents:
diff changeset
89 global gaslist_toggle_type
heinrichsweikamp
parents:
diff changeset
90 gaslist_toggle_type:
heinrichsweikamp
parents:
diff changeset
91 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
92 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG]
heinrichsweikamp
parents:
diff changeset
93 movff PLUSW1,gaslist_Type
heinrichsweikamp
parents:
diff changeset
94 incf gaslist_Type,F ; 0-3/0-2
heinrichsweikamp
parents:
diff changeset
95 btfsc ccr_diluent_setup ; In CCR setup?
heinrichsweikamp
parents:
diff changeset
96 bra gaslist_toggle_type2 ; Yes
heinrichsweikamp
parents:
diff changeset
97 btfsc gaslist_Type,2 ; >3?
heinrichsweikamp
parents:
diff changeset
98 clrf gaslist_Type ; Clear to zero
heinrichsweikamp
parents:
diff changeset
99 movff gaslist_Type,PLUSW1 ; Copy back result
heinrichsweikamp
parents:
diff changeset
100 return
heinrichsweikamp
parents:
diff changeset
101
heinrichsweikamp
parents:
diff changeset
102 gaslist_toggle_type2:
heinrichsweikamp
parents:
diff changeset
103 movlw .3
heinrichsweikamp
parents:
diff changeset
104 cpfslt gaslist_Type ; >2?
heinrichsweikamp
parents:
diff changeset
105 clrf gaslist_Type ; Clear to zero
heinrichsweikamp
parents:
diff changeset
106 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
107 movff gaslist_Type,PLUSW1 ; Copy back result
heinrichsweikamp
parents:
diff changeset
108 return
heinrichsweikamp
parents:
diff changeset
109
heinrichsweikamp
parents:
diff changeset
110 global gaslist_setSP
heinrichsweikamp
parents:
diff changeset
111 gaslist_setSP:
heinrichsweikamp
parents:
diff changeset
112 movff PRODL,gaslist_gas ; 0-4
heinrichsweikamp
parents:
diff changeset
113 return
heinrichsweikamp
parents:
diff changeset
114
heinrichsweikamp
parents:
diff changeset
115 extern tbar
heinrichsweikamp
parents:
diff changeset
116 global gaslist_strcat_setpoint
heinrichsweikamp
parents:
diff changeset
117 global gaslist_strcat_setpoint_0
heinrichsweikamp
parents:
diff changeset
118 gaslist_strcat_setpoint:
heinrichsweikamp
parents:
diff changeset
119 call gaslist_setSP
heinrichsweikamp
parents:
diff changeset
120 gaslist_strcat_setpoint_0:
heinrichsweikamp
parents:
diff changeset
121 bsf leftbind
heinrichsweikamp
parents:
diff changeset
122 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint
heinrichsweikamp
parents:
diff changeset
123 bra gaslist_strcat_setpoint2 ; Short version
heinrichsweikamp
parents:
diff changeset
124 STRCAT_TEXT tSP
heinrichsweikamp
parents:
diff changeset
125 incf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
126 movwf lo
heinrichsweikamp
parents:
diff changeset
127 output_8
heinrichsweikamp
parents:
diff changeset
128 bcf leftbind
heinrichsweikamp
parents:
diff changeset
129 PUTC ":"
heinrichsweikamp
parents:
diff changeset
130 gaslist_strcat_setpoint2: ; Short version
heinrichsweikamp
parents:
diff changeset
131 lfsr FSR1,opt_gas_type
heinrichsweikamp
parents:
diff changeset
132 btfsc divemode
heinrichsweikamp
parents:
diff changeset
133 bra gaslist_strcat_setpoint4 ; no "*" in divemode
heinrichsweikamp
parents:
diff changeset
134 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
135 decf PLUSW1,W ; Type-1 into WREG
heinrichsweikamp
parents:
diff changeset
136 bnz gaslist_strcat_setpoint3 ; Not "first"
heinrichsweikamp
parents:
diff changeset
137 PUTC "*"
heinrichsweikamp
parents:
diff changeset
138 bra gaslist_strcat_setpoint4
heinrichsweikamp
parents:
diff changeset
139 gaslist_strcat_setpoint3:
heinrichsweikamp
parents:
diff changeset
140 PUTC " "
heinrichsweikamp
parents:
diff changeset
141 gaslist_strcat_setpoint4:
heinrichsweikamp
parents:
diff changeset
142 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
143 lfsr FSR1,char_I_setpoint_cbar
heinrichsweikamp
parents:
diff changeset
144 movf PLUSW1,W
heinrichsweikamp
parents:
diff changeset
145 movwf lo
heinrichsweikamp
parents:
diff changeset
146 clrf hi
heinrichsweikamp
parents:
diff changeset
147 bsf leftbind
heinrichsweikamp
parents:
diff changeset
148 output_16dp d'3'
heinrichsweikamp
parents:
diff changeset
149 btfsc divemode
heinrichsweikamp
parents:
diff changeset
150 bra gaslist_strcat_setpoint5 ; Skip text in divemode
heinrichsweikamp
parents:
diff changeset
151 STRCAT_TEXT tbar
heinrichsweikamp
parents:
diff changeset
152 gaslist_strcat_setpoint5:
heinrichsweikamp
parents:
diff changeset
153 PUTC " "
heinrichsweikamp
parents:
diff changeset
154 ; Read switch depth
heinrichsweikamp
parents:
diff changeset
155 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
156 lfsr FSR1,char_I_setpoint_change
heinrichsweikamp
parents:
diff changeset
157 movff PLUSW1,lo
heinrichsweikamp
parents:
diff changeset
158 bra gaslist_strcat_4 ; And return...
heinrichsweikamp
parents:
diff changeset
159
heinrichsweikamp
parents:
diff changeset
160 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
161 ; Append gas description to current string.
heinrichsweikamp
parents:
diff changeset
162 ; Input: PRODL : gas number (0..4)
heinrichsweikamp
parents:
diff changeset
163 ; FSR2 : Current string position.
heinrichsweikamp
parents:
diff changeset
164 ; Output: Text appended into buffer pointed by FSR2.
heinrichsweikamp
parents:
diff changeset
165 ;
heinrichsweikamp
parents:
diff changeset
166 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry.
heinrichsweikamp
parents:
diff changeset
167
heinrichsweikamp
parents:
diff changeset
168 gaslist_strcat_gas_better: ; Yes, check if this is a "better gas"
heinrichsweikamp
parents:
diff changeset
169 movlw .0
heinrichsweikamp
parents:
diff changeset
170 movff WREG,win_invert
heinrichsweikamp
parents:
diff changeset
171 incf gaslist_gas,W ; gaslist_gas+1 -> WREG
heinrichsweikamp
parents:
diff changeset
172 cpfseq better_gas_number ; 1-5 for OC/Bailout and 6-10 for diluents
heinrichsweikamp
parents:
diff changeset
173 return
heinrichsweikamp
parents:
diff changeset
174 movlw color_yellow ; show in yellow
heinrichsweikamp
parents:
diff changeset
175 call TFT_set_color
heinrichsweikamp
parents:
diff changeset
176 movlw .1
heinrichsweikamp
parents:
diff changeset
177 movff WREG,win_invert ; and invert
heinrichsweikamp
parents:
diff changeset
178 return
heinrichsweikamp
parents:
diff changeset
179
heinrichsweikamp
parents:
diff changeset
180 global gaslist_strcat_gas_mod
heinrichsweikamp
parents:
diff changeset
181 gaslist_strcat_gas_mod:
heinrichsweikamp
parents:
diff changeset
182 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents)
heinrichsweikamp
parents:
diff changeset
183
heinrichsweikamp
parents:
diff changeset
184 global gaslist_gastitle
heinrichsweikamp
parents:
diff changeset
185 gaslist_gastitle:
heinrichsweikamp
parents:
diff changeset
186 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint
heinrichsweikamp
parents:
diff changeset
187 bra gaslist_gastitle2 ; Short version
heinrichsweikamp
parents:
diff changeset
188 STRCAT_TEXT tGas
heinrichsweikamp
parents:
diff changeset
189 incf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
190 movwf lo
heinrichsweikamp
parents:
diff changeset
191 bsf leftbind
heinrichsweikamp
parents:
diff changeset
192 output_8
heinrichsweikamp
parents:
diff changeset
193 bcf leftbind
heinrichsweikamp
parents:
diff changeset
194 PUTC ":"
heinrichsweikamp
parents:
diff changeset
195
heinrichsweikamp
parents:
diff changeset
196 gaslist_gastitle2: ; Short version
heinrichsweikamp
parents:
diff changeset
197 lfsr FSR1,opt_gas_type
heinrichsweikamp
parents:
diff changeset
198 btfsc divemode
heinrichsweikamp
parents:
diff changeset
199 bra gaslist_gastitle3 ; no "*" in divemode
heinrichsweikamp
parents:
diff changeset
200 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
201 decf PLUSW1,W ; Type-1 into WREG
heinrichsweikamp
parents:
diff changeset
202 bnz gaslist_gastitle1 ; Not "First"
heinrichsweikamp
parents:
diff changeset
203 PUTC "*"
heinrichsweikamp
parents:
diff changeset
204 bra gaslist_gastitle3
heinrichsweikamp
parents:
diff changeset
205 gaslist_gastitle1:
heinrichsweikamp
parents:
diff changeset
206 PUTC " "
heinrichsweikamp
parents:
diff changeset
207 gaslist_gastitle3: ; Short version
heinrichsweikamp
parents:
diff changeset
208 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
209
heinrichsweikamp
parents:
diff changeset
210 btfsc divemode ; In divemode?
heinrichsweikamp
parents:
diff changeset
211 rcall gaslist_strcat_gas_better ; Yes, check if this is a "better gas"
heinrichsweikamp
parents:
diff changeset
212
heinrichsweikamp
parents:
diff changeset
213 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents)
heinrichsweikamp
parents:
diff changeset
214 movf PLUSW1,W
heinrichsweikamp
parents:
diff changeset
215 bnz gaslist_strcat_3
heinrichsweikamp
parents:
diff changeset
216 call TFT_disabled_color
heinrichsweikamp
parents:
diff changeset
217 gaslist_strcat_3:
heinrichsweikamp
parents:
diff changeset
218 rcall gaslist_strcat_gas_0
heinrichsweikamp
parents:
diff changeset
219 PUTC " "
heinrichsweikamp
parents:
diff changeset
220 ; Read switch depth
heinrichsweikamp
parents:
diff changeset
221 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents)
heinrichsweikamp
parents:
diff changeset
222 lfsr FSR1,char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
223 movff PLUSW1,lo
heinrichsweikamp
parents:
diff changeset
224 rcall gaslist_calc_mod ; Compute MOD into WREG
heinrichsweikamp
parents:
diff changeset
225 cpfsgt lo
heinrichsweikamp
parents:
diff changeset
226 bra gaslist_strcat_4
heinrichsweikamp
parents:
diff changeset
227 TFT_WARNINGS_COLOR ; Turn red if bigger
heinrichsweikamp
parents:
diff changeset
228 gaslist_strcat_4:
heinrichsweikamp
parents:
diff changeset
229 TSTOSS opt_units ; 0=Meters, 1=Feets
heinrichsweikamp
parents:
diff changeset
230 bra gaslist_strcat_3_metric
heinrichsweikamp
parents:
diff changeset
231 ;gaslist_strcat_3_imperial:
heinrichsweikamp
parents:
diff changeset
232 movf lo,W
heinrichsweikamp
parents:
diff changeset
233 mullw .100 ; convert meters to mbar
heinrichsweikamp
parents:
diff changeset
234 movff PRODL,lo
heinrichsweikamp
parents:
diff changeset
235 movff PRODH,hi
heinrichsweikamp
parents:
diff changeset
236 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
heinrichsweikamp
parents:
diff changeset
237 bsf leftbind
heinrichsweikamp
parents:
diff changeset
238 output_16_3
heinrichsweikamp
parents:
diff changeset
239 STRCAT_TEXT tFeets ; "ft"
heinrichsweikamp
parents:
diff changeset
240 return
heinrichsweikamp
parents:
diff changeset
241
heinrichsweikamp
parents:
diff changeset
242 gaslist_strcat_3_metric:
heinrichsweikamp
parents:
diff changeset
243 output_99
heinrichsweikamp
parents:
diff changeset
244 STRCAT_TEXT tMeters ; "m"
heinrichsweikamp
parents:
diff changeset
245 return
heinrichsweikamp
parents:
diff changeset
246
heinrichsweikamp
parents:
diff changeset
247 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
248 ; Store current menu item, and display gas description later.
heinrichsweikamp
parents:
diff changeset
249 ; Input: PRODL : gas number (0..4)
heinrichsweikamp
parents:
diff changeset
250 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry.
heinrichsweikamp
parents:
diff changeset
251 global gaslist_setgas
heinrichsweikamp
parents:
diff changeset
252 gaslist_setgas:
heinrichsweikamp
parents:
diff changeset
253 movff PRODL,gaslist_gas
heinrichsweikamp
parents:
diff changeset
254 movlw .5
heinrichsweikamp
parents:
diff changeset
255 btfsc ccr_diluent_setup ; in CCR menus?
heinrichsweikamp
parents:
diff changeset
256 addwf gaslist_gas,F ; Yes, offset to gases 5-9
heinrichsweikamp
parents:
diff changeset
257 return
heinrichsweikamp
parents:
diff changeset
258
heinrichsweikamp
parents:
diff changeset
259
heinrichsweikamp
parents:
diff changeset
260 global gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth
heinrichsweikamp
parents:
diff changeset
261 gaslist_cleanup_list:
heinrichsweikamp
parents:
diff changeset
262 bcf ignore_last_edited_gas
heinrichsweikamp
parents:
diff changeset
263 movlw .0
heinrichsweikamp
parents:
diff changeset
264 btfsc ccr_diluent_setup ; In CCR-Menu?
heinrichsweikamp
parents:
diff changeset
265 addlw .5 ; Yes, adjust offset
heinrichsweikamp
parents:
diff changeset
266 subwf gaslist_gas,F
heinrichsweikamp
parents:
diff changeset
267 gaslist_cleanup_list1:
heinrichsweikamp
parents:
diff changeset
268 clrf lo
heinrichsweikamp
parents:
diff changeset
269 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG]
heinrichsweikamp
parents:
diff changeset
270 movlw .5 ; Check 5 gases
heinrichsweikamp
parents:
diff changeset
271 movwf hi
heinrichsweikamp
parents:
diff changeset
272 gaslist_cleanup_list2:
heinrichsweikamp
parents:
diff changeset
273 decf hi,w ; 0-4
heinrichsweikamp
parents:
diff changeset
274 btfsc ccr_diluent_setup ; In CCR-Menu?
heinrichsweikamp
parents:
diff changeset
275 addlw .5 ; Yes, adjust offset
heinrichsweikamp
parents:
diff changeset
276 movff PLUSW1,hi_temp
heinrichsweikamp
parents:
diff changeset
277 movlw .1
heinrichsweikamp
parents:
diff changeset
278 cpfseq hi_temp ; gas = first ?
heinrichsweikamp
parents:
diff changeset
279 bra gaslist_cleanup_list3 ; No
heinrichsweikamp
parents:
diff changeset
280 incf lo,F ; Yes, count "first gases"
heinrichsweikamp
parents:
diff changeset
281
heinrichsweikamp
parents:
diff changeset
282 btfss ignore_last_edited_gas ; If we are not in the second-pass mode
heinrichsweikamp
parents:
diff changeset
283 bra gaslist_cleanup_list2b
heinrichsweikamp
parents:
diff changeset
284
heinrichsweikamp
parents:
diff changeset
285 decf hi,w ; 0-4
heinrichsweikamp
parents:
diff changeset
286 cpfseq gaslist_gas ; Do not disable last edited gas
heinrichsweikamp
parents:
diff changeset
287 gaslist_cleanup_list2b:
heinrichsweikamp
parents:
diff changeset
288 movff hi,lo_temp ; Keep the last "first gas" found
heinrichsweikamp
parents:
diff changeset
289 gaslist_cleanup_list3:
heinrichsweikamp
parents:
diff changeset
290 decfsz hi,F
heinrichsweikamp
parents:
diff changeset
291 bra gaslist_cleanup_list2 ; Loop
heinrichsweikamp
parents:
diff changeset
292
heinrichsweikamp
parents:
diff changeset
293 tstfsz lo ; No gas active?
heinrichsweikamp
parents:
diff changeset
294 bra gaslist_cleanup_list4 ; No, at least one is active
heinrichsweikamp
parents:
diff changeset
295
heinrichsweikamp
parents:
diff changeset
296 btfsc ccr_diluent_setup ; In CCR-Menu?
heinrichsweikamp
parents:
diff changeset
297 bra gaslist_cleanup_list3a ; Yes.
heinrichsweikamp
parents:
diff changeset
298 ; make gas1 first and zero
heinrichsweikamp
parents:
diff changeset
299 movlw .1 ; First
heinrichsweikamp
parents:
diff changeset
300 movwf lo_temp
heinrichsweikamp
parents:
diff changeset
301 movwf INDF1
heinrichsweikamp
parents:
diff changeset
302 bra gaslist_cleanup_list5 ; Set change depth to zero
heinrichsweikamp
parents:
diff changeset
303
heinrichsweikamp
parents:
diff changeset
304 gaslist_cleanup_list3a:
heinrichsweikamp
parents:
diff changeset
305 movlw .5
heinrichsweikamp
parents:
diff changeset
306 addwf FSR1L,F
heinrichsweikamp
parents:
diff changeset
307 movlw .0
heinrichsweikamp
parents:
diff changeset
308 addwfc FSR1H,F ; Setup to Diluents
heinrichsweikamp
parents:
diff changeset
309 ; make dil1 first and zero
heinrichsweikamp
parents:
diff changeset
310 movlw .1 ; First
heinrichsweikamp
parents:
diff changeset
311 movwf lo_temp
heinrichsweikamp
parents:
diff changeset
312 movwf INDF1
heinrichsweikamp
parents:
diff changeset
313 bra gaslist_cleanup_list5 ; Set change depth to zero
heinrichsweikamp
parents:
diff changeset
314
heinrichsweikamp
parents:
diff changeset
315 gaslist_cleanup_list4:
heinrichsweikamp
parents:
diff changeset
316 movlw .1
heinrichsweikamp
parents:
diff changeset
317 cpfsgt lo ; More then one "first gas"?
heinrichsweikamp
parents:
diff changeset
318 bra gaslist_cleanup_list5 ; No, done.
heinrichsweikamp
parents:
diff changeset
319 ; More then one Gas is "first gas"
heinrichsweikamp
parents:
diff changeset
320 ; Disable last found "first gas" but keep it's change depth
heinrichsweikamp
parents:
diff changeset
321 decf lo_temp,W ; 0-4
heinrichsweikamp
parents:
diff changeset
322 cpfseq gaslist_gas ; Do not disable last edited gas
heinrichsweikamp
parents:
diff changeset
323 bra gaslist_cleanup_list4b
heinrichsweikamp
parents:
diff changeset
324 ; Do not disable last edited gas
heinrichsweikamp
parents:
diff changeset
325 ; search again but ignore last edited gas
heinrichsweikamp
parents:
diff changeset
326 bsf ignore_last_edited_gas
heinrichsweikamp
parents:
diff changeset
327 bra gaslist_cleanup_list1 ; Loop until only one "first gas" is left
heinrichsweikamp
parents:
diff changeset
328
heinrichsweikamp
parents:
diff changeset
329 gaslist_cleanup_list4b:
heinrichsweikamp
parents:
diff changeset
330 btfsc ccr_diluent_setup ; In CCR-Menu?
heinrichsweikamp
parents:
diff changeset
331 addlw .5 ; Yes, adjust offset
heinrichsweikamp
parents:
diff changeset
332 clrf PLUSW1 ; Disable gas
heinrichsweikamp
parents:
diff changeset
333 bra gaslist_cleanup_list ; Loop until only one "first gas" is left
heinrichsweikamp
parents:
diff changeset
334
heinrichsweikamp
parents:
diff changeset
335 gaslist_cleanup_list5:
heinrichsweikamp
parents:
diff changeset
336 lfsr FSR1,char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
337 decf lo_temp,W
heinrichsweikamp
parents:
diff changeset
338 btfsc ccr_diluent_setup ; In CCR-Menu?
heinrichsweikamp
parents:
diff changeset
339 addlw .5 ; Yes, adjust offset
heinrichsweikamp
parents:
diff changeset
340 clrf PLUSW1 ; Set First gas to zero m
heinrichsweikamp
parents:
diff changeset
341 return
heinrichsweikamp
parents:
diff changeset
342
heinrichsweikamp
parents:
diff changeset
343 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
344 ; Increment/Decrement O2 ratio
heinrichsweikamp
parents:
diff changeset
345 global gaslist_pO2
heinrichsweikamp
parents:
diff changeset
346 gaslist_pO2:
heinrichsweikamp
parents:
diff changeset
347 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
348 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
349 movff PLUSW1,gaslist_He
heinrichsweikamp
parents:
diff changeset
350 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
351 movff PLUSW1,gaslist_O2
heinrichsweikamp
parents:
diff changeset
352
heinrichsweikamp
parents:
diff changeset
353 incf gaslist_O2,F ; O2++
heinrichsweikamp
parents:
diff changeset
354 movf gaslist_He,W
heinrichsweikamp
parents:
diff changeset
355 addwf gaslist_O2,W
heinrichsweikamp
parents:
diff changeset
356 movwf lo
heinrichsweikamp
parents:
diff changeset
357 movlw .101
heinrichsweikamp
parents:
diff changeset
358 cpfslt lo ; O2+He<101?
heinrichsweikamp
parents:
diff changeset
359 decf gaslist_O2,F ; O2-- (Unchanged)
heinrichsweikamp
parents:
diff changeset
360
heinrichsweikamp
parents:
diff changeset
361 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
362 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
363 return
heinrichsweikamp
parents:
diff changeset
364
heinrichsweikamp
parents:
diff changeset
365 global gaslist_mO2
heinrichsweikamp
parents:
diff changeset
366 gaslist_mO2:
heinrichsweikamp
parents:
diff changeset
367 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
368 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
369 movff PLUSW1,gaslist_O2
heinrichsweikamp
parents:
diff changeset
370
heinrichsweikamp
parents:
diff changeset
371 decf gaslist_O2,F
heinrichsweikamp
parents:
diff changeset
372 movlw gaslist_min_o2
heinrichsweikamp
parents:
diff changeset
373 cpfslt gaslist_O2
heinrichsweikamp
parents:
diff changeset
374 bra gaslist_mO2_1
heinrichsweikamp
parents:
diff changeset
375 movlw gaslist_min_o2
heinrichsweikamp
parents:
diff changeset
376 movwf gaslist_O2
heinrichsweikamp
parents:
diff changeset
377 gaslist_mO2_1:
heinrichsweikamp
parents:
diff changeset
378 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
379 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
380 return
heinrichsweikamp
parents:
diff changeset
381
heinrichsweikamp
parents:
diff changeset
382 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
383 ; Increment/Decrement He ratio
heinrichsweikamp
parents:
diff changeset
384 global gaslist_pHe
heinrichsweikamp
parents:
diff changeset
385 gaslist_pHe:
heinrichsweikamp
parents:
diff changeset
386 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
387 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
388 movff PLUSW1,gaslist_O2
heinrichsweikamp
parents:
diff changeset
389 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
390 movff PLUSW1,gaslist_He
heinrichsweikamp
parents:
diff changeset
391
heinrichsweikamp
parents:
diff changeset
392 incf gaslist_He,F ; He++
heinrichsweikamp
parents:
diff changeset
393 movf gaslist_He,W
heinrichsweikamp
parents:
diff changeset
394 addwf gaslist_O2,W
heinrichsweikamp
parents:
diff changeset
395 movwf lo
heinrichsweikamp
parents:
diff changeset
396 movlw .101
heinrichsweikamp
parents:
diff changeset
397 cpfslt lo ; O2+He<101?
heinrichsweikamp
parents:
diff changeset
398 decf gaslist_He,F ; Yes, He-- (Unchanged)
heinrichsweikamp
parents:
diff changeset
399
heinrichsweikamp
parents:
diff changeset
400 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
401 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
402 return
heinrichsweikamp
parents:
diff changeset
403
heinrichsweikamp
parents:
diff changeset
404 global gaslist_mHe
heinrichsweikamp
parents:
diff changeset
405 gaslist_mHe:
heinrichsweikamp
parents:
diff changeset
406 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
407 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
408 movff PLUSW1,gaslist_He
heinrichsweikamp
parents:
diff changeset
409
heinrichsweikamp
parents:
diff changeset
410 decf gaslist_He,F
heinrichsweikamp
parents:
diff changeset
411 bnn gaslist_mHe_1
heinrichsweikamp
parents:
diff changeset
412 clrf gaslist_He
heinrichsweikamp
parents:
diff changeset
413 gaslist_mHe_1:
heinrichsweikamp
parents:
diff changeset
414 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
415 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
416 return
heinrichsweikamp
parents:
diff changeset
417
heinrichsweikamp
parents:
diff changeset
418 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
419 ; Increment/Decrement switch depth
heinrichsweikamp
parents:
diff changeset
420 global gaslist_pDepth
heinrichsweikamp
parents:
diff changeset
421 gaslist_pDepth:
heinrichsweikamp
parents:
diff changeset
422 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
423 lfsr FSR1,char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
424 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG]
heinrichsweikamp
parents:
diff changeset
425
heinrichsweikamp
parents:
diff changeset
426 incf gaslist_O2,F
heinrichsweikamp
parents:
diff changeset
427 movlw gaslist_max_change_depth
heinrichsweikamp
parents:
diff changeset
428 cpfsgt gaslist_O2
heinrichsweikamp
parents:
diff changeset
429 bra gaslist_pDepth_1
heinrichsweikamp
parents:
diff changeset
430 movlw gaslist_max_change_depth
heinrichsweikamp
parents:
diff changeset
431 movwf gaslist_O2
heinrichsweikamp
parents:
diff changeset
432 gaslist_pDepth_1:
heinrichsweikamp
parents:
diff changeset
433 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
434 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG]
heinrichsweikamp
parents:
diff changeset
435 return
heinrichsweikamp
parents:
diff changeset
436
heinrichsweikamp
parents:
diff changeset
437 global gaslist_mDepth
heinrichsweikamp
parents:
diff changeset
438 gaslist_mDepth:
heinrichsweikamp
parents:
diff changeset
439 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
440 lfsr FSR1,char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
441 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG]
heinrichsweikamp
parents:
diff changeset
442
heinrichsweikamp
parents:
diff changeset
443 decf gaslist_O2,F
heinrichsweikamp
parents:
diff changeset
444 btfsc STATUS,N
heinrichsweikamp
parents:
diff changeset
445 clrf gaslist_O2
heinrichsweikamp
parents:
diff changeset
446
heinrichsweikamp
parents:
diff changeset
447 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
448 movff gaslist_O2,PLUSW1 ; And write back to char_I_deco_gas_change[WREG]
heinrichsweikamp
parents:
diff changeset
449 return
heinrichsweikamp
parents:
diff changeset
450
heinrichsweikamp
parents:
diff changeset
451 global gaslist_spplus
heinrichsweikamp
parents:
diff changeset
452 gaslist_spplus:
heinrichsweikamp
parents:
diff changeset
453 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
454 lfsr FSR1,char_I_setpoint_cbar
heinrichsweikamp
parents:
diff changeset
455 movff PLUSW1,lo ; Read char_I_setpoint_cbar[WREG]
heinrichsweikamp
parents:
diff changeset
456 movlw gaslist_sp_stepsize
heinrichsweikamp
parents:
diff changeset
457 addwf lo,F
heinrichsweikamp
parents:
diff changeset
458 movlw gaslist_sp_max
heinrichsweikamp
parents:
diff changeset
459 cpfsgt lo
heinrichsweikamp
parents:
diff changeset
460 bra gaslist_spplus2
heinrichsweikamp
parents:
diff changeset
461 movlw gaslist_sp_min
heinrichsweikamp
parents:
diff changeset
462 movwf lo
heinrichsweikamp
parents:
diff changeset
463 gaslist_spplus2:
heinrichsweikamp
parents:
diff changeset
464 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
465 movff lo,PLUSW1 ; Write back to char_I_setpoint_cbar
heinrichsweikamp
parents:
diff changeset
466 return
heinrichsweikamp
parents:
diff changeset
467
heinrichsweikamp
parents:
diff changeset
468 global gaslist_spdepthplus
heinrichsweikamp
parents:
diff changeset
469 gaslist_spdepthplus:
heinrichsweikamp
parents:
diff changeset
470 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
471 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m
heinrichsweikamp
parents:
diff changeset
472 lfsr FSR1,char_I_setpoint_change
heinrichsweikamp
parents:
diff changeset
473 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG]
heinrichsweikamp
parents:
diff changeset
474 incf gaslist_O2,F
heinrichsweikamp
parents:
diff changeset
475 movlw gaslist_max_change_depth
heinrichsweikamp
parents:
diff changeset
476 cpfsgt gaslist_O2
heinrichsweikamp
parents:
diff changeset
477 bra gaslist_spdepthplus_1
heinrichsweikamp
parents:
diff changeset
478 movlw gaslist_max_change_depth
heinrichsweikamp
parents:
diff changeset
479 movwf gaslist_O2
heinrichsweikamp
parents:
diff changeset
480 gaslist_spdepthplus_1:
heinrichsweikamp
parents:
diff changeset
481 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
482 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG]
heinrichsweikamp
parents:
diff changeset
483 return
heinrichsweikamp
parents:
diff changeset
484
heinrichsweikamp
parents:
diff changeset
485 gaslist_spdepthplus3:
heinrichsweikamp
parents:
diff changeset
486 movlw .0
heinrichsweikamp
parents:
diff changeset
487 movff WREG,char_I_setpoint_change+0 ; Reset to 0m
heinrichsweikamp
parents:
diff changeset
488 return
heinrichsweikamp
parents:
diff changeset
489
heinrichsweikamp
parents:
diff changeset
490 global gaslist_spdepthminus
heinrichsweikamp
parents:
diff changeset
491 gaslist_spdepthminus:
heinrichsweikamp
parents:
diff changeset
492 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
493 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m
heinrichsweikamp
parents:
diff changeset
494 lfsr FSR1,char_I_setpoint_change
heinrichsweikamp
parents:
diff changeset
495 movff PLUSW1,gaslist_O2 ; Read opt_gas_O2_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
496 decf gaslist_O2,F
heinrichsweikamp
parents:
diff changeset
497 btfsc STATUS,N
heinrichsweikamp
parents:
diff changeset
498 clrf gaslist_O2
heinrichsweikamp
parents:
diff changeset
499 movf gaslist_gas,W
heinrichsweikamp
parents:
diff changeset
500 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
501 return
heinrichsweikamp
parents:
diff changeset
502
heinrichsweikamp
parents:
diff changeset
503 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
504 ; Compute MOD from ppO2 Max and current O2 Ratio.
heinrichsweikamp
parents:
diff changeset
505 ;
heinrichsweikamp
parents:
diff changeset
506 ; Input: gaslist_gas = current gas index.
heinrichsweikamp
parents:
diff changeset
507 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio
heinrichsweikamp
parents:
diff changeset
508 ; Output: WREG = MOD [m]
heinrichsweikamp
parents:
diff changeset
509 ;
heinrichsweikamp
parents:
diff changeset
510 gaslist_calc_mod:
heinrichsweikamp
parents:
diff changeset
511 movf gaslist_gas,W ; Read current gas O2 ratio
heinrichsweikamp
parents:
diff changeset
512 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
heinrichsweikamp
parents:
diff changeset
513 movf PLUSW1,W
heinrichsweikamp
parents:
diff changeset
514
heinrichsweikamp
parents:
diff changeset
515 btfsc divemode ; In divemode?
heinrichsweikamp
parents:
diff changeset
516 bra gaslist_calc_mod_divemode ; Yes.
heinrichsweikamp
parents:
diff changeset
517
heinrichsweikamp
parents:
diff changeset
518 ; Pamb max = ppO2 Max / O2 ratio
heinrichsweikamp
parents:
diff changeset
519 movwf xB+0
heinrichsweikamp
parents:
diff changeset
520 clrf xB+1
heinrichsweikamp
parents:
diff changeset
521
heinrichsweikamp
parents:
diff changeset
522 movff opt_ppO2_max,WREG
heinrichsweikamp
parents:
diff changeset
523 mullw .10
heinrichsweikamp
parents:
diff changeset
524 movff PRODL,xA+0
heinrichsweikamp
parents:
diff changeset
525 movff PRODH,xA+1
heinrichsweikamp
parents:
diff changeset
526 call div16x16
heinrichsweikamp
parents:
diff changeset
527
heinrichsweikamp
parents:
diff changeset
528 ; Prof = Pamb - 1bar.
heinrichsweikamp
parents:
diff changeset
529 movf xC+0,W
heinrichsweikamp
parents:
diff changeset
530 addlw -.10
heinrichsweikamp
parents:
diff changeset
531 return
heinrichsweikamp
parents:
diff changeset
532
heinrichsweikamp
parents:
diff changeset
533 gaslist_calc_mod_divemode:
heinrichsweikamp
parents:
diff changeset
534 extern TFT_color_code1
heinrichsweikamp
parents:
diff changeset
535 movwf hi ; Copy O2%
heinrichsweikamp
parents:
diff changeset
536 movlw warn_gas_in_gaslist
heinrichsweikamp
parents:
diff changeset
537 call TFT_color_code1 ; Color-code current row in Gaslist (%O2 in hi), opt_ppO2_max as threshold
heinrichsweikamp
parents:
diff changeset
538 return
heinrichsweikamp
parents:
diff changeset
539 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
540 global gaslist_MOD_END
heinrichsweikamp
parents:
diff changeset
541 gaslist_MOD_END:
heinrichsweikamp
parents:
diff changeset
542 rcall gaslist_calc_mod ; Compute MOD into WREG
heinrichsweikamp
parents:
diff changeset
543 movwf lo ; Copy to lo
heinrichsweikamp
parents:
diff changeset
544 STRCAT_TEXT tEAD ; EAD:
heinrichsweikamp
parents:
diff changeset
545 TSTOSS opt_units ; 0=Meters, 1=Feets
heinrichsweikamp
parents:
diff changeset
546 bra gaslist_MOD_metric
heinrichsweikamp
parents:
diff changeset
547 ;gaslist_MOD_imperial:
heinrichsweikamp
parents:
diff changeset
548 movf lo,W
heinrichsweikamp
parents:
diff changeset
549 mullw .100 ; convert meters to mbar
heinrichsweikamp
parents:
diff changeset
550 movff PRODL,lo
heinrichsweikamp
parents:
diff changeset
551 movff PRODH,hi
heinrichsweikamp
parents:
diff changeset
552 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
heinrichsweikamp
parents:
diff changeset
553 bsf leftbind
heinrichsweikamp
parents:
diff changeset
554 output_16_3
heinrichsweikamp
parents:
diff changeset
555 STRCAT_TEXT tFeets ; "ft"
heinrichsweikamp
parents:
diff changeset
556 bra gaslist_MOD_common
heinrichsweikamp
parents:
diff changeset
557 gaslist_MOD_metric:
heinrichsweikamp
parents:
diff changeset
558 output_8
heinrichsweikamp
parents:
diff changeset
559 STRCAT_TEXT tMeters ; m
heinrichsweikamp
parents:
diff changeset
560 gaslist_MOD_common:
heinrichsweikamp
parents:
diff changeset
561 PUTC "/"
heinrichsweikamp
parents:
diff changeset
562 STRCAT_TEXT tEND ; END:
heinrichsweikamp
parents:
diff changeset
563 rcall gaslist_calc_mod ; Output: WREG = MOD [m]
heinrichsweikamp
parents:
diff changeset
564 addlw .10 ; MOD=MOD+10m
heinrichsweikamp
parents:
diff changeset
565 movwf xB+0
heinrichsweikamp
parents:
diff changeset
566 clrf xB+1
heinrichsweikamp
parents:
diff changeset
567 movlw d'100'
heinrichsweikamp
parents:
diff changeset
568 movwf xA+0
heinrichsweikamp
parents:
diff changeset
569 movf gaslist_He,W ; He value in % -> WREG
heinrichsweikamp
parents:
diff changeset
570 subwf xA+0,F ; xA+0 = 100 - He Value in %
heinrichsweikamp
parents:
diff changeset
571 clrf xA+1
heinrichsweikamp
parents:
diff changeset
572 call mult16x16 ; xA*xB=xC
heinrichsweikamp
parents:
diff changeset
573 movff xC+0,xA+0
heinrichsweikamp
parents:
diff changeset
574 movff xC+1,xA+1
heinrichsweikamp
parents:
diff changeset
575 movlw d'100'
heinrichsweikamp
parents:
diff changeset
576 movwf xB+0
heinrichsweikamp
parents:
diff changeset
577 clrf xB+1
heinrichsweikamp
parents:
diff changeset
578 call div16x16 ; xA/xB=xC with xA as remainder
heinrichsweikamp
parents:
diff changeset
579 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100
heinrichsweikamp
parents:
diff changeset
580 movlw d'10'
heinrichsweikamp
parents:
diff changeset
581 subwf xC+0,F ; Subtract 10m...
heinrichsweikamp
parents:
diff changeset
582 movff xC+0,lo
heinrichsweikamp
parents:
diff changeset
583 ; END 8Bit only
heinrichsweikamp
parents:
diff changeset
584 ; movlw d'0'
heinrichsweikamp
parents:
diff changeset
585 ; subwfb xC+1,F
heinrichsweikamp
parents:
diff changeset
586 ; movff xC+1,hi
heinrichsweikamp
parents:
diff changeset
587 TSTOSS opt_units ; 0=Meters, 1=Feets
heinrichsweikamp
parents:
diff changeset
588 bra gaslist_END_metric
heinrichsweikamp
parents:
diff changeset
589 ;gaslist_END_imperial:
heinrichsweikamp
parents:
diff changeset
590 movf lo,W
heinrichsweikamp
parents:
diff changeset
591 mullw .100 ; convert meters to mbar
heinrichsweikamp
parents:
diff changeset
592 movff PRODL,lo
heinrichsweikamp
parents:
diff changeset
593 movff PRODH,hi
heinrichsweikamp
parents:
diff changeset
594 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
heinrichsweikamp
parents:
diff changeset
595 bsf leftbind
heinrichsweikamp
parents:
diff changeset
596 output_16_3
heinrichsweikamp
parents:
diff changeset
597 STRCAT_TEXT tFeets ; "ft"
heinrichsweikamp
parents:
diff changeset
598 return
heinrichsweikamp
parents:
diff changeset
599 gaslist_END_metric:
heinrichsweikamp
parents:
diff changeset
600 output_8
heinrichsweikamp
parents:
diff changeset
601 STRCAT_TEXT tMeters ; m
heinrichsweikamp
parents:
diff changeset
602 return
heinrichsweikamp
parents:
diff changeset
603
heinrichsweikamp
parents:
diff changeset
604 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
605 global gaslist_reset_mod_title
heinrichsweikamp
parents:
diff changeset
606 gaslist_reset_mod_title:
heinrichsweikamp
parents:
diff changeset
607 STRCAT_TEXT tDepthReset
heinrichsweikamp
parents:
diff changeset
608
heinrichsweikamp
parents:
diff changeset
609 gaslist_reset_mod_title2:
heinrichsweikamp
parents:
diff changeset
610 rcall gaslist_calc_mod ; Compute MOD into WREG
heinrichsweikamp
parents:
diff changeset
611 movwf lo ; Copy to lo
heinrichsweikamp
parents:
diff changeset
612
heinrichsweikamp
parents:
diff changeset
613 movf gaslist_gas,W ; Compare to switch depth
heinrichsweikamp
parents:
diff changeset
614 lfsr FSR1,char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
615 movf PLUSW1,W
heinrichsweikamp
parents:
diff changeset
616 cpfslt lo
heinrichsweikamp
parents:
diff changeset
617 bra gaslist_strcat_4 ; And return...
heinrichsweikamp
parents:
diff changeset
618 TFT_WARNINGS_COLOR ; Turn red if bigger !
heinrichsweikamp
parents:
diff changeset
619 bra gaslist_strcat_4 ; And return...
heinrichsweikamp
parents:
diff changeset
620
heinrichsweikamp
parents:
diff changeset
621 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
622 global gaslist_reset_mod
heinrichsweikamp
parents:
diff changeset
623 gaslist_reset_mod:
heinrichsweikamp
parents:
diff changeset
624 rcall gaslist_calc_mod ; Compute MOD
heinrichsweikamp
parents:
diff changeset
625 movwf gaslist_depth
heinrichsweikamp
parents:
diff changeset
626
heinrichsweikamp
parents:
diff changeset
627 movf gaslist_gas,W ; Read current gas O2 ratio
heinrichsweikamp
parents:
diff changeset
628 lfsr FSR1,char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
629 movff gaslist_depth,PLUSW1 ; And save new change depth
heinrichsweikamp
parents:
diff changeset
630 return
heinrichsweikamp
parents:
diff changeset
631 ;----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
632 END