comparison src/gaslist.asm @ 631:185ba2f91f59

3.09 beta 1 release
author heinrichsweikamp
date Fri, 28 Feb 2020 15:45:07 +0100
parents cd58f7fc86db
children 4050675965ea
comparison
equal deleted inserted replaced
630:4cd81bdbf15c 631:185ba2f91f59
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File gaslist.asm combined next generation V3.03.5 3 ; File gaslist.asm combined next generation V3.08.8
4 ; 4 ;
5 ; Managing OSTC gas list 5 ; Managing OSTC gas list
6 ; 6 ;
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
18 #include "shared_definitions.h" 18 #include "shared_definitions.h"
19 #include "wait.inc" 19 #include "wait.inc"
20 #include "rx_ops.inc" 20 #include "rx_ops.inc"
21 21
22 22
23 extern convert_mbar_to_feet 23 extern convert_meter_to_feet
24 extern tSetup_GasDepth 24 extern tSetup_GasDepth
25 extern tGasDisabled 25 extern tGasDisabled
26 extern tDilDisabled 26 extern tDilDisabled
27 extern tLiter 27 extern tLiter
28 extern tbar10 28 extern tbar10
29 extern tbar 29 extern tbar
30 30
31 IFDEF _cave_mode
32 extern cavemode_waypoint_set_check
33 extern cavemode_waypoint_out_check
34 extern cavemode_waypoint_in_check
35 extern cavemode_turndive_check
36 ENDIF
37
31 38
32 gaslist CODE 39 gaslist CODE
33 40
34 ;----------------------------------------------------------------------------- 41 ;-----------------------------------------------------------------------------
35 42
36 ;============================================================================= 43 ;=============================================================================
37 ; Helper Functions for divemenu_tree.asm 44 ; Helper Functions for divemenu_tree.asm
38 ; 45 ;
39 ; They need to be put in a different file than 46 ; These functions need to be placed in a different
40 ; where the MENU_DYNAMIC macros uses them. 47 ; file than where the MENU_DYNAMIC macros use them.
41 48
42 global do_toggle_gf_label 49 ;-----------------------------------------------------------------------------
43 do_toggle_gf_label: 50
44 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF 51 global label_do_toggle_gf
52 label_do_toggle_gf:
53 movff char_I_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF
45 decfsz WREG,W ; toggle GF only in GF modes - in GF mode? 54 decfsz WREG,W ; toggle GF only in GF modes - in GF mode?
46 bra do_toggle_gf_label_1 ; NO - print in disabled color 55 bra do_toggle_gf_label_1 ; NO - print in disabled color
47 movff opt_enable_aGF,WREG ; =1: aGF can be selected underwater 56 movff opt_enable_aGF,WREG ; =1: aGF can be selected underwater
48 decfsz WREG,W ; aGF enabled? 57 decfsz WREG,W ; aGF enabled?
49 bra do_toggle_gf_label_1 ; NO - print in disabled color 58 bra do_toggle_gf_label_1 ; NO - print in disabled color
50 bra do_toggle_gf_label_2 ; YES to both - print in standard color 59 bra do_toggle_gf_label_2 ; YES to both - print in standard color
51 do_toggle_gf_label_1: 60 do_toggle_gf_label_1:
52 call TFT_disabled_color 61 call TFT_disabled_color ; print in disabled color
53 do_toggle_gf_label_2: 62 do_toggle_gf_label_2:
54 STRCAT_TEXT tDivemenu_ToggleGF 63 STRCAT_TEXT tDivemenu_ToggleGF ; output label
55 return 64 return ; done
56 65
57 ;============================================================================= 66
67 global label_do_gas6_or_exit
68 label_do_gas6_or_exit:
69 btfsc gas6_or_EXIT ; shall print exit?
70 bra label_do_gas6_or_exit_1 ; YES - print exit label
71 STRCAT_TEXT tGas6 ; NO - print gas 6 label
72 return ; - done
73 label_do_gas6_or_exit_1:
74 STRCAT_TEXT tExit ; print exit label
75 return ; done
76
77 ;-----------------------------------------------------------------------------
58 78
59 IFDEF _cave_mode 79 IFDEF _cave_mode
60 80
61 global do_turn_dive_label 81 global label_do_turn_dive
62 do_turn_dive_label: 82 label_do_turn_dive:
83 call cavemode_turndive_check ; check if command is allowed
84 tstfsz WREG ; command allowed?
85 call TFT_disabled_color ; NO - switch to disabled color
63 btfss cave_mode ; cave mode switched on? 86 btfss cave_mode ; cave mode switched on?
64 call TFT_disabled_color ; NO - print in disabled color 87 bra label_do_turn_dive_1 ; NO - print turn dive label
65 btfsc dive_turned ; dive already turned? 88 btfss dive_turned ; YES - dive turned?
66 call TFT_attention_color ; YES - print in attention color 89 bra label_do_turn_dive_1 ; NO - print turn dive label
67 STRCAT_TEXT tDivemenu_TurnDive ; output label 90 STRCAT_TEXT tDivemenu_ContDive ; YES - print continue dive label
68 return 91 return ; - done
69 92 label_do_turn_dive_1:
70 ENDIF 93 STRCAT_TEXT tDivemenu_TurnDive ; print turn dive label
71 94 return ; done
72 ;============================================================================= 95
96 global label_do_wp_set
97 label_do_wp_set:
98 call cavemode_waypoint_set_check ; check if command is allowed to execute
99 tstfsz WREG ; command allowed?
100 call TFT_disabled_color ; NO - switch to disabled color
101 STRCAT_TEXT tDivemenu_wp_set ; print label
102 return ; done
103
104 global label_do_wp_out
105 label_do_wp_out:
106 call cavemode_waypoint_out_check ; check if command is allowed to execute
107 tstfsz WREG ; command allowed?
108 call TFT_disabled_color ; NO - switch to disabled color
109 STRCAT_TEXT tDivemenu_wp_out ; print label
110 return ; done
111
112 global label_do_wp_in
113 label_do_wp_in:
114 call cavemode_waypoint_in_check ; check if command is allowed to execute
115 tstfsz WREG ; command allowed?
116 call TFT_disabled_color ; NO - switch to disabled color
117 STRCAT_TEXT tDivemenu_wp_in ; print label
118 return ; done
119
120 ENDIF
121
122 ;-----------------------------------------------------------------------------
73 123
74 IFDEF _rx_functions 124 IFDEF _rx_functions
75 125
76 global do_toggle_max_pres_diff_label 126 global do_toggle_max_pres_diff_label
77 do_toggle_max_pres_diff_label: 127 do_toggle_max_pres_diff_label:
85 STRCAT_TEXT tbar ; " bar" 135 STRCAT_TEXT tbar ; " bar"
86 return 136 return
87 137
88 ENDIF 138 ENDIF
89 139
90 ;============================================================================= 140 ;-----------------------------------------------------------------------------
91 141
92 IFDEF _ccr_pscr 142 IFDEF _ccr_pscr
93 143
94 global gaslist_copy_dil_to_oc 144 global gaslist_copy_dil_to_oc
95 gaslist_copy_dil_to_oc: 145 gaslist_copy_dil_to_oc:
175 ; Input: FSR2 : Current string position 225 ; Input: FSR2 : Current string position
176 ; Output: Text appended into buffer pointed by FSR2 226 ; Output: Text appended into buffer pointed by FSR2
177 227
178 global gaslist_strcat_gas6 228 global gaslist_strcat_gas6
179 gaslist_strcat_gas6: ; show current O2/He mix 229 gaslist_strcat_gas6: ; show current O2/He mix
180 STRCAT_TEXT tGas ; print "Gas" 230 STRCAT_TEXT tTakeGas ; print "take"
181 STRCAT ": " ; print ":" 231 PUTC " " ; print one space
182 movff gas6_O2_ratio,hi ; TFT_color_code_gaslist needs O2 ratio in hi 232 movff gas6_O2_ratio,hi ; TFT_color_code_gaslist needs O2 ratio in hi
183 call TFT_color_code_gaslist ; color-code according to O2 ratio and depth 233 call TFT_color_code_gaslist ; color-code according to O2 ratio and depth
184 movff gas6_O2_ratio,lo ; gaslist_show_mix needs O2 ratio in lo 234 movff gas6_O2_ratio,lo ; gaslist_show_mix needs O2 ratio in lo
185 IFDEF _helium 235 IFDEF _helium
186 movff gas6_He_ratio,hi ; ... and He ratio in hi 236 movff gas6_He_ratio,hi ; ... and He ratio in hi
225 return 275 return
226 276
227 277
228 global gaslist_toggle_type 278 global gaslist_toggle_type
229 gaslist_toggle_type: 279 gaslist_toggle_type:
230 movf gaslist_gas,W
231 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type 280 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type
232 movff PLUSW1,lo ; read gas type 281 movf gaslist_gas,W ; copy gas number (0-9) to WREG
233 incf lo,F ; increment type 282 movff PLUSW1,lo ; read type value
283 incf lo,F ; increment type value
284 movlw num_gas_types ; get number of gas types by default
234 btfsc is_diluent_menu ; setting up diluents? 285 btfsc is_diluent_menu ; setting up diluents?
235 bra gaslist_toggle_type2 ; YES - diluents 286 movlw num_dil_types ; YES - replace by number of diluent types
236 btfsc lo,2 ; NO - gases, type index > 3 ? 287 cpfslt lo ; type value valid?
237 clrf lo ; YES - clear to zero 288 clrf lo ; NO - clear to zero
238 movff lo,PLUSW1 ; - copy back result 289 movf gaslist_gas,W ; restore gas number (0-9) in WREG
239 return
240 gaslist_toggle_type2:
241 movlw .3
242 cpfslt lo ; index > 2 ?
243 clrf lo ; YES - clear to zero
244 movf gaslist_gas,W ; restore gaslist_gas in WREG
245 movff lo,PLUSW1 ; copy back result 290 movff lo,PLUSW1 ; copy back result
246 return 291 return ; done
247 292
248 ;============================================================================= 293 ;=============================================================================
249 294
250 IFDEF _ccr_pscr 295 IFDEF _ccr_pscr
251 296
303 ; Output: text appended to buffer pointed by FSR2 348 ; Output: text appended to buffer pointed by FSR2
304 ; 349 ;
305 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry 350 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry
306 351
307 global gaslist_strcat_gas_cd 352 global gaslist_strcat_gas_cd
308 global gaslist_gastitle
309 gaslist_strcat_gas_cd: ; entry point with gas in PRODL (0-4) and flag 'is_diluent_menu' set accordingly 353 gaslist_strcat_gas_cd: ; entry point with gas in PRODL (0-4) and flag 'is_diluent_menu' set accordingly
310 movff PRODL,gaslist_gas ; get current menu item (0-4) 354 movff PRODL,gaslist_gas ; get current menu item (0-4)
311 movlw .5 ; offset between gases and diluents 355 movlw .5 ; offset between gases and diluents
312 btfsc is_diluent_menu ; setting up diluents? 356 btfsc is_diluent_menu ; dealing with diluents?
313 addwf gaslist_gas,F ; YES - add the offset 357 addwf gaslist_gas,F ; YES - add the offset
358 ;bra gaslist_gastitle ; continue with gaslist_gastitle function
359
360 global gaslist_gastitle
314 gaslist_gastitle: ; entry point with gas/dil in gaslist_gas (0-4 for gases, 5-9 for diluents) 361 gaslist_gastitle: ; entry point with gas/dil in gaslist_gas (0-4 for gases, 5-9 for diluents)
315 bcf win_invert ; clear flag for inverted output by default 362 bcf win_invert ; clear flag for inverted output by default
316 btfsc short_gas_descriptions ; shall use short versions of gaslist_strcat_gas_cd? 363 btfsc short_gas_descriptions ; shall use short versions of gaslist_strcat_gas_cd?
317 bra gaslist_gastitle1 ; YES - use short version 364 bra gaslist_gastitle1 ; YES - use short version
318 incf gaslist_gas,W ; (0-9) -> (1-10) into WREG 365 incf gaslist_gas,W ; (0-9) -> (1-10) into WREG
319 movwf lo 366 movwf lo ; copy gas index to lo
320 movlw .6 ; diluents start with 6 367 movlw .6 ; diluents start with 6
321 cpfslt lo ; gas number < 6 ? 368 cpfslt lo ; gas number < 6 ?
322 bra gaslist_gastitle_dil ; NO - it's a diluent 369 bra gaslist_gastitle_dil ; NO - it's a diluent
323 STRCAT_TEXT tGas ; YES - it's a gas 370 STRCAT_TEXT tGas ; YES - it's a gas
324 bra gaslist_gastitle0 371 bra gaslist_gastitle0 ; - continue
325 gaslist_gastitle_dil: 372 gaslist_gastitle_dil:
326 STRCAT_TEXT tDil 373 STRCAT_TEXT tDil ; it's a diluent
327 movlw .5 ; offset between gases and diluents 374 movlw .5 ; offset between gases and diluents
328 subwf lo,F ; subtract offset from diluent number (6-10) -> (1-5) 375 subwf lo,F ; subtract offset from diluent number (6-10) -> (1-5) again
329 gaslist_gastitle0: 376 gaslist_gastitle0:
330 bsf leftbind 377 bsf leftbind
331 output_8 ; print gas/dil number (1-5) 378 output_8 ; print gas/dil number (1-5)
332 bcf leftbind 379 bcf leftbind
333 PUTC ":" 380 PUTC ":"
351 gaslist_gastitle2: 398 gaslist_gastitle2:
352 rcall gaslist_strcat_gas_type ; print "*" for first gas/dil, "=" for a deco gas or " " else 399 rcall gaslist_strcat_gas_type ; print "*" for first gas/dil, "=" for a deco gas or " " else
353 gaslist_gastitle3: 400 gaslist_gastitle3:
354 call TFT_standard_color 401 call TFT_standard_color
355 btfsc divemode ; in dive mode? 402 btfsc divemode ; in dive mode?
356 rcall gaslist_strcat_gas_better ; YES - check if this is a "better gas" 403 rcall gaslist_strcat_gas_better ; YES - check if this is a "better gas", if yes switch to green and inverted output
357 lfsr FSR1,opt_gas_type ; load base address of gas types 404 lfsr FSR1,opt_gas_type ; load base address of gas types
358 movf gaslist_gas,W ; load index into WREG (0-4 for gases, 5-9 for diluents) 405 movf gaslist_gas,W ; load index into WREG (0-4 for gases, 5-9 for diluents)
359 movf PLUSW1,W ; read gas/dil type into WREG 406 movf PLUSW1,W ; read gas/dil type into WREG
360 bnz gaslist_gastitle4 ; type = disabled? NO - keep color 407 btfsc WREG,gas_lost ; gas/dil lost?
361 call TFT_disabled_color ; YES - switch color to disabled 408 bra gaslist_gastitle3a ; YES - switch to disabled color
362 bra gaslist_gastitle5 ; - skip ppO2 check for disabled gases 409 btfsc WREG,gas_staged ; gas/dil staged?
410 bra gaslist_gastitle3a ; YES - switch to disabled color
411 bnz gaslist_gastitle4 ; type = disabled ?
412 gaslist_gastitle3a:
413 call TFT_disabled_color ; YES - switch to disabled color
414 bra gaslist_gastitle5 ; - skip ppO2 check for disabled gases
363 gaslist_gastitle4: 415 gaslist_gastitle4:
364 btfss divemode ; in dive mode? 416 btfss divemode ; in dive mode?
365 bra gaslist_gastitle5 ; NO - no ppO2 check if not in dive mode 417 bra gaslist_gastitle5 ; NO - no color-coding if not in dive mode
366 lfsr FSR1,opt_gas_O2_ratio ; YES - load base address of opt_gas_O2_ratio 418 btfss color_code_gases ; YES - shall color-code the gases by ppO2 and current depth?
367 movf gaslist_gas,W ; - load index into WREG (0-4 for gases, 5-9 for diluents) 419 bra gaslist_gastitle5 ; NO - skip color-coding
368 movff PLUSW1,hi ; - read O2 ratio into hi 420 lfsr FSR1,opt_gas_O2_ratio ; YES - load base address of opt_gas_O2_ratio
369 call TFT_color_code_gaslist ; - set color according to ppO2 limits 421 movf gaslist_gas,W ; - load index into WREG (0-4 for gases, 5-9 for diluents)
422 movff PLUSW1,hi ; - read O2 ratio into hi
423 call TFT_color_code_gaslist ; - set color according to ppO2 limits
370 gaslist_gastitle5: 424 gaslist_gastitle5:
371 movf gaslist_gas,W ; copy gas/dil index to WREG (0-9) 425 movf gaslist_gas,W ; copy gas/dil index to WREG (0-9)
372 rcall gaslist_strcat_gas_WREG ; print gas composition 426 rcall gaslist_strcat_gas_WREG ; print gas composition
373 btfss divemode ; in dive mode? 427 btfss divemode ; in dive mode?
374 bra gaslist_gastitle6 ; NO - continue printing a space 428 bra gaslist_gastitle6 ; NO - continue printing a space
382 movff PLUSW1,lo ; read change depth into lo 436 movff PLUSW1,lo ; read change depth into lo
383 gaslist_strcat_depth: ; entry point for general printing of depths with value in meters in lo 437 gaslist_strcat_depth: ; entry point for general printing of depths with value in meters in lo
384 TSTOSS opt_units ; check depth units 438 TSTOSS opt_units ; check depth units
385 bra gaslist_strcat_depth_metric ; 0 - use Meters 439 bra gaslist_strcat_depth_metric ; 0 - use Meters
386 gaslist_strcat_depth_imperial: ; 1 - use Feet 440 gaslist_strcat_depth_imperial: ; 1 - use Feet
387 movf lo,W 441 call convert_meter_to_feet ; convert value in lo from [m] to [feet]
388 mullw .100 ; convert meters to mbar
389 movff PRODL,lo
390 movff PRODH,hi
391 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
392 output_16_3 ; limit to 999 and display only 0-999 442 output_16_3 ; limit to 999 and display only 0-999
393 STRCAT_TEXT tFeets ; append "ft" REMARK: still one char to long for space available in dive mode menu! 443 STRCAT_TEXT tFeets ; append "ft" REMARK: still one char to long for space available in dive mode menu!
394 return 444 return
395 gaslist_strcat_depth_metric: 445 gaslist_strcat_depth_metric:
396 ; PUTC " " ; print a space 446 ; PUTC " " ; print a space
425 475
426 476
427 gaslist_strcat_gas_type: 477 gaslist_strcat_gas_type:
428 lfsr FSR1,opt_gas_type ; load base address of gas types 478 lfsr FSR1,opt_gas_type ; load base address of gas types
429 movf gaslist_gas,W ; load index to WREG (0-4 for gases, 5-9 for diluents) 479 movf gaslist_gas,W ; load index to WREG (0-4 for gases, 5-9 for diluents)
430 decf PLUSW1,W ; get and decrement gas type (-1 for disabled, 0 for first, 1 for work/normal, 2 for deco) 480 movf PLUSW1,W ; get gas/dil type into WREG
481 btfsc WREG,gas_lost ; gas set as lost?
482 bra gaslist_strcat_gas_type_4 ; YES - print lost marking
483 IFDEF _cave_mode
484 btfsc WREG,gas_staged ; gas set as staged?
485 bra gaslist_strcat_gas_type_5 ; YES - print staged marking
486 ENDIF
487 decf WREG,W ; decrement gas type (-1 for disabled, 0 for first, 1 for work/normal, 2 for deco)
431 bnz gaslist_strcat_gas_type_1 ; type = first? NO - continue with checking for work and deco gas 488 bnz gaslist_strcat_gas_type_1 ; type = first? NO - continue with checking for work and deco gas
432 PUTC "*" ; YES - print "*" for first 489 PUTC "*" ; YES - print "*" for first
433 return ; - done 490 return ; - done
434 gaslist_strcat_gas_type_1: 491 gaslist_strcat_gas_type_1:
435 decf WREG,W ; decrement gas type (-2 for disabled, -1 for first, 0 for work/normal, 1 for deco) 492 decf WREG,W ; decrement gas type (-2 for disabled, -1 for first, 0 for work/normal, 1 for deco)
441 bnz gaslist_strcat_gas_type_3 ; type = deco? NO - neither first nor deco 498 bnz gaslist_strcat_gas_type_3 ; type = deco? NO - neither first nor deco
442 PUTC "=" ; YES - print "=" for a deco gas 499 PUTC "=" ; YES - print "=" for a deco gas
443 return ; - done 500 return ; - done
444 gaslist_strcat_gas_type_3: 501 gaslist_strcat_gas_type_3:
445 PUTC " " ; neither first nor deco, print a space 502 PUTC " " ; neither first nor deco, print a space
446 return 503 return ; done
504 gaslist_strcat_gas_type_4:
505 PUTC "x" ; print lost marking
506 return ; done
507 IFDEF _cave_mode
508 gaslist_strcat_gas_type_5:
509 PUTC "S" ; print staged marking
510 return ; done
511 ENDIF
447 512
448 513
449 ;---------------------------------------------------------------------------- 514 ;----------------------------------------------------------------------------
450 ; Housekeeping for the gas/dil settings, e.g. making sure there is one FIRST only 515 ; Housekeeping for the gas/dil settings, e.g. making sure there is one FIRST only
451 ; 516 ;
490 btfsc is_diluent_menu ; NO - setting up diluents? 555 btfsc is_diluent_menu ; NO - setting up diluents?
491 lfsr FSR1,opt_dil_type ; YES - load base address of opt_gas_type 556 lfsr FSR1,opt_dil_type ; YES - load base address of opt_gas_type
492 ENDIF 557 ENDIF
493 movlw .1 ; - load coding for first gas 558 movlw .1 ; - load coding for first gas
494 movwf INDF1 ; - make gas/dil 1 the first gas 559 movwf INDF1 ; - make gas/dil 1 the first gas
495 bsf option_repaired ; - flag that an option was repaired
496 return ; - done 560 return ; - done
497 gaslist_cleanup_list4: 561 gaslist_cleanup_list4:
498 movlw .1 ; total number of Firsts that should exist is 1 562 movlw .1 ; total number of Firsts that should exist is 1
499 cpfsgt lo ; more then one "first gas" found? 563 cpfsgt lo ; more then one "first gas" found?
500 return ; NO - done 564 return ; NO - done
507 IFDEF _ccr_pscr 571 IFDEF _ccr_pscr
508 btfsc is_diluent_menu ; setting up diluents? 572 btfsc is_diluent_menu ; setting up diluents?
509 addlw .5 ; YES - adjust offset 573 addlw .5 ; YES - adjust offset
510 ENDIF 574 ENDIF
511 clrf PLUSW1 ; disable gas 575 clrf PLUSW1 ; disable gas
512 bsf option_repaired ; flag that an option was repaired
513 bra gaslist_cleanup_list0 ; redo from start until only one "first" is left over 576 bra gaslist_cleanup_list0 ; redo from start until only one "first" is left over
514 return 577 return
515 578
516 579
517 ;---------------------------------------------------------------------------- 580 ;----------------------------------------------------------------------------