Mercurial > public > hwos_code
comparison src/simulator.asm @ 97:53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
CHANGE: Re-select last diluent when returning from bailout to OC
author | heinrichsweikamp |
---|---|
date | Mon, 28 Apr 2014 16:26:31 +0200 |
parents | f2201aa374db |
children | c61b7a4e317c |
comparison
equal
deleted
inserted
replaced
96:a4bff632e97b | 97:53a99a2dc6a1 |
---|---|
139 | 139 |
140 global deco_setup_dive | 140 global deco_setup_dive |
141 deco_setup_dive: ; Called from divemode | 141 deco_setup_dive: ; Called from divemode |
142 banksel common ; Bank1 | 142 banksel common ; Bank1 |
143 | 143 |
144 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active | |
145 rcall deco_setup_cc_diluents ; Setup CC Diluents | |
144 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active | 146 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active |
145 rcall deco_setup_oc_gases ; Setup OC Gases | 147 rcall deco_setup_oc_gases ; Setup OC Gases |
146 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active | |
147 rcall deco_setup_cc_diluents ; Setup CC Diluents | |
148 btfsc is_bailout ; =1: Bailout | 148 btfsc is_bailout ; =1: Bailout |
149 rcall deco_setup_oc_gases ; Setup OC/Bailout Gases | 149 rcall deco_setup_oc_gases ; Setup OC/Bailout Gases |
150 | 150 |
151 movlw deco_distance | 151 movlw deco_distance |
152 movff WREG,char_I_deco_distance | 152 movff WREG,char_I_deco_distance |
168 sublw .100 ; 100 - (O2 + He) -> WREG | 168 sublw .100 ; 100 - (O2 + He) -> WREG |
169 movff WREG,char_I_deco_N2_ratio+0 | 169 movff WREG,char_I_deco_N2_ratio+0 |
170 movff opt_dil_type+0,WREG ; 0=Disabled, 1=First, 2=Normal | 170 movff opt_dil_type+0,WREG ; 0=Disabled, 1=First, 2=Normal |
171 tstfsz WREG ; Disabled? | 171 tstfsz WREG ; Disabled? |
172 bra $+4 ; No | 172 bra $+4 ; No |
173 movff WREG,char_I_deco_gas_change+0 ; Yes, clear char_I_deco_gas_change | 173 movff WREG,char_I_dil_change+0 ; Yes, clear char_I_deco_gas_change |
174 | 174 |
175 movff opt_dil_He_ratio+1,char_I_deco_He_ratio+1 | 175 movff opt_dil_He_ratio+1,char_I_deco_He_ratio+1 |
176 movff char_I_deco_He_ratio+1,lo | 176 movff char_I_deco_He_ratio+1,lo |
177 movff opt_dil_O2_ratio+1,WREG | 177 movff opt_dil_O2_ratio+1,WREG |
178 addwf lo,W ; O2 + He -> WREG | 178 addwf lo,W ; O2 + He -> WREG |
179 sublw .100 ; 100 - (O2 + He) -> WREG | 179 sublw .100 ; 100 - (O2 + He) -> WREG |
180 movff WREG,char_I_deco_N2_ratio+1 | 180 movff WREG,char_I_deco_N2_ratio+1 |
181 movff opt_dil_type+1,WREG ; 0=Disabled, 1=First, 2=Normal | 181 movff opt_dil_type+1,WREG ; 0=Disabled, 1=First, 2=Normal |
182 tstfsz WREG ; Disabled? | 182 tstfsz WREG ; Disabled? |
183 bra $+4 ; No | 183 bra $+4 ; No |
184 movff WREG,char_I_deco_gas_change+1 ; Yes, clear char_I_deco_gas_change | 184 movff WREG,char_I_dil_change+1 ; Yes, clear char_I_dil_change |
185 | 185 |
186 movff opt_dil_He_ratio+2,char_I_deco_He_ratio+2 | 186 movff opt_dil_He_ratio+2,char_I_deco_He_ratio+2 |
187 movff char_I_deco_He_ratio+2,lo | 187 movff char_I_deco_He_ratio+2,lo |
188 movff opt_dil_O2_ratio+2,WREG | 188 movff opt_dil_O2_ratio+2,WREG |
189 addwf lo,W ; O2 + He -> WREG | 189 addwf lo,W ; O2 + He -> WREG |
190 sublw .100 ; 100 - (O2 + He) -> WREG | 190 sublw .100 ; 100 - (O2 + He) -> WREG |
191 movff WREG,char_I_deco_N2_ratio+2 | 191 movff WREG,char_I_deco_N2_ratio+2 |
192 movff opt_dil_type+2,WREG ; 0=Disabled, 1=First, 2=Normal | 192 movff opt_dil_type+2,WREG ; 0=Disabled, 1=First, 2=Normal |
193 tstfsz WREG ; Disabled? | 193 tstfsz WREG ; Disabled? |
194 bra $+4 ; No | 194 bra $+4 ; No |
195 movff WREG,char_I_deco_gas_change+2 ; Yes, clear char_I_deco_gas_change | 195 movff WREG,char_I_dil_change+2 ; Yes, clear char_I_dil_change |
196 | 196 |
197 movff opt_dil_He_ratio+3,char_I_deco_He_ratio+3 | 197 movff opt_dil_He_ratio+3,char_I_deco_He_ratio+3 |
198 movff char_I_deco_He_ratio+3,lo | 198 movff char_I_deco_He_ratio+3,lo |
199 movff opt_dil_O2_ratio+3,WREG | 199 movff opt_dil_O2_ratio+3,WREG |
200 addwf lo,W ; O2 + He -> WREG | 200 addwf lo,W ; O2 + He -> WREG |
201 sublw .100 ; 100 - (O2 + He) -> WREG | 201 sublw .100 ; 100 - (O2 + He) -> WREG |
202 movff WREG,char_I_deco_N2_ratio+3 | 202 movff WREG,char_I_deco_N2_ratio+3 |
203 movff opt_dil_type+3,WREG ; 0=Disabled, 1=First, 2=Normal | 203 movff opt_dil_type+3,WREG ; 0=Disabled, 1=First, 2=Normal |
204 tstfsz WREG ; Disabled? | 204 tstfsz WREG ; Disabled? |
205 bra $+4 ; No | 205 bra $+4 ; No |
206 movff WREG,char_I_deco_gas_change+3 ; Yes, clear char_I_deco_gas_change | 206 movff WREG,char_I_dil_change+3 ; Yes, clear char_I_dil_change |
207 | 207 |
208 movff opt_dil_He_ratio+4,char_I_deco_He_ratio+4 | 208 movff opt_dil_He_ratio+4,char_I_deco_He_ratio+4 |
209 movff char_I_deco_He_ratio+4,lo | 209 movff char_I_deco_He_ratio+4,lo |
210 movff opt_dil_O2_ratio+4,WREG | 210 movff opt_dil_O2_ratio+4,WREG |
211 addwf lo,W ; O2 + He -> WREG | 211 addwf lo,W ; O2 + He -> WREG |
212 sublw .100 ; 100 - (O2 + He) -> WREG | 212 sublw .100 ; 100 - (O2 + He) -> WREG |
213 movff WREG,char_I_deco_N2_ratio+4 | 213 movff WREG,char_I_deco_N2_ratio+4 |
214 movff opt_dil_type+4,WREG ; 0=Disabled, 1=First, 2=Normal | 214 movff opt_dil_type+4,WREG ; 0=Disabled, 1=First, 2=Normal |
215 tstfsz WREG ; Disabled? | 215 tstfsz WREG ; Disabled? |
216 bra $+4 ; No | 216 bra $+4 ; No |
217 movff WREG,char_I_deco_gas_change+4 ; Yes, clear char_I_deco_gas_change | 217 movff WREG,char_I_dil_change+4 ; Yes, clear char_I_dil_change |
218 | |
219 ; Setup char_I_deco_gas_change array | |
220 movff char_I_dil_change+0, char_I_deco_gas_change+0 | |
221 movff char_I_dil_change+1, char_I_deco_gas_change+1 | |
222 movff char_I_dil_change+2, char_I_deco_gas_change+2 | |
223 movff char_I_dil_change+3, char_I_deco_gas_change+3 | |
224 movff char_I_dil_change+4, char_I_deco_gas_change+4 | |
218 return | 225 return |
219 | 226 |
220 deco_setup_oc_gases: | 227 deco_setup_oc_gases: |
221 movff opt_gas_He_ratio+0,char_I_deco_He_ratio+0 | 228 movff opt_gas_He_ratio+0,char_I_deco_He_ratio+0 |
222 movff char_I_deco_He_ratio+0,lo | 229 movff char_I_deco_He_ratio+0,lo |
225 sublw .100 ; 100 - (O2 + He) -> WREG | 232 sublw .100 ; 100 - (O2 + He) -> WREG |
226 movff WREG,char_I_deco_N2_ratio+0 | 233 movff WREG,char_I_deco_N2_ratio+0 |
227 movff opt_gas_type+0,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco | 234 movff opt_gas_type+0,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco |
228 tstfsz WREG ; Disabled? | 235 tstfsz WREG ; Disabled? |
229 bra $+4 ; No | 236 bra $+4 ; No |
230 movff WREG,char_I_deco_gas_change+0 ; Yes, clear char_I_deco_gas_change | 237 movff WREG,opt_OC_bail_gas_change+0 ; Yes, clear opt_OC_bail_gas_change |
231 | 238 |
232 movff opt_gas_He_ratio+1,char_I_deco_He_ratio+1 | 239 movff opt_gas_He_ratio+1,char_I_deco_He_ratio+1 |
233 movff char_I_deco_He_ratio+1,lo | 240 movff char_I_deco_He_ratio+1,lo |
234 movff opt_gas_O2_ratio+1,WREG | 241 movff opt_gas_O2_ratio+1,WREG |
235 addwf lo,W ; O2 + He -> WREG | 242 addwf lo,W ; O2 + He -> WREG |
236 sublw .100 ; 100 - (O2 + He) -> WREG | 243 sublw .100 ; 100 - (O2 + He) -> WREG |
237 movff WREG,char_I_deco_N2_ratio+1 | 244 movff WREG,char_I_deco_N2_ratio+1 |
238 movff opt_gas_type+1,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco | 245 movff opt_gas_type+1,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco |
239 tstfsz WREG ; Disabled? | 246 tstfsz WREG ; Disabled? |
240 bra $+4 ; No | 247 bra $+4 ; No |
241 movff WREG,char_I_deco_gas_change+1 ; Yes, clear char_I_deco_gas_change | 248 movff WREG,opt_OC_bail_gas_change+1 ; Yes, clear opt_OC_bail_gas_change |
242 | 249 |
243 movff opt_gas_He_ratio+2,char_I_deco_He_ratio+2 | 250 movff opt_gas_He_ratio+2,char_I_deco_He_ratio+2 |
244 movff char_I_deco_He_ratio+2,lo | 251 movff char_I_deco_He_ratio+2,lo |
245 movff opt_gas_O2_ratio+2,WREG | 252 movff opt_gas_O2_ratio+2,WREG |
246 addwf lo,W ; O2 + He -> WREG | 253 addwf lo,W ; O2 + He -> WREG |
247 sublw .100 ; 100 - (O2 + He) -> WREG | 254 sublw .100 ; 100 - (O2 + He) -> WREG |
248 movff WREG,char_I_deco_N2_ratio+2 | 255 movff WREG,char_I_deco_N2_ratio+2 |
249 movff opt_gas_type+2,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco | 256 movff opt_gas_type+2,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco |
250 tstfsz WREG ; Disabled? | 257 tstfsz WREG ; Disabled? |
251 bra $+4 ; No | 258 bra $+4 ; No |
252 movff WREG,char_I_deco_gas_change+2 ; Yes, clear char_I_deco_gas_change | 259 movff WREG,opt_OC_bail_gas_change+2 ; Yes, clear opt_OC_bail_gas_change |
253 | 260 |
254 movff opt_gas_He_ratio+3,char_I_deco_He_ratio+3 | 261 movff opt_gas_He_ratio+3,char_I_deco_He_ratio+3 |
255 movff char_I_deco_He_ratio+3,lo | 262 movff char_I_deco_He_ratio+3,lo |
256 movff opt_gas_O2_ratio+3,WREG | 263 movff opt_gas_O2_ratio+3,WREG |
257 addwf lo,W ; O2 + He -> WREG | 264 addwf lo,W ; O2 + He -> WREG |
258 sublw .100 ; 100 - (O2 + He) -> WREG | 265 sublw .100 ; 100 - (O2 + He) -> WREG |
259 movff WREG,char_I_deco_N2_ratio+3 | 266 movff WREG,char_I_deco_N2_ratio+3 |
260 movff opt_gas_type+3,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco | 267 movff opt_gas_type+3,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco |
261 tstfsz WREG ; Disabled? | 268 tstfsz WREG ; Disabled? |
262 bra $+4 ; No | 269 bra $+4 ; No |
263 movff WREG,char_I_deco_gas_change+3 ; Yes, clear char_I_deco_gas_change | 270 movff WREG,opt_OC_bail_gas_change+3 ; Yes, clear opt_OC_bail_gas_change |
264 | 271 |
265 movff opt_gas_He_ratio+4,char_I_deco_He_ratio+4 | 272 movff opt_gas_He_ratio+4,char_I_deco_He_ratio+4 |
266 movff char_I_deco_He_ratio+4,lo | 273 movff char_I_deco_He_ratio+4,lo |
267 movff opt_gas_O2_ratio+4,WREG | 274 movff opt_gas_O2_ratio+4,WREG |
268 addwf lo,W ; O2 + He -> WREG | 275 addwf lo,W ; O2 + He -> WREG |
269 sublw .100 ; 100 - (O2 + He) -> WREG | 276 sublw .100 ; 100 - (O2 + He) -> WREG |
270 movff WREG,char_I_deco_N2_ratio+4 | 277 movff WREG,char_I_deco_N2_ratio+4 |
271 movff opt_gas_type+4,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco | 278 movff opt_gas_type+4,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco |
272 tstfsz WREG ; Disabled? | 279 tstfsz WREG ; Disabled? |
273 bra $+4 ; No | 280 bra $+4 ; No |
274 movff WREG,char_I_deco_gas_change+4 ; Yes, clear char_I_deco_gas_change | 281 movff WREG,opt_OC_bail_gas_change+4 ; Yes, clear opt_OC_bail_gas_change |
275 nop | 282 nop |
276 | 283 |
277 movlw .0 | 284 movlw .0 |
278 movff WREG,char_I_const_ppO2 ; Clear constant ppO2 for OC/bailout | 285 movff WREG,char_I_const_ppO2 ; Clear constant ppO2 for OC/bailout |
286 | |
287 ; Setup char_I_deco_gas_change array | |
288 movff opt_OC_bail_gas_change+0, char_I_deco_gas_change+0 | |
289 movff opt_OC_bail_gas_change+1, char_I_deco_gas_change+1 | |
290 movff opt_OC_bail_gas_change+2, char_I_deco_gas_change+2 | |
291 movff opt_OC_bail_gas_change+3, char_I_deco_gas_change+3 | |
292 movff opt_OC_bail_gas_change+4, char_I_deco_gas_change+4 | |
279 return | 293 return |
280 | 294 |
281 ;============================================================================= | 295 ;============================================================================= |
282 ; Reset decompression tissues | 296 ; Reset decompression tissues |
283 ; | 297 ; |