Mercurial > public > hwos_code
annotate src/simulator.asm @ 246:f345a55c92e0
minor docu update
author | heinrichsweikamp |
---|---|
date | Thu, 05 Mar 2015 10:36:56 +0100 |
parents | 31088352ee32 |
children | ad62dff7739a |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File simulator.asm | |
4 ; | |
5 ; Decoplan interface to C model code. | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-07-09 : [jDG] Creation... | |
11 | |
12 #include "ostc3.inc" ; Mandatory include. | |
13 #include "convert.inc" ; output_* | |
14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | |
15 #include "strings.inc" ; STRCPY,... | |
16 #include "tft.inc" ; WIN_LEFT,... | |
17 #include "wait.inc" ; speed_* | |
18 #include "start.inc" | |
19 #include "divemode.inc" | |
20 #include "math.inc" | |
21 #include "eeprom_rs232.inc" | |
50 | 22 #include "tft_outputs.inc" |
0 | 23 |
24 gui CODE | |
25 | |
26 extern deco_clear_tissue | |
27 extern deco_push_tissues_to_vault | |
28 extern deco_calc_dive_interval | |
29 extern deco_calc_hauptroutine | |
30 extern deco_calc_tissue | |
31 extern deco_calc_CNS_fraction | |
32 extern deco_calc_CNS_planning | |
33 extern deco_pull_tissues_from_vault | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
34 extern TFT_display_decotype_surface1 |
0 | 35 |
36 extern log_screendump_and_onesecond, logbook_preloop_tasks | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
37 extern do_planner_menu |
0 | 38 |
39 ;---- Private temp variables ------------------------------------------------- | |
40 CBLOCK tmp+0x10 ; Reserved space for wordprocessor and convert | |
41 decoplan_index ; within each page | |
42 decoplan_gindex ; global index | |
43 decoplan_last ; Depth of last stop (CF#29) | |
44 decoplan_flags ; Various private flags. | |
45 decoplan_CNS:2 ; Backup CNS before vault restore | |
46 ; Reserved to tmp+0x1F... | |
47 ENDC | |
48 #define decoplan_last_ceiling_shown decoplan_flags,0 | |
49 | |
50 ;---- Demo decoplanner ------------------------------------------------------- | |
51 global do_demo_planner | |
52 | |
53 do_demo_planner: | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
54 btfsc FLAG_gauge_mode ; =1: In Gauge mode |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
55 goto do_planner_menu |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
56 btfsc FLAG_apnoe_mode ; =1: In Apnea mode |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
57 goto do_planner_menu |
0 | 58 ; call deco_reset ; TODO: remove reset all Decodata |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
59 rcall deco_planer |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
60 rcall deco_show_plan |
0 | 61 goto do_planner_menu |
62 | |
63 ;============================================================================= | |
64 ; Pass all parameters to the C code | |
65 ; | |
66 | |
67 global get_first_dil_to_WREG | |
68 get_first_dil_to_WREG: ; Gets first dil (0-4) into WREG | |
69 lfsr FSR1,opt_dil_type ; Point to dil types | |
70 clrf lo ; start with Gas0 | |
81
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
71 get_first_dil_to_WREG2: |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
72 movf lo,W ; |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
73 movf PLUSW1,W ; Get Type of Dil #lo |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
74 sublw .1 ; it is = 1 (First Dil) |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
75 bz get_first_dil_to_WREG3 ; Found the first dil! |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
76 incf lo,F ; ++ |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
77 movlw NUM_GAS+1 |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
78 cpfseq lo ; All done? |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
79 bra get_first_dil_to_WREG2 ; Not yet |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
80 ; No first dil found, use #1 |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
81 movlw .1 |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
82 movff WREG,opt_dil_type+0 ; Set Dil1 to First |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
83 return |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
84 get_first_dil_to_WREG3: |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
85 movf lo,W ; Put into Wreg |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
86 return ; Done |
0 | 87 |
88 global get_first_gas_to_WREG | |
89 get_first_gas_to_WREG: ; Gets first gas (0-4) into WREG | |
90 lfsr FSR1,opt_gas_type ; Point to gas types | |
91 clrf lo ; start with Gas0 | |
92 get_first_gas_to_WREG2: | |
93 movf lo,W ; | |
94 movf PLUSW1,W ; Get Type of Gas #lo | |
95 sublw .1 ; it is = 1 (First Gas) | |
96 bz get_first_gas_to_WREG3 ; Found the first gas! | |
97 incf lo,F ; ++ | |
98 movlw NUM_GAS+1 | |
99 cpfseq lo ; All done? | |
100 bra get_first_gas_to_WREG2 ; Not yet | |
81
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
101 ; No first gas found, use #1 |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
102 movlw .1 |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
103 movff WREG,opt_gas_type+0 ; Set Gas1 to First |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
104 return |
0 | 105 get_first_gas_to_WREG3: |
106 movf lo,W ; Put into Wreg | |
107 return ; Done | |
108 | |
109 deco_setup: | |
110 banksel char_I_step_is_1min ; Select the right bank... | |
111 clrf char_I_step_is_1min ; Default to 2sec steps. | |
46 | 112 clrf char_I_const_ppO2 ; Clear for OC, will be set for CC later |
0 | 113 |
114 ; Fixed ambient surface pressure to 1bar. | |
115 movlw LOW(.1000) | |
116 movwf int_I_pres_surface+0 | |
117 movwf int_I_pres_respiration+0 | |
118 movlw HIGH(.1000) | |
119 movwf int_I_pres_surface+1 | |
120 movwf int_I_pres_respiration+1 | |
121 | |
46 | 122 clrf int_I_divemins+0 ; Dive start |
0 | 123 clrf int_I_divemins+1 |
46 | 124 banksel common ; Bank1 |
125 bcf use_agf ; =1: Use aGF | |
126 | |
40 | 127 rcall deco_setup_dive |
0 | 128 |
46 | 129 ; Setup char_I_const_ppO2 for CC modes |
130 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active | |
40 | 131 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always start with SP1) |
132 | |
133 rcall get_first_gas_to_WREG ; Gets first gas (0-4) into WREG | |
0 | 134 movff WREG,char_I_first_gas ; Copy for compatibility |
197 | 135 banksel char_I_first_gas |
136 incf char_I_first_gas,F ; 0-4 -> 1-5 | |
137 banksel common | |
0 | 138 extern setup_gas_registers |
139 call setup_gas_registers ; With WREG=Gas 0-4, set current N2/He/O2 ratios. | |
140 extern set_actual_ppo2 | |
141 call set_actual_ppo2 ; Then configure char_I_actual_ppO2 (For CNS) | |
40 | 142 return |
0 | 143 |
144 global deco_setup_dive | |
145 deco_setup_dive: ; Called from divemode | |
146 banksel common ; Bank1 | |
147 | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
148 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
149 rcall deco_setup_cc_diluents ; Setup CC Diluents |
0 | 150 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active |
151 rcall deco_setup_oc_gases ; Setup OC Gases | |
152 btfsc is_bailout ; =1: Bailout | |
153 rcall deco_setup_oc_gases ; Setup OC/Bailout Gases | |
154 | |
178 | 155 movff divemins+0,int_I_divemins+0 ; Current dive time. |
156 movff divemins+1,int_I_divemins+1 | |
157 | |
0 | 158 movlw deco_distance |
159 movff WREG,char_I_deco_distance | |
160 movff opt_last_stop,char_I_depth_last_deco | |
161 movff opt_GF_low,char_I_GF_Low_percentage | |
162 movff opt_GF_high,char_I_GF_High_percentage | |
163 ;Overwrite GF if aGF is wanted | |
164 btfsc use_agf ; =1: Use aGF | |
165 movff opt_aGF_low,char_I_GF_Low_percentage | |
166 btfsc use_agf ; =1: Use aGF | |
167 movff opt_aGF_high,char_I_GF_High_percentage | |
168 return | |
169 | |
170 deco_setup_cc_diluents: | |
171 movff opt_dil_He_ratio+0,char_I_deco_He_ratio+0 | |
172 movff char_I_deco_He_ratio+0,lo | |
173 movff opt_dil_O2_ratio+0,WREG | |
174 addwf lo,W ; O2 + He -> WREG | |
175 sublw .100 ; 100 - (O2 + He) -> WREG | |
176 movff WREG,char_I_deco_N2_ratio+0 | |
177 movff opt_dil_type+0,WREG ; 0=Disabled, 1=First, 2=Normal | |
178 tstfsz WREG ; Disabled? | |
179 bra $+4 ; No | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
180 movff WREG,char_I_dil_change+0 ; Yes, clear char_I_deco_gas_change |
0 | 181 |
182 movff opt_dil_He_ratio+1,char_I_deco_He_ratio+1 | |
183 movff char_I_deco_He_ratio+1,lo | |
184 movff opt_dil_O2_ratio+1,WREG | |
185 addwf lo,W ; O2 + He -> WREG | |
186 sublw .100 ; 100 - (O2 + He) -> WREG | |
187 movff WREG,char_I_deco_N2_ratio+1 | |
188 movff opt_dil_type+1,WREG ; 0=Disabled, 1=First, 2=Normal | |
189 tstfsz WREG ; Disabled? | |
190 bra $+4 ; No | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
191 movff WREG,char_I_dil_change+1 ; Yes, clear char_I_dil_change |
0 | 192 |
193 movff opt_dil_He_ratio+2,char_I_deco_He_ratio+2 | |
194 movff char_I_deco_He_ratio+2,lo | |
195 movff opt_dil_O2_ratio+2,WREG | |
196 addwf lo,W ; O2 + He -> WREG | |
197 sublw .100 ; 100 - (O2 + He) -> WREG | |
198 movff WREG,char_I_deco_N2_ratio+2 | |
199 movff opt_dil_type+2,WREG ; 0=Disabled, 1=First, 2=Normal | |
200 tstfsz WREG ; Disabled? | |
201 bra $+4 ; No | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
202 movff WREG,char_I_dil_change+2 ; Yes, clear char_I_dil_change |
0 | 203 |
204 movff opt_dil_He_ratio+3,char_I_deco_He_ratio+3 | |
205 movff char_I_deco_He_ratio+3,lo | |
206 movff opt_dil_O2_ratio+3,WREG | |
207 addwf lo,W ; O2 + He -> WREG | |
208 sublw .100 ; 100 - (O2 + He) -> WREG | |
209 movff WREG,char_I_deco_N2_ratio+3 | |
210 movff opt_dil_type+3,WREG ; 0=Disabled, 1=First, 2=Normal | |
211 tstfsz WREG ; Disabled? | |
212 bra $+4 ; No | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
213 movff WREG,char_I_dil_change+3 ; Yes, clear char_I_dil_change |
0 | 214 |
215 movff opt_dil_He_ratio+4,char_I_deco_He_ratio+4 | |
216 movff char_I_deco_He_ratio+4,lo | |
217 movff opt_dil_O2_ratio+4,WREG | |
218 addwf lo,W ; O2 + He -> WREG | |
219 sublw .100 ; 100 - (O2 + He) -> WREG | |
220 movff WREG,char_I_deco_N2_ratio+4 | |
221 movff opt_dil_type+4,WREG ; 0=Disabled, 1=First, 2=Normal | |
222 tstfsz WREG ; Disabled? | |
223 bra $+4 ; No | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
224 movff WREG,char_I_dil_change+4 ; Yes, clear char_I_dil_change |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
225 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
226 ; Setup char_I_deco_gas_change array |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
227 movff char_I_dil_change+0, char_I_deco_gas_change+0 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
228 movff char_I_dil_change+1, char_I_deco_gas_change+1 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
229 movff char_I_dil_change+2, char_I_deco_gas_change+2 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
230 movff char_I_dil_change+3, char_I_deco_gas_change+3 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
231 movff char_I_dil_change+4, char_I_deco_gas_change+4 |
0 | 232 return |
233 | |
234 deco_setup_oc_gases: | |
235 movff opt_gas_He_ratio+0,char_I_deco_He_ratio+0 | |
236 movff char_I_deco_He_ratio+0,lo | |
237 movff opt_gas_O2_ratio+0,WREG | |
238 addwf lo,W ; O2 + He -> WREG | |
239 sublw .100 ; 100 - (O2 + He) -> WREG | |
240 movff WREG,char_I_deco_N2_ratio+0 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
241 banksel opt_gas_type+0 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
242 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
243 cpfseq opt_gas_type+0 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
244 clrf opt_OC_bail_gas_change+0 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
245 banksel common |
0 | 246 |
247 movff opt_gas_He_ratio+1,char_I_deco_He_ratio+1 | |
248 movff char_I_deco_He_ratio+1,lo | |
249 movff opt_gas_O2_ratio+1,WREG | |
250 addwf lo,W ; O2 + He -> WREG | |
251 sublw .100 ; 100 - (O2 + He) -> WREG | |
252 movff WREG,char_I_deco_N2_ratio+1 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
253 banksel opt_gas_type+1 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
254 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
255 cpfseq opt_gas_type+1 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
256 clrf opt_OC_bail_gas_change+1 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
257 banksel common |
0 | 258 |
259 movff opt_gas_He_ratio+2,char_I_deco_He_ratio+2 | |
260 movff char_I_deco_He_ratio+2,lo | |
261 movff opt_gas_O2_ratio+2,WREG | |
262 addwf lo,W ; O2 + He -> WREG | |
263 sublw .100 ; 100 - (O2 + He) -> WREG | |
264 movff WREG,char_I_deco_N2_ratio+2 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
265 banksel opt_gas_type+2 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
266 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
267 cpfseq opt_gas_type+2 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
268 clrf opt_OC_bail_gas_change+2 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
269 banksel common |
0 | 270 |
271 movff opt_gas_He_ratio+3,char_I_deco_He_ratio+3 | |
272 movff char_I_deco_He_ratio+3,lo | |
273 movff opt_gas_O2_ratio+3,WREG | |
274 addwf lo,W ; O2 + He -> WREG | |
275 sublw .100 ; 100 - (O2 + He) -> WREG | |
276 movff WREG,char_I_deco_N2_ratio+3 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
277 banksel opt_gas_type+3 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
278 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
279 cpfseq opt_gas_type+3 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
280 clrf opt_OC_bail_gas_change+3 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
281 banksel common |
0 | 282 |
283 movff opt_gas_He_ratio+4,char_I_deco_He_ratio+4 | |
284 movff char_I_deco_He_ratio+4,lo | |
285 movff opt_gas_O2_ratio+4,WREG | |
286 addwf lo,W ; O2 + He -> WREG | |
287 sublw .100 ; 100 - (O2 + He) -> WREG | |
288 movff WREG,char_I_deco_N2_ratio+4 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
289 banksel opt_gas_type+4 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
290 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
291 cpfseq opt_gas_type+4 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
292 clrf opt_OC_bail_gas_change+4 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
293 banksel common |
94
f2201aa374db
BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents:
81
diff
changeset
|
294 |
f2201aa374db
BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents:
81
diff
changeset
|
295 movlw .0 |
f2201aa374db
BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents:
81
diff
changeset
|
296 movff WREG,char_I_const_ppO2 ; Clear constant ppO2 for OC/bailout |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
297 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
298 ; Setup char_I_deco_gas_change array |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
299 movff opt_OC_bail_gas_change+0, char_I_deco_gas_change+0 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
300 movff opt_OC_bail_gas_change+1, char_I_deco_gas_change+1 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
301 movff opt_OC_bail_gas_change+2, char_I_deco_gas_change+2 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
302 movff opt_OC_bail_gas_change+3, char_I_deco_gas_change+3 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
303 movff opt_OC_bail_gas_change+4, char_I_deco_gas_change+4 |
0 | 304 return |
305 | |
306 ;============================================================================= | |
307 ; Reset decompression tissues | |
308 ; | |
309 global deco_reset | |
310 deco_reset: | |
311 rcall deco_setup ; Setup all model parameters. | |
312 call deco_clear_tissue ; Set all tissues to Pamb * N2_ratio | |
313 call deco_clear_CNS_fraction ; Reset CNS value. | |
314 banksel common ; Bank1 | |
315 return | |
316 | |
317 ;============================================================================= | |
318 ; Launch decoplanning | |
319 ; | |
320 global deco_planer | |
321 deco_planer: | |
322 call speed_fastest ; Quick ! | |
323 rcall deco_setup ; Setup all model parameters. | |
324 call deco_push_tissues_to_vault | |
325 banksel common ; Bank1 | |
326 | |
327 ;---- Specific settings ------------------------------------------------------ | |
328 | |
329 banksel char_O_deco_status ; Bank 2 | |
330 movlw .3 ; Start in surface state. | |
331 movwf char_O_deco_status | |
332 | |
333 banksel char_I_step_is_1min ; Bank 3 | |
334 movlw 1 | |
335 movwf char_I_step_is_1min ; Set 1min steps | |
336 | |
337 ;---- Add delay at surface, if needed ---------------------------------------- | |
338 tstfsz char_I_dive_interval | |
339 call deco_calc_dive_interval | |
340 | |
341 ;---- Dive loop -------------------------------------------------------------- | |
342 | |
343 ; Compute dive ambiant conditions | |
344 banksel char_I_bottom_depth | |
345 movf char_I_bottom_depth,W | |
346 mullw .100 | |
347 movlw LOW(.1000) | |
348 addwf PRODL,W | |
349 movwf int_I_pres_respiration+0 | |
350 movlw HIGH(.1000) | |
351 addwfc PRODH,W | |
352 movwf int_I_pres_respiration+1 | |
353 | |
354 banksel int_I_divemins ; Bank 4 | |
355 clrf int_I_divemins+0 ; Clear dive time | |
356 clrf int_I_divemins+1 | |
357 | |
358 clrf TMR5L | |
359 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H | |
360 call deco_calc_hauptroutine ; Reset + simulate first min. | |
361 | |
362 deco_planer_loop: | |
363 banksel int_I_divemins ; Bank 3 | |
364 incf int_I_divemins,F ; Done 1 min. | |
365 btg LEDg | |
366 | |
367 movf char_I_bottom_time,W ; Finished ? | |
368 xorwf int_I_divemins,W | |
369 bz deco_planer_endloop ; YES | |
111 | 370 |
0 | 371 call deco_calc_tissue ; JUST calc tissue (faster). |
372 call deco_calc_CNS_fraction ; Also calculate CNS (in 1min loop) | |
373 bra deco_planer_loop | |
374 | |
375 deco_planer_endloop: | |
376 banksel char_I_step_is_1min | |
377 clrf char_I_step_is_1min ; Back to 2sec loops | |
378 | |
379 ;---- Wait until status reach zero ------------------------------------------- | |
380 deco_planer_finishing: | |
381 btg LEDg | |
382 clrf TMR5L | |
383 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H | |
384 call deco_calc_hauptroutine ; Simulate 2sec more | |
385 | |
386 banksel char_O_deco_status ; Bank 2 | |
387 movf char_O_deco_status,W | |
388 bz deco_planer_finished | |
389 | |
390 bra deco_planer_finishing | |
391 | |
392 deco_planer_finished: | |
393 call deco_calc_CNS_planning | |
394 movff int_O_CNS_fraction+0,decoplan_CNS+0 | |
395 movff int_O_CNS_fraction+1,decoplan_CNS+1 | |
396 call deco_pull_tissues_from_vault | |
397 bcf LEDg | |
398 banksel common ; Bank1 | |
399 movlw b'00111000' ; 1:8 Prescaler -> 65,536ms@16MHz | |
400 movwf T3CON | |
401 call speed_normal | |
402 return | |
403 | |
404 ;----------------------------------------------------------------------------- | |
405 ; Draw a stop of the deco plan (simulator or dive). | |
406 ; Inputs: lo = depth. Range 3m...93m | |
407 ; + 80 if this is a switch-gas stop. | |
408 ; up = minutes. range 1'..240'. | |
409 ; win_top = line to draw on screen. | |
410 ; Trashed: up, lo, win_height, win_leftx2, win_width, win_color*, | |
411 ; WREG, PROD, TBLPTR TABLAT. | |
412 ; | |
413 deco_plan_show_stop: | |
414 ;---- Print depth ---------------------------------------------------- | |
415 btfss lo,7 ; Bit set ? | |
416 bra deco_plan_show_std_stop ; No : Just an usual stop. | |
417 | |
50 | 418 call TFT_attention_color |
0 | 419 bcf lo,7 ; and cleanup depth. |
420 bra deco_plan_show_nstd_stop | |
421 | |
422 deco_plan_show_std_stop: | |
50 | 423 call TFT_standard_color |
0 | 424 |
425 deco_plan_show_nstd_stop: | |
426 lfsr FSR2,buffer | |
427 | |
428 TSTOSS opt_units ; 0=Meters, 1=Feets | |
429 bra deco_plan_show_nstd_stop_metric | |
430 | |
431 WIN_LEFT .85 | |
432 movf lo,W ; lo = m | |
433 mullw .100 ; PRODL:PRODH = mbar | |
434 movff PRODL,lo | |
435 movff PRODH,hi | |
436 ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops... | |
437 movff lo,xA+0 | |
438 movff hi,xA+1 | |
439 movlw LOW d'334' ; 334feet/100m | |
440 movwf xB+0 | |
441 movlw HIGH d'334' | |
442 movwf xB+1 | |
443 call mult16x16 ; xA*xB=xC (lo:hi * 328) | |
444 movlw d'50' ; round up | |
445 addwf xC+0,F | |
446 movlw 0 | |
447 addwfc xC+1,F | |
448 addwfc xC+2,F | |
449 addwfc xC+3,F | |
450 movlw d'100' | |
451 movwf xB+0 | |
452 clrf xB+1 | |
453 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
454 movff xC+0,lo | |
455 movff xC+1,hi ; restore lo and hi with updated value | |
456 bsf leftbind | |
457 bsf ignore_digit4 ; Only full feet | |
458 output_16 | |
459 STRCAT_PRINT "ft " | |
460 bra deco_plan_show_nstd_stop_common | |
461 | |
462 deco_plan_show_nstd_stop_metric: | |
463 WIN_LEFT .90 | |
464 bsf leftbind | |
465 output_8 ; outputs into Postinc2! | |
466 STRCAT_PRINT "m " | |
467 deco_plan_show_nstd_stop_common: | |
468 ;---- Print duration ------------------------------------------------- | |
469 WIN_LEFT .135 | |
470 lfsr FSR2,buffer | |
471 | |
472 movf lo,W ; Swap up & lo | |
473 movff up,lo | |
474 movwf up | |
475 | |
476 output_8 ; Allow up to 240' | |
477 STRCAT_PRINT "' " ; 1 to 3 chars for depth. | |
478 | |
479 movf lo,W ; Swap back up & lo | |
480 movff up,lo | |
481 movwf up | |
482 | |
483 ;--------------------------------------------------------------------- | |
484 ; Draw the bar graph used for deco stops (decoplan in simulator or dive). | |
485 incf win_top,F | |
486 movlw .19 | |
487 movwf win_height | |
488 movlw .118 | |
489 movwf win_leftx2 ; column left (0-159) | |
490 movlw .16 | |
491 movwf win_width ; column max width. | |
492 | |
493 ; Draw used area (up = minutes): | |
494 movlw .16 ; Limit length (16min) | |
495 cpfslt up | |
496 movwf up | |
497 movff up,win_bargraph ; Active width, the rest is cleared. | |
498 call TFT_box | |
499 | |
500 ; Restore win_top | |
50 | 501 call TFT_standard_color |
0 | 502 decf win_top,F ; Restore win_top |
503 return | |
504 | |
505 ;----------------------------------------------------------------------------- | |
506 ; Clear unused area belw last stop | |
507 ; Inputs: win_top : last used area... | |
508 deco_plan_show_clear_bottom: | |
509 movf win_top,W ; Get back from bank0 | |
510 btfsc divemode ; In dive mode ? | |
511 sublw .168 ; Yes: bottom row in divemode | |
512 btfss divemode ; In dive mode ? | |
513 sublw .240 ; No: bottom row in planning | |
514 movwf win_height | |
515 | |
516 WIN_LEFT .85 ; Full divemenu width | |
517 movlw .160-.85+1 | |
518 movwf win_width | |
519 | |
520 clrf win_color1 ; Fill with black | |
521 clrf win_color2 | |
522 | |
523 goto TFT_box | |
524 | |
525 ;----------------------------------------------------------------------------- | |
526 ; Display the decoplan (simulator or divemode). | |
527 ; Inputs: char_O_deco_table (array of stop times, in minutes) | |
528 ; decoplan_page = page number. | |
529 ; | |
530 deco_show_plan_page: | |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
178
diff
changeset
|
531 bcf win_invert ; Reset invert flag |
0 | 532 |
533 ;---- Is there deco stops ? ------------------------------------------ | |
534 movff char_O_first_deco_depth,WREG | |
535 iorwf WREG | |
536 bnz deco_plan_show_1 | |
537 | |
538 ;---- No Deco -------------------------------------------------------- | |
50 | 539 call TFT_standard_color |
0 | 540 TEXT_SMALL .80, .0, tNoDeco |
541 bsf decoplan_last_ceiling_shown | |
542 return | |
543 | |
544 deco_plan_show_1: | |
545 lfsr FSR0,char_O_deco_depth ; Initialize indexed addressing. | |
546 lfsr FSR1,char_O_deco_time | |
547 | |
548 clrf decoplan_index ; Start with index = 0 | |
549 clrf win_top ; and row = 0 | |
550 | |
551 ; Read stop parameters, indexed by decoplan_index and decoplan_page | |
552 movf decoplan_page,W ; decoplan_gindex = 6*decoplan_page + decoplan_index | |
148 | 553 mullw .8 ; 8 lines/page in decoplan |
0 | 554 movf decoplan_index,W |
555 addwf PRODL,W | |
556 movwf decoplan_gindex ; --> decoplan_gindex | |
557 | |
558 bcf decoplan_last_ceiling_shown ; Not finished yet... | |
559 | |
560 deco_plan_show_2: | |
561 btfsc decoplan_gindex,5 ; Reached table length (32) ? | |
562 bra deco_plan_show_99 ; YES: finished... | |
563 | |
564 ; Read stop parameters, indexed by decoplan_index | |
565 movf decoplan_gindex,W ; index | |
566 movff PLUSW1,up ; char_O_deco_time [gindex] --> up | |
567 movff PLUSW0,lo ; char_O_deco_depth[gindex] | |
568 movf lo,W | |
569 bz deco_plan_show_99 ; depth == 0 : finished. | |
570 | |
571 ; Display the stop line | |
572 rcall deco_plan_show_stop | |
573 | |
574 ; Next | |
575 movlw .24 | |
576 addwf win_top,F ; row: += 24 | |
577 incf decoplan_index,F ; local index += 1 | |
578 incf decoplan_gindex,F ; global index += 1 | |
579 | |
580 ; Max number of lines/page reached ? | |
148 | 581 movlw .8 ; 8 lines/page in decoplan |
0 | 582 cpfseq decoplan_index |
583 bra deco_plan_show_2 ; NO: loop | |
584 | |
585 ; Check if next stop if end-of-list ? | |
586 movf decoplan_gindex,W | |
587 movf PLUSW0,W ; char_O_deco_depth[gindex] | |
588 bz deco_plan_show_99 ; End of list... | |
589 | |
590 ; Display the message "more..." | |
591 rcall deco_plan_show_clear_bottom ; Clear from next line | |
592 | |
50 | 593 call TFT_standard_color |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
594 TEXT_SMALL .88, .220, tMore |
0 | 595 return |
596 | |
597 deco_plan_show_99: | |
598 bsf decoplan_last_ceiling_shown ; Nothing more in table to display. | |
599 rcall deco_plan_show_clear_bottom ; Clear from next line | |
600 return | |
601 | |
602 ;----------------------------------------------------------------------------- | |
603 ; Loop to show all pages of the decoplan (surfacemode) | |
604 | |
605 global deco_show_plan | |
606 deco_show_plan: | |
607 clrf decoplan_page | |
608 call TFT_ClearScreen | |
609 WIN_COLOR color_greenish | |
610 TEXT_SMALL .1,.1, tDivePlan | |
50 | 611 call TFT_standard_color |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
612 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
613 ; Show plan parameters |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
614 WIN_SMALL .0,.25 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
615 STRCPY "Int:" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
616 movff char_I_dive_interval,lo |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
617 bsf leftbind |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
618 output_8 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
619 STRCAT_PRINT "'" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
620 WIN_SMALL .0,.50 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
621 STRCPY_TEXT tBtTm_short |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
622 movff char_I_bottom_time,lo |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
623 bsf leftbind |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
624 output_8 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
625 STRCAT_PRINT "'" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
626 WIN_SMALL .0,.75 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
627 STRCPY_TEXT tDepth |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
628 PUTC ":" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
629 movff char_I_bottom_depth,lo |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
630 bsf leftbind |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
631 output_8 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
632 STRCAT_PRINT "m" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
633 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
634 ; Show deco mode |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
635 WIN_TOP .155 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
636 lfsr FSR2,buffer |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
637 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
638 call TFT_display_decotype_surface1 |
0 | 639 |
640 ;---- Display model | |
641 movff char_I_deco_model,WREG | |
642 iorwf WREG | |
643 bnz deco_show_plan_m1 | |
644 | |
645 ; Display ZH-L16 sat/desat model. | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
646 TEXT_SMALL .0,.130, tZHL16 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
647 WIN_SMALL .14,.155 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
648 PUTC "," |
0 | 649 movff char_I_desaturation_multiplier,lo |
650 output_8 | |
651 STRCAT "%/" | |
652 movff char_I_saturation_multiplier,lo | |
653 output_8 | |
654 bra deco_show_plan_m2 | |
655 | |
656 ; Display ZH-L16-GF low/high model. | |
657 deco_show_plan_m1: | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
658 TEXT_SMALL .0,.130, tZHL16GF |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
659 WIN_SMALL .14,.155 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
660 PUTC "," |
0 | 661 movff char_I_GF_Low_percentage,lo |
662 output_99x | |
663 STRCAT "%/" | |
664 movff char_I_GF_High_percentage,lo | |
665 output_99x | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
666 deco_show_plan_m2: |
0 | 667 STRCAT_PRINT "%" |
668 | |
669 ;---- Display TTS result | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
670 WIN_SMALL .0,.180 |
0 | 671 STRCPY_TEXT tTTS |
672 STRCAT ": " | |
673 | |
674 movff int_O_ascenttime+0,lo | |
675 movff int_O_ascenttime+1,hi | |
676 bsf leftbind | |
677 output_16 | |
678 STRCAT_PRINT "'" | |
679 | |
680 ;---- Display CNS result | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
681 WIN_TOP .205 |
0 | 682 STRCPY_TEXT tCNS |
683 STRCAT ": " | |
684 movff int_O_CNS_fraction+0,lo | |
685 movff int_O_CNS_fraction+1,hi | |
225
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
208
diff
changeset
|
686 output_16_3 ; limit to 999 and display only (0-999) |
0 | 687 STRCAT "%\x92" ; "->" |
688 movff decoplan_CNS+0,lo | |
689 movff decoplan_CNS+1,hi | |
225
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
208
diff
changeset
|
690 output_16_3 ; limit to 999 and display only (0-999) |
0 | 691 STRCAT_PRINT "%" |
692 | |
693 ;---- Loop through pages | |
694 deco_show_plan_1: | |
695 rcall deco_show_plan_page | |
696 incf decoplan_page,F | |
697 | |
698 call logbook_preloop_tasks | |
699 deco_show_plan_2: | |
700 btfsc switch_right | |
701 bra deco_show_plan_3 | |
702 btfsc switch_left | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
703 return ; Return to simulator menu |
0 | 704 call log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second |
705 btfsc sleepmode ; Timeout? | |
9 | 706 goto restart |
0 | 707 bra deco_show_plan_2 |
708 | |
709 deco_show_plan_3: | |
710 btfss decoplan_last_ceiling_shown | |
711 bra deco_show_plan_1 | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
712 return ; Return to simulator menu |
0 | 713 |
714 ;============================================================================= | |
715 ; | |
716 global do_demo_divemode | |
717 do_demo_divemode: | |
718 extern option_save_all | |
719 call option_save_all ; Save all settings into EEPROM before starting simulation | |
720 call deco_push_tissues_to_vault | |
721 banksel common ; Bank1 | |
722 | |
723 bsf restore_deco_data ; Restore tissue and CNS after sim | |
724 | |
725 bcf pressure_refresh | |
726 btfss pressure_refresh ; Wait for sensor | |
727 bra $-2 | |
728 | |
729 bsf simulatormode_active ; Set Flag | |
132
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
730 ; Compute dive ambient conditions |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
731 banksel char_I_bottom_depth |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
732 movf char_I_bottom_depth,W |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
733 mullw .100 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
734 movff PRODL,rel_pressure+0 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
735 movff PRODH,rel_pressure+1 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
736 movlw LOW(.1000) |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
737 addwf PRODL,W |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
738 movff WREG,sim_pressure+0 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
739 movlw HIGH(.1000) |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
740 addwfc PRODH,W |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
741 movff WREG,sim_pressure+1 |
0 | 742 |
136 | 743 banksel common ; Bank1 |
0 | 744 bsf divemode |
745 goto diveloop ; Switch into Divemode! | |
746 | |
747 | |
748 END |