Mercurial > public > hwos_code
comparison src/simulator.asm @ 628:cd58f7fc86db
3.05 stable work
author | heinrichsweikamp |
---|---|
date | Thu, 19 Sep 2019 12:01:29 +0200 |
parents | c40025d8e750 |
children | 185ba2f91f59 |
comparison
equal
deleted
inserted
replaced
627:bf5fee575701 | 628:cd58f7fc86db |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File simulator.asm combined next generation V3.03.3 | 3 ; File simulator.asm combined next generation V3.04.3 |
4 ; | 4 ; |
5 ; Deco Calculator | 5 ; Deco Calculator |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
39 ENDIF | 39 ENDIF |
40 | 40 |
41 | 41 |
42 ;---- Private local Variables ------------------------------------------------- | 42 ;---- Private local Variables ------------------------------------------------- |
43 | 43 |
44 CBLOCK local1 ; max size is 16 Byte !!! | 44 CBLOCK local3 ; max size is 16 Byte !!! |
45 decoplan_index ; within each page | 45 decoplan_index ; within each page |
46 decoplan_gindex ; global index | 46 decoplan_gindex ; global index |
47 decoplan_last ; depth of last stop | 47 decoplan_last ; depth of last stop |
48 decoplan_flags ; private flags | 48 decoplan_flags ; private flags |
49 decoplan_page ; page number | 49 decoplan_page ; page number |
50 decoplan_warnings ; deco engine warnings | 50 decoplan_warnings ; deco engine warnings |
51 gas_index ; counter for looping through the gases | 51 gas_index ; counter for looping through the gases |
52 output_row ; used for positioning of the results output | 52 output_row ; used for positioning of the results output |
53 real_CNS ; real CNS value from before simulated dive | |
53 ENDC ; used: 8 byte, remaining: 8 byte | 54 ENDC ; used: 8 byte, remaining: 8 byte |
54 | 55 |
55 | 56 |
56 ;---- Private local Flags ---------------------------------------------------- | 57 ;---- Private local Flags ---------------------------------------------------- |
57 | 58 |
85 ; btfsc reset_timebase ; has the ISR confirmed reset of the timebase? | 86 ; btfsc reset_timebase ; has the ISR confirmed reset of the timebase? |
86 ; bra $-2 ; NO - not yet, loop waiting for the ISR | 87 ; bra $-2 ; NO - not yet, loop waiting for the ISR |
87 call deco_push_tissues_to_vault ; back-up the state of the real tissues (C-code) | 88 call deco_push_tissues_to_vault ; back-up the state of the real tissues (C-code) |
88 banksel common ; back to bank common | 89 banksel common ; back to bank common |
89 | 90 |
91 MOVII int_O_CNS_current,real_CNS ; memorize real CNS value from before simulated dive | |
92 | |
90 rcall deco_calculate ; calculate deco plan | 93 rcall deco_calculate ; calculate deco plan |
94 | |
91 btfss decoplan_abort ; was the deco plan calculation aborted? | 95 btfss decoplan_abort ; was the deco plan calculation aborted? |
92 rcall deco_results ; NO - show results | 96 rcall deco_results ; NO - show results |
93 | 97 |
94 movff simulator_time,char_I_dive_interval ; get the deco calculator runtime | 98 movff simulator_time,char_I_dive_interval ; get the deco calculator runtime |
95 call deco_pull_tissues_from_vault ; restore the status of the real tissues (C-code) | 99 call deco_pull_tissues_from_vault ; restore the status of the real tissues (C-code) |
125 | 129 |
126 ; initialization of the deco engine | 130 ; initialization of the deco engine |
127 btfsc update_surface_pressure ; is there a pending surface pressure update? | 131 btfsc update_surface_pressure ; is there a pending surface pressure update? |
128 bra $-2 ; YES - loop waiting for the ISR to kick in | 132 bra $-2 ; YES - loop waiting for the ISR to kick in |
129 | 133 |
130 ; set mode and gases | |
131 call dive_boot_oc_bail ; basic setup for all modes, also clears bailout_mode | |
132 | |
133 IFDEF _ccr_pscr | |
134 btfsc FLAG_oc_mode ; in OC mode? | |
135 call dive_boot_oc ; YES - set up OC mode | |
136 btfss FLAG_oc_mode ; in OC mode? | |
137 call dive_boot_cc ; NO - set up CCR/pSCR mode | |
138 ELSE | |
139 call dive_boot_oc ; set up OC mode | |
140 ENDIF | |
141 | |
142 ; set absolute pressure at selected depth | 134 ; set absolute pressure at selected depth |
143 movff char_I_bottom_depth,WREG ; get selected depth in meters | 135 movff char_I_bottom_depth,WREG ; get selected depth in meters |
144 mullw .100 ; multiply with 100 to get relative pressure in mbar | 136 movwf depth_meter ; set depth for check_gas_best code |
137 mullw .100 ; multiply depth with 100 to get relative pressure in mbar | |
145 movff int_I_pres_surface+0,WREG ; low byte - get surface pressure to WREG | 138 movff int_I_pres_surface+0,WREG ; low byte - get surface pressure to WREG |
146 addwf PRODL,W ; - add relative pressure | 139 addwf PRODL,W ; - add relative pressure |
147 movff WREG,int_I_pres_respiration+0 ; - store as absolute pressure at depth | 140 movff WREG,int_I_pres_respiration+0 ; - store as absolute pressure at depth |
148 movff int_I_pres_surface+1,WREG ; high byte - get surface pressure to WREG | 141 movff int_I_pres_surface+1,WREG ; high byte - get surface pressure to WREG |
149 addwfc PRODH,W ; - add relative pressure | 142 addwfc PRODH,W ; - add relative pressure |
150 movff WREG,int_I_pres_respiration+1 ; - store as absolute pressure at depth | 143 movff WREG,int_I_pres_respiration+1 ; - store as absolute pressure at depth |
151 | 144 |
145 ; compute absolute pressure / 10, will be used by check_gas_best | |
146 MOVII int_I_pres_respiration,xA ; get absolute pressure at depth | |
147 MOVLI .10,xB ; divide by 10 | |
148 call div16x16 ; xC = xA / xB = absolute pressure / 10 | |
149 MOVII xC,pressure_abs_10 ; store result for later use | |
150 | |
151 ; set up gas / diluent to be used on bottom segment | |
152 clrf WREG ; reset the deco info vector / deco flag so that ... | |
153 movff WREG,char_O_deco_info ; ... check_gas_best will not pick any deco gases | |
154 IFDEF _ccr_pscr | |
155 clrf active_dil ; invalidate active diluent | |
156 ENDIF | |
157 clrf active_gas ; invalidate active gas | |
158 call check_gas_best ; determine best diluent and/or gas | |
159 | |
160 IFDEF _ccr_pscr | |
161 btfsc FLAG_oc_mode ; in OC mode? | |
162 bra deco_calculate_0_oc ; YES - set up OC mode | |
163 ;bra deco_calculate_0_loop ; NO - set up CCR/pSCR mode | |
164 | |
165 deco_calculate_0_loop: | |
166 movf best_dil_number,W ; get best diluent into WREG | |
167 bz deco_calculate_0_error ; any usable diluent found? if NO do error handling | |
168 call setup_dil_registers ; set-up of diluent parameters for currently breathed diluent | |
169 call deco_setup_cc_diluents ; set-up of diluent list for deco calculations | |
170 bra deco_calculate_0_com ; continue with common part | |
171 ENDIF | |
172 | |
173 deco_calculate_0_oc: | |
174 movf best_gas_number,W ; get best gas into WREG | |
175 bz deco_calculate_0_error ; any usable gas found? if NO do error handling | |
176 call setup_gas_registers ; set-up of gas parameters of currently breathed gas | |
177 call deco_setup_oc_gases ; set-up of gas list for deco calculations | |
178 bra deco_calculate_0_com ; continue with common part | |
179 | |
180 deco_calculate_0_error: | |
181 call request_speed_normal ; request switch back to normal speed | |
182 WIN_COLOR color_red ; select color for error message | |
183 TEXT_SMALL .0, .80, tNoBottomGas1 ; print error message, line 1 | |
184 TEXT_SMALL .0, .105, tNoBottomGas2 ; print error message, line 2 | |
185 bsf decoplan_abort ; set abort flag | |
186 call wait_1s ; wait up to a full second | |
187 call wait_1s ; wait a full second | |
188 call wait_1s ; wait another full second | |
189 bcf switch_left ; clear potential button event | |
190 return ; return to deco calculator main function | |
191 | |
192 deco_calculate_0_com: | |
152 ; set deco stop settings | 193 ; set deco stop settings |
153 movlw deco_distance ; get deco distance safety factor | |
154 movff WREG,char_I_deco_distance ; write deco distance safety factor to deco engine | |
155 movff opt_last_stop,char_I_depth_last_deco ; write last stop depth to deco engine | 194 movff opt_last_stop,char_I_depth_last_deco ; write last stop depth to deco engine |
156 | 195 |
157 ; set GF factors | 196 ; set GF factors |
158 movff opt_GF_low, char_I_GF_Low_percentage ; load normal GF factors by default | 197 movff opt_GF_low, char_I_GF_Low_percentage ; load normal GF factors by default |
159 movff opt_GF_high,char_I_GF_High_percentage ; ... | 198 movff opt_GF_high,char_I_GF_High_percentage ; ... |
196 ; configure the deco engine - char_O_deco_status | 235 ; configure the deco engine - char_O_deco_status |
197 movff char_O_deco_status,lo ; get the configuration set by dive_boot_oc / dive_boot_cc | 236 movff char_O_deco_status,lo ; get the configuration set by dive_boot_oc / dive_boot_cc |
198 bcf lo,DECO_START_NORM ; clear flag for normal plan mode | 237 bcf lo,DECO_START_NORM ; clear flag for normal plan mode |
199 bcf lo,DECO_START_ALT ; clear flag for alternative plan mode | 238 bcf lo,DECO_START_ALT ; clear flag for alternative plan mode |
200 bsf lo,DECO_INITIALIZE ; set flag for once-per-dive initialization | 239 bsf lo,DECO_INITIALIZE ; set flag for once-per-dive initialization |
240 bsf lo,DECO_CALCULATOR_MODE ; signal that the deco engine is run from the deco calculator | |
201 bcf lo,DECO_BAILOUT_FLAG ; no gas switches before first deco stop | 241 bcf lo,DECO_BAILOUT_FLAG ; no gas switches before first deco stop |
202 bcf lo,DECO_ASCENT_FLAG ; no delayed ascent | 242 bcf lo,DECO_ASCENT_FLAG ; no delayed ascent |
203 movff lo,char_O_deco_status ; bank-safe copy to deco engine control | 243 movff lo,char_O_deco_status ; bank-safe copy to deco engine control |
204 | 244 |
205 deco_calculate_redo: | 245 deco_calculate_redo: |
211 WIN_COLOR color_lightblue ; select color for abort label | 251 WIN_COLOR color_lightblue ; select color for abort label |
212 TEXT_SMALL .1,.215, tAbort ; print abort label | 252 TEXT_SMALL .1,.215, tAbort ; print abort label |
213 WIN_COLOR color_white ; select color for title and progress outputs | 253 WIN_COLOR color_white ; select color for title and progress outputs |
214 TEXT_SMALL .0, .40, tCalculating ; print "Calculating..." | 254 TEXT_SMALL .0, .40, tCalculating ; print "Calculating..." |
215 | 255 |
216 ; calculated the surface interval | 256 ; calculate the surface interval |
217 TSTOSS opt_surface_interval ; surface interval > 0 ? | 257 TSTOSS opt_surface_interval ; surface interval > 0 ? |
218 bra deco_calculate_bottom ; NO - continue with bottom segment | 258 bra deco_calculate_bottom ; NO - continue with bottom segment |
219 TEXT_SMALL .20,.75, tCalcSurfInter ; YES - print what we are doing | 259 TEXT_SMALL .20,.75, tCalcSurfInter ; YES - print what we are doing |
220 movff opt_surface_interval,char_I_dive_interval ; - copy surface interval to deco engine | 260 movff opt_surface_interval,char_I_dive_interval ; - copy surface interval to deco engine |
221 call deco_calc_dive_interval ; - calculate surface interval (C-code) | 261 call deco_calc_dive_interval ; - calculate surface interval (C-code) |
225 deco_calculate_bottom: | 265 deco_calculate_bottom: |
226 ; advance tissues by selected bottom time, | 266 ; advance tissues by selected bottom time, |
227 ; char_I_sim_advance_time is cleared by deco engine after execution | 267 ; char_I_sim_advance_time is cleared by deco engine after execution |
228 movff char_I_bottom_time,char_I_sim_advance_time | 268 movff char_I_bottom_time,char_I_sim_advance_time |
229 | 269 |
230 TEXT_SMALL .20,.100, tCalcBotSeg ; print what we are doing | 270 TEXT_SMALL .20,.100,tCalcBotSeg ; print what we are doing |
231 | 271 |
232 ; invoke the deco engine once to condition the real tissues | 272 ; invoke the deco engine once to condition the real tissues |
233 ; to their pressure state at the end of the bottom segment | 273 ; to their pressure state at the end of the bottom segment |
234 call deco_calc_hauptroutine ; (C-code) | 274 call deco_calc_hauptroutine ; (C-code) |
235 banksel common | 275 banksel common |
237 IFDEF _ccr_pscr | 277 IFDEF _ccr_pscr |
238 ; conditional switch to bailout mode | 278 ; conditional switch to bailout mode |
239 btfss bailout_mode ; shall calculate a bailout plan? | 279 btfss bailout_mode ; shall calculate a bailout plan? |
240 bra deco_calculate_ascent ; NO - skip next | 280 bra deco_calculate_ascent ; NO - skip next |
241 | 281 |
242 call dive_boot_oc ; YES - switch to OC mode and gases | 282 call dive_boot_oc ; YES - switch to OC mode, configure OC gases and switch to gas set as 'First' |
243 movff char_O_main_status,hi ; - bank-safe copy from deco engine control (main status) | 283 movff char_O_main_status,hi ; - bank-safe copy from deco engine control (main status) |
244 bcf hi,DECO_BOTTOM_FLAG ; - exclude bottom segment from gas needs, i.e. calculate ascent needs only | 284 bcf hi,DECO_BOTTOM_FLAG ; - exclude bottom segment from gas needs, i.e. calculate ascent needs only |
245 movff hi,char_O_main_status ; - bank-safe copy back to deco engine control | 285 movff hi,char_O_main_status ; - bank-safe copy back to deco engine control |
246 movff char_O_deco_status,lo ; - bank-safe copy from deco engine control (deco status) | 286 movff char_O_deco_status,lo ; - bank-safe copy from deco engine control (deco status) |
247 bsf lo,DECO_BAILOUT_FLAG ; - allow gas switches before first deco stop | 287 bsf lo,DECO_BAILOUT_FLAG ; - allow gas switches before first deco stop |
258 movff lo,char_O_deco_status ; bank-safe copy back to deco engine control | 298 movff lo,char_O_deco_status ; bank-safe copy back to deco engine control |
259 TEXT_SMALL .20,.150, tCalcAscent ; print what we are doing | 299 TEXT_SMALL .20,.150, tCalcAscent ; print what we are doing |
260 deco_calculate_loop: | 300 deco_calculate_loop: |
261 btfsc switch_left ; was the left button pressed? | 301 btfsc switch_left ; was the left button pressed? |
262 bra deco_calculate_abort ; YES - set abort flag, do some clean-up and return | 302 bra deco_calculate_abort ; YES - set abort flag, do some clean-up and return |
263 call deco_calc_hauptroutine ; NO - invoke the deco engine so that it can do the deco calculation (C-code) | 303 call deco_calc_hauptroutine ; NO - invoke the deco engine so that it can do the deco calculation (C-code) |
264 banksel common ; - back to bank common | 304 banksel common ; - back to bank common |
265 movff char_O_depth_sim,lo ; - get the depth reached (in meters) | 305 movff char_O_depth_sim,lo ; - get the depth reached (in meters) |
266 WIN_SMALL .70,.150 ; - set output position | 306 WIN_SMALL .75,.150 ; - set output position |
267 output_8 ; - print depth reached (in meters) | 307 output_8 ; - print depth reached (in meters) |
268 STRCAT " m" ; - print unit (meters) | 308 STRCAT " m" ; - print unit (meters) |
269 btg decoplan_toggleflag ; - toggle the toggle flag | 309 btg decoplan_toggleflag ; - toggle the toggle flag |
270 btfsc decoplan_toggleflag ; - toggle flag set? | 310 btfsc decoplan_toggleflag ; - toggle flag set? |
271 bra deco_calculate_loop_1 ; YES - print ". " | 311 bra deco_calculate_loop_1 ; YES - print ". " |
325 | 365 |
326 ; print duration | 366 ; print duration |
327 WIN_LEFT .135 | 367 WIN_LEFT .135 |
328 lfsr FSR2,buffer | 368 lfsr FSR2,buffer |
329 movff hi,lo | 369 movff hi,lo |
330 output_99 ; stop entries are 99 min max. | 370 output_99dd ; stop entries are 99 minutes at max., prints double dots if duration is zero |
331 STRCAT_PRINT "'" | 371 STRCAT_PRINT "'" |
332 | 372 |
333 ; draw the bar graph used for deco stops (lo = minutes) | 373 ; draw the bar graph used for deco stops (lo = minutes) |
334 incf win_top,F | 374 incf win_top,F |
335 movlw .19 | 375 movlw .19 |
336 movwf win_height | 376 movwf win_height |
337 movlw .118 | 377 movlw .118 |
338 movwf win_leftx2 ; column left (0-159) | 378 movwf win_leftx2 ; column left (0-159) |
339 MOVLI .16,win_width ; column max width | 379 MOVLI .16,win_width ; column max width |
340 ; movlw .16 ; limit length to max. column width - not needed, done by TFT_box | |
341 ; cpfslt lo | |
342 ; movwf lo | |
343 incf lo,W ; add 1 for a minimum visible active bargraph area | 380 incf lo,W ; add 1 for a minimum visible active bargraph area |
344 movwf win_bargraph ; set width of the active bargraph area | 381 movwf win_bargraph ; set width of the active bargraph area |
345 call TFT_box ; draw bargraph | 382 call TFT_box ; draw bargraph |
346 | 383 |
347 ; restore win_top | 384 ; restore win_top |
348 call TFT_standard_color | 385 call TFT_standard_color |
349 decf win_top,F ; restore win_top | 386 decf win_top,F ; restore win_top |
350 return | 387 return |
351 | 388 |
352 ;----------------------------------------------------------------------------- | |
353 ; Clear unused area below last stop | |
354 ; Inputs: win_top : last used area | |
355 ; | |
356 deco_plan_show_clear_bottom: | |
357 movf win_top,W ; get back from bank0 | |
358 sublw .239 ; bottom row in planning | |
359 movwf win_height | |
360 | |
361 WIN_LEFT .85 ; full dive menu width | |
362 MOVLI .75,win_width ; .159-.85+.1 | |
363 | |
364 clrf win_color1 ; fill with black | |
365 clrf win_color2 | |
366 | |
367 goto TFT_box ; and return | |
368 | 389 |
369 ;----------------------------------------------------------------------------- | 390 ;----------------------------------------------------------------------------- |
370 ; Display the deco plan (simulator) | 391 ; Display the deco plan (simulator) |
371 ; Inputs: char_O_deco_table (array of stop times, in minutes) | 392 ; Inputs: char_O_deco_table (array of stop times, in minutes) |
372 ; decoplan_page = page number. | 393 ; decoplan_page = page number. |
381 bra deco_results_page_2 | 402 bra deco_results_page_2 |
382 ENDIF | 403 ENDIF |
383 deco_results_page_1: | 404 deco_results_page_1: |
384 TEXT_SMALL .80,.1, tDivePlan | 405 TEXT_SMALL .80,.1, tDivePlan |
385 deco_results_page_2: | 406 deco_results_page_2: |
386 movff char_O_deco_depth,WREG ; get depth of the first deco stop | 407 movff char_O_deco_info,WREG ; get the deco info vector |
387 iorwf WREG ; is there at least one deco stop? | 408 btfsc WREG,deco_stops ; are there deco stops? |
388 bnz deco_plan_show_1 ; YES | 409 bra deco_plan_show_1 ; YES |
389 | 410 |
390 ;---- no deco -------------------------------------------------------- | 411 ;---- no deco -------------------------------------------------------- |
391 call TFT_standard_color | 412 call TFT_standard_color |
392 TEXT_SMALL .80, .25, tNoDeco | 413 TEXT_SMALL .80, .25, tNoDeco |
393 | 414 |
394 ; output of remaining NDL time | 415 ; output of remaining NDL time |
395 WIN_SMALL .80, .50 ; same line as bottom time | 416 WIN_SMALL .80, .50 ; same line as bottom time |
417 PUTC "+" | |
396 movff char_O_NDL_norm,lo ; get NDL time in normal plan | 418 movff char_O_NDL_norm,lo ; get NDL time in normal plan |
397 output_8 | 419 bsf leftbind |
420 output_8 | |
421 bcf leftbind | |
398 PUTC "'" | 422 PUTC "'" |
399 PUTC " " | 423 PUTC " " |
400 STRCAT_TEXT_PRINT tNDLleft ; "left" | 424 STRCAT_TEXT_PRINT tNDLleft ; "NDL" |
401 | 425 |
402 bsf decoplan_last_stop_shown | 426 bsf decoplan_last_stop_shown |
403 return | 427 return |
404 | 428 |
405 ;---- deco stops --------------------------------------------------------- | 429 ;---- deco stops --------------------------------------------------------- |
448 ; check if next stop is end-of-list? | 472 ; check if next stop is end-of-list? |
449 movf decoplan_gindex,W | 473 movf decoplan_gindex,W |
450 movf PLUSW0,W ; char_O_deco_depth[decoplan_gindex] | 474 movf PLUSW0,W ; char_O_deco_depth[decoplan_gindex] |
451 bz deco_plan_show_99 ; end of list | 475 bz deco_plan_show_99 ; end of list |
452 | 476 |
453 ; display the message "more..." | |
454 rcall deco_plan_show_clear_bottom ; clear from next line | |
455 | |
456 call TFT_standard_color | 477 call TFT_standard_color |
457 TEXT_SMALL .88, .220, tMore | 478 WIN_SMALL .135,.212 |
479 STRCAT_PRINT ">>>" | |
458 return | 480 return |
459 | 481 |
460 deco_plan_show_99: | 482 deco_plan_show_99: |
461 bsf decoplan_last_stop_shown ; nothing more in table to display | 483 bsf decoplan_last_stop_shown ; nothing more in table to display |
462 rcall deco_plan_show_clear_bottom ; clear from next line | |
463 call TFT_standard_color | 484 call TFT_standard_color |
464 return | 485 return |
465 | 486 |
466 ;============================================================================= | 487 ;============================================================================= |
467 ; Show Deco Calculation Results | 488 ; Show Deco Calculation Results |
468 ; | 489 ; |
469 deco_results: | 490 deco_results: |
470 call TFT_ClearScreen | 491 call TFT_ClearScreen |
471 call TFT_standard_color | 492 call TFT_standard_color |
472 | 493 |
473 ; display plan parameters | 494 ; print interval |
474 WIN_SMALL .0,.25 | 495 WIN_SMALL .0,.25 |
475 STRCPY "Int. :" | 496 STRCPY "Int. :" |
476 movff char_I_dive_interval,lo | 497 movff opt_surface_interval,lo |
477 output_8 | 498 output_8 |
478 STRCAT_PRINT "'" | 499 STRCAT_PRINT "'" |
500 | |
501 ; print bottom time | |
479 WIN_SMALL .0,.50 | 502 WIN_SMALL .0,.50 |
480 STRCPY_TEXT tBtTm_short | 503 STRCPY_TEXT tBtTm_short |
481 movff char_I_bottom_time,lo | 504 movff char_I_bottom_time,lo |
482 output_8 | 505 output_8 |
483 STRCAT_PRINT "'" | 506 STRCAT_PRINT "'" |
507 | |
508 ; print bottom depth | |
484 WIN_SMALL .0,.75 | 509 WIN_SMALL .0,.75 |
485 STRCPY_TEXT tDepth | 510 STRCPY_TEXT tDepth |
486 PUTC ":" | 511 PUTC ":" |
487 movff char_I_bottom_depth,lo | 512 movff char_I_bottom_depth,lo |
488 output_8 | 513 output_8 |
489 STRCAT_PRINT "m" | 514 STRCAT_PRINT "m" |
490 WIN_SMALL .0,.105 ; set position for warnings or sat/dsat factors | 515 |
516 ; print warnings or sat/dsat factors | |
517 WIN_SMALL .0,.105 | |
491 | 518 |
492 ; check for stop table overflow | 519 ; check for stop table overflow |
493 btfss decoplan_warnings,stoptable_overflow ; check if we have a overflow warning | 520 btfss decoplan_warnings,deco_plan_incomplete ; check if deco plan is incomplete |
494 bra deco_results_0a ; NO - skip | 521 bra deco_results_0a ; NO - skip |
495 | 522 |
496 ; display overflow warning | 523 ; display overflow warning |
497 call TFT_warning_color ; YES - show overflow warning | 524 call TFT_warning_color ; YES - show overflow warning |
498 STRCAT_PRINT "incomplete" ; max 10 characters | 525 STRCAT_PRINT "incomplete" ; max 10 characters |
585 STRCAT_PRINT "'" | 612 STRCAT_PRINT "'" |
586 | 613 |
587 ; display CNS result | 614 ; display CNS result |
588 WIN_TOP .205 | 615 WIN_TOP .205 |
589 STRCPY_TEXT tCNS2 ; "CNS:" | 616 STRCPY_TEXT tCNS2 ; "CNS:" |
590 MOVII int_O_CNS_current,mpr ; get current CNS | 617 MOVII real_CNS,mpr ; recall real CNS from before simulated dive |
591 call TFT_color_code_cns ; color-code CNS output | 618 call TFT_color_code_cns ; color-code CNS output |
592 bsf leftbind | 619 bsf leftbind |
593 output_16_3 ; limit to 999 and display only (0-999) | 620 output_16_3 ; limit to 999 and display only (0-999) |
594 bcf leftbind | 621 bcf leftbind |
595 STRCAT "%\x92" ; "->" | 622 STRCAT "%\x92" ; "->" |
596 MOVII int_O_CNS_norm,mpr ; get CNS at end of dive in normal plan | 623 MOVII int_O_CNS_norm,mpr ; get CNS at end of simulated dive in normal plan |
597 call TFT_color_code_cns ; color-code CNS output | 624 call TFT_color_code_cns ; color-code CNS output |
598 bsf leftbind | 625 bsf leftbind |
599 output_16_3 ; limit to 999 and display only (0-999) | 626 output_16_3 ; limit to 999 and display only (0-999) |
600 bcf leftbind | 627 bcf leftbind |
601 STRCAT_PRINT "%" | 628 STRCAT_PRINT "%" |
604 ; loop through deco plan pages | 631 ; loop through deco plan pages |
605 deco_results_1: | 632 deco_results_1: |
606 clrf decoplan_page ; start from first page | 633 clrf decoplan_page ; start from first page |
607 bcf decoplan_pressures_shown ; when showing the gas needs, start with volumes (liter) | 634 bcf decoplan_pressures_shown ; when showing the gas needs, start with volumes (liter) |
608 deco_results_1a: | 635 deco_results_1a: |
609 WIN_BOX_BLACK .0, .239, .80, .159 ; clear the complete stop result column (top, bottom, left, right) | 636 WIN_BOX_BLACK .0, .239, .80, .159 ; clear the complete right part of the result column (top, bottom, left, right) |
610 rcall deco_results_page ; show a results page | 637 rcall deco_results_page ; show a results page |
611 incf decoplan_page,F ; increment results page number | 638 incf decoplan_page,F ; increment results page number |
612 call reset_timeout_surfmode ; reset timeout | 639 call reset_timeout_surfmode ; reset timeout |
613 bcf switch_right ; clear left-over right button event | 640 bcf switch_right ; clear left-over right button event |
614 bcf switch_left ; clear left-over left button event | 641 bcf switch_left ; clear left-over left button event |
633 IFDEF _ccr_pscr | 660 IFDEF _ccr_pscr |
634 movff char_O_deco_status,WREG ; YES - get deco calculation status | 661 movff char_O_deco_status,WREG ; YES - get deco calculation status |
635 btfss WREG,DECO_MODE_LOOP_FLAG ; - check if calculation was made for loop mode (CCR/pSCR) | 662 btfss WREG,DECO_MODE_LOOP_FLAG ; - check if calculation was made for loop mode (CCR/pSCR) |
636 bra deco_results_gas_volumes ; NO - normal OC mode or bailout mode, show gas needs | 663 bra deco_results_gas_volumes ; NO - normal OC mode or bailout mode, show gas needs |
637 bsf bailout_mode ; YES - do a 2nd deco-plan in bailout mode | 664 bsf bailout_mode ; YES - do a 2nd deco-plan in bailout mode |
638 rcall deco_calculate_redo ; - redo deco calculation | 665 call deco_pull_tissues_from_vault ; - restore the status of the real tissues (C-code) |
666 banksel common ; - back to bank common | |
667 rcall deco_calculate_redo ; - redo complete deco calculation | |
639 btfss decoplan_abort ; - was the calculation aborted? | 668 btfss decoplan_abort ; - was the calculation aborted? |
640 bra deco_results ; NO - redo display of deco stops | 669 bra deco_results ; NO - redo display of deco stops |
641 return ; YES - return to deco calculator main function | 670 return ; YES - return to deco calculator main function |
642 ENDIF | 671 ENDIF |
643 | 672 |
644 ;---- show the gas needs (OC and bailout only) --------------------------- | 673 ;---- show the gas needs (OC and bailout only) --------------------------- |
645 deco_results_gas_volumes: | 674 deco_results_gas_volumes: |
646 lfsr FSR0,int_O_gas_need_vol ; load base address of gas needs in volume | 675 lfsr FSR0,int_O_gas_need_vol ; load base address of gas needs in volume |
647 | 676 |
648 deco_results_gas_common: | 677 deco_results_gas_common: |
649 WIN_BOX_BLACK .0, .239, .80, .159 ; clear the complete stop result column (top, bottom, left, right) | 678 WIN_BOX_BLACK .0, .239, .80, .159 ; clear the complete right part of the result column (top, bottom, left, right) |
650 movlw .25 ; output row is 25 (fixed offset set here) + n*25 (line increment, see below) | 679 movlw .25 ; output row is 25 (fixed offset set here) + n*25 (line increment, see below) |
651 movwf output_row ; set fixed vertical offset for output row | 680 movwf output_row ; set fixed vertical offset for output row |
652 WIN_LEFT .80 ; set column | 681 WIN_LEFT .80 ; set column |
653 call TFT_standard_color | 682 call TFT_standard_color |
654 clrf gas_index ; initialize gas counter | 683 clrf gas_index ; initialize gas counter |