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