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