annotate src/simulator.asm @ 598:e1f0f5e3d4e4

BUGFIX: Internal deco planner did not display results in imperial units
author heinrichsweikamp
date Mon, 30 Jul 2018 19:45:53 +0200
parents b455b31ce022
children ca4556fb60b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
3 ; File simulator.asm REFACTORED VERSION V2.98
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Decoplan interface to C model code.
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
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
10 ; 2011-07-09 : [jDG] Creation...
0
heinrichsweikamp
parents:
diff changeset
11
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
12 #include "hwos.inc" ; Mandatory include
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
13 #include "convert.inc" ; output_*
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
15 #include "strings.inc" ; STRCPY,...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
16 #include "tft.inc" ; WIN_LEFT,...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
17 #include "wait.inc" ; speed_*
0
heinrichsweikamp
parents:
diff changeset
18 #include "start.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "divemode.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "math.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "eeprom_rs232.inc"
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 46
diff changeset
22 #include "tft_outputs.inc"
298
2fe34fc0e2ae new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents: 296
diff changeset
23 #include "gaslist.inc"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
24 #include "isr.inc"
0
heinrichsweikamp
parents:
diff changeset
25
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
26 gui CODE
0
heinrichsweikamp
parents:
diff changeset
27
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
28 extern deco_clear_tissue
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
29 extern deco_push_tissues_to_vault
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
30 extern deco_calc_dive_interval
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
31 extern deco_calc_hauptroutine
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
32 extern deco_pull_tissues_from_vault
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
33 extern TFT_display_decotype_surface1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
34 extern get_first_dil_to_WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
35 extern get_first_gas_to_WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
36 extern setup_dil_registers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
37 extern setup_gas_registers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
38 extern deco_setup_cc_diluents
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
39 extern deco_setup_oc_gases
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
40 extern log_screendump_and_onesecond
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
41 extern logbook_preloop_tasks
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
42 extern do_return_demo_planner
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
43
0
heinrichsweikamp
parents:
diff changeset
44
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
45 ;---- Private local variables -------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
46
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
47 CBLOCK local1 ; max size is 16 Byte !!!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
48 decoplan_index ; within each page
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
49 decoplan_gindex ; global index
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
50 decoplan_last ; Depth of last stop (CF#29)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
51 decoplan_flags ; Various private flags.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
52 decoplan_page ; page number
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
53 decoplan_warnings ; deco engine warnings
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
54 gas_counter ; counter for looping through the gases
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
55 row_pos ; used for positioning of graphic elements
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
56 ENDC ; used: 8 byte, remaining: 8 byte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
57
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
58 ;---- Defines ----------------------------------------------------------------
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
59
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
60 #define decoplan_last_ceiling_shown decoplan_flags,0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
61 #define decoplan_abort decoplan_flags,1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
62
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
63 ;---- Demo deco planner ------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
64
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
65 global do_demo_planner
0
heinrichsweikamp
parents:
diff changeset
66 do_demo_planner:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
67 btfsc FLAG_gauge_mode ; =1: In Gauge mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
68 goto do_return_demo_planner
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
69 btfsc FLAG_apnoe_mode ; =1: In Apnea mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
70 goto do_return_demo_planner
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
71 bcf decoplan_abort ; initialize (clear) abort flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
72 bcf is_bailout ; clear bailout condition (may have remained set from last invocation)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
73 rcall deco_planer
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
74 btfss decoplan_abort ; skip recall deco_show_plan if calculations were aborted
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
75 rcall deco_show_plan
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
76 goto do_return_demo_planner
0
heinrichsweikamp
parents:
diff changeset
77
heinrichsweikamp
parents:
diff changeset
78
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
79 global deco_setup
0
heinrichsweikamp
parents:
diff changeset
80 deco_setup:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
81 btfsc FLAG_ccr_mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
82 bra deco_setup_cc
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
83 btfsc FLAG_pscr_mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
84 bra deco_setup_cc
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
85 deco_setup_oc:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
86 call get_first_gas_to_WREG ; gets first gas (1-5) into WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
87 call setup_gas_registers ; with WREG=Gas 1-5
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
88 call deco_setup_oc_gases ; setup OC/Bailout Gases and configure for OC deco calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
89 bra deco_setup_cont
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
90 deco_setup_cc:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
91 call get_first_dil_to_WREG ; gets first gas (1-5) into WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
92 call setup_dil_registers ; with WREG=Gas 1-5
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
93 call deco_setup_cc_diluents ; setup CCR/pSCR diluents and configure for CCR/pSCR deco calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
94 deco_setup_cont:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
95 ; use ambient conditions for simulation
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
96 SAFE_2BYTE_COPY last_surfpressure_30min, int_I_pres_surface ; copy surface pressure to deco routine
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
97
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
98 movlw deco_distance
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
99 movff WREG,char_I_deco_distance
0
heinrichsweikamp
parents:
diff changeset
100
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
101 movff opt_last_stop,char_I_depth_last_deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
102 movff opt_GF_low,char_I_GF_Low_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
103 movff opt_GF_high,char_I_GF_High_percentage
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
104
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
105 ; overwrite GF if aGF is wanted
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
106 bsf use_agf
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
107 TSTOSS opt_sim_use_aGF
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
108 bcf use_agf
0
heinrichsweikamp
parents:
diff changeset
109
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
110 btfsc use_agf ; =1: Use aGF
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
111 movff opt_aGF_low,char_I_GF_Low_percentage
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
112 btfsc use_agf ; =1: Use aGF
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
113 movff opt_aGF_high,char_I_GF_High_percentage
0
heinrichsweikamp
parents:
diff changeset
114
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
115 bcf is_bailout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
116
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
117 ; setup char_I_const_ppO2 for CC modes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
118 clrf WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
119 btfsc FLAG_pscr_mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
120 movff WREG,char_I_const_ppO2 ; configure pSCR computations to calculated ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
121 btfss FLAG_ccr_mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
122 return ; done if not in CCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
123 movff opt_sim_setpoint_number,WREG ; configure CCR computations to selected setpoint
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
124 decf WREG,W ; 1-5 -> 0-4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
125 lfsr FSR1,char_I_setpoint_cbar ; load base address of setpoint list
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
126 movff PLUSW1,char_I_const_ppO2 ; setup setpoint
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
127 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
128
0
heinrichsweikamp
parents:
diff changeset
129 ;=============================================================================
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
130 ; Launch deco planning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
131 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
132 global deco_planer
0
heinrichsweikamp
parents:
diff changeset
133 deco_planer:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
134 call speed_fastest ; Quick !
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
135 call deco_push_tissues_to_vault ; C-code: back-up state of the real tissues
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
136 banksel common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
137 rcall deco_setup ; Setup all model parameters.
0
heinrichsweikamp
parents:
diff changeset
138
heinrichsweikamp
parents:
diff changeset
139 ;---- Specific settings ------------------------------------------------------
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
140
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
141 ; configure the deco engine for normal plan, CNS & gas volume calculation and no delayed ascent
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
142 movff char_O_deco_status,WREG ; bank-safe copy
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
143 bcf WREG,DECO_PLAN_FLAG ; normal plan mode,
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
144 bsf WREG,DECO_CNS_FLAG ; enable CNS calculation (CNS at end of dive),
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
145 bsf WREG,DECO_VOLUME_FLAG ; enable gas volume calculation, and
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
146 bcf WREG,DECO_ASCENT_FLAG ; disable delayed ascent calculation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
147 movff WREG,char_O_deco_status ; bank-safe copy back
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
148
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
149 ; configure the deco engine for total-dive gas volume calculation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
150 movff char_O_main_status,WREG ; bank-safe copy
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
151 bsf WREG,DECO_BOTTOM_FLAG ; set bottom flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
152 movff WREG,char_O_main_status ; bank-safe copy back
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
153
295
7027d735ac62 NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents: 294
diff changeset
154 deco_planer_redo:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
155 ; show deco calculation is in progress
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
156 call TFT_ClearScreen
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
157 WIN_COLOR color_greenish
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
158 TEXT_SMALL .20,.40, tCalculating
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
159 WIN_COLOR color_lightblue
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
160 WIN_SMALL .1,.215
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
161 STRCPY_TEXT_PRINT tAbort
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
162
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
163 ; configure the deco engine for restart:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
164 movff char_O_deco_status,WREG ; bank-safe copy
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
165 bsf WREG,DECO_STATUS_0_FLAG ; configure init ...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
166 bsf WREG,DECO_STATUS_1_FLAG ; ... state,
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
167 movff WREG,char_O_deco_status ; bank-safe copy back
0
heinrichsweikamp
parents:
diff changeset
168
heinrichsweikamp
parents:
diff changeset
169 ;---- Add delay at surface, if needed ----------------------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
170 banksel char_I_dive_interval
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
171 tstfsz char_I_dive_interval
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
172 call deco_calc_dive_interval
0
heinrichsweikamp
parents:
diff changeset
173
heinrichsweikamp
parents:
diff changeset
174 ;---- Dive loop --------------------------------------------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
175 ; Compute dive ambient conditions
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
176 banksel char_I_bottom_depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
177 movf char_I_bottom_depth,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
178 mullw .100
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
179 movlw LOW(.1000)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
180 addwf PRODL,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
181 movwf int_I_pres_respiration+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
182 movlw HIGH(.1000)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
183 addwfc PRODH,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
184 movwf int_I_pres_respiration+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
185 banksel common
0
heinrichsweikamp
parents:
diff changeset
186
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
187 movff char_I_bottom_time,char_I_sim_advance_time
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
188
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
189 clrf TMR5L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
190 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H
0
heinrichsweikamp
parents:
diff changeset
191
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
192 call deco_calc_hauptroutine ; C-code: initialization + complete bottom time part
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
193 banksel common
0
heinrichsweikamp
parents:
diff changeset
194
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
195 ;---- BAILOUT: Switch to OC gases for ascent cycles --------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
196 btfss is_bailout ; Doing a bailout deco plan ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
197 bra deco_planer_finishing ; NO - keep gases
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
198 ; YES - switch to OC gas
111
c61b7a4e317c Bugfix: CNS in planner
heinrichsweikamp
parents: 97
diff changeset
199
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
200 ; reconfigure the deco engine for delayed ascent mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
201 movff char_O_deco_status,lo ; bank-safe copy
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
202 bsf lo,DECO_ASCENT_FLAG ; set flag for delayed ascent calculation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
203 movff lo,char_O_deco_status ; bank-safe copy back
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
204
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
205 ; configure the deco engine for delayed ascent part gas volume calculation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
206 movff char_O_main_status,WREG ; bank-safe copy
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
207 bcf WREG,DECO_BOTTOM_FLAG ; set bottom flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
208 movff WREG,char_O_main_status ; bank-safe copy back
0
heinrichsweikamp
parents:
diff changeset
209
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
210 ; reconfigure gas settings to OC gases
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
211 call get_first_gas_to_WREG ; get first gas (1-5) into WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
212 call setup_gas_registers ; With WREG=Gas 1-5 (or 6, not applicable here)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
213 call deco_setup_oc_gases ; With WREG=Gas 1-5 (or 6, not applicable here)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
214
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
215 ; set the gas change override flag to allow gas changes before deco stops as done in alternative plan
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
216 movff char_O_main_status,lo ; bank-safe copy
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
217 bsf lo,DECO_GASCHANGE_OVRD ; set flag for gas change override
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
218 movff lo,char_O_main_status ; bank-safe copy back
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
219
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
220 ;---- Wait until status reaches zero -------------------------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
221 deco_planer_finishing:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
222 call deco_calc_hauptroutine ; C-code: Simulate more dive time to trigger the deco calculations
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
223 banksel common
0
heinrichsweikamp
parents:
diff changeset
224
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
225 btfss switch_left ; check if left button was pressed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
226 bra deco_planer_finishing_1 ; NO - continue calculations
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
227 bsf decoplan_abort ; YES - set abort flag so that deco_show_plan will not be called
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
228 bra deco_planer_finishing_2 ; do some clean-up and return
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
229 deco_planer_finishing_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
230 movff char_O_deco_status,lo ; working copy of char_O_deco_status in bank common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
231 movlw DECO_STATUS_MASK ; bit mask for deco status bit set
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
232 andwf lo,W ; mask out bits showing state of computation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
233 tstfsz WREG ; check if a compute cycle is finished (bits 1 and 0 == 0)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
234 bra deco_planer_finishing ; NO - needs more computation cycles
295
7027d735ac62 NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents: 294
diff changeset
235
296
af13a18a233b Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents: 295
diff changeset
236 ;---- Done: add CNS from decoplan, and restore tissues
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
237 deco_planer_finishing_2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
238 movff char_O_deco_warnings,decoplan_warnings ; copy warnings
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
239
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
240 call deco_pull_tissues_from_vault ; C-code: restore status of the real tissues
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
241 banksel common ; back to bank 1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
242
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
243 movlw b'00111000' ; 1:8 Prescaler -> 65,536ms@16MHz
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
244 movwf T3CON
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
245 goto speed_normal ; (and return)
0
heinrichsweikamp
parents:
diff changeset
246
heinrichsweikamp
parents:
diff changeset
247 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
248 ; Draw a stop of the deco plan (simulator or dive).
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
249 ; Inputs: lo = depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
250 ; hi = minutes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
251 ; win_top = line to draw on screen.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
252 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
253 ; Trashed: hi, lo,
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
254 ; win_height, win_leftx2, win_width, win_color*,
0
heinrichsweikamp
parents:
diff changeset
255 ; WREG, PROD, TBLPTR TABLAT.
heinrichsweikamp
parents:
diff changeset
256 ;
heinrichsweikamp
parents:
diff changeset
257 deco_plan_show_stop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
258 ;---- Print depth ----------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
259 lfsr FSR2,char_O_deco_gas ; needed to be initialized here every time because...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
260 movf decoplan_gindex,W ; ...FSR2 is also used for string operations
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
261 movff PLUSW2,WREG ; get current gas and copy it to WREG for color-coding
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
262 call TFT_color_code_gas ; set output color dependent on gas (1-5)
0
heinrichsweikamp
parents:
diff changeset
263
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
264 lfsr FSR2,buffer
0
heinrichsweikamp
parents:
diff changeset
265
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
266 TSTOSS opt_units ; 0=Meters, 1=Feets
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
267 bra deco_plan_show_nstd_stop_metric
0
heinrichsweikamp
parents:
diff changeset
268
598
e1f0f5e3d4e4 BUGFIX: Internal deco planner did not display results in imperial units
heinrichsweikamp
parents: 582
diff changeset
269 movff hi,up ; backup hi (minutes)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
270 WIN_LEFT .85
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
271 movf lo,W ; lo = m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
272 mullw .100 ; PRODL:PRODH = mbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
273 movff PRODL,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
274 movff PRODH,hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
275 ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
276 movff lo,xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
277 movff hi,xA+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
278 movlw LOW d'334' ; 334feet/100m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
279 movwf xB+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
280 movlw HIGH d'334'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
281 movwf xB+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
282 call mult16x16 ; xA*xB=xC (lo:hi * 328)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
283 movlw d'50' ; round up
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
284 addwf xC+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
285 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
286 addwfc xC+1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
287 addwfc xC+2,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
288 addwfc xC+3,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
289 movlw d'100'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
290 movwf xB+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
291 clrf xB+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
292 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
293 movff xC+0,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
294 movff xC+1,hi ; restore lo and hi with updated value
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
295 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
296 bsf ignore_digit4 ; Only full feet
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
297 output_16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
298 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
299 STRCAT_PRINT "ft "
598
e1f0f5e3d4e4 BUGFIX: Internal deco planner did not display results in imperial units
heinrichsweikamp
parents: 582
diff changeset
300 movff up,hi ; restore hi (minutes)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
301 bra deco_plan_show_nstd_stop_common
0
heinrichsweikamp
parents:
diff changeset
302
heinrichsweikamp
parents:
diff changeset
303 deco_plan_show_nstd_stop_metric:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
304 WIN_LEFT .90
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
305 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
306 output_8 ; outputs into Postinc2!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
307 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
308 STRCAT_PRINT "m "
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
309
0
heinrichsweikamp
parents:
diff changeset
310 deco_plan_show_nstd_stop_common:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
311 ;---- Print duration -------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
312 WIN_LEFT .135
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
313 lfsr FSR2,buffer
0
heinrichsweikamp
parents:
diff changeset
314
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
315 movf lo,W ; Swap hi & lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
316 movff hi,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
317 movwf hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
318
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
319 output_8 ; Allow up to 240'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
320 clrf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
321 movff WREG,buffer+.3 ; limit to 2 chars
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
322 STRCAT_PRINT ""
0
heinrichsweikamp
parents:
diff changeset
323
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
324 movf lo,W ; Swap back hi & lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
325 movff hi,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
326 movwf hi
0
heinrichsweikamp
parents:
diff changeset
327
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
328 ;---------------------------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
329 ; Draw the bar graph used for deco stops (deco plan in simulator or dive).
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
330 incf win_top,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
331 movlw .19
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
332 movwf win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
333 movlw .118
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
334 movwf win_leftx2 ; column left (0-159)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
335 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
336 movwf win_width+0 ; column max width.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
337 clrf win_width+1
0
heinrichsweikamp
parents:
diff changeset
338
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
339 ; Draw used area (hi = minutes):
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
340 movlw .16 ; Limit length (16min)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
341 cpfslt hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
342 movwf hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
343 movff hi,win_bargraph ; Active width, the rest is cleared.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
344 call TFT_box
0
heinrichsweikamp
parents:
diff changeset
345
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
346 ; Restore win_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
347 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
348 decf win_top,F ; Restore win_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
349 return
0
heinrichsweikamp
parents:
diff changeset
350
heinrichsweikamp
parents:
diff changeset
351 ;-----------------------------------------------------------------------------
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
352 ; Clear unused area below last stop
0
heinrichsweikamp
parents:
diff changeset
353 ; Inputs: win_top : last used area...
heinrichsweikamp
parents:
diff changeset
354 deco_plan_show_clear_bottom:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
355 movf win_top,W ; Get back from bank0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
356 sublw .239 ; No: bottom row in planning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
357 movwf win_height
0
heinrichsweikamp
parents:
diff changeset
358
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
359 WIN_LEFT .85 ; Full dive menu width
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
360 movlw .159-.85+.1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
361 movwf win_width+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
362 clrf win_width+1
0
heinrichsweikamp
parents:
diff changeset
363
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
364 clrf win_color1 ; Fill with black
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
365 clrf win_color2
0
heinrichsweikamp
parents:
diff changeset
366
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
367 goto TFT_box ; and return
0
heinrichsweikamp
parents:
diff changeset
368
heinrichsweikamp
parents:
diff changeset
369 ;-----------------------------------------------------------------------------
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
370 ; Display the deco plan (simulator).
0
heinrichsweikamp
parents:
diff changeset
371 ; Inputs: char_O_deco_table (array of stop times, in minutes)
heinrichsweikamp
parents:
diff changeset
372 ; decoplan_page = page number.
heinrichsweikamp
parents:
diff changeset
373 ;
heinrichsweikamp
parents:
diff changeset
374 deco_show_plan_page:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
375 bcf win_invert ; Reset invert flag
0
heinrichsweikamp
parents:
diff changeset
376
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
377 ;---- Is there deco stops ? ------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
378 movff char_O_first_deco_depth,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
379 iorwf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
380 bnz deco_plan_show_1
0
heinrichsweikamp
parents:
diff changeset
381
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
382 ;---- No Deco --------------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
383 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
384 TEXT_SMALL .80, .0, tNoDeco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
385 bsf decoplan_last_ceiling_shown
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
386 return
0
heinrichsweikamp
parents:
diff changeset
387
heinrichsweikamp
parents:
diff changeset
388 deco_plan_show_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
389 lfsr FSR0,char_O_deco_depth ; Initialize indexed addressing.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
390 lfsr FSR1,char_O_deco_time
0
heinrichsweikamp
parents:
diff changeset
391
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
392 clrf decoplan_index ; Start with index = 0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
393 clrf win_top ; and row = 0
0
heinrichsweikamp
parents:
diff changeset
394
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
395 ; Read stop parameters, indexed by decoplan_index and decoplan_page
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
396 movf decoplan_page,W ; decoplan_gindex = 6*decoplan_page + decoplan_index
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
397 mullw .8 ; 8 lines/page in deco plan
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
398 movf decoplan_index,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
399 addwf PRODL,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
400 movwf decoplan_gindex ; --> decoplan_gindex
0
heinrichsweikamp
parents:
diff changeset
401
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
402 bcf decoplan_last_ceiling_shown ; Not finished yet...
0
heinrichsweikamp
parents:
diff changeset
403
heinrichsweikamp
parents:
diff changeset
404 deco_plan_show_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
405 btfsc decoplan_gindex,5 ; Reached table length (32) ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
406 bra deco_plan_show_99 ; YES: finished...
0
heinrichsweikamp
parents:
diff changeset
407
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
408 ; Read stop parameters, indexed by decoplan_index
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
409 movf decoplan_gindex,W ; index
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
410 movff PLUSW0,lo ; char_O_deco_depth[gindex]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
411 movff PLUSW1,hi ; char_O_deco_time [gindex]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
412 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
413 bz deco_plan_show_99 ; depth == 0 : finished.
0
heinrichsweikamp
parents:
diff changeset
414
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
415 ; Display the stop line
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
416 rcall deco_plan_show_stop
0
heinrichsweikamp
parents:
diff changeset
417
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
418 ; Next
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
419 movlw .24
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
420 addwf win_top,F ; row: += 24
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
421 incf decoplan_index,F ; local index += 1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
422 incf decoplan_gindex,F ; global index += 1
0
heinrichsweikamp
parents:
diff changeset
423
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
424 ; Max number of lines/page reached ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
425 movlw .8 ; 8 lines/page in deco plan
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
426 cpfseq decoplan_index
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
427 bra deco_plan_show_2 ; NO: loop
0
heinrichsweikamp
parents:
diff changeset
428
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
429 ; Check if next stop is end-of-list ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
430 movf decoplan_gindex,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
431 movf PLUSW0,W ; char_O_deco_depth[gindex]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
432 bz deco_plan_show_99 ; End of list...
0
heinrichsweikamp
parents:
diff changeset
433
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
434 ; Display the message "more..."
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
435 rcall deco_plan_show_clear_bottom ; Clear from next line
0
heinrichsweikamp
parents:
diff changeset
436
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
437 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
438 TEXT_SMALL .88, .220, tMore
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
439 return
0
heinrichsweikamp
parents:
diff changeset
440
heinrichsweikamp
parents:
diff changeset
441 deco_plan_show_99:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
442 bsf decoplan_last_ceiling_shown ; Nothing more in table to display.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
443 rcall deco_plan_show_clear_bottom ; Clear from next line
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
444 return
0
heinrichsweikamp
parents:
diff changeset
445
heinrichsweikamp
parents:
diff changeset
446 ;-----------------------------------------------------------------------------
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
447 ; Loop to show all pages of the deco plan (surface mode)
0
heinrichsweikamp
parents:
diff changeset
448
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
449 global deco_show_plan
0
heinrichsweikamp
parents:
diff changeset
450 deco_show_plan:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
451 clrf decoplan_page
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
452 call TFT_ClearScreen
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
453 WIN_COLOR color_greenish
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
454 btfsc is_bailout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
455 bra deco_show_plan_bail_title
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
456 TEXT_SMALL .1,.1, tDivePlan
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
457 bra deco_show_plan2
462
1eeafeeb9287 CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents: 432
diff changeset
458 deco_show_plan_bail_title:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
459 TEXT_SMALL .1,.1, tDiveBailout
462
1eeafeeb9287 CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents: 432
diff changeset
460 deco_show_plan2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
461 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
462 ;---- Display Plan Parameters
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
463 WIN_SMALL .0,.25
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
464 STRCPY "Int:"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
465 movff char_I_dive_interval,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
466 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
467 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
468 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
469 STRCAT_PRINT "'"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
470 WIN_SMALL .0,.50
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
471 STRCPY_TEXT tBtTm_short
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
472 movff char_I_bottom_time,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
473 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
474 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
475 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
476 STRCAT_PRINT "'"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
477 WIN_SMALL .0,.75
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
478 STRCPY_TEXT tDepth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
479 PUTC ":"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
480 movff char_I_bottom_depth,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
481 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
482 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
483 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
484 STRCAT_PRINT "m"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
485 WIN_SMALL .0,.105 ; set position for warnings or sat/dsat factors
208
53771bd3d567 NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents: 197
diff changeset
486
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
487 ;---- Check for Stop Table Overflow
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
488 btfss decoplan_warnings,stoptable_overflow ; check if we have a overflow warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
489 bra deco_show_plan2a ; NO - skip
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
490 ;---- Display Overflow warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
491 call TFT_warnings_color ; YES - show overflow warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
492 STRCAT_PRINT "incomplete" ; max 10 characters
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
493 bra deco_show_plan_m1 ; skip displaying sat/dsat factors
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
494
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
495 deco_show_plan2a:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
496 ;---- Check for IBCD Warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
497 btfss decoplan_warnings,IBCD_warning_lock ; check if we have a locked IBCD warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
498 bra deco_show_plan2b ; NO - skip
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
499 ;---- Display IBCD warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
500 call TFT_attention_color ; YES - show IBCD warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
501 STRCAT_PRINT "IBCD!" ; max 10 characters
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
502 bra deco_show_plan_m1 ; skip displaying sat/dsat factors
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
503
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
504 deco_show_plan2b:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
505 ;---- Display Sat/Desat Factors --> omitted if there were warnings
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
506 STRCAT_PRINT "SD:"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
507 WIN_SMALL .25,.105
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
508 movff char_I_saturation_multiplier,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
509 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
510 STRCAT "/"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
511 movff char_I_desaturation_multiplier,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
512 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
513 STRCAT_PRINT ""
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
514
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
515 deco_show_plan_m1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
516 call TFT_standard_color ; clean-up from warnings
0
heinrichsweikamp
parents:
diff changeset
517
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
518 ;---- Get Model
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
519 movff char_I_deco_model,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
520 iorwf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
521 bz deco_show_plan_m2
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
522
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
523 ;---- Display GF low/high values
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
524 WIN_SMALL .0,.130
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
525 STRCAT_PRINT "GF:"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
526 WIN_SMALL .25,.130
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
527 movff char_I_GF_Low_percentage,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
528 output_99x
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
529 STRCAT "/"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
530 movff char_I_GF_High_percentage,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
531 output_99x
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
532 STRCAT_PRINT ""
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
533
208
53771bd3d567 NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents: 197
diff changeset
534 deco_show_plan_m2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
535 ;---- Display Deco Mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
536 WIN_SMALL .0,.155
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
537 lfsr FSR2,buffer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
538 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
539 call TFT_display_decotype_surface1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
540 btfss FLAG_ccr_mode ; current dive mode = CCR ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
541 bra deco_show_plan2c ; NO - branch
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
542 WIN_SMALL .25,.155
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
543 STRCPY "SP:" ; output setpoint used for calculation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
544 movff opt_sim_setpoint_number,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
545 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
546 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
547 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
548 STRCAT_PRINT ""
0
heinrichsweikamp
parents:
diff changeset
549
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
550 deco_show_plan2c:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
551 ;---- Display TTS result
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
552 WIN_SMALL .0,.180
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
553 STRCPY_TEXT tTTS
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
554 STRCAT ": "
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
555 movff int_O_ascenttime+0,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
556 movff int_O_ascenttime+1,hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
557 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
558 output_16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
559 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
560 STRCAT_PRINT "'"
0
heinrichsweikamp
parents:
diff changeset
561
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
562 ;---- Display CNS result
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
563 WIN_TOP .205
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
564 STRCPY_TEXT tCNS2 ; "CNS:"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
565 movff int_O_CNS_fraction+0,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
566 movff int_O_CNS_fraction+1,hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
567 call TFT_color_code_cns ; Color-code CNS output
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
568 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
569 output_16_3 ; limit to 999 and display only (0-999)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
570 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
571 STRCAT "%\x92" ; "->"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
572 movff int_O_normal_CNS_fraction+0,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
573 movff int_O_normal_CNS_fraction+1,hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
574 call TFT_color_code_cns ; Color-code CNS output
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
575 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
576 output_16_3 ; limit to 999 and display only (0-999)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
577 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
578 STRCAT_PRINT "%"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
579 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
580
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
581 ;---- Loop through pages
0
heinrichsweikamp
parents:
diff changeset
582 deco_show_plan_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
583 ; Clear the complete stop result column:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
584 WIN_BOX_BLACK .0, .239, .80, .159 ; top, bottom, left, right
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
585
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
586 rcall deco_show_plan_page
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
587 incf decoplan_page,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
588 call logbook_preloop_tasks
0
heinrichsweikamp
parents:
diff changeset
589 deco_show_plan_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
590 btfsc switch_right
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
591 bra deco_show_plan_3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
592 btfsc switch_left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
593 return ; Return to simulator menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
594 call log_screendump_and_onesecond ; Check if we need to make a screen shot and check for new second
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
595 btfsc sleepmode ; Timeout?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
596 goto restart
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
597 bra deco_show_plan_2
0
heinrichsweikamp
parents:
diff changeset
598
heinrichsweikamp
parents:
diff changeset
599 deco_show_plan_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
600 btfss decoplan_last_ceiling_shown
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
601 bra deco_show_plan_1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
602 ; All stops shown
295
7027d735ac62 NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents: 294
diff changeset
603
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
604 ;---- In CCR and pSCR mode, compute a BAILOUT deco plan -----------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
605 movff char_O_deco_status,WREG ; get deco calculation status
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
606 btfss WREG,DECO_MODE_LOOP_FLAG ; check if in CCR or pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
607 bra simulator_show_decoplan5_0 ; NO - normal OC mode: just display
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
608 bsf is_bailout ; YES - redo 2nd deco-plan in bailout mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
609 rcall deco_planer_redo ; redo plan computation
295
7027d735ac62 NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents: 294
diff changeset
610
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
611 btfss decoplan_abort ; shall we abort?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
612 bra deco_show_plan ; NO - display bailout stops
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
613 return ; YES
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
614
295
7027d735ac62 NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents: 294
diff changeset
615
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
616 ;---- In OC+BAIL modes, show the gas usage special page -----------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
617 simulator_show_decoplan5_0:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
618 ; Clear the complete stop result column:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
619 WIN_BOX_BLACK .0, .239, .80, .159 ; top, bottom, left, right
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
620
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
621 movlw .25
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
622 movwf row_pos ; Row for gas list is .25+.25
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
623 clrf gas_counter ; Gas counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
624 lfsr FSR0,int_O_gas_volumes ; Initialize indexed addressing.
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
625
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
626 WIN_LEFT .80 ; Set column
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
627 call TFT_standard_color
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
628
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
629 simulator_show_decoplan5_loop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
630 movff gas_counter,PRODL ; Copy to PRODL first
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
631 incf gas_counter,F ; Increment gas #
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
632
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
633 movff gas_counter,WREG ; copy current gas to WREG for color-coding
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
634 call TFT_color_code_gas ; set output color according to gas (1-5)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
635
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
636 lfsr FSR2,buffer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
637 bsf short_gas_decriptions
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
638 bsf divemode ; Tweak "customview_show_mix:"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
639 call gaslist_strcat_gas ; Input: PRODL : gas number (0..4), Output: "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
640 bcf divemode ; Tweak "customview_show_mix:"
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
641
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
642 movlw .25
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
643 addwf row_pos,F ; Increase row position
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
644 movff row_pos,win_top ; Set Row
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
645
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
646 movff POSTINC0,lo ; Read (16bit) result, low first,
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
647 movff POSTINC0,hi ; then high.
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
648
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
649 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
650 andwf hi,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
651 incf WREG ; > 65535?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
652 bnz simulator_show_decoplan5_1 ; NO
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
653 STRCAT_PRINT ">65500" ; YES
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
654 bra simulator_show_decoplan5_2
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
655
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
656 simulator_show_decoplan5_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
657 PUTC ":"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
658 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
659 output_16 ; No decimal anymore.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
660 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
661 STRCAT_PRINT ""
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
662
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
663 ; Loop for all 5 gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
664 simulator_show_decoplan5_2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
665 movlw d'5' ; list all five gases
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
666 cpfseq gas_counter ; All gases shown?
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
667 bra simulator_show_decoplan5_loop ; No
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
668
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
669 WIN_COLOR color_greenish
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
670
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
671 movlw .30
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
672 addwf row_pos,F ; Increase row position
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
673 movff row_pos,win_top ; Set Row
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
674 STRCPY_TEXT_PRINT tBarLiter ; "Bar Liter"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
675
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
676 WIN_SMALL .80,.25
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
677 STRCPY_TEXT tGasUsage ; "Gas Usage"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
678 STRCAT_PRINT ":"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
679
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
680 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
681 call logbook_preloop_tasks
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
682
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
683 simulator_show_decoplan5_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
684 btfss switch_right
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
685 bra simulator_show_decoplan5_3a
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
686 bcf switch_right
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
687 clrf decoplan_page
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
688 bra deco_show_plan_1 ; toggle between stops plan and gas usage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
689 simulator_show_decoplan5_3a:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
690 btfss switch_left
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
691 bra simulator_show_decoplan5_4
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
692 bcf is_bailout ; Back to normal
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
693 bcf ccr_diluent_setup ; init for OC/Bailout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
694 return ; Return to simulator menu
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
695
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
696 simulator_show_decoplan5_4:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
697 call log_screendump_and_onesecond ; Check if we need to make a screen shot and check for new second
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
698 btfsc sleepmode ; Timeout?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
699 goto restart
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
700 bra simulator_show_decoplan5_3
0
heinrichsweikamp
parents:
diff changeset
701
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
702 END